agent-browser 0.32.1 → 0.32.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/bin/agent-browser-darwin-arm64 +0 -0
- package/bin/agent-browser-darwin-x64 +0 -0
- package/bin/agent-browser-linux-arm64 +0 -0
- package/bin/agent-browser-linux-musl-arm64 +0 -0
- package/bin/agent-browser-linux-musl-x64 +0 -0
- package/bin/agent-browser-linux-x64 +0 -0
- package/bin/agent-browser-win32-x64.exe +0 -0
- package/package.json +1 -1
- package/skill-data/core/SKILL.md +4 -0
- package/skill-data/core/references/commands.md +5 -0
- package/skill-data/derive-client/SKILL.md +86 -0
- package/skills/agent-browser/SKILL.md +1 -0
package/README.md
CHANGED
|
@@ -314,7 +314,9 @@ agent-browser network requests --type xhr,fetch # Filter by resource type
|
|
|
314
314
|
agent-browser network requests --method POST # Filter by HTTP method
|
|
315
315
|
agent-browser network requests --status 2xx # Filter by status (200, 2xx, 400-499)
|
|
316
316
|
agent-browser network request <requestId> # View full request/response detail
|
|
317
|
-
agent-browser network har start # Start HAR recording
|
|
317
|
+
agent-browser network har start # Start HAR recording (embeds text response bodies)
|
|
318
|
+
agent-browser network har start --content all # Embed all response bodies (binary as base64)
|
|
319
|
+
agent-browser network har start --content none # Metadata only, no bodies
|
|
318
320
|
agent-browser network har stop [output.har] # Stop and save HAR (temp path if omitted)
|
|
319
321
|
```
|
|
320
322
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
package/skill-data/core/SKILL.md
CHANGED
|
@@ -310,6 +310,10 @@ agent-browser network requests # inspect wha
|
|
|
310
310
|
agent-browser network har start # record all traffic
|
|
311
311
|
# ... perform actions ...
|
|
312
312
|
agent-browser network har stop /tmp/trace.har
|
|
313
|
+
|
|
314
|
+
# HAR files embed text response bodies (JSON/HTML/JS) by default, so the
|
|
315
|
+
# recording alone is enough to study a site's API offline. Use
|
|
316
|
+
# `--content all` to include binary bodies or `--content none` to disable.
|
|
313
317
|
```
|
|
314
318
|
|
|
315
319
|
### Record a video of the workflow
|
|
@@ -191,6 +191,11 @@ agent-browser network route <url> --body '{}' # Mock response
|
|
|
191
191
|
agent-browser network unroute [url] # Remove routes
|
|
192
192
|
agent-browser network requests # View tracked requests
|
|
193
193
|
agent-browser network requests --filter api # Filter requests
|
|
194
|
+
agent-browser network request <requestId> # Full request/response detail incl. body
|
|
195
|
+
agent-browser network har start # Record traffic (embeds text response bodies)
|
|
196
|
+
agent-browser network har start --content all # Embed all bodies (binary as base64)
|
|
197
|
+
agent-browser network har start --content none # Sizes and headers only
|
|
198
|
+
agent-browser network har stop [output.har] # Stop and save HAR
|
|
194
199
|
```
|
|
195
200
|
|
|
196
201
|
## Tabs and Windows
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: derive-client
|
|
3
|
+
description: Reverse-engineer a website's internal API by recording browser traffic into a HAR file, then generate a standalone client or CLI that calls the endpoints directly, with no browser needed after the first recording. Use when asked to "derive a client", "build a CLI for <site>", "reverse engineer this site's API", "record network requests", "turn this site into an API", or when the same site will be automated repeatedly and direct HTTP calls would beat driving the browser every time.
|
|
4
|
+
allowed-tools: Bash(agent-browser:*), Bash(npx agent-browser:*)
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Derive an API client from a recorded session
|
|
8
|
+
|
|
9
|
+
Driving a browser is the right tool for the first visit and the wrong tool for the hundredth. This skill records a site's network traffic once while you use it, then turns the captured requests into a standalone client (script, CLI, or library) that talks to the site's internal API directly.
|
|
10
|
+
|
|
11
|
+
The recording alone contains everything needed: agent-browser embeds text response bodies (JSON/HTML/JS) in the HAR by default, so endpoint shapes can be studied offline after the browser is closed.
|
|
12
|
+
|
|
13
|
+
## Workflow
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
1. Record Start HAR capture, drive the flows you want in the client
|
|
17
|
+
2. Identify Find the real API endpoints among the noise
|
|
18
|
+
3. Extract Pull request shapes, response schemas, and auth material
|
|
19
|
+
4. Generate Write the client, one function per flow
|
|
20
|
+
5. Verify Call every endpoint for real before declaring done
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 1. Record
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
agent-browser network har start # embeds text response bodies by default
|
|
27
|
+
# ... drive the site: search, open a detail page, paginate, etc. ...
|
|
28
|
+
agent-browser network har stop /tmp/site.har
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- Exercise **every flow the client should support**, and run each one at least twice with different inputs (two search terms, two detail pages). Diffing the recorded URLs reveals which parts are parameters.
|
|
32
|
+
- If the site needs login, log in **before** starting the HAR so credentials don't land in the recording unnecessarily. The session cookies are exported separately in step 3.
|
|
33
|
+
- `--content all` embeds binary bodies too (base64); `--content none` disables embedding. Per-body cap is 2 MB.
|
|
34
|
+
|
|
35
|
+
While the session is still open, `agent-browser network requests` and `network request <id>` give the same data interactively — but only the HAR survives navigation and browser close, so prefer it for anything multi-page.
|
|
36
|
+
|
|
37
|
+
## 2. Identify endpoints
|
|
38
|
+
|
|
39
|
+
Query the HAR with `jq`:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# All JSON API calls: method, URL, status
|
|
43
|
+
jq -r '.log.entries[]
|
|
44
|
+
| select(.response.content.mimeType | test("json"))
|
|
45
|
+
| "\(.request.method) \(.response.status) \(.request.url)"' /tmp/site.har
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Ignore analytics and infrastructure noise: telemetry endpoints (`/collect`, `/track`, `/beacon`, `/log`), third-party domains (google-analytics, segment, sentry, datadog, intercom, hotjar), and static assets. The real API is usually first-party, JSON, and correlates with the actions you performed.
|
|
49
|
+
|
|
50
|
+
## 3. Extract shapes and auth
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Full detail for one endpoint: request headers, POST body, response body
|
|
54
|
+
jq '.log.entries[] | select(.request.url | test("api/search"))
|
|
55
|
+
| {request: {method: .request.method, headers: .request.headers,
|
|
56
|
+
postData: .request.postData.text},
|
|
57
|
+
response: .response.content.text}' /tmp/site.har
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
- **Response schema**: read `.response.content.text` — this is the real payload, use it to derive types.
|
|
61
|
+
- **Auth**: compare request headers across endpoints. Look for `authorization`, `cookie`, `x-csrf-token`, `x-api-key`, and site-specific `x-*` headers. Replay only the ones that matter — test by omission in step 5.
|
|
62
|
+
- **Cookies**: export the live session with `agent-browser cookies get --json > cookies.json` for the client to load at runtime. Never hardcode cookie values into generated source.
|
|
63
|
+
|
|
64
|
+
## 4. Generate the client
|
|
65
|
+
|
|
66
|
+
- One function per recorded flow (`search(query)`, `getItem(id)`), typed from the observed response bodies.
|
|
67
|
+
- Auth material (cookies, bearer tokens) loads from a file or environment variable, with a clear error telling the user to re-run the browser login when it expires.
|
|
68
|
+
- Reproduce the headers the API actually requires — some sites 403 without a matching `user-agent`, `referer`, or `x-requested-with`.
|
|
69
|
+
- Keep pagination, sort, and filter parameters that appeared in the recorded query strings as function options.
|
|
70
|
+
|
|
71
|
+
## 5. Verify
|
|
72
|
+
|
|
73
|
+
Call every generated function against the live API and compare the response shape with the recording. Common failures:
|
|
74
|
+
|
|
75
|
+
| Symptom | Cause | Fix |
|
|
76
|
+
|---------|-------|-----|
|
|
77
|
+
| 401/403 | Expired or missing session | Re-login via agent-browser, re-export cookies |
|
|
78
|
+
| 403/419 on writes | CSRF token is per-session or per-form | Fetch the token endpoint first, or keep that flow browser-driven |
|
|
79
|
+
| Works then breaks | Signed/expiring request params | Fall back to the browser for that step; derive the rest |
|
|
80
|
+
| Different shape than HAR | A/B tests or geo-dependent responses | Re-record and treat the union as optional fields |
|
|
81
|
+
|
|
82
|
+
## Caveats
|
|
83
|
+
|
|
84
|
+
- Internal APIs are unversioned and change without notice — keep the HAR so the client can be re-derived.
|
|
85
|
+
- Respect the site's terms of service and rate limits; add delays for bulk fetching.
|
|
86
|
+
- HAR files contain live session credentials (cookies, tokens, POST bodies). Treat them like secrets: keep them out of version control and delete them when done.
|
|
@@ -30,6 +30,7 @@ Load a specialized skill when the task falls outside browser web pages:
|
|
|
30
30
|
agent-browser skills get electron # Electron desktop apps (VS Code, Slack, Discord, Figma, ...)
|
|
31
31
|
agent-browser skills get slack # Slack workspace automation
|
|
32
32
|
agent-browser skills get dogfood # Exploratory testing / QA / bug hunts
|
|
33
|
+
agent-browser skills get derive-client # Record a HAR, derive a standalone API client for a site
|
|
33
34
|
agent-browser skills get vercel-sandbox # agent-browser inside Vercel Sandbox microVMs
|
|
34
35
|
agent-browser skills get agentcore # AWS Bedrock AgentCore cloud browsers
|
|
35
36
|
```
|