@roll-agent/browser-use-agent 0.25.2 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SKILL.md +45 -16
- package/dist/browser-execution.d.ts +19 -0
- package/dist/browser-observation.d.ts +14 -0
- package/dist/browser-script-approval.d.ts +18 -0
- package/dist/index.js +1 -1
- package/dist/reply-authority/schemas.d.ts +2 -2
- package/dist/tools/browser-dom-action-candidates.d.ts +1 -0
- package/dist/tools/browser-execute.d.ts +152 -0
- package/dist/tools/browser-ref-frame-guard.d.ts +8 -0
- package/dist/tools/browser-ref-schemas.d.ts +6 -6
- package/dist/tools/browser-snapshot.d.ts +22 -3
- package/dist/tools/browser-workflows.d.ts +670 -0
- package/dist/tools/click-ref.d.ts +2 -1
- package/dist/tools/type-ref.d.ts +2 -1
- package/dist/tools/zhipin-diagnose-browser-state.d.ts +4 -4
- package/dist/tools/zhipin-generate-reply-preview.d.ts +2 -2
- package/dist/tools/zhipin-list-recommend-jobs.d.ts +2 -2
- package/dist/tools/zhipin-select-recommend-job.d.ts +6 -6
- package/dist/tools/zhipin-send-prepared-reply.d.ts +3 -3
- package/dist/workflows/parameters.d.ts +8 -0
- package/dist/workflows/store.d.ts +319 -0
- package/package.json +3 -3
- package/references/browser-exploration.md +141 -0
- package/references/generic-browser-refs.md +77 -25
package/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: browser-use-agent
|
|
3
|
-
description: 浏览器操控 Agent
|
|
3
|
+
description: 浏览器操控 Agent。提供招聘平台预编排、通用 AX snapshot/ref 操作、受控 JavaScript 组合执行及显式启用的站点经验复用;BOSS 使用 native CDP,可读取消息、打开聊天、发送签名回复、筛选候选人和截取简历。
|
|
4
4
|
metadata:
|
|
5
5
|
roll-env-file: references/env.yaml
|
|
6
6
|
---
|
|
@@ -9,12 +9,27 @@ metadata:
|
|
|
9
9
|
|
|
10
10
|
浏览器自动化执行层。BOSS 直聘链路(含简历弹窗与简历截图工具)全部使用 native CDP backend;Playwright attach 仅保留在显式诊断工具中。
|
|
11
11
|
|
|
12
|
+
## 通用探索与站点经验
|
|
13
|
+
|
|
14
|
+
按 **平台专用工具 → 已启用站点经验 → 通用探索** 的顺序选择能力。已经覆盖的 BOSS 操作继续使用 `zhipin_*`,不要改写成脚本或视觉循环。
|
|
15
|
+
|
|
16
|
+
- 未建模页面先观察,必要时用 `browser_workflow_list({url})` 查找适用的已启用经验,再调用 `browser_workflow_run`。
|
|
17
|
+
- 已明确的一组步骤使用 `browser_execute` 合并执行。JS 只可使用 `page` helpers 和 `args`,没有 Node、fetch、任意页面 evaluate 或裸 CDP。
|
|
18
|
+
- 遇到陌生下拉,先用 `page.inspectControl(field)` 查看触发器、面板关联与当前选项,再用 `page.choose(field,{label:"目标文案"})` 选择并验证。field 优先使用严格 ref,或带正确 `frameId` 的 locator;门户面板无明确关联时需指定唯一的 `panel` CSS 区域,不全页面搜索后选择第一个同名项。
|
|
19
|
+
- Snapshot 会按原生/ARIA/列表结构识别独立选项行,避免父容器聚合所有选项文案;普通文章列表不自动变成控件。跨 iframe 操作会检查祖先遮挡和焦点,无法可靠检查时返回覆盖缺口。
|
|
20
|
+
- 表单操作失配后保留现场并重新观察;不要通过 reload 自动恢复未保存的表单。级联菜单逐级声明预期,虚拟列表只承诺当前渲染的选项,不盲目递归点击。
|
|
21
|
+
- 对结果声明 `expect` 或 `postconditions`;`status:completed` 只表示脚本结束,业务结果是否验证要看 `verification`。失败后检查已执行步骤,不重放整段。
|
|
22
|
+
- `actionPolicy=confirm` 时,整段批准绑定脚本、参数、browserInstance、页面 document、站点、能力和限制。必须先获得用户明确批准;Runtime 会通过现有确认通道续接一次,直接 CLI 调用则在用户批准后原样补入 `approvalRequest.retryInput`。收到凭据不代表已经批准,不修改已批准内容,也不重复使用凭据。
|
|
23
|
+
- 有复用价值的成功探索可整理为参数化草稿;保存草稿不自动启用。验证可能真实操作页面,按正常任务授权执行;启用具体版本必须由用户明确批准。
|
|
24
|
+
- 纯经验列表、保存草稿和状态管理不启动浏览器;执行/验证工具仍需明确页面和正确的 browserInstance。
|
|
25
|
+
- 详细接口、示例和边界见 [通用页面探索](references/browser-exploration.md)。
|
|
26
|
+
|
|
12
27
|
## 使用前提
|
|
13
28
|
|
|
14
29
|
- 先启动 `browser-use-agent` HTTP 常驻服务;浏览器 session 跨调用持久。
|
|
15
30
|
- 通过 Roll 调用本 Agent 时,先用 `roll skills get browser-use-agent --include-references --json` 读取当前说明和 `references/*`,再用 `roll agent tools browser-use-agent --json` 读取真实 schema。
|
|
16
31
|
- 完整 `inputSchema` 以 `roll agent tools browser-use-agent --json` 为准。
|
|
17
|
-
- 多账号/多 profile 场景下,Roll 会从 `browser.instances` 注入 `BROWSER_INSTANCES_JSON
|
|
32
|
+
- 多账号/多 profile 场景下,Roll 会从 `browser.instances` 注入 `BROWSER_INSTANCES_JSON`;页面操作工具支持可选 `browserInstance` 输入,用于选择目标 `profile/userDataDir + cdpPort + sessionsDir`。未传时按 `browser.defaultInstance`,再按单实例自动选择;多实例且无默认值时会返回 `needs_input`。经验列表、草稿保存和状态管理使用当前用户的全局经验库,不选择浏览器实例。
|
|
18
33
|
- 多个 `managed-cdp` 实例首次启动时会自动把 Chrome profile 展示名设为实例 ID,并按声明顺序分配 profile 颜色和自适应平铺窗口:2–3 个实例横向并列并撑满桌面可用高度;4 个实例 2×2 铺满屏幕;5 个及以上按「最多 4 列、每行撑满宽度」均衡排列(5→3+2、6→3+3、8→4+4、10→4+3+3)。macOS 使用只读 `system_profiler SPDisplaysDataType` 探测逻辑分辨率;Windows 使用只读 PowerShell/.NET `PrimaryScreen.WorkingArea` 探测扣除任务栏后的工作区;探测不到时回退默认工作区;也可通过 `ROLL_BROWSER_WORK_AREA=x,y,width,height` 覆盖。需要固定展示时在实例上配置 `profile-name` / `profile-color` / `window-bounds`。
|
|
19
34
|
- 浏览器实例采用 **lazy start**:agent 启动不会立刻拉起全部 Chrome,首次访问某个 `browserInstance` 时才启动对应 profile/CDP runtime。
|
|
20
35
|
- Roll 启动的 `managed-cdp` Chrome 默认关闭后台定时器节流、occluded-window backgrounding 和 renderer backgrounding,避免窗口被完全遮挡或切换到其他 macOS Space 时触发 Chromium 后台降级;该行为需重启对应 browser instance 后生效,不影响 `remote-cdp`、`existing-session` 或其他手动启动的 Chrome。
|
|
@@ -74,7 +89,7 @@ browser:
|
|
|
74
89
|
|
|
75
90
|
orchestrator 规则:
|
|
76
91
|
|
|
77
|
-
1. 多账号托管时,把 `browserInstance`
|
|
92
|
+
1. 多账号托管时,把 `browserInstance` 当作账号路由键;操作同一账号的页面工具调用必须传同一个 `browserInstance`。经验列表、保存草稿和状态管理使用全局经验库,不传该参数。
|
|
78
93
|
2. 不要把 `boss-a` 产生的 `pageId`、`@eN`、`@cN`、`@jN`、`preparedReplyId` 或当前页面状态传给 `boss-b`。
|
|
79
94
|
3. `browserInstance` 只标识浏览器/profile;业务归因使用该实例的 `trackingAgentId`,缺失时才 fallback 到 `RECRUITMENT_EVENTS_DEFAULT_AGENT_ID`,仍缺失则跳过招聘事件上报并 warn。
|
|
80
95
|
4. `platform` 与实例配置不一致时会返回 `platform_mismatch`。例如 `browserInstance:"boss-a"` 声明为 `zhipin`,就不要调用 `yupao_*` 工具或 `open_platform({ platform:"yupao" })`。
|
|
@@ -154,50 +169,63 @@ zhipin_read_messages({ browserInstance, onlyUnread:true, limit:N })
|
|
|
154
169
|
| `select_page(platform, pageId)` | 将指定页面绑定为平台活跃页;登录前优先走 native target 激活。 |
|
|
155
170
|
| `navigate_active_tab(url)` | 通过 native CDP 打开/导航页面;不触发 Playwright attach,不支持直接跳转 BOSS `/web/chat/*` 后台路径。 |
|
|
156
171
|
| `browser_reload_active_tab(ignoreCache?, browserActionApproval?)` | 对当前 tracked native page 执行 CDP `Page.reload`,清空页面内 DOM 与 SPA 状态后等待文档换页;不触发 Playwright attach,走现有 actionPolicy / domainAllowlist 边界。reload 后所有 `@eN` / `candidateRef` 失效,必须重新 snapshot / 读列表。 |
|
|
157
|
-
| `browser_snapshot(pageId?, maxDepth?, maxNodes?, interactiveOnly?)` |
|
|
158
|
-
| `click_ref(ref, pageId?, browserActionApproval?)` |
|
|
159
|
-
| `type_ref(ref, text, clear?, pageId?, browserActionApproval?)` |
|
|
172
|
+
| `browser_snapshot(pageId?, scope?, maxDepth?, maxNodes?, interactiveOnly?)` | 读取 AX 快照及有限非语义可操作节点,返回 `@eN`、`snapshotId`、表单/弹窗上下文、定位提示和覆盖缺口;`scope` 为唯一匹配的 CSS 区域。沿用同 target iframe 能力。 |
|
|
173
|
+
| `click_ref(ref, pageId?, snapshotId?, browserActionApproval?)` | 点击快照 ref;推荐携带 `snapshotId`,严格校验实例、页面、document 和最新快照,过期时停止。只有未传 `snapshotId` 的兼容调用保留 `role/name/nth` fallback。 |
|
|
174
|
+
| `type_ref(ref, text, clear?, pageId?, snapshotId?, browserActionApproval?)` | 向快照 ref 输入;`clear:true` 先清空控件,`snapshotId` 启用相同严格绑定;iframe ref 复用原 `frameId`。 |
|
|
175
|
+
| `browser_execute(pageId, source, args?, capabilities, allowedOrigins, preconditions?, postconditions?, timeoutMs?, maxCalls?, scriptApproval?)` | 单页受控 JS 组合执行;默认上限 30 秒、100 次 helper、32MiB 脚本堆、64KiB 文本输出,截图为独立产物。返回动作记录、验证、观察变化和耗时,不自动重放。 |
|
|
176
|
+
| `browser_workflow_list(url)` | 按 URL 发现适用的已启用经验,返回简短签名与适用条件;不启动浏览器。 |
|
|
177
|
+
| `browser_workflow_save_draft(draft)` | 保存参数化的不可变版本草稿并检查语法;不执行、不启用,不自动保存本次参数或页面正文。 |
|
|
178
|
+
| `browser_workflow_validate(id, version, pageId, args?, scriptApproval?)` | 显式实际执行该版本;只有执行成功且结果验证通过才记录验证凭据,遵守正常页面操作策略。 |
|
|
179
|
+
| `browser_workflow_set_status(id, version, status, toolActionApproval?)` | 启用或停用具体版本;`active` 要求成功验证和用户明确批准,`disabled` 停止后续 helper。修改内容产生新版本,不继承批准。 |
|
|
180
|
+
| `browser_workflow_run(id, version, pageId, args?, scriptApproval?)` | 执行适用且已启用的经验,复用组合执行内核;定位或断言失效时暂停推荐并返回需要重新探索。 |
|
|
160
181
|
|
|
161
182
|
## 通用页面操作编排
|
|
162
183
|
|
|
163
|
-
|
|
184
|
+
通用工具用于没有平台专用方法覆盖的页面操作。依次选择平台专用工具、已启用的适用经验、通用探索;未知目标先观察,已明确的连续步骤再组合执行。
|
|
164
185
|
|
|
165
186
|
工具选择优先级:
|
|
166
187
|
|
|
167
188
|
| 场景 | 首选 | 兜底 |
|
|
168
189
|
| --- | --- | --- |
|
|
169
190
|
| BOSS 已建模业务链路,例如读消息、打开聊天、换微信、打招呼、筛选候选人 | `zhipin_*` 专用 tool | 只有专用 tool 缺失或无法覆盖新按钮时,才使用 `browser_snapshot` + `click_ref` / `type_ref` |
|
|
170
|
-
|
|
|
191
|
+
| 已有已启用经验覆盖当前 URL 与任务 | `browser_workflow_list` + `browser_workflow_run` | 适用条件或定位/断言失效后重新探索,不反复重放 |
|
|
192
|
+
| 通用网页上的确定性连续步骤 | `browser_execute`,使用唯一 locator 并声明结果断言 | 未知目标或覆盖缺口处再请求区域快照或截图 |
|
|
193
|
+
| 尚需探索的按钮、链接、输入框 | `browser_snapshot` 找上下文与 `role/name`,再用严格 ref 单步操作 | 用业务读取或有期限的断言验证;仅在需要重新定位时刷新快照 |
|
|
171
194
|
| 页面、tab、平台选择 | `list_pages` + `select_page` 或平台专用 opener | 不要直接猜内部 URL |
|
|
172
195
|
| 风控或底层行为诊断 | `zhipin_diagnose_browser_state` | 正常业务路径不要默认诊断 |
|
|
173
196
|
|
|
174
|
-
|
|
197
|
+
单步探索流程:
|
|
175
198
|
|
|
176
199
|
```text
|
|
177
200
|
观察阶段:
|
|
178
201
|
list_pages/select_page # 仅多页面或目标页不明确时
|
|
179
|
-
-> browser_snapshot(interactiveOnly=true)
|
|
202
|
+
-> browser_snapshot(pageId, scope?, interactiveOnly=true)
|
|
180
203
|
-> orchestrator 按 role/name/disabled 选择 @eN
|
|
181
204
|
|
|
182
205
|
动作阶段:
|
|
183
|
-
click_ref(
|
|
184
|
-
-> 若 actionPolicy=confirm
|
|
185
|
-
->
|
|
206
|
+
click_ref(ref, pageId, snapshotId) 或 type_ref(ref, text, clear?, pageId, snapshotId)
|
|
207
|
+
-> 若 actionPolicy=confirm,先获得用户批准,再原样补入 browserActionApproval
|
|
208
|
+
-> 用业务 read tool / 结果断言验证;需要重新定位时再 snapshot
|
|
209
|
+
|
|
210
|
+
步骤明确后:
|
|
211
|
+
browser_execute(pageId, source, args, capabilities, allowedOrigins, postconditions)
|
|
212
|
+
-> 检查 status、verification 和已执行动作
|
|
213
|
+
-> 有复用价值且验证成功时,整理草稿 → 显式验证 → 用户批准具体版本 → 启用
|
|
186
214
|
```
|
|
187
215
|
|
|
188
216
|
关键规则:
|
|
189
217
|
|
|
190
|
-
1. `@eN` 只来自最近一次
|
|
218
|
+
1. `@eN` 只来自最近一次 Snapshot。单步工具推荐同时传 `pageId` / `snapshotId`;脚本中的 `page.ref(ref, snapshotId)` 必须绑定同一 browserInstance、页面、document 和最新快照,不能跨页面或跨实例使用。
|
|
191
219
|
2. `@eN` 不等同于 BOSS 推荐页的 `@cN` / `@jN`;`@cN`、`@jN` 只服务对应 `zhipin_*` 工具。
|
|
192
220
|
3. 不要自行构造 `@eN`;只能传 `browser_snapshot.snapshot.refs[].ref`。
|
|
193
221
|
4. 选择目标时优先匹配 `role + name`,并排除 `disabled:true` 的节点;若目标是非语义短文本控件,使用 `role:"clickable"` / `role:"focusable"` / `role:"editable"`、可见文案和 `properties.domActionable:true` 判断。
|
|
194
222
|
5. 如果 `refs[]` 或 `nodes[]` 中出现 `frameId`,说明该 ref 来自 iframe 子 frame;orchestrator 只需要继续传 `ref` 和必要的 `pageId`,不要手工传或改写 `frameId`。
|
|
195
|
-
6. `snapshot.truncated:true`
|
|
223
|
+
6. `snapshot.truncated:true` 表示观察被截断;优先用 `scope` 限定相关表单、弹窗或区域,再按需调整 `maxDepth` / `maxNodes`。同时检查 `coverageWarnings`,不要把未覆盖区域当成空页面。
|
|
196
224
|
7. 页面导航、刷新、弹窗出现、列表重排、筛选变化后,先重新 `browser_snapshot`,不要复用旧 `@eN`。
|
|
197
225
|
8. `browser_snapshot` 是 AX 语义快照,不是完整 HTML、截图或网络状态;需要业务数据时仍应使用对应 read tool。
|
|
198
226
|
9. 当前 iframe 支持是同 target / 同 CDP session 内递归内联;递归受 `maxNodes`、frame 去重和 CDP frame 可解析性限制。跨 target / OOPIF iframe 需要 Native CDP session multiplexing,当前不承诺覆盖。
|
|
199
227
|
|
|
200
|
-
|
|
228
|
+
单步兼容接口细节见 `references/generic-browser-refs.md`;组合执行、严格定位、审批与经验管理见 [通用页面探索](references/browser-exploration.md)。
|
|
201
229
|
|
|
202
230
|
## 调试 Tools
|
|
203
231
|
|
|
@@ -347,6 +375,7 @@ zhipin_get_candidate_list
|
|
|
347
375
|
|
|
348
376
|
## 参考资料
|
|
349
377
|
|
|
378
|
+
- [通用页面探索](references/browser-exploration.md):受控 JS helpers、结果断言、严格定位、整段审批、站点经验管理和 SDK 示例。
|
|
350
379
|
- `references/zhipin-diagnostics.md`:BOSS native CDP / attach 诊断阶段、推进顺序和返回字段。
|
|
351
380
|
- `references/zhipin-workflows.md`:聊天主键、动态列表、`preferredBrand` / `preferredBrandId`、服务端地点解析(`location.resolved`)、Reply Authority 编排细节。
|
|
352
381
|
- `references/generic-browser-refs.md`:通用 AX snapshot、`@eN` ref、点击/输入闭环和边界条件。
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AgentContext } from "@roll-agent/sdk";
|
|
2
|
+
import { compileBrowserScript, executeBrowserProgram } from "@roll-agent/browser";
|
|
3
|
+
import type { BrowserExecuteInput, BrowserExecuteResult, BrowserRuntime } from "@roll-agent/browser";
|
|
4
|
+
export type BrowserExecutionDependencies = {
|
|
5
|
+
runtime: Pick<BrowserRuntime, "getConfig" | "listNativePages" | "connectNativePage">;
|
|
6
|
+
browserInstance: string;
|
|
7
|
+
compile: typeof compileBrowserScript;
|
|
8
|
+
execute: typeof executeBrowserProgram;
|
|
9
|
+
};
|
|
10
|
+
export declare function setBrowserExecutionDependenciesForTests(value: BrowserExecutionDependencies | undefined): void;
|
|
11
|
+
/** Called internally by execute/workflow tools, under the existing instance lock exactly once. */
|
|
12
|
+
export declare function executeBrowserTool(rawInput: BrowserExecuteInput, ctx: AgentContext, options?: {
|
|
13
|
+
workflowKey?: string;
|
|
14
|
+
beforeAction?: () => Promise<void>;
|
|
15
|
+
toolName?: string;
|
|
16
|
+
}): Promise<{
|
|
17
|
+
result: BrowserExecuteResult;
|
|
18
|
+
executionDigest: string;
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type BrowserAxSnapshot, type NativeCdpController } from "@roll-agent/browser";
|
|
2
|
+
export { readBrowserDocumentIdentity } from "@roll-agent/browser";
|
|
3
|
+
export declare function observeBrowserPage(input: {
|
|
4
|
+
readonly controller: NativeCdpController;
|
|
5
|
+
readonly page: {
|
|
6
|
+
readonly targetId: string;
|
|
7
|
+
};
|
|
8
|
+
readonly browserInstance: string;
|
|
9
|
+
readonly scope?: string;
|
|
10
|
+
readonly allowedOrigins?: readonly string[];
|
|
11
|
+
readonly maxDepth?: number;
|
|
12
|
+
readonly maxNodes?: number;
|
|
13
|
+
readonly interactiveOnly?: boolean;
|
|
14
|
+
}): Promise<BrowserAxSnapshot>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BrowserExecuteInput, BrowserSecurityConfig } from "@roll-agent/browser";
|
|
2
|
+
export declare function browserExecutionDigest(input: BrowserExecuteInput, binding: {
|
|
3
|
+
browserInstance: string;
|
|
4
|
+
documentId: string;
|
|
5
|
+
workflowKey?: string;
|
|
6
|
+
toolName?: string;
|
|
7
|
+
}): string;
|
|
8
|
+
export declare function assertScriptDomains(input: BrowserExecuteInput, security: BrowserSecurityConfig): void;
|
|
9
|
+
/** Whole-program approval is consumed once before any website side effect. */
|
|
10
|
+
export declare function authorizeBrowserScript(input: BrowserExecuteInput, binding: {
|
|
11
|
+
browserInstance: string;
|
|
12
|
+
documentId: string;
|
|
13
|
+
workflowKey?: string;
|
|
14
|
+
toolName?: string;
|
|
15
|
+
}, security: BrowserSecurityConfig): {
|
|
16
|
+
approved: boolean;
|
|
17
|
+
executionDigest: string;
|
|
18
|
+
};
|