feat: add network request detail and filtering for request tracking (#935)

* feat: add network request detail and filtering for request tracking

- Add `network request <requestId>` command to view full request/response
  details including response body via CDP Network.getResponseBody
- Add --type, --method, --status filter flags to `network requests`
  - --type: comma-separated resource types (xhr,fetch,document)
  - --method: filter by HTTP method
  - --status: supports exact (200), class (2xx), range (400-499)
- Extend TrackedRequest with request_id, post_data, status,
  response_headers, mime_type fields
- Update Network.responseReceived handler to also populate
  tracked_requests (previously only updated HAR entries)
- Add tests for parse commands and matches_status_filter
- Update README, SKILL.md, docs, and help text

Closes #932

* fix: show request ID and status in network requests output
This commit is contained in:
ChunHao Chen
2026-03-23 10:17:17 -05:00
committed by GitHub
parent 5c5c0d8081
commit ceaee00952
7 changed files with 293 additions and 28 deletions
+16 -1
View File
@@ -384,7 +384,15 @@ pub fn print_response_with_opts(resp: &Response, action: Option<&str>, opts: &Ou
.get("resourceType")
.and_then(|v| v.as_str())
.unwrap_or("");
println!("{} {} ({})", method, url, resource_type);
let request_id = req.get("requestId").and_then(|v| v.as_str()).unwrap_or("");
let status = req.get("status").and_then(|v| v.as_i64());
match status {
Some(s) => println!(
"[{}] {} {} ({}) {}",
request_id, method, url, resource_type, s
),
None => println!("[{}] {} {} ({})", request_id, method, url, resource_type),
}
}
}
return;
@@ -1735,6 +1743,10 @@ Subcommands:
requests [options] List captured requests
--clear Clear request log
--filter <pattern> Filter by URL pattern
--type <types> Filter by resource type (comma-separated: xhr,fetch,document)
--method <method> Filter by HTTP method (GET, POST, etc.)
--status <code> Filter by status (200, 2xx, 400-499)
request <requestId> View full request/response detail (including body)
har <start|stop> [path] Record and export a HAR file
Global Options:
@@ -1747,7 +1759,10 @@ Examples:
agent-browser network unroute
agent-browser network requests
agent-browser network requests --filter "api"
agent-browser network requests --type xhr,fetch
agent-browser network requests --method POST --status 2xx
agent-browser network requests --clear
agent-browser network request 1234.5
agent-browser network har start
agent-browser network har stop ./capture.har
"##