yunti-browser-runtime 0.1.3 → 0.2.1

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/README.md CHANGED
@@ -13,6 +13,13 @@ Chrome/Edge 浏览器:查看标签页、读取页面、点击输入、截图
13
13
 
14
14
  它的第一目标是:**部署简单、执行高效、和具体 Agent/平台解耦**。
15
15
 
16
+ `0.2.1+` 默认页面操作路径优先走扩展 content script,不会自动 attach Chrome
17
+ debugger:`yunti_observe_page`、fresh uid 的 `yunti_click` / `yunti_hover` /
18
+ `yunti_fill` / `yunti_select` / `yunti_scroll` / `yunti_type_text` /
19
+ `yunti_press_key` 应作为普通页面操作首选。显式 CDP、trace、部分截图 fallback、
20
+ drag/upload/emulation/resize 和 legacy snapshot 兼容路径仍可能触发 Chrome 的调试横幅,
21
+ 只在确实需要低层能力时使用。
22
+
16
23
  ## 当前定位
17
24
 
18
25
  当前版本是本地单用户 MVP:
@@ -45,7 +52,8 @@ npm install -g yunti-browser-runtime
45
52
  yunti-browser-runtime print-config -- --agent codex --human
46
53
  ```
47
54
 
48
- 把输出的 MCP 配置加入 Agent 后,加载浏览器扩展并刷新任意 `http` / `https` 页面即可。
55
+ 把输出的 MCP 配置加入 Agent 后,加载浏览器扩展并打开或保持任意 `http` / `https`
56
+ 页面即可。扩展会自动扫描可访问页面、注入内容脚本并注册到本地 bridge。
49
57
  默认不需要填写 token,不需要打开扩展 popup,也不需要保存设置。
50
58
 
51
59
  需要独立调试 bridge 时,可以手动运行:
@@ -54,6 +62,22 @@ yunti-browser-runtime print-config -- --agent codex --human
54
62
  yunti-browser-runtime bridge
55
63
  ```
56
64
 
65
+ 需要查看本地运行时状态时,可以打开可选控制台:
66
+
67
+ ```bash
68
+ yunti-browser-runtime console
69
+ ```
70
+
71
+ 然后访问:
72
+
73
+ ```text
74
+ http://127.0.0.1:48887/console
75
+ ```
76
+
77
+ 控制台只展示连接页面、pending/queued 任务、最近工具 activity 和诊断数量等脱敏摘要;
78
+ 它不是必选 hub,也不会改变 Agent 的 MCP 使用路径。
79
+ `yunti-browser-runtime doctor` 的人类可读摘要也会打印这个控制台 URL。
80
+
57
81
  其他常用 CLI:
58
82
 
59
83
  ```bash
@@ -104,11 +128,11 @@ npm run doctor:json
104
128
  6. 引导我打开 Chrome/Edge 的扩展管理页,开启开发者模式,手动加载扩展目录:
105
129
  $(npm root -g)/yunti-browser-runtime/extension
106
130
  7. 告诉我:扩展默认 bridge URL 是 http://127.0.0.1:48887,本地默认不需要 token,不需要打开 popup,也不需要保存设置。
107
- 8. 打开任意 http/https 页面并刷新。
131
+ 8. 打开或保持任意 http/https 页面;扩展会自动尝试注入并注册已有页面。
108
132
  9. 执行:yunti-browser-runtime doctor
109
133
  10. 如果 doctor 正常,再调用 yunti_list_browser_targets 或 yunti_get_tool_usage_hints 验证你能看到浏览器页面。
110
134
 
111
- 注意:Chrome 扩展不能由 npm 静默安装,必须由我手动在浏览器扩展页加载。扩展加载完成后默认立即可用,不要要求我填写 token、打开 popup 或保存设置;除非 doctor 明确提示 bridge 未运行,才让我单独执行 yunti-browser-runtime bridge。
135
+ 注意:Chrome 扩展不能由 npm 静默安装,必须由我手动在浏览器扩展页加载。扩展加载完成后会自动尝试接管已打开的 http/https 页面,不要默认要求我刷新页面、填写 token、打开 popup 或保存设置;只有 doctor/list targets 仍看不到页面,且确认是浏览器限制或页面未加载完成时,才把刷新目标页作为兜底。
112
136
  ```
