Agent Browser
Use agent-browser CLI for full browser automation tasks. It is suitable when a page needs JavaScript rendering, real browser interaction, screenshots, or form automation.
Upstream project: https://github.com/vercel-labs/agent-browser
Platform Support
vercel-labs/agent-browser provides native builds for:
- macOS ARM64 / x64
- Linux ARM64 / x64
- Windows x64
Windows support in this skill targets Windows 11 x64 with PowerShell and Node.js 18+.
Prerequisites
Node.js 18+
npm available in PATH
Network access to install
agent-browserand download ChromiumAbout 500 MB free disk space for Chromium
The
nodebinary on PATH must actually execute code, not just print a version.agent-browserspawns a Node child process internally; if that Node is broken, the daemon will crash with no useful output even whenagent-browser --versionworks.Quick check:
node -e "console.log('ok')"If this does not print
ok(SIGILL / exit 133 / any crash), the Node on PATH is unusable. Fix it, or runagent-browserwith a known-good Node prepended to PATH for that command only:PATH="/path/to/working-node/bin:$PATH" agent-browser open <url>Inspect which Node would be picked up with
which -a node.
Installation
Inside the CodeBuddy marketplace,
scripts/setup.shauto-runs these steps on first load. The commands below are for manual setup or reinstall.
Windows PowerShell
npm install -g agent-browser
agent-browser install
macOS / Linux
npm install -g agent-browser
agent-browser install
Linux missing dependencies
agent-browser install --with-deps
Required Command Sequence
The current upstream agent-browser CLI does not require a separate launch command. agent-browser open <url> starts or connects to the browser daemon automatically.
Always follow this order:
- Open target URL.
- Wait for page load when needed.
- Inspect page with
snapshotorsnapshot -i. - Interact with the page.
- Close browser when done.
agent-browser open https://example.com
agent-browser wait --load networkidle
agent-browser snapshot
agent-browser close
Session Model
agent-browser runs a persistent background daemon. Understand this before planning multi-step tasks:
- The first
agent-browser openstarts a daemon; subsequent commands auto-connect to the same daemon. - Within one session, cookies, localStorage and login state are preserved across commands.
- Multiple
opencalls in the same session navigate the existing browser (no need to close between URLs). agent-browser closeends the daemon. Only call it when the whole task is finished, not between steps of the same task.
Implication: for a task that visits N URLs, do one open ... snapshot ... chain per URL and one close at the very end, not N open/close pairs.
Execution Principles
Apply these when running command sequences, especially in multi-step tasks:
closeis mandatory in finally: whether the task succeeds or fails midway, always runagent-browser closeat the end to avoid zombie daemons and leaked Chromium processes.waitis optional and degradable:wait --load networkidlecan hang on SPAs that never go idle. If a wait stalls, fall back towait --load loador skip waiting andsnapshotdirectly. Do not block the whole task onwait.- Reuse the daemon: in the same task, do not
closebetween intermediate steps. Open once, navigate/interact multiple times, close at the end. - Prefer
snapshot -ifor interaction: when you need to click or type, get interactive element IDs first viasnapshot -i, then act on them. Do not guess CSS selectors blindly. - Use agent-browser's own install channel: for Chromium, runtime, or dependency issues, stay inside agent-browser's own tooling —
agent-browser install, or theplaywright-coreCLI bundled under$(npm root -g)/agent-browser/node_modules/playwright-core. Do not runnpx playwright installin parallel; it can fetch a revision that does not match what agent-browser expects and may time out downloading browsers agent-browser never uses. - Fail fast on environment errors: if the very first
openfails with daemon / Chromium / SIGILL errors, do not retry the same command repeatedly. Verify the Prerequisite Node check, then consultreferences/troubleshooting.md.
When NOT to Use
agent-browser launches a real Chromium and consumes hundreds of MB plus a few seconds of cold start. Pick the lighter tool whenever possible:
| Need | Recommended tool |
|---|---|
| Fetch static HTML, plain text, or markdown of a page | WebFetch |
| Call a JSON / REST API | curl, fetch, or HTTP client |
| Read content already present in raw HTML | WebFetch |
| Render JavaScript-driven pages before reading | agent-browser |
| Click, type, login, or any multi-step interaction | agent-browser |
| Take a visual screenshot for review | agent-browser |
| Reproduce a real user flow end-to-end | agent-browser |
Rule of thumb: if curl <url> already contains the target content in plain HTML, do not start agent-browser.
Essential Commands
| Command | Description |
|---|---|
agent-browser open <url> |
Start or connect to the browser daemon and navigate to a URL. |
agent-browser wait --load networkidle |
Wait until network activity is idle. Useful after opening dynamic pages. |
agent-browser snapshot |
Get page content as text. |
agent-browser snapshot -i |
Get page content with element IDs for interaction. |
agent-browser screenshot |
Take a screenshot. |
agent-browser click <selector> |
Click an element. |
agent-browser type <selector> <text> |
Type text into an input. |
agent-browser close |
Close browser and free resources. |
Common Workflows
View webpage content
agent-browser open https://example.com
agent-browser wait --load networkidle
agent-browser snapshot
agent-browser close
Take screenshot
agent-browser open https://example.com
agent-browser wait --load networkidle
agent-browser screenshot
agent-browser close
Fill form and submit
First get interactive element IDs:
agent-browser open https://example.com/login
agent-browser wait --load networkidle
agent-browser snapshot -i
Then interact with stable selectors or element IDs:
agent-browser type "#username" "myuser"
agent-browser type "#password" "mypassword"
agent-browser click "#submit"
agent-browser close
Extract data from a JavaScript-rendered page
agent-browser open https://example.com/data
agent-browser wait --load networkidle
agent-browser snapshot
agent-browser close
Windows Notes
On Windows, prefer PowerShell for installation and verification:
npm install -g agent-browser
agent-browser install
agent-browser open https://example.com
agent-browser wait --load networkidle
agent-browser snapshot
agent-browser close
If the command is not found after installation, restart PowerShell or confirm npm global bin is in PATH:
npm config get prefix
Troubleshooting
For environment problems (daemon won't start, Chromium revision mismatch, SIGILL / Exit 133, install timeouts, etc.), see references/troubleshooting.md. It is organized by symptom so you can diagnose against the actual error message instead of following a fixed script.
Quick checks before going there:
agent-browsernot found after install: restart shell, confirm npm global bin is in PATH (npm config get prefix).- Linux browser launch missing system libs:
agent-browser install --with-deps. - Always run
agent-browser closewhen a task ends, even on failure paths.