STG-1672: Add --connect flag to browse CLI for existing Browserbase sessions
Merged
SH
8mo ago+245+245+012345678901234567890123456789-12-12-01234567890123456789
Summary
- Adds a global
--connect <session-id>flag to thebrowseCLI that connects to an existing Browserbase session instead of creating a new one - Uses Stagehand core's existing
browserbaseSessionIDsupport withkeepAlive: trueso the session stays alive after the CLI disconnects - Follows the same state-file pattern as
--context-id(writes session ID to/tmp/browse-{session}.connect, daemon reads it during initialization)
Test procedure
# 1. Sync cookies
node cookie-sync.mjs --domains github.com
# → Session ID: 3ee737d4-237f-4557-a1ca-09a3d5dcbaf2
# 2. Connect and browse (dev build)
browse --connect 3ee737d4-... open https://github.com/notifications ✅
browse eval "..." ✅
Tests completed
-
browse --connect <id> open ...in local mode → errors with "only supported in remote mode" -
browse --connect <id> open --context-id <ctx> ...→ errors with mutual exclusion message -
--connectwrites session ID to connect file before daemon start - Commands without
--connectclear stale connect file -
browse statusoutput includesbrowserbaseSessionIdfield - Manual:
browse --connect <valid-bb-session> open https://example.comconnects and navigates - Manual:
browse stopdisconnects without killing the BB session
🤖 Generated with Claude Code
Fixes STG-1672
Summary by cubic
Adds a --connect <session-id> flag to the browse CLI to attach to an existing Browserbase session instead of creating a new one, leaving the session running after the CLI exits. Implements STG-1672.
- New Features
- New global
--connect <session-id>forbrowseto attach to an existing Browserbase session - Remote mode only; errors in local mode
- Mutually exclusive with
--context-id - Persists the session ID to
/tmp/browse-{session}.connect; clears when unused and restarts the daemon if the ID changes - Uses
browserbaseSessionIDwithkeepAlive: trueso the session persists after disconnect browse statusnow includes abrowserbaseSessionIdfield- Minor release for
@browserbasehq/browse-cli
- New global