3/4 Add local Chrome support to Go - #2416
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 13 files
Architecture diagram
sequenceDiagram
participant CI as CI Pipeline
participant Dev as Developer
participant Just as Justfile
participant GoGen as Go Generate
participant ExtPack as extensionpack Command
participant Server as Server Build
participant ExtAssets as extensionassets Package
participant GoSDK as Go SDK
participant Chrome as Chrome Process
Note over CI,Chrome: NEW: Local Chrome support with bundled extension
CI->>Just: just check
Just->>ExtPack: run --check
ExtPack->>ExtPack: verify stagehand-extension.zip in Go module
Dev->>Just: just generate
Just->>Server: pnpm build (server)
Server->>Server: produce artifacts/stagehand-extension.zip
Just->>GoGen: go generate ./...
GoGen->>ExtPack: run extensionpack
ExtPack->>ExtPack: sync built ZIP to internal/extensionassets/
ExtPack->>ExtAssets: update stagehand-extension.zip (embedded)
ExtAssets->>ExtAssets: validate version matches server package.json
Note over ExtAssets,Chrome: Runtime: Local Chrome Launch
GoSDK->>ExtAssets: Materialize()
ExtAssets->>ExtAssets: extract ZIP to temp dir
ExtAssets-->>GoSDK: directory path + cleanup func
GoSDK->>Chrome: findChromePath()
alt CHROME_PATH env set
Chrome-->>GoSDK: explicit path
else macOS/Linux/Windows
Chrome-->>GoSDK: OS-specific candidates
end
GoSDK->>GoSDK: availablePort() (if port 0)
GoSDK->>Chrome: exec.Command(chromePath, flags...)
Note over GoSDK,Chrome: flags include --load-extension=<extracted dir>
GoSDK->>GoSDK: configureChromeProcess() (platform-specific)
GoSDK->>Chrome: command.Start()
GoSDK->>Chrome: waitForChrome() polling /json/version
alt timeout
Chrome-->>GoSDK: error
GoSDK->>Chrome: close() → terminate + kill
GoSDK->>Chrome: cleanup profile & extension dir
else success
Chrome-->>GoSDK: CDP URL available
end
Note over GoSDK,Chrome: Graceful Shutdown
GoSDK->>Chrome: close()
alt Unix
Chrome->>Chrome: syscall.Kill(-pid, SIGTERM)
opt after timeout
Chrome->>Chrome: syscall.Kill(-pid, SIGKILL)
end
else Windows
Chrome->>Chrome: taskkill /PID /T /F
end
GoSDK->>GoSDK: os.RemoveAll(userDataDir)
GoSDK->>ExtAssets: cleanup() → os.RemoveAll(extension dir)
Note over CI,Dev: CI Integration
CI->>CI: install chrome-version:stable
CI->>CI: set CHROME_PATH dynamically
CI->>GoSDK: go test (with CHROME_PATH env)
GoSDK->>Chrome: launchChrome() for integration test
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
sameelarif
left a comment
There was a problem hiding this comment.
lgtm but check cubic comments
# Conflicts: # justfile
|
# Conflicts: # .github/workflows/ci.yml # justfile
# Conflicts: # justfile
There was a problem hiding this comment.
All reported issues were addressed across 8 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Local Chrome needs the Stagehand extension unpacked on disk, while Browserbase needs the same extension as a ZIP. This bundles one canonical extension archive into the Go module and safely extracts it when needed.
The next PR wires this into the public client alongside Browserbase.
Stack created with GitHub Stacks CLI • Give Feedback 💬