113
137
 
114
138
  ## 安装浏览器扩展
@@ -126,7 +150,7 @@ $(npm root -g)/yunti-browser-runtime/extension
126
150
  3. 点击“加载已解压的扩展程序”。
127
151
  4. 选择本项目的 `extension/` 目录。
128
152
  5. 打开任意 `http` 或 `https` 页面。
129
- 6. 刷新目标页面即可连接。
153
+ 6. 扩展会自动扫描并注册可访问页面;如果 doctor 仍看不到页面,再刷新目标页作为兜底。
130
154
 
131
155
  扩展默认使用 `http://127.0.0.1:48887`,本地安装不需要 token,不需要打开 popup,
132
156
  也不需要保存设置。扩展 popup 首屏只显示连接状态;自定义 bridge URL、页面匹配或
@@ -140,6 +164,8 @@ npm run package:extension
140
164
  ```
141
165
 
142
166
  输出文件位于 `dist/yunti-browser-runtime-extension-<version>.zip`,zip 内只包含扩展运行所需文件。
167
+ 浏览器商店分发前的权限、隐私和素材准备清单见
168
+ [扩展分发准备度](docs/EXTENSION_DISTRIBUTION.md)。
143
169
 
144
170
  ## 给 Agent 注册 MCP
145
171
 
@@ -199,6 +225,8 @@ cp -R skills/yunti-browser-runtime ~/.codex/skills/
199
225
 
200
226
  - `yunti_click` / `yunti_hover` 需要 `uid`、`selector`,或同时提供 `x` 和 `y`。
201
227
  - `yunti_fill` 必须提供 `value`,并用 `uid` 或 `selector` 定位;不支持只传坐标。
228
+ - 普通页面操作优先使用 `yunti_observe_page` 返回的 fresh uid;`0.2.1+` 的默认
229
+ fresh-uid action 路径不会自动 attach Chrome debugger。
202
230
  - `yunti_close_page` 按 `browserSessionId` 关闭页面;如只有 `tabId` / `targetId`,请用 `yunti_cdp_send_command` + `Target.closeTarget`。
203
231
  - `yunti_cdp_send_command` 必须提供 `method`;`params` 可选,但传入时必须是 object。
204
232
  - `yunti_forget_learning_memory` 需要 memory `id`,或使用 `all=true` 且 `confirmed=true` 删除全部。
@@ -221,6 +249,7 @@ cp -R skills/yunti-browser-runtime ~/.codex/skills/
221
249
  - [工具指南](docs/TOOL_GUIDE.md)
222
250
  - [权限和隐私说明](docs/SECURITY.md)
223
251
  - [发布运行手册](docs/RELEASE.md)
252
+ - [0.2.0 发布清单](docs/RELEASE_0_2_0_CHECKLIST.md)
224
253
  - [发布阻塞处理](docs/PUBLISHING_BLOCKERS.md)
225
254
  - [项目初衷](docs/PROJECT_INTENT.md)
226
255
  - [项目状态](docs/PROJECT_STATUS.md)
@@ -295,8 +324,11 @@ token。
295
324
 
296
325
  ## 发布状态与后续事项
297
326
 
298
- - `yunti-browser-runtime@0.1.3` 已发布到官方 npm registry。
299
- - `0.1.3` 将扩展 popup 首屏改成零配置状态面板,并补充“Agent 会自动启动 bridge”
300
- 的安装引导。
301
- - 发布后验证命令:`npm run release:verify-published`。
302
- - 如要上架浏览器扩展商店,需要再次审查 broad host permissions。
327
+ - 当前源码版本:`yunti-browser-runtime@0.2.1`。
328
+ - 当前已发布 npm 稳定版:`yunti-browser-runtime@0.2.0`。
329
+ - `0.2.1` 修复默认 observe-first 页面动作误触发 Chrome debugger 的问题;
330
+ `0.2.0` 增强了 `yunti_observe_page`、fresh uid
331
+ 操作闭环、结构化恢复诊断、DOM/diagnostic 脱敏和可选本地控制台。
332
+ - `0.2.0` 发布后验证已通过:`npm run release:verify-published`。
333
+ - 浏览器扩展商店版本不阻塞 `0.2.0` npm 发布;如要上架商店,需要沿
334
+ `docs/EXTENSION_PERMISSION_STRATEGY.md` 另行设计 store-candidate 权限 UX。
@@ -16,6 +16,10 @@ const commands = {
16
16
  script: join(rootDir, "mcp", "server.js"),
17
17
  env: { YUNTI_BROWSER_BRIDGE_ONLY: "1" },
18
18
  },
19
+ console: {
20
+ script: join(rootDir, "mcp", "server.js"),
21
+ env: { YUNTI_BROWSER_BRIDGE_ONLY: "1" },
22
+ },
19
23
  doctor: {
20
24
  script: join(rootDir, "scripts", "doctor.js"),
21
25
  env: {},
@@ -73,6 +77,7 @@ Usage:
73
77
  Commands:
74
78
  mcp Start the stdio MCP server (default)
75
79
  bridge Start only the local HTTP bridge
80
+ console Start the bridge and print the optional local console URL
76
81
  doctor Run install and bridge diagnostics
77
82
  print-config Print MCP configuration for an agent
78
83
  package-extension Build the browser extension zip
@@ -80,6 +85,7 @@ Commands:
80
85
  Examples:
81
86
  yunti-browser-runtime
82
87
  yunti-browser-runtime bridge
88
+ yunti-browser-runtime console
83
89
  yunti-browser-runtime doctor
84
90
  yunti-browser-runtime print-config -- --agent codex --human
85
91
  yunti-browser-runtime package-extension`)
