Chrome

Chrome(以及 Chromium)是默认的浏览器引擎。agent-browser 通过 Chrome DevTools Protocol (CDP) 自动发现、启动并管理 Chrome 进程。

二进制文件查找

当未提供 --executable-path 时,agent-browser 按以下顺序搜索 Chrome:

平台检查路径
macOS

/Applications/Google Chrome.app, /Applications/Google Chrome Canary.app, /Applications/Chromium.app, Playwright Chromium 缓存

Linux

google-chrome, google-chrome-stable, chromium-browser, chromium 在 PATH 中, Playwright Chromium 缓存

Windows

%LOCALAPPDATA%\Google\Chrome\Application\chrome.exe, C:\Program Files\Google\Chrome\Application\chrome.exe, C:\Program Files (x86)...\chrome.exe

如果未找到 Chrome,请运行 agent-browser install,通过 Playwright 下载 Chromium。

使用方式

Chrome 是默认引擎——无需指定 --engine 标志:

agent-browser open example.com

若需明确指定:

agent-browser --engine chrome open example.com

自定义二进制文件

使用 --executable-path 指向任意基于 Chromium 的浏览器:

agent-browser --executable-path /path/to/chromium open example.com

或通过环境变量设置:

export AGENT_BROWSER_EXECUTABLE_PATH=/path/to/chromium
agent-browser open example.com

Chrome 特有功能

这些功能仅在使用 Chrome 时可用:

功能标志
浏览器扩展--extension <path>
持久化配置文件--profile <path>
存储状态--state <path>
文件 URL 访问--allow-file-access
带界面模式--headed
自定义启动参数--args <args>

容器与 CI 环境

在 Docker、CI 运行器或其他沙箱环境中,可能需要禁用 Chrome 的用户命名空间沙盒:

agent-browser --args "--no-sandbox" open example.com

agent-browser 在检测到容器环境(如 Docker、Podman)或以 root 身份运行时,会自动添加 --no-sandbox