dsh-browser-cdp 1.14.5 → 1.14.7

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/CHANGELOG.md CHANGED
@@ -1,3 +1,28 @@
1
+ ## 1.14.7 (2026-11-22)
2
+
3
+ **观察窗帧解码预换(上游 #82/#81 同构,预防性):`img.src` 直换的解码空白窗口收口。**
4
+
5
+ 反向审计确认的第三个平行面。两处实时帧 flush(浮动观察窗 + 侧栏控制器)此前直接 `img.src = dataUrl`——换帧瞬间旧位图被丢弃、新帧解码期间出现空白窗口,即上游在有头 macOS(M1/M5)实测的面板黑闪(他们以 canvas 合成修复)。我们的 flush 已有 rAF 合帧(一展示一解码,频次已降),但单次直换的空白窗口仍在。
6
+
7
+ - **修复**:两处 flush 改为先经 detached `Image` + `decode()` 预解码新帧,成功后才换 `liveImg.src`——旧画面保留到新位图就绪;`decode()` 不可用或失败时降级为原直换(不劣于从前)。解码期间新到帧保持 `pendingLiveFrame` 语义(apply 只清自己那一帧),最新帧由下一次 rAF 呈现,不丢帧。
8
+ - **诚实声明**:黑闪是视觉缺陷,本地无 DSH 宿主可自动目验——验收 = 构建 + 契约测试 + 所有者目验三段承担;修复取上游同面板架构的实证结论,归类预防性。
9
+ - **契约测试**:新增 `tests/client-render-contract.test.ts`——两处 flush 均须走 `probe.decode().then(apply, apply)`、降级路径存在、`apply` 内换帧仍在。
10
+
11
+ 门禁:`npm run typecheck` 干净;`npm test` **1343 passed / 13 skipped**(+1 契约用例);`npm run build` 后 lib/client.js 含 decode ×2。
12
+
13
+ ## 1.14.6 (2026-11-22)
14
+
15
+ **JS 弹窗可见性(上游 #104 同构):卡住的步骤从裸超时变成自带「dialog 类型 + 页面 message + 处置指引」的诊断。**
16
+
17
+ 反向审计确认的第二个平行面:worker 的消息循环忽略一切事件,`Page.javascriptDialogOpening/Closed` 从未被消费——而弹窗打开时渲染器主线程冻结,后续页面型 CDP 调用全部挂起,agent 看到的只是莫名超时(`Input.dispatchMouseEvent timed out after 15000ms`),没有任何线索指向弹窗。手动处置工具(`Page.handleJavaScriptDialog`)一直存在,缺的是「知道要去找它」。
18
+
19
+ - **修复**:worker 在事件流上跟踪弹窗生命周期(`Page.enable` 已在 attachPage 开启,事件本就在流上):`javascriptDialogOpening` → `state.dialog = { type, message, url }`,`Closed` 清空。**失败路径**:步骤错误消息追加 `(a JavaScript dialog (type "alert", message "…") is open on the page - dismiss it with Page.handleJavaScriptDialog before retrying)`。**成功路径**:capture/act/navigate/interactive 回包在弹窗打开时携带 `dialog` 字段(页面冻结状态如实呈现)。effects 侧 `CaptureReply.dialog?` / `ActReply.dialog?` 契约字段。
20
+ - **决策**:只可见性、不自动 dismiss——agent 保留知情权,自动关闭可能吞掉页面必需的 confirm 流程;手动工具是正道。
21
+ - **E2E 实测**(Chrome 158 headless):alert 按钮页点击 → `Input.dispatchMouseEvent timed out after 15000ms (a JavaScript dialog (type "alert", message "blocked!") is open on the page - dismiss it with Page.handleJavaScriptDialog before retrying)`(修复前 = 裸超时零诊断);无弹窗对照 → `ok=True` 且无 dialog 字段泄漏。
22
+ - **测试设计注记**:gather 与 act 必须同文档(跨进程重导航会使 backendNodeId 失效)——首轮 E2E 的 no-box-model 假阴性即此因。
23
+
24
+ 门禁:`npm run typecheck` 干净;`npm test` **1342 passed / 13 skipped**(+2 契约用例:弹窗生命周期跟踪、失败消息与成功回包的 dialog 面);worker 为直维护 .mjs 无构建面,lib 因 effects.ts 契约字段重建。
25
+
1
26
  ## 1.14.5 (2026-11-22)
2
27
 
3
28
  **scroll 行为诚实化(上游 #109 同构)+ 修复 jev 循环 scroll 全灭的潜伏缺陷。**
@@ -47,6 +47,8 @@ let state = {
47
47
  sessionId: '',
48
48
  targetId: '',
49
49
  targetUrl: '',
50
+ /** Open JavaScript dialog (alert/confirm/prompt), if any — see the event interceptor below. */
51
+ dialog: null,
50
52
  }
51
53
 
52
54
  function log(message) {
@@ -133,7 +135,25 @@ async function connect(wsUrl, timeoutMs) {
133
135
  ws.addEventListener('message', (event) => {
134
136
  let message
135
137
  try { message = JSON.parse(String(event.data)) } catch { return }
136
- if (typeof message.id !== 'number') return // an event, not a reply
138
+ if (typeof message.id !== 'number') {
139
+ // An EVENT, not a reply. The only family this worker cares about is the
140
+ // JavaScript dialog lifecycle: while a dialog is open the renderer's
141
+ // main thread is frozen, so every page-facing call would hang into an
142
+ // opaque timeout. Recording it here is what lets a failing step SAY
143
+ // "a dialog is open" instead of a bare timeout (upstream dsh-ego-browser
144
+ // issue #104's failure mode). Page.enable is already on (attachPage),
145
+ // so these events are already flowing.
146
+ if (message.method === 'Page.javascriptDialogOpening') {
147
+ state.dialog = {
148
+ type: String(message.params?.type || 'unknown'),
149
+ message: String(message.params?.message || ''),
150
+ url: String(message.params?.url || ''),
151
+ }
152
+ } else if (message.method === 'Page.javascriptDialogClosed') {
153
+ state.dialog = null
154
+ }
155
+ return
156
+ }
137
157
  const entry = state.pending.get(message.id)
138
158
  if (!entry) return
139
159
  clearTimeout(entry.timer)
@@ -754,9 +774,22 @@ rl.on('line', (line) => {
754
774
  const id = request.id ?? null
755
775
  try {
756
776
  const result = await handle(String(request.method || ''), request.params || {})
757
- reply(id, true, { result })
777
+ // A page-facing reply while a dialog is open carries the dialog state:
778
+ // the screenshot/script went through, but the page is frozen behind it.
779
+ const method = String(request.method || '')
780
+ const withDialog = state.dialog && (method === 'capture' || method === 'act' || method === 'navigate' || method === 'interactive')
781
+ ? { ...result, dialog: state.dialog }
782
+ : result
783
+ reply(id, true, { result: withDialog })
758
784
  } catch (error) {
759
- reply(id, false, { error: { code: 'call-failed', message: error instanceof Error ? error.message : String(error) } })
785
+ const message = error instanceof Error ? error.message : String(error)
786
+ // The renderer is frozen behind the dialog, so a failing step is far
787
+ // more likely to BE the dialog than an ordinary timeout — say so where
788
+ // the caller can read it, instead of an opaque hang.
789
+ const dialogNote = state.dialog
790
+ ? ` (a JavaScript dialog (type "${state.dialog.type}", message "${state.dialog.message}") is open on the page - dismiss it with Page.handleJavaScriptDialog before retrying)`
791
+ : ''
792
+ reply(id, false, { error: { code: 'call-failed', message: message + dialogNote } })
760
793
  }
761
794
  })
762
795
  })
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.14.5",
5
+ "version": "1.14.7",
6
6
  "manifestVersion": "0.15",
7
7
  "facets": {
8
8
  "host": {
package/lib/client.js CHANGED
@@ -3836,10 +3836,18 @@ function mountFloatingWatch(ctx) {
3836
3836
  if (!liveFlushRaf && !disposed) liveFlushRaf = window.requestAnimationFrame(() => {
3837
3837
  liveFlushRaf = null;
3838
3838
  if (disposed || !liveImg || pendingLiveFrame == null) return;
3839
- try {
3840
- liveImg.src = pendingLiveFrame;
3841
- } catch {}
3842
- pendingLiveFrame = null;
3839
+ const frame = pendingLiveFrame;
3840
+ const apply$1 = () => {
3841
+ if (disposed || !liveImg) return;
3842
+ try {
3843
+ liveImg.src = frame;
3844
+ } catch {}
3845
+ if (pendingLiveFrame === frame) pendingLiveFrame = null;
3846
+ };
3847
+ const probe = new window.Image();
3848
+ probe.src = frame;
3849
+ if (typeof probe.decode === "function") probe.decode().then(apply$1, apply$1);
3850
+ else apply$1();
3843
3851
  });
3844
3852
  return;
3845
3853
  }
@@ -5836,10 +5844,18 @@ LivePreviewController.prototype.applyFrame = function(targetId, dataUrl, vw, vh)
5836
5844
  if (!this.liveFlushRaf && !this.disposed) this.liveFlushRaf = window.requestAnimationFrame(function() {
5837
5845
  self2.liveFlushRaf = null;
5838
5846
  if (self2.disposed || !self2.liveImg || self2.pendingLiveFrame == null) return;
5839
- try {
5840
- self2.liveImg.src = self2.pendingLiveFrame;
5841
- } catch (e) {}
5842
- self2.pendingLiveFrame = null;
5847
+ var frame = self2.pendingLiveFrame;
5848
+ var apply$1 = function() {
5849
+ if (self2.disposed || !self2.liveImg) return;
5850
+ try {
5851
+ self2.liveImg.src = frame;
5852
+ } catch (e) {}
5853
+ if (self2.pendingLiveFrame === frame) self2.pendingLiveFrame = null;
5854
+ };
5855
+ var probe = new window.Image();
5856
+ probe.src = frame;
5857
+ if (typeof probe.decode === "function") probe.decode().then(apply$1, apply$1);
5858
+ else apply$1();
5843
5859
  });
5844
5860
  return;
5845
5861
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-browser-cdp",
3
- "version": "1.14.5",
3
+ "version": "1.14.7",
4
4
  "description": "dsh-browser-cdp: visible agent browser for DSH — drives the vendored ego-compatible Chromium over CDP, and can also attach to a running Chrome/Edge/Brave or route through egolite, Tabbit and Lightpanda backends. 35 structured bcdp_* tools; only bcdp_status stays resident by default (lazy injection, −91.9% schema per turn for non-browser sessions). Realtime watch panel with direct click/scroll/IME input, element picks quoted into the composer, human-verification notices; non-CDP channels sync frames by 3s polling. Web shell: floating watch ball without dsh-better-sidebar, sidebar tab with it. Headless/TUI hosts: tools-only. [DSH 0.1.0-rc.2 ~ 0.2.2-rc.1: declarative settings via Config .volatile() fields on 0.1.7+; imperative installSection / module-level registration + describe/mutate bridge on 0.1.0 ~ 0.1.5 (experimental, pending farm). Client peers stay optional so gen-1 hosts without dsh-client-store still load; for a production install on the current line use the 0.17.x line]",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",