dsh-browser-cdp 1.14.3 → 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 +28 -0
- package/bin/cdp-render-worker.mjs +51 -8
- package/dsh-plugin.json +1 -1
- package/lib/index.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
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
|
+
|
|
15
|
+
## 1.14.4 (2026-11-22)
|
|
16
|
+
|
|
17
|
+
**点击未映射点位按 unverified 放行(#18):`Number(undefined)` 的 NaN 比较不再把「未知」折叠成「确定 miss」。**
|
|
18
|
+
|
|
19
|
+
上游 issue [#18](https://github.com/drscrewdriver/dsh-browser-cdp/issues/18)(同 #16/#17 报告者)。pre/post 两处 `getNodeForLocation` 判定用 `Number(hit?.backendNodeId) !== backendNodeId` 比较——点位解析不到节点时 `Number(undefined)` 是 NaN,`NaN !== x` 恒真,`nodeContains(target, NaN)` 又在 `Number.isFinite` 守卫处短路返回 false:**「那里没有节点」被当成「有东西挡在上面」**。pre-check 由此不派发点击;post-check 报 miss 诱发上层重试 → 重复点击(#9 #5 同款失败模式,afterHref 分支只救了导航场景)。
|
|
20
|
+
|
|
21
|
+
- **与 #17 不重复**:#17 修在 `nodeContains` 内部(push 前补 getDocument,1.14.3),NaN 路径在 `Number.isFinite` 短路处**根本走不到 push**——1.14.3 之后本 issue 依旧存在;本版修在调用侧,两者无交集。报告者建议中的双向 `nodeContains(hitId, targetId)` 未采纳:点到祖先容器算命中的语义放宽无实证场景,且弱化 overlay 防护。
|
|
22
|
+
- **修复**:两处判定引入 `hitId`/`hitMissing`(`!Number.isFinite(hitId) || hitId <= 0`)守卫——`!hitMissing && hitId !== backendNodeId && !nodeContains(...)` 才判 miss。pre-check 未映射点位放行点击(盒模型刚量到目标确实在;点空由 jev verify 兜底);post-check 放行落到 `ok:true`(点击已派发无法撤销)。hitId 有效但不匹配时 miss 分支原样保留——overlay 防护零弱化。
|
|
23
|
+
- **stub 代理 E2E 三组对照**(确定性复现:本地 CDP 代理仅把 `getNodeForLocation` 响应改写后转发):旧 worker(v1.14.3) + 空改写 → `click-missed "…backendNodeId undefined"`(issue 原文逐字);新 worker + 空改写 → `ok=True code=ok`(点击派发);新 worker + 改写为其他有效节点(424242) → 仍 `click-missed`(防护保住)。
|
|
24
|
+
- **契约测试**:worker-dispatch 套件新增用例——hitMissing/afterMissing 守卫存在、旧 NaN 比较式消失、守卫先于 nodeContains 判定。
|
|
25
|
+
- **边界**:post-check 的 afterHref 导航判定分支零改动;`navigated` 标志 src 侧无消费方,hitMissing 放行路径不造无人读的 flag。
|
|
26
|
+
|
|
27
|
+
门禁:`npm run typecheck` 干净;`npm test` **1338 passed / 13 skipped**(+1 契约用例);worker 为直维护 .mjs 无构建面,lib 未动。
|
|
28
|
+
|
|
1
29
|
## 1.14.3 (2026-11-22)
|
|
2
30
|
|
|
3
31
|
**img-in-link 点击误报收口(#17):`nodeContains` 先请求 document,祖先/后代容错从死代码变回活防护。**
|
|
@@ -382,10 +382,15 @@ async function actOnCandidate(params) {
|
|
|
382
382
|
}
|
|
383
383
|
}
|
|
384
384
|
|
|
385
|
-
|
|
386
|
-
|
|
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
|
-
|
|
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') {
|
|
@@ -422,13 +452,21 @@ async function actOnCandidate(params) {
|
|
|
422
452
|
const hit = await call('DOM.getNodeForLocation', {
|
|
423
453
|
x: Math.round(measured.centre.x), y: Math.round(measured.centre.y), includeUserAgentShadowDOM: false,
|
|
424
454
|
})
|
|
425
|
-
|
|
455
|
+
const hitId = Number(hit?.backendNodeId)
|
|
456
|
+
const hitMissing = !Number.isFinite(hitId) || hitId <= 0
|
|
457
|
+
// "No node at that point" is UNVERIFIED, not a miss (issue #18): the NaN
|
|
458
|
+
// comparison folded an unknown answer into "something is on top of it".
|
|
459
|
+
// An overlay answers with a NODE; an unmapped point (mutation race between
|
|
460
|
+
// the box model and this read, renderer-mapping limits) must not block the
|
|
461
|
+
// click the box model just measured — and in the post-check below it must
|
|
462
|
+
// not trigger a caller retry that double-clicks (issue #9 #5's failure mode).
|
|
463
|
+
if (!hitMissing && hitId !== backendNodeId && !(await nodeContains(backendNodeId, hitId))) {
|
|
426
464
|
const at = Math.round(measured.centre.x) + ',' + Math.round(measured.centre.y)
|
|
427
465
|
return {
|
|
428
466
|
ok: false,
|
|
429
467
|
code: 'click-missed',
|
|
430
468
|
message: 'candidate measured to ' + at + ' but that point resolves to backendNodeId ' +
|
|
431
|
-
String(
|
|
469
|
+
String(hitId) + ' - something is on top of it or the page moved',
|
|
432
470
|
}
|
|
433
471
|
}
|
|
434
472
|
|
|
@@ -453,7 +491,12 @@ async function actOnCandidate(params) {
|
|
|
453
491
|
const after = await call('DOM.getNodeForLocation', {
|
|
454
492
|
x: Math.round(measured.centre.x), y: Math.round(measured.centre.y), includeUserAgentShadowDOM: false,
|
|
455
493
|
})
|
|
456
|
-
|
|
494
|
+
const afterId = Number(after?.backendNodeId)
|
|
495
|
+
const afterMissing = !Number.isFinite(afterId) || afterId <= 0
|
|
496
|
+
// Same rule as the pre-check: an unmapped point is unverified (issue #18),
|
|
497
|
+
// not evidence that something is on top of the target — a miss here would
|
|
498
|
+
// make the caller retry an already-dispatched click.
|
|
499
|
+
if (!afterMissing && afterId !== backendNodeId && !(await nodeContains(backendNodeId, afterId))) {
|
|
457
500
|
// The node changed. If the URL changed too, the click navigated — that is a
|
|
458
501
|
// success, not a miss. Only report click-missed when neither the node family
|
|
459
502
|
// nor the URL accounts for the change.
|
package/dsh-plugin.json
CHANGED
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-browser-cdp",
|
|
3
|
-
"version": "1.14.
|
|
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",
|