slipwing 0.0.0-stage → 0.1.0

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.
Files changed (99) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +143 -3
  3. package/bin/agent-desktop-win32-x64.exe +0 -0
  4. package/bin/workflow.js +512 -0
  5. package/browser/LICENSE +201 -0
  6. package/browser/LICENSE-axe-core-THIRD-PARTY.txt +66 -0
  7. package/browser/LICENSE-axe-core.txt +362 -0
  8. package/browser/bin/agent-browser-win32-x64.exe +0 -0
  9. package/browser/skill-data/agentcore/SKILL.md +115 -0
  10. package/browser/skill-data/core/SKILL.md +279 -0
  11. package/browser/skill-data/core/references/authentication.md +413 -0
  12. package/browser/skill-data/core/references/commands.md +727 -0
  13. package/browser/skill-data/core/references/profiling.md +120 -0
  14. package/browser/skill-data/core/references/proxy-support.md +221 -0
  15. package/browser/skill-data/core/references/session-management.md +215 -0
  16. package/browser/skill-data/core/references/snapshot-refs.md +244 -0
  17. package/browser/skill-data/core/references/streaming.md +107 -0
  18. package/browser/skill-data/core/references/trust-boundaries.md +69 -0
  19. package/browser/skill-data/core/references/video-recording.md +254 -0
  20. package/browser/skill-data/core/references/webgpu.md +118 -0
  21. package/browser/skill-data/core/templates/authenticated-session.sh +109 -0
  22. package/browser/skill-data/core/templates/capture-workflow.sh +69 -0
  23. package/browser/skill-data/core/templates/form-automation.sh +63 -0
  24. package/browser/skill-data/derive-client/SKILL.md +88 -0
  25. package/browser/skill-data/dogfood/SKILL.md +224 -0
  26. package/browser/skill-data/dogfood/references/issue-taxonomy.md +109 -0
  27. package/browser/skill-data/dogfood/templates/dogfood-report-template.md +53 -0
  28. package/browser/skill-data/electron/SKILL.md +236 -0
  29. package/browser/skill-data/modern-web-guidance/SKILL.md +165 -0
  30. package/browser/skill-data/slack/SKILL.md +288 -0
  31. package/browser/skill-data/slack/references/slack-tasks.md +349 -0
  32. package/browser/skill-data/slack/templates/slack-report-template.md +163 -0
  33. package/browser/skill-data/vercel/SKILL.md +160 -0
  34. package/browser/skill-data/vercel-sandbox/SKILL.md +237 -0
  35. package/browser/skill-data/webmcp-gen/SKILL.md +52 -0
  36. package/browser/skills/agent-browser/SKILL.md +51 -0
  37. package/bundle.json +19 -0
  38. package/lib/browser-move.js +185 -0
  39. package/lib/bundle-version.js +32 -0
  40. package/lib/choose.js +382 -0
  41. package/lib/cli-options.js +47 -0
  42. package/lib/control-changes.js +47 -0
  43. package/lib/current-page.js +165 -0
  44. package/lib/error-code.js +19 -0
  45. package/lib/final-picture.js +31 -0
  46. package/lib/final-words.json +7 -0
  47. package/lib/flow-record.js +32 -0
  48. package/lib/host-client.js +65 -0
  49. package/lib/host-command.js +175 -0
  50. package/lib/host-paths.js +22 -0
  51. package/lib/host-server.js +383 -0
  52. package/lib/host-waits.js +12 -0
  53. package/lib/host-watch.js +340 -0
  54. package/lib/mcp-guide.js +45 -0
  55. package/lib/mcp-server.js +264 -0
  56. package/lib/notify.js +31 -0
  57. package/lib/page-choice.js +273 -0
  58. package/lib/page-input.js +141 -0
  59. package/lib/page-lease.js +87 -0
  60. package/lib/page-line.js +83 -0
  61. package/lib/page-pointer.js +191 -0
  62. package/lib/page-read.js +44 -0
  63. package/lib/platform.js +89 -0
  64. package/lib/png-mark.js +83 -0
  65. package/lib/prefs.js +228 -0
  66. package/lib/routine-approvals.js +67 -0
  67. package/lib/routine-command.js +150 -0
  68. package/lib/routine-effects.js +119 -0
  69. package/lib/routine-store.js +143 -0
  70. package/lib/script-args.js +48 -0
  71. package/lib/script-call.js +63 -0
  72. package/lib/script-desktop.js +731 -0
  73. package/lib/script-final.js +93 -0
  74. package/lib/script-fix.js +121 -0
  75. package/lib/script-input.js +25 -0
  76. package/lib/script-match.js +90 -0
  77. package/lib/script-picture.js +104 -0
  78. package/lib/script-repeat.js +43 -0
  79. package/lib/script-run.js +367 -0
  80. package/lib/script-screen.js +53 -0
  81. package/lib/script-visible.js +228 -0
  82. package/lib/script-wait.js +15 -0
  83. package/lib/script-web.js +338 -0
  84. package/lib/skill-command.js +81 -0
  85. package/lib/space.js +56 -0
  86. package/lib/text-match.js +18 -0
  87. package/lib/watch-helper.ps1 +200 -0
  88. package/lib/web-page.js +214 -0
  89. package/lib/window-move.js +213 -0
  90. package/lib/windows-bin.js +44 -0
  91. package/package.json +32 -5
  92. package/scripts/initialize-state.ps1 +13 -0
  93. package/skills/slipwing/SKILL.md +189 -0
  94. package/skills/slipwing/chrome.md +62 -0
  95. package/skills/slipwing/desktop.md +82 -0
  96. package/skills/slipwing/human.md +63 -0
  97. package/skills/slipwing/jobs.md +82 -0
  98. package/skills/slipwing/routines.md +73 -0
  99. package/skills/slipwing/watches.md +37 -0
