Skip to content

feat(sdk): allow injecting a Browserbase client - #2931

Closed
pr1m8 wants to merge 1 commit into
browserbase:mainfrom
pr1m8:browserbase-client-injection
Closed

pr1m8 wants to merge 1 commit into
browserbase:mainfrom
pr1m8:browserbase-client-injection

Conversation

@pr1m8

@pr1m8 pr1m8 commented Sep 14, 2026 •

Copy link
Copy Markdown

why

Applications that centralize Browserbase setup need to reuse an existing
@browserbasehq/sdk client when launching or attaching Stagehand browsers.

Today, browserbase.launch() and browserbase.connect() always create a new
Browserbase client. This prevents callers from supplying their own configured
Browserbase management client and endpoint.

what changed

  • Add an optional client?: Browserbase option to TypeScript
    browserbase.launch() and browserbase.connect().
  • Reuse the supplied client for Browserbase session and extension lifecycle
    operations, including session create, retrieve, release, and extension
    provisioning/cleanup.
  • Preserve existing behavior when client is omitted.
  • Keep apiKey for Stagehand runtime authentication.
  • Document that the supplied client controls Browserbase management requests;
    baseUrl is therefore not used for those requests.
  • Add TypeScript factory, lifecycle, contract, package-consumer, and
    cross-language schema-parity coverage.
  • Add a minor Changeset for @browserbasehq/stagehand.

test plan

  • pnpm build
  • pnpm fmt:check
  • pnpm check
  • pnpm test — 33 workspace tasks passed; 80 test files / 627 tests
  • Focused SDK coverage — 20 test files / 282 tests
  • Published-package consumer type fixture
  • Cross-language schema-parity test
  • Go SDK test, vet, build, generator, and example checks
  • Full just Python coverage was not run because the disposable validation
    sandbox did not include uv.
  • The Go extension-pack consistency check reports a pre-existing mismatch
    in the committed embedded extension archive; this PR changes neither
    artifact.

Summary by cubic

Adds an optional client option to browserbase.launch() and browserbase.connect() so callers can reuse an existing @browserbasehq/sdk client for session and extension lifecycle management. Previously these methods always created a new Browserbase client; now they use the supplied client, and existing behavior is unchanged when client is omitted.

  • When client is provided, it determines the Browserbase management endpoint; baseUrl is ignored for those calls.
  • apiKey still configures Stagehand runtime authentication.

Written for commit 4bc630d. Summary will update on new commits.

Review in cubic

@pr1m8
pr1m8 requested a review from a team as a code owner September 14, 2026 19:39
@changeset-bot

changeset-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4bc630d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 16 packages
Name Type
@browserbasehq/stagehand Minor
@browserbasehq/stagehand-integrations Patch
@browserbasehq/stagehand-integrations-example-eve-facade Patch
@browserbasehq/stagehand-integrations-example-pi-facade Patch
@browserbasehq/stagehand-integrations-claude-agent-sdk Patch
@browserbasehq/stagehand-integrations-example-claude-code-facade Patch
@browserbasehq/stagehand-integrations-codex-sdk Patch
@browserbasehq/stagehand-integrations-example-codex-facade Patch
@browserbasehq/stagehand-integrations-cursor-sdk Patch
@browserbasehq/stagehand-integrations-deepagents-sdk Patch
@browserbasehq/stagehand-integrations-eve-sdk Patch
@browserbasehq/stagehand-integrations-fx-sdk Patch
@browserbasehq/stagehand-integrations-mastra-sdk Patch
@browserbasehq/stagehand-integrations-example-mastra-facade Patch
@browserbasehq/stagehand-integrations-pi-sdk Patch
@browserbasehq/stagehand-integrations-example-vercel-ai-facade Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another 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 Sep 14, 2026
@github-actions github-actions Bot added external-contributor:mirrored An internal mirrored PR currently exists for this external contributor PR. and removed external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. labels Sep 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR was approved by @miguelg719 and mirrored to #2933. All further discussion should happen on that PR.

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

Labels

external-contributor:mirrored An internal mirrored PR currently exists for this external contributor PR. external-contributor Tracks PRs mirrored from external contributor forks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants