Skip to content

feat(integrations): add Grok Build integration + Experimental ACP - #2772

Closed
antonvishal wants to merge 9 commits into
browserbase:mainfrom
antonvishal:acp+grok-build
Closed

antonvishal wants to merge 9 commits into
browserbase:mainfrom
antonvishal:acp+grok-build

Conversation

@antonvishal

@antonvishal antonvishal commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

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/core because 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 check
  • core integration tests
  • Grok Build tests
  • tested locally with an authenticated Grok Build install and a local browser

Summary by cubic

Adds an experimental Grok Build integration and reusable ACP runner so one persistent Stagehand browser serves run, snapshot, and screenshot. Grok Build is now also available as an executable eval harness with isolated credentials, tool mounts, trajectories, and usage metrics.

Integration

  • Supports XAI_API_KEY or cached grok login authentication in disposable runtime directories.
  • Restricts Grok to MCP discovery and invocation while disabling shell, files, subagents, plan mode, memory, and web search.
  • Applies the existing 60 KB screenshot limit to ACP-launched facades and forwards only required environment variables.
  • Adds setup documentation, navigation, and local usage instructions; BROWSERBASE_PROJECT_ID remains optional.

Eval harness

  • Registers grok_build for Stagehand, Playwright MCP, and Chrome DevTools MCP surfaces.
  • Captures native streaming tool calls, observations, trajectories, token usage, cost, cancellation, and cleanup.
  • Adds @agentclientprotocol/sdk, @xai-official/grok, smol-toml, and the private @browserbasehq/stagehand-integrations-grok-build-sdk package; no migrations are required.

Written for commit 46a63e6. Summary will update on new commits.

Review in cubic

@antonvishal
antonvishal requested a review from a team as a code owner August 18, 2026 16:38
@changeset-bot

changeset-bot Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 46a63e6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run.
Approving the latest commit mirrors it into an internal PR owned by the approver.
If new commits are pushed later, the internal PR stays open but is marked stale until someone approves the latest external commit and refreshes it.

@github-actions github-actions Bot added external-contributor Tracks PRs mirrored from external contributor forks. external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. labels Aug 18, 2026
@socket-security

socket-security Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​xai-official/​grok@​1.0.5911008796100
Addednpm/​@​agentclientprotocol/​sdk@​1.3.01001009498100

View full report

@antonvishal antonvishal changed the title Add Grok Build integration feat(integrations): add Grok Build integration Aug 18, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/integrations/core/src/acp/agent-process.ts Outdated
Comment thread packages/integrations/core/src/acp/facade-launcher.ts Outdated
Comment thread packages/integrations/grok-build/src/agent.ts Outdated
Comment thread packages/integrations/grok-build/README.md Outdated
Comment thread packages/docs/v4/integrations/grok-build.mdx Outdated
Comment thread packages/docs/v4/integrations/grok-build.mdx
Comment thread packages/integrations/core/src/acp/facade-launcher.ts Outdated
Comment thread packages/integrations/core/src/acp/env.ts Outdated
Comment thread packages/docs/v4/integrations/grok-build.mdx Outdated
Comment thread packages/integrations/grok-build/tests/agent.test.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 8 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/integrations/core/src/acp/agent-process.ts Outdated
Comment thread packages/integrations/grok-build/src/agent.ts Outdated
@antonvishal antonvishal changed the title feat(integrations): add Grok Build integration feat(integrations): add Grok Build integration + Experimental ACP Aug 19, 2026
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.
@antonvishal antonvishal closed this Sep 2, 2026
@antonvishal
antonvishal deleted the acp+grok-build branch September 2, 2026 11:02
@antonvishal

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. external-contributor Tracks PRs mirrored from external contributor forks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant