Skip to content

feat: add network har start/stop command for HAR 1.2 export - #874

Merged
ctate merged 1 commit into
vercel-labs:mainfrom
ysm-dev:opencode/stellar-canyon
Mar 17, 2026
Merged

ctate merged 1 commit into
vercel-labs:mainfrom
ysm-dev:opencode/stellar-canyon

Conversation

@ysm-dev

@ysm-dev ysm-dev commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds network har start and network har stop [path] CLI subcommands for recording and exporting network traffic as HAR 1.2 files
  • Enriches the existing (but previously CLI-inaccessible) har_start/har_stop daemon actions with full request/response metadata
  • Does not open the browser twice -- har_stop is added to the skip-launch list so export works without re-launching

Changes

CLI parsing (cli/src/commands.rs):

  • Added har to valid network subcommands
  • network har start -> { "action": "har_start" }
  • network har stop [path] -> { "action": "har_stop", "path": "..." }
  • Added 4 unit tests for parsing

HAR capture & export (cli/src/native/actions.rs):

  • Enriched HarEntry struct with request/response headers, statusText, startedDateTime (from CDP wallTime), resource type, HTTP version, and body sizes
  • Captures additional CDP events: Network.requestWillBeSent headers/wallTime/type, Network.responseReceived statusText/headers/protocol/encodedDataLength, and Network.loadingFinished for final transfer size
  • Produces HAR 1.2 output with creator/browser metadata, proper [{name, value}] header arrays, query string parsing, and redirect URL extraction
  • Auto-generates output path under ~/.agent-browser/tmp/har/ when no path is provided
  • Added har_stop to skip_launch list so export does not trigger browser auto-launch
  • Added 4 unit tests for HAR entry serialization, timestamp formatting, default path generation, and skip-launch behavior

Help & output (cli/src/output.rs):

  • har_start now prints "HAR recording started" instead of generic "Recording started"
  • har_stop now prints request count alongside the saved path
  • Updated network --help and summary help text

Documentation:

  • README.md: Added network har start/stop examples
  • docs/src/app/commands/page.mdx: Added HAR commands to network section
  • docs/src/app/security/page.mdx: Updated network action policy to include har start/stop
  • skills/agent-browser/SKILL.md: Added HAR recording examples for AI agents

Dependencies (cli/Cargo.toml):

  • Added time crate (v0.3, formatting feature) for RFC 3339 timestamp formatting

Testing

  • cargo test -- 470 passed, 0 failed, 29 ignored
  • cargo fmt --check -- clean
  • New tests: test_network_har_start, test_network_har_stop_with_path, test_network_har_stop_without_path, test_network_har_requires_subcommand, test_har_entry_json_enriches_request_and_response, test_har_started_date_time_uses_rfc3339, test_handle_har_stop_without_path_uses_default_location, test_execute_har_stop_skips_browser_auto_launch, test_browser_metadata_from_version_parses_product

Usage

agent-browser open https://example.com
agent-browser network har start
# ... navigate, interact ...
agent-browser network har stop ./capture.har

If no path is given to stop, a timestamped file is written to ~/.agent-browser/tmp/har/.

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

Expose HAR recording as a CLI subcommand under the existing `network`
command so users can capture and export network traffic without a
separate tool or opening the browser twice.

- Parse `network har start` and `network har stop [path]` in commands.rs
- Enrich HarEntry with request/response headers, timestamps, status text,
  resource type, HTTP version, and body sizes from CDP events
- Produce HAR 1.2 output with creator/browser metadata, query strings,
  and proper header arrays compatible with Chrome DevTools HAR viewer
- Auto-generate output path under ~/.agent-browser/tmp/har/ when omitted
- Add har_stop to skip_launch list so export works without a live browser
- Update help text, README, docs site, SKILL.md, and security policy docs
- Add unit tests for parsing, HAR entry serialization, and stop behavior
@vercel

vercel Bot commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

@ysm-dev is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​time@​0.3.4710010093100100

View full report

@ctate

ctate commented Mar 17, 2026

Copy link
Copy Markdown
Collaborator

Excellent addition. Thanks @ysm-dev!

@ctate
ctate merged commit 8dd012f into vercel-labs:main Mar 17, 2026
3 of 5 checks passed
f01c33 added a commit to f01c33/agent-browser that referenced this pull request Mar 17, 2026
…ol normalisation

Extends vercel-labs#874's HarEntry struct and CDP handlers with richer capture:

- wall_time (f64) replaces pre-formatted started_date_time, preserving
  sub-second precision from CDP wallTime for accurate RFC 3339 output
- request_headers / response_headers changed from Value to Vec<(String,String)>
  for typed access without re-parsing JSON objects
- post_data captured from Network.requestWillBeSent for HAR postData
- cdp_timing and loading_finished_timestamp captured from responseReceived
  and loadingFinished respectively, enabling har_compute_timings to produce
  accurate blocked/dns/connect/ssl/send/wait/receive phases
- har_cdp_protocol_to_http_version normalises CDP protocol strings
  (h2 -> HTTP/2.0, h3 -> HTTP/3.0, etc.)
- Request cookies parsed from Cookie header; response cookies from Set-Cookie
  with ';'-first split to correctly strip Path/HttpOnly attributes before '='
- har_wall_time_to_rfc3339 replaces har_started_date_time, using the time
  crate directly on the f64 epoch value

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot mentioned this pull request Mar 17, 2026
ctate pushed a commit that referenced this pull request Mar 17, 2026
* feat: enhance HAR entries with timings, cookies, postData, and protocol normalisation

Extends #874's HarEntry struct and CDP handlers with richer capture:

- wall_time (f64) replaces pre-formatted started_date_time, preserving
  sub-second precision from CDP wallTime for accurate RFC 3339 output
- request_headers / response_headers changed from Value to Vec<(String,String)>
  for typed access without re-parsing JSON objects
- post_data captured from Network.requestWillBeSent for HAR postData
- cdp_timing and loading_finished_timestamp captured from responseReceived
  and loadingFinished respectively, enabling har_compute_timings to produce
  accurate blocked/dns/connect/ssl/send/wait/receive phases
- har_cdp_protocol_to_http_version normalises CDP protocol strings
  (h2 -> HTTP/2.0, h3 -> HTTP/3.0, etc.)
- Request cookies parsed from Cookie header; response cookies from Set-Cookie
  with ';'-first split to correctly strip Path/HttpOnly attributes before '='
- har_wall_time_to_rfc3339 replaces har_started_date_time, using the time
  crate directly on the f64 epoch value

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: apply cargo fmt

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
leeguooooo referenced this pull request in leeguooooo/chrome-use Sep 15, 2026
Expose HAR recording as a CLI subcommand under the existing `network`
command so users can capture and export network traffic without a
separate tool or opening the browser twice.

- Parse `network har start` and `network har stop [path]` in commands.rs
- Enrich HarEntry with request/response headers, timestamps, status text,
  resource type, HTTP version, and body sizes from CDP events
- Produce HAR 1.2 output with creator/browser metadata, query strings,
  and proper header arrays compatible with Chrome DevTools HAR viewer
- Auto-generate output path under ~/.agent-browser/tmp/har/ when omitted
- Add har_stop to skip_launch list so export works without a live browser
- Update help text, README, docs site, SKILL.md, and security policy docs
- Add unit tests for parsing, HAR entry serialization, and stop behavior
leeguooooo referenced this pull request in leeguooooo/chrome-use Sep 15, 2026
* feat: enhance HAR entries with timings, cookies, postData, and protocol normalisation

Extends #874's HarEntry struct and CDP handlers with richer capture:

- wall_time (f64) replaces pre-formatted started_date_time, preserving
  sub-second precision from CDP wallTime for accurate RFC 3339 output
- request_headers / response_headers changed from Value to Vec<(String,String)>
  for typed access without re-parsing JSON objects
- post_data captured from Network.requestWillBeSent for HAR postData
- cdp_timing and loading_finished_timestamp captured from responseReceived
  and loadingFinished respectively, enabling har_compute_timings to produce
  accurate blocked/dns/connect/ssl/send/wait/receive phases
- har_cdp_protocol_to_http_version normalises CDP protocol strings
  (h2 -> HTTP/2.0, h3 -> HTTP/3.0, etc.)
- Request cookies parsed from Cookie header; response cookies from Set-Cookie
  with ';'-first split to correctly strip Path/HttpOnly attributes before '='
- har_wall_time_to_rfc3339 replaces har_started_date_time, using the time
  crate directly on the f64 epoch value

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: apply cargo fmt

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
tahodev pushed a commit to tahodev/agent-browser that referenced this pull request Oct 20, 2026
…-labs#874)

Expose HAR recording as a CLI subcommand under the existing `network`
command so users can capture and export network traffic without a
separate tool or opening the browser twice.

- Parse `network har start` and `network har stop [path]` in commands.rs
- Enrich HarEntry with request/response headers, timestamps, status text,
  resource type, HTTP version, and body sizes from CDP events
- Produce HAR 1.2 output with creator/browser metadata, query strings,
  and proper header arrays compatible with Chrome DevTools HAR viewer
- Auto-generate output path under ~/.agent-browser/tmp/har/ when omitted
- Add har_stop to skip_launch list so export works without a live browser
- Update help text, README, docs site, SKILL.md, and security policy docs
- Add unit tests for parsing, HAR entry serialization, and stop behavior
tahodev pushed a commit to tahodev/agent-browser that referenced this pull request Oct 20, 2026
* feat: enhance HAR entries with timings, cookies, postData, and protocol normalisation

Extends vercel-labs#874's HarEntry struct and CDP handlers with richer capture:

- wall_time (f64) replaces pre-formatted started_date_time, preserving
  sub-second precision from CDP wallTime for accurate RFC 3339 output
- request_headers / response_headers changed from Value to Vec<(String,String)>
  for typed access without re-parsing JSON objects
- post_data captured from Network.requestWillBeSent for HAR postData
- cdp_timing and loading_finished_timestamp captured from responseReceived
  and loadingFinished respectively, enabling har_compute_timings to produce
  accurate blocked/dns/connect/ssl/send/wait/receive phases
- har_cdp_protocol_to_http_version normalises CDP protocol strings
  (h2 -> HTTP/2.0, h3 -> HTTP/3.0, etc.)
- Request cookies parsed from Cookie header; response cookies from Set-Cookie
  with ';'-first split to correctly strip Path/HttpOnly attributes before '='
- har_wall_time_to_rfc3339 replaces har_started_date_time, using the time
  crate directly on the f64 epoch value

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: apply cargo fmt

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

2 participants