@shgroup/dsh-serenity-hooks 1.130.1 → 1.130.3

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/dsh.plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-serenity-hooks",
3
- "version": "1.130.1",
3
+ "version": "1.130.3",
4
4
  "main": "lib/index.js",
5
5
  "description": "宁静号 ACC harness(Native Cordis 插件):给 DSH 装一个「AI 工作区」——14 个工具(container_fs/cognitive_trajectory/dashboard/container_git/msm/praxis/ontology/serenity-skill-creator/localstore/container_admin/browser_slot;另三个 im-bridge/diagram/reconstruct 按条件出现)+ 机械约束(安全模式/工作区围墙/密钥守卫)+ 认知轨迹日志与原地重建 + 网页登录入口/IM 桥/认知轨迹唤醒注册表 + 浏览器槽位管理(≤20 个独立 profile 的 Chrome 槽位,带占用归属与异常时向所属会话反向注入提醒)。轨迹声明 = 轨迹目录下的 trajectory.json(约束面 + 旧标识 uid + CRO 机器绑定 cro.host;旧名 trajectory-constraint.json / skiff.json 仍在读取族里);轨迹提示词 = 轨迹目录下的 PROMPT.md(一条轨迹「是谁、按什么章程工作」,所有轨迹通用,追加在容器层与质量层之后,不替换它们)。适配 DSH 0.1.7-rc.1 / 0.2.0-rc.1 / 0.2.1-rc.1(三档,deepseek-ai/deepseek-harness)。",
