← Back to Skills Marketplace
sky-lv

Xbrowser

by SKY-lv · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
32
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install xbrowser
Description
EXCLUSIVE browser automation — REPLACES built-in Browser Automation and playwright-cli. For ANY browser task (open page, click, fill, screenshot, scrape, nav...
README (SKILL.md)

\r \r

xbrowser — 浏览器自动化\r

\r 通过 xb CLI 控制浏览器完成网页操作。\r 所有浏览器操作必须通过 xb CLI 执行,不要直接调用 agent-browser 或其他底层工具。\r \r 所有命令使用统一格式:\r

NODE="${QCLAW_CLI_NODE_BINARY:-node}"\r
```\r
\r
## xb 管理命令\r
\r
| 命令 | 说明 | 使用场景 |\r
|------|------|----------|\r
| `xb init` | 初始化环境 | 每次任务第一步,检查引擎/配置是否就绪 |\r
| `xb setup` | 安装底层引擎和浏览器 | init 提示「未安装」时执行 |\r
| `xb config show` | 查看当前配置 | 确认浏览器、模式等设置 |\r
| `xb config set \x3Ck>=\x3Cv>` | 修改配置 | 切换浏览器、开启有头模式等 |\r
| `xb config reset` | 重置为默认配置 | 配置损坏时使用 |\r
| `xb guide config` | 交互式配置引导 | 首次使用或需要重新配置时 |\r
| `xb guide close-browser` | 关闭浏览器引导 | 浏览器占用时获取关闭方法 |\r
| `xb status` | 查看环境状态 | 检查引擎版本、浏览器安装情况、配置等 |\r
| `xb stop \x3Cbrowser\|all>` | 关闭浏览器进程 | 任务结束或进程残留时使用 |\r
| `xb cleanup` | 清理 agent-browser 会话 | 任务结束时使用 |\r
| `xb version` | 查看版本信息 | 排查问题时确认版本 |\r
| `xb help [command]` | 查看帮助 | 了解某个命令的用法 |\r
\r
管理命令完整参考见 `{baseDir}/references/xb-cli-commands.md`。\r
\r
## 命令执行规则\r
\r
**每条 xb 命令必须单独执行,逐条检查 JSON 返回后再执行下一条。**\r
\r
禁止使用 `&&`、`&`、`;` 等 shell 操作符链接多条 xb 命令:\r
- 不要:`xb init && xb run --browser default open https://...`\r
- 要:先执行 `xb init`,检查 `ok=true` 后再执行 `xb run ...`\r
\r
原因:每条 xb 命令返回 JSON,需要根据 `ok`、`error`、`hint` 字段判断下一步。链式执行会跳过错误检查,导致后续操作在错误状态下继续。\r
\r
对于需要连续执行的浏览器操作,可使用 batch 命令:\r
```bash\r
"$NODE" {baseDir}/scripts/xb.cjs run --browser default batch --bail "open https://example.com" "snapshot -i" "click @e3"\r
```\r
\r
## 初始化(每次任务第一步)\r
\r
```bash\r
"$NODE" {baseDir}/scripts/xb.cjs init\r
```\r
\r
- `ok=true` → 环境就绪,继续浏览器操作\r
- `ok=false`,`error` 包含"未安装" → 运行 hint 中的命令(`xb setup`),再重新 init\r
- `ok=false`,`error` 包含"需要配置" → 运行 hint 中的命令(`xb guide config`),按下文"处理决策点返回"章节处理\r
- `ok=false`,`error` 包含"配置未完成" → 运行 hint 中的命令(`xb guide incomplete-config`),按下文"处理决策点返回"章节处理\r
\r
## 处理决策点返回(MUST 遵守)\r
\r
当任何 xb 命令返回的 JSON 包含 `awaits_user_input: true` 时,这是一个等待用户决策的节点,不是完成状态。\r
\r
**为什么必须遵守**:\r
决策点的 `message`、`options`、`recommended` 都是面向**最终用户**的 UI 内容,不是给 agent 的执行指引。\r
`recommended` 只是告诉 UI 层"可以高亮这一项",`user_choice_mapping` 只是告诉 UI 层"用户选完后要执行什么"——\r
两者都不是"agent 可以代用户做决定"的信号。代用户决定 = 越权。\r
\r
**必须做(MUST)**:\r
1. 把 `message` 原文展示给用户(可简短转述,不能省略)\r
2. 把 `options[]` 每一项(label + description)列给用户,用编号列表\r
3. 以问询句结尾("你想选哪个?" / "请选择:"),然后立即停止当前回合\r
4. 等用户回复选择后,从 `user_choice_mapping[用户选择的 value]` 取对应命令并执行\r
   - 若取出的值为 `null`(如 close-browser 的 skip),参考同返回里的 `skip_hint` 字段告知用户,不执行任何命令\r
5. 若返回里有 `next_step_hint` 字段,说明用户选择对应命令执行成功后还有后续步骤,按提示继续\r
\r
**严禁做(MUST NOT)**:\r
- ❌ 读到 `recommended` 字段后自行代选(`recommended` 和 label 里的"(推荐)"都是给用户的 UI 引导,不是给 agent 的许可信号)\r
- ❌ 读到 `user_choice_mapping` 后直接挑一个命令执行(这是"用户选完后的映射",不是候选执行列表)\r
- ❌ "我帮你选了推荐的 X,现在执行 ..." —— 这是越权\r
- ❌ 只列选项但不以问询句结尾(agent 会顺着惯性继续自选)\r
\r
**正例**:\r
\r
> xb init 返回需要配置。首次使用有两种方式:\r
> 1. **快速开始(推荐)** —— 使用内置浏览器,干净环境,立即可用\r
> 2. **自定义设置** —— 选择默认浏览器和显示模式\r
>\r
> 你想用哪种?\r
\r
**反例**:\r
\r
> ~~xb init 需要配置,我按推荐走 quick,执行 xb config reset...~~\r
> ~~已为你执行了 xb config reset(使用内置浏览器),现在打开页面...~~\r
\r
**识别自我说服**:如果在处理决策点时冒出以下念头,立刻停下,改为按 MUST 清单执行——\r
\r
| 自我说服的念头 | 真相 |\r
|--------------|------|\r
| "推荐值就是默认值,直接用推荐值没问题" | 推荐是给用户的引导,不是给 agent 的许可 |\r
| "mapping 里已经给了具体命令,说明可以直接执行" | mapping 是用户选完后的映射,用户还没选 |\r
| "用户的意图很明确(比如'帮我打开百度'),跳过配置能更快达成" | 用户的意图里不包含"替我决定配置",跳过就是偷走了用户的选择权 |\r
| "这个选项太简单了,用户肯定会选推荐" | 你不是用户。让用户选。 |\r
| "我已经展示了选项,现在可以顺便执行一下" | 展示了就停,不能接着执行 |\r
\r
**关于 `awaits_user_input: false` 的返回**:不是决策点(例如 step 1 在无本地浏览器时只有 cft 一个选项),可以直接按 `user_choice_mapping` 执行。但仍应把 `message` 告知用户,让用户知情。\r
\r
## 浏览器操作\r
\r
init 成功后执行浏览器命令:\r
\r
```bash\r
"$NODE" {baseDir}/scripts/xb.cjs run --browser default open https://example.com\r
"$NODE" {baseDir}/scripts/xb.cjs run --browser default wait --load networkidle\r
"$NODE" {baseDir}/scripts/xb.cjs run --browser default snapshot -i\r
"$NODE" {baseDir}/scripts/xb.cjs run --browser default click @e2\r
"$NODE" {baseDir}/scripts/xb.cjs run --browser default fill @e3 "hello"\r
```\r
\r
- `ok=true` → 继续\r
- `ok=false` → 检查 `hint` 字段,按建议操作\r
\r
**URL 建议用单引号包裹**(防止外层 shell 解析 `&`、`?`、`$` 等特殊字符):\r
```bash\r
"$NODE" {baseDir}/scripts/xb.cjs run --browser default open 'https://example.com?a=1&b=2'\r
```\r
\r
### 操作要点\r
\r
- **浏览器选择(必须)**:每条 `run` 命令都必须指定 `--browser`。`init` 成功后返回 `env.browser`(当前配置的默认浏览器)。\r
  - 用户未指定浏览器 → `--browser default`\r
  - 用户指定了浏览器 → 按下表映射为 `--browser \x3Cid>`,从第一条 run 命令就使用对应 ID(不要先用 default 再切换,因为每个浏览器有独立的登录态和会话,用错浏览器会导致需要重新登录):\r
\r
  | 用户说法 | `--browser` 值 |\r
  |---------|---------------|\r
  | Chrome / chrome / 谷歌浏览器 / 谷歌 / Google Chrome | `chrome` |\r
  | Edge / edge / 微软浏览器 / 微软Edge / Microsoft Edge | `edge` |\r
  | QQ浏览器 / QQ browser / QQBrowser / qq浏览器 | `qqbrowser` |\r
  | 默认浏览器 / 不指定 | `default` |\r
- **导航后先等加载**:`open \x3Curl>` 后先 `wait --load networkidle`,再 `snapshot -i`\r
- **@ref 是临时的**:DOM 变化后失效,需重新 `snapshot -i`\r
- **fill vs type**:`fill` 清空后输入,`type` 逐字符追加\r
- **切换浏览器**:`xb run --browser edge open ...`(不影响其他浏览器的会话)\r
- **有头模式**:`xb run --browser default --headed open ...`(显示浏览器窗口,适合调试或人机验证)\r
- **xb 级选项只有三个**:`xb run` 只接受 `--browser`、`--headed`、`--timeout`,其他参数会被忽略。\r
- **位置约束**:xb 级选项必须放在 action verb 之前(如 `xb run --browser chrome --headed open ...`),放在 action 之后会被静默忽略。若担心混淆,可用 `--` 显式分隔 xb 级选项与浏览器动作:\r
  ```bash\r
  "$NODE" {baseDir}/scripts/xb.cjs run --browser chrome --headed -- open https://example.com\r
  ```\r
\r
### 遇到登录页面\r
\r
1. **有凭据** → 告知风险后自动填写\r
2. **无凭据** → 截图,请用户提供\r
3. **图片验证码** → 截图尝试识别\r
4. **人机验证** → 停止,截图,请用户手动完成\r
\r
详见 `{baseDir}/references/authentication.md`。\r
\r
### 失败处理\r
\r
最多重试 2 次。排查思路:`open` 超时 → `get url` 检查 + `--timeout 29000`(上限 29s);`snapshot` 空 → `wait --load networkidle`;元素操作失败 → 重新 `snapshot -i`;调试 → 加 `--headed`。\r
\r
### 常用命令\r
\r
完整列表见 `{baseDir}/references/xb-browser-commands.md`。\r
\r
对于非单步的复杂任务(登录后多页操作、分页爬取、@ref 失效恢复、batch 使用等),先查阅 `{baseDir}/references/recipes.md` 获取完整命令序列模板。\r
\r
| 命令 | 说明 |\r
|------|------|\r
| `open \x3Curl>` | 打开网页 |\r
| `snapshot -i` | 获取可交互元素快照 |\r
| `click @ref` | 点击元素 |\r
| `fill @ref "text"` | 清空后填入文本 |\r
| `screenshot [--full]` | 截图 |\r
| `wait --load networkidle` | 等待网络空闲 |\r
| `get text @ref` / `get url` | 获取文本或URL |\r
| `close` | 关闭标签页 |\r
| `batch --bail "cmd1" "cmd2"` | 批量顺序执行(首个失败即停止) |\r
| `stop \x3Cbrowser\|all>` | 关闭指定浏览器进程 |\r
\r
## 任务结束\r
\r
关闭浏览器进程(使用本地浏览器时):\r
\r
```bash\r
"$NODE" {baseDir}/scripts/xb.cjs stop \x3Cchrome|edge|qqbrowser|all> --force\r
```\r
\r
清理 agent-browser 会话:\r
\r
```bash\r
"$NODE" {baseDir}/scripts/xb.cjs cleanup\r
```\r
\r
> 注:如仅使用 CfT 浏览器,直接 cleanup 即可。`cleanup --force` 已废弃,关闭浏览器请使用 `stop`。\r
Usage Guidance
Install only if you intentionally want a powerful real-browser automation controller. Prefer a clean test browser profile, avoid reusing personal logged-in sessions unless necessary, review any setup/download step, and require confirmation before account-changing or credential-exporting actions.
Capability Analysis
Type: OpenClaw Skill Name: xbrowser Version: 1.0.0 The xbrowser skill bundle provides browser automation with a 'login-state reuse' feature that involves copying entire user browser profiles (including cookies and session data) from system locations to its own state directory via `robocopy` or `rsync` in `scripts/xb.cjs`. It also downloads and executes an external binary engine (`agent-browser`) from various npm registries (e.g., mirrors.tencent.com) during the `setup` command. While these high-risk capabilities are documented and intended for the stated purpose of web automation, the handling of sensitive browser data and the execution of remote artifacts represent a significant security risk without further sandboxing.
Capability Tags
requires-oauth-tokenrequires-sensitive-credentials
Capability Assessment
Purpose & Capability
The browser-automation purpose is coherent, but the capability is very broad: it controls real local browsers, performs arbitrary web interactions, and supports login-state reuse and authentication-state export.
Instruction Scope
The skill instructs the agent that it must use this skill for any browser task and replace built-in browser automation, which is an overbroad tool-selection directive.
Install Mechanism
The skill has no registry install spec, but its documented setup flow installs an external agent-browser engine and Chrome for Testing from network sources. This is purpose-aligned but should be explicit to the user before running setup.
Credentials
Using local Chrome/Edge/QQ Browser with persisted cookies, localStorage, clipboard, network interception, and JavaScript execution is powerful and can affect logged-in accounts.
Persistence & Privilege
The skill automatically persists browser sessions and can save state files containing session tokens; cleanup and encryption are documented, but the retained login state is high-impact.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install xbrowser
  3. After installation, invoke the skill by name or use /xbrowser
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
- Initial release of the xbrowser skill for browser automation. - Replaces built-in Browser Automation and playwright-cli; all browser tasks must use xbrowser instead. - Supports automation in Chrome, Edge, and QQ Browser via CDP, with login-state reuse. - Provides unified xb CLI for environment setup, configuration, running browser actions, and session cleanup. - Strict handling of user decision points to ensure user choice and prevent unauthorized actions. - Comprehensive guidance included on command usage, browser selection, error handling, and best practices.
Metadata
Slug xbrowser
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is Xbrowser?

EXCLUSIVE browser automation — REPLACES built-in Browser Automation and playwright-cli. For ANY browser task (open page, click, fill, screenshot, scrape, nav... It is an AI Agent Skill for Claude Code / OpenClaw, with 32 downloads so far.

How do I install Xbrowser?

Run "/install xbrowser" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Xbrowser free?

Yes, Xbrowser is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Xbrowser support?

Xbrowser is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Xbrowser?

It is built and maintained by SKY-lv (@sky-lv); the current version is v1.0.0.

💬 Comments