站内导读
定位:agent-browser 是 Vercel Labs 用 Rust 写的 CLI,让 AI agent 在 shell 里逐条命令操作浏览器,适合把网页任务拆成小步执行的场景。
核心能力
- snapshot 把页面输出为紧凑文本,每个可交互元素带一个 @e1 形式的 ref。
- 浏览器进程在命令之间保持打开,每一步只是一次短小的 shell 调用。
- 除 ref 外还支持 CSS 选择器、文本、XPath 与 find role button 这类语义定位。
- 点击目标隐藏、禁用、在视口外或被弹窗遮挡时直接报错,不会返回成功。
适用人群:需要在脚本或 agent 循环里做浏览器自动化的开发者。需有 Node.js 环境,首次运行要下载 Chrome for Testing,Linux 另需系统依赖。
注意:页面跳转或 DOM 变化后 ref 失效,需重新 snapshot。
位置づけ:agent-browser は Vercel Labs が Rust で書いた CLI で、AI agent がシェルの中でコマンドを一つずつ実行しながらブラウザを操作できます。Web タスクを小さなステップに分けて実行する場面に向いています。
主な機能
- snapshot はページをコンパクトなテキストとして出力し、操作可能な要素ごとに @e1 形式の ref が付きます。
- ブラウザプロセスはコマンド間も開いたままで、各ステップは短いシェル呼び出し一つで済みます。
- ref のほか、CSS セレクタ、テキスト、XPath、find role button のような意味的な指定も使えます。
- クリック対象が隠れている、無効化されている、ビューポート外にある、ポップアップに覆われている場合は成功とせず、その場でエラーを返します。
対象ユーザー:スクリプトや agent のループの中でブラウザ自動化を行いたい開発者。Node.js 環境が必要で、初回実行時に Chrome for Testing をダウンロードし、Linux では別途システム依存が必要です。
注意:ページ遷移や DOM の変化で ref は失効するため、snapshot を取り直す必要があります。
정의: agent-browser는 Vercel Labs가 Rust로 작성한 CLI로, AI agent가 셸에서 명령을 하나씩 실행하며 브라우저를 조작할 수 있게 합니다. 웹 작업을 작은 단계로 나눠 실행하는 상황에 적합합니다.
핵심 기능
- snapshot은 페이지를 간결한 텍스트로 출력하며, 상호작용 가능한 요소마다 @e1 형식의 ref가 붙습니다.
- 브라우저 프로세스는 명령 사이에 계속 열려 있어, 각 단계가 짧은 셸 호출 하나로 끝납니다.
- ref 외에도 CSS 선택자, 텍스트, XPath, find role button 같은 의미 기반 지정을 지원합니다.
- 클릭 대상이 숨겨져 있거나, 비활성화됐거나, 뷰포트 밖에 있거나, 팝업에 가려져 있으면 성공으로 반환하지 않고 바로 오류를 냅니다.
대상 사용자: 스크립트나 agent 루프 안에서 브라우저 자동화를 하려는 개발자에게 적합합니다. Node.js 환경이 필요하고, 첫 실행 시 Chrome for Testing을 내려받으며, Linux에서는 시스템 의존성이 추가로 필요합니다.
참고: 페이지 이동이나 DOM 변화가 있으면 ref가 무효가 되므로 snapshot을 다시 찍어야 합니다.
What it is: agent-browser is a Rust CLI from Vercel Labs that gives an AI agent a browser it drives one shell command at a time, for step-by-step web automation.
Key capabilities
snapshotreturns the page as compact text, with a ref such as@e1attached to each interactive element.- The browser stays open between commands, so every step is one short shell call.
- Besides refs, CSS selectors, text, XPath and semantic locators like
find role buttonalso work. - A click on a hidden, disabled, off-viewport or covered target fails rather than reporting success.
Who it is for: developers putting browser automation into scripts or agent loops. Needs Node.js, a first-time Chrome for Testing download, and system libraries on Linux.
README · 详细文档
来源 · 查看原文
agent-browser
Browser automation for AI agents: open pages, read them as an accessibility tree, and act on elements from the shell.
agent-browser is a native Rust CLI that gives an AI agent a browser it can drive one command at a time. snapshot returns the page as compact text with a ref such as @e1 for each element. The agent acts on a ref, reads the page again to check the result, and repeats. The browser stays open between commands, so each step is one short shell call.
Install
npm install -g agent-browser
agent-browser install # download Chrome for Testing (first time only)
- Homebrew:
brew install agent-browser, thenagent-browser install. - Linux:
agent-browser install --with-depsalso installs the browser's system libraries. - No install:
npx agent-browser open example.com.
Project installs, building from source, upgrade, and doctor are covered in Installation.
Quick start
agent-browser open example.com
agent-browser snapshot -i # interactive elements, each with a ref
agent-browser click @e1 # act on a ref from that snapshot
agent-browser get url # check the result
agent-browser close
The snapshot for example.com:
- link "Learn more" [ref=e1]
- Refs describe the page at the time of the snapshot. After navigation or a DOM change, take a new snapshot before using refs again.
- CSS selectors, text, XPath, and semantic locators also work, for example
agent-browser find role button click --name "Submit". See Selectors. - A click fails, instead of reporting success, when the target is hidden, disabled, outside the viewport, or covered by another element such as a consent banner. Dismiss the covering element, take a new snapshot, and retry.
The full walkthrough is in the quick start.
How it works
The CLI sends each command to a background daemon that starts on the first command and controls the browser over the Chrome DevTools Protocol. Each --session gets its own daemon and browser. By default, the daemon closes a headless browser and exits after one hour without commands, saving state first when session persistence is configured.
Chrome for Testing is the default browser. You can also attach to a running Chrome with --cdp or --auto-connect (CDP mode), select the Lightpanda or Obscura engine with --engine, drive Mobile Safari in the iOS Simulator, or use a cloud browser provider such as Browserbase, Browserless, Browser Use, Kernel, or AgentCore.
For AI agents
The CLI ships skills that match its version:
agent-browser skills get core # the core loop, refs, waiting, and common workflows
agent-browser skills get core --ref commands # one reference, such as the full command list
agent-browser skills get core --full # adds the full command reference and templates
agent-browser skills list # specialized skills: electron, slack, dogfood, and more
Install the discovery skill into an agent harness from skills.sh:
npx skills add vercel-labs/agent-browser
The installed skill is a thin stub that tells the agent to load agent-browser skills get core, so its instructions always match the installed CLI. Or add this to your AGENTS.md:
Use `agent-browser` for browser automation. Before the first use, run
`agent-browser skills get core` and follow it.
For MCP clients, agent-browser mcp starts an MCP server over stdio. See MCP server.
Commands
Run agent-browser --help for the full list, or agent-browser <command> --help for one command.
| Group | Commands | Docs |
|---|---|---|
| Navigate and read | open, back, forward, reload, read, snapshot, get, is | Core, Snapshots |
| Interact | click, dblclick, fill, type, press, keyboard, hover, focus, select, check, uncheck, scroll, drag, upload, mouse, find | Core, Find elements |
| Wait | wait | Wait |
| Capture | screenshot, pdf, record, download, diff | Recording, Diffing, Files |
| Page and network state | cookies, storage, network, set, clipboard, eval, pushstate | Network, Settings |
| Tabs, frames, and dialogs | tab, frame, dialog | Tabs and frames |
| Debug and performance | console, errors, highlight, inspect, trace, profiler, vitals, react, a11y | Debugging, Profiler, React |
| Sessions and auth | session, state, auth, profiles, confirm, deny | Sessions, Security |
| Agents and integrations | skills, mcp, webmcp, flow, chat, batch, plugin | Skills, WebMCP, Plugins |
| Observe | stream, dashboard | Streaming, Dashboard |
| Setup | install, upgrade, doctor, connect, close | Installation |
Flags, environment variables, and agent-browser.json are documented in Configuration.
Platforms
Native binaries ship for macOS (ARM64, x64), Linux (ARM64, x64, glibc and musl), and Windows (x64). The npm package picks the right binary for the host.
Development
Building from source requires Node.js 24 or later, pnpm 11 or later, and Rust:
pnpm install
pnpm build:source # builds the dashboard and the native CLI
pnpm link --global
agent-browser install
Run the Rust checks from cli/:
cargo fmt -- --check
cargo clippy
cargo test
cargo test e2e -- --ignored --test-threads=1 # launches real headless Chrome
AGENTS.md lists the files to update with each change, the docs checks, and the release process.
Documentation
- agent-browser.dev: introduction, guides, and reference
- Commands and Configuration
- Security: the auth vault, domain allowlists, action policies, and content boundaries
- Next.js and Vercel and eve: running agent-browser in Vercel Sandbox and eve agents
- Changelog
License
Apache-2.0