dsh-browser-cdp 1.7.11 → 1.9.6

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
@@ -1,24 +1,36 @@
1
1
  # dsh-browser-cdp — 看得见的 Agent 浏览器(CDP 接入)
2
2
 
3
- [简体中文](README.md) | [Français](README.fr.md) | [Deutsch](README.de.md) | [Italiano](README.it.md) | [Русский](README.ru.md) | [Español](README.es.md)
4
-
3
+ <p align="center" dir="auto">
4
+ <a href="https://dshfind.com/zh/plugins/drscrewdriver/dsh-browser-cdp?ref=badge" rel="nofollow"><img src="https://raw.githubusercontent.com/drscrewdriver/dsh-browser-cdp/f7df074f2658266f373440c34f8227b40257c837/assets/dshfind-card.svg" alt="dshfind - dsh-browser-cdp" data-canonical-src="https://dshfind.com/api/badge/drscrewdriver/dsh-browser-cdp" style="max-width: 100%;"></a>
5
+ </p>
5
6
  <p align="center">
6
- <img src="https://img.shields.io/badge/DSH-0.1.7--rc.1~0.2.1--rc.5-blue" alt="DSH 0.1.7-rc.1 ~ 0.2.1-rc.5">
7
+ <img src="https://camo.githubusercontent.com/4fe1ea473d5204131549e6b56e6cbcb0cbd22c56f60deedc4c074ca58ce01738/68747470733a2f2f64736866696e642e636f6d2f6170692f62616467652f466973667a792f65676f2d62726f777365723f6c616e673d7a68" alt="dshfind - dsh-browser-cdp" data-canonical-src="https://dshfind.com/zh/plugins/drscrewdriver/dsh-browser-cdp" style="max-width: 100%;">
8
+ <img src="https://img.shields.io/badge/DSH-0.1.7--rc.1~0.2.2--rc.1-blue" alt="DSH 0.1.7-rc.1 ~ 0.2.2-rc.1">
7
9
  <img src="https://img.shields.io/badge/DSH--better--sidebar-%3E%3D0.12.2(optional)-red" alt="dsh-better-sidebar >= 0.12.2 (optional)">
8
10
  <img src="https://img.shields.io/badge/Node-%3E%3D22-brightgreen?logo=node.js&logoColor=white" alt="Node >= 22">
9
11
  </p>
10
12
 
