fix(cli): restore V3 network capture through a CDP sidecar - #2849
Draft
shrey150 wants to merge 6 commits into
Draft
fix(cli): restore V3 network capture through a CDP sidecar#2849shrey150 wants to merge 6 commits into
shrey150 wants to merge 6 commits into
Conversation
…-sidecar # Conflicts: # packages/cli/src/lib/driver/network-capture.ts
…-sidecar # Conflicts: # packages/cli/src/lib/driver/network-capture.ts
|
This was referenced Aug 28, 2026
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.
Stack
--return-xpath; complete supported V3 parityWhy
Browse V3 reads raw CDP Network events from the page frame session. Stagehand V4 does not expose that session. Adding a public
page.on("network")API would commit the framework, protocol, generated SDKs, and extension to a new event schema before that API has been designed.This PR restores CLI parity without expanding Stagehand public API surface.
Architecture
on/off/sendsession shape it used before.browse network off, removes listeners, sendsNetwork.disable, and detaches the page target.browse close.The request correlation and request/response JSON writer are inherited from the V3 CLI. No protocol schema, extension, SDK, or generated-client changes are included.
Versioning is intentionally deferred to the consolidated Browse minor changeset in #2838.
User-visible behavior
The command surface and files remain the V3 shape:
Each request directory still contains
request.jsonand, when available,response.json, including POST bodies, response bodies, failures, redirects, and cache hits with the existing V3 semantics.Verification
pnpm --filter browse test: 27 test files, 382 tests passed against the built CLI.pnpm --filter browse lint: formatting, ESLint, and TypeScript passed.Built CLI E2E matrix
The local differential invoked each built CLI as a subprocess against the same HTTP fixture:
network on/path/off/path/clearreturn shape[]/redirectrequest-only plus/finalrequest/response0700; request/response files0600Normalization was deliberately limited to values that cannot match across independent browser runs: CDP request ID, timestamp, duration, HTTP
Date, and fixture origin/port. Header names/casing, directory counters, methods, paths, bodies, statuses, MIME types, status text, error shape, and file modes were compared as emitted.The Browserbase matrix also invoked the actual built CLI:
network on → navigate → offnetwork on → navigate → offnetwork offopen --wait networkidlecompletedbrowserConnected: true,initialized: true, moderemotebrowse stopcompleted; no remote or local test artifacts retainedReview guide
network-cdp-sidecar.ts: the isolated transport and lifecycle.network-capture.ts: the narrow adapter from V4pageIdto the preserved V3 writer.session-manager.ts: endpoint access and close ordering.The built-CLI local differential and real Browserbase lifecycle matrix are attached above. This remains draft for code review, not for missing runtime proof.
Summary by cubic
Restores V3 network capture in the Browse V4 CLI via a CLI-owned CDP sidecar. Previously
browse network onfailed because the V4 runtime no longer exposes the page frame session; now it works without expanding the public Stagehand API.Details
browse close.Written for commit 86ea880. Summary will update on new commits.