@shgroup/dsh-serenity-hooks 1.138.3 → 1.139.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.138.3",
3
+ "version": "1.139.0",
4
4
  "main": "lib/index.js",
5
5
  "description": "宁静号 ACC harness(Native Cordis 插件):给 DSH 装一个「AI 工作区」——13 个工具(container_fs/cognitive_trajectory/dashboard/container_git/msm/praxis/ontology/serenity-skill-creator/localstore/container_admin/browser_slot;另两个 im-bridge/diagram 按条件出现)+ 机械约束(安全模式/工作区围墙/密钥守卫)+ 认知轨迹日志与原地重建 + 网页登录入口/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": {
package/lib/index.js CHANGED
@@ -6594,15 +6594,15 @@ function createCognitiveTrajectoryTool(ctx) {
6594
6594
  });
6595
6595
  return [
6596
6596
  message,
6597
- `✓ 已自动激活(此前**无绑定**):${active.dir} —— 后续工作写回该轨迹的 SESSION.md。`,
6598
- ` (判据:create 前无任何绑定 ⇒ 激活;有绑定则只建不夺,见下。)`
6597
+ `✓ Auto-activated (it had **no binding** before): ${active.dir} — subsequent work writes back to that trajectory's SESSION.md.`,
6598
+ ` (Rule: no binding before create ⇒ activate; with a binding we only create, never take over — see below.)`
6599
6599
  ].join("\n");
6600
6600
  }
6601
6601
  return [
6602
6602
  message,
6603
- `⚠ 本轨迹【未】被激活 —— 当前已绑定 ${priorBound},保绑定优先(不夺走你正在用的轨迹)。`,
6604
- ` 要激活它(并在它名下开一条会话):用 cognitive_trajectory send-now 向 ${result.dirName} 投一条消息 ——`,
6605
- ` 目标若没有活跃 dsh 会话,会自动创建一条并把「使用提示词 + 你的消息」一并注入。`
6603
+ `⚠ This trajectory was NOT activated — currently bound to ${priorBound}; the existing binding wins (we do not take over the one you are using).`,
6604
+ ` To activate it (and open a session under its name): use cognitive_trajectory send-now to send a message to ${result.dirName} —`,
6605
+ ` if the target has no live dsh session, one is created and bound, with the usage prompt and your message injected together.`
6606
6606
  ].join("\n");
6607
6607
  }
6608
6608
  case "use": {
@@ -6740,7 +6740,7 @@ function createCognitiveTrajectoryTool(ctx) {
6740
6740
  code: parseTrajectoryCode(entry.dirName),
6741
6741
  uid: cur,
6742
6742
  retired: true,
6743
- note: cur === null ? `未设定遗留 UID ⇒ 用编码指认(${parseTrajectoryCode(entry.dirName) ?? "无编码"})。UID 写入已退役;要一条可指定的标识,请用 create --id 起新轨迹。` : `遗留 UID = ${cur}(文件 ${UID_FILENAME},只读兼容)——仍可用它指认本条轨迹。⚠️ 写入已退役:新轨迹用 create --id 指定编码。`
6743
+ note: cur === null ? `No legacy UID set ⇒ identify it by code (${parseTrajectoryCode(entry.dirName) ?? "no code"}).UID writing is retired; for a handle you can name, start a new trajectory with create --id.` : `Legacy UID = ${cur} (file ${UID_FILENAME}, read-only compat) — still usable to name this trajectory.⚠️ Writing it is retired: give new trajectories a code via create --id.`
6744
6744
  };
6745
6745
  }
6746
6746
  case "send-later": {
@@ -18236,10 +18236,10 @@ function deriveSlotState(lease, proc, now, policy = DEFAULT_POLICY) {
18236
18236
  reasons: ["进程已退出"]
18237
18237
  };
18238
18238
  const idle = now - lease.lastActionAt;
18239
- if (!(lease.holdUntil > now) && idle > policy.idleMs) reasons.push(`已 ${Math.round(idle / 6e4)} 分钟无动作`);
18240
- if (now - lease.leasedAt > policy.leaseMaxMs) reasons.push(`占用已超 ${Math.round(policy.leaseMaxMs / 6e4)} 分钟上限`);
18241
- if (proc && proc.cpuPct >= policy.cpuPct) reasons.push(`CPU ${proc.cpuPct.toFixed(0)}% 超阈值`);
18242
- if (proc && proc.rssMb >= policy.rssMb) reasons.push(`内存 ${proc.rssMb.toFixed(0)}MB 超阈值`);
18239
+ if (!(lease.holdUntil > now) && idle > policy.idleMs) reasons.push(`idle ${Math.round(idle / 6e4)}m`);
18240
+ if (now - lease.leasedAt > policy.leaseMaxMs) reasons.push(`held over ${Math.round(policy.leaseMaxMs / 6e4)}m cap`);
18241
+ if (proc && proc.cpuPct >= policy.cpuPct) reasons.push(`CPU ${proc.cpuPct.toFixed(0)}% over threshold`);
18242
+ if (proc && proc.rssMb >= policy.rssMb) reasons.push(`rss ${proc.rssMb.toFixed(0)}MB over threshold`);
18243
18243
  return reasons.length > 0 ? {
18244
18244
  state: "stale",
18245
18245
  reasons
@@ -18271,10 +18271,10 @@ function shouldNudge(lease, state, now, policy) {
18271
18271
  * 而它真正该做的是 `release`。⇒ 每条文本都把**具体动作**写明。
18272
18272
  */
18273
18273
  function nudgeText(slot, state, reasons, policy) {
18274
- const head = `[浏览器槽位看守] 槽位 ${slotLabel(slot)}(端口 ${slotPort(slot)})需要你处理。`;
18275
- const rel = ` 已租用,请**用完立刻 release**:\`browser_slot release ${slotLabel(slot)}\``;
18276
- if (state === "orphaned") return `${head}\n 现象:该槽位的 Chrome 进程已经不在了。\n ⚠️ 你现在如果还在用它,接下来的操作会失败 —— 但**不会自动恢复**。\n ⇒ 要做的事:\`browser_slot release ${slotLabel(slot)}\` 交还,再 \`acquire\` 重新租一个。\n${rel}`;
18277
- return `${head}\n 现象:${reasons.length > 0 ? reasons.join(";") : "状态异常"}\n${` 判据(你越了哪条线):闲置 ${Math.round(policy.idleMs / 6e4)} 分钟 / CPU ${policy.cpuPct}% / 内存 ${policy.rssMb}MB / 占用上限 ${Math.round(policy.leaseMaxMs / 6e4)} 分钟。`}\n 为什么找你:这个槽位是**你**租的,只有你知道它还有没有用。\n ⇒ 还在用:把闲置阈值以下的动作做一次,或先 release 再重新租(会刷新计时)。\n ⇒ 不用了:若你已不再需要它,release 即可 —— 这是最省事的一步。\n${rel}`;
18274
+ const head = `[slot-watchman] slot ${slotLabel(slot)} (port ${slotPort(slot)}) needs your action.`;
18275
+ const rel = ` You hold it — **release as soon as you are done**: \`browser_slot release ${slotLabel(slot)}\``;
18276
+ if (state === "orphaned") return `${head}\n What: the Chrome process for this slot is gone.\n ⚠️ If you still need it, further calls will fail — it will NOT recover by itself.\n ⇒ Do this: \`browser_slot release ${slotLabel(slot)}\` to hand it back, then \`acquire\` a fresh slot.\n${rel}`;
18277
+ return `${head}\n What: ${reasons.length > 0 ? reasons.join("; ") : "abnormal state"}\n${` Thresholds (which line you crossed): idle ${Math.round(policy.idleMs / 6e4)}m / CPU ${policy.cpuPct}% / rss ${policy.rssMb}MB / held cap ${Math.round(policy.leaseMaxMs / 6e4)}m.`}\n Why you: **you** leased this slot; only you know whether it is still needed.\n ⇒ Still using it: perform any action below the idle threshold, or release and re-acquire (resets the timer).\n ⇒ Done with it: if you no longer need it, just release — that is the cheapest step.\n${rel}`;
18278
18278
  }
18279
18279
  /**
18280
18280
  * 🔴 **强关判定(纯函数,owner 2026-11-24 令)**。
@@ -18318,7 +18318,7 @@ function shouldForceReap(lease, proc, now, policy = DEFAULT_POLICY) {
18318
18318
  * ⛔ 不写"你的槽位异常了" —— 那是无法行动的话。
18319
18319
  */
18320
18320
  function forceReapText(slot, idleMin, nudges, policy = DEFAULT_POLICY) {
18321
- return `[浏览器槽位看守] 槽位 ${slotLabel(slot)} 已被**强制回收**(闲置 ${idleMin} 分钟,之前已提醒 ${nudges} 次)。\n · 你的浏览器已关闭。**profile 目录保留** ⇒ 登录态还在,重新 acquire 不需要重登。\n · 若这次是被误杀(例如在做长下载、等一个慢查询),下次请先保活:\n \`browser_slot hold --slot ${slotLabel(slot)} --reason "<在做什么>" --holdFor <分钟>\`\n · 要接着用:重新 \`acquire\` 即可。\n 为什么是我:闲置阈值 ${Math.round(policy.idleKillMs / 6e4)} 分钟 —— 一个真在干活的浏览器不会静默这么久。`;
18321
+ return `[slot-watchman] slot ${slotLabel(slot)} was **force-reclaimed** (idle ${idleMin}m, nudged ${nudges}x before).\n · Your browser is closed. **The profile dir is kept** ⇒ login sessions survive; re-acquire without re-login.\n · If this was a false kill (long download, slow query), hold it next time:\n \`browser_slot hold --slot ${slotLabel(slot)} --reason "<what you are doing>" --holdFor <minutes>\`\n · To continue: just \`acquire\` again.\n Why me: the idle threshold is ${Math.round(policy.idleKillMs / 6e4)}m — a browser actually doing work does not go silent that long.`;
18322
18322
  }
18323
18323
  /**
18324
18324
  * 选一个空槽。⛔ 不做"最久未用优先"这类聪明事 —— 20 个槽位装得下,选择规则越简单越可预测。
@@ -21626,7 +21626,7 @@ async function acquireSlot(input) {
21626
21626
  slot: existing.slot,
21627
21627
  state: "leased",
21628
21628
  reused: true,
21629
- detail: `你在槽位 ${slotLabel(existing.slot)}(端口 ${slotPort(existing.slot)})上已有占用,已复用。\n ⛔ 不要再租第二个 —— 一次会话占两个槽位是本次事故的形状(租了忘记退)。\n` + launched.detail
21629
+ detail: `You already hold slot ${slotLabel(existing.slot)} (port ${slotPort(existing.slot)}); reusing it.\n ⛔ Do not lease a second one — two slots per session is exactly the shape of the incident (leased and forgotten).\n` + launched.detail
21630
21630
  };
21631
21631
  }
21632
21632
  const picked = withLedger((lg) => {
@@ -21662,14 +21662,14 @@ async function acquireSlot(input) {
21662
21662
  slot: 0,
21663
21663
  state: "free",
21664
21664
  reused: false,
21665
- detail: "20 个槽位已全部占用,⛔ 拒绝再租。\n ⇒ 先看谁占着:`browser_slot list`;不用了的用 `release <槽>` 交还。\n ⚠️ 槽位满通常不是\"需求多\",而是**有人忘了 release** —— 看 idleMin 最大的那一行。"
21665
+ detail: "All 20 slots are taken, ⛔ refusing to lease another.\n ⇒ See who holds them: `browser_slot list`; hand one back with `release <slot>`.\n ⚠️ A full house is usually not \"high demand\" but **someone forgot to release** — look at the largest idleMin row."
21666
21666
  };
21667
21667
  if (picked < 0) return {
21668
21668
  ok: false,
21669
21669
  slot: -picked,
21670
21670
  state: "leased",
21671
21671
  reused: false,
21672
- detail: `槽位 ${slotLabel(-picked)} 已被占用(⛔ 不抢占)。用 \`browser_slot list\` 看占用者,或省略槽位号让系统挑。`
21672
+ detail: `Slot ${slotLabel(-picked)} is taken (⛔ not preempting). Use \`browser_slot list\` to see the owner, or omit --slot to let the system pick.`
21673
21673
  };
21674
21674
  const n = picked;
21675
21675
  const launched = ensureRunning(input.root, n, 0);
@@ -21681,7 +21681,6 @@ async function acquireSlot(input) {
21681
21681
  result: null
21682
21682
  };
21683
21683
  });
21684
- const r = SLOT_RESOLUTION(n);
21685
21684
  if (!launched.ok) {
21686
21685
  withLedger((lg) => {
21687
21686
  delete lg.leases[String(n)];
@@ -21705,7 +21704,7 @@ async function acquireSlot(input) {
21705
21704
  slot: n,
21706
21705
  state: "leased",
21707
21706
  reused: false,
21708
- detail: `已租下槽位 ${slotLabel(n)}(端口 ${slotPort(n)},${r.width}x${r.height})。\n${launched.detail}\n🔴 **用完必须交还**:\`browser_slot release ${slotLabel(n)}\`\n 忘了交还的话,看守会在它闲置超过阈值时来提醒你 —— 那时你可能已经换了话题。`
21707
+ detail: `${launched.detail}\n🔴 **You must hand it back**: \`browser_slot release ${slotLabel(n)}\`\n If you forget, the watchman will nudge you once it sits idle — by then you may have moved on.`
21709
21708
  };
21710
21709
  }
21711
21710
  /** 启动退避:连续失败按指数推迟(G9)。返回 0 = 可以尝试,>0 = 还需等待的毫秒 */
@@ -21748,18 +21747,18 @@ function ensureRunning(root, n, pidHint) {
21748
21747
  if (live.length > 0) return {
21749
21748
  ok: true,
21750
21749
  pid: live[0],
21751
- detail: `槽位 ${slotLabel(n)} 进程已在(pid ${live[0]})`
21750
+ detail: `Slot ${slotLabel(n)} already running (pid ${live[0]})`
21752
21751
  };
21753
21752
  if (pidHint > 0 && existsSync(`/proc/${pidHint}`)) return {
21754
21753
  ok: true,
21755
21754
  pid: pidHint,
21756
- detail: `槽位 ${slotLabel(n)} 进程已在(pid ${pidHint})`
21755
+ detail: `Slot ${slotLabel(n)} already running (pid ${pidHint})`
21757
21756
  };
21758
21757
  const wait = backoffWaitMs(root, n, Date.now());
21759
21758
  if (wait > 0) return {
21760
21759
  ok: false,
21761
21760
  pid: 0,
21762
- detail: `槽位 ${slotLabel(n)} 处于**启动退避**中(还需 ${Math.ceil(wait / 1e3)} 秒)。\n 🔴 起因:该槽位连续启动失败。⇒ 反复重试会白付一次完整复检(数秒),且**读数上分不出来**。\n ⇒ 先查根因:\`browser_slot doctor\` 看 pidDrift 与日志路径;或换一个槽位。`
21761
+ detail: `Slot ${slotLabel(n)} is in **launch backoff** (${Math.ceil(wait / 1e3)}s left).\n 🔴 Cause: this slot failed to start repeatedly. ⇒ Retrying pays a full re-check again (seconds) and **is indistinguishable in the readings**.\n ⇒ Find the root cause first: \`browser_slot doctor\` for pidDrift and log paths; or use another slot.`
21763
21762
  };
21764
21763
  const launched = launchSlot(n);
21765
21764
  if (!launched.ok) {
@@ -21767,7 +21766,7 @@ function ensureRunning(root, n, pidHint) {
21767
21766
  return {
21768
21767
  ok: false,
21769
21768
  pid: 0,
21770
- detail: `${launched.detail}\n ⇒ 已记一次启动失败,下次允许尝试在 ${Math.ceil(w / 1e3)} 秒后。`
21769
+ detail: `${launched.detail}\n ⇒ One launch failure recorded; next attempt allowed in ${Math.ceil(w / 1e3)}s.`
21771
21770
  };
21772
21771
  }
21773
21772
  clearLaunchFailure(root, n);
@@ -21810,12 +21809,12 @@ function releaseSlot(root, sessionId, target) {
21810
21809
  const lease = readLedger().leases[String(target)];
21811
21810
  if (!lease) return {
21812
21811
  ok: true,
21813
- detail: `槽位 ${slotLabel(target)} 本就无人占用(无需释放)。`,
21812
+ detail: `Slot ${slotLabel(target)} was already free (nothing to release).`,
21814
21813
  released: false
21815
21814
  };
21816
21815
  if (sessionId && lease.sessionId && lease.sessionId !== sessionId) return {
21817
21816
  ok: false,
21818
- detail: `槽位 ${slotLabel(target)} 不属于你(占用者:${lease.trajectory || lease.sessionId || "未知"})。\n ⛔ 不代别人释放 —— 它可能正在用。若确信它已废弃,用 \`browser_slot reap <槽>\`(看守动作,会记录原因)。`,
21817
+ detail: `Slot ${slotLabel(target)} is not yours (owner: ${lease.trajectory || lease.sessionId || "unknown"}).\n ⛔ Not releasing on someone else's behalf — they may be using it. If you are sure it is abandoned, use \`browser_slot reap <slot>\` (watchman action, records a reason).`,
21819
21818
  released: false
21820
21819
  };
21821
21820
  const destroyed = destroySlot(target, lease.pid);
@@ -21830,7 +21829,7 @@ function releaseSlot(root, sessionId, target) {
21830
21829
  sampleCache.delete(target);
21831
21830
  return {
21832
21831
  ok: true,
21833
- detail: `已释放槽位 ${slotLabel(target)}。${destroyed.detail}`,
21832
+ detail: `Released slot ${slotLabel(target)}. ${destroyed.detail}`,
21834
21833
  released: true
21835
21834
  };
21836
21835
  }
@@ -21884,7 +21883,7 @@ function reapSlot(root, target, reason) {
21884
21883
  sampleCache.delete(target);
21885
21884
  return {
21886
21885
  ok: true,
21887
- detail: `已回收槽位 ${slotLabel(target)}(原因:${reason})。${destroyed.detail}`
21886
+ detail: `Reclaimed slot ${slotLabel(target)} (reason: ${reason}). ${destroyed.detail}`
21888
21887
  };
21889
21888
  }
21890
21889
  /**
@@ -21914,7 +21913,7 @@ async function forceReapIdleSlots(root, inject, policy = policyFromEnv()) {
21914
21913
  scanned += 1;
21915
21914
  const verdict = shouldForceReap(lease, readProcFor(root, lease.slot, now, lease.pid), now, policy);
21916
21915
  if (!verdict) continue;
21917
- const res = reapSlot(root, lease.slot, `闲置 ${verdict.idleMin} 分钟(已提醒 ${verdict.nudges} 次)`);
21916
+ const res = reapSlot(root, lease.slot, `idle ${verdict.idleMin}m (nudged ${verdict.nudges}x)`);
21918
21917
  recordRecentKill(lease.slot, lease.trajectory, verdict.idleMin, verdict.nudges, res.ok);
21919
21918
  const target = lease.trajectory || lease.sessionId;
21920
21919
  let delivered = false;
@@ -21928,7 +21927,7 @@ async function forceReapIdleSlots(root, inject, policy = policyFromEnv()) {
21928
21927
  } catch (err) {
21929
21928
  deliverDetail = String(err?.message ?? err);
21930
21929
  }
21931
- } else deliverDetail = "该槽位没有归属轨迹(sessionId/trajectory 皆空)⇒ 无法告知,已在台账留痕";
21930
+ } else deliverDetail = "This slot has no owning trajectory (sessionId and trajectory both empty) ⇒ cannot notify; the kill is still recorded in the ledger";
21932
21931
  out.push({
21933
21932
  slot: lease.slot,
21934
21933
  trajectory: lease.trajectory,
@@ -21962,20 +21961,20 @@ async function forceReapIdleSlots(root, inject, policy = policyFromEnv()) {
21962
21961
  function holdSlot(root, sessionId, target, minutes, reason) {
21963
21962
  if (!Number.isFinite(minutes) || minutes <= 0) return {
21964
21963
  ok: false,
21965
- detail: `hold 需要正的分钟数(收到 ${minutes})`
21964
+ detail: `hold needs a positive number of minutes (got ${minutes})`
21966
21965
  };
21967
21966
  if (minutes > 240) return {
21968
21967
  ok: false,
21969
- detail: `hold 单次最多 240 分钟(收到 ${minutes})。\n ⛔ 不让它变成"永久豁免" —— 那等于把闲置强关架空。需要更久就到期前再续一次。`
21968
+ detail: `hold is capped at 240 minutes per call (got ${minutes}).\n ⛔ Never a permanent exemption — that would defeat idle reclaim. Renew before it expires if you need longer.`
21970
21969
  };
21971
21970
  const lease = readLedger().leases[String(target)];
21972
21971
  if (!lease) return {
21973
21972
  ok: false,
21974
- detail: `槽位 ${slotLabel(target)} 无人占用(没有可保活的租约)。`
21973
+ detail: `Slot ${slotLabel(target)} is not leased (nothing to hold).`
21975
21974
  };
21976
21975
  if (sessionId && lease.sessionId && lease.sessionId !== sessionId) return {
21977
21976
  ok: false,
21978
- detail: `槽位 ${slotLabel(target)} 不属于你,⛔ 不能替别人保活。`
21977
+ detail: `Slot ${slotLabel(target)} is not yours; ⛔ cannot hold on someone else's behalf.`
21979
21978
  };
21980
21979
  const until = Date.now() + minutes * 6e4;
21981
21980
  withLedger((lg) => {
@@ -21988,7 +21987,7 @@ function holdSlot(root, sessionId, target, minutes, reason) {
21988
21987
  });
21989
21988
  return {
21990
21989
  ok: true,
21991
- detail: `已保活槽位 ${slotLabel(target)} 至 ${new Date(until).toLocaleTimeString("zh-CN")}(${minutes} 分钟)。\n · 保活期内**不判闲置**,但仍判进程死活/CPU/内存。\n · 原因:${reason || "(未填)"}\n · 到期后若仍无动作,照常进入提醒→强关流程。`
21990
+ detail: `Held slot ${slotLabel(target)} until ${new Date(until).toLocaleTimeString("en-GB")} (${minutes} min).\n · Idle is NOT judged while held, but process liveness / CPU / rss still are.\n · Reason: ${reason || "(none given)"}\n · If still idle when it expires, the normal nudge→force-reclaim flow resumes.`
21992
21991
  };
21993
21992
  }
21994
21993
  /**
@@ -22035,7 +22034,7 @@ async function nudgeStaleSlots(root, inject, policy = policyFromEnv()) {
22035
22034
  state,
22036
22035
  trajectory: "",
22037
22036
  delivered: false,
22038
- detail: "该槽位没有归属轨迹(sessionId/trajectory 皆空)⇒ 无法注入,请人工处置"
22037
+ detail: "This slot has no owning trajectory (sessionId and trajectory both empty) ⇒ cannot inject; needs manual handling"
22039
22038
  });
22040
22039
  continue;
22041
22040
  }
@@ -22122,8 +22121,8 @@ function doctorSlots(root, policy = policyFromEnv()) {
22122
22121
  */
22123
22122
  function assertSlotOwned(root, slot, sessionId) {
22124
22123
  const lease = readLedger().leases[String(slot)];
22125
- if (!lease) throw new Error(`槽位 ${slotLabel(slot)} 当前无人占用 ⇒ 先 \`browser_slot acquire\` 租一个再用。\n ⛔ 不自动替你租:租了不还就是 2026-11-09 那次 36 小时功耗事故的形状。`);
22126
- if (sessionId === "" || lease.sessionId !== sessionId) throw new Error(`槽位 ${slotLabel(slot)} 不是你租的(占用者 ${lease.sessionId || "(无)"})⇒ 拒绝操作。\n ⇒ 自己的槽位用 \`browser_slot list\` 查;要新开一个用 \`browser_slot acquire\`。\n ⚠️ 硬拒绝是刻意的:放行会让"谁在动谁的浏览器"变成没有读数可查的事。`);
22124
+ if (!lease) throw new Error(`Slot ${slotLabel(slot)} is not leased right now ⇒ \`browser_slot acquire\` one first.\n ⛔ Not auto-leasing for you: lease-and-forget is exactly the shape of the 2026-11-09 36-hour power incident.`);
22125
+ if (sessionId === "" || lease.sessionId !== sessionId) throw new Error(`Slot ${slotLabel(slot)} is not yours (owner ${lease.sessionId || "(none)"}) ⇒ refusing the operation.\n ⇒ Find your own with \`browser_slot list\`; to open a new one use \`browser_slot acquire\`.\n ⚠️ A hard refusal is deliberate: allowing it would make "who drives whose browser" unanswerable.`);
22127
22126
  }
22128
22127
  /** 把页面上一次成功的操作推进 lastActionAt(这就是"长期不动作"判据的来源) */
22129
22128
  function pageTouched(root, slot) {
@@ -22142,14 +22141,14 @@ function pageTouched(root, slot) {
22142
22141
  * @returns 解析好的 targetId(**唯一**),或抛出可读错误(0 命中 / 多命中都把候选列全)
22143
22142
  */
22144
22143
  async function resolveTarget(root, slot, sessionId, opts) {
22145
- if (!opts.target && !opts.match) throw new Error("⛔ 需要 --target=<targetId> 或 --match=<URL 或标题子串>。\n ⇒ 先 `browser_slot targets --slot b1` 看有什么,或直接给 --match=example.com");
22144
+ if (!opts.target && !opts.match) throw new Error("⛔ needs --target=<targetId> or --match=<URL or title substring>.\n ⇒ Run `browser_slot targets --slot b1` to see what is there, or just pass --match=example.com");
22146
22145
  if (opts.target) return opts.target;
22147
22146
  const list = await slotTargets(root, slot, sessionId);
22148
22147
  const res = pickTarget(list, { match: opts.match });
22149
22148
  if (res.ok) return res.target.id;
22150
22149
  const pages = list.filter((t) => t.type === "page");
22151
- if (res.reason === "not-found") throw new Error(`⛔ 没有页面匹配「${opts.match}」(匹配 url 或 title,大小写不敏感)。\n ⇒ 当前 ${pages.length} 个页面:\n${renderHits(pages)}`);
22152
- throw new Error(`⛔ 「${opts.match}」匹配到 ${res.hits.length} 个页面 —— 拒绝替你选一个(选错会产出一张"看起来对、内容却属于别人"的图)。\n ⇒ 换个更长的子串,或用 --target=<id> 点名:\n${renderHits(res.hits)}`);
22150
+ if (res.reason === "not-found") throw new Error(`⛔ No page matches "${opts.match}" (matches url or title, case-insensitive).\n ⇒ ${pages.length} page(s) currently:\n${renderHits(pages)}`);
22151
+ throw new Error(`⛔ "${opts.match}" matched ${res.hits.length} pages — refusing to pick one for you (a wrong pick yields an image that looks right but belongs to someone else).\n ⇒ Use a longer substring, or name one with --target=<id>:\n${renderHits(res.hits)}`);
22153
22152
  }
22154
22153
  /**
22155
22154
  * 语义化点击:`--text` 子串或 `--xy` 坐标。
@@ -22162,11 +22161,11 @@ async function resolveTarget(root, slot, sessionId, opts) {
22162
22161
  */
22163
22162
  async function slotClick(root, slot, sessionId, targetId, opts) {
22164
22163
  assertSlotOwned(root, slot, sessionId);
22165
- if (!opts.text && !opts.xy) throw new Error("⛔ 需要 --text=<按钮可见文字> 或坐标(先 targets 拿 targetId)");
22164
+ if (!opts.text && !opts.xy) throw new Error("⛔ needs --text=<visible label> or coordinates (run targets first for a targetId)");
22166
22165
  if (opts.xy) {
22167
22166
  const hit = judgeHit(await hitTestAt(slot, targetId, opts.xy.x, opts.xy.y), opts.ref !== void 0 ? { backendNodeId: opts.ref } : void 0);
22168
- if (hit.kind === "offscreen" || hit.kind === "blank") throw new Error(`⛔ 不点:${renderHit(hit)}\n ⇒ 坐标 ${opts.xy.x},${opts.xy.y}。先用 \`ax\` 拿 ref(更稳)或 \`scroll\` 把目标滚进视口。`);
22169
- if (hit.kind === "blocked") throw new Error(`⛔ 不点:${renderHit(hit)}\n ⇒ 被挡住时点下去会**执行另一个元素**的处理逻辑(而回执若是"clicked"就无从发现)。\n ⇒ 出路:先用 \`ax\` 看那一层是什么(弹层/固定头/遮罩),关掉它;或改用 \`--ref\` 点名目标。`);
22167
+ if (hit.kind === "offscreen" || hit.kind === "blank") throw new Error(`⛔ Not clicking: ${renderHit(hit)}\n ⇒ coords ${opts.xy.x},${opts.xy.y}. Get a ref via \`ax\` first (more reliable), or \`scroll\` the target into the viewport.`);
22168
+ if (hit.kind === "blocked") throw new Error(`⛔ Not clicking: ${renderHit(hit)}\n ⇒ When something covers it, the click runs ANOTHER element's handler (and a receipt saying "clicked" would never reveal it).\n ⇒ Fix: use \`ax\` to see what that layer is (overlay / sticky header / mask) and close it; or name the target with \`--ref\`.`);
22170
22169
  const r = await clickAt(slot, targetId, opts.xy.x, opts.xy.y);
22171
22170
  pageTouched(root, slot);
22172
22171
  return {
@@ -22192,12 +22191,12 @@ async function slotClick(root, slot, sessionId, targetId, opts) {
22192
22191
  const res = pickClickable(list, { text: opts.text });
22193
22192
  if (!res.ok) {
22194
22193
  const visible = list.filter((e) => e.w > 0 && e.h > 0);
22195
- if (res.reason === "ambiguous") throw new Error(`⛔ 「${opts.text}」匹配到 ${res.hits.length} 个可点元素 —— 拒绝替你选(点错是已经发生的事,不会自己撤销)。\n ⇒ 换个更长的文字,或用 --xy=<x,y> 点名:\n${renderClickables(res.hits)}`);
22196
- if (res.reason === "not-clickable") throw new Error(`⛔ 「${opts.text}」找到了,但${res.why}。\n ⇒ 这不是"尽力点一下"的场合:点了没反应与没点,在读数上一样。\n${renderClickables(res.hits)}`);
22197
- throw new Error(`⛔ 页面上没有可点元素匹配「${opts.text}」(匹配渲染后的可见文本,含 value/aria-label/title)。\n ⇒ 当前 ${visible.length} 个可见可点元素:\n${renderClickables(visible)}`);
22194
+ if (res.reason === "ambiguous") throw new Error(`⛔ "${opts.text}" matched ${res.hits.length} clickable elements — refusing to pick (a wrong click has already happened and will not undo itself).\n ⇒ Use a longer label, or name it with --xy=<x,y>:\n${renderClickables(res.hits)}`);
22195
+ if (res.reason === "not-clickable") throw new Error(`⛔ "${opts.text}" was found, but ${res.why}.\n ⇒ This is not a "try clicking anyway" situation: a dead click and no click read the same.\n${renderClickables(res.hits)}`);
22196
+ throw new Error(`⛔ No clickable element on the page matches "${opts.text}" (matches rendered visible text, incl. value/aria-label/title).\n ⇒ ${visible.length} visible clickable element(s) right now:\n${renderClickables(visible)}`);
22198
22197
  }
22199
22198
  const hit = judgeHit(await hitTestAt(slot, targetId, res.el.x, res.el.y));
22200
- if (hit.kind === "offscreen" || hit.kind === "blank") throw new Error(`⛔ 不点「${opts.text}」:${renderHit(hit)}\n ⇒ 「找得到」与「点得到」是两件事:元素在 DOM 里可见、可点,不代表这一下会落在它上面。`);
22199
+ if (hit.kind === "offscreen" || hit.kind === "blank") throw new Error(`⛔ Not clicking "${opts.text}": ${renderHit(hit)}\n ⇒ "Found" and "can be clicked" are two different things: visible and clickable in the DOM does not mean this click lands on it.`);
22201
22200
  const clicked = await clickAt(slot, targetId, res.el.x, res.el.y);
22202
22201
  pageTouched(root, slot);
22203
22202
  return {
@@ -22279,9 +22278,9 @@ async function slotClose(root, slot, sessionId, targetId, all = false) {
22279
22278
  */
22280
22279
  function needBackendId(args) {
22281
22280
  const ref = typeof args.ref === "string" ? args.ref : "";
22282
- if (!ref) throw new Error("⛔ 需要 --ref=<eNNN>(先跑 `browser_slot ax` 拿 ref)。\n ⇒ ref 来自无障碍树快照;⛔ 不是 DOM 选择器,也不是 CSS 路径。");
22281
+ if (!ref) throw new Error("⛔ needs --ref=<eNNN> (run `browser_slot ax` to get a ref first).\n ⇒ A ref comes from an accessibility-tree snapshot; ⛔ it is not a DOM selector or CSS path.");
22283
22282
  const id = refToBackendId(ref);
22284
- if (id === null) throw new Error(`⛔ --ref 格式不对:${JSON.stringify(ref)}(应形如 e12345,来自 \`ax\` 的输出)。\n ⛔ 不接受 CSS 选择器/文本 —— 那需要猜,而猜错会操作到另一个元素且没有任何信号。`);
22283
+ if (id === null) throw new Error(`⛔ malformed --ref: ${JSON.stringify(ref)} (expected e12345, as printed by \`ax\`).\n ⛔ CSS selectors / text are not accepted — those need guessing, and a wrong guess drives another element with no signal.`);
22285
22284
  return id;
22286
22285
  }
22287
22286
  /** AX 快照 */
@@ -22299,7 +22298,7 @@ async function slotAx(root, slot, sessionId, targetId, limit = 200) {
22299
22298
  async function slotPress(root, slot, sessionId, targetId, keyDesc, times = 1) {
22300
22299
  assertSlotOwned(root, slot, sessionId);
22301
22300
  const stroke = parseKeyStroke(keyDesc);
22302
- if (!stroke) throw new Error(`⛔ 解析不出按键:${JSON.stringify(keyDesc)}。\n ⇒ 可用形态:Enter / Escape / Tab / ArrowUp/Down/Left/Right / Home / End / PageUp / PageDown / Space / Backspace / Delete;修饰用 + 连接(Control+A / Meta+Shift+Enter);单字符只认 a-z 0-9。\n ⇒ 要「把一段文字打进输入框」用 type(走 Input.insertText,不猜键位):--text=<原文>`);
22301
+ if (!stroke) throw new Error(`⛔ Cannot parse key: ${JSON.stringify(keyDesc)}.\n ⇒ Accepted forms: Enter / Escape / Tab / ArrowUp|Down|Left|Right / Home / End / PageUp / PageDown / Space / Backspace / Delete; join modifiers with + (Control+A / Meta+Shift+Enter); single chars limited to a-z 0-9.\n ⇒ To type free text into a field use type (goes through Input.insertText, no key guessing): --text=<text>`);
22303
22302
  const sent = await pressKey(slot, targetId, stroke, times);
22304
22303
  pageTouched(root, slot);
22305
22304
  return {
@@ -22360,7 +22359,7 @@ async function slotScroll(root, slot, sessionId, targetId, opts) {
22360
22359
  async function slotWait(root, slot, sessionId, targetId, raw, timeoutMs) {
22361
22360
  assertSlotOwned(root, slot, sessionId);
22362
22361
  const spec = parseWaitSpec(raw);
22363
- if (!spec) throw new Error(`⛔ 解析不出等待条件:${JSON.stringify(raw)}。\n ⇒ 可用形态(前缀必填,裸值有歧义会等到永不到来的条件):\n selector:<CSS> text:<子串> url:<子串> gone:<CSS> js:<表达式>`);
22362
+ if (!spec) throw new Error(`⛔ Cannot parse wait condition: ${JSON.stringify(raw)}.\n ⇒ Accepted forms (prefix required; a bare value is ambiguous and may wait for something that never comes):\n selector:<CSS> text:<substring> url:<substring> gone:<CSS> js:<expression>`);
22364
22363
  const r = await waitForInPage(slot, targetId, spec.expression, timeoutMs);
22365
22364
  pageTouched(root, slot);
22366
22365
  if (!r.ok) throw new Error(explainWaitTimeout(spec, r.waitedMs, r.last));
@@ -22388,9 +22387,9 @@ function resolveUploadPath(cccRoot, relOrAbs) {
22388
22387
  try {
22389
22388
  st = statSync(abs);
22390
22389
  } catch {
22391
- throw new Error(`⛔ 文件不存在:${relOrAbs}(解析为 ${abs})。\n ⚠️ 这条拒绝是必要的:DOM.setFileInputFiles 对不存在的路径**静默成功**,表单里会是空的,而页面上看起来与「上传中」一样。`);
22390
+ throw new Error(`⛔ File does not exist: ${relOrAbs} (resolved to ${abs}).\n ⚠️ This refusal is necessary: DOM.setFileInputFiles SILENTLY SUCCEEDS on a missing path, the form field stays empty, and the page looks exactly like "uploading".`);
22392
22391
  }
22393
- if (!st.isFile()) throw new Error(`⛔ 不是普通文件(目录/设备/符号链接):${relOrAbs}`);
22392
+ if (!st.isFile()) throw new Error(`⛔ Not a regular file (directory/device/symlink): ${relOrAbs}`);
22394
22393
  return abs;
22395
22394
  }
22396
22395
  async function slotUpload(root, slot, sessionId, targetId, backendNodeId, absPaths) {
@@ -22448,7 +22447,7 @@ async function slotExt(root, slot, sessionId, name, args) {
22448
22447
  return {
22449
22448
  ok: false,
22450
22449
  code: "ext-not-found",
22451
- error: `没有名为「${name}」的扩展。\n` + (known.length > 0 ? ` ⇒ 本 CCC 现有的扩展:${known.join(", ")}` : ` ⇒ 本 CCC 还没有任何扩展(<CCC 根>/${EXT_DIR_REL}/ 下没有 .ts 文件)。\n 写一个:stdin 收 {slot,port,cccRoot,args},stdout 最后一行给 {"ok":true,"result":…}`)
22450
+ error: `No extension named "${name}".\n` + (known.length > 0 ? ` ⇒ Extensions in this CCC: ${known.join(", ")}` : ` ⇒ This CCC has no extensions yet (no .ts files under <CCC root>/${EXT_DIR_REL}/).\n To add one: stdin gets {slot,port,cccRoot,args}; the last stdout line returns {"ok":true,"result":…}`)
22452
22451
  };
22453
22452
  }
22454
22453
  const res = await runExtension(entry, buildExtPayload({
@@ -22907,9 +22906,9 @@ function trajectoryNameFromCwd(root, cwd) {
22907
22906
  */
22908
22907
  function row(v) {
22909
22908
  const g = STATE_GLYPH[v.state] ?? "?";
22910
- const who = v.state === "free" ? "" : ` ${v.trajectory || v.sessionId || "(无归属)"}`;
22911
- const res = v.sampled ? `cpu${v.cpuPct}% 内存${v.rssMb}M` : "cpu— 内存—(本平台不采样)";
22912
- const extra = v.state === "free" ? "" : ` 持${v.heldMin}m 闲${v.idleMin}m ${res}`;
22909
+ const who = v.state === "free" ? "" : ` ${v.trajectory || v.sessionId || "(unowned)"}`;
22910
+ const res = v.sampled ? `cpu${v.cpuPct}% rss${v.rssMb}M` : "cpu— rss—(not sampled on this platform)";
22911
+ const extra = v.state === "free" ? "" : ` held${v.heldMin}m idle${v.idleMin}m ${res}`;
22913
22912
  const why = v.reasons.length > 0 ? `\n ↳ ${v.reasons.join(";")}` : "";
22914
22913
  return ` ${g} ${v.label.padEnd(3)} :${v.port} ${v.resolution.padEnd(9)} ${v.state.padEnd(8)}${who}${extra}${why}`;
22915
22914
  }
@@ -22922,7 +22921,7 @@ function row(v) {
22922
22921
  */
22923
22922
  function needSlot(args) {
22924
22923
  const n = normalizeSlotId(String(args.slot ?? ""));
22925
- if (n === 0) throw new Error(`⛔ 需要 --slot <b1..b20>(当前收到 ${JSON.stringify(args.slot)})。\n ⇒ 页面操作必须指明槽位:先 \`browser_slot list\` 看你租的是哪个。`);
22924
+ if (n === 0) throw new Error(`⛔ needs --slot <b1..b20> (got ${JSON.stringify(args.slot)}).\n ⇒ Page actions must name the slot: run \`browser_slot list\` to see which one you hold.`);
22926
22925
  return n;
22927
22926
  }
22928
22927
  /**
@@ -22934,7 +22933,7 @@ function needSlot(args) {
22934
22933
  async function needTarget(root, n, sessionId, args) {
22935
22934
  const target = str(args.target);
22936
22935
  const match = str(args.match);
22937
- if (!target && !match) throw new Error("⛔ 需要 --target=<targetId> 或 --match=<URL/标题子串>(先跑 targets 看清有什么)。\n ⇒ --match 是子串匹配,命中唯一才动手;命中多个会拒绝并列全候选。");
22936
+ if (!target && !match) throw new Error("⛔ needs --target=<targetId> or --match=<URL/title substring> (run targets first).\n ⇒ --match is a substring match: it acts only on a unique hit; multiple hits are rejected with all candidates listed.");
22938
22937
  return resolveTarget(root, n, sessionId, {
22939
22938
  target,
22940
22939
  match
@@ -22999,7 +22998,7 @@ async function run(ctx, root, sessionId, trajectory, action, args) {
22999
22998
  trajectory,
23000
22999
  want: typeof args.slot === "string" ? normalizeSlotId(args.slot) : 0
23001
23000
  });
23002
- if (!res.ok) return `⛔ 未租到槽位。\n${res.detail}`;
23001
+ if (!res.ok) return `⛔ acquire failed.\n${res.detail}`;
23003
23002
  if (args.wait === true) {
23004
23003
  const ready = await waitSlotReady(root, res.slot);
23005
23004
  return `${res.detail}\n${ready.ok ? "✓ " + ready.detail : "⚠️ " + ready.detail}`;
@@ -23008,27 +23007,27 @@ async function run(ctx, root, sessionId, trajectory, action, args) {
23008
23007
  }
23009
23008
  case "release": {
23010
23009
  const n = normalizeSlotId(String(args.slot ?? ""));
23011
- if (n === 0) return "⛔ 需要槽位号:release 需要 --slot <b1..b20>";
23010
+ if (n === 0) return "⛔ release needs --slot <b1..b20>";
23012
23011
  const r = releaseSlot(root, sessionId, n);
23013
23012
  return r.detail + (r.released && r.ok ? domainSkillPrompt(root) : "");
23014
23013
  }
23015
23014
  case "reap": {
23016
23015
  const n = normalizeSlotId(String(args.slot ?? ""));
23017
- if (n === 0) return "⛔ 需要槽位号:reap 需要 --slot <b1..b20>";
23016
+ if (n === 0) return "⛔ reap needs --slot <b1..b20>";
23018
23017
  return reapSlot(root, n, typeof args.reason === "string" && args.reason ? args.reason : "manual reaping").detail;
23019
23018
  }
23020
23019
  case "hold": {
23021
23020
  const n = normalizeSlotId(String(args.slot ?? ""));
23022
- if (n === 0) return "⛔ 需要槽位号:hold 需要 --slot <b1..b20>";
23021
+ if (n === 0) return "⛔ hold needs --slot <b1..b20>";
23023
23022
  const mins = num(args.holdFor);
23024
- if (mins === void 0) return "⛔ 需要 --holdFor=<分钟>(保活多久)。例:--holdFor 60\n ⛔ 不接受\"永久保活\" —— 那会把闲置强关架空。";
23023
+ if (mins === void 0) return "⛔ hold needs --holdFor=<minutes> (e.g. --holdFor 60). No permanent hold — that would defeat idle reclaim.";
23025
23024
  const r = holdSlot(root, sessionId, n, mins, typeof args.reason === "string" ? args.reason : "");
23026
23025
  return r.ok ? r.detail : `⛔ ${r.detail}`;
23027
23026
  }
23028
23027
  case "status": {
23029
23028
  const n = normalizeSlotId(String(args.slot ?? ""));
23030
23029
  const v = n > 0 ? slotStatus(root, n) : null;
23031
- if (!v) return `⛔ 槽位号非法(1..20)。`;
23030
+ if (!v) return `⛔ invalid slot (1..20)`;
23032
23031
  return row(v).trimStart();
23033
23032
  }
23034
23033
  case "list":
@@ -23037,24 +23036,24 @@ async function run(ctx, root, sessionId, trajectory, action, args) {
23037
23036
  const occupied = views.filter((v) => v.state !== "free");
23038
23037
  const bad = views.filter((v) => v.state === "stale" || v.state === "orphaned");
23039
23038
  const lines = [];
23040
- lines.push(`浏览器槽位 ${views.length} 个(占用 ${occupied.length},空闲 ${views.length - occupied.length},异常 ${bad.length})` + (ledgerAgeMin > 0 ? ` 台账 ${ledgerAgeMin} 分钟前更新` : ""));
23041
- lines.push(" · 空闲 ✓ 占用 ! 异常(需处理) ✗ 进程已死");
23042
- if (occupied.length === 0) lines.push(" (全部空闲)");
23039
+ lines.push(`slots ${views.length} (busy ${occupied.length}, free ${views.length - occupied.length}, bad ${bad.length})` + (ledgerAgeMin > 0 ? ` ledger ${ledgerAgeMin}m old` : ""));
23040
+ lines.push(" · free ✓ leased ! stale(act) ✗ orphaned");
23041
+ if (occupied.length === 0) lines.push(" (all free)");
23043
23042
  else for (const v of occupied) lines.push(row(v));
23044
23043
  if (bad.length > 0) {
23045
23044
  lines.push("");
23046
- lines.push("🔴 异常槽位会由看守向**占用它的会话**注入提醒;若占用者已经不在,用 reap 回收:");
23045
+ lines.push("🔴 The watchman notifies the OWNING session; if the owner is gone, reap it:");
23047
23046
  for (const v of bad) lines.push(` browser_slot reap --slot ${v.label}`);
23048
23047
  }
23049
23048
  lines.push("");
23050
- lines.push("用法:acquire(自动挑空槽,可 --slot 指定)· release(用完必须交还)· status --slot b1");
23049
+ lines.push("usage: acquire (auto-picks, or --slot) · release (always when done) · status --slot b1");
23051
23050
  const visits = Object.entries(readVisits(root).domains).sort((a, b) => b[1].opens - a[1].opens || b[1].lastAt - a[1].lastAt);
23052
23051
  if (visits.length > 0) {
23053
23052
  const missing = visits.filter(([h]) => !hasDomainSkill(root, h)).length;
23054
23053
  lines.push("");
23055
- lines.push(`域名台账 ${visits.length} 个站${missing > 0 ? `(${missing} 个还没有说明书)` : "(都有说明书)"}:`);
23056
- for (const [h, v] of visits.slice(0, 5)) lines.push(` ${hasDomainSkill(root, h) ? "✓" : "·"} ${h.padEnd(28)} ${v.opens} 次`);
23057
- if (visits.length > 5) lines.push(` ……另有 ${visits.length - 5} 个(BROWSER/_index.json)`);
23054
+ lines.push(`domains ${visits.length}${missing > 0 ? ` (${missing} without notes)` : " (all documented)"}:`);
23055
+ for (const [h, v] of visits.slice(0, 5)) lines.push(` ${hasDomainSkill(root, h) ? "✓" : "·"} ${h.padEnd(28)} ${v.opens}x`);
23056
+ if (visits.length > 5) lines.push(` …${visits.length - 5} more (BROWSER/_index.json)`);
23058
23057
  }
23059
23058
  return lines.join("\n");
23060
23059
  }
@@ -23062,13 +23061,13 @@ async function run(ctx, root, sessionId, trajectory, action, args) {
23062
23061
  case "targets": {
23063
23062
  const n = needSlot(args);
23064
23063
  const list = await slotTargets(root, n, sessionId);
23065
- if (list.length === 0) return `槽位 ${slotLabel(n)}(端口 ${slotPort(n)})上没有 target。`;
23066
- return `[browser_slot] ${list.length} 个 target(槽位 ${slotLabel(n)},端口 ${slotPort(n)})\n` + list.map((t) => ` ${t.type.padEnd(10)} ${t.id} ${t.title.slice(0, 40)} ${t.url.slice(0, 90)}`).join("\n");
23064
+ if (list.length === 0) return `no targets on ${slotLabel(n)} (port ${slotPort(n)})`;
23065
+ return `[browser_slot] ${list.length} target(s) on ${slotLabel(n)} (port ${slotPort(n)})\n` + list.map((t) => ` ${t.type.padEnd(10)} ${t.id} ${t.title.slice(0, 40)} ${t.url.slice(0, 90)}`).join("\n");
23067
23066
  }
23068
23067
  case "open": {
23069
23068
  const n = needSlot(args);
23070
23069
  const url = str(args.url);
23071
- if (!url) return "⛔ 需要 --url=<地址>";
23070
+ if (!url) return "⛔ needs --url=<address>";
23072
23071
  return `[browser_slot] targetId=${await slotOpen(root, n, sessionId, url)}` + domainSkillTail(root, url, sessionId, n);
23073
23072
  }
23074
23073
  case "goto": {
@@ -23078,9 +23077,9 @@ async function run(ctx, root, sessionId, trajectory, action, args) {
23078
23077
  const match = str(args.match);
23079
23078
  const missing = [];
23080
23079
  if (n === 0) missing.push("--slot <b1..b20>");
23081
- if (!target && !match) missing.push("--target <targetId> 或 --match <URL/标题子串>(先跑 targets 看清有什么)");
23082
- if (!url) missing.push("--url <目的地地址>");
23083
- if (missing.length > 0) return `⛔ goto 缺少 ${missing.length} 个参数,一次列全:\n` + missing.map((m) => ` · ${m}`).join("\n") + `\n ⚠️ goto 与 open 形状不同:open 只要 --slot + --url;goto 还要指出**在哪个标签页**导航。`;
23080
+ if (!target && !match) missing.push("--target <targetId> or --match <URL/title substring> (run targets first)");
23081
+ if (!url) missing.push("--url <destination>");
23082
+ if (missing.length > 0) return `⛔ goto missing ${missing.length} arg(s), all listed at once:\n` + missing.map((m) => ` · ${m}`).join("\n") + `\n ⚠️ goto differs from open: open needs only --slot + --url; goto also needs WHICH tab to navigate.`;
23084
23083
  const slotN = n;
23085
23084
  const destUrl = url;
23086
23085
  const tgt = target ?? await needTarget(root, slotN, sessionId, args);
@@ -23091,7 +23090,7 @@ async function run(ctx, root, sessionId, trajectory, action, args) {
23091
23090
  const n = needSlot(args);
23092
23091
  const js = str(args.js);
23093
23092
  const target = await needTarget(root, n, sessionId, args);
23094
- if (!js) return "⛔ 需要 --js=<表达式>(例如 document.title)";
23093
+ if (!js) return "⛔ needs --js=<expression> (e.g. document.title)";
23095
23094
  const v = await slotEval(root, n, sessionId, target, js, num(args.timeout));
23096
23095
  return typeof v === "string" ? v : JSON.stringify(v, null, 2);
23097
23096
  }
@@ -23110,59 +23109,59 @@ async function run(ctx, root, sessionId, trajectory, action, args) {
23110
23109
  }
23111
23110
  case "reload": {
23112
23111
  const n = needSlot(args);
23113
- return `[browser_slot] reload 完成(readyState=${await slotReload(root, n, sessionId, await needTarget(root, n, sessionId, args), str(args.script)) || "?"})`;
23112
+ return `[browser_slot] reload done (readyState=${await slotReload(root, n, sessionId, await needTarget(root, n, sessionId, args), str(args.script)) || "?"})`;
23114
23113
  }
23115
23114
  case "click": {
23116
23115
  const n = needSlot(args);
23117
23116
  const target = await needTarget(root, n, sessionId, args);
23118
23117
  const text = str(args.text);
23119
23118
  const xy = parseXY(args.xy);
23120
- if (!text && !xy) return `⛔ 需要 --text=<按钮可见文字> 或坐标(坐标三种写法都收):\n${xyFormHint("xy")}\n 例如:--text=登录`;
23119
+ if (!text && !xy) return `⛔ needs --text=<visible label> or coordinates (all three forms accepted):\n${xyFormHint("xy")}\n e.g. --text=Sign in`;
23121
23120
  const refRaw = str(args.ref);
23122
23121
  const refId = refRaw === void 0 ? void 0 : refToBackendId(refRaw) ?? void 0;
23123
- if (refRaw !== void 0 && refId === void 0) return `⛔ --ref 格式不对:${JSON.stringify(refRaw)}(要 \`ax\` 给出的 eNNN)`;
23122
+ if (refRaw !== void 0 && refId === void 0) return `⛔ malformed --ref: ${JSON.stringify(refRaw)} (want eNNN from \`ax\`)`;
23124
23123
  const { picked, dialogs, hit } = await slotClick(root, n, sessionId, target, {
23125
23124
  text,
23126
23125
  xy,
23127
23126
  ref: refId
23128
23127
  });
23129
- const base = `[browser_slot] clicked ${xy ? `@${xy.x},${xy.y}` : `<${picked.tag}> "${picked.text.slice(0, 60)}" @${picked.x},${picked.y}`}|命中:${renderHit(hit)}`;
23128
+ const base = `[browser_slot] clicked ${xy ? `@${xy.x},${xy.y}` : `<${picked.tag}> "${picked.text.slice(0, 60)}" @${picked.x},${picked.y}`}|hit: ${renderHit(hit)}`;
23130
23129
  if (dialogs.length === 0) return base;
23131
- return `${base}\n${dialogs.map((d) => ` ⚠️ 自动处理弹窗 ${d.type || "(未知类型)"}:${JSON.stringify(d.message.slice(0, 100))} ⇒ ${d.accepted ? "已确定" : "已取消"}`).join("\n")}\n (默认取消;要「确定」请单独用 dialog --accept —— OK 常意味着删除/支付/发布)`;
23130
+ return `${base}\n${dialogs.map((d) => ` ⚠️ auto-handled dialog ${d.type || "(unknown)"}: ${JSON.stringify(d.message.slice(0, 100))} ⇒ ${d.accepted ? "accepted" : "dismissed"}`).join("\n")}\n (default = dismiss; use dialog --accept to confirm — OK often means delete/pay/publish)`;
23132
23131
  }
23133
23132
  case "ax": {
23134
23133
  const n = needSlot(args);
23135
23134
  const target = await needTarget(root, n, sessionId, args);
23136
23135
  const { lines, total } = await slotAx(root, n, sessionId, target, num(args.limit) ?? 200);
23137
- if (lines.length === 0) return `[browser_slot] ax —— 无障碍树里没有可交互元素(target=${target})。\n ⇒ 可能页面还没渲染完(先 wait 一下),或这个页面真的只有静态文本(用 text 读)。`;
23138
- return `[browser_slot] ax —— ${lines.length} 个可交互元素(共 ${total} 个,ref 跨快照稳定)\n${renderAx(lines, total)}`;
23136
+ if (lines.length === 0) return `[browser_slot] ax — no interactive elements in the a11y tree (target=${target}).\n ⇒ maybe not rendered yet (wait first), or the page is genuinely static text (use text).`;
23137
+ return `[browser_slot] ax — ${lines.length} interactive element(s) (of ${total}; ref stays stable across snapshots)\n${renderAx(lines, total)}`;
23139
23138
  }
23140
23139
  case "press": {
23141
23140
  const n = needSlot(args);
23142
23141
  const target = await needTarget(root, n, sessionId, args);
23143
23142
  const k = str(args.key);
23144
- if (!k) return "⛔ 需要 --key=<按键>(例如 Enter / Escape / Control+A / Meta+Shift+Enter)";
23143
+ if (!k) return "⛔ needs --key=<key> (e.g. Enter / Escape / Control+A / Meta+Shift+Enter)";
23145
23144
  const { stroke, sent } = await slotPress(root, n, sessionId, target, k, num(args.times) ?? 1);
23146
- return `[browser_slot] press ${stroke.key}(code=${stroke.code},modifiers=${stroke.modifiers})× ${sent}\n ⚠️ 回执只说「发了几个按键」,⛔ 不说「界面响应了」 —— 效果请用 ax / eval 再读一次。`;
23145
+ return `[browser_slot] press ${stroke.key} (code=${stroke.code}, modifiers=${stroke.modifiers}) × ${sent}\n ⚠️ This only reports keys SENT, ⛔ not that the UI responded — re-read with ax / eval.`;
23147
23146
  }
23148
23147
  case "type": {
23149
23148
  const n = needSlot(args);
23150
23149
  const target = await needTarget(root, n, sessionId, args);
23151
23150
  const text = typeof args.text === "string" ? args.text : void 0;
23152
- if (text === void 0 || text === "") return "⛔ 需要 --text=<要打的原文>(作用于当前焦点;要设值用 fill)";
23151
+ if (text === void 0 || text === "") return "⛔ needs --text=<exact text> (acts on current focus; use fill to set a value)";
23153
23152
  await slotType(root, n, sessionId, target, text);
23154
- return `[browser_slot] type ${JSON.stringify(text.slice(0, 40))}(已插入 ${[...text].length} 个字符;⛔ 未触发 change —— blur 才触发)`;
23153
+ return `[browser_slot] type ${JSON.stringify(text.slice(0, 40))} (inserted ${[...text].length} chars; ⛔ no change event — blur triggers it)`;
23155
23154
  }
23156
23155
  case "fill": {
23157
23156
  const n = needSlot(args);
23158
23157
  const target = await needTarget(root, n, sessionId, args);
23159
23158
  const id = needBackendId(args);
23160
23159
  const value = typeof args.value === "string" ? args.value : void 0;
23161
- if (value === void 0) return "⛔ 需要 --value=<要设成的值>(空串可以:--value=)";
23160
+ if (value === void 0) return "⛔ needs --value=<value> (empty string allowed: --value=)";
23162
23161
  const r = await slotFill(root, n, sessionId, target, id, value);
23163
- if (!r.ok) return `⛔ fill 失败(<${r.tag || "?"}>):${r.why ?? "未知原因"}`;
23162
+ if (!r.ok) return `⛔ fill failed (<${r.tag || "?"}>): ${r.why ?? "unknown reason"}`;
23164
23163
  const same = r.readBack === value;
23165
- return `[browser_slot] fill <${r.tag}> 读回=${JSON.stringify(r.readBack.slice(0, 80))}` + (same ? " ✓ 与给的值一致" : " ⚠️ 与给的值**不一致** —— 该控件可能做了格式化/拒绝");
23164
+ return `[browser_slot] fill <${r.tag}> read-back=${JSON.stringify(r.readBack.slice(0, 80))}` + (same ? " ✓ matches the value given" : " ⚠️ does NOT match — the control may reformat or reject it");
23166
23165
  }
23167
23166
  case "scroll": {
23168
23167
  const n = needSlot(args);
@@ -23171,55 +23170,55 @@ async function run(ctx, root, sessionId, trajectory, action, args) {
23171
23170
  const xy = parseXY(args.xy);
23172
23171
  const toRaw = str(args.to);
23173
23172
  const to = toRaw === "top" || toRaw === "bottom" ? toRaw : void 0;
23174
- if (!refStr && !xy && !to) return "⛔ 需要 --ref=<eNNN> / --xy=<x,y> / --to=<top|bottom> 之一";
23173
+ if (!refStr && !xy && !to) return "⛔ needs one of --ref=<eNNN> / --xy=<x,y> / --to=<top|bottom>";
23175
23174
  const { scrolledY, via, why } = await slotScroll(root, n, sessionId, target, {
23176
23175
  ref: refStr ? needBackendId(args) : void 0,
23177
23176
  xy,
23178
23177
  to,
23179
23178
  deltaY: num(args.delta)
23180
23179
  });
23181
- const viaLine = via === "wheel" ? "(真实 wheel 事件)" : `(⚠️ 回落 JS 滚动 —— ${why ?? ""};本次**没有产生 wheel 事件**,靠 wheel 触发的懒加载不会启动)`;
23182
- return `[browser_slot] scroll → scrollY 变化 ${scrolledY > 0 ? "+" : ""}${scrolledY}px ${viaLine}`;
23180
+ const viaLine = via === "wheel" ? "(real wheel event)" : `(⚠️ fell back to JS scroll — ${why ?? ""}; NO wheel event was emitted, so wheel-triggered lazy loading will not start)`;
23181
+ return `[browser_slot] scroll → scrollY ${scrolledY > 0 ? "+" : ""}${scrolledY}px ${viaLine}`;
23183
23182
  }
23184
23183
  case "wait": {
23185
23184
  const n = needSlot(args);
23186
23185
  const target = await needTarget(root, n, sessionId, args);
23187
23186
  const forRaw = str(args.for);
23188
- if (!forRaw) return "⛔ 需要 --for=<selector:…|text:…|url:…|gone:…|js:…>(前缀必填)";
23187
+ if (!forRaw) return "⛔ needs --for=<selector:…|text:…|url:…|gone:…|js:…> (prefix required)";
23189
23188
  const { spec, waitedMs } = await slotWait(root, n, sessionId, target, forRaw, num(args.timeout) ?? 15e3);
23190
- return `[browser_slot] wait ${spec.kind} 成立(等了 ${waitedMs}ms)`;
23189
+ return `[browser_slot] wait ${spec.kind} satisfied (waited ${waitedMs}ms)`;
23191
23190
  }
23192
23191
  case "drag": {
23193
23192
  const n = needSlot(args);
23194
23193
  const target = await needTarget(root, n, sessionId, args);
23195
23194
  const from = parseXY(args.from);
23196
23195
  const to = parseXY(args.to);
23197
- if (!from || !to) return `⛔ 需要 --from 与 --to(坐标三种写法都收):\n${xyFormHint("from")}${xyFormHint("to")}\n 先 ax 拿 ref,再用 scroll/eval 量坐标`;
23196
+ if (!from || !to) return `⛔ needs --from and --to (all three coordinate forms accepted):\n${xyFormHint("from")}${xyFormHint("to")}\n get a ref via ax, then measure coords with scroll/eval`;
23198
23197
  const steps = num(args.steps) ?? 12;
23199
23198
  await slotDrag(root, n, sessionId, target, from, to, steps);
23200
- return `[browser_slot] drag ${from.x},${from.y} → ${to.x},${to.y}(分 ${steps} 步;⛔ 回执不说拖成功)`;
23199
+ return `[browser_slot] drag ${from.x},${from.y} → ${to.x},${to.y} (${steps} steps; ⛔ this does not report success)`;
23201
23200
  }
23202
23201
  case "upload": {
23203
23202
  const n = needSlot(args);
23204
23203
  const target = await needTarget(root, n, sessionId, args);
23205
23204
  const id = needBackendId(args);
23206
23205
  const list = Array.isArray(args.file) ? args.file : typeof args.file === "string" ? [args.file] : [];
23207
- if (list.length === 0) return "⛔ 需要 --file=<CCC 内路径>(可重复;⛔ 不接受 CCC 根外路径)";
23206
+ if (list.length === 0) return "⛔ needs --file=<path inside CCC> (repeatable; paths outside the CCC root are refused)";
23208
23207
  const abs = list.filter((x) => typeof x === "string" && x !== "").map((f) => resolveUploadPath(root, f));
23209
- if (abs.length === 0) return "⛔ --file 里没有可用路径";
23208
+ if (abs.length === 0) return "⛔ no usable path in --file";
23210
23209
  const r = await slotUpload(root, n, sessionId, target, id, abs);
23211
- return `[browser_slot] upload ${r.files.length} 个文件 → ref ${str(args.ref) ?? ""}\n ${r.files.map((f) => f.replace(root + "/", "")).join("\n ")}`;
23210
+ return `[browser_slot] upload ${r.files.length} file(s) → ref ${str(args.ref) ?? ""}\n ${r.files.map((f) => f.replace(root + "/", "")).join("\n ")}`;
23212
23211
  }
23213
23212
  case "downloads": {
23214
23213
  const n = needSlot(args);
23215
23214
  const { dir, files } = await slotDownloads(root, n, sessionId, await needTarget(root, n, sessionId, args));
23216
- return `[browser_slot] 下载捕获目录:${dir}\n${files.length === 0 ? "(目录是空的)" : files.map((f) => ` ${f.name} ${Math.round(f.bytes / 1024)} KB`).join("\n")}\n ⇒ 触发下载用 click(点带 download 的链接会被拒)或 eval;之后**再调一次 downloads** 看新文件。\n ⚠️ 目录不自动清理 —— 清掉的是证据。`;
23215
+ return `[browser_slot] download capture dir: ${dir}\n${files.length === 0 ? "(directory is empty)" : files.map((f) => ` ${f.name} ${Math.round(f.bytes / 1024)} KB`).join("\n")}\n ⇒ trigger a download with click (links with download attr are refused) or eval; then call downloads again to see new files.\n ⚠️ The dir is never auto-cleaned — cleaning it destroys evidence.`;
23217
23216
  }
23218
23217
  case "dialog": {
23219
23218
  const n = needSlot(args);
23220
23219
  const r = await slotDialog(root, n, sessionId, await needTarget(root, n, sessionId, args), args.accept === true, str(args.prompt));
23221
- if (!r.hadDialog) return "[browser_slot] dialog —— 此刻没有弹窗(正常状态,不报错)";
23222
- return `[browser_slot] dialog ${r.type || "(未知类型)"}:${JSON.stringify(r.message.slice(0, 120))}\n ${r.accepted ? "✓ 已接受(确定)" : "✓ 已拒绝(取消)"}`;
23220
+ if (!r.hadDialog) return "[browser_slot] dialog — no dialog open right now (normal, not an error)";
23221
+ return `[browser_slot] dialog ${r.type || "(unknown)"}: ${JSON.stringify(r.message.slice(0, 120))}\n ${r.accepted ? "✓ accepted (OK)" : "✓ dismissed (Cancel)"}`;
23223
23222
  }
23224
23223
  case "close": {
23225
23224
  const n = needSlot(args);
@@ -23228,15 +23227,15 @@ async function run(ctx, root, sessionId, trajectory, action, args) {
23228
23227
  }
23229
23228
  case "ext-list": {
23230
23229
  const exts = slotExtList(root);
23231
- if (exts.length === 0) return `本 CCC 还没有任何扩展。\n 写一个:在 <CCC 根>/${EXT_DIR_REL}/ 下放一个 .ts 文件,文件名即扩展名。\n 契约:stdin 收 {slot,port,cccRoot,args};stdout **最后一个非空行**给 {"ok":true,"result":…}。\n ⚠️ ACC 只 spawn、⛔ 从不 import —— 你的语法错不会放倒宿主。`;
23232
- return `本 CCC 的浏览器扩展 ${exts.length} 个(<CCC 根>/${EXT_DIR_REL}/):\n` + exts.map((e) => ` · ${e.name}`).join("\n") + `\n\n调用:browser_slot ext --slot b1 --name <名> [--earg key=value …(可重复)]`;
23230
+ if (exts.length === 0) return `No browser extensions in this CCC yet.\n To add one: drop a .ts file under <CCC root>/${EXT_DIR_REL}/ — the filename is the extension name.\n Contract: stdin gets {slot,port,cccRoot,args}; stdout's LAST non-empty line must be {"ok":true,"result":…}.\n ⚠️ ACC only spawns, ⛔ never imports — your syntax error cannot take down the host.`;
23231
+ return `browser extensions in this CCC: ${exts.length} (<CCC root>/${EXT_DIR_REL}/):\n` + exts.map((e) => ` · ${e.name}`).join("\n") + `\n\ncall: browser_slot ext --slot b1 --name <name> [--earg key=value … (repeatable)]`;
23233
23232
  }
23234
23233
  case "ext": {
23235
23234
  const n = needSlot(args);
23236
23235
  const name = str(args.name);
23237
- if (!name) return "⛔ 需要 --name=<扩展名>(先跑 ext-list)";
23236
+ if (!name) return "⛔ needs --name=<extension> (run ext-list first)";
23238
23237
  const res = await slotExt(root, n, sessionId, name, extArgs(args));
23239
- if (!res.ok) return `⛔ 扩展「${name}」失败(${res.code ?? "unknown"}):\n${res.error ?? ""}`;
23238
+ if (!res.ok) return `⛔ extension "${name}" failed (${res.code ?? "unknown"}):\n${res.error ?? ""}`;
23240
23239
  return typeof res.result === "string" ? res.result : JSON.stringify(res.result ?? null, null, 2);
23241
23240
  }
23242
23241
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shgroup/dsh-serenity-hooks",
3
- "version": "1.138.3",
3
+ "version": "1.139.0",
4
4
  "description": "宁静号 ACC harness(Native Cordis 插件)——给 DeepSeek Harness 装一个「AI 工作区」:13 个工具(container_fs/cognitive_trajectory/dashboard/container_git/msm/praxis/ontology/serenity-skill-creator/localstore/container_admin/browser_slot;另两个 im-bridge/diagram 按条件出现)+ 机械约束(安全模式/工作区围墙/密钥守卫/对外输出守卫)+ 认知轨迹日志与原地重建 + 网页登录入口/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": {