Repository navigation
[feat]: expose optional extensionCdpUrl param on localBrowser.connect() in TS - #3253
Merged
seanmcguire12 merged 4 commits intoOct 19, 2026
Merged
seanmcguire12 merged 4 commits into
seanmcguire12 merged 4 commits into
Conversation
🦋 Changeset detectedLatest commit: 9bf9abf The changes in this PR will be included in the next version bump. This PR includes changesets to release 21 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 |
seanmcguire12
changed the base branch from
main
to
evals/sydney-runkle-extension-cdp-url
October 19, 2026 18:15
Contributor
There was a problem hiding this comment.
1 issue found across 14 files
Confidence score: 5/5
.changeset/ts-extension-cdp-url.mdsaysextensionCdpUrlmust be a loopback URL, which could mislead users who use a separate WebSocket endpoint or a proxy. Update the release note to describe the separate CDP URL and proxy use.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name=".changeset/ts-extension-cdp-url.md">
<violation number="1" location=".changeset/ts-extension-cdp-url.md:5">
P3: This release note implies `extensionCdpUrl` must be a loopback URL, but the option accepts any WebSocket host and lets the extension use a separate endpoint from the client. Describe the separate CDP URL and proxy use case instead.
(Based on your team's feedback about user-visible changesets.) .</violation>
</file>
Architecture diagram
sequenceDiagram
participant Client as Client SDK
participant Factory as Browser Factory
participant CDP as CDP Client
participant Worker as Worker Init
participant Gateway as CDP Gateway (Proxy)
participant Browser as Browser/Extension
Note over Client,Extension: Local Browser Connection Flow
Client->>Factory: localBrowser.connect({cdpUrl, extensionCdpUrl?})
alt extensionCdpUrl provided
Factory->>Factory: NEW: Validate ws:// or wss:// with host
alt Invalid URL
Factory-->>Client: Throw ValidationError
else Valid URL
Factory->>CDP: connect({cdpUrl}) - client connects to gateway
CDP->>Gateway: wss://gateway/cdp?api_key=secret
Gateway-->>CDP: WebSocket ready
CDP-->>Factory: CDPClient
Factory->>Worker: Pass browserCdpUrl from extensionCdpUrl
end
else No extensionCdpUrl
Factory->>CDP: connect({cdpUrl})
CDP->>Gateway: wss://gateway/cdp?api_key=secret
Gateway-->>CDP: WebSocket ready
CDP-->>Factory: CDPClient
Factory->>Worker: No browserCdpUrl override
end
Factory-->>Client: LocalBrowser handle
Note over Client,Extension: Stagehand.create Flow
Client->>Worker: Stagehand.create({browser})
Worker->>Worker: Read cdpClient.webSocketDebuggerUrl
alt browserCdpUrl override exists
Worker->>Worker: NEW: Use workerInitMetadata.browserCdpUrl (loopback)
Worker->>Browser: stagehand.init with browser_cdp_url=ws://127.0.0.1:9300
Browser->>Browser: Extension dials loopback CDP directly
else Default behavior
Worker->>Worker: Use cdpClient.webSocketDebuggerUrl (gateway URL)
Worker->>Browser: stagehand.init with browser_cdp_url=wss://gateway/cdp?api_key=secret
Browser->>Gateway: Extension dials gateway URL (may expose credentials)
end
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Contributor
There was a problem hiding this comment.
No issues found across 6 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Client as Client App
participant LB as localBrowser.connect()
participant SC as Schema Validation
participant WF as Worker Init Metadata
participant CH as stagehandCreateParamsForWorker()
participant CDP as CDP Client
participant EXT as Stagehand Extension
Note over Client,CDP: Browser Connection Flow
Client->>LB: connect({ cdpUrl, extensionCdpUrl? })
alt extensionCdpUrl is provided
LB->>SC: Validate extensionCdpUrl
SC->>SC: Check ws:// or wss:// protocol
alt Invalid URL (http, no host, bad port)
SC-->>LB: Validation error
LB-->>Client: Reject - no connection attempted
else Valid ws/wss URL
SC-->>LB: Valid
end
else extensionCdpUrl is undefined
LB->>LB: Use default behavior
end
LB->>CDP: connect({ cdpUrl })
CDP-->>LB: CDP client
LB->>WF: Store browserCdpUrl = extensionCdpUrl ?? undefined
Client->>CH: Prepare worker init params
alt extensionCdpUrl was set
CH->>WF: Read browserCdpUrl
WF-->>CH: extensionCdpUrl value
CH->>CDP: Use browserCdpUrl as browser_cdp_url
else No extensionCdpUrl (fallback)
CH->>CDP: Get webSocketDebuggerUrl
CDP-->>CH: Client's CDP URL
CH->>CH: Use client URL as browser_cdp_url
end
CH->>EXT: init with browser_cdp_url
EXT->>EXT: Dial CDP WebSocket at browser_cdp_url
EXT-->>CH: Connection established
Note over CDP,EXT: Security boundary: gateway credentials not leaked to extension
Note over Client,EXT: End-to-end browser automation session active
seanmcguire12
force-pushed
the
localbrowser-ext-url-ts
branch
from
October 19, 2026 19:34
a39de3a to
9bf9abf
Compare
miguelg719
approved these changes
Oct 19, 2026
miguelg719
pushed a commit
that referenced
this pull request
Oct 20, 2026
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 - [#3267](#3267) [`cb9a1d1`](cb9a1d1) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add extension archive getter - [#3253](#3253) [`6bf4146`](6bf4146) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add optional `extensionCdpUrl` to `localBrowser.connect` to allow configuring the in-browser CDP url - [#3263](#3263) [`ecb2a6b`](ecb2a6b) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add `headers` to `localBrowser.connect` so CDP gateways can be authenticated without credentials in the URL - [#3183](#3183) [`901eb27`](901eb27) Thanks [@supremeboxlogos](https://github.com/supremeboxlogos)! - Add `page.waitForFunction()` to wait until a predicate in the page returns a truthy value. ### Patch Changes - [#3229](#3229) [`c6b6f27`](c6b6f27) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - skip caching for request bodies larger than 25 MB. - [#3198](#3198) [`10418f9`](10418f9) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - enable WebMCP by default for local chromium versions newer than 157 - [#3210](#3210) [`1c40ba7`](1c40ba7) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Require client transport for Browserbase Model Gateway and cache requests. - [#3209](#3209) [`17de6ea`](17de6ea) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Route Browserbase Model Gateway and cache requests through the connected SDK. ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies [[`c6b6f27`](c6b6f27), [`cb9a1d1`](cb9a1d1), [`10418f9`](10418f9), [`1c40ba7`](1c40ba7), [`17de6ea`](17de6ea), [`6bf4146`](6bf4146), [`ecb2a6b`](ecb2a6b), [`901eb27`](901eb27)]: - @browserbasehq/[email protected] ## @browserbasehq/[email protected] ### Major Changes - [#3210](#3210) [`1c40ba7`](1c40ba7) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Require client transport for Browserbase Model Gateway and cache requests. ### Minor Changes - [#3208](#3208) [`4a7c637`](4a7c637) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Support routing Browserbase Model Gateway and cache requests through the connected SDK. - [#3183](#3183) [`901eb27`](901eb27) Thanks [@supremeboxlogos](https://github.com/supremeboxlogos)! - Add the `page.wait_for_function` method. ## @browserbasehq/[email protected] ### Minor Changes - [#3208](#3208) [`4a7c637`](4a7c637) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Support routing Browserbase Model Gateway and cache requests through the connected SDK. - [#3183](#3183) [`901eb27`](901eb27) Thanks [@supremeboxlogos](https://github.com/supremeboxlogos)! - Add the `page.wait_for_function` method. ### Patch Changes - [#3229](#3229) [`c6b6f27`](c6b6f27) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - skip caching for request bodies larger than 25 MB. - [#3257](#3257) [`113ad81`](113ad81) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - honour a changed extension CDP WS URL when creating a new Stagehand instance after closing the previous one - [#3210](#3210) [`1c40ba7`](1c40ba7) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Require client transport for Browserbase Model Gateway and cache requests. ## @browserbasehq/[email protected] ### Minor Changes - [#3267](#3267) [`cb9a1d1`](cb9a1d1) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add extension archive getter - [#3265](#3265) [`a31e2da`](a31e2da) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add `Headers` to `LocalBrowserConnectOptions` so CDP gateways can be authenticated without credentials in the URL - [#3254](#3254) [`9eac212`](9eac212) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add optional `ExtensionCDPURL` to `LocalBrowserConnectOptions` to allow configuring the in-browser CDP url. - [#3183](#3183) [`901eb27`](901eb27) Thanks [@supremeboxlogos](https://github.com/supremeboxlogos)! - Add `Page.WaitForFunction` to wait until a predicate in the page returns a truthy value. ### Patch Changes - [#3229](#3229) [`c6b6f27`](c6b6f27) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - skip caching for request bodies larger than 25 MB. - [#3198](#3198) [`10418f9`](10418f9) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - enable WebMCP by default for local chromium versions newer than 157 - [#3210](#3210) [`1c40ba7`](1c40ba7) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Require client transport for Browserbase Model Gateway and cache requests. - [#3209](#3209) [`17de6ea`](17de6ea) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Route Browserbase Model Gateway and cache requests through the connected SDK. ## @browserbasehq/[email protected] ### Minor Changes - [#3260](#3260) [`2859fd5`](2859fd5) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add `headers` to `local_browser.connect` so CDP gateways can be authenticated without credentials in the URL - [#3267](#3267) [`cb9a1d1`](cb9a1d1) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add extension archive getter - [#3252](#3252) [`21e0363`](21e0363) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add `extension_cdp_url` to `local_browser.connect` for clients that reach Chrome through a proxy the extension cannot use - [#3183](#3183) [`901eb27`](901eb27) Thanks [@supremeboxlogos](https://github.com/supremeboxlogos)! - Add `page.wait_for_function()` to wait until a predicate in the page returns a truthy value. ### Patch Changes - [#3229](#3229) [`c6b6f27`](c6b6f27) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - skip caching for request bodies larger than 25 MB. - [#3198](#3198) [`10418f9`](10418f9) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - enable WebMCP by default for local chromium versions newer than 157 - [#3210](#3210) [`1c40ba7`](1c40ba7) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Require client transport for Browserbase Model Gateway and cache requests. - [#3209](#3209) [`17de6ea`](17de6ea) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Route Browserbase Model Gateway and cache requests through the connected SDK. ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies [[`c6b6f27`](c6b6f27), [`cb9a1d1`](cb9a1d1), [`10418f9`](10418f9), [`1c40ba7`](1c40ba7), [`17de6ea`](17de6ea), [`6bf4146`](6bf4146), [`ecb2a6b`](ecb2a6b), [`901eb27`](901eb27)]: - @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 [[`c6b6f27`](c6b6f27), [`cb9a1d1`](cb9a1d1), [`10418f9`](10418f9), [`1c40ba7`](1c40ba7), [`17de6ea`](17de6ea), [`6bf4146`](6bf4146), [`ecb2a6b`](ecb2a6b), [`901eb27`](901eb27)]: - @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 [[`c6b6f27`](c6b6f27), [`cb9a1d1`](cb9a1d1), [`10418f9`](10418f9), [`1c40ba7`](1c40ba7), [`17de6ea`](17de6ea), [`6bf4146`](6bf4146), [`ecb2a6b`](ecb2a6b), [`901eb27`](901eb27)]: - @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 [[`c6b6f27`](c6b6f27), [`cb9a1d1`](cb9a1d1), [`10418f9`](10418f9), [`1c40ba7`](1c40ba7), [`17de6ea`](17de6ea), [`6bf4146`](6bf4146), [`ecb2a6b`](ecb2a6b), [`901eb27`](901eb27)]: - @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 [[`c6b6f27`](c6b6f27), [`cb9a1d1`](cb9a1d1), [`10418f9`](10418f9), [`1c40ba7`](1c40ba7), [`17de6ea`](17de6ea), [`6bf4146`](6bf4146), [`ecb2a6b`](ecb2a6b), [`901eb27`](901eb27)]: - @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>
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.
why
what changed
extensionCdpUrlonlocalBrowser.connect()test plan
Summary by cubic
Adds an optional
extensionCdpUrlparam tolocalBrowser.connect()so callers can tell Stagehand's extension which CDP WebSocket to dial. Previously the extension always dialed the same URL the client connected with, which could hand gateway credentials to the browser and route extension traffic through the gateway.When unset, behavior is unchanged. The value must be a
ws://orwss://URL with a host and a port between 1 and 65535; invalid values are rejected with a validation error before any connection is attempted.Written for commit 9bf9abf. Summary will update on new commits.