@@ -0,0 +1,41 @@
1
+ # Action Result Coverage
2
+
3
+ This document is the durable P6.2 action result coverage matrix. It exists so
4
+ future context compaction or thread handoff cannot blur which browser action
5
+ surfaces already expose structured result fields.
6
+
7
+ Compatibility rule: every action path must keep its historical fields while
8
+ adding structured fields such as `action`, `target`, `ok`, `code`,
9
+ `recoverable`, `recoveryHint`, and `nextStepHint` where useful.
10
+
11
+ ## Coverage Matrix
12
+
13
+ | Tool | Covered success paths | Covered failure diagnostics | Compatibility fields preserved | Remaining validation |
14
+ | --- | --- | --- | --- | --- |
15
+ | `yunti_click` | uid, coordinate, selector | stale uid, missing uid, selector failure via content result | `clicked`, `uid`, `selector`, `x`, `y`, `method`, `element`, `browserSessionId` | Real-browser observe-click-observe closure pending |
16
+ | `yunti_hover` | uid, coordinate, selector | stale uid, missing uid, selector failure via content result | `hovered`, `uid`, `selector`, `x`, `y`, `method`, `element`, `browserSessionId` | Real-browser hover menu closure pending |
17
+ | `yunti_fill` | uid keyboard, uid select, uid contenteditable, selector | stale uid, missing uid, selector failure, non-editable, hidden, disabled, readonly, option miss, value not applied | `filled`, `uid`, `selector`, `method`, `value`, `valueLength`, `element`, `before`, `after`, `browserSessionId` | Real-browser controlled input closure pending |
18
+ | `yunti_select` | selector value, uid value, uid text | selector failure, uid failure, option miss, disabled option, non-select target | `selected`, `uid`, `selector`, `value`, `text`, `selectedIndex`, `element`, `browserSessionId` | Real-browser async option closure pending |
19
+ | `yunti_fill_form` | aggregate success, partial failure | per-field fill/select failure aggregation | `filled`, `failed`, `results`, `browserSessionId` | Real-browser multi-field form closure pending |
20
+ | `yunti_wait_for` | text, selector, urlContains | timeout | `found`, `text`, `selector`, `condition`, `value`, `waitedMs`, `browserSessionId` | Real-browser async wait closure pending |
21
+ | `yunti_scroll` | document, uid container, coordinate container, coordinate document fallback | uid missing, uid stale, coordinate unavailable, no movement, partial movement, document fallback hint | `scrolled`, `deltaX`, `deltaY`, `target`, `before`, `after`, `moved`, `browserSessionId` | Real-browser nested panel closure pending |
22
+ | `yunti_type_text` | uid, selector | stale uid, missing uid, selector failure via content result | `typed`, `uid`, `selector`, `text`, `textLength`, `method`, `mode`, `element`, `browserSessionId` | Real-browser text editor closure pending |
23
+ | `yunti_press_key` | uid, selector | stale uid, missing uid, selector failure via content result | `pressed`, `uid`, `selector`, `key`, `element`, `valueChanged`, `browserSessionId` | Real-browser shortcut closure pending |
24
+ | `yunti_upload_file` | uid, selector | stale uid, missing uid, selector failure via CDP/content path | `uploaded`, `uid`, `selector`, `fileCount`, `filePaths`, `browserSessionId` | Real-browser file input closure pending |
25
+ | `yunti_drag` | coordinate | coordinate argument validation, CDP dispatch failure via tool error | `dragged`, `from`, `to`, `steps`, `browserSessionId` | Real-browser drag target closure pending |
26
+
27
+ ## Coverage Gate
28
+
29
+ - Last audited phase: P6.2.7.
30
+ - Required automated check: `npm run check:action-results`.
31
+ - Required release gate: `npm run release:check` runs the coverage check.
32
+ - Real browser closure: Pending until Playwright/Chromium is installed in the
33
+ validation environment.
34
+ - Real browser command: `YUNTI_E2E=1 npm run test:e2e`.
35
+
36
+ ## Next Coverage Work
37
+
38
+ P6.2.7 closes the structured action result coverage audit. The next engineering
39
+ slice should not add another manual coverage checklist unless a new action tool
40
+ or result contract is introduced. Prefer moving to real-browser closure
41
+ validation or P6.3 agent workflow contracts.
@@ -0,0 +1,108 @@
1
+ # Agent Workflow Contract
2
+
3
+ This document is the P6.3.1 default operating contract for agents using Yunti
4
+ Browser Runtime. It is intentionally tool-level and LLM-agnostic: Yunti stays
5
+ the browser operation layer, while the agent remains responsible for task
6
+ planning and user judgment.
7
+
8
+ ## Default Loop
9
+
10
+ Use this loop for normal page work:
11
+
12
+ 1. Call `yunti_get_tool_usage_hints` when the tool contract is uncertain.
13
+ 2. Call `yunti_list_browser_targets` and choose the intended
14
+ `browserSessionId`.
15
+ 3. Call `yunti_observe_page` for the current page state.
16
+ 4. Act with a fresh uid when possible.
17
+ 5. If the page is loading or changing, call `yunti_wait_for`.
18
+ 6. After every wait or action, call `yunti_observe_page` again.
19
+ 7. Verify the result using observe, snapshot, evaluate, screenshot, network, or
20
+ console tools before assuming the task is done.
21
+ 8. If a uid/session/action result is stale or recoverable, follow
22
+ `code`, `recoveryHint`, and `nextStepHint` before retrying.
23
+
24
+ ## Recovery Rules
25
+
26
+ - Stale route: call `yunti_list_browser_targets` and use the latest
27
+ `browserSessionId`.
28
+ - Stale uid: call `yunti_observe_page` again and use a fresh uid.
29
+ - Async UI: call `yunti_wait_for`, then `yunti_observe_page`, then continue
30
+ with a fresh uid.
31
+ - Scroll uncertainty: prefer fresh `scrollableContainers[]` uids, inspect
32
+ `moved`, `edgeHint`, `partialMovement`, and `recoveryHint`.
33
+ - Fill/select uncertainty: inspect `fillable`, `readOnly`, `disabled`,
34
+ `fillBlockReason`, `selectedValue`, `selectedText`, and `options[]` before
35
+ retrying.
36
+ - Timeout: treat `WAIT_TIMEOUT` as a signal to observe and adjust the condition,
37
+ not proof that the user task failed.
38
+ - Coordinates/selectors: use them as recovery or debugging paths when fresh
39
+ uids are unavailable.
40
+
41
+ ## Debugger Boundary
42
+
43
+ - In `0.2.1+`, normal observe-first page actions should not automatically
44
+ attach Chrome debugger. Prefer `yunti_observe_page` plus fresh uid
45
+ `yunti_click`, `yunti_hover`, `yunti_fill`, `yunti_select`, `yunti_scroll`,
46
+ `yunti_type_text`, and `yunti_press_key` on anti-debug-sensitive pages.
47
+ - Chrome debugger banners may still appear for explicit low-level or advanced
48
+ tools such as `yunti_cdp_send_command`, raw CDP diagnostics, performance
49
+ tracing, screenshot fallback paths, drag, upload, emulation, resize, or
50
+ legacy snapshot compatibility.
51
+
52
+ ## Confirmation Boundary
53
+
54
+ Ask the user for explicit confirmation before:
55
+
56
+ - submitting forms that change production data;
57
+ - deleting, approving, purchasing, publishing, or sending messages;
58
+ - uploading sensitive files;
59
+ - exposing or copying secrets, credentials, cookies, auth headers, tokens, or
60
+ private keys;
61
+ - taking an action whose effect cannot be verified from page state.
62
+
63
+ ## Copyable Prompt
64
+
65
+ ```text
66
+ Please operate my browser through Yunti Browser Runtime.
67
+
68
+ Follow this workflow:
69
+ 1. Call yunti_get_tool_usage_hints if tool usage is uncertain.
70
+ 2. Call yunti_list_browser_targets and choose the intended browserSessionId.
71
+ 3. Use yunti_observe_page before page actions.
72
+ 4. Prefer fresh uids from yunti_observe_page for click, hover, fill, select,
73
+ scroll, type, press, upload, and drag operations.
74
+ 5. After each action, verify by observing again or using snapshot, evaluate,
75
+ screenshot, network, or console tools.
76
+ 6. For async rendering, validation, navigation, option loading, or infinite
77
+ scroll, call yunti_wait_for, then yunti_observe_page, then continue with a
78
+ fresh uid.
79
+ 7. If a result has ok=false, code, recoveryHint, or nextStepHint, follow that
80
+ guidance before retrying. Do not blindly repeat the same action.
81
+ 8. Use selector or coordinate fallback only when fresh uids are unavailable or
82
+ as an explicit recovery/debugging path.
83
+ 9. Before submitting, deleting, approving, purchasing, publishing, uploading
84
+ sensitive files, or changing production data, ask me for confirmation.
85
+ 10. Do not expose raw cookies, passwords, auth headers, tokens, private keys, or
86
+ other secrets. Remember that DOM observation redaction does not redact
87
+ screenshots.
88
+ ```
89
+
90
+ ## Minimal Use Case Index
91
+
92
+ The concrete P6.3.2 minimal use cases are maintained in
93
+ [Tool Guide](TOOL_GUIDE.md#minimal-use-cases) and mirrored in the packaged
94
+ skill:
95
+
96
+ - Click
97
+ - Fill Form
98
+ - Scroll To Find
99
+ - Switch Tab
100
+ - Wait For Async Result
101
+
102
+ ## Non-Goals
103
+
104
+ - Do not move a built-in LLM loop into Yunti Runtime.
105
+ - Do not replace fine-grained `yunti_*` tools with a single opaque task runner.
106
+ - Do not require a mandatory hub tab or side panel for the default local path.
107
+ - Do not remove CDP, screenshots, network, console, tab control, upload, or
108
+ diagnostic capabilities while improving page-level workflows.