dsh-browser-cdp 1.14.4 → 1.14.5

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,17 @@
1
+ ## 1.14.5 (2026-11-22)
2
+
3
+ **scroll 行为诚实化(上游 #109 同构)+ 修复 jev 循环 scroll 全灭的潜伏缺陷。**
4
+
5
+ 反向审计上游 `omdsh-dev/dsh-ego-browser` 的 issue 历史时确认的平行面(他们 #109 → PR #110):
6
+
7
+ - **潜伏缺陷(更硬)**:worker 把 scroll 分支放在 `backendNodeId <= 0` 守卫**之后**,而 jev 循环的 act 对 scroll 发送 `backendNodeId: 0`(页面级动作无目标)——**每一条循环驱动的 scroll 都以 `no-candidate` 失败**,scroll 分支经唯一调用方是完全的死代码。reload 同为页面级动作却在守卫前(其注释明言理由),scroll 漏了同样的待遇。
8
+ - **修复一**:scroll 分支移到守卫之前,与 reload 同序。
9
+ - **修复二(报告语义)**:wheel 派发是协议层 fire-and-forget——渲染器异步生效。现在 wheel 前后各读一次 `readScroll()`(基建已有),派发后做**双稳定读轮询**(连续两次相同才停,有界 ~600ms;单次固定 settle 观测到过一次读早于生效),回包新增 `scroll: { moved, before, after }`——页面滚不动时**如实报 `moved:false` 而非谎报成功**;jev verify 兜底语义不变。契约类型:`ActOk.scroll?`(act.ts)/ `ActReply.scroll?`(effects.ts)透传。
10
+
11
+ **E2E 实测**(Chrome 158 headless):长页(3000px 可滚)→ `ok=True moved=true after={0,600}`,后续 capture 复核 `viewport.scrollY=600`;短页(无溢出)→ `ok=True moved=false`(诚实报告,不再谎报成功)。原生 CDP 分时间点取证:wheel 50ms 内生效,证明双稳定轮询覆盖。
12
+
13
+ 门禁:`npm run typecheck` 干净;`npm test` **1340 passed / 13 skipped**(+2 契约用例:scroll 先于守卫序位、wheel 前后读序 + 稳定轮询形态);worker 为直维护 .mjs 无构建面,lib 因 act.ts/effects.ts 契约字段重建。
14
+
1
15
  ## 1.14.4 (2026-11-22)
2
16
 
3
17
  **点击未映射点位按 unverified 放行(#18):`Number(undefined)` 的 NaN 比较不再把「未知」折叠成「确定 miss」。**
@@ -382,10 +382,15 @@ async function actOnCandidate(params) {
382
382
  }
383
383
  }
384
384
 
385
- if (!Number.isFinite(backendNodeId) || backendNodeId <= 0) {
386
- return { ok: false, code: 'no-candidate', message: 'act needs a positive backendNodeId' }
387
- }
388
-
385
+ // Scroll is a PAGE-level action like reload: the caller sends no candidate
386
+ // (backendNodeId 0), so it must be decided BEFORE the candidate guard —
387
+ // otherwise every loop-driven scroll dies as `no-candidate`. The wheel
388
+ // dispatch is fire-and-forget at the protocol level (the renderer applies it
389
+ // asynchronously), so the offsets are read before the dispatch and after a
390
+ // short settle, and `moved` says whether THIS event actually scrolled the
391
+ // page — a success that a page which cannot scroll still reports honestly,
392
+ // with moved:false (the same reporting fix upstream dsh-ego-browser shipped
393
+ // for ego_scroll, their issue #109).
389
394
  if (action === 'scroll') {
390
395
  const deltaY = Number(params.deltaY)
391
396
  if (!Number.isFinite(deltaY) || deltaY === 0) {
@@ -394,10 +399,35 @@ async function actOnCandidate(params) {
394
399
  // A wheel event needs a point; the viewport centre is neutral and needs no
395
400
  // measurement.
396
401
  const centre = await viewportCentre()
402
+ const before = await readScroll()
397
403
  await call('Input.dispatchMouseEvent', {
398
404
  type: 'mouseWheel', x: centre.x, y: centre.y, deltaX: 0, deltaY, button: 'none', buttons: 0, clickCount: 0,
399
405
  })
400
- return { ok: true, code: 'ok', action: 'scroll', backendNodeId: 0, point: centre, measured: null, drift: 0 }
406
+ // One fixed settle can read before the renderer applies the wheel (observed
407
+ // once as moved:false on a page that provably scrolled). Poll until the
408
+ // offset holds stable across two consecutive reads, bounded at ~600ms —
409
+ // cheap insurance for a scroll action that is rare in the loop.
410
+ let after = await readScroll()
411
+ for (let stable = 0, i = 0; i < 4 && stable < 2; i++) {
412
+ await new Promise((resolve) => setTimeout(resolve, 150))
413
+ const next = await readScroll()
414
+ stable = next.x === after.x && next.y === after.y ? stable + 1 : 0
415
+ after = next
416
+ }
417
+ return {
418
+ ok: true,
419
+ code: 'ok',
420
+ action: 'scroll',
421
+ backendNodeId: 0,
422
+ point: centre,
423
+ measured: null,
424
+ drift: 0,
425
+ scroll: { moved: before.x !== after.x || before.y !== after.y, before, after },
426
+ }
427
+ }
428
+
429
+ if (!Number.isFinite(backendNodeId) || backendNodeId <= 0) {
430
+ return { ok: false, code: 'no-candidate', message: 'act needs a positive backendNodeId' }
401
431
  }
402
432
 
403
433
  if (action === 'fill') {
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.4",
5
+ "version": "1.14.5",
6
6
  "manifestVersion": "0.15",
7
7
  "facets": {
8
8
  "host": {
package/lib/index.js CHANGED
@@ -9611,6 +9611,7 @@ function makeJudgeEffects(deps) {
9611
9611
  height: 0
9612
9612
  },
9613
9613
  drift: reply.drift ?? 0,
9614
+ ...reply.scroll === void 0 ? {} : { scroll: reply.scroll },
9614
9615
  ...reply.recorded === void 0 ? {} : { recorded: reply.recorded }
9615
9616
  };
9616
9617
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-browser-cdp",
3
- "version": "1.14.4",
3
+ "version": "1.14.5",
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",