agent-browser README

项目的 README,来自 github.com/vercel-labs/agent-browser。合并为一个 markdown 文件:README.md。

agent-browser

Browser automation for AI agents: open pages, read them as an accessibility tree, and act on elements from the shell.

Vercel Labs Product npm version: agent-browser License: Apache-2.0 npm downloads per month: agent-browser skills.sh

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)

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]

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.

See the Firefox engine guide.

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

License

Apache-2.0

agent-browser (vercel-labs/agent-browser)

正在搜索数据库…

这是什么?agent-browser 是专为 AI 智能体打造的浏览器自动化命令行工具,以快速的原生 Rust 二进制程序形式提供,可驱动 Chrome 完成脚本化或智能体式的网页交互。
这是要导入的代码库,还是独立的 CLI/MCP 工具?它是一个独立的命令行二进制程序(不是代码库),你可以直接调用,也可以将其配置为 MCP 工具供智能体使用;它通过后台守护进程驱动一个受管理的 Chrome 实例。
我该如何安装并开始使用?可以全局安装原生二进制程序(推荐),也可以通过 macOS 上的 Homebrew、Cargo 安装,或从源码构建;然后运行其安装命令获取 Chrome for Testing,之后再执行 click、fill、navigate 等命令行指令。
使用前需要先安装 Chrome、Node 或 Rust 吗?需要 Chrome。它可以通过 'agent-browser install' 自动下载,也可以检测已安装的 Chrome、Brave、Playwright 或 Puppeteer;只有从源码构建时才需要 Node.js 24+/pnpm 11+ 和 Rust。
等待或无障碍检查方面有什么需要注意的地方吗?networkidle 等待条件在使用 SSE、WebSocket、轮询或长轮询的页面上可能无法完成判定;无障碍审计仅适用于基于 CDP 的 Chrome,在 Safari 或 iOS WebDriver 会话中不可用。
这个工具在 macOS、Windows 和 Linux 上的使用方式都一样吗?是的,它可以在 macOS、Windows 和 Linux 上运行,但在 Linux 上你需要额外安装系统库,Chrome 才能正常启动。
什么是 WebMCP?它在这里有什么用?WebMCP 是一项实验性功能,默认开启,它让 agent-browser 能够发现并展示网页本身提供的工具,并在 CLI/MCP 响应中自动公布这些工具,使智能体能够调用页面原生的操作。
它能对网页进行无障碍检查吗?可以,它内置了 axe-core 引擎,能够离线运行完整的无障碍审计,返回违规项及其影响程度、规则 ID、选择器和修复建议,也可以输出结构化的 JSON 供自动化使用。
它对 React 应用有专门的支持吗?有,使用 --enable react-devtools 启动时会嵌入 React DevTools 钩子,便于查看 React 组件状态;此外,与框架无关的 Web Vitals 指标适用于任何应用。
我能把多个浏览器操作合并到一次调用中吗?可以,批量执行功能允许你以带引号的参数或通过 stdin 传入管道 JSON 的形式一次传递多条命令,从而避免为每条命令重复启动进程的开销,适合多步骤工作流。
大小
43.2 MB
星标
55.2K
时长
10个月
提交 · 90 天