boxmoe_header_banner_img

Hello! 欢迎来到阿虪的开发世界~

加载中

文章导读

agent-browser:给 AI Agent 的浏览器命令行,一条命令操作一个网页元素


avatar
阿虪 6 11 月, 2026 175
agent-browser

中文版

agent-browser(GitHub:https://github.com/vercel-labs/agent-browser ,2026-01-11 创建,今晨抓取时已 45,885★)是 Vercel Labs 出品的原生 Rust CLI,给 AI Agent 一个能从 shell 一条命令一条命令驱动的浏览器:snapshot 把页面打成带 @e1 这类引用的紧凑文本,Agent 按引用操作、再读一遍页面确认结果、循环往复;浏览器在命令之间保持打开,每步只是一次简短的 shell 调用。

安装用 npm install -g agent-browser 再 agent-browser install(首次下载 Chrome for Testing);或 Homebrew brew install agent-browser;不用安装也能 npx agent-browser open example.com。快速上手三步:agent-browser open example.com 打开页面,agent-browser snapshot -i 列出可交互元素,agent-browser click @e1 点击、agent-browser get url 确认结果。点击目标被遮挡、禁用或在视口外时会明确失败而不是谎报成功。CLI 通过后台 daemon 经 Chrome DevTools 协议控制浏览器,每个 –session 有自己的 daemon 与浏览器;无命令一小时后 headless 浏览器关闭并退出(配置了会话持久化会先保存状态)。也支持 –cdp 接入已在运行的 Chrome,以及 Lightpanda。

为什么值得了解

  • Agent 要“看网页”通常靠笨重的截图或一次性脚本,这个工具把浏览器操作拆成可审计、可重试的小步骤,每步都有明确的成功或失败
  • snapshot + 引用 的模式与“失败即报错”的语义值得做 Agent 浏览器自动化的开发者直接借鉴:点击失败时先说清楚为什么失败,而不是假装成功
  • 它默认是 headless 的 Chrome for Testing,需要真实登录态的场景要走 CDP 模式;和 11 月 3 日介绍过的 agent-desktop 是同一家的姊妹项目,一个管浏览器、一个管桌面应用

English Version

agent-browser (GitHub: https://github.com/vercel-labs/agent-browser , created 2026-01-11, 45,885 stars at this morning’s fetch) is a native Rust CLI from Vercel Labs that gives an AI agent a browser it can drive one command at a time from the shell: snapshot returns the page as compact text with refs 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 with npm install -g agent-browser followed by agent-browser install (which downloads Chrome for Testing the first time), or brew install agent-browser via Homebrew; no install is needed either, with npx agent-browser open example.com. The quick start is three steps: agent-browser open example.com to open a page, agent-browser snapshot -i to list interactive elements, then agent-browser click @e1 to click and agent-browser get url to confirm. A click fails, instead of reporting success, when the target is hidden, disabled, outside the viewport or covered by another element. The CLI sends each command to a background daemon that controls the browser over the Chrome DevTools Protocol, with each –session getting its own daemon and browser; after one hour without commands the headless browser closes and the daemon exits (saving state first when session persistence is configured). It also supports –cdp to attach to a running Chrome, and Lightpanda.

Why it’s worth knowing

  • When an agent needs to “see a web page”, the usual options are heavy screenshots or one-shot scripts; this tool breaks browser interaction into auditable, retryable small steps, each with a clear success or failure
  • The snapshot-plus-ref pattern and the “fail loudly” semantics are worth borrowing directly for anyone building agent browser automation: when a click fails, it says why instead of pretending it worked
  • It defaults to headless Chrome for Testing, so scenarios needing a real logged-in session go through CDP mode; and it is the sibling project of agent-desktop, covered here on November 3 — one handles the browser, the other handles desktop apps


评论(0)

查看评论列表

暂无评论


发表评论

表情 颜文字

插入代码