fix(sdk-ts,cli): replace incompatible extension on --cdp attach
why
Two failure modes when using browse open --cdp with remote Browserbase sessions:
-
Extension path inaccessible: Sessions created without the Stagehand extension fail on
--cdpattach because the CLI tries to load the bundled extension viaExtensions.loadUnpacked, but the remote Chrome can't access the local filesystem. Error: "File path cannot be resolved." -
Incompatible extension version: Sessions created with an older Stagehand extension (e.g., from an earlier SDK version) fail because the runtime protocol versions don't match. Error: "Incompatible Stagehand runtime."
The fix addresses both: browse cloud sessions create now uploads the bundled extension by default, and the SDK auto-replaces incompatible extensions on local --cdp attach.
before / after
Remote (run on cb46fff with real BROWSERBASE_API_KEY):
# BEFORE: browse 0.12.0 from npm
$ browse cloud sessions create > session.json
$ browse open https://example.com --cdp "$(jq -r .connectUrl session.json)"
File path cannot be resolved.
# exit=1 (3/3 runs failed)
# AFTER: this branch (cb46fff)
$ browse cloud sessions create > session.json # bundled extension uploaded, ~+300ms
$ browse open https://example.com --cdp "$(jq -r .connectUrl session.json)"
{
"mode": "cdp",
"pages": [{ "index": 0, "title": "Example Domain", "url": "https://example.com/" }]
}
# exit=0 (3/3 runs passed)
# AFTER, --no-stagehand-extension
$ browse cloud sessions create --no-stagehand-extension > session.json
$ browse open https://example.com --cdp "$(jq -r .connectUrl session.json)"
File path cannot be resolved.
# exit=1 (3/3, same as 0.12.0)
what changed
SDK (packages/sdk-ts/src/cdpClient.ts):
- Auto-replace incompatible extension via
Extensions.loadUnpackedwhenlocalExtensionDiris set and runtime version mismatch is detected - Map "File path cannot be resolved" Chrome error to
extension_path_inaccessiblewith actionable message
CLI (packages/cli/src/commands/cloud/sessions/create.ts):
- Auto-upload bundled Stagehand extension when creating sessions (default on)
- Use
--no-stagehand-extensionto skip, or--extension-idfor a pre-uploaded extension - On upload failure, warn to stderr and continue creating session without extension
CLI (packages/cli/src/lib/cloud/stagehand-extension.ts):
- Helper to upload extension with 429 retry logic
- Mirrors SDK's
provisionBrowserbaseExtensionpattern; separate because CLI depends on published SDK (4.4.0), notworkspace:*, andlinkWorkspacePackages: false - Each
sessions createuploads a new extension (no caching)
CLI (packages/cli/src/lib/driver/session-manager.ts):
- Handle
extension_path_inaccessiblewith typed error code and actionable guidance
test plan
-
localExtensionReplacement.test.ts: preinstalls mutated extension (older 3.0.0 or future 4.0.0), connects, verifies replacement -
cli-cloud-contract.test.ts: verifiessessions createincludes extension in API request -
cli-cloud-contract.test.ts: verifies graceful degradation on upload failure (warns, continues) - SDK tests pass (682 passed, 4 skipped)
- CLI tests pass (702 passed)
- Remote end-to-end on cb46fff: 3/3 passed


Summary by cubic
Fixes browse open --cdp failing when the connected browser has an older Stagehand extension, and makes browse cloud sessions create provision a compatible runtime up front.
CDPClient.connectauto-replaces an incompatible extension with the bundled one when connecting via a local extension dir with the default runtime requirement; failed replacements re-throw the original error tagged withreplacementError, preserving abort cancellation.- Chrome's "File path cannot be resolved" error maps to
extension_path_inaccessible; runtime mismatches get typed codesruntime_incompatibleandruntime_incompatible_replace_failedwith actionable guidance. browse cloud sessions createuploads the bundled Stagehand extension by default;--extension-idor--no-stagehand-extensionskip it, and upload failures (including an unavailable archive) warn without failing.- Telemetry on failed commands includes a redacted, 200-char-truncated
error_message. - Tests cover older, newer, and remote incompatible extension scenarios.