Skip to content

[feat]: expose optional extensionCdpUrl param on localBrowser.connect() in TS - #3253

Merged
seanmcguire12 merged 4 commits into
evals/sydney-runkle-extension-cdp-urlfrom
localbrowser-ext-url-ts
Oct 19, 2026
Merged

seanmcguire12 merged 4 commits into
evals/sydney-runkle-extension-cdp-urlfrom
localbrowser-ext-url-ts

Conversation

@seanmcguire12

@seanmcguire12 seanmcguire12 commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

why

  • this allows users to specify a CDP url that the extension will use for its loopback/in-browser connection

what changed

  • exposed extensionCdpUrl on localBrowser.connect()

test plan

  • added unit tests ensuring the URL gets correctly propagated through the protocol

Summary by cubic

Adds an optional extensionCdpUrl param to localBrowser.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:// or wss:// 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.

View guided diff Turn on auto-fix

@changeset-bot

changeset-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9bf9abf

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

This PR includes changesets to release 21 packages
Name Type
@browserbasehq/stagehand Minor
browse Patch
@browserbasehq/stagehand-examples Patch
@browserbasehq/stagehand-integrations-claude-cua-sdk Patch
@browserbasehq/stagehand-integrations Patch
@browserbasehq/eve Patch
@browserbasehq/stagehand-integrations-gemini-cua-sdk 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-example-cursor-facade 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

@seanmcguire12
seanmcguire12 changed the base branch from main to evals/sydney-runkle-extension-cdp-url October 19, 2026 18:15

@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.

1 issue found across 14 files

Confidence score: 5/5

  • .changeset/ts-extension-cdp-url.md says extensionCdpUrl must 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
Loading

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

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread .changeset/ts-extension-cdp-url.md Resolved

@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.

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
Loading

View guided diff | Turn on auto-fix | Re-trigger cubic

@seanmcguire12
seanmcguire12 added this pull request to stack #3258 October 19, 2026 18:58
@seanmcguire12
seanmcguire12 force-pushed the localbrowser-ext-url-ts branch from a39de3a to 9bf9abf Compare October 19, 2026 19:34
@seanmcguire12
seanmcguire12 merged commit 6bf4146 into main Oct 19, 2026
23 of 26 checks passed
@seanmcguire12
seanmcguire12 deleted the localbrowser-ext-url-ts branch October 19, 2026 19:47
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants