Repository navigation
feat(sdk): add Browserbase clientOptions to launch and connect - #3118
Conversation
…ython) Let callers tune the Browserbase SDK client Stagehand builds for session and extension management (timeout, retries, default headers/query; TS also fetch) without handing over a client instance. apiKey/baseUrl stay top-level so one key authenticates both Browserbase and the Stagehand runtime. Go is exempted from parity for now since it does not use the official Browserbase SDK.
🦋 Changeset detectedLatest commit: b94c694 The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 packages
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 |
Keep this PR TypeScript-only; exempt Python from client_options parity until the stacked Python PR lands.
There was a problem hiding this comment.
Review completed against the latest diff
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 12 files
Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.
Turn on auto-fix | Re-trigger cubic
seanmcguire12
left a comment
There was a problem hiding this comment.
left some comments above. non blocking but i would address
There was a problem hiding this comment.
All reported issues were addressed across 13 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Matches TypeScript (Record<string, string | undefined>) and Go (map[string]string); None and non-string values are now rejected by the strict model before any request.
…d Python #3122 added an integration page with TypeScript and Python tabs only; the integration has no Go SDK, so the all-languages tab rule failed every PR. Add an explicit per-page language list instead of a placeholder Go tab.
…nt-options # Conflicts: # packages/docs/tests/sdk-reference.test.ts
) # why Stacked on #3119 (Python), which is stacked on #3118 (TypeScript). Those PRs add Browserbase client options to `browserbase.launch()` / `browserbase.connect()` in TS and Python. This PR adds the Go equivalent, so the three SDKs are at parity again and the parity test no longer needs a Go exemption. # what changed - New `BrowserbaseClientOptions` struct, set as `ClientOptions *BrowserbaseClientOptions` on both `BrowserbaseLaunchOptions` and `BrowserbaseConnectOptions`: - `Timeout time.Duration`: applies to each attempt; 0 keeps the 60s default. - `MaxRetries *int`: nil keeps the default of 2. - `DefaultHeaders map[string]string`, `DefaultQuery map[string]string`. - `HTTPClient *http.Client`: owned by the caller and never modified. - Go talks to Browserbase over its own `net/http` client, so the internal options it already had (HTTP client, max retries) are now exposed, plus headers and query. - The timeout is applied per attempt through the request context, both for the default client and for a client the caller passes in, and it also covers reading the response body. The default client no longer sets `http.Client.Timeout` itself. If an attempt times out, only requests that are safe to resend (retrieve, release, delete) are retried, each with a new deadline. Creates fail immediately. - Negative `Timeout` or `MaxRetries`, invalid header names, and header values containing control characters are rejected before any request is sent. - `ClientOptions` is never sent in the session-create body; a test checks the body contents. - Removes `pendingGoBrowserFields` from the cross-language parity test. - Docs: the client-options section is a TypeScript / Python / Go tab group again. - Adds a minor changeset for `@browserbasehq/stagehand-go`. This PR is the only change in the stack that releases Go. # header precedence Same rule as TS and Python: `DefaultHeaders` override Stagehand's own headers on conflict, including `X-BB-API-Key` and `User-Agent`. Both Browserbase SDKs apply caller default headers last; this was checked in their source (`@browserbasehq/sdk` `index.js` `defaultHeaders`, and the Python `_base_client`). Go still rejects invalid header names or values before sending. # test plan - [x] `go vet`; gofmt (prints nothing); `go test -race` on every package except examples; generator `--check`; `scripts/check-examples.sh` - [x] New `browserbase_client_options_test.go` uses `httptest` servers to cover: - options reaching requests, and later changes to the caller's maps having no effect; - default headers and query on POST and GET, with caller defaults overriding Stagehand's headers (mutation-checked); - `MaxRetries` set to 0 and 1, and the default; - the per-attempt timeout, including a retry getting a new deadline and the deadline covering the response body; - a caller `HTTPClient` being used and left unmodified; - invalid options failing with zero requests reaching the server, on both launch and connect; - full launch and connect through the real factory. - [x] Mutation-checked: with the per-attempt deadline removed, the timeout test fails in about 5s with a clear message. - [x] `rules/ast-grep` parity tests (Go exemption removed), docs tests, the TS suite, oxfmt, oxlint, `check-changesets` - [ ] Plain `go test ./...` fails only because `packages/sdk-go/examples` doesn't build as a single package; that was already the case. CI and the justfile exclude `/examples`. - [ ] No live Browserbase session was launched
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @browserbasehq/[email protected] ### Minor Changes - [#2821](#2821) [`a237c77`](a237c77) Thanks [@shrey150](https://github.com/shrey150)! - Replace the Eve extension's browser and web tools with Stagehand V4 `run`, `snapshot`, and `screenshot`. ### Patch Changes - [#3115](#3115) [`7abca76`](7abca76) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - update the Eve peer dependency to ^0.71.2 to use upstream security fixes. Requires Eve 0.71.2 or later within the 0.71.x release line. - Updated dependencies [[`34edfa3`](34edfa3), [`a837acf`](a837acf), [`4da1a21`](4da1a21), [`5802f59`](5802f59), [`819db28`](819db28), [`0210688`](0210688), [`666b6fa`](666b6fa), [`f3543d3`](f3543d3), [`f2060a6`](f2060a6), [`1562d35`](1562d35), [`7d8dcef`](7d8dcef), [`476658b`](476658b), [`70f4e91`](70f4e91)]: - @browserbasehq/[email protected] ## @browserbasehq/[email protected] ### Minor Changes - [#3030](#3030) [`34edfa3`](34edfa3) Thanks [@supremeboxlogos](https://github.com/supremeboxlogos)! - Export browser pages as PDF bytes in TypeScript, Python, and Go, with configurable print settings and timeouts, and optional local file saving in TypeScript and Python. - [#3118](#3118) [`a837acf`](a837acf) Thanks [@miguelg719](https://github.com/miguelg719)! - Add `clientOptions` to `browserbase.launch()` and `browserbase.connect()`. Thanks to [@pr1m8](https://github.com/pr1m8) for the original proposal that motivated this feature. - [#3083](#3083) [`666b6fa`](666b6fa) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - expose a timeout option for page.snapshot() across all sdks, defaulting to 20 seconds. set it to 0 for unlimited execution. one budget covers the whole snapshot capture. - [#3140](#3140) [`f2060a6`](f2060a6) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - automatically discover Stagehand extensions when connecting to browsers. deprecate & ignore extension IDs passed into .connect(). - [#2916](#2916) [`476658b`](476658b) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add page level hooks for webmcp tools added and webmcp tools removed events. ### Patch Changes - [#3045](#3045) [`4da1a21`](4da1a21) Thanks [@github-actions](https://github.com/apps/github-actions)! - Keep telemetry disabled unless an OTLP traces endpoint is explicitly configured. - [#2893](#2893) [`5802f59`](5802f59) Thanks [@miguelg719](https://github.com/miguelg719)! - Bound experimental batch and RPC deadlines so callers can stop waiting without replaying actions or accepting late capture state. - [#2894](#2894) [`819db28`](819db28) Thanks [@miguelg719](https://github.com/miguelg719)! - Add configurable bounded CDP heartbeats and sanitized disconnect diagnostics with cleanup on shutdown. - [#2892](#2892) [`0210688`](0210688) Thanks [@miguelg719](https://github.com/miguelg719)! - Release a newly created Browserbase session when initial attachment fails, and support upload retries - [#2978](#2978) [`f3543d3`](f3543d3) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Fix locator failures when entering loading iframes, and correctly target iframe elements when an XPath ends at the iframe. - [#3033](#3033) [`1562d35`](1562d35) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add per-call locator timeouts across TypeScript, Python, & Go. one timeout covers frame readiness, element lookup, & execution, including typing delays & highlight duration. the default is 20 seconds. setting timeout to 0 disables it. - [#3146](#3146) [`7d8dcef`](7d8dcef) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Make selector waits include frame readiness in their timeout, support unlimited waits with `timeout: 0`, and clean up observers when the wait ends. - [#3052](#3052) [`70f4e91`](70f4e91) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Match native XPath semantics for `text()` predicates when a shadow root routes locators through the composed-tree parser ## @browserbasehq/[email protected] ### Minor Changes - [#3030](#3030) [`34edfa3`](34edfa3) Thanks [@supremeboxlogos](https://github.com/supremeboxlogos)! - Export browser pages as PDF bytes in TypeScript, Python, and Go, with configurable print settings and timeouts, and optional local file saving in TypeScript and Python. - [#3083](#3083) [`666b6fa`](666b6fa) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - expose a timeout option for page.snapshot() across all sdks, defaulting to 20 seconds. set it to 0 for unlimited execution. one budget covers the whole snapshot capture. - [#2916](#2916) [`476658b`](476658b) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add page level hooks for webmcp tools added and webmcp tools removed events. ### Patch Changes - [#3045](#3045) [`4da1a21`](4da1a21) Thanks [@github-actions](https://github.com/apps/github-actions)! - Keep telemetry disabled unless an OTLP traces endpoint is explicitly configured. - [#2896](#2896) [`7919934`](7919934) Thanks [@miguelg719](https://github.com/miguelg719)! - Snapshot references remain valid across same-origin and out-of-process frame captures - [#2978](#2978) [`f3543d3`](f3543d3) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Fix locator failures when entering loading iframes, and correctly target iframe elements when an XPath ends at the iframe. - [#3033](#3033) [`1562d35`](1562d35) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add per-call locator timeouts across TypeScript, Python, & Go. one timeout covers frame readiness, element lookup, & execution, including typing delays & highlight duration. the default is 20 seconds. setting timeout to 0 disables it. - [#3146](#3146) [`7d8dcef`](7d8dcef) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Make selector waits include frame readiness in their timeout, support unlimited waits with `timeout: 0`, and clean up observers when the wait ends. - [#3052](#3052) [`70f4e91`](70f4e91) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Match native XPath semantics for `text()` predicates when a shadow root routes locators through the composed-tree parser ## @browserbasehq/[email protected] ### Minor Changes - [#3030](#3030) [`34edfa3`](34edfa3) Thanks [@supremeboxlogos](https://github.com/supremeboxlogos)! - Export browser pages as PDF bytes in TypeScript, Python, and Go, with configurable print settings and timeouts, and optional local file saving in TypeScript and Python. - [#3083](#3083) [`666b6fa`](666b6fa) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - expose a timeout option for page.snapshot() across all sdks, defaulting to 20 seconds. set it to 0 for unlimited execution. one budget covers the whole snapshot capture. - [#2916](#2916) [`476658b`](476658b) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add page level hooks for webmcp tools added and webmcp tools removed events. ### Patch Changes - [#3045](#3045) [`4da1a21`](4da1a21) Thanks [@github-actions](https://github.com/apps/github-actions)! - Keep telemetry disabled unless an OTLP traces endpoint is explicitly configured. - [#3033](#3033) [`1562d35`](1562d35) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add per-call locator timeouts across TypeScript, Python, & Go. one timeout covers frame readiness, element lookup, & execution, including typing delays & highlight duration. the default is 20 seconds. setting timeout to 0 disables it. ## @browserbasehq/[email protected] ### Minor Changes - [#3030](#3030) [`34edfa3`](34edfa3) Thanks [@supremeboxlogos](https://github.com/supremeboxlogos)! - Export browser pages as PDF bytes in TypeScript, Python, and Go, with configurable print settings and timeouts, and optional local file saving in TypeScript and Python. - [#3123](#3123) [`100e201`](100e201) Thanks [@miguelg719](https://github.com/miguelg719)! - Add `ClientOptions` to `LaunchBrowserbase` and `ConnectBrowserbase`. - [#3083](#3083) [`666b6fa`](666b6fa) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - expose a timeout option for page.snapshot() across all sdks, defaulting to 20 seconds. set it to 0 for unlimited execution. one budget covers the whole snapshot capture. - [#3140](#3140) [`f2060a6`](f2060a6) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - automatically discover Stagehand extensions when connecting to browsers. deprecate & ignore extension IDs passed into .connect(). - [#2916](#2916) [`476658b`](476658b) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add page level hooks for webmcp tools added and webmcp tools removed events. ### Patch Changes - [#3045](#3045) [`4da1a21`](4da1a21) Thanks [@github-actions](https://github.com/apps/github-actions)! - Keep telemetry disabled unless an OTLP traces endpoint is explicitly configured. - [#2896](#2896) [`7919934`](7919934) Thanks [@miguelg719](https://github.com/miguelg719)! - Snapshot references remain valid across same-origin and out-of-process frame captures - [#2978](#2978) [`f3543d3`](f3543d3) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Fix locator failures when entering loading iframes, and correctly target iframe elements when an XPath ends at the iframe. - [#3033](#3033) [`1562d35`](1562d35) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add per-call locator timeouts across TypeScript, Python, & Go. one timeout covers frame readiness, element lookup, & execution, including typing delays & highlight duration. the default is 20 seconds. setting timeout to 0 disables it. - [#3146](#3146) [`7d8dcef`](7d8dcef) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Make selector waits include frame readiness in their timeout, support unlimited waits with `timeout: 0`, and clean up observers when the wait ends. - [#3052](#3052) [`70f4e91`](70f4e91) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Match native XPath semantics for `text()` predicates when a shadow root routes locators through the composed-tree parser ## @browserbasehq/[email protected] ### Minor Changes - [#3030](#3030) [`34edfa3`](34edfa3) Thanks [@supremeboxlogos](https://github.com/supremeboxlogos)! - Export browser pages as PDF bytes in TypeScript, Python, and Go, with configurable print settings and timeouts, and optional local file saving in TypeScript and Python. - [#3118](#3118) [`a837acf`](a837acf) Thanks [@miguelg719](https://github.com/miguelg719)! - Add `client_options` to `browserbase.launch()` and `browserbase.connect()`. - [#3083](#3083) [`666b6fa`](666b6fa) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - expose a timeout option for page.snapshot() across all sdks, defaulting to 20 seconds. set it to 0 for unlimited execution. one budget covers the whole snapshot capture. - [#3140](#3140) [`f2060a6`](f2060a6) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - automatically discover Stagehand extensions when connecting to browsers. deprecate & ignore extension IDs passed into .connect(). - [#2916](#2916) [`476658b`](476658b) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add page level hooks for webmcp tools added and webmcp tools removed events. ### Patch Changes - [#3045](#3045) [`4da1a21`](4da1a21) Thanks [@github-actions](https://github.com/apps/github-actions)! - Keep telemetry disabled unless an OTLP traces endpoint is explicitly configured. - [#2978](#2978) [`f3543d3`](f3543d3) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Fix locator failures when entering loading iframes, and correctly target iframe elements when an XPath ends at the iframe. - [#3033](#3033) [`1562d35`](1562d35) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add per-call locator timeouts across TypeScript, Python, & Go. one timeout covers frame readiness, element lookup, & execution, including typing delays & highlight duration. the default is 20 seconds. setting timeout to 0 disables it. - [#3146](#3146) [`7d8dcef`](7d8dcef) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Make selector waits include frame readiness in their timeout, support unlimited waits with `timeout: 0`, and clean up observers when the wait ends. - [#3052](#3052) [`70f4e91`](70f4e91) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Match native XPath semantics for `text()` predicates when a shadow root routes locators through the composed-tree parser ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies [[`34edfa3`](34edfa3), [`a837acf`](a837acf), [`4da1a21`](4da1a21), [`5802f59`](5802f59), [`819db28`](819db28), [`0210688`](0210688), [`666b6fa`](666b6fa), [`f3543d3`](f3543d3), [`f2060a6`](f2060a6), [`1562d35`](1562d35), [`7d8dcef`](7d8dcef), [`476658b`](476658b), [`70f4e91`](70f4e91)]: - @browserbasehq/[email protected] - @browserbasehq/[email protected] ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies []: - @browserbasehq/[email protected] ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies []: - @browserbasehq/[email protected] - @browserbasehq/[email protected] ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies [[`34edfa3`](34edfa3), [`a837acf`](a837acf), [`4da1a21`](4da1a21), [`5802f59`](5802f59), [`819db28`](819db28), [`0210688`](0210688), [`666b6fa`](666b6fa), [`f3543d3`](f3543d3), [`f2060a6`](f2060a6), [`1562d35`](1562d35), [`7d8dcef`](7d8dcef), [`476658b`](476658b), [`70f4e91`](70f4e91)]: - @browserbasehq/[email protected] - @browserbasehq/[email protected] ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies []: - @browserbasehq/[email protected] - @browserbasehq/[email protected] ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies []: - @browserbasehq/[email protected] ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies [[`34edfa3`](34edfa3), [`a837acf`](a837acf), [`4da1a21`](4da1a21), [`5802f59`](5802f59), [`819db28`](819db28), [`0210688`](0210688), [`666b6fa`](666b6fa), [`f3543d3`](f3543d3), [`f2060a6`](f2060a6), [`1562d35`](1562d35), [`7d8dcef`](7d8dcef), [`476658b`](476658b), [`70f4e91`](70f4e91)]: - @browserbasehq/[email protected] ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies []: - @browserbasehq/[email protected] - @browserbasehq/[email protected] ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies []: - @browserbasehq/[email protected] ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies []: - @browserbasehq/[email protected] ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies []: - @browserbasehq/[email protected] ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies []: - @browserbasehq/[email protected] ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies [[`34edfa3`](34edfa3), [`a837acf`](a837acf), [`4da1a21`](4da1a21), [`5802f59`](5802f59), [`819db28`](819db28), [`0210688`](0210688), [`666b6fa`](666b6fa), [`f3543d3`](f3543d3), [`f2060a6`](f2060a6), [`1562d35`](1562d35), [`7d8dcef`](7d8dcef), [`476658b`](476658b), [`70f4e91`](70f4e91)]: - @browserbasehq/[email protected] - @browserbasehq/[email protected] ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies []: - @browserbasehq/[email protected] ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies []: - @browserbasehq/[email protected] ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies [[`34edfa3`](34edfa3), [`a837acf`](a837acf), [`4da1a21`](4da1a21), [`5802f59`](5802f59), [`819db28`](819db28), [`0210688`](0210688), [`666b6fa`](666b6fa), [`f3543d3`](f3543d3), [`f2060a6`](f2060a6), [`1562d35`](1562d35), [`7d8dcef`](7d8dcef), [`476658b`](476658b), [`70f4e91`](70f4e91)]: - @browserbasehq/[email protected] - @browserbasehq/[email protected] ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies []: - @browserbasehq/[email protected] ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies []: - @browserbasehq/[email protected] --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Miguel <[email protected]>
why
Sibling to #2933. That PR lets callers inject a
BrowserbaseSDK instance. This PR takes the alternative approach: Stagehand keeps building the Browserbase client, and callers pass the client's HTTP settings instead.apiKeyauthenticates both Browserbase and the Stagehand runtime. An injected client could carry a different key.extensions.deletethat depend on SDK-specific options.timeout,max_retries,default_headers,default_query) exist in both SDKs.The options are nested under
clientOptionsrather than flattened, becausebrowserbase.launch()passes unknown keys through toSessionCreateParams, which already has atimeoutfield (the session timeout in seconds).what changed
clientOptions?: BrowserbaseClientOptionsonbrowserbase.launch()andbrowserbase.connect(). The type isPick<ClientOptions, "timeout" | "maxRetries" | "defaultHeaders" | "defaultQuery" | "fetch">, validated by a strict schema.apiKeyandbaseURLare rejected inside it.BrowserbaseClientOptionsis exported.BrowserbaseConnectOptions.client_optionsis temporarily exempt for Python, until the stacked feat(sdk-python): add Browserbase client_options to launch and connect #3119 removes the exemption, and pending for Go. Go talks to Browserbase over its ownnet/httpclient rather than the official SDK.configuration/browser.mdx, TypeScript only for now) and a minor changeset for@browserbasehq/stagehand.test plan
tsc --noEmit, oxfmt, oxlint; sdk-ts unit tests andrules/ast-grepparity tests (31 files, 407 tests)@browserbasehq/sdkclient with a spyfetchand checks that the request URL,defaultQuery,defaultHeadersand API key are appliedBrowserbaseClientOptions