feat: add Stagehand V4 code-mode MCP spike - #2537
Closed
shrey150 wants to merge 2 commits into
Closed
Conversation
|
Contributor
Author
|
Superseded by browserbase/integrations#91, which moves the spike to the integrations repository and narrows it to a local stdio MCP plus native framework bindings. Closing this draft so implementation and review continue in one place. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
code_executerun, then preserve browser state behind an opaque logical-session handle across later calls and MCP reconnectsrun,status,reset, andclosethrough Streamable HTTP and stdio transportsstructuredContentfor broad harness compatibilitySafety status
This is a trusted-code spike, not a multi-tenant sandbox. Generated JavaScript runs as the server OS user and can access Node globals, the filesystem, network, and inherited credentials.
Unauthenticated HTTP is limited to loopback binds with strict loopback
HostandOriginvalidation. Non-loopback HTTP requires a bearer token and must sit behind trusted TLS termination.E2E Test Matrix
corepack pnpm@11.10.0 install --frozen-lockfilepnpm exec oxfmt --check packages/codemodeandpnpm exec oxlint --deny-warnings packages/codemodepnpm --filter @browserbasehq/stagehand-codemode typecheckpnpm --filter @browserbasehq/stagehand-codemode testpnpm --filter @browserbasehq/stagehand-codemode buildtsdownproduced the CLI, library, child runtime, declarations, and source mapsBROWSERBASE_API_KEY=<redacted> node packages/codemode/tests/live-smoke.mjsKnown gaps
No changeset is included because this is a private spike package and does not publish runtime behavior.
Summary by cubic
Adds a private
@browserbasehq/stagehand-codemodeMCP server and runtime to run Stagehand V4 code on Browserbase with long-lived, reusable browser sessions. Implements STG-2663 by extending V4 code mode to Browserbase with lazy session startup, handle-based reuse, and cleanup.New Features
code_executewithrun,status,reset,close; works over Streamable HTTP and stdio.run; reuses the same browser viacode_session_idacross calls and MCP reconnects.textandstructuredContent; exposespage,context,stagehand,z,consolein code.stagehand-codemodewith loopback-only default; non-loopback HTTP requiresCODEMODE_MCP_BEARER_TOKENand enforces strictHost/Originchecks.Bug Fixes
Written for commit 8d09d46. Summary will update on new commits.