Repository navigation
feat(integrations): add Grok Build integration + Experimental ACP - #2772
antonvishal wants to merge 9 commits into
Conversation
|
|
This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
All reported issues were addressed across 25 files
Architecture diagram
sequenceDiagram
participant CLI as Grok CLI (user CLI)
participant ACP as ACP Client (Stagehand)
participant AGENT as Grok Agent Process
participant FACE as Facade MCP Server (Stagehand)
participant STAGE as Stagehand Core
participant BROWSER as Browser
Note over CLI,ACP: User runs: pnpm --dir packages/integrations/grok-build start -- "task"
CLI->>ACP: runGrokBuild(instruction)
ACP->>ACP: Create disposable runtime (home, cwd, GROK_HOME, agent profile)
ACP->>AGENT: Spawn grok CLI with ACP stdio + restricted tools
ACP->>AGENT: ACP initialize
AGENT-->>ACP: Initialize response with auth methods
alt XAI_API_KEY exists
ACP->>AGENT: Authenticate via xai.api_key
else cached auth.json only
ACP->>AGENT: Authenticate via cached_token
end
ACP->>AGENT: session.new with Stagehand facade as only MCP server
AGENT->>FACE: Launch facade stdio server (via launcher binary)
FACE->>STAGE: Initialize Stagehand (lazily start browser)
STAGE->>BROWSER: Start persistent browser session
ACP->>AGENT: Prompt with task + Stagehand instructions
AGENT->>AGENT: Discover MCP tools (run, snapshot, screenshot)
AGENT->>ACP: Permission request for Stagehand tool
alt Tool is stagehand__run/snapshot/screenshot
ACP->>AGENT: Allow once
else Other tool (shell, file, etc.)
ACP->>AGENT: Reject or cancel
end
AGENT->>FACE: MCP tool call (e.g., stagehand__run)
FACE->>STAGE: Execute browser automation
STAGE->>BROWSER: Navigate, act, snapshot, screenshot
BROWSER-->>STAGE: Results
STAGE-->>FACE: Tool result
FACE-->>AGENT: Tool response
AGENT-->>ACP: Stream text messages (agent updates)
ACP-->>CLI: Final assistant response
Note over ACP,AGENT: On abort/signal
ACP->>AGENT: ACP session.cancel
ACP->>AGENT: SIGTERM to process tree
opt No graceful exit
ACP->>AGENT: SIGKILL to process tree
end
ACP->>ACP: Clean up disposable runtime directories
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 8 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Resolve overview.mdx conflicts to include both Grok Build and fx entries. Keep the screenshot base64 budget from browserbase#2791 alongside the ACP facade launcher changes. Also pass --max-screenshot-base64-bytes=60000 to the facade spawned by the ACP launcher so ACP transports get the same frame-cap protection as fx, mark BROWSERBASE_PROJECT_ID optional in the Grok Build README per browserbase#2777, and update the affected ACP arg assertions.
|
The fork branch was renamed to grok-build. GitHub closed this cross-fork PR instead of retargeting it, so the updated work continues in #2876. |
What
Adds a Grok Build example that can use Stagehand through the existing facade.
Grok Build exposes ACP rather than a TypeScript SDK for driving the agent, so this adds a small ACP runner under
integrations/core. The Grok-specific package only handles its CLI setup, authentication, and tool mapping.The ACP process runs with the user's existing Grok login or
XAI_API_KEY. The Stagehand MCP process receives only the environment variables it needs.Question for maintainers
I put the ACP runner in
integrations/corebecause it is not specific to Grok another ACP-compatible agent could use it by providing its own profile.Does that feel like the right place for it?
If ACP is something we want to support as an integration path, I can also add a general ACP docs page. For this PR, I kept the documentation focused on Grok Build.
Testing
pnpm checkSummary by cubic
Adds an experimental Grok Build integration and reusable ACP runner so one persistent Stagehand browser serves
run,snapshot, andscreenshot. Grok Build is now also available as an executable eval harness with isolated credentials, tool mounts, trajectories, and usage metrics.Integration
XAI_API_KEYor cachedgrok loginauthentication in disposable runtime directories.BROWSERBASE_PROJECT_IDremains optional.Eval harness
grok_buildfor Stagehand, Playwright MCP, and Chrome DevTools MCP surfaces.@agentclientprotocol/sdk,@xai-official/grok,smol-toml, and the private@browserbasehq/stagehand-integrations-grok-build-sdkpackage; no migrations are required.Written for commit 46a63e6. Summary will update on new commits.