6
6
  "engines": {
@@ -134,7 +134,10 @@ export declare function insertText(slot: number, targetId: string, text: string)
134
134
  * 前者会触发懒加载/无限滚动/吸顶 header 的监听;后者只移动视口 ⇒ 页面上的虚拟列表**不加载新行**,
135
135
  * 而读数看起来「滚动成功」(scrollY 变了)。
136
136
  */
137
- export declare function scrollAt(slot: number, targetId: string, x: number, y: number, deltaX: number, deltaY: number): Promise<void>;
137
+ export declare function scrollAt(slot: number, targetId: string, x: number, y: number, deltaX: number, deltaY: number): Promise<{
138
+ via: 'wheel' | 'js-fallback';
139
+ why?: string;
140
+ }>;
138
141
  /**
139
142
  * 拖拽(`mousePressed` → 多次 `mouseMoved` → `mouseReleased`)。
140
143
  *
@@ -239,6 +239,8 @@ export declare function slotScroll(root: string, slot: number, sessionId: string
239
239
  deltaY?: number;
240
240
  }): Promise<{
241
241
  scrolledY: number;
242
+ via: 'wheel' | 'js-fallback';
243
+ why?: string;
242
244
  }>;
243
245
  /** 等待条件成立(条件由 `wait-spec.ts` 解析) */
244
246
  export declare function slotWait(root: string, slot: number, sessionId: string, targetId: string, raw: string, timeoutMs: number): Promise<{
package/lib/index.js CHANGED
@@ -20374,16 +20374,52 @@ async function insertText(slot, targetId, text) {
20374
20374
  * 而读数看起来「滚动成功」(scrollY 变了)。
20375
20375
  */
20376
20376
  async function scrollAt(slot, targetId, x, y, deltaX, deltaY) {
20377
- await withPage(slot, targetId, async (send) => {
20378
- await send("Input.dispatchMouseEvent", {
20379
- type: "mouseWheel",
20380
- x,
20381
- y,
20382
- deltaX,
20383
- deltaY,
20384
- pointerType: "mouse"
20377
+ /**
20378
+ * 🔴🔴 **真机实测(2026-11-11):Wayland headed Chrome 上 `mouseWheel` 会永久挂住。**
20379
+ *
20380
+ * 同一台机器、同一个 Chrome 版本,对照实验三档:
20381
+ * · `mouseMoved/mousePressed/mouseReleased` ⇒ **立刻返回**
20382
+ * · `Input.dispatchMouseEvent{type:'mouseWheel'}` ⇒ **30s 超时**
20383
+ * · `Input.synthesizeScrollGesture` ⇒ **同样超时**
20384
+ * 而**另起一个 `--headless=new` 实例**发同一个 wheel ⇒ **立刻返回**。
20385
+ * ⇒ 根因在「headed + Wayland」这一档:窗口被节流/遮挡时合成器不确认输入,
20386
+ * 而 CDP 的 wheel 是**等确认**的(不像 mouseMoved 那样 fire-and-forget)。
20387
+ * ⚠️ 我们**刻意**没有加 `--disable-renderer-backgrounding` 那组 flag(2026-11-09 耗电事故的教训),
20388
+ * 所以这个节流是预期行为 ⇒ 不该为了让 wheel 好用去关它。
20389
+ *
20390
+ * ⇒ 判据:**一种能力在有副作用的动作上不能"挂住"**。等 30s 再失败,等于把一个
20391
+ * 「滚不动」变成「卡死 30 秒」,而调用方无从区分。
20392
+ * ⇒ wheel 给**短超时**,超时后回落 JS 滚动,**并在回执里写明走的是哪条路**。
20393
+ * 🔴 回落不是等价物:JS 滚动**不产生 wheel 事件**,只靠 wheel 的懒加载不会触发。
20394
+ * 所以它必须**可见**(`via: 'js-fallback'`),⛔ 不静默替代。
20395
+ */
20396
+ const wheel = {
20397
+ type: "mouseWheel",
20398
+ x,
20399
+ y,
20400
+ deltaX,
20401
+ deltaY,
20402
+ pointerType: "mouse"
20403
+ };
20404
+ try {
20405
+ await withPage(slot, targetId, async (send) => {
20406
+ await send("Input.dispatchMouseEvent", wheel, 4e3);
20385
20407
  });
20386
- });
20408
+ return { via: "wheel" };
20409
+ } catch (e) {
20410
+ const msg = String(e?.message ?? e);
20411
+ if (!/超时|timeout/i.test(msg)) throw e;
20412
+ await withPage(slot, targetId, async (send) => {
20413
+ await send("Runtime.evaluate", {
20414
+ expression: `window.scrollBy(${Math.round(deltaX)}, ${Math.round(deltaY)})`,
20415
+ returnByValue: true
20416
+ }, 8e3);
20417
+ });
20418
+ return {
20419
+ via: "js-fallback",
20420
+ why: "mouseWheel 在本机 headed/Wayland 档会挂住(见 scrollAt 判据),已回落 JS 滚动"
20421
+ };
20422
+ }
20387
20423
  }
20388
20424
  /**
20389
20425
  * 拖拽(`mousePressed` → 多次 `mouseMoved` → `mouseReleased`)。
@@ -20668,42 +20704,49 @@ function listDownloaded(absDir) {
20668
20704
  * 而对话框正文由页面控制(可以写任何话)。要接受必须由调用方显式要求。
20669
20705
  */
20670
20706
  async function handleDialog(slot, targetId, accept, promptText) {
20671
- let seen = {
20672
- hadDialog: false,
20673
- type: "",
20674
- message: ""
20675
- };
20676
- await withPage(slot, targetId, async (send) => {
20677
- await send("Page.enable");
20678
- try {
20679
- await send("Page.handleJavaScriptDialog", {
20680
- accept,
20681
- ...promptText !== void 0 ? { promptText } : {}
20682
- });
20683
- seen = {
20684
- hadDialog: true,
20685
- type: "",
20686
- message: ""
20687
- };
20688
- } catch (e) {
20689
- const msg = String(e?.message ?? e);
20690
- if (/no dialog|No dialog is showing/i.test(msg)) return;
20691
- throw e;
20692
- }
20693
- }, {
20694
- events: ["Page.javascriptDialogOpening"],
20695
- onEvent: (_m, p) => {
20696
- seen = {
20697
- hadDialog: true,
20698
- type: String(p.type ?? ""),
20699
- message: String(p.message ?? "")
20700
- };
20701
- }
20702
- });
20703
- return {
20704
- ...seen,
20705
- accepted: seen.hadDialog ? accept : false
20706
- };
20707
+ /**
20708
+ * 🔴🔴 **真机实测(2026-11-11):先 `Page.enable` 再处理弹窗,会把整页卡死。**
20709
+ *
20710
+ * 现象:`click` 一个会 `confirm()` 的按钮 ⇒ 点击请求 30s 超时(页面同步阻塞,这是**预期的**);
20711
+ * 接着调 `dialog` 去处理它 ⇒ **`Page.enable` 自己超时 30s**,弹窗一直挂着,页面永久卡死。
20712
+ *
20713
+ * 对照实验(裸 WS 直连,同一个卡死的页面):
20714
+ * · `Page.handleJavaScriptDialog{accept:false}` **不 enable 直接发** ⇒ 立刻返回 `No dialog is showing`
20715
+ * (说明这条路**通**,只是此刻那条 confirm 已被上一次尝试里的某个环节关掉了)
20716
+ * · `Page.enable` ⇒ 在弹窗阻塞的页面上**挂住**
20717
+ *
20718
+ * ⇒ 判据:**在「页面已阻塞」这个状态下,任何需要页面响应的方法都不能排在前面**。
20719
+ * `Page.enable` 要往渲染器要一次响应,而渲染器正停在 `confirm()` 那一行上。
20720
+ * ⇒ **先直接发 `handleJavaScriptDialog`**(它由浏览器进程处理,不经过被阻塞的渲染器),
20721
+ * 成功/失败都能立刻知道;`Page.enable` 只在需要**事件面**(拿弹窗类型与正文)时**事后**补。
20722
+ *
20723
+ * ⚠️ 代价如实登记:不 enable 就拿不到 `Page.javascriptDialogOpening` 的 type/message,
20724
+ * 所以本函数报的 `type`/`message` 多为空。**这不是缺陷** —— 判据是「先把页面救回来」,
20725
+ * 而类型/正文属于附加信息(要它就得在弹窗出现**之前** enable,那是调用方的编排问题)。
20726
+ */
20727
+ const send = async (method, params, timeoutMs) => await withPage(slot, targetId, async (s) => await s(method, params, timeoutMs));
20728
+ try {
20729
+ await send("Page.handleJavaScriptDialog", {
20730
+ accept,
20731
+ ...promptText !== void 0 ? { promptText } : {}
20732
+ }, 8e3);
20733
+ return {
20734
+ hadDialog: true,
20735
+ type: "",
20736
+ message: "",
20737
+ accepted: accept
20738
+ };
20739
+ } catch (e) {
20740
+ const msg = String(e?.message ?? e);
20741
+ if (/no dialog|No dialog is showing/i.test(msg)) return {
20742
+ hadDialog: false,
20743
+ type: "",
20744
+ message: "",
20745
+ accepted: false
20746
+ };
20747
+ if (/超时|timeout/i.test(msg)) throw new Error("⛔ 处理弹窗超时:连 handleJavaScriptDialog 都没能在 8s 内返回。\n ⇒ 这个 target 已经不响应了(多半是被 sync alert/confirm 卡住且浏览器进程也没接住)。\n ⇒ 出路:close 掉这个 tab 重来(页面状态已不可信)—— ⛔ 不要反复重试同一个 target。");
20748
+ throw e;
20749
+ }
20707
20750
  }
20708
20751
  /**
20709
20752
  * 在页面里等一个条件成立(`wait` 动作)。
@@ -22163,13 +22206,15 @@ async function slotScroll(root, slot, sessionId, targetId, opts) {
22163
22206
  };
22164
22207
  }
22165
22208
  const before = Number(await evalInPage(slot, targetId, "String(window.scrollY || 0)"));
22166
- if (opts.to === "top") await scrollAt(slot, targetId, at.x, at.y, 0, -1e5);
22167
- else if (opts.to === "bottom") await scrollAt(slot, targetId, at.x, at.y, 0, 1e5);
22168
- else await scrollAt(slot, targetId, at.x, at.y, 0, opts.deltaY ?? 600);
22209
+ const r = opts.to === "top" ? await scrollAt(slot, targetId, at.x, at.y, 0, -1e5) : opts.to === "bottom" ? await scrollAt(slot, targetId, at.x, at.y, 0, 1e5) : await scrollAt(slot, targetId, at.x, at.y, 0, opts.deltaY ?? 600);
22169
22210
  await new Promise((r) => setTimeout(r, 250));
22170
22211
  const after = Number(await evalInPage(slot, targetId, "String(window.scrollY || 0)"));
22171
22212
  pageTouched(root, slot);
22172
- return { scrolledY: Number.isFinite(after - before) ? after - before : 0 };
22213
+ return {
22214
+ scrolledY: Number.isFinite(after - before) ? after - before : 0,
22215
+ via: r.via,
22216
+ ...r.why ? { why: r.why } : {}
22217
+ };
22173
22218
  }
22174
22219
  /** 等待条件成立(条件由 `wait-spec.ts` 解析) */
22175
22220
  async function slotWait(root, slot, sessionId, targetId, raw, timeoutMs) {
@@ -22543,13 +22588,14 @@ async function run(ctx, root, sessionId, trajectory, action, args) {
22543
22588
  const toRaw = str(args.to);
22544
22589
  const to = toRaw === "top" || toRaw === "bottom" ? toRaw : void 0;
22545
22590
  if (!refStr && !xy && !to) return "⛔ 需要 --ref=<eNNN> / --xy=<x,y> / --to=<top|bottom> 之一";
22546
- const { scrolledY } = await slotScroll(root, n, sessionId, target, {
22591
+ const { scrolledY, via, why } = await slotScroll(root, n, sessionId, target, {
22547
22592
  ref: refStr ? needBackendId(args) : void 0,
22548
22593
  xy,
22549
22594
  to,
22550
22595
  deltaY: num(args.delta)
22551
22596
  });
22552
- return `[browser_slot] scroll → scrollY 变化 ${scrolledY > 0 ? "+" : ""}${scrolledY}px`;
22597
+ const viaLine = via === "wheel" ? "(真实 wheel 事件)" : `(⚠️ 回落 JS 滚动 —— ${why ?? ""};本次**没有产生 wheel 事件**,靠 wheel 触发的懒加载不会启动)`;
22598
+ return `[browser_slot] scroll → scrollY 变化 ${scrolledY > 0 ? "+" : ""}${scrolledY}px ${viaLine}`;
22553
22599
  }
22554
22600
  case "wait": {
22555
22601
  const n = needSlot(args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shgroup/dsh-serenity-hooks",
3
- "version": "1.130.1",
3
+ "version": "1.130.3",
4
4
  "description": "宁静号 ACC harness(Native Cordis 插件)——给 DeepSeek Harness 装一个「AI 工作区」:14 个工具(container_fs/cognitive_trajectory/dashboard/container_git/msm/praxis/ontology/serenity-skill-creator/localstore/container_admin/browser_slot;另三个 im-bridge/diagram/reconstruct 按条件出现)+ 机械约束(安全模式/工作区围墙/密钥守卫/对外输出守卫)+ 认知轨迹日志与原地重建 + 网页登录入口/IM 桥/认知轨迹唤醒注册表 + 浏览器槽位管理(≤20 个独立 profile 的 Chrome 槽位,带占用归属与异常时向所属会话反向注入提醒)。轨迹声明 = 轨迹目录下的 trajectory.json(约束面 + 旧标识 uid + CRO 机器绑定 cro.host;旧名 trajectory-constraint.json / skiff.json 仍在读取族里);轨迹提示词 = 轨迹目录下的 PROMPT.md(一条轨迹「是谁、按什么章程工作」,所有轨迹通用,追加在容器层与质量层之后,不替换它们)。适配 DSH 0.1.7-rc.1 / 0.2.0-rc.1 / 0.2.1-rc.1(三档)。",
5
5
  "license": "MIT",
6
6
  "repository": {