@@ -0,0 +1,727 @@
1
+ # Command Reference
2
+
3
+ Complete reference for all agent-browser commands. For quick start and common patterns, see SKILL.md. Unknown commands exit with status 1, including when you request command help.
4
+
5
+ These commands reject unknown flags and use the same `--` boundary. Navigation: `open`, `goto`, `navigate`, `back`, `forward`, `reload`, `pushstate`. Interaction: `click`, `dblclick`, `hover`, `focus`, `check`, `uncheck`, `drag`, `scroll`, `scrollintoview`, `tap`. Capture and files: `screenshot`, `pdf`, `download`, `record start|restart`. Inspection and state: `snapshot`, `frame`, `highlight`, `console`, `errors`, `trace start|stop`, `profiler start|stop`, `state save|load|list|clear|show|clean`, `network`, `flow steps|list`, `react`, `vitals`, `close`, `inspect`. Operands of `select`, `upload`, `press`, `keydown`, `keyup`, `keyboard`, `set`, `clipboard`, `auth`, `webmcp`, `dialog`, `tab`, `skills` and `plugin` also follow a leading `--`; a lone `--` stays an operand. Put flags before `--`; values after `--` are positional. Commands that accept negative numbers take them directly. Other commands may validate options differently.
6
+
7
+ ## Linux dependencies
8
+
9
+ On Linux, `agent-browser install --with-deps` installs system dependencies with the detected package manager. It runs that package manager directly as root and uses `sudo` for non-root users. If you are not root and `sudo` is unavailable, it reports that root privileges or `sudo` are required.
10
+
11
+ ## Navigation
12
+
13
+ ```bash
14
+ agent-browser open # Launch browser (no navigation); stays on about:blank.
15
+ # Pair with `network route` or `cookies set --curl` to
16
+ # stage state before the first navigation.
17
+ agent-browser open <url> # Launch + navigate (aliases: goto, navigate)
18
+ # Supports: https://, http://, file://, about:, data://
19
+ # Auto-prepends https:// if no protocol given
20
+ agent-browser read [url] # Fetch agent-readable text, or read rendered active-tab DOM
21
+ # Explicit URLs send Accept: text/markdown, then try .md if needed
22
+ # Walks ancestor paths for llms.txt before HTML fallback
23
+ # --llms and --require-md without URL use the active tab URL
24
+ # --filter narrows page content to matching heading sections
25
+ # Honors --allowed-domains, --content-boundaries, and --max-output
26
+ # Invalid --max-output values warn and keep the previous limit
27
+ # Options: --raw, --require-md, --outline, --llms <index|full>, --filter, --timeout <ms>
28
+ agent-browser back # Go back
29
+ agent-browser forward # Go forward
30
+ agent-browser reload # Reload page
31
+ agent-browser pushstate <url> # SPA client-side navigation. Auto-detects
32
+ # window.next.router.push (triggers RSC fetch on Next.js);
33
+ # falls back to history.pushState + popstate/navigate events.
34
+ agent-browser close # Close browser (aliases: quit, exit)
35
+ agent-browser connect 9222 # Connect to browser via CDP port
36
+ ```
37
+
38
+ After `connect`, the session stays attached until `agent-browser close`. Later commands without a connection flag run against the same browser, as if you passed `--cdp` again. If that browser goes away, commands fail instead of launching a local one.
39
+
40
+ If the debugging port is not open yet, `connect` and `--cdp` wait up to 2 seconds for it before failing.
41
+
42
+ ### Pre-navigation setup (one-turn batch)
43
+
44
+ ```bash
45
+ agent-browser batch \
46
+ "open" \
47
+ "network route * --abort --resource-type script" \
48
+ "cookies set --curl cookies.curl --domain localhost" \
49
+ "navigate http://localhost:3000/target"
50
+ ```
51
+
52
+ Put global flags such as `--init-script` and `--enable` only on the outer batch invocation, never inside an item. Inside an item, `--` separates command flags from literal values only for commands that support `--` as an end-of-options marker. For those commands, put command flags before `--`; a path or selector after `--` is literal. Other commands may treat `--` as data. For example, the item `screenshot body -- --draft.png` passes `--draft.png` as the path.
53
+
54
+ Batch items cannot run `close --all`, `quit --all`, or `exit --all`; run the command outside the batch instead.
55
+
56
+ ```bash
57
+ agent-browser --enable react-devtools batch "open" "navigate data:text/html,<h1>hi</h1>"
58
+ agent-browser batch "open https://example.com" "screenshot body -- --draft.png"
59
+ ```
60
+
61
+ `open` with no URL gives you a clean launch so interception rules and cookies can take effect on the *first* real navigation. Pass `--init-script <path>` at launch to install a script before navigation. Use this flow for SSR-only debug (`--resource-type script`), protected-origin auth, or capturing fresh `react suspense`/`vitals` state without noise from a prior page.
62
+
63
+ With `--json`, `--omit-command` replaces each `command` array with a stable zero-based `index` field on success, failure, or `--bail`; default output is unchanged. This only removes command arrays and does not make output safe for secrets. Errors and response data are unchanged: `type` echoes typed text, and `get value`/`eval` may return input values. The MCP `agent_browser_batch` tool accepts `omitCommand: true`.
64
+
65
+ ## Snapshot (page analysis)
66
+
67
+ ```bash
68
+ agent-browser snapshot # Full accessibility tree
69
+ agent-browser snapshot -i # Interactive elements only (recommended)
70
+ agent-browser snapshot -c # Compact output
71
+ agent-browser snapshot -d 3 # Limit depth to 3
72
+ agent-browser snapshot -s "#main" # Scope to every match of a CSS selector
73
+ agent-browser snapshot --delta # Full state once, then bounded structural deltas
74
+ agent-browser snapshot --delta --full # Force full state and refresh baseline
75
+ ```
76
+
77
+ Delta history is per tab and option set. Responses are `full`, `unchanged`, or `delta`; URL changes or large deltas return full state. For a delta, apply `changes` (`add`, `remove`, `replace`) to ref metadata. Split the previous tree on newlines, splice `treeChange.lines` at zero-based `startLine`, replacing `deleteCount` lines, then join with newlines. Apply both parts to `baseRevision` before advancing to `revision`; use `--full` if the baseline is unavailable.
78
+
79
+ A ref is tied to the document it was issued in. After a page load or an iframe navigation or removal (a click, script or redirect), using that ref fails with `Ref @eN is from a document that is no longer loaded`; snapshot again. A snapshot taken while the document is being replaced fails with `The document changed while the snapshot was being captured`; run it again. Refs survive same-document changes such as `pushState` and DOM updates.
80
+
81
+ ## Interactions (use @refs from snapshot)
82
+
83
+ ```bash
84
+ agent-browser click @e1 # Click
85
+ agent-browser click @e1 --new-tab # Click and open in new tab
86
+ agent-browser click @e1 --button right # Right-click (fires contextmenu)
87
+ agent-browser click @e1 --button middle # Middle-click (fires auxclick)
88
+ agent-browser click @e1 --modifiers control,shift # Hold keys during the click
89
+ agent-browser dblclick @e1 # Double-click
90
+ agent-browser dblclick @e1 --modifiers shift # Double-click with Shift held
91
+ agent-browser focus @e1 # Focus element
92
+ agent-browser fill @e2 "text" # Clear and fill
93
+ agent-browser type @e2 "text" # Type without clearing
94
+ agent-browser press Enter # Press key (alias: key)
95
+ agent-browser press Control+a # Key combination
96
+ agent-browser keydown Shift # Hold key down
97
+ agent-browser keyup Shift # Release key
98
+ agent-browser hover @e1 # Hover
99
+ agent-browser check @e1 # Check checkbox
100
+ agent-browser uncheck @e1 # Uncheck checkbox
101
+ agent-browser select @e1 "value" # Select by value or visible label
102
+ agent-browser select @e1 "a" "b" # Select multiple options
103
+ # On a custom ARIA combobox/listbox (Radix, Headless UI), select opens it and clicks the
104
+ # role=option whose name or value matches; no match errors with the available options,
105
+ # and a matched aria-disabled option errors instead of being clicked.
106
+ agent-browser scroll down 500 # Scroll page (default: down 300px)
107
+ agent-browser scrollintoview @e1 # Scroll element into view (alias: scrollinto)
108
+ agent-browser drag @e1 @e2 # Drag and drop
109
+ agent-browser upload @e1 file.pdf # Upload files (relative to cwd; errors: file_not_found, not_file_input)
110
+ ```
111
+
112
+ `upload` fails with `file_not_found` when a path does not exist and with `not_file_input` when the target is not a file input; relative paths resolve against the current directory. `diff snapshot` compares against the last snapshot taken on the tab with that snapshot's options, failing with `no_baseline` when there is none and `baseline_mismatch` when a named option differs.
113
+
114
+ For `fill` and `type`, put options before the optional `--` marker. Text after the marker is literal, including values that look like flags. For example, `agent-browser fill @e2 -- --json` fills with `--json`, and `agent-browser type @e2 --clear --delay 10 -- --clear` clears the field, then types `--clear`. MCP `agent_browser_fill` and `agent_browser_type` pass typed `text` values literally, so they do not need the marker.
115
+
116
+ MCP tools pass typed values literally where they are emitted as positionals (`fill` and `type` text, `select` values, `press` and `keyboard` text, `auth save` and `auth login` names and credential values, `webmcp invoke` tool names, `webmcp result` invocation ids, `plugin run` names and request types, and the other covered commands; `frameId` for `webmcp invoke` is still refused when it starts with `-`). In every other free-form field (for example storage, cookie, credential and wait values, and option values), MCP refuses a value that equals a global CLI token or has the form `--<global>=...`, such as `-v`, `-q`, `-p`, `--help`, `--session` or `--json=1`, because the CLI could read it as a global flag. Examples: `wait_for_text "--help"`, `storage_set` with value `-v`, `cookies_set` with value `-q`, `set_credentials` with password `-p`, `find` with `action: "fill"` and text `--json`, and `chat "--help"`. There is no workaround for those fields yet; use `agent_browser_fill` for flag-shaped text input. Carrying such values as data in every field is a planned follow-up.
117
+
118
+ Visible-label matching treats non-breaking and ordinary spaces equivalently.
119
+
120
+ `fill` and `type` fail when the target cannot take focus because it is hidden or disabled; they do not type into whichever field holds the focus. `fill` sets a date, time, month, week, color, range or select field directly, for example `agent-browser fill @e5 "1998-03-15"`. A value in the wrong format fails, names the expected format and leaves the field as it was. On an editable region, `fill` replaces the existing content.
121
+
122
+ Clicks fail before dispatch when another element covers the target's click point. The error names the covering element, for example `covered by <div#consent-banner>`. Dismiss or interact with that element, run a fresh snapshot, then retry the original action. Click and dblclick fail, instead of reporting success, when the element is hidden, disabled, or outside the viewport. `click --new-tab` opens the link's URL directly, so these checks do not apply to it.
123
+
124
+ `--button` presses `left` (default), `right`, `middle`, `back`, or `forward`; a right click fires the page's `contextmenu` event and a middle click fires `auxclick`. `--modifiers` holds `alt`, `control` (alias `ctrl`), `meta` (aliases `cmd`, `command`), and `shift` during the click, joined by a comma or a plus, such as `control,shift`. Flags go before or after the selector, unknown flags are rejected, and `--new-tab` cannot be combined with `--button` or `--modifiers`. `dblclick` takes `--button`, `--modifiers`, `--human`, and `--seed`, follows the session input mode, and sends two full clicks, so the page receives `click`, `click`, `dblclick`. On macOS, `control` click opens the context menu, so use `meta` for a click that opens a link in a new tab; on Windows and Linux that key is `control`.
125
+
126
+ ## Get Information
127
+
128
+ ```bash
129
+ agent-browser get text @e1 # Get element text
130
+ agent-browser get html @e1 # Get innerHTML
131
+ agent-browser get value @e1 # Get input value
132
+ agent-browser get attr @e1 href # Get attribute
133
+ agent-browser get title # Get page title
134
+ agent-browser get url # Get current URL
135
+ agent-browser get cdp-url # CDP WebSocket URL of a running browser (never launches)
136
+ agent-browser get count ".item" # Count matching elements
137
+ agent-browser get box @e1 # Get bounding box
138
+ agent-browser get styles @e1 # Get computed styles (font, color, bg, etc.)
139
+ ```
140
+
141
+ A batch containing only `get cdp-url` commands also skips browser launch. A mixed batch can launch a browser for its other commands.
142
+
143
+ ## Check State
144
+
145
+ ```bash
146
+ agent-browser is visible @e1 # Check if visible
147
+ agent-browser is enabled @e1 # Check if enabled
148
+ agent-browser is checked @e1 # Check if checked
149
+ ```
150
+
151
+ ## Screenshots and PDF
152
+
153
+ ```bash
154
+ agent-browser screenshot # Save to temporary directory
155
+ agent-browser screenshot path.png # Save to specific path
156
+ agent-browser screenshot --full # Full page
157
+ agent-browser screenshot --if-changed # Recommended: skip unchanged images to save tokens
158
+ agent-browser screenshot --threshold 0.01 # Ignore changes affecting at most 1% of pixels
159
+ agent-browser screenshot body -- --draft.png # Literal path starting with -
160
+ agent-browser pdf output.pdf # Save as PDF
161
+ ```
162
+
163
+ `--threshold <0-1>` implies `--if-changed`. Conditional history is isolated by tab and capture scope. JSON responses include `changed`, `revision`, `pixelChangeRatio`, and `threshold`; `path` is present only when the change exceeds the threshold. The first capture for a scope is always changed.
164
+
165
+ Headless Chromium screenshots hide native scrollbars for consistent image output. Pass `--hide-scrollbars false` when launching to keep native scrollbars visible.
166
+
167
+ ## Video Recording
168
+
169
+ ```bash
170
+ agent-browser open https://example.com # Launch a browser session first
171
+ agent-browser record start ./demo.webm # Start recording the current page at 30 fps
172
+ agent-browser click @e1 # Perform actions
173
+ agent-browser record stop # Stop and save video
174
+ agent-browser record restart ./take2.webm # Stop current + start new
175
+
176
+ agent-browser record start ./scroll.webm --fps 60 # 60 fps for motion-heavy takes
177
+ agent-browser record start ./soak.webm --fps 10 # Lower rate for long sessions
178
+ agent-browser tab new https://example.com # Open a separate tab first if you want the recording there
179
+ agent-browser record start ./demo.webm --cursor # Add an animated mouse pointer
180
+ agent-browser record start ./demo.webm --contact-sheet # Save a timestamped PNG summary
181
+ ```
182
+
183
+ Needs `ffmpeg` on PATH; use a path with an extension. `--fps` accepts 1 to 60 and defaults to 30. `--contact-sheet-threshold <0-1>` adjusts keyframe sensitivity and implies `--contact-sheet`.
184
+
185
+ ## Wait
186
+
187
+ ```bash
188
+ agent-browser wait @e1 # Wait for element
189
+ agent-browser wait 2000 # Wait milliseconds
190
+ agent-browser wait --text "Success" # Wait for text (or -t)
191
+ agent-browser wait --url "**/dashboard" # Wait for URL pattern (or -u)
192
+ agent-browser wait --load domcontentloaded # Wait for DOMContentLoaded (or -l)
193
+ agent-browser wait --load load # Wait for the load event
194
+ agent-browser wait --load networkidle # Wait for network idle on known-quiet pages
195
+ agent-browser wait --fn "window.ready" # Wait for JS condition (or -f)
196
+ ```
197
+
198
+ For selector waits, `--state` accepts `visible`, `hidden`, `attached`, or `detached` and cannot be combined with URL, load, function, text, download, or millisecond wait modes. The global auth-state `--state <path>` remains available before `wait`, as it does before other commands.
199
+
200
+ After a page-changing action, prefer the selector, text, URL, or JavaScript condition that represents the result you need. Use a lifecycle wait when the lifecycle event is the milestone. `networkidle` is also supported, but use it only for pages known to become quiet because SSE, WebSockets, polling, and long-polling can keep it from resolving.
201
+
202
+ A load-state wait runs for its whole timeout budget, taken from `--timeout` or `AGENT_BROWSER_DEFAULT_TIMEOUT`, and returns an error when it expires.
203
+
204
+ ## Mouse Control
205
+
206
+ ```bash
207
+ agent-browser mouse move 100 200 # Move mouse instantly
208
+ agent-browser mouse move 600 400 --duration 250 --steps 24
209
+ agent-browser mouse move 600 400 --human --seed 42
210
+ agent-browser mouse down left # Press button
211
+ agent-browser mouse up left # Release button
212
+ agent-browser mouse move 100 200 # Move over the target
213
+ agent-browser mouse wheel 100 # Scroll at the current tracked pointer
214
+ ```
215
+
216
+ Use `--human [natural|careful]` and `--seed <n>` with `click`, `dblclick`, `drag`, `hover`, `mouse move`, `type`, or `keyboard type` when pointer-path or per-key events matter. `natural` is the default. Pointer movement is curved, uses a minimum-jerk speed profile, whole-pixel steps 7 to 13 ms apart, and a Fitts' law duration, with an occasional overshoot or undershoot and short correction, a pause before pressing, and a varied press duration. The landing point stays inside the visible target. Typing uses uneven key intervals (about 125 ms natural, 210 ms careful), pauses between words, occasional thinking pauses, and occasional typos corrected with Backspace; a wrong Chinese character is a same-sound one fixed immediately. Password, card, and one-time-code fields never get typos. `type --keys` sends real key events without the pacing. Plain `type` is unchanged. In a background tab, `hover` events stay queued until the next click or until the tab renders; the response notes this.
217
+
218
+ Movement starts at the current cursor position and ends at the target; `mouse move --seed` makes the path reproducible. `--duration` is the target total duration, including browser response time; a slow browser can still extend it.
219
+
220
+ The wheel starts at `0,0`; move the pointer first to scroll elsewhere. Failed wheel dispatches leave the tracked pointer unchanged.
221
+
222
+ Mouse coordinates and wheel deltas accept finite decimal values; invalid supplied values are rejected. For `mouse wheel`, omitted `dy` and `dx` default to `100` and `0`, respectively, and explicit `0` values are preserved.
223
+
224
+ ## Semantic Locators (alternative to refs)
225
+
226
+ ```bash
227
+ agent-browser find role button click --name "Submit"
228
+ agent-browser find role heading text --name "Skills" # implicit roles work: <h2>=heading, <ul>=list, top-level <header>=banner
229
+ agent-browser find text "Sign In" click
230
+ agent-browser find text "Sign In" click --exact # Exact match only
231
+ agent-browser find label "Email" fill "user@test.com"
232
+ agent-browser find near "邮箱" fill "user@test.com" # plain text beside the field, no real label
233
+ agent-browser find placeholder "Search" fill "query"
234
+ agent-browser find alt "Logo" click
235
+ agent-browser find title "Close" click
236
+ agent-browser find testid "submit-btn" click
237
+ agent-browser find first ".item" click
238
+ agent-browser find last ".item" click
239
+ agent-browser find nth 2 "a" hover
240
+ ```
241
+
242
+ ## Browser Settings
243
+
244
+ ```bash
245
+ agent-browser set viewport 1920 1080 # Set viewport size (kept across relaunches and new tabs)
246
+ agent-browser set viewport 1920 1080 2 # 2x retina (same CSS size, higher res screenshots)
247
+ agent-browser set device "iPhone 14" # Emulate a device: viewport, user agent and touch input (touch events exist after the next navigation)
248
+ agent-browser set geo 37.7749 -122.4194 # Set geolocation (alias: geolocation)
249
+ agent-browser set offline on # Toggle offline mode
250
+ agent-browser set headers '{"X-Key":"v"}' # Extra HTTP headers
251
+ agent-browser set credentials user pass # HTTP basic auth for current and future tabs (alias: auth)
252
+ agent-browser set media dark # Emulate color scheme
253
+ agent-browser set media light reduced-motion # Light mode + reduced motion
254
+ ```
255
+
256
+ Viewport scales and geolocation coordinates must be finite numbers.
257
+
258
+ ## Cookies and Storage
259
+
260
+ ```bash
261
+ agent-browser cookies # Get all cookies
262
+ agent-browser cookies set name value # Set cookie
263
+ agent-browser cookies clear # Clear cookies
264
+ agent-browser storage local # Get all localStorage
265
+ agent-browser storage local key # Get specific key
266
+ agent-browser storage local set k v # Set value
267
+ agent-browser storage local clear # Clear all
268
+ ```
269
+
270
+ Reads accept at most one key, sets require one key and one value, and clears take no operands. A bare key is shorthand for a one-key read.
271
+
272
+ Cookie operations are `get` (the default), `set`, and `clear`; unknown operations return an error. Cookie attributes use kebab-case flags such as `--http-only` and `--same-site`. The legacy `--httpOnly` and `--sameSite` spellings remain accepted. When setting one cookie, unknown flags and extra arguments return an error.
273
+
274
+ ```bash
275
+ agent-browser cookies set session_id abc123 --http-only --same-site Strict
276
+ ```
277
+
278
+ ## Network
279
+
280
+ ```bash
281
+ agent-browser network route <url> # Intercept requests
282
+ agent-browser network route <url> --abort # Block requests
283
+ agent-browser network route <url> --body '{}' # Mock response
284
+ agent-browser network route <url> --body '{}' --allow-origin https://www.example.com # Mock a cross-origin API for that page
285
+ agent-browser network unroute [url] # Remove routes
286
+ agent-browser network requests # View tracked requests
287
+ agent-browser network requests --filter api # Filter requests
288
+ agent-browser network request <requestId> # Full request/response detail incl. body
289
+ agent-browser network har start # Record traffic (embeds text response bodies)
290
+ agent-browser network har start --content all # Embed all bodies (binary as base64)
291
+ agent-browser network har start --content none # Sizes and headers only
292
+ agent-browser network har stop [output.har] # Stop and save HAR
293
+ ```
294
+
295
+ If HAR export fails, recording and captured requests remain available. Fix the destination and retry `network har stop`.
296
+
297
+ `har stop` fails with `no_har_recording` when no recording is active, for example after a daemon restart (`close` or idle shutdown).
298
+
299
+ ## Saved flows
300
+
301
+ Experimental. A run can fail on a page that changed or answers differently each time; when it does, the flow is marked unverified and you continue with the UI.
302
+
303
+ ```bash
304
+ agent-browser --capture flow open <url> # Open a session that records its commands and requests
305
+ agent-browser flow steps [--json] # Recorded steps: seq, command, URL, request count, ok or failed
306
+ agent-browser flow save <name> [--param k=v]... [--output <id>] [--description <text>] [--timeout <ms>] # Keep first-party JSON requests, turn values into params; --output takes a saved id (s1r1, numbered within the range) or a capture id s<step>r<n>; an id that means two requests is refused
307
+ agent-browser flow save <name> --from <seq> --to <seq> # Save a range of steps
308
+ agent-browser flow run <name> [--param k=v]... [--timeout <ms>] # Send over HTTP, falling back to the page and then a replay; --timeout bounds the whole run
309
+ agent-browser flow run <name> --where field=value --fields a,b.c --limit 5 # Return only matching items and fields
310
+ agent-browser flow list [--origin <host>] # Saved flows, with params and verified state
311
+ ```
312
+
313
+ `flow save` waits for first-party requests the range's last step started that have no response yet, up to the command timeout (`--timeout` to wait less); a response whose body gets no bytes for 500 ms after its headers (a long poll) is not waited on. Requests left out are reported as `still loading at save`, also in the error when nothing else was recorded.
314
+
315
+ `--capture flow` is a launch setting: on a running session without capture it relaunches the browser with capture on, and later commands that repeat or omit it do not relaunch. Every recorded command returns `recorded: {seq}` in JSON. Failed commands stay in the recording with `ok: false`. Saving does not stop the capture, so one session can save several flows; by default `flow save` starts at the last navigation after the previous save. `close` reports `unsaved: {steps: N}` when steps after the last save exist. `har stop` is unavailable while capture is on; use `flow save`.
316
+
317
+ `flow save` keeps first-party JSON responses and, for pages rendered on the server, JSON the HTML embeds (`__NEXT_DATA__`, JSON-LD, `window.x = {...}` state); a run fetches the page and reads the same block back. `flow save` also finds params on its own: a value the task sent that came from an item of an earlier response (an id picked from a list) becomes a param, and a value copied from a single field (a session key) is filled from that response on every run. The save report lists them, plus the steps it could not turn into requests and why, such as a login the recording stopped at.
318
+
319
+ Flows live in `~/.agent-browser/flows/<origin>/<name>.json` (override with `AGENT_BROWSER_FLOWS_DIR`) and are `version: 1`; a file with an unknown field fails to load. A replay sends only the interaction fields of each recorded command and runs under the current session's settings, plugins and action policy, whatever the flow file carries. Cookies, `authorization` and token or CSRF headers are never saved. The value of a credential parameter (`token`, `csrf`, `auth`, `apikey`, `signature`, `password`; not pagination cursors like `pageToken`) in a navigation URL, the start URL or a write is saved as `<redacted>`, and that step is not replayed; a saved request's own URL is sent as recorded. A value typed with `fill`, `type`, `keyboard type` or `inserttext` is saved as a param (`{{name}}` in the step, no copy of the value, so a run needs `--param name=value`) or, when the field is a password, `one-time-code`, `cc-*` or otherwise secret, as `<redacted>`. A run tries direct HTTP, then the request from the page, then a replay of the recorded commands, and starts the next run at the tier that worked; a transport error or a skipped tier does not move it. Every tier checks the response shape against the recording; a mismatch on every tier fails the run with `drifted`, naming the missing key, and marks the flow unverified (use the page, then save again). A run that a later tier answered after a mismatch returns the data with `verified: false` and `drift`, and the flow is unverified too. A read also goes on to the next tier after a network error, and after a 5xx once an earlier tier saw the site change; any other non-drift failure of a read, such as a 4xx rejecting the params, ends the request. A 401 or 403 stops the run with `auth_expired`. When the recording sent a credential header the file does not keep, or the request carries a recorded signature or timestamp header with a per-request value (`X-Sig`, `X-Ts`, nonce, hmac), the HTTP and in-page tiers may only lack what the page adds, so the run goes on to the replay, where the page's own scripts send fresh values; a 401 or 403 from the replay is `auth_expired`. If the replay cannot get an answer, the run reports `credential_not_sendable` (use the page UI, signing in again does not help) or `request_signed` (the signature expires, use the page). A 429 stops the run with `rate_limited` (and `retryAfter` when the site sent one) and a bot challenge with `blocked`, and a host that resolves to an address a run does not send to with `address_refused` (nothing is sent); no other tier is tried. A run that stops after a tier saw the shape change also marks the flow unverified. A write with no answer, answered with a 5xx or 408, answered with a redirect, or answered with a 2xx that is not JSON (a login page or a bot challenge, say) returns `outcome_unknown` and is never sent again: check the site before rerunning; a write answered with a 2xx JSON body of a different shape was applied, returns `write_applied`, marks the flow unverified and must not be repeated; a write rejected with another 4xx was not applied. Requests, redirects and navigations outside the base domain of the flow's start URL are rejected, regardless of `--allowed-domains`. A direct request goes only to public addresses, checked when each host resolves and on every redirect: a host that resolves to a loopback, private or link-local address fails with `resolved to a non-public address` and nothing is sent (a flow recorded against `localhost` runs only against loopback, one against a local IP or a name the browser reached directly only at local addresses, saved as `"reach": "loopback"` or `"reach": "local"`, only against local addresses and never link-local or cloud metadata; a recording through a proxy or from cache is not marked local and the save report says why in `reachNote`). A proxy from `HTTP_PROXY`, `HTTPS_PROXY` or `ALL_PROXY` is used at any address and checks the requests that go through it, not agent-browser; a target excluded by `NO_PROXY` is checked like any other. A proxy name that is an `https://` hostname is trusted by the resolver, so a direct target with that same name skips the filter. The replay tier runs only plain interactions and stops when the tab leaves the site. The in-page tier is skipped unless the active tab is on the flow's site. `flow save` lists the flow's writes with ids: explicit ones (non-GET, GraphQL mutations) and suspected ones (a GET whose path has a whole `logout`, `signout`, `unsubscribe`, `delete` or `remove` segment). `flow run <name> --allow-write <all|id,...>` sends the writes it covers; any other write asks for confirmation as policy action `flow_write:<id>`, which `--action-policy` and `--confirm-actions` also see.
320
+
321
+ ## Tabs and Windows
322
+
323
+ ```bash
324
+ agent-browser tab # List tabs with tabId and label
325
+ agent-browser tab new [url] # New tab
326
+ agent-browser tab new --label docs [url] # New tab with a memorable label
327
+ agent-browser tab claim --url <url> [--title <text>] # Bind the session to one already-open tab and pin it
328
+ agent-browser tab t2 # Switch to tab by id
329
+ agent-browser tab docs # Switch to tab by label
330
+ agent-browser tab close # Close current tab
331
+ agent-browser tab close t2 # Close tab by id
332
+ agent-browser tab close docs # Close tab by label
333
+ agent-browser tab keep live [t<N>|label] # Keep a tab at full speed in the background
334
+ agent-browser tab keep throttled [t<N>|label] # Return a tab to the default throttling
335
+ agent-browser tab keep frozen <t<N>|label> # Pause a background tab until you switch to it
336
+ agent-browser window new # New window
337
+ ```
338
+
339
+ Tab ids are stable strings of the form `t1`, `t2`, `t3`. They're never reused within a session, so the same id keeps referring to the same tab across commands. Positional integers are **not** accepted — `tab 2` errors with a teaching message; use `t2`.
340
+
341
+ User-assigned labels (`docs`, `app`, `admin`) are interchangeable with ids everywhere a tab ref is accepted. Labels are the agent-friendly way to write multi-tab workflows:
342
+
343
+ ```bash
344
+ agent-browser tab new --label docs https://docs.example.com
345
+ agent-browser tab new --label app https://app.example.com
346
+ agent-browser tab docs # switch to docs
347
+ agent-browser snapshot # populate refs for docs
348
+ agent-browser click @e1 # ref click on docs
349
+ agent-browser tab app # switch to app
350
+ agent-browser tab close docs # close by label
351
+ ```
352
+
353
+ Labels are never auto-generated, never rewritten on navigation, and must be unique within a session. A label starts with a letter and contains only letters, digits, `-`, or `_`, and cannot use the reserved `t<N>` or `T<N>` tab-id form. Rejected labels preserve the current tab's refs and selected frame. To interact with another tab, switch to it first: the daemon maintains a single active tab, so refs (`@eN`) belong to the tab that was active when the snapshot ran.
354
+
355
+ Tabs opened through `tab new` or `click --new-tab` inherit the session's setup before their first document loads: user agent, `set headers`, `set credentials`, origin-scoped `--headers`, init scripts, `route` rules, and emulation overrides (color scheme, timezone, locale, geolocation, offline). Turning offline mode off or setting headers to `{}` restores the default setup for future tabs.
356
+
357
+ `tab claim` binds the session to a tab that is already open without moving or focusing it, and pins the session. The URL is matched exactly first, then as a case-insensitive substring; `--title` narrows it. Zero matches or more than one fail closed, and a tab pinned by another live session is refused.
358
+
359
+ `tab list --json` also reports each tab's CDP `targetId`, accepted anywhere a tab ref is accepted (`tab <targetId>`, `tab close <targetId>`). Target ids stay stable across daemon restarts, unlike `t<N>` ids, which are per-daemon counters. With `--pin-tab` the session is pinned to its bound tab: if that tab is closed, commands fail with a `tab_gone` error instead of falling back to another tab, and `tab new` or `tab list` recover. JSON errors include `code: "tab_gone"` and a recovery object with `data.targetId` plus optional sanitized `data.lastUrl`; batch uses `result` for the same object.
360
+
361
+ Switching to a tab that the browser discarded to save memory reactivates it, since a discarded tab has no renderer to drive. Reactivation reloads the page and resets its unsaved state, and the switch result adds `"revived": true` so the reload is not silent. A tab whose page is paused by a JavaScript dialog is alive rather than discarded: the switch leaves it untouched and adds `"dialogBlocked": true`. Resolve the dialog with `dialog accept`/`dialog dismiss` and its state is preserved. Closing the active tab onto a discarded successor revives it the same way and reports `"activeTabRevived": true`.
362
+
363
+ Chrome slows every tab that is not in front: timers fire about once per second and animation frames stop, so a page you leave in the background falls behind and you read stale state when you switch back. `tab keep live` keeps one tab running at full speed in the background, and `tab keep throttled` returns it to the default. Without a tab ref both apply to the active tab. The daemon holds focus emulation on a live tab, so the page reports `document.visibilityState === "visible"` and `document.hasFocus() === true` while another tab is in front, and the setting survives reloads and navigation. A live tab uses as much CPU as a front tab (five busy background tabs: 0.05 CPU cores throttled, 0.73 live), so set it only on tabs that have to keep running. `tab keep frozen <tab>` pauses a background tab completely until you switch back to it, which returns it to `throttled`. The active tab can't be frozen, and neither can a tab that is still visible: switch to another tab first, then freeze it by ref. Closing the session unfreezes the tabs it froze. A tab pinned by another session with `--pin-tab` is refused with `tab_locked`. `tab list` shows `(live)` or `(frozen)` in text and `"keep"` in JSON. Chrome only. In a browser attached with `--cdp` or `--auto-connect`, a live tab's timers reach the full rate only if that browser was started with `--disable-renderer-backgrounding`; without it a 100 ms timer fired 6 to 8 times per second instead of 10.
364
+
365
+ ## Frames
366
+
367
+ ```bash
368
+ agent-browser frame "#iframe" # Switch to iframe by CSS selector
369
+ agent-browser frame @e3 # Switch to iframe by element ref
370
+ agent-browser frame main # Back to main frame
371
+ ```
372
+
373
+ ### Iframe support
374
+
375
+ Iframes are detected automatically during snapshots. When the main-frame snapshot runs, `Iframe` nodes are resolved and their content is inlined beneath the iframe element in the output (frames inside frames are followed too, up to six levels deep).
376
+
377
+ ```bash
378
+ agent-browser snapshot -i
379
+ # @e3 [Iframe] "payment-frame"
380
+ # @e4 [input] "Card number"
381
+ # @e5 [button] "Pay"
382
+
383
+ # Interact directly — refs inside iframes already work
384
+ agent-browser fill @e4 "4111111111111111"
385
+ agent-browser click @e5
386
+
387
+ # Or switch frame context for scoped snapshots
388
+ agent-browser frame @e3 # Switch using element ref
389
+ agent-browser snapshot -i # Snapshot scoped to that iframe
390
+ agent-browser frame main # Return to main frame
391
+ ```
392
+
393
+ The `frame` command accepts:
394
+ - **Element refs** — `frame @e3` resolves the ref to an iframe element
395
+ - **CSS selectors** — `frame "#payment-iframe"` finds the iframe by selector
396
+ - **Frame name/URL** — matches against the browser's frame tree
397
+
398
+ ## Dialogs
399
+
400
+ By default, `alert` and `beforeunload` dialogs are automatically accepted so they never block the agent. `confirm` and `prompt` dialogs still require explicit handling. Use `--no-auto-dialog` to disable this behavior.
401
+
402
+ ```bash
403
+ agent-browser dialog accept [text] # Accept dialog
404
+ agent-browser dialog dismiss # Dismiss dialog
405
+ agent-browser dialog status # Check if a dialog is currently open
406
+ ```
407
+
408
+ ## JavaScript
409
+
410
+ ```bash
411
+ agent-browser eval "document.title" # Simple expressions only
412
+ agent-browser eval -b "<base64>" # Any JavaScript (base64 encoded)
413
+ agent-browser eval --stdin # Read script from stdin
414
+ ```
415
+
416
+ When the top-level Chrome/CDP `eval` result is a value JSON cannot represent, plain output prints its exact JavaScript token, including `NaN`, `Infinity`, `-Infinity`, `-0`, BigInt literals, and `undefined`. With `--json`, `data.result` stays `null` and sibling `data.unserializable` contains the token. MCP text prints the token, and structured responses expose it at `structuredContent.response.data.unserializable`.
417
+
418
+ Use `-b`/`--base64` or `--stdin` for reliable execution. Shell escaping with nested quotes and special characters is error-prone.
419
+
420
+ ```bash
421
+ # Base64 encode your script, then:
422
+ agent-browser eval -b "ZG9jdW1lbnQucXVlcnlTZWxlY3RvcignW3NyYyo9Il9uZXh0Il0nKQ=="
423
+
424
+ # Or use stdin with heredoc for multiline scripts:
425
+ cat <<'EOF' | agent-browser eval --stdin
426
+ const links = document.querySelectorAll('a');
427
+ Array.from(links).map(a => a.href);
428
+ EOF
429
+ ```
430
+
431
+ ## Authentication and Plugins
432
+
433
+ ```bash
434
+ agent-browser auth save <name> --url <url> --username <user> --password-stdin
435
+ agent-browser auth login <name> # Login using saved credentials
436
+ agent-browser auth login <name> --no-navigate
437
+ # Use active page after same-origin validation
438
+ agent-browser auth login <name> --credential-provider <plugin> [--item <ref>] [--url <url>]
439
+ agent-browser auth login <name> --username-selector <s> --password-selector <s> [--submit-selector <s>]
440
+ agent-browser auth list # List saved auth profiles
441
+ agent-browser auth show <name> # Show profile metadata, no passwords
442
+ agent-browser auth delete <name> # Delete a saved profile
443
+ agent-browser plugin add <ref> # Add a plugin from npm or GitHub (writes ~/.agent-browser/config.json; --project writes ./agent-browser.json for use with --config)
444
+ agent-browser plugin list # List configured plugins
445
+ agent-browser plugin show <name> # Show one configured plugin
446
+ agent-browser plugin run <name> <type> --payload <json>
447
+ # Run an arbitrary plugin request
448
+ ```
449
+
450
+ `auth login` filters matching controls by their layout size, computed visibility and opacity, and disabled/readonly state, including custom CSS selectors. If a selected credential field is replaced or redirects focus before entry, the command fails without submitting.
451
+
452
+ `auth login` normally navigates to the effective credential URL. `--no-navigate` requires an existing active top-level HTTP(S) page, checks that its scheme, host, and effective port match the effective credential URL, then uses the normal selector waits, fills, and submit click without replacing the document. Paths, queries, and fragments may differ, and submit-triggered navigation remains enabled. Command-level `--url` takes precedence over stored or provider metadata and becomes the expected-origin constraint in this mode.
453
+
454
+ Credential provider plugins run out-of-process over the `agent-browser.plugin.v1` stdio JSON protocol and must declare `credential.read`. Use `--confirm-actions plugin:<name>:credential.read` to require explicit approval before a plugin resolves secrets.
455
+
456
+ Other capabilities use the same protocol:
457
+ - `browser.provider`: `agent-browser --provider <name> open <url>`
458
+ - `launch.mutate`: append local launch args, extensions, or init scripts
459
+ - `command.run`: `agent-browser plugin run <name> <type> --payload <json>`
460
+
461
+ A `browser.provider` plugin that returns `directPage: true` connects to a page socket, so console messages, network requests, HAR recording, tracing, and profiling apply to that page.
462
+
463
+ `plugin run` is for `command.run` and custom capabilities. Core capabilities and protocol request types use their dedicated command paths.
464
+
465
+ ## State Management
466
+
467
+ ```bash
468
+ agent-browser state save auth.json # Save cookies, storage, auth state
469
+ agent-browser state load auth.json # Restore saved state
470
+ ```
471
+
472
+ ## Live Streaming
473
+
474
+ ```bash
475
+ agent-browser stream status --json # Enabled state, port, client count
476
+ agent-browser stream enable # Start the WebSocket stream server
477
+ agent-browser stream enable --port 9223
478
+ agent-browser stream disable # Stop it
479
+ ```
480
+
481
+ Clients connect to `ws://127.0.0.1:<port>` and receive `frame`, `status`, `tabs`, `url`, and `console` messages. They send `input_mouse`, `input_keyboard`, and `input_touch` to drive the page, `{"type":"config","maxFps":N}` (1 to 120, `0` = uncapped) to cap their own frame rate, and `{"type":"config","pacing":"ack"}` to receive one frame at a time, acknowledged with `{"type":"ack","seq":N}`. Both settings can be declared on the URL instead (`ws://127.0.0.1:<port>/?pacing=ack&maxFps=10`). See [streaming.md](streaming.md).
482
+
483
+ ## WebMCP page tools
484
+
485
+ Experimental. Browser responses announce a tool list (names, frame IDs, and descriptions) on first discovery and when the catalog changes. Catalogs of up to four tools show full descriptions; larger ones show up to 16 tools with descriptions shortened to 160 bytes, and the announcement says how many are listed. Choose a relevant tool, fetch its schema when the description does not show the arguments, then invoke it within the user's task. Schemas and annotations are never included proactively. Omission means no update; an empty or unavailable update invalidates earlier tools. Support is enabled by default in managed Chrome; `--no-webmcp` or `AGENT_BROWSER_NO_WEBMCP` opts out. See [trust-boundaries.md](trust-boundaries.md#webmcp-tools-are-page-content) for how to treat tool metadata and results.
486
+
487
+ ```bash
488
+ agent-browser webmcp list <tool> --frame <frame-id> --json # One tool's schema
489
+ agent-browser webmcp list --json # Full catalog, or recover context after compaction
490
+ agent-browser webmcp invoke <tool> --frame <frame-id> '{"key":"value"}'
491
+ agent-browser webmcp invoke <tool> --params '{"key":"value"}' # Same as the line above
492
+ agent-browser webmcp invoke <tool> --params @input.json --detach
493
+ agent-browser webmcp result <invocation-id>
494
+ agent-browser webmcp cancel <invocation-id>
495
+ ```
496
+
497
+ ## Observability Dashboard
498
+
499
+ ```bash
500
+ agent-browser dashboard start
501
+ agent-browser dashboard start --port 8080
502
+ agent-browser dashboard start --allowed-origins https://dashboard.example.com
503
+ agent-browser dashboard stop
504
+ ```
505
+
506
+ The dashboard runs on port 4848 by default, independent of browser sessions. It can also be opened through a proxied or forwarded URL such as `https://dashboard.agent-browser.localhost`; stay on the dashboard origin, because session tabs, status, and stream traffic are proxied internally and session ports do not need to be exposed. Loopback origins are allowed by default over IPv4 and IPv6 without an access token. Set `--allowed-origins` or `AGENT_BROWSER_DASHBOARD_ALLOWED_ORIGINS` to a comma-separated list of exact HTTPS reverse-proxied origins. Every origin must be valid, and custom ports must be integers from 1 to 65535. Unknown options, missing values, invalid ports, and malformed origins fail without starting the server. The command prints private tokenized access URLs only for external origins; open the matching URL once to establish the browser session and do not share it. The URL's token is carried in the initial fragment, then stored in a Secure, host-bound, same-site cookie for dashboard API and stream requests. Configure the reverse proxy to redact cookies from logs. The dashboard rejects requests with missing or cross-origin browser provenance. Open `http://localhost:<port>` directly for local access. Repeated starts reuse the running dashboard only when the port and allowed origins match; stop it before changing either setting.
507
+
508
+ ## Browser installation
509
+
510
+ `agent-browser install` downloads Chrome for Testing. On macOS versions below 13, the command stops before the download and prints instructions to update macOS or install Chrome manually. If `sw_vers -productVersion` is unavailable, exits with an error, returns no version, or returns a malformed version, the command reports a detection error and stops before making a network request. On Linux, `--with-deps` also installs system dependencies and exits nonzero if the package manager cannot install every required browser library.
511
+
512
+ At launch, agent-browser uses the browser from `agent-browser install` first. When that is missing, it falls back to a system Chrome (on macOS, Chrome, Chrome Canary, Chromium, and Brave in `/Applications`, then in `~/Applications`), then to the Puppeteer and Playwright caches.
513
+
514
+ ## Diagnostics
515
+
516
+ Run `doctor` first when a command fails unexpectedly (`Unknown command`, `Failed to connect`, stale daemons, version mismatches after `upgrade`, missing Chrome).
517
+
518
+ ```bash
519
+ agent-browser doctor # Full diagnosis: env, Chrome, daemons, config, providers, network, launch test
520
+ agent-browser doctor --offline --quick # Fast, local-only
521
+ agent-browser doctor --fix # Also run destructive repairs (reinstall Chrome, purge old state)
522
+ agent-browser doctor --json # Structured output
523
+ agent-browser doctor --webgpu # Check the WebGPU pipeline
524
+ ```
525
+
526
+ `doctor` cleans stale socket, pid, and version sidecar files on every run. Destructive actions require `--fix`. The exit code is `0` when all checks pass (warnings allowed) and `1` when any fail.
527
+
528
+ ## MCP Server
529
+
530
+ ```bash
531
+ agent-browser mcp
532
+ agent-browser mcp --tools all
533
+ agent-browser mcp --tools core,network,react
534
+ agent-browser mcp call agent_browser_open '{"url":"https://example.com"}'
535
+ echo '{"selector":"@e2"}' | agent-browser mcp call agent_browser_click -
536
+ ```
537
+
538
+ Starts a stdio Model Context Protocol server. MCP clients should configure the server command as `agent-browser` with args `["mcp"]`. The server defaults to MCP protocol 2025-11-25 and accepts older supported client protocol versions during initialization.
539
+
540
+ `mcp call` runs one MCP tool without a stdio session and prints its `tools/call` result as JSON, with the agent-browser version in `_meta.agentBrowserVersion`. Pass the tool arguments as a JSON object, or `-` to read them from stdin. Every tool is available unless `--tools` limits the call to profiles. The exit code is 0 on success, 1 when the tool reports an error, and 2 for an unknown tool or invalid arguments. Use it from runtimes that cannot keep a stdio session open between tool calls, such as serverless agents. Access settings such as `AGENT_BROWSER_ALLOWED_DOMAINS` come from the environment, as with the server. In a Vercel Sandbox, `startAgentBrowserMcp` from `@agent-browser/sandbox/vercel` runs the server over the sandbox command's stdin.
541
+
542
+ For tool calls that run the CLI, `structuredContent.response` contains parsed CLI JSON. `stdout` is included only when the output cannot be parsed as JSON; `exitCode` and `stderr` are always included.
543
+
544
+ The default tools profile is `core`, which keeps MCP context small for everyday browser automation. Use `--tools all` for the full typed CLI parity surface, or combine profiles with commas, such as `--tools core,network,react`.
545
+
546
+ Profiles:
547
+
548
+ - `core` - Default. Navigation, snapshots, interaction, waits, reads, screenshots, JavaScript eval, close, tab basics, and profile discovery
549
+ - `network` - Network routes, request inspection, HAR, headers, credentials, offline
550
+ - `state` - Cookies, storage, auth, saved state, sessions, profiles, skills
551
+ - `debug` - Console/errors, tracing, profiling, recording, a11y audit, clipboard, plugins, doctor, dashboard, install, upgrade, chat, diff, batch, confirm/deny
552
+ - `tabs` - Back/forward/reload, tabs, windows, frames, dialogs
553
+ - `react` - React tree/inspect/renders/suspense, vitals, pushstate
554
+ - `mobile` - Viewport/device/geolocation/media, touch, swipe, mouse, keyboard
555
+ - `all` - Every MCP tool, including the full typed CLI parity surface
556
+
557
+ Common tools include:
558
+
559
+ - `agent_browser_tools_profiles`
560
+ - `agent_browser_open`
561
+ - `agent_browser_snapshot`
562
+ - `agent_browser_click`
563
+ - `agent_browser_fill`
564
+ - `agent_browser_type`
565
+ - `agent_browser_press`
566
+ - `agent_browser_wait_for_selector`
567
+ - `agent_browser_screenshot`
568
+ - `agent_browser_get_url`
569
+ - `agent_browser_eval`
570
+ - `agent_browser_close`
571
+
572
+ Tool calls use the same config files and environment variables as the CLI by default. Each tool accepts typed arguments plus `extraArgs` for per-command options and display or emulation flags such as `--engine`; `extraArgs` cannot set `--config` or global flags that change network, file, policy, or host access. Set host-wide options in the MCP server's environment or selected config. The typed `allowedDomains` argument is rejected when the server's environment or selected config already sets allowed domains. The common `allowedDomains` array maps to `--allowed-domains` and activates the same WebRTC containment and launch-mode restrictions. Tool discovery is paginated and includes read-only/open-world annotations so modern MCP clients can load the large typed surface incrementally. Use the `session` tool argument or `AGENT_BROWSER_SESSION` to isolate browser state. Undeclared argument keys are rejected with an invalid-params error that names them. The typed `idleTimeout` argument maps to `--idle-timeout`. The typed `relaunch` argument maps to `--relaunch`; `open` and `tab_new` list it in their schema. The typed `button` and `modifiers` arguments on `agent_browser_click` and `agent_browser_dblclick` map to `--button` and `--modifiers`; `agent_browser_dblclick` also accepts `human`.
573
+
574
+ For eve agents, mount the `@agent-browser/eve` extension instead of hand-writing browser tools. It adds namespaced tools such as `browser__open`, `browser__snapshot`, `browser__click`, `browser__fill`, `browser__find`, and `browser__screenshot`, backed by agent-browser inside the eve sandbox. The sandbox bootstrap helpers (`installAgentBrowser`, `agentBrowserRevalidationKey`) ship in `@agent-browser/eve/sandbox`.
575
+
576
+ Pass `--config <trusted-path>` to `agent-browser mcp` or `agent-browser mcp call` to select one trusted config file. MCP tool child processes load only that file, replacing default user/project discovery. Put any required safety policy in it. Environment variables and accepted per-tool CLI arguments keep their normal precedence.
577
+
578
+ ## Configuration files
579
+
580
+ The auto-discovered `./agent-browser.json` accepts only `headed`, `json`, `debug`, `userAgent`, `hideScrollbars`, `annotate`, `colorScheme`, `maxOutput`, `screenshotQuality`, `screenshotFormat`, and `idleTimeout`. Other runtime keys, including `extensions`, `initScripts`, state, trust, policy, session, connection, and path settings, are ignored with a warning. The `$schema` key is ignored silently. Put advanced settings in `~/.agent-browser/config.json` or load a trusted file with `--config` or `AGENT_BROWSER_CONFIG`. An explicit config replaces default discovery and loads only that file.
581
+
582
+ ## Global Options
583
+
584
+ ```bash
585
+ agent-browser --session <name> ... # Isolated browser session
586
+ agent-browser --json ... # JSON output for parsing
587
+ agent-browser --headed ... # Show browser window (not headless; on displayless Linux an Xvfb display starts automatically)
588
+ agent-browser --webgpu ... # Enable WebGPU (SwiftShader software Vulkan on Linux, no GPU needed)
589
+ agent-browser --no-webmcp ... # Disable default experimental WebMCP Chrome features (or AGENT_BROWSER_NO_WEBMCP env)
590
+ agent-browser --cdp <port|url> ... # Connect via CDP; root query slash is optional
591
+ agent-browser --auto-connect ... # Connect to a running Chrome; works in its own pinned tab, never the tab in view
592
+ agent-browser --adopt-tab ... # With --auto-connect: work in the tab in view instead of a new one
593
+ agent-browser --cdp <url> --cdp-headers '{"Authorization":"Bearer <token>"}' ... # Auth headers for discovery and handshake
594
+ agent-browser --pin-tab ... # Pin the session to its bound tab (strict tab binding)
595
+ agent-browser --no-pin-tab ... # Disable a sticky pin previously enabled with --pin-tab
596
+ agent-browser -p <provider> ... # Browser provider or configured provider plugin
597
+ agent-browser --proxy <url> ... # Use proxy server
598
+ agent-browser --proxy-bypass <hosts> # Hosts to bypass proxy
599
+ agent-browser --headers <json> ... # HTTP headers scoped to URL's origin
600
+ agent-browser --executable-path <p> # Custom browser executable
601
+ agent-browser --args "--a,--b=x,y" # Launch args; commas inside a value are kept
602
+ agent-browser --extension <path> ... # Load browser extension (repeatable)
603
+ agent-browser --ignore-https-errors # Ignore SSL certificate errors
604
+ agent-browser --ca-cert <path> # Trust a CA for CLI requests, and in local Chromium on Linux (install --with-deps provides certutil)
605
+ agent-browser --no-ca-cert # Clear CA trust retained by the running session
606
+ agent-browser --use-system-ca # OS trust store for CLI requests (read, install, upgrade, doctor)
607
+ agent-browser --hide-scrollbars false # Keep native scrollbars visible in headless Chromium screenshots
608
+ agent-browser --engine <name> ... # chrome (default), lightpanda, obscura (experimental)
609
+ agent-browser --auto-connect ... # Connect to an already-running Chrome
610
+ agent-browser --no-auto-connect ... # Return an --auto-connect session to a local launch
611
+ agent-browser --profile <name|path> # Use a Chrome profile (login state survives)
612
+ agent-browser --state <path> ... # Load saved auth state from JSON
613
+ agent-browser --restore [name] ... # Auto-save and restore session state; defaults to --session
614
+ agent-browser --restore-save <policy> # auto (default), always, or never
615
+ agent-browser --namespace <name> ... # Isolate daemon sockets and restore-state directories
616
+ agent-browser --idle-timeout <time> # Daemon idle shutdown (default 1h; 0 disables)
617
+ agent-browser --relaunch ... # Relaunch the browser even when no setting changed; once per batch
618
+ agent-browser --help # Show help (-h)
619
+ agent-browser --version # Show version (-V)
620
+ agent-browser <command> --help # Show detailed help for a command
621
+ ```
622
+
623
+ ## Debugging
624
+
625
+ On Windows, owned headless Chrome runs on a private desktop so hidden windows cannot draw stray rectangles over the user's desktop. This applies to custom Chrome executables and windows created later through CDP. Headed and extension sessions use the interactive desktop. Owned Chrome trees are terminated when their daemon exits, including forced termination; attaching to an external browser does not take ownership of it.
626
+
627
+ ```bash
628
+ agent-browser --headed open example.com # Show browser window
629
+ agent-browser --cdp 9222 snapshot # Connect via CDP port
630
+ agent-browser connect 9222 # Alternative: connect command
631
+ agent-browser console # View console messages
632
+ agent-browser console --clear # Clear console
633
+ agent-browser errors # View page errors
634
+ agent-browser errors --clear # Clear errors
635
+ agent-browser highlight @e1 # Highlight element
636
+ agent-browser inspect # Open Chrome DevTools for this session
637
+ agent-browser trace start # Start recording trace
638
+ agent-browser trace stop trace.json # Stop and save trace
639
+ agent-browser profiler start # Start Chrome DevTools profiling
640
+ agent-browser profiler stop trace.json # Stop and save profile
641
+ ```
642
+
643
+ ## React / Web Vitals
644
+
645
+ Requires `--enable react-devtools` at launch for the `react ...` commands. `vitals` and `pushstate` are framework-agnostic.
646
+
647
+ ```bash
648
+ agent-browser open --enable react-devtools <url> # Launch with React hook installed
649
+ agent-browser react tree # Print the component tree
650
+ agent-browser react inspect <fiberId> # Props, hooks, state, source
651
+ agent-browser react renders start # Begin re-render recording
652
+ agent-browser react renders stop [--json] # Stop and print render profile
653
+ agent-browser react suspense [--only-dynamic] [--json] # Suspense boundaries + classifier
654
+ # --only-dynamic hides the "static" list
655
+ agent-browser vitals [url] [--json] # LCP/CLS/TTFB/FCP/INP + hydration
656
+ agent-browser pushstate <url> # SPA client-side nav (auto-detects Next router)
657
+ ```
658
+
659
+ `react tree` prints the component tree when one is available. If the response contains only a header, no tree was collected. Confirm the page uses React and that a React root has mounted.
660
+
661
+ `vitals` prints a summary by default and uses the same fields as the structured `--json` response.
662
+
663
+ ## Accessibility audit
664
+
665
+ Runs an embedded axe-core audit with no CDN fetch. The vendored engine runs private partial audits through CDP across the page's frame tree and merges serialized results without page messaging, so page CSP does not block it, page-provided `window.axe` values remain intact, and iframe violations retain their frame selector paths. Accessibility audits require a CDP browser and are not available with Safari or iOS WebDriver sessions. Reports WCAG violations with impact, rule id, fix guidance URL, and failing-node selectors.
666
+
667
+ ```bash
668
+ agent-browser a11y # Audit the current page
669
+ agent-browser a11y <url> # Navigate, then audit
670
+ agent-browser a11y --tags wcag2a,wcag2aa # Only rules with these axe tags
671
+ agent-browser a11y --selector "#main" # Scope audit to a subtree
672
+ agent-browser a11y <url> --json # Structured results for automation
673
+ ```
674
+
675
+ `--json` returns `counts` plus `violations`/`incomplete` arrays; each entry has `id`, `impact`, `help`, `helpUrl`, `tags`, `nodeCount`, and up to 10 `nodes` (`target` selector path arrays, `html` snippet, `failureSummary`). Nested `target` arrays preserve shadow DOM boundaries. `incomplete` lists rules axe could not evaluate automatically — review those manually.
676
+
677
+ ## Init scripts
678
+
679
+ ```bash
680
+ agent-browser --init-script <path> open <url> # Register before first navigation (repeatable)
681
+ agent-browser removeinitscript <identifier>
682
+ ```
683
+
684
+ Init-script identifiers are session-wide. `removeinitscript` removes a script from every open tab where it was registered and prevents it from being replayed into future tabs.
685
+
686
+ ## cURL cookie import
687
+
688
+ ```bash
689
+ agent-browser cookies set --curl <file> # Auto-detects JSON/cURL/Cookie-header
690
+ agent-browser cookies set --curl <file> --domain example.com # Scope to a domain
691
+ ```
692
+
693
+ Supported formats: JSON array of `{name, value}`, a cURL dump from DevTools -> Network -> Copy as cURL, or a bare Cookie header. Errors never echo cookie values.
694
+
695
+ ## Network route by resource type
696
+
697
+ ```bash
698
+ agent-browser network route '*' --abort --resource-type script # Block scripts only (SSR-lock pattern)
699
+ agent-browser network route '*' --resource-type image,font --body '' # Stub images and fonts
700
+ ```
701
+
702
+ ## Environment Variables
703
+
704
+ ```bash
705
+ AGENT_BROWSER_SESSION="mysession" # Default session name
706
+ AGENT_BROWSER_EXECUTABLE_PATH="/path/chrome" # Custom browser path
707
+ AGENT_BROWSER_EXTENSIONS="/ext1,/ext2" # Comma-separated extension paths
708
+ AGENT_BROWSER_INIT_SCRIPTS="/a.js,/b.js" # Comma-separated init script paths
709
+ AGENT_BROWSER_ENABLE="react-devtools" # Comma-separated built-in init script features
710
+ AGENT_BROWSER_HIDE_SCROLLBARS="false" # Keep native scrollbars visible in headless Chromium screenshots
711
+ AGENT_BROWSER_WEBGPU="1" # Enable the WebGPU launch preset (see references/webgpu.md)
712
+ AGENT_BROWSER_NO_XVFB="1" # Disable automatic Xvfb for headed mode on displayless Linux
713
+ AGENT_BROWSER_NO_VERSION_CHECK="1" # Skip the outdated-Chrome CVE check and its request to Google
714
+ AGENT_BROWSER_PROVIDER="browserbase" # Browser provider or configured provider plugin
715
+ BROWSER_USE_API_KEY="your-api-key" # Browser Use Cloud API key
716
+ BROWSER_USE_PROFILE_ID="profile-uuid" # Optional Browser Use profile UUID
717
+ BROWSER_USE_PROXY_COUNTRY="de" # Managed proxy country; none/direct disables proxy
718
+ BROWSER_USE_ENABLE_RECORDING="true" # Record the Browser Use Cloud session
719
+ AGENT_BROWSER_STREAM_PORT="9223" # Override WebSocket streaming port (default: OS-assigned)
720
+ AGENT_BROWSER_DASHBOARD_ALLOWED_ORIGINS="https://dashboard.example.com" # Trusted HTTPS reverse-proxied dashboard origins
721
+ AGENT_BROWSER_CONFIG="./agent-browser.json" # Custom config file
722
+ AGENT_BROWSER_CDP="9222" # Connect daemon to CDP port or WebSocket URL
723
+ AGENT_BROWSER_ALLOWED_DOMAINS="example.com" # Restrict network domains; requires a fresh controllable browser context without profile/session startup args, restore/state replay, or direct-page provider plugins
724
+ AGENT_BROWSER_PLUGINS='[{"name":"vault","command":"agent-browser-plugin-vault","capabilities":["credential.read"]},{"name":"stealth","command":"agent-browser-plugin-stealth","capabilities":["launch.mutate"]}]'
725
+ ```
726
+
727
+ Browser Use Cloud lifecycle: setup is bounded to 18s plus up to 4s for timeout cleanup (10s create, 8s CDP attach, 4s stop). `close` succeeds only after the Cloud session acknowledges it stopped; a failed stop returns an error, keeps the session id for retrying `close`, and blocks a new launch until released. If create fails before an id arrives, the outcome is unknown; inspect the Browser Use Cloud dashboard before retrying. If the daemon exits before a successful stop, inspect and stop the browser in Cloud.