Skip to content

feat(cli): add network response subcommand for body capture#882

Open
mvanhorn wants to merge 1 commit intovercel-labs:mainfrom
mvanhorn:osc/feat-network-response-body
Open

feat(cli): add network response subcommand for body capture#882
mvanhorn wants to merge 1 commit intovercel-labs:mainfrom
mvanhorn:osc/feat-network-response-body

Conversation

@mvanhorn
Copy link
Contributor

@mvanhorn mvanhorn commented Mar 17, 2026

Summary

Wire the existing responsebody daemon handler to a new CLI subcommand: network response <url-pattern>. This lets users capture response bodies from the command line, which was previously only available via batch/JSON mode.

# Wait for a matching response and print its body
agent-browser network response "/api/products"

# With custom timeout
agent-browser network response "/api/data" --timeout 10000

Closes #111

Evidence

Signal Source
Issue #111 "network requests --body: include response bodies for scraping workflows"
PR #464 Prior attempt (too broad scope - response + dump + filters). Never merged.
Existing handler handle_responsebody already implements CDP Network.getResponseBody but had no CLI command
Reddit r/mcp Benchmarked API costs of AI browser agents - reducing duplicate fetch calls saves tokens
#555 network requests does not capture navigations - agents need better network introspection
Firecrawl Analysis agent-browser listed among top 11 AI browser agents but noted CLI overhead

Implementation

The daemon's handle_responsebody handler was already complete - it subscribes to Network.responseReceived events, matches URLs, and calls Network.getResponseBody. This PR adds:

  • network response subcommand in parse_network (commands.rs)
  • --timeout flag support (default 30s)
  • Human-readable output for response body (output.rs)
  • Help text and tests

Files changed

  • cli/src/commands.rs - add response to parse_network VALID list and parser
  • cli/src/output.rs - response body output handler, help text updates

Test plan

  • cargo fmt passes
  • cargo clippy passes
  • cargo test passes (476 tests, 0 failures)
  • Manual: agent-browser network response "/api/*" returns matching body

This contribution was developed with AI assistance (Claude Code).

Wire the existing `responsebody` handler to a new `network response
<url-pattern>` CLI subcommand. Waits for a matching Network.responseReceived
event and returns the body via Network.getResponseBody.

Closes vercel-labs#111

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Contributor

vercel bot commented Mar 17, 2026

@mvanhorn is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

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.

network requests --body: include response bodies for scraping workflows

1 participant