dsh-browser-cdp 1.2.5 → 1.3.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/README.md CHANGED
@@ -221,28 +221,34 @@ dshx list # 应显示:[on] dsh-
221
221
 
222
222
  ## 工具注入分级(懒注册 / 分级 / 锁定)
223
223
 
224
- 38 个工具全量注册时,**每个会话每一轮**都要为它们的 schema 付费(实测 `description` + `parameters` ≈ 25.6K 字符 ≈ 5–7K token),而不碰浏览器的会话一个也用不上。插件因此把「谁能出现在模型面前」收成一处策略(`src/toolTiers.ts`),分四级注入:
224
+ 38 个工具全量注册时,**每个会话每一轮**都要为它们的 schema 付费(AST 实测 `description` + `parameters` ≈ 18.8K 字符 ≈ 5.4K token),而不碰浏览器的会话一个也用不上。插件因此把「谁能出现在模型面前」收成一处策略(`src/toolTiers.ts`),分**八批**注入:
225
225
 
226
- | 级别 | 成员 | 何时出现 |
227
- |---|---|---|
228
- | **core** 常驻(6) | `bcdp_status` `bcdp_doctor` `bcdp_help` `bcdp_space_open` `bcdp_navigate` `bcdp_snapshot` | 永远在场,不可封印——否则 lazy 模式连解锁入口都没有 |
229
- | **browse** 基础操作(14) | 点击/填写/键鼠/截图/读取/等待/关闭空间 等 | `lazy` 下等首次活动;`always` 下挂载即在 |
230
- | **extended** 扩展能力(13) | 拖拽/上传/下载/对话框/裸 CDP/脚本逃生舱/登录搬运 | 同上 |
231
- | **judge** 评审链(5) | `bcdp_jev_*` | 除解锁外,**还要求配了 JEV 或 Laya Key**——没 Key 它们只能回答「未配置」 |
226
+ | 批次 | 成员 | schema | 何时出现 |
227
+ |---|---|---:|---|
228
+ | **core** 常驻(7) | `bcdp_status` `bcdp_doctor` `bcdp_help` `bcdp_space_open` `bcdp_space_close` `bcdp_navigate` `bcdp_snapshot` | 2,610 | 永远在场,不可封印——否则 lazy 模式连解锁入口都没有 |
229
+ | **act** 动手(8) | click / fill / key / hover / scroll / select / check / drag | 3,823 | `lazy` 下首次活动放第一波 |
230
+ | **observe** 观察(4) | screenshot / page_info / read_element / js | 1,663 | 第二次活动 |
231
+ | **wait** 等待(4) | wait / wait_for_selector / wait_for_url / wait_for_response | 1,695 | 第三次活动 |
232
+ | **power** 重量级(5) | raw CDP / http / upload / download / dialog | 2,947 | 首次活动(同 `toolExtended`) |
233
+ | **session** 登录态(3) | captcha / auth_flush / login_import | 1,689 | 首次活动(同 `toolExtended`) |
234
+ | **escape** 逃生舱(2) | cli / script | 1,224 | **冷启动即在**,不吃活动闸(见下) |
235
+ | **judge** 评审链(5) | `bcdp_jev_*` | 3,183 | 除解锁外,**还要求配了 JEV 或 Laya Key** |
236
+
237
+ 设置项在插件设置页**最上方**的「工具封印」分块(全部 volatile,翻完当场生效,不重启插件)——一个开关管一组批次,形状照 dsh-prime-memory 的「工具封印」:
232
238
 
233
- 设置项在插件设置页**最上方**的「工具封印」分块(全部 volatile,翻完当场生效,不重启插件)——一级一个开关,形状照 dsh-prime-memory 的「工具封印」:
239
+ - **`toolInjection`** `lazy`(**默认**:常驻 core + escape,其余首次 `bcdp_*` 调用后按开关注入)/ `always`(挂载即全量,历史行为)。
240
+ - **`toolBrowse`**(act + observe + wait = 16)/ **`toolExtended`**(power + session = 8)/ **`toolEscape`**(cli + script = 2)/ **`toolJudge`**(5):开 = 开放注册,关 = 该批从模型工具列表移除。四组各自独立,封一组不波及别组;`core` 级不给开关(封了就没了活动入口)。
234
241
 
235
- - **`toolInjection`** `lazy`(**默认**:只常驻 core,首次 `bcdp_*` 调用后按开关注入)/ `always`(挂载即全量,历史行为)。
236
- - **`toolBrowse`**(14)/ **`toolExtended`**(13)/ **`toolJudge`**(5):开 = 开放注册,关 = 该级从模型工具列表移除。三级各自独立,封一级不波及别级;`core` 级不给开关(封了就没了活动入口)。
242
+ **escape 批为什么单独成组、且不等活动**:`cli` / `script` 是唯一能在一次调用里干完任意多步任务的入口(`page` / `browser` / `taskSpaces` / `fetch` / `cdp` 全预置),其余 36 个工具能做的事它都能做。所以它必须始终可达——否则模型遇到「结构化工具没覆盖」的情形时手里没有任何逃生手段。这也让它成为**按需只开逃生舱**的合法姿势:关掉 `toolExtended`、留着 `toolEscape`,只留 2 个工具。
237
243
 
