@shgroup/dsh-serenity-hooks 1.131.0 → 1.132.0

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.131.0",
3
+ "version": "1.132.0",
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": {
@@ -0,0 +1,36 @@
1
+ /**
2
+ * browser/coords.ts — 坐标参数的**纯解析**(`x,y` 字符串 / `[x,y]` 数组 / `{x,y}` 对象)。
3
+ *
4
+ * 🔴🔴 **为什么必须三种形态都收**(2026-11-13 真机事故,owner 截图):
5
+ * 坐标原本**只声明成 string**,于是模型想传两个数字时写出了「裸两个值」:
6
+ * {"xy": 1428,76} ← 坏 JSON
7
+ * 宿主在**参数 JSON 解析阶段**就拒了(`MALFORMED_RESPONSE`)⇒ **我们的工具一次都没执行**。
8
+ * 表现是「本轮运行失败」,而根因**不在点击逻辑里** —— 是 schema 把一个自然的写法挤了出去。
9
+ *
10
+ * ⇒ 判据:**schema 的形状会改变调用方的写法**。只收 string 等于强迫模型把两个数字
11
+ * 序列化进一个字符串,而「数字就是数字」是它更自然的表达。三种都收,坏写法就失去动机。
12
+ *
13
+ * ⚠️ 但**收得宽 ≠ 判得松**:形态放宽了,「解析成功」的门槛一条没降 ——
14
+ * 非有限数、负数、多于/少于两个分量,一律返回 null(调用方据此拒绝并列出正确形态)。
15
+ */
16
+ /** 一个视口坐标 */
17
+ export interface XY {
18
+ x: number;
19
+ y: number;
20
+ }
21
+ /** 坐标的三种合法入参形态(schema 与解析器必须**同时**支持这三者) */
22
+ export type XYInput = string | readonly unknown[] | {
23
+ x?: unknown;
24
+ y?: unknown;
25
+ } | null | undefined;
26
+ /**
27
+ * 解析坐标。
28
+ *
29
+ * 判据(每条都是「宁可拒绝」):
30
+ * ① 只接受三种形态;其余(布尔、裸数字、对象缺分量)⇒ null
31
+ * ② 分量必须是**有限数**且 **≥ 0** —— 负数与 NaN 会让点击落到别处或直接被 CDP 丢弃
32
+ * ③ 字符串形态按 `,` 或空白切;**必须正好两个分量**(`"1,2,3"` 拒绝,⛔ 不取前两个)
33
+ */
34
+ export declare function parseXY(raw: XYInput): XY | undefined;
35
+ /** 拒绝时列给调用方的三种正确形态(⛔ 只列一种 —— 那等于又把口子收窄回去) */
36
+ export declare function xyFormHint(param?: string): string;
package/lib/index.js CHANGED
@@ -22382,6 +22382,52 @@ async function slotExt(root, slot, sessionId, name, args) {
22382
22382
  return res;
22383
22383
  }
22384
22384
  //#endregion
22385
+ //#region src/browser/coords.ts
22386
+ /**
22387
+ * 解析坐标。
22388
+ *
22389
+ * 判据(每条都是「宁可拒绝」):
22390
+ * ① 只接受三种形态;其余(布尔、裸数字、对象缺分量)⇒ null
22391
+ * ② 分量必须是**有限数**且 **≥ 0** —— 负数与 NaN 会让点击落到别处或直接被 CDP 丢弃
22392
+ * ③ 字符串形态按 `,` 或空白切;**必须正好两个分量**(`"1,2,3"` 拒绝,⛔ 不取前两个)
22393
+ */
22394
+ function parseXY(raw) {
22395
+ if (raw === null || raw === void 0) return void 0;
22396
+ let a;
22397
+ let b;
22398
+ if (typeof raw === "string") {
22399
+ const parts = raw.split(/[,\s]+/).filter((s) => s !== "");
22400
+ if (parts.length !== 2) return void 0;
22401
+ a = parts[0];
22402
+ b = parts[1];
22403
+ } else if (Array.isArray(raw)) {
22404
+ if (raw.length !== 2) return void 0;
22405
+ a = raw[0];
22406
+ b = raw[1];
22407
+ } else if (typeof raw === "object") {
22408
+ const o = raw;
22409
+ a = o.x;
22410
+ b = o.y;
22411
+ if (a === void 0 || b === void 0) return void 0;
22412
+ } else return;
22413
+ const x = typeof a === "number" ? a : Number(a);
22414
+ const y = typeof b === "number" ? b : Number(b);
22415
+ if (!Number.isFinite(x) || !Number.isFinite(y)) return void 0;
22416
+ if (x < 0 || y < 0) return void 0;
22417
+ return {
22418
+ x,
22419
+ y
22420
+ };
22421
+ }
22422
+ /** 拒绝时列给调用方的三种正确形态(⛔ 只列一种 —— 那等于又把口子收窄回去) */
22423
+ function xyFormHint(param = "xy") {
22424
+ return [
22425
+ ` --${param}=1428,76 (字符串:逗号分隔)`,
22426
+ ` --${param}=[1428,76] (数组:两个数字)`,
22427
+ ` --${param}={x:1428,y:76} (对象)`
22428
+ ].join("\n");
22429
+ }
22430
+ //#endregion
22385
22431
  //#region src/tools/browser-slot/index.ts
22386
22432
  /**
22387
22433
  * tools/browser-slot/index.ts — browser_slot 工具(ACC 级浏览器槽位管理器)
@@ -22457,18 +22503,6 @@ async function needTarget(root, n, sessionId, args) {
22457
22503
  match
22458
22504
  });
22459
22505
  }
22460
- /** 解析 `--xy=x,y`(也接受 `x y`)。⛔ 非有限数、负数一律当没给 —— 越界坐标会让点击落到别处。 */
22461
- function parseXY(raw) {
22462
- if (!raw) return void 0;
22463
- const parts = raw.split(/[,\s]+/).filter(Boolean);
22464
- if (parts.length !== 2) return void 0;
22465
- const x = Number(parts[0]);
22466
- const y = Number(parts[1]);
22467
- return Number.isFinite(x) && Number.isFinite(y) && x >= 0 && y >= 0 ? {
22468
- x,
22469
- y
22470
- } : void 0;
22471
- }
22472
22506
  /** 取字符串参数(空串当没给) */
22473
22507
  function str(v) {
22474
22508
  return typeof v === "string" && v !== "" ? v : void 0;
@@ -22598,8 +22632,8 @@ async function run(ctx, root, sessionId, trajectory, action, args) {
22598
22632
  const n = needSlot(args);
22599
22633
  const target = await needTarget(root, n, sessionId, args);
22600
22634
  const text = str(args.text);
22601
- const xy = parseXY(str(args.xy));
22602
- if (!text && !xy) return "⛔ 需要 --text=<按钮可见文字> 或 --xy=<x,y>(例如 --text=登录 / --xy=320,48)";
22635
+ const xy = parseXY(args.xy);
22636
+ if (!text && !xy) return `⛔ 需要 --text=<按钮可见文字> 或坐标(坐标三种写法都收):\n${xyFormHint("xy")}\n 例如:--text=登录`;
22603
22637
  const { picked, dialogs } = await slotClick(root, n, sessionId, target, {
22604
22638
  text,
22605
22639
  xy
@@ -22646,7 +22680,7 @@ async function run(ctx, root, sessionId, trajectory, action, args) {
22646
22680
  const n = needSlot(args);
22647
22681
  const target = await needTarget(root, n, sessionId, args);
22648
22682
  const refStr = str(args.ref);
22649
- const xy = parseXY(str(args.xy));
22683
+ const xy = parseXY(args.xy);
22650
22684
  const toRaw = str(args.to);
22651
22685
  const to = toRaw === "top" || toRaw === "bottom" ? toRaw : void 0;
22652
22686
  if (!refStr && !xy && !to) return "⛔ 需要 --ref=<eNNN> / --xy=<x,y> / --to=<top|bottom> 之一";
@@ -22670,11 +22704,12 @@ async function run(ctx, root, sessionId, trajectory, action, args) {
22670
22704
  case "drag": {
22671
22705
  const n = needSlot(args);
22672
22706
  const target = await needTarget(root, n, sessionId, args);
22673
- const from = parseXY(str(args.from));
22674
- const to = parseXY(str(args.to));
22675
- if (!from || !to) return "⛔ 需要 --from=<x,y> 与 --to=<x,y>(先 ax 拿 ref,再用 scroll/eval 量坐标)";
22676
- await slotDrag(root, n, sessionId, target, from, to, num(args.steps) ?? 12);
22677
- return `[browser_slot] drag ${from.x},${from.y} → ${to.x},${to.y}(分 ${num(args.steps) ?? 12} 步;⛔ 回执不说拖成功)`;
22707
+ const from = parseXY(args.from);
22708
+ const to = parseXY(args.to);
22709
+ if (!from || !to) return `⛔ 需要 --from 与 --to(坐标三种写法都收):\n${xyFormHint("from")}${xyFormHint("to")}\n 先 ax 拿 ref,再用 scroll/eval 量坐标`;
22710
+ const steps = num(args.steps) ?? 12;
22711
+ await slotDrag(root, n, sessionId, target, from, to, steps);
22712
+ return `[browser_slot] drag ${from.x},${from.y} → ${to.x},${to.y}(分 ${steps} 步;⛔ 回执不说拖成功)`;
22678
22713
  }
22679
22714
  case "upload": {
22680
22715
  const n = needSlot(args);
@@ -22787,8 +22822,35 @@ function createBrowserSlotTool(ctx) {
22787
22822
  description: "click: visible-text SUBSTRING of the element to click (matched against rendered text + value + aria-label + title). Refuses when 0 or >1 elements match, or the single hit is disabled/zero-size/pointer-events:none — never guesses, because a wrong click has already happened"
22788
22823
  },
22789
22824
  xy: {
22790
- type: "string",
22791
- description: "click: \"x,y\" viewport coordinates to click instead of --text (no hit-testing; the receipt says so). ⛔ Omit both text and xy = refused"
22825
+ oneOf: [
22826
+ {
22827
+ type: "string",
22828
+ description: "\"x,y\" (comma or space separated)"
22829
+ },
22830
+ {
22831
+ type: "array",
22832
+ items: { type: "number" },
22833
+ description: "[x, y]"
22834
+ },
22835
+ {
22836
+ type: "object",
22837
+ properties: {
22838
+ x: {
22839
+ type: "number",
22840
+ required: true,
22841
+ description: "viewport x"
22842
+ },
22843
+ y: {
22844
+ type: "number",
22845
+ required: true,
22846
+ description: "viewport y"
22847
+ }
22848
+ },
22849
+ additionalProperties: false,
22850
+ description: "{x, y}"
22851
+ }
22852
+ ],
22853
+ description: "click / scroll: viewport coordinates as \"x,y\" | [x,y] | {x,y}. ⛔ Not a slot or element id — pass `ref` for provenance"
22792
22854
  },
22793
22855
  script: {
22794
22856
  type: "string",
@@ -22823,8 +22885,33 @@ function createBrowserSlotTool(ctx) {
22823
22885
  description: "wait: REQUIRED PREFIX — selector:<css> | text:<substring> | url:<substring> | gone:<css> | js:<expr>. A bare value is refused because \"which form\" would be a guess"
22824
22886
  },
22825
22887
  from: {
22826
- type: "string",
22827
- description: "drag: \"x,y\" start point in viewport coords"
22888
+ oneOf: [
22889
+ {
22890
+ type: "string",
22891
+ description: "\"x,y\""
22892
+ },
22893
+ {
22894
+ type: "array",
22895
+ items: { type: "number" },
22896
+ description: "[x, y]"
22897
+ },
22898
+ {
22899
+ type: "object",
22900
+ properties: {
22901
+ x: {
22902
+ type: "number",
22903
+ required: true
22904
+ },
22905
+ y: {
22906
+ type: "number",
22907
+ required: true
22908
+ }
22909
+ },
22910
+ additionalProperties: false,
22911
+ description: "{x, y}"
22912
+ }
22913
+ ],
22914
+ description: "drag: start point in viewport coords (three forms, same as xy)"
22828
22915
  },
22829
22916
  steps: {
22830
22917
  type: "number",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shgroup/dsh-serenity-hooks",
3
- "version": "1.131.0",
3
+ "version": "1.132.0",
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": {