11
- > **仓库**:`github.com/drscrewdriver/dsh-browser-cdp`|版本历史见 [CHANGELOG.md](CHANGELOG.md)
13
+ [![dshfind](https://dshfind.com/api/badge/drscrewdriver/dsh-browser-cdp?lang=zh)](https://dshfind.com/zh/plugins/drscrewdriver/dsh-browser-cdp?ref=badge)
14
+ [![dsh.so risk](https://cdn.dsh.so/badge/dsh-browser-cdp.svg)](https://www.dsh.so/artifact/dsh-browser-cdp/?ref=badge)
15
+ [![dsh.so install · dsh 0.2.1-rc.2](https://cdn.dsh.so/badge/install/dsh-browser-cdp@0.2.1-rc.2.svg)](https://www.dsh.so/artifact/dsh-browser-cdp/?ref=badge-install)
16
+ > 看得见的 Agent 浏览器(CDP 接入),同时驱动 egolite / Tabbit / Chrome / Edge / Brave / Lightpanda。常驻只有 `bcdp_status`(401 字符),其余 34 个 `bcdp_*` 工具按活动批次解锁——不碰浏览器的会话不缴 schema token 税(实测 −91.9%)。实时观察窗支持直接点击/滚动/中文输入,点选元素以 `@"picks/*.json"` 引用投进输入框,人机验证提醒;非 CDP 通道(ego CLI / Tabbit CLI)以 3s 轮询同步画面。宿主 `>=0.1.7-rc.1 <0.3.0-0`(窗口 era)。
17
+ >
18
+ > Visible agent browser for DSH over CDP, also driving egolite / Tabbit / Chrome / Edge / Brave / Lightpanda. Only `bcdp_status` stays resident (401 chars); the other 34 context-optimized `bcdp_*` tools unlock per activity batch, so non-browser sessions pay no schema tax (−91.9% measured). Realtime watch panel with direct click/scroll/IME, element picks quoted into the composer as `@"picks/*.json"`, human-verification notices; non-CDP channels (ego CLI / Tabbit CLI) sync frames by 3s polling. Host `>=0.1.7-rc.1 <0.3.0-0` (window era).
19
+
20
+ [简体中文](README.md) | [Français](README.fr.md) | [Deutsch](README.de.md) | [Italiano](README.it.md) | [Русский](README.ru.md) | [Español](README.es.md)
21
+
22
+
23
+ > **仓库**:`github.com/drscrewdriver/dsh-browser-cdp`|当前版本 **v1.8.0**|版本历史见 [CHANGELOG.md](CHANGELOG.md)|详情页:[dshfind](https://dshfind.com/zh/plugins/drscrewdriver/dsh-browser-cdp)
12
24
 
13
25
  ### 版本兼容矩阵
14
26
 
15
27
  | 依赖 | 最低版本 | 推荐版本 | 说明 |
16
28
  |---|---|---|---|
17
- | **DSH** (DeepSeek Harness) | `0.1.7-rc.1` | `0.1.7-rc.1 ~ 0.2.1-rc.4`(精确枚举) | 精确枚举 8 个 rc 版本,engines 与全部 dsh peer 同串(无区间/caret):`0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5`;宿主对插件 API 向后兼容(0.2.0 的 composer/`forkSession` 为签名扩展,插件仅作调用方,免改)。声明式设置面自 0.1.7 引入(Config `.volatile()` 字段自动生成设置表单),0.2.0/0.2.1 延续该形态。DSH `0.1.2-rc.1` ~ `0.1.5-rc.3` 请使用 **0.17.x** 版本线,0.1.0-rc.x / 0.1.1-rc.x 请使用 v0.8.0 及更早版本 |
29
+ | **DSH** (DeepSeek Harness) | `0.1.7-rc.1` | `>=0.1.7-rc.1 <0.3.0-0`(窗口 era) | engines 与全部 dsh peer 同串(单侧 rc 下界 + pre-release 排他上界的窗口):`>=0.1.7-rc.1 <0.3.0-0`,`<0.3.0-0` 确保排除 0.3.0 线及其 rc;宿主对插件 API 向后兼容(0.2.0 的 composer/`forkSession` 为签名扩展,插件仅作调用方,免改)。声明式设置面自 0.1.7 引入(Config `.volatile()` 字段自动生成设置表单),0.2.0/0.2.1 延续该形态。DSH `0.1.2-rc.1` ~ `0.1.5-rc.3` 请使用 **0.17.x** 版本线,0.1.0-rc.x / 0.1.1-rc.x 请使用 v0.8.0 及更早版本 |
18
30
  | **dsh-better-sidebar** | `0.12.2`(可选) | `≥ 0.17.1` | 未安装时自动回退浮动观察球;`< 0.12.2` 可运行但外部链接拦截(`urlTarget`)静默降级 |
19
31
  | **Node.js** | `22` | — | harness 环境自带 |
20
32
 
21
- **DSH 全版本适配说明**:本版本(**1.2.1 起**;1.2.2 起追加 0.2.1-rc.2)面向 DSH `0.1.7-rc.1 ~ 0.2.1-rc.5`(精确枚举 9 个 rc):相对 0.1.7 线(v0.17.x)**零代码改动**,纯依赖/元数据换代——0.2.0 宿主对插件 API 向后兼容,本插件经 `ctx.get('conversation').input` 门面投递选区(不调 `submit()`、不 override),不在 0.2.0 变更影响面内。声明式设置面自 0.1.7 引入:插件不再注册任何设置节(`ctx.settings` 注册类 API 已被宿主删除),改为在 Config schema 上以 `.volatile()` 标记可配置字段,由宿主设置页自动生成表单;volatile 字段变更通过 `loader/volatile-update` 事件热生效,无需重载插件。核心宿主 API(`defineTool`、`ctx.tools.register`、`ctx.subprocess.spawn`、`ctx.webServer.register`、`ctx.inject`、`ModuleLoader` CJS factory、`cordis.patch.yml`)沿用 0.1.2 以来形态。DSH `0.1.2-rc.1` ~ `0.1.5-rc.3` 请使用 **0.17.x** 版本线。
33
+ **DSH 全版本适配说明**:本版本(**1.2.1 起**;1.2.2 起追加 0.2.1-rc.2,1.7.10/1.7.11 起追加 0.2.2-rc.1)面向 DSH `0.1.7-rc.1 ~ 0.2.2-rc.1`(精确枚举 10 个 rc):相对 0.1.7 线(v0.17.x)**零代码改动**,纯依赖/元数据换代——0.2.0 宿主对插件 API 向后兼容,本插件经 `ctx.get('conversation').input` 门面投递选区(不调 `submit()`、不 override),不在 0.2.0 变更影响面内。声明式设置面自 0.1.7 引入:插件不再注册任何设置节(`ctx.settings` 注册类 API 已被宿主删除),改为在 Config schema 上以 `.volatile()` 标记可配置字段,由宿主设置页自动生成表单;volatile 字段变更通过 `loader/volatile-update` 事件热生效,无需重载插件。核心宿主 API(`defineTool`、`ctx.tools.register`、`ctx.subprocess.spawn`、`ctx.webServer.register`、`ctx.inject`、`ModuleLoader` CJS factory、`cordis.patch.yml`)沿用 0.1.2 以来形态。DSH `0.1.2-rc.1` ~ `0.1.5-rc.3` 请使用 **0.17.x** 版本线。
22
34
 
23
35
  **dsh-better-sidebar 适配说明**:本插件通过 `ctx.betterSidebar` 服务(try-catch 防御性获取)注册侧边栏 Tab 并监听外部链接。关键 API 引入版本:
24
36
 
@@ -36,7 +48,7 @@
36
48
 
37
49
  **登录态导入(v0.8.5 新增)**:工具 `bcdp_login_import`,把你日常 Chrome/Edge/Brave 里的登录 cookie **按域名**复制进 agent 浏览器(真实二进制无头启动 + CDP 透传读取,兼容 Chrome 127+ 的 App-Bound Encryption,不做离线解密;源浏览器运行中可选择优雅关闭后导入,窗口下次启动自动恢复)。cookie 值不出现在任何日志与输出中;导入前自动备份源 cookie 库,异常清空自动还原。配合默认的磁盘持久化 Profile,导入的登录态跨重启永久保留。
38
50
 
39
- 一款 **CDP 浏览器代理**:内置 **ego 兼容运行时**(供 AI Agent 用的 Chromium,来源与许可逐文件见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md))接入 DeepSeek Harness,以 **34 个结构化 `bcdp_*` 工具**驱动浏览器,并配一套**实时观察前端口**——agent 后台操作网页时,你能像看直播一样看到它正在浏览的每个页面,还能直接操作它。
51
+ 一款 **CDP 浏览器代理**:内置 **ego 兼容运行时**(供 AI Agent 用的 Chromium,来源与许可逐文件见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md))接入 DeepSeek Harness,以 **35 个结构化 `bcdp_*` 工具**驱动浏览器,并配一套**实时观察前端口**——agent 后台操作网页时,你能像看直播一样看到它正在浏览的每个页面,还能直接操作它。
40
52
 
41
53
  **一点私藏的独特之处(self-observation)**:agent 用的就是这一个 Chromium——连它操作 **DSH 自身**(管理会话、任务看板、调设置)时,观察窗也实时显示、你能随时接手。不只是"看得见 agent 在网页上干活",连 agent 操作 DSH 界面本身都是全程可见、可掌控的。
42
54
 
@@ -50,7 +62,7 @@
50
62
 
51
63
  | 能力 | 本插件(本仓库) | 同类插件 |
52
64
  |---|---|---|
53
- | 结构化工具数 | **34 个**,职责单一、可确定性调用 | **3 个**(`run`/`help`/`status`) |
65
+ | 结构化工具数 | **35 个**,职责单一、可确定性调用 | **3 个**(`run`/`help`/`status`) |
54
66
  | 实时观察窗(CDP JPEG / FFmpeg H.264 双后端 + 标签条 + 历史抽屉) | ✅ 有 | ❌ 无 |
55
67
  | 监控窗鼠标**直接操作**真实浏览器(点击/拖拽/滚动回传 CDP) | ✅ 有 | ❌ 无 |
56
68
  | **观察窗点选元素 → 捕获并引用进对话输入框**(`[CDP-PICKS]` 结构化块,人工指认目标) | ✅ 有 | ❌ 无 |
@@ -64,7 +76,7 @@
64
76
  - **控得住**:别家只读;我们监控窗**直接驱动**同一个 agent 浏览器,需要时你亲手接管(缩放/拖拽/点击),不必打断 agent 重来。
65
77
  - **指得准**:你在观察窗里**点选**页面元素,插件捕获其 `backendNodeId`/`tag`/`id` 与语义描述,以 `[CDP-PICKS]` 结构化块并入对话输入框草稿(同页多元素自动合并编号)——agent 拿到的是精确目标,不用猜"你说的按钮是哪个"。
66
78
 
67
- > 以上对比基于公开可见的可核实事实:本仓库代码(`bin/cdp-cast-worker.mjs` 实时推流 + CDP 输入回传、`lib/index.js` 34 个注册工具、`lib/cast-server.js` host 桥接、`lib/client.js` 的 `deliverPickToConversation` 点选引用)与同类插件公开可见的源码/README。此文档不含对任何他人的贬低——我们只陈述自己多实现并验证了哪些能力。
79
+ > 以上对比基于公开可见的可核实事实:本仓库代码(`bin/cdp-cast-worker.mjs` 实时推流 + CDP 输入回传、`lib/index.js` 35 个注册工具、`lib/cast-server.js` host 桥接、`lib/client.js` 的 `deliverPickToConversation` 点选引用)与同类插件公开可见的源码/README。此文档不含对任何他人的贬低——我们只陈述自己多实现并验证了哪些能力。
68
80
 
69
81
  **相对内置运行时本体(一个无头 CLI),我们多做了这些(都可对照本仓库代码核实):**
70
82
 
@@ -144,25 +156,28 @@ dshx list # 应显示:[on] dsh-
144
156
 
145
157
  无需宿主侧任何配置:`resolveEgoEnv` 自动探测 root / 无显示器并兜底。观察窗 host 路由(`/api/bcdp/spaces` 等)仅在有 HTTP server 时注册,headless 是安全 no-op。
146
158
 
147
- ## 连接方式:CDP 端点 / 本机 ego CLI
159
+ ## 连接方式:CDP 端点 / 本机 ego CLI / 本机 Tabbit CLI / Lightpanda
148
160
 
149
- **连接目标直接在设置里增删改**(0.18.1 起,与 0.17.x 线同源):设置卡有两处入口——「起子插件设置」family 区的本插件 tab(装了 `dsh-thinking-levels` 时),以及**插件详情页**的设置卡(`plugins.bundle.config`,不装 thinking-levels 时的独立入口);两处渲染同一份组件。每行支持:启用开关、激活、标签/端点/CLI 路径就位编辑、逐行**探测**、上移/下移、删除(删激活行会同时清空激活,**绝不顺延**);底部内联表单直接添加 CDP 端点或本机 ego CLI(第二条本机 CLI 会被拒绝)。写回落在活动 profile 的 `cordis.patch.yml`,跨重启保留。0.18.1 之前,连接序列只能在 profile 的 `cordis.patch.yml` `links` 中手工维护。
161
+ **连接目标直接在设置里增删改**(0.18.1 起,与 0.17.x 线同源):设置卡有两处入口——「起子插件设置」family 区的本插件 tab(装了 `dsh-thinking-levels` 时),以及**插件详情页**的设置卡(`plugins.bundle.config`,不装 thinking-levels 时的独立入口);两处渲染同一份组件。每行支持:启用开关、激活、标签/端点/CLI 路径就位编辑、逐行**探测**、上移/下移、删除(删激活行会同时清空激活,**绝不顺延**);底部内联表单直接添加 CDP 端点、本机 ego CLI、Lightpanda 或本机 Tabbit CLI(第二条本机 CLI / Tabbit 行会被拒绝)。写回落在活动 profile 的 `cordis.patch.yml`,跨重启保留。0.18.1 之前,连接序列只能在 profile 的 `cordis.patch.yml` `links` 中手工维护。
150
162
 
151
- 设置面板里的连接列表是**有序**的——**顺序即优先级**,被激活的那一项驱动每一次 `bcdp_*` 调用。列表元素有两种类型:
163
+ 设置面板里的连接列表是**有序**的——**顺序即优先级**,被激活的那一项驱动每一次 `bcdp_*` 调用。列表元素有四种类型:
152
164
 
153
165
  | 类型 | 它做什么 | 约束 |
154
166
  |---|---|---|
155
167
  | **CDP 端点** | 把一个已开调试端口的浏览器地址交给内置运行时(注入 `EGO_LINUX_CDP_URL`),运行时**附着**上去 | 可多条 |
156
168
  | **本机 ego CLI** | 由本机 ego CLI **自己**驱动它本机的 ego 浏览器——**不注入任何端点** | **仅限本机,全局至多一条** |
169
+ | **本机 Tabbit CLI** | 由本机 `tabbit-cli` 驱动它本机的 Tabbit 浏览器(`tabbit-cli nodejs` 执行 Playwright 片段)——**不走插件的裸 CDP 通道** | **仅限本机,全局至多一条** |
170
+ | **Lightpanda** | 插件托管启动的无头文本渲染引擎(详见下节),对插件而言是一个普通 CDP 端点 | 全局至多一条 |
157
171
 
158
- **为什么需要第二种**:注入用的 `EGO_LINUX_CDP_URL` 是**内置运行时(Linux 线)**的私有契约,macOS 上用 `ego lite` app 附带的那个原生 `ego-browser` **根本不读它**。所以在只有"CDP 端点"这一种类型时,macOS 用户无法用上自己那个已登录的 ego——只能连远端端口,或让内置运行时另起一个 stock Chromium。本机 CLI 类型补的就是这条路。
172
+ **为什么需要第二种**:注入用的 `EGO_LINUX_CDP_URL` 是**内置运行时(Linux 线)**的私有契约,macOS 上用 `ego lite` app 附带的那个原生 `ego-browser` **根本不读它**。所以在只有"CDP 端点"这一种类型时,macOS 用户无法用上自己那个已登录的 ego——只能连远端端口,或让内置运行时另起一个 stock Chromium。本机 CLI 类型补的就是这条路。Tabbit 行则是同类需求的另一条:**只有 `tabbit-cli` 能驱 Tabbit 自己的任务生命周期**(CLI 不对外开调试端口),所以插件不做裸 CDP 而是拼 Playwright 片段下发(详见下节「Tabbit 后端」)。
159
173
 
160
- 解析顺序(`cliPath` 留空时):显式路径 → PATH 上的 `ego-browser` → macOS app 包内 helper(`/Applications/ego lite.app/…/Helpers/ego-browser`)→ 插件内置运行时。
174
+ 解析顺序(`cliPath` 留空时):显式路径 → PATH 上的 `ego-browser` → macOS app 包内 helper(`/Applications/ego lite.app/…/Helpers/ego-browser`)→ 插件内置运行时。Tabbit 行的解析顺序(`cliPath` 留空时):显式路径 → `%LOCALAPPDATA%\Tabbit\LocalAgent\bin\tabbit-cli(.exe)`(Windows)→ `~/.local/bin` / `/usr/local/bin`(macOS/Linux)→ PATH 探测。
161
175
 
162
- 两个默认值值得知道:
176
+ 三个默认值值得知道:
163
177
 
164
178
  - **`useSdkPath` 默认关闭**:关闭时用 CLI 自带的 harness(配套的那套);打开后,**探测与每一次工具执行**都会注入 `--sdk-path <插件内置 harness>`。这一点很关键:只在探测时带、执行时不带,脚本首行就会崩 `ReferenceError: taskSpaces is not defined`(1.2.4 修复的 P0)。若 CLI 不认这个旗标,探测会记一条提示并**自动重试一次不带它**;此时只有 CLI 自带的 harness 确实暴露 `taskSpaces` / `browser` 门面才算就绪,否则显式判失败并给出缺失的门面名——不再假阳性。
165
179
  - **就绪探测是 `nodejs` 通道上的 facade 探针**(与干活同一条通道):只检查注入后的 `taskSpaces` / `browser` / `page` 全局,不启动也不等待浏览器,实测约 300 ms;`bcdp_status` 走同一判据。
180
+ - **Tabbit 的 `--timeout-ms` 被夹紧到 60000–180000**:超出范围 CLI 直接整请求拒绝(snippet 根本不执行),所以下发前在一处夹紧到最近合法值;单帧/截图的短截止不由它表达,而是写在 snippet 内的 `Promise.race`(默认 8s 截止,超时返回 `skipped: capture-timeout`)。
166
181
 
167
182
  ### 双 API 面共存风险
168
183
 
@@ -170,13 +185,25 @@ dshx list # 应显示:[on] dsh-
170
185
 
171
186
  与其它开关的关系:
172
187
 
173
- - `cdpMode`:`auto` 按激活项(两种类型都行);`remote` **只接受 CDP 端点**,激活项是本机 CLI 时会显式报 `mode-kind-mismatch`;`local` 走受管本地启动器。
174
- - `remoteEnabled`(远端总开关)**只管远端 CDP**,不影响本机 CLI 连接。
188
+ - `cdpMode`:`auto` 按激活项(四种类型都行);`remote` **只接受 CDP 端点**,激活项是本机 CLI / Tabbit 时会显式报 `mode-kind-mismatch`;`local` 走受管本地启动器。
189
+ - `remoteEnabled`(远端总开关)**只管远端 CDP**,不影响本机 CLI / Tabbit 连接。
175
190
  - `allowLocalFallback` / `localHeadless` / `localUserDataDir` 只作用于 CDP 端点的回落与受管启动。
176
191
  - `allowProbeColdStart`(**默认关**):就绪探测**绝不拉起 ego 浏览器**——`--status` 证明浏览器已在跑才做 heredoc 验证,否则跳过,浏览器推迟到首个真实 `bcdp_*` 调用才启动(插件挂载/改设置不再弹浏览器窗口)。打开 = 挂载探测预先验证 SDK harness(可能当场弹出浏览器窗口)。
177
192
 
178
193
  `bcdp_doctor` 会报告当前序列类型计数、CLI 实际解析到的路径与形态,以及(若同机装了旧版 `dsh-ego-browser`)一条共存提示。
179
194
 
195
+ > 现行口径:doctor 的 `links:` 计数行只列 cdp / ego-cli / lightpanda 三种,**tabbit 行不计入该行**;Tabbit 作激活后端时以 `bcdp_status` / `bcdp_help` 报出的 `backend: tabbit-cli` 为准。
196
+
197
+ ## Tabbit 后端(本机 Tabbit 浏览器,可选通道)
198
+
199
+ [Tabbit 浏览器](https://github.com/Tabbit-Browser)本身是 Chromium,但本插件不直接拿它的调试端口:激活 `tabbit-cli` 连接行后,每次 `bcdp_*` 调用被翻译成一段 Playwright 片段,经 `tabbit-cli nodejs` 在浏览器内嵌运行时里执行(适配层 `src/cdp/tabbit-cli-link.ts`)。也就是说 Tabbit 是**第四条连接通道**,与 CDP 端点 / 本机 ego CLI / Lightpanda 并列,按列表优先级争用。
200
+
201
+ - **添加入口**:设置面板底部表单选「本机 Tabbit CLI」(默认标签 `Tabbit 浏览器`);第二会被拒绝。`cliPath` 留空走上方的自动解析链。
202
+ - **支持的工具**(1.7.10 现行口径):`bcdp_space`、`bcdp_navigate`、`bcdp_snapshot`、`bcdp_click`、`bcdp_fill`、`bcdp_screenshot`、`bcdp_tab op=list`,以及入口类 `bcdp_status` / `bcdp_help` / `bcdp_doctor`。**未覆盖的工具明确报错而不静默回落 Chrome**——激活 Tabbit 时插件会硬拒内置运行时启动(避免“以为在 Tabbit 里做、实际驱动了另一个浏览器”)。
203
+ - **能力降级由连接模式决定**(`src/cdp/capabilities.ts` 的 `tabbit` 投影):`Browser.*` / `Target.*` 域不可达→无标签枚举与窗口关闭;Overlay 点选不可用→观察窗不能“点选元素引用进输入框”;下载事件不可用→`bcdp_download` 不可用;`Runtime.addBinding` 不可靠→`bindingCalled` 关闭。画面与截图走 page 作域的 `newCDPSession` + `Page.captureScreenshot`,JPEG 原生可用。
204
+ - **观察窗画面**:与内置运行时非 CDP 连接模式同一机制——后台轮询而非 screencast 直推,间隔 3s;重页面上单帧捕获可能贴近 8s 截止线(实测),所以高负载页面的实际刷新率会低于 3s,卡住的帧以 `skipped` 返回而不是挂死面板。
205
+ - **与 dsh-tabbit 插件的关系**:两者都能驱 Tabbit,但工具面与任务生命周期各自管理。同机共装时建议**二选一**,避免两个 harness 抢同一个 Tabbit 任务槽。
206
+
180
207
  ## Lightpanda 后端(可选引擎,beta)
181
208
 
182
209
  [Lightpanda](https://lightpanda.io) 是面向 AI 的无头文本渲染浏览器(AGPL-3.0,本插件仅作 CDP 客户端使用)。它对插件来说就是一个**普通 CDP 端点**:设置面板添加并激活后,probe 会从 `/json/version` 的 `Browser: Lightpanda/…` **自动识别引擎**,badge 与 `bcdp_doctor` 显示 engine,能力降级自动生效(无需任何配置)。
@@ -206,7 +233,7 @@ dshx list # 应显示:[on] dsh-
206
233
 
207
234
  识别失败的端点(`engine: unknown`)保持**全能力**——误判只应"少给",不应"错给"。
208
235
 
209
- ## 工具清单(34 个,前缀 `bcdp_`,完整索引见 `bcdp_help`)
236
+ ## 工具清单(35 个,前缀 `bcdp_`,完整索引见 `bcdp_help`)
210
237
 
211
238
  | 类别 | 工具 |
212
239
  |---|---|
@@ -307,6 +334,7 @@ wait / space / escape 三族已按 `op` 合并,旧工具名**移除**(不保
307
334
 
308
335
  - **主画面**:agent 当前页面实况;点击/拖动/滚轮直接操作页面,Ctrl+滚轮缩放视图、Ctrl+拖动平移,双击复位。点击画面后可直接键盘输入,支持中文 IME、粘贴、Tab/Enter/方向键及 Ctrl/Cmd 快捷键。
309
336
  - **选择元素**(点选引用):点一下工具条进入点选模式,再点实时画面里的任意元素——插件捕获其 `backendNodeId`/`tag`/`id` 与语义描述,以 `[CDP-PICKS]` 结构化块并入对话输入框草稿;同一页面的多次点选自动合并进同一块并依次编号,agent 按编号精确取用。浮动观察球与侧边栏 Tab 均可用。
337
+ - **整页锚点报告**(@引用):侧栏/历史抽屉里每个 tab 项的 `@` 按钮——一次点击抓取该页全部可交互元素(role+name+快照作用域 `sb-<anchor>`),归档为一份 `@"picks/*.json"` 整页报告投进输入框,让 agent 一眼拿到当前页面上下文而无需逐元素点选。同页二次点击覆盖刷新。这是 tab 粒度的快捷引用,与逐元素点选互补。
310
338
  - **标签页条**:顶部横排,点选切换,`×` 关闭。
311
339
  - **历史抽屉**(🕘):按时间回看访问轨迹。
312
340
  - 操作时下方网址行就地显示提示,2 秒后恢复。
@@ -317,6 +345,7 @@ wait / space / escape 三族已按 `op` 合并,旧工具名**移除**(不保
317
345
  - `cdp`:`Page.startScreencast` JPEG,默认 20 FPS。每个源帧立即按 Chrome 提供的帧 ID ACK,只保留最新待发帧;仅捕获当前观看标签,静态页恢复截图默认 3 秒一次。
318
346
  - `ffmpeg`:Windows 以 `gfxcapture(hwnd)` 直接采集目标 Chrome 窗口的 D3D11 surface;其他平台使用显示来源 crop。随后编码 H.264 fragmented MP4 → HTTP 二进制 chunk → MediaSource `<video>`,不经过 Base64/SSE。
319
347
  - `auto`:默认选择 CDP,不检测成功也不会自动下载 FFmpeg。FFmpeg 安装并通过能力检查后才可选择;已保存的 FFmpeg 后端若后来失效,本次观察会回退 CDP 并展示原因。
348
+ - **非 CDP 连接模式(本机 ego CLI / 本机 Tabbit CLI)**:这两类通道拿不到 `Page.startScreencast` 直推,观察窗改走**后台轮询拍帧**——每 3s 一次,帧写到临时文件后由 host 读回再广播(回执只带路径,不带字节)。因此它是“看快照”而不是“看直播”:静态页约 3s 一帧,重页面(单帧接近 8s 截止线)会明显低于这个频率;拿不到帧时以 `skipped` 标记跳过,不会挂死面板。
320
349
  - Windows FFmpeg 必须包含 `gfxcapture`。插件按 browser PID、target title 和 CDP window bounds 匹配 HWND;窗口移动或被遮挡时仍捕获目标页面,并且不允许回退到桌面录制。若 target 是同一 Chrome 窗口里的后台 tab,会明确报错而不是展示当前可见 tab 或抢用户焦点。macOS 首次使用需要“屏幕录制”权限;X11 需要 Chromium 与 FFmpeg 共享 `DISPLAY`;Wayland 缺少 Portal/PipeWire 输入时会提示切回 CDP。
321
350
 
322
351
  托管 FFmpeg 安装到 `~/.dsh/cache/ego-browser/ffmpeg/`,不会写入插件目录。Windows/Linux 使用固定 BtbN release tag;macOS 使用固定的 `ffmpeg-static` GitHub release 资产(其 Intel/Apple Silicon 二进制分别来源于 Evermeet/OSXExperts)。所有下载均固定资源 SHA-256,只提取 FFmpeg 主程序,不安装 `ffprobe` 或 `ffplay`。Windows/Linux 解包使用系统 `tar`;缺少时会在下载前明确报错。
@@ -325,7 +354,7 @@ wait / space / escape 三族已按 `op` 合并,旧工具名**移除**(不保
325
354
 
326
355
  ## 工作原理
327
356
 
328
- - **工具层**:每个工具把参数拼成 JS 脚本,经 `ctx.subprocess` 用 `ego-browser nodejs` 喂给 stdin 运行,宿主经 CDP 驱动共享 Chromium。结果以 `@@DSH_RESULT@@` 哨兵行解析。所有 `bcdp_*` 经进程内互斥锁串行化,错误统一归一。
357
+ - **工具层**:每个工具把参数拼成 JS 脚本,经 `ctx.subprocess` 用 `ego-browser nodejs` 喂给 stdin 运行,宿主经 CDP 驱动共享 Chromium。结果以 `@@DSH_RESULT@@` 哨兵行解析。所有 `bcdp_*` 经进程内互斥锁串行化,错误统一归一。激活项是本机 Tabbit CLI 时走分发器 `dispatchTabbit`:参数拼成 Playwright 片段经 `tabbit-cli nodejs` 执行,不复用 ego 子进程路径,也不得落到内置运行时。
329
358
  - **观察窗**:`lib/client.js` 管理 watcher lease、JPEG `<img>` 与 MSE `<video>`;`lib/cast-server.js` 代理元数据 SSE、watch API 和带背压的二进制视频;worker 中 `CaptureManager` 保证同时只有一个活动后端和一个当前 target。CDP 控制面(标签、viewport、输入、验证码)独立于画面后端。
330
359
 
331
360
  ## JEV 风格管道:让 LLM 把控浏览器循环(阶段 10)
@@ -380,8 +409,16 @@ pnpm run build # tsdown 三 bundle:lib/index.js + lib/client.js + bin/cdp-ca
380
409
  - **快照质量**:Linux 用 CDP `DOMSnapshot` 重建语义树,非 macOS 内核级,复杂 iframe/画布场景可能降级。
381
410
  - **宿主可靠性(Linux)**:未合并的社区 PR,跨 CLI 调用间可能丢 tab/空间状态;插件已内置防御,简单流程稳定,复杂流程可能需重试。
382
411
  - **登录态持久化**:Chrome 运行期 Cookie 仅优雅关闭时落盘,强杀重启需重登。
412
+ - **Tabbit 通道覆盖面**:仅 `space` / `navigate` / `snapshot` / `click` / `fill` / `screenshot` / `tab op=list` 已接入,其余工具返回明确错误而不回落其他后端;观察窗只能看帧、不能点选元素引用,无下载事件(`capabilities.ts` 的 `tabbit` 投影:`overlay` / `bindingCalled` / `downloadEvents` / `browserClose` 均为 false)。`bcdp_jev_*` 评审链在 Tabbit 下没有接入分发器,调用返回“尚未支持”而不是错驱另一个浏览器。
383
413
  - 输出 schema 为宽松 `additionalProperties: true`,客户端以实际返回值为准。
384
414
 
415
+ ## macOS 开箱与 Cookie 排查
416
+
417
+ - **开箱可用**:macOS 上 Chrome 从不在 `PATH`,而在 `.app` 包内。本版自动探测 `/Applications` 与 `~/Applications` 下的 Chrome / Chromium / Edge / Brave / Tungsten Edge,并注入运行时;headed 启动不依赖 X11/Xvfb(macOS 图形栈是 Aqua/Quartz,本就无 `$DISPLAY`)。无需手动填 `chromePath`。
418
+ - **Cookie 落盘路径**:macOS(与 Linux)用 `Default/Cookies`;**不是** Windows Chrome 127+ 的 `Default/Network/Cookies`。
419
+ - **Cookie 不落盘诊断(macOS 27 + Chrome 156+,issue #93)**:若 `bcdp_auth_flush` 报告的 cookie jar 非空但 `Default/Cookies` 未变,可临时用 mock keychain 对照:设环境变量 `EGO_LINUX_USE_MOCK_KEYCHAIN=1`,或在设置页 `chromeArgs` 填 `--use-mock-keychain`,然后冷启动浏览器重测。**默认关闭**——它会降低静态加密强度,仅用于诊断。
420
+ - **登录导入**:`bcdp_login_import` 在 macOS 从 `~/Library/Application Support/{Google/Chrome,Chromium,Microsoft Edge,BraveSoftware/Brave-Browser}` 定位源 profile。
421
+
385
422
  ## 许可与署名
386
423
 
387
424
  插件本体 MIT。内置运行时嵌入第三方 MIT 代码;可选下载的 FFmpeg 构建涉及 GPL-3.0-or-later 义务。使用或再分发前请阅读构建来源的许可证与源码获取信息,来源与署名详见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。
@@ -6354,6 +6354,70 @@ function capabilitiesFromEnvValue(value) {
6354
6354
  return capabilitiesFor("unknown");
6355
6355
  }
6356
6356
 
6357
+ //#endregion
6358
+ //#region src/worker/window-size.ts
6359
+ /** Chrome refuses slivers; below this a resize is not worth sending. */
6360
+ const MIN_VIEWPORT_WIDTH = 320;
6361
+ const MIN_VIEWPORT_HEIGHT = 200;
6362
+ /** A sanity ceiling; the OS clamps to the display anyway. */
6363
+ const MAX_VIEWPORT_WIDTH = 3840;
6364
+ const MAX_VIEWPORT_HEIGHT = 2160;
6365
+ /** Keep a requested viewport inside a sane range (a sliver is unusable). */
6366
+ function clampViewportSize(width, height) {
6367
+ return {
6368
+ width: Math.min(MAX_VIEWPORT_WIDTH, Math.max(MIN_VIEWPORT_WIDTH, Math.round(width))),
6369
+ height: Math.min(MAX_VIEWPORT_HEIGHT, Math.max(MIN_VIEWPORT_HEIGHT, Math.round(height)))
6370
+ };
6371
+ }
6372
+ /**
6373
+ * Apply a drag delta to the current viewport width. The panel edge maps to a
6374
+ * window-width CHANGE, not an absolute width: the panel is much narrower than
6375
+ * the window, so absolute mapping would shrink the window to the sidebar on the
6376
+ * first frame.
6377
+ */
6378
+ function widthWithDelta(currentWidth, delta) {
6379
+ const next = Math.round(currentWidth + delta);
6380
+ return Math.min(MAX_VIEWPORT_WIDTH, Math.max(MIN_VIEWPORT_WIDTH, next));
6381
+ }
6382
+ /**
6383
+ * Compute CDP `Browser.setWindowBounds` bounds for a desired page viewport.
6384
+ * `left`/`top` are preserved when known so the window does not jump while the
6385
+ * user drags a panel edge. `windowState: 'normal'` is always included: a
6386
+ * maximized window ignores width/height until it is restored.
6387
+ */
6388
+ function computeWindowBounds(viewport, chromeFrame = {
6389
+ width: 0,
6390
+ height: 0
6391
+ }, current = {}) {
6392
+ const width = Math.max(MIN_VIEWPORT_WIDTH, Math.round(viewport.width + Math.max(0, chromeFrame.width)));
6393
+ const height = Math.max(MIN_VIEWPORT_HEIGHT, Math.round(viewport.height + Math.max(0, chromeFrame.height)));
6394
+ return {
6395
+ ...typeof current.left === "number" && Number.isFinite(current.left) ? { left: Math.round(current.left) } : {},
6396
+ ...typeof current.top === "number" && Number.isFinite(current.top) ? { top: Math.round(current.top) } : {},
6397
+ width,
6398
+ height,
6399
+ windowState: "normal"
6400
+ };
6401
+ }
6402
+ /** Aspect-ratio presets offered by the panel (label → height/width ratio). */
6403
+ const ASPECT_RATIOS = {
6404
+ "16:9": 9 / 16,
6405
+ "4:3": 3 / 4,
6406
+ "21:9": 9 / 21,
6407
+ "1:1": 1,
6408
+ "9:16": 16 / 9
6409
+ };
6410
+ /**
6411
+ * Resolve an aspect preset to a viewport height for the given width. Unknown
6412
+ * labels fall back to the current height (a no-op), so a stale client value
6413
+ * never distorts the window.
6414
+ */
6415
+ function aspectHeight(width, aspect, fallbackHeight) {
6416
+ const ratio = ASPECT_RATIOS[aspect];
6417
+ if (ratio === void 0) return fallbackHeight;
6418
+ return Math.round(width * ratio);
6419
+ }
6420
+
6357
6421
  //#endregion
6358
6422
  //#region src/worker/cdp-cast-worker.ts
6359
6423
  const SENTINEL = "@@DSH_RESULT@@";
@@ -6400,6 +6464,8 @@ const sseClients = /* @__PURE__ */ new Set();
6400
6464
  const videoClients = /* @__PURE__ */ new Set();
6401
6465
  const probeCache = /* @__PURE__ */ new Map();
6402
6466
  const frameCache = /* @__PURE__ */ new Map();
6467
+ const winCache = /* @__PURE__ */ new Map();
6468
+ const chromeFrameCache = /* @__PURE__ */ new Map();
6403
6469
  let active = null;
6404
6470
  /**
6405
6471
  * M1.4 / T5.1c — the pick channel rides the worker's RESIDENT connection.
@@ -7010,13 +7076,168 @@ async function main() {
7010
7076
  await active.cdp.call("Target.closeTarget", { targetId });
7011
7077
  return sendJson(res, 200, { ok: true });
7012
7078
  }
7079
+ if (req.method === "POST" && url.pathname === "/api/switch-tab") {
7080
+ const body = await readJson(req);
7081
+ const targetId = typeof body?.targetId === "string" ? body.targetId : "";
7082
+ if (!active || targetId === "") return sendJson(res, 400, {
7083
+ ok: false,
7084
+ error: "targetId required"
7085
+ });
7086
+ try {
7087
+ await active.cdp.call("Target.activateTarget", { targetId });
7088
+ return sendJson(res, 200, {
7089
+ ok: true,
7090
+ targetId
7091
+ });
7092
+ } catch (error) {
7093
+ return sendJson(res, 502, {
7094
+ ok: false,
7095
+ error: error.message || String(error)
7096
+ });
7097
+ }
7098
+ }
7013
7099
  if (req.method === "POST" && url.pathname === "/api/flush") {
7014
7100
  if (!active) return sendJson(res, 409, {
7015
7101
  ok: false,
7016
7102
  error: "no live browser"
7017
7103
  });
7018
- await active.cdp.call("Storage.flushCookies").catch(() => {});
7019
- return sendJson(res, 200, { ok: true });
7104
+ let total = 0;
7105
+ try {
7106
+ const jar = await active.cdp.call("Storage.getCookies");
7107
+ total = Array.isArray(jar?.cookies) ? jar.cookies.length : 0;
7108
+ } catch {
7109
+ total = 0;
7110
+ }
7111
+ const flushed = await active.cdp.call("Storage.flushCookies").then(() => total).catch(() => 0);
7112
+ return sendJson(res, 200, {
7113
+ ok: true,
7114
+ total,
7115
+ flushed
7116
+ });
7117
+ }
7118
+ if (req.method === "POST" && url.pathname === "/api/window-size") {
7119
+ if (!active) return sendJson(res, 409, {
7120
+ ok: false,
7121
+ error: "no live browser"
7122
+ });
7123
+ const body = await readJson(req);
7124
+ const targetId = await activeTargetId();
7125
+ if (!targetId) return sendJson(res, 409, {
7126
+ ok: false,
7127
+ error: "no active page target"
7128
+ });
7129
+ try {
7130
+ let win = winCache.get(targetId);
7131
+ if (!win || Date.now() - win.at > 1e4) {
7132
+ const r = await active.cdp.call("Browser.getWindowForTarget", { targetId });
7133
+ win = {
7134
+ windowId: r.windowId,
7135
+ bounds: r.bounds || {},
7136
+ at: Date.now()
7137
+ };
7138
+ winCache.set(targetId, win);
7139
+ }
7140
+ if (body.maximize === true) {
7141
+ await active.cdp.call("Browser.setWindowBounds", {
7142
+ windowId: win.windowId,
7143
+ bounds: { windowState: "maximized" }
7144
+ });
7145
+ return sendJson(res, 200, {
7146
+ ok: true,
7147
+ maximized: true,
7148
+ windowId: win.windowId
7149
+ });
7150
+ }
7151
+ let cf = chromeFrameCache.get(targetId);
7152
+ if (!cf || Date.now() - cf.at > 2e3) {
7153
+ const v = (await active.sessions.call(targetId, "Runtime.evaluate", {
7154
+ expression: "({ow:outerWidth,oh:outerHeight,iw:innerWidth,ih:innerHeight})",
7155
+ returnByValue: true
7156
+ }, 3e3))?.result?.value || {};
7157
+ cf = {
7158
+ width: Math.max(0, (v.ow || 0) - (v.iw || 0)),
7159
+ height: Math.max(0, (v.oh || 0) - (v.ih || 0)),
7160
+ viewport: {
7161
+ width: v.iw || 0,
7162
+ height: v.ih || 0
7163
+ },
7164
+ at: Date.now()
7165
+ };
7166
+ chromeFrameCache.set(targetId, cf);
7167
+ }
7168
+ const cur = cf.viewport;
7169
+ let width = typeof body.width === "number" && Number.isFinite(body.width) ? body.width : typeof body.delta === "number" && Number.isFinite(body.delta) ? widthWithDelta(cur.width, body.delta) : cur.width;
7170
+ let height = typeof body.height === "number" && Number.isFinite(body.height) ? body.height : typeof body.dy === "number" && Number.isFinite(body.dy) ? cur.height + body.dy : cur.height;
7171
+ if (typeof body.aspect === "string" && body.aspect !== "") height = aspectHeight(width, body.aspect, height);
7172
+ const clamped = clampViewportSize(width, height);
7173
+ const bounds = computeWindowBounds(clamped, {
7174
+ width: cf.width,
7175
+ height: cf.height
7176
+ }, {
7177
+ left: win.bounds.left,
7178
+ top: win.bounds.top
7179
+ });
7180
+ await active.cdp.call("Browser.setWindowBounds", {
7181
+ windowId: win.windowId,
7182
+ bounds
7183
+ });
7184
+ cf.viewport = {
7185
+ width: clamped.width,
7186
+ height: clamped.height
7187
+ };
7188
+ cf.at = Date.now();
7189
+ return sendJson(res, 200, {
7190
+ ok: true,
7191
+ windowId: win.windowId,
7192
+ viewport: {
7193
+ width: clamped.width,
7194
+ height: clamped.height
7195
+ }
7196
+ });
7197
+ } catch (error) {
7198
+ return sendJson(res, 502, {
7199
+ ok: false,
7200
+ error: error.message || String(error)
7201
+ });
7202
+ }
7203
+ }
7204
+ if (req.method === "POST" && url.pathname === "/api/navigate") {
7205
+ if (!active) return sendJson(res, 409, {
7206
+ ok: false,
7207
+ error: "no live browser"
7208
+ });
7209
+ const body = await readJson(req);
7210
+ const targetId = await activeTargetId();
7211
+ if (!targetId) return sendJson(res, 409, {
7212
+ ok: false,
7213
+ error: "no active page target"
7214
+ });
7215
+ try {
7216
+ if (body.reload === true) {
7217
+ await active.sessions.call(targetId, "Page.reload", { ignoreCache: body.ignoreCache === true }, 15e3);
7218
+ return sendJson(res, 200, {
7219
+ ok: true,
7220
+ reloaded: true,
7221
+ targetId
7222
+ });
7223
+ }
7224
+ const navUrl = typeof body.url === "string" ? body.url.trim() : "";
7225
+ if (navUrl === "") return sendJson(res, 400, {
7226
+ ok: false,
7227
+ error: "url required"
7228
+ });
7229
+ await active.sessions.call(targetId, "Page.navigate", { url: navUrl }, 15e3);
7230
+ return sendJson(res, 200, {
7231
+ ok: true,
7232
+ url: navUrl,
7233
+ targetId
7234
+ });
7235
+ } catch (error) {
7236
+ return sendJson(res, 502, {
7237
+ ok: false,
7238
+ error: error.message || String(error)
7239
+ });
7240
+ }
7020
7241
  }
7021
7242
  if (req.method === "GET" && url.pathname === "/api/stream") {
7022
7243
  res.writeHead(200, {
@@ -316,6 +316,38 @@ async function recordElement(backendNodeId) {
316
316
  }
317
317
  }
318
318
 
319
+ /**
320
+ * Does the target node contain (or equal) the node hit at the click point?
321
+ *
322
+ * `DOM.getNodeForLocation` returns the TOPMOST node, which for `<a><img></a>` is
323
+ * the IMG, not the anchor we targeted. Strict id equality then misreports a good
324
+ * click as `click-missed` (issue #9 #4). Accepting the target itself OR any of its
325
+ * descendants via `Node.contains` fixes that without weakening the overlay guard:
326
+ * a genuine overlay is neither the target nor its child, so it still fails.
327
+ * Best-effort: any resolution hiccup returns false and the caller keeps the strict result.
328
+ */
329
+ async function nodeContains(targetBackendId, hitBackendId) {
330
+ if (!Number.isFinite(hitBackendId) || hitBackendId <= 0) return false
331
+ if (hitBackendId === targetBackendId) return true
332
+ try {
333
+ const pushed = await call('DOM.pushNodesByBackendIdsToFrontend', { backendNodeIds: [targetBackendId, hitBackendId] })
334
+ const [targetNodeId, hitNodeId] = pushed?.nodeIds ?? []
335
+ if (!targetNodeId || !hitNodeId) return false
336
+ const tObj = (await call('DOM.resolveNode', { nodeId: targetNodeId }))?.object?.objectId
337
+ const hObj = (await call('DOM.resolveNode', { nodeId: hitNodeId }))?.object?.objectId
338
+ if (!tObj || !hObj) return false
339
+ const fn = await call('Runtime.callFunctionOn', {
340
+ objectId: tObj,
341
+ functionDeclaration: 'function(h){ return this === h || this.contains(h) }',
342
+ arguments: [{ objectId: hObj }],
343
+ returnByValue: true,
344
+ })
345
+ return fn?.result?.value === true
346
+ } catch {
347
+ return false
348
+ }
349
+ }
350
+
319
351
  async function actOnCandidate(params) {
320
352
  const backendNodeId = Number(params.backendNodeId)
321
353
  const action = String(params.action || 'click')
@@ -382,7 +414,7 @@ async function actOnCandidate(params) {
382
414
  const hit = await call('DOM.getNodeForLocation', {
383
415
  x: Math.round(measured.centre.x), y: Math.round(measured.centre.y), includeUserAgentShadowDOM: false,
384
416
  })
385
- if (Number(hit?.backendNodeId) !== backendNodeId) {
417
+ if (Number(hit?.backendNodeId) !== backendNodeId && !(await nodeContains(backendNodeId, Number(hit?.backendNodeId)))) {
386
418
  const at = Math.round(measured.centre.x) + ',' + Math.round(measured.centre.y)
387
419
  return {
388
420
  ok: false,
@@ -392,6 +424,12 @@ async function actOnCandidate(params) {
392
424
  }
393
425
  }
394
426
 
427
+ // Remember where we were so a navigation can be told apart from a re-layout
428
+ // (issue #9 #5): a link that navigates makes the point resolve to a different
429
+ // node afterwards, which the old post-check reported as a failed click even
430
+ // though the navigation succeeded and the caller then clicked twice.
431
+ const beforeHref = (await call('Runtime.evaluate', { expression: 'location.href', returnByValue: true }))?.result?.value
432
+
395
433
  for (const type of ['mouseMoved', 'mousePressed', 'mouseReleased']) {
396
434
  await call('Input.dispatchMouseEvent', {
397
435
  type,
@@ -407,7 +445,15 @@ async function actOnCandidate(params) {
407
445
  const after = await call('DOM.getNodeForLocation', {
408
446
  x: Math.round(measured.centre.x), y: Math.round(measured.centre.y), includeUserAgentShadowDOM: false,
409
447
  })
410
- if (Number(after?.backendNodeId) !== backendNodeId) {
448
+ if (Number(after?.backendNodeId) !== backendNodeId && !(await nodeContains(backendNodeId, Number(after?.backendNodeId)))) {
449
+ // The node changed. If the URL changed too, the click navigated — that is a
450
+ // success, not a miss. Only report click-missed when neither the node family
451
+ // nor the URL accounts for the change.
452
+ const afterHref = (await call('Runtime.evaluate', { expression: 'location.href', returnByValue: true }))?.result?.value
453
+ if (typeof afterHref === 'string' && typeof beforeHref === 'string' && afterHref !== beforeHref) {
454
+ const navRecorded = await recordElement(backendNodeId)
455
+ return { ok: true, code: 'ok', action: 'click', navigated: true, backendNodeId, point: measured.centre, measured: measured.rect, drift: measured.drift, ...(navRecorded === null ? {} : { recorded: navRecorded }) }
456
+ }
411
457
  return { ok: false, code: 'click-missed', message: 'the click dispatched but the point now resolves to a different node' }
412
458
  }
413
459
  const recorded = await recordElement(backendNodeId)
@@ -664,8 +710,15 @@ rl.on('line', (line) => {
664
710
  })
665
711
  })
666
712
  rl.on('close', () => {
667
- if (state.ws) { try { state.ws.close() } catch { /* already gone */ } }
668
- process.exit(0)
713
+ // Do NOT exit while a request is still in flight. stdin EOF arrives before the
714
+ // async `chain` finishes, and a hard process.exit() here truncates the not-yet-
715
+ // flushed stdout replies (issue #9 #2: "the worker returned no reply for capture").
716
+ // Drain the chain, close the socket, then let the event loop end naturally so
717
+ // stdout flushes; a truly stuck chain is bounded by the host's graceMs kill.
718
+ chain.finally(() => {
719
+ if (state.ws) { try { state.ws.close() } catch { /* already gone */ } }
720
+ process.exitCode = 0
721
+ })
669
722
  })
670
723
 
671
724
  log(`ready (pid ${process.pid}, node ${process.version})`)
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.7.11",
5
+ "version": "1.9.6",
6
6
  "manifestVersion": "0.15",
7
7
  "facets": {
8
8
  "host": {
@@ -203,4 +203,4 @@
203
203
  "dsh-tui"
204
204
  ]
205
205
  }
206
- }
206
+ }