238
244
  行为要点:
239
245
 
240
246
  - **封印 = 反注册**(工具从模型的工具列表里消失),不是执行期拒绝。解锁信号挂在 `bcdp_*` 调用的公共出口上,工具体不知道分级存在;`bcdp_status` / `bcdp_help` / `bcdp_doctor` 自身也算活动信号(读了指南就得有工具可用)。
241
247
  - **闲置自动收回**:`lazy` + `idleTimeoutMin > 0` 时,空闲回收把后台浏览器停掉的同一刻收回扩展面;下次活动重新铺开。`always` 模式不受影响。
242
248
  - `legacyEgoToolNames` 的 `ego_*` 别名跟随其 `bcdp_*` 本体的级别。
243
- - 当前注入面写在 `bcdp_doctor` 报告首行(`tool injection: mode=lazy browse=open extended=open judge=open judgeKey=none active=no → live 6 / sealed 32`),不用猜。
244
- - 默认档下不碰浏览器的会话只有 **6** 个工具在场(≈ 2.9K 字符,−88.6%);要回到历史行为把 `toolInjection` 改成 `always`(38 件全在场需再配一个评审 Key)。
245
- - 四个字段都带 schema `.default()`:volatile 字段的表单描述符直接拿 schema 默认值,不写默认会出现「面板显示 A、运行时用 B」。
249
+ - 当前注入面写在 `bcdp_doctor` 报告首行(`tool injection: mode=lazy browse=open extended=open escape=open judge=open judgeKey=none active=no → live 9 / sealed 29`),不用猜。
250
+ - 默认档下不碰浏览器的会话只有 **9** 个工具在场(core 7 + escape 2 ≈ 3.8K 字符,−79.6%);要回到历史行为把 `toolInjection` 改成 `always`(38 件全在场需再配一个评审 Key)。
251
+ - 五个字段都带 schema `.default()`:volatile 字段的表单描述符直接拿 schema 默认值,不写默认会出现「面板显示 A、运行时用 B」。
246
252
 
247
253
  > 取舍提醒:窄工具(一个动作一个工具)是模型写对参数、少重试的护栏。把交互原子合并成脚本逃生舱会省上下文,但代价是模型要自己写 heredoc、出错率上升——本插件保持全部 38 个工具的签名不变,只改**出现时机**。
248
254
 
package/dsh-plugin.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://dsh.community/schemas/dsh-plugin-0.15.json",
3
3
  "id": "dsh-browser-cdp",
4
4
  "name": "dsh-browser-cdp",
5
- "version": "1.2.4",
5
+ "version": "1.3.0",
6
6
  "manifestVersion": "0.15",
7
7
  "facets": {
8
8
  "host": {
@@ -72,23 +72,31 @@
72
72
  "label": "always"
73
73
  }
74
74
  ],
75
- "hint": "lazy(默认)= 只常驻核心 6 个,首次 bcdp_* 调用后按下方开关注入,闲置回收时收回;always = 挂载即注册全部 38 个(历史行为)。"
75
+ "hint": "lazy(默认)= 常驻核心 7 个 + 逃生舱 2 个,其余首次 bcdp_* 调用后按下方开关注入,闲置回收时收回;always = 挂载即注册全部 38 个(历史行为)。"
76
76
  },
77
77
  {
78
78
  "path": [
79
79
  "toolBrowse"
80
80
  ],
81
- "label": "基础操作工具(14 个)",
81
+ "label": "基础操作工具(16 个)",
82
82
  "kind": "boolean",
83
- "hint": "开(默认)= 浏览器活动后正常注册;关 = 14 个工具从模型工具列表移除(点击/填写/键鼠/截图/读取/等待…)。"
83
+ "hint": "开(默认)= 浏览器活动后按 act → observe → wait 三波放行;关 = 16 个工具从模型工具列表移除(点击/填写/键鼠/拖拽/截图/读取/等待…)。"
84
84
  },
85
85
  {
86
86
  "path": [
87
87
  "toolExtended"
88
88
  ],
89
- "label": "扩展能力工具(13 个)",
89
+ "label": "扩展能力工具(8 个)",
90
90
  "kind": "boolean",
91
- "hint": "开(默认)= 正常注册;关 = 13 个工具移除(拖拽/上传/下载/对话框/裸 CDP/脚本逃生舱/登录导入)。"
91
+ "hint": "开(默认)= 浏览器活动后注册;关 = 8 个工具移除(裸 CDP/HTTP/上传/下载/对话框/验证码/登录落盘/登录导入)。"
92
+ },
93
+ {
94
+ "path": [
95
+ "toolEscape"
96
+ ],
97
+ "label": "逃生舱 cli / script(2 个)",
98
+ "kind": "boolean",
99
+ "hint": "始终可用——与其它档不同,它不等浏览器活动,因为一个 heredoc 就能做到其余 36 个工具的事。关 = 封印。"
92
100
  },
93
101
  {
94
102
  "path": [
package/lib/client.js CHANGED
@@ -1360,20 +1360,26 @@ var FAM_FIELD_GROUPS = [
1360
1360
  k: "toolInjection",
1361
1361
  kind: "sel",
1362
1362
  options: ["lazy", "always"],
1363
- en: ["Injection mode", "lazy (default) = only the 6 core tools stay resident; the rest are injected after the first bcdp_* call and sealed back on idle reaping. always = every tool registered at mount (historical)"],
1364
- zh: ["工具注入模式", "lazy(默认)= 只常驻核心 6 个,首次 bcdp_* 调用后铺开、闲置回收时收回;always = 挂载即注册全部(历史行为)"]
1363
+ en: ["Injection mode", "lazy (default) = the 7 core tools plus the 2 escape-hatch tools stay resident; the rest are injected after the first bcdp_* call and sealed back on idle reaping. always = every tool registered at mount (historical)"],
1364
+ zh: ["工具注入模式", "lazy(默认)= 常驻核心 7 个 + 逃生舱 2 个,其余在首次 bcdp_* 调用后铺开、闲置回收时收回;always = 挂载即注册全部(历史行为)"]
1365
1365
  },
1366
1366
  {
1367
1367
  k: "toolBrowse",
1368
1368
  kind: "bool",
1369
- en: ["Basic browsing tools (14)", "On (default) = registered after browser activity; off = 14 tools removed from the model tool list (click / fill / key / screenshot / read / wait ...)"],
1370
- zh: ["基础操作工具(14 个)", "开(默认)= 浏览器活动后正常注册;关 = 14 个工具从模型工具列表移除(点击/填写/键鼠/截图/读取/等待…)"]
1369
+ en: ["Basic browsing tools (16)", "On (default) = released in three waves after browser activity (act → observe → wait); off = 16 tools removed from the model tool list (click / fill / key / drag / screenshot / read / wait ...)"],
1370
+ zh: ["基础操作工具(16 个)", "开(默认)= 浏览器活动后按 act → observe → wait 三波放行;关 = 16 个工具从模型工具列表移除(点击/填写/键鼠/拖拽/截图/读取/等待…)"]
1371
1371
  },
1372
1372
  {
1373
1373
  k: "toolExtended",
1374
1374
  kind: "bool",
1375
- en: ["Extended tools (13)", "On (default) = registered; off = 13 tools removed (drag / upload / download / dialog / raw CDP / script escape hatches / login import)"],
1376
- zh: ["扩展能力工具(13 个)", "开(默认)= 正常注册;关 = 13 个工具移除(拖拽/上传/下载/对话框/裸 CDP/脚本逃生舱/登录导入)"]
1375
+ en: ["Extended tools (8)", "On (default) = registered after browser activity; off = 8 tools removed (raw CDP / http / upload / download / dialog / captcha / auth flush / login import)"],
1376
+ zh: ["扩展能力工具(8 个)", "开(默认)= 浏览器活动后注册;关 = 8 个工具移除(裸 CDP/HTTP/上传/下载/对话框/验证码/登录落盘/登录导入)"]
1377
+ },
1378
+ {
1379
+ k: "toolEscape",
1380
+ kind: "bool",
1381
+ en: ["Escape hatch (2: cli / script)", "Always available — unlike the other tiers it does not wait for browser activity, because one heredoc can do what any of the other 36 tools do. Off = sealed"],
1382
+ zh: ["逃生舱(2 个:cli / script)", "始终可用——与其它档不同,它不等浏览器活动,因为一个 heredoc 就能做到其余 36 个工具的事。关 = 封印"]
1377
1383
  },
1378
1384
  {
1379
1385
  k: "toolJudge",
package/lib/index.js CHANGED
@@ -2713,6 +2713,7 @@ const Config$1 = z.object({
2713
2713
  toolInjection: toolInjection.default("lazy").description("lazy = keep only the core tier resident and inject the rest after the first bcdp_* activity (the idle reaper seals them back); always = register every allowed tool at mount (the historical behaviour).").volatile(),
2714
2714
  toolBrowse: z.boolean().default(true).description("Basic browsing tier (14 tools: click / fill / key / hover / scroll / select / check / screenshot / page_info / read_element / js / wait / wait_for_selector / space_close). Off = sealed: removed from the model tool list.").volatile(),
2715
2715
  toolExtended: z.boolean().default(true).description("Extended tier (13 tools: drag / upload / download / dialog / raw CDP / http / cli / script / captcha / auth_flush / login_import / wait_for_url / wait_for_response). Off = sealed even after browser activity.").volatile(),
2716
+ toolEscape: z.boolean().default(true).description("Escape-hatch tier (2 tools: cli / script — run an arbitrary heredoc with page/browser/taskSpaces/fetch/cdp preloaded). Unlike every other non-core tier it is NOT held back until browser activity: the one tool that can do anything in a single call must always be reachable. Off = sealed.").volatile(),
2716
2717
  toolJudge: z.boolean().default(true).description("Judgement tier (5 bcdp_jev_* tools). On still requires a JEV or Laya key: without one they can only answer \"not configured\", so they stay sealed anyway.").volatile(),
2717
2718
  localHeadless: z.boolean().description("Run the locally launched browser headless."),
2718
2719
  remoteEnabled: z.boolean().description("Master switch for REMOTE attach. Off = the configured target sequence is preserved but inert (nothing probes or connects remotely); flip back on any time. Does not affect cdpMode=local.").volatile(),
@@ -2979,6 +2980,7 @@ function resolveConfig(config = {}) {
2979
2980
  toolInjection: oneOf(config.toolInjection, ["lazy", "always"], "lazy"),
2980
2981
  toolBrowse: tierOpenByDefault(config.toolBrowse),
2981
2982
  toolExtended: tierOpenByDefault(config.toolExtended),
2983
+ toolEscape: tierOpenByDefault(config.toolEscape),
2982
2984
  toolJudge: tierOpenByDefault(config.toolJudge),
2983
2985
  localHeadless: config.localHeadless === void 0 ? false : Boolean(config.localHeadless),
2984
2986
  localUserDataDir: typeof config.localUserDataDir === "string" ? config.localUserDataDir : "",
@@ -3240,7 +3242,7 @@ const EGO_HELP_INDEX = {
3240
3242
  login: "bcdp_auth_flush: 把登录cookie落盘到ego profile; 观察窗登录引导条+『已登录,保存』按钮触发同一动作。bcdp_login_import: 从系统浏览器(Chrome/Edge/Brave)按域名导入登录cookie(source/domains/dryRun; 先dryRun看可导入项; ego浏览器须已在运行)。",
3241
3243
  script: "bcdp_cli / bcdp_script: 原样运行任意内置运行时 heredoc 脚本(page/browser/taskSpaces/site/fetch/cdp预载)。bcdp_script额外返回 duration/timedOut。",
3242
3244
  doctor: "bcdp_doctor: 体检环境(浏览器候选、vendored runtime、状态目录、CDP端口、任务空间、引擎与降级清单);首行附工具注入面快照。",
3243
- injection: "工具分级注入(不是工具,是出现时机):38 个 bcdp_* 分四级——core(status/doctor/help/space_open/navigate/snapshot,常驻不可封印)/ browse(基础操作)/ extended(拖拽上传下载对话框裸CDP脚本登录搬运)/ judge(bcdp_jev_*)。设置旋钮(全 volatile,一级一个开关):toolInjection = lazy(默认,只常驻 core,首次 bcdp_* 调用后铺开)/ always(挂载即全量,历史行为);toolBrowse / toolExtended / toolJudge 三把开关——开 = 开放注册,关 = 该级从工具列表移除(core 级不给开关,封了就没解锁入口);judge 级即使开了仍需配 JEV/Laya Key。封印 = 从工具列表里反注册,不是执行期报错;lazy 下闲置回收会把扩展面收回。**若某个 bcdp_* 工具不在你的工具列表里**:它被分级封印了——先跑 bcdp_status 或 bcdp_doctor(两者也算浏览器活动,会把面铺开),或让用户在设置页「工具封印」里打开对应档位的开关;别猜测不存在的工具名。",
3245
+ injection: "工具分级注入(不是工具,是出现时机):38 个 bcdp_* 分八批——core(status/doctor/help/space_open/space_close/navigate/snapshot,常驻不可封印)/ act(点击填写键鼠拖拽)/ observe(截图页面信息读取js)/ wait(等待类)/ power(裸CDP/HTTP/上传/下载/对话框)/ session(验证码/登录落盘/登录导入)/ escape(cli/script 逃生舱)/ judge(bcdp_jev_*)。设置旋钮(全 volatile):toolInjection = lazy(默认,常驻 core + escape,首次 bcdp_* 调用后铺开其余)/ always(挂载即全量,历史行为);toolBrowse(act+observe+wait,内部按 act→observe→wait 三波放行)/ toolExtended(power+session)/ toolEscape(cli+script)/ toolJudge 四把开关——开 = 开放注册,关 = 该批从工具列表移除(core 级不给开关,封了就没解锁入口);judge 级即使开了仍需配 JEV/Laya Key。**escape 批不吃活动闸**:cli/script 是唯一的「一次调用干完任意多步任务」的入口,必须始终可达,不排在首次活动之后。封印 = 从工具列表里反注册,不是执行期报错;lazy 下闲置回收会把扩展面收回。**若某个 bcdp_* 工具不在你的工具列表里**:它被分级封印了——先跑 bcdp_status 或 bcdp_doctor(两者也算浏览器活动,会把面铺开),或让用户在设置页「工具封印」里打开对应档位的开关;别猜测不存在的工具名。",
3244
3246
  lightpanda: "Lightpanda 作为后端(无头文本渲染引擎,beta):设置面板「添加 Lightpanda(受管)」——受管 serve 行(本机单例,插件负责拉起/复用/停止;win32 经 WSL2,linux/mac 本机直装),激活后 probe 自动识别 engine 并全链降级;也可用普通 CDP 端点接已自起的 serve(http://127.0.0.1:9222)。**有头/无头与顺序语义**:CDP 端点/本机 Chrome/ego CLI 是有头类型——可人工兜底(手动输账号、过验证码),是兜底主力;Lightpanda 是无头类型——无法人工介入,只适合快速试验。顺序即优先级:把 Lightpanda 排在前面 = 快速场景优先用它;排在有头类型后面 = 有头兜底优先,Lightpanda 实际不会被启用。安装——linux/macOS:`curl -fsSL https://pkg.lightpanda.io/install.sh | bash`(装入 ~/.local/bin,确保 PATH 含它),`lightpanda serve --host 127.0.0.1 --port 9222`;Windows:无原生版,用 WSL2(管理员 `wsl --install`,WSL 内同上;WSL2 自动把端口映射到宿主 localhost)或 Docker(`docker run -d -p 127.0.0.1:9222:9222 lightpanda/browser:nightly`)。可用:navigate/js/click/fill/key/snapshot(AX树)/http/login_import 等;降级:截图=PNG 文本渲染(jev 输出带 engine/rendering 元数据);关闭:观察窗实时画面、面板点选、bcdp_download(调用即结构化报错)、auth_flush(返回 degraded)",
3245
3247
  judge: "JEV/Laya 判定(阶段 10):机械采集「截图 + 编号 DOM + 意图 + 操作进度」→ 组装问题 → 取选择 → 执行 → 验证。判定器只能回传编号,绝不给选择器(幻觉选择器在结构上不可能)。四件套:bcdp_jev_status(先跑这个:判定链可用性 + 配置体检,不发任何请求)/ bcdp_jev_frame(采一帧,看判定器会看到什么)/bcdp_jev_ask(组装请求体;dryRun 默认 true,可指定 round=control|chapter|pick|evaluate 逐级看)/ bcdp_jev_run(跑循环,返回逐步 trace)。bcdp_jev_attempt(平的尝试循环):给 url + goal,开页后每轮选项 = DOM 候选 + end 项,判定模型在 maxActions(默认 5)预算内行动或自选 end 结束,回执含每步 anchor;判定上下文只走 DOM 树文本(模型不读截图),完成后你用 bcdp_cdp/bcdp_screenshot 按 targetId 自行核验——回执是报告不是证明。**三级缩小**:control(要不要动手,固定 5 项)→ chapter(哪个章节,按 AX 容器聚簇)→ pick(章节内哪个编号 + 风险度)。分章节不是装饰:阈值按候选数分桶,把 20 选 1 拆成「几选 1 × 几选 1」会让两轮都落在更严的桶里。单章节时不问章节轮。**判定上下文是隔离的**:只允许 INTENT / PROGRESS / FRAME / HISTORY 四段,**绝不带 agent 会话 session 前缀**;多出任何一段都会在组装时直接抛错(不靠约定,靠断言)。PROGRESS 由循环自己机械生成,不让模型写(模型写的进度是第二个人幻觉通道)。**评估开关 jevEvaluate(默认开)**:每步执行后判定器再判进度 inprogress/done/fail;fail 或「未验真的 done」不猜下一步,直接 escalate——带有序 RecoveryOption(reload 排第一,因陈旧渲染会藏住已写入的确认),交回你来恢复或停手。被操作元素会保留 class 等定位特征(只剥离检视器外壳 token)随 escalate 回传,便于恢复。**默认链路是 laya -> rule**:JEV 目前无法注册,所以默认不写它;将来可用时把 jev 加回跳序并填 URL 即可。不可用的跳**跳过不调用**(laya-api 强制鉴权无匿名分支,缺 key 必然 401),每一跳的跳过与失败都记进 trace,绝不静默回落;refuse 是结果不是异常。阈值一律用选中项概率 top(不是 confidence:后者是归一化熵,2 选 1 与 20 选 1 不可比)。设置面板键:layaUrl/layaKey/layaModel(laya 端口 8000,不是 7789)、judgePrefer、jevChunkSize、jevMaxImageBytes、jevHistoryLimit、jevArchiveImage、jevStepBudget、jevWallMs;jevUrl/jevKey/jevModel 留空即可(JEV 未开放注册)。"
3246
3248
  };
@@ -3554,7 +3556,7 @@ const CORE = [
3554
3556
  "bcdp_navigate",
3555
3557
  "bcdp_snapshot"
3556
3558
  ];
3557
- const BROWSE = [
3559
+ const ACT = [
3558
3560
  "bcdp_click",
3559
3561
  "bcdp_fill",
3560
3562
  "bcdp_key",
@@ -3562,28 +3564,33 @@ const BROWSE = [
3562
3564
  "bcdp_scroll",
3563
3565
  "bcdp_select",
3564
3566
  "bcdp_check",
3567
+ "bcdp_drag"
3568
+ ];
3569
+ const OBSERVE = [
3565
3570
  "bcdp_screenshot",
3566
3571
  "bcdp_page_info",
3567
3572
  "bcdp_read_element",
3568
- "bcdp_js",
3573
+ "bcdp_js"
3574
+ ];
3575
+ const WAIT = [
3569
3576
  "bcdp_wait",
3570
- "bcdp_wait_for_selector"
3577
+ "bcdp_wait_for_selector",
3578
+ "bcdp_wait_for_url",
3579
+ "bcdp_wait_for_response"
3571
3580
  ];
3572
- const EXTENDED = [
3573
- "bcdp_drag",
3574
- "bcdp_upload",
3575
- "bcdp_download",
3576
- "bcdp_dialog",
3581
+ const POWER = [
3577
3582
  "bcdp_cdp",
3578
3583
  "bcdp_http",
3579
- "bcdp_cli",
3580
- "bcdp_script",
3584
+ "bcdp_upload",
3585
+ "bcdp_download",
3586
+ "bcdp_dialog"
3587
+ ];
3588
+ const SESSION = [
3581
3589
  "bcdp_captcha",
3582
3590
  "bcdp_auth_flush",
3583
- "bcdp_login_import",
3584
- "bcdp_wait_for_url",
3585
- "bcdp_wait_for_response"
3591
+ "bcdp_login_import"
3586
3592
  ];
3593
+ const ESCAPE = ["bcdp_cli", "bcdp_script"];
3587
3594
  const JUDGE = [
3588
3595
  "bcdp_jev_status",
3589
3596
  "bcdp_jev_ask",
@@ -3594,8 +3601,12 @@ const JUDGE = [
3594
3601
  /** 工具名 → 分级。`ego_*` 旧名(legacyEgoToolNames 别名)与 bcdp_* 同名同组。 */
3595
3602
  const TIER_OF_TOOL = new Map([
3596
3603
  ["core", CORE],
3597
- ["browse", BROWSE],
3598
- ["extended", EXTENDED],
3604
+ ["act", ACT],
3605
+ ["observe", OBSERVE],
3606
+ ["wait", WAIT],
3607
+ ["power", POWER],
3608
+ ["session", SESSION],
3609
+ ["escape", ESCAPE],
3599
3610
  ["judge", JUDGE]
3600
3611
  ].flatMap(([tier, names]) => names.map((n) => [n, tier])));
3601
3612
  /** 去掉 `bcdp_`/`ego_` 前缀后的裸名,便于策略表保持前缀无关。 */
@@ -3606,34 +3617,16 @@ const BATCH_ORDER = [
3606
3617
  "observe",
3607
3618
  "wait"
3608
3619
  ];
3609
- /** `browse` 级工具 → 批次。未登记的名字按 'act' 处理,绝不因缺表而被卡住。 */
3610
- const BROWSE_BATCH = {
3611
- click: "act",
3612
- fill: "act",
3613
- key: "act",
3614
- hover: "act",
3615
- scroll: "act",
3616
- select: "act",
3617
- check: "act",
3618
- screenshot: "observe",
3619
- page_info: "observe",
3620
- read_element: "observe",
3621
- js: "observe",
3622
- wait: "wait",
3623
- wait_for_selector: "wait"
3624
- };
3625
- /** 某工具的注入批次(前缀无关)。 */
3626
- const batchOfTool = (name$1) => BROWSE_BATCH[bareToolName(name$1)] ?? "act";
3627
3620
  /**
3628
- * 工具所属分级。未登记的名字落到 `extended`(最严的一档:宁可等活动解锁,
3629
- * 也不让新工具悄悄回到常驻面);调用方应当在启动时打一条 warn,见
3621
+ * 工具所属分级。未登记的名字落到 `power`(最严的一档:宁可等活动解锁,也不
3622
+ * 让新工具悄悄回到常驻面);调用方应当在启动时打一条 warn,见
3630
3623
  * `unknownTieredTools`。分级表漂移由 `tests/tool-tiers.test.ts` 的覆盖率断言
3631
3624
  * 兜住,这里只是运行期兜底。
3632
3625
  */
3633
3626
  function tierOfTool(name$1) {
3634
3627
  const bare = bareToolName(name$1);
3635
3628
  for (const [known, tier] of TIER_OF_TOOL) if (bareToolName(known) === bare) return tier;
3636
- return "extended";
3629
+ return "power";
3637
3630
  }
3638
3631
  /** 名单里所有查不到分级登记的工具名(启动自检 / 测试用)。 */
3639
3632
  const unknownTieredTools = (names) => names.filter((n) => ![...TIER_OF_TOOL.keys()].some((k) => bareToolName(k) === bareToolName(n)));
@@ -3646,36 +3639,43 @@ const judgeConfigured = (c) => (c.jevKey ?? "").trim() !== "" || (c.layaKey ?? "
3646
3639
  /** 某级开关的当前极性;`core` 恒开放。 */
3647
3640
  const tierOpen = (tier, p) => {
3648
3641
  switch (tier) {
3649
- case "browse": return p.toolBrowse;
3650
- case "extended": return p.toolExtended;
3642
+ case "core": return true;
3643
+ case "act":
3644
+ case "observe":
3645
+ case "wait": return p.toolBrowse;
3646
+ case "power":
3647
+ case "session": return p.toolExtended;
3648
+ case "escape": return p.toolEscape;
3651
3649
  case "judge": return p.toolJudge;
3652
- default: return true;
3653
3650
  }
3654
3651
  };
3655
3652
  /**
3656
3653
  * 该分级此刻是否允许注册。
3657
3654
  *
3658
- * 三条独立闸,任一不过即封印:
3659
- * ① 本级开关(一级一个,ON = 开放);
3655
+ * 四条独立闸,任一不过即封印:
3656
+ * ① 本级开关(见 tierOpen);
3660
3657
  * ② 评审级额外要求已配 Key(没 Key 的 `bcdp_jev_*` 只能回「未配置」);
3661
- * ③ 注入模式:`lazy` 下非 core 级要等活动,`always` 下不设时机闸。
3658
+ * ③ 活动闸:`lazy` 下非 core 级要等活动,`always` 下不设时机闸;
3659
+ * ④ 批次闸:只在 act/observe/wait 三批上按 batchDepth 递增放行。
3660
+ *
3661
+ * `escape` 是唯一的例外:它不吃③。逃生舱必须在模型手里始终可达——否则遇到
3662
+ * 「结构化工具没覆盖」的情形时,模型既调不动它、也没法用别的工具绕过。
3662
3663
  */
3663
3664
  function tierAllowed(tier, p) {
3665
+ if (tier === "core") return true;
3664
3666
  if (!tierOpen(tier, p)) return false;
3665
3667
  if (tier === "judge" && !p.judgeConfigured) return false;
3666
- if (tier === "core") return true;
3667
- return p.injection === "always" || p.active;
3668
- }
3669
- /** 某工具此刻是否允许注册(名字 → 分级 → 策略)。 */
3670
- function toolAllowed(name$1, p) {
3671
- const tier = tierOfTool(name$1);
3672
- if (!tierAllowed(tier, p)) return false;
3673
- if (tier === "browse" && p.injection !== "always") {
3668
+ if (tier === "escape") return true;
3669
+ if (p.injection === "always") return true;
3670
+ if (tier === "act" || tier === "observe" || tier === "wait") {
3671
+ if (!p.active) return false;
3674
3672
  const depth = p.batchDepth ?? BATCH_ORDER.length;
3675
- if (BATCH_ORDER.indexOf(batchOfTool(name$1)) >= depth) return false;
3673
+ return BATCH_ORDER.indexOf(tier) < depth;
3676
3674
  }
3677
- return true;
3675
+ return p.active;
3678
3676
  }
3677
+ /** 某工具此刻是否允许注册(名字 → 分级 → 策略)。 */
3678
+ const toolAllowed = (name$1, p) => tierAllowed(tierOfTool(name$1), p);
3679
3679
  function createTierInjector(o) {
3680
3680
  const label = o.label ?? "dsh-browser-cdp";
3681
3681
  /** 全部已登记工具,插入序。 */
@@ -7706,6 +7706,9 @@ function apply(ctx, config = {}) {
7706
7706
  get toolExtended() {
7707
7707
  return resolveConfig(bridge.source()).toolExtended;
7708
7708
  },
7709
+ get toolEscape() {
7710
+ return resolveConfig(bridge.source()).toolEscape;
7711
+ },
7709
7712
  get toolJudge() {
7710
7713
  return resolveConfig(bridge.source()).toolJudge;
7711
7714
  },
@@ -7809,6 +7812,7 @@ function apply(ctx, config = {}) {
7809
7812
  injection: cfg.toolInjection,
7810
7813
  toolBrowse: cfg.toolBrowse,
7811
7814
  toolExtended: cfg.toolExtended,
7815
+ toolEscape: cfg.toolEscape,
7812
7816
  toolJudge: cfg.toolJudge,
7813
7817
  judgeConfigured: judgeConfigured({
7814
7818
  jevKey: cfg.jevKey,
@@ -7874,8 +7878,8 @@ function apply(ctx, config = {}) {
7874
7878
  {
7875
7879
  const s = tiers.surface();
7876
7880
  const unlisted = unknownTieredTools([...s.live, ...s.sealed]);
7877
- if (unlisted.length > 0) ctx.logger?.warn?.(`dsh-browser-cdp: tools missing from the tier table (defaulted to extended): ${unlisted.join(" ")}`);
7878
- ctx.logger?.info?.(`dsh-browser-cdp: tool surface ${s.live.length}/${s.live.length + s.sealed.length} (injection=${cfg.toolInjection}, switches browse=${cfg.toolBrowse ? "open" : "sealed"} extended=${cfg.toolExtended ? "open" : "sealed"} judge=${cfg.toolJudge ? "open" : "sealed"}, judgeConfigured=${judgeConfigured({
7881
+ if (unlisted.length > 0) ctx.logger?.warn?.(`dsh-browser-cdp: tools missing from the tier table (defaulted to power): ${unlisted.join(" ")}`);
7882
+ ctx.logger?.info?.(`dsh-browser-cdp: tool surface ${s.live.length}/${s.live.length + s.sealed.length} (injection=${cfg.toolInjection}, switches browse=${cfg.toolBrowse ? "open" : "sealed"} extended=${cfg.toolExtended ? "open" : "sealed"} escape=${cfg.toolEscape ? "open" : "sealed"} judge=${cfg.toolJudge ? "open" : "sealed"}, judgeConfigured=${judgeConfigured({
7879
7883
  jevKey: cfg.jevKey,
7880
7884
  layaKey: cfg.layaKey
7881
7885
  })})`);
@@ -9070,7 +9074,7 @@ function registerHelpAndDoctor(ctx, cfg, reg, tiers) {
9070
9074
  jevKey: cfg.jevKey,
9071
9075
  layaKey: cfg.layaKey
9072
9076
  });
9073
- lines.push(`tool injection: mode=${cfg.toolInjection} browse=${cfg.toolBrowse ? "open" : "sealed"} extended=${cfg.toolExtended ? "open" : "sealed"} judge=${cfg.toolJudge ? "open" : "sealed"} judgeKey=${key ? "set" : "none"} active=${tiers.active() ? "yes" : "no"} → live ${s.live.length} / sealed ${s.sealed.length}`);
9077
+ lines.push(`tool injection: mode=${cfg.toolInjection} browse=${cfg.toolBrowse ? "open" : "sealed"} extended=${cfg.toolExtended ? "open" : "sealed"} escape=${cfg.toolEscape ? "open" : "sealed"} judge=${cfg.toolJudge ? "open" : "sealed"} judgeKey=${key ? "set" : "none"} active=${tiers.active() ? "yes" : "no"} → live ${s.live.length} / sealed ${s.sealed.length}`);
9074
9078
  }
9075
9079
  lines.push(`egoBin: ${cfg.egoBin}`);
9076
9080
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-browser-cdp",
3
- "version": "1.2.5",
3
+ "version": "1.3.0",
4
4
  "description": "dsh-browser-cdp: DSH browser plugin — attach to a running Chrome/Edge over CDP (no bundled browser needed); structured browser-automation tools (30+ bcdp_*) that drive the vendored ego runtime through ctx.subprocess, plus a realtime watch panel (live SSE screencast + direct mouse interaction + download capture + human-verification notice). Web shell: floating watch panel without dsh-better-sidebar, sidebar tab with it. Headless/TUI hosts: tools-only. [DSH 0.1.7-rc.1 ~ 0.2.1-rc.1 line (exact rc enumeration): declarative settings via Config .volatile() fields; for DSH 0.1.2-rc.1 ~ 0.1.5-rc.3 use the 0.17.x line]",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",