@shgroup/dsh-serenity-hooks 1.121.0 → 1.123.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.121.0",
3
+ "version": "1.123.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;另三个 im-bridge/diagram/reconstruct 按条件出现)+ 机械约束(安全模式/工作区围墙/密钥守卫)+ 认知轨迹日志与原地重建 + 网页登录入口/IM 桥/认知轨迹唤醒注册表。轨迹声明 = 轨迹目录下的 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": {
@@ -161,11 +161,11 @@ function loadSerenityConfig(root, paths = DEFAULT_SERENITY_CONFIG_PATHS) {
161
161
  *
162
162
  * ## 失败方向 = **fail-open,但坏项逐条报告**(与另外两处刻意不同)
163
163
  *
164
- * 不订阅 ≠ 危险动作:它只是"没有通知",不会藏掉任何能力(对比 `safeMode.hiddenTools`
165
- * 是 fail-open 因为**隐藏**才是危险方向)。⇒ 整体读不到 ⇒ 空表。
164
+ * 不订阅 ≠ 危险动作:它只是"没有通知",不会藏掉任何能力(对比已删除的
165
+ * `safeMode.hiddenTools` 是 fail-open 因为**隐藏**才是危险方向)。⇒ 整体读不到 ⇒ 空表。
166
166
  *
167
167
  * 🔴 **但"坏项"不能一起吞掉**:配置里写了这一条、却因为成员名写错而**永远不触发**,
168
- * 是与 `safeMode.hiddenTools` 写错工具名**同族的静默失效**(写了但不生效,且没人知道)。
168
+ * 是与当年 `safeMode.hiddenTools` 写错工具名**同族的静默失效**(写了但不生效,且没人知道)。
169
169
  * ⇒ 本函数返回 `{ subs, problems }`:合法项照常生效,坏项进 `problems` 供调用方响亮告警。
170
170
  * ⚠️ 这与"整表读不到就空表"并不矛盾:前者是**文件级**失败(无法解析),
171
171
  * 后者是**条目级**失败(能解析但内容不成立)—— **两个粒度、两种处置**(D233 同族)。
@@ -236,30 +236,19 @@ function readUserQuotesEnabled(root, paths = DEFAULT_SERENITY_CONFIG_PATHS) {
236
236
  return raw.enabled === true;
237
237
  }
238
238
  /**
239
- * 读取 CCC 声明的「安全模式期间隐藏的工具」清单(`safeMode.hiddenTools`,v1.51.4)。
239
+ * 🔴 **`readSafeModeHiddenTools` 已于 v1.123.0 删除**(owner 2026-11-06 令
240
+ * 「安全模式开关只影响 bash 开关」)。
240
241
  *
241
- * 语义(R↓):**标记文件存在 ⇒ 才生效**。deny = `['bash', ...本清单]`(并集去重);
242
- * 标记消失 ⇒ 连同 `bash` 一起解除(调用点在 `syncSafeModeRestriction`,与基础表同一处)。
242
+ * 原语义:读 `safeMode.hiddenTools` —— **安全模式开启期间**的附加屏蔽。
243
+ * 删除后:安全模式只藏 `bash`;其余"在 CCC 内一律关"的那批工具**不再随开关忽隐忽现**,
244
+ * 改由 `seams/guards.ts` 的 `ALWAYS_DENY_TOOLS` 恒隐。
243
245
  *
244
- * 失败方向 = **fail-open**(与已删除的 `exclusiveTools` 的 fail-closed 相反,理由不同):
245
- * 未配置 / 字段缺失 / 配置损坏 ⇒ **空数组** = 只隐藏基础表。本键是**附加**屏蔽,
246
- * 读不到声明就等于"没有证据要求多藏";且**隐藏是危险方向**(藏掉 agent 真正要用的工具
247
- * 会静默损害能力),而配置损坏本身已有 `loadSerenityConfig` 的响亮告警(不静默)。
248
- *
249
- * 🔴 名字在此**不做**校验——未注册的名字会被 DSH `restrict` 拒绝(宿主契约逐字:
250
- * "Empty filters, unknown names, scope-local names, and reserved transport names **fail**")
251
- * ⇒ **调用方必须按"失败退化为基础表"处理**(见 `syncSafeModeRestriction`),
252
- * 否则 CCC 写错一个名字会连 `bash` 的隐藏一起丢掉。
253
- *
254
- * @param root CCC 根
255
- * @param paths 候选配置相对路径
256
- * @returns 去空白后的工具名列表(非字符串/空白项被丢弃)
246
+ * ⛔ 别为了"以后可能还要按开关多藏几件"把它加回来:
247
+ * 实测(2026-11-06 本机 0.2.2-rc.1)该键当时那 11 项里 **3 项宿主根本没注册**(空转,
248
+ * 因宿主 `restrict()` 对未知名只会剔除 ⇒ 零信号),其余 7 项**任何时候都该关**
249
+ * (跟着文件开关忽隐忽现反而是缺陷)。⇒ 若将来真要再引入"随开关变化的屏蔽面",
250
+ * 第一个要回答的问题是"**它为什么不该一直关**"。
257
251
  */
258
- function readSafeModeHiddenTools(root, paths = DEFAULT_SERENITY_CONFIG_PATHS) {
259
- const list = loadSerenityConfig(root, paths).safeMode?.hiddenTools;
260
- if (!Array.isArray(list)) return [];
261
- return list.filter((x) => typeof x === "string" && x.trim() !== "").map((x) => x.trim());
262
- }
263
252
  /**
264
253
  * 读取 CCC 声明的「轨迹默认 skill」清单(`trajectory.skills`,v1.44.0)。
265
254
  *
@@ -319,4 +308,4 @@ function matchBlacklist(relPath, rules) {
319
308
  return null;
320
309
  }
321
310
  //#endregion
322
- export { resolveInside as _, findSerenityRoot as a, matchBlacklist as c, readCccName as d, readCognitiveTrajectorySkills as f, readUtf8 as g, readUserQuotesEnabled as h, findGitRoot as i, pathInside as l, readTrajectorySubscriptions as m, SAFE_MODE_MARKER as n, isSafeModeOn as o, readSafeModeHiddenTools as p, classifyPath as r, loadSerenityConfig as s, DEFAULT_SERENITY_CONFIG_PATHS as t, readBlacklist as u };
311
+ export { findSerenityRoot as a, matchBlacklist as c, readCccName as d, readCognitiveTrajectorySkills as f, resolveInside as g, readUtf8 as h, findGitRoot as i, pathInside as l, readUserQuotesEnabled as m, SAFE_MODE_MARKER as n, isSafeModeOn as o, readTrajectorySubscriptions as p, classifyPath as r, loadSerenityConfig as s, DEFAULT_SERENITY_CONFIG_PATHS as t, readBlacklist as u };
@@ -1,5 +1,5 @@
1
1
  import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.js";
2
- import { a as findSerenityRoot } from "./ccc-x94FCzOv.js";
2
+ import { a as findSerenityRoot } from "./ccc-DSMqTrRU.js";
3
3
  import { basename } from "node:path";
4
4
  //#region src/host/access.ts
5
5
  /**
@@ -235,7 +235,7 @@ async function listCccs(ctx, opts = {}) {
235
235
  if (typeof defaultRoot === "string" && defaultRoot !== "" && !c.roots.includes(defaultRoot)) c.roots.unshift(defaultRoot);
236
236
  let rolesOf = null;
237
237
  if (opts.withRoles === true) {
238
- const { listTrajectoryConstraints } = await import("./profile-Djqz4Noy.js").then((n) => n.a);
238
+ const { listTrajectoryConstraints } = await import("./profile-DpxC9HtB.js").then((n) => n.a);
239
239
  rolesOf = (root) => {
240
240
  try {
241
241
  return listTrajectoryConstraints(root).map((p) => p.code);
@@ -1,4 +1,4 @@
1
- import { c as readWeixinSettings, o as readImSettings } from "./route-D-W3O2PF.js";
1
+ import { c as readWeixinSettings, o as readImSettings } from "./route-C2rARdoU.js";
2
2
  import { isAbsolute, join, relative, resolve } from "node:path";
3
3
  import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
4
4
  //#region src/im/log-scan.ts
package/lib/client.js CHANGED
@@ -236,7 +236,7 @@ window.__ModuleLoader__.load({
236
236
  "aria-haspopup": "dialog",
237
237
  "aria-expanded": open,
238
238
  onClick: () => setOpen((v) => !v),
239
- title: inCcc ? `Serenity v${status.accVersion} — ${status.root}(${status.safeModeOn ? "SAFE ON — 写工具已隐藏" : "SAFE OFF — 写工具全开,无保护"})` : "Serenity(未激活)",
239
+ title: inCcc ? `Serenity v${status.accVersion} — ${status.root}(${status.safeModeOn ? "SAFE ON — bash 已隐藏" : "SAFE OFF — bash 可用"})` : "Serenity(未激活)",
240
240
  children: [
241
241
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: cx("sp-dot", inCcc ? void 0 : "sp-dotOff") }),
242
242
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -249,7 +249,7 @@ window.__ModuleLoader__.load({
249
249
  }),
250
250
  inCcc && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: cx("sp-sep") }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
251
251
  className: cx("sp-safeBadge", status.safeModeOn ? "sp-safeBadgeOn" : "sp-safeBadgeOff"),
252
- title: status.safeModeOn ? "safe-mode ON — 写工具已隐藏(状态信息;开关在 设置 → Serenity)" : "safe-mode OFF — 写工具全开(状态信息;开关在 设置 → Serenity)",
252
+ title: status.safeModeOn ? "safe-mode ON — bash 已隐藏(状态信息;开关在 设置 → Serenity)" : "safe-mode OFF — bash 可用(状态信息;开关在 设置 → Serenity)",
253
253
  children: [
254
254
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: cx("sp-safeDot") }),
255
255
  "SAFE ",
@@ -286,7 +286,7 @@ window.__ModuleLoader__.load({
286
286
  "aria-label": "safe-mode",
287
287
  disabled: busy,
288
288
  className: cx("sp-quickSwitch", status.safeModeOn ? "sp-quickSwitchOn" : "sp-quickSwitchOff", busy ? "sp-quickSwitchBusy" : void 0),
289
- title: status.safeModeOn ? "safe-mode ON —— 写工具已隐藏(点击关闭)" : "safe-mode OFF —— 写工具全开(点击开启)",
289
+ title: status.safeModeOn ? "safe-mode ON —— bash 已隐藏(点击关闭)" : "safe-mode OFF —— bash 可用(点击开启)",
290
290
  onClick: () => void toggleSafeMode(!status.safeModeOn),
291
291
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: cx("sp-quickSwitchThumb") })
292
292
  }),
package/lib/index.js CHANGED
@@ -1,19 +1,19 @@
1
1
  import { i as __toESM, n as __exportAll } from "./rolldown-runtime-B4iAMlE-.js";
2
- import { c as hostAgents, d as hostSessions, f as hostSettings, i as cccRootForExec, m as hostWebServer, n as agentCwdFor, o as listCccs, p as hostWeb, r as cccRootForCwd, t as NO_CCC_FROM_AGENT_CWD, u as hostService } from "./ccc-roots-CsSSQjSS.js";
3
- import { _ as resolveInside, a as findSerenityRoot$1, d as readCccName, h as readUserQuotesEnabled, l as pathInside, m as readTrajectorySubscriptions, s as loadSerenityConfig, t as DEFAULT_SERENITY_CONFIG_PATHS } from "./ccc-x94FCzOv.js";
2
+ import { c as hostAgents, d as hostSessions, f as hostSettings, i as cccRootForExec, m as hostWebServer, n as agentCwdFor, o as listCccs, p as hostWeb, r as cccRootForCwd, t as NO_CCC_FROM_AGENT_CWD, u as hostService } from "./ccc-roots-CtNmjx5v.js";
3
+ import { a as findSerenityRoot$1, d as readCccName, g as resolveInside, l as pathInside, m as readUserQuotesEnabled, p as readTrajectorySubscriptions, s as loadSerenityConfig, t as DEFAULT_SERENITY_CONFIG_PATHS } from "./ccc-DSMqTrRU.js";
4
4
  import { A as useSession, C as resolveSessionByTitle, D as showSession, E as setActiveSessionInfo, F as isoLocal, I as localFileStamp, M as TRAJECTORY_LEGACY_FILENAMES, O as summarize, S as readTrajectoryUid, T as sessionsRoot, _ as listSessions, b as parseTrajectoryCode, c as UID_FILENAME, d as createSession, f as extractSessionMdPathFromText, j as TRAJECTORY_FILENAME, k as trajectoryDescOf, l as archiveSession, m as getActiveSessionInfo, o as COGNITIVE_TRAJECTORY_ACTIONS, p as findSession, u as clearActiveSessionInfo, v as namingTitleFor, w as sessionEvents, y as parseSessionContextFromEvents } from "./bind-file-B0TuOP89.js";
5
- import { n as checkLocalstoreGitCompliance, o as readStore, s as runLocalStore, t as LOCALSTORE_SCOPES } from "./service-Dv-8E2bI.js";
6
- import { d as findPackageRoot, i as constraintSystemPromptSource, l as resolveConstraintSystemPrompt, r as constraintCognitiveTrajectory, t as TRAJECTORY_CONSTRAINT_HINT, u as ACC_VERSION } from "./rules-DKlpuFN_.js";
7
- import { C as runMsmAsync, S as runMsm, T as setWeixinSendEndpoint, _ as ACC_CATALOG, a as loadOpencodeSkill, b as findEntry, c as summarizeHostContract, f as forgetNonCccToolVisibility, g as forgetToolVisibility, h as syncToolVisibility, i as listOpencodeSkillDirs, m as registerGuards, n as readDshVersion, o as compareSemver, r as setSafeMode, s as hostContractReport, t as getStatus, v as CCC_CONFIG_REFERENCE, w as docsPointer, x as loadMsmEntries } from "./status-DU4k3Wqe.js";
8
- import { c as replacesDefaultIdentity, i as listTrajectoryConstraints, l as trajectoryCodeForSession, n as findDirNameByCode, o as readTrajectoryConstraintAt, r as isTrajectoryConstrained, s as readTrajectoryConstraintByCode, t as TRAJECTORY_CONSTRAINT_FILENAME } from "./profile-Djqz4Noy.js";
9
- import { A as TRAJECTORY_PROMPT_FILENAME, C as recordToolUsage, D as buildResourceNameSuffix, E as buildResourceIndex, O as isSafeSkillName, S as verifyTotpCode, T as SKILL_ONTOLOGY_FILE, _ as projectKnownWorkspaces, a as trajectoryConstraintFor, b as FACE_PORTS, c as trajectoryWorkspaceMdPath, d as splitModel, f as registerCognitiveTrajectorySkillSection, g as migrateLegacyLocalstore, h as applyWirePatch, i as getTrajectoryAgent, j as hasTrajectoryPrompt, k as truncateContent, l as unregisterTrajectorySession, m as registerEntrySkillSectionGlobal, n as deliverToTrajectory, o as trajectoryConstraintMsmGate, p as registerEntrySkillSection, r as ensureWorkspacePromptSection, s as trajectoryConstraintParticipates, t as createTrajectoryAgent, u as workspaceCognitiveTrajectoryLine, v as readAdvancedSettings, w as REFERENCE_DIR, x as MECHANISM_PORTS, y as toWire } from "./session-C4AzKUh_.js";
10
- import { a as ACC_MESSAGE_KIND, d as readLastBound, f as resolveSessionCognitiveTrajectoryLabel, i as toMessage, l as findTrajectoryOfSession, n as deliver, o as PLUGIN_SOURCE, r as makeInjection, s as appendBound } from "./injection-B5jZxemg.js";
11
- import { _ as WAKE_CATCH_UP_MS, c as formatPendingTools, d as listRunningSessionIds, f as registerCroTurnTracking, g as CARRIER_OPENING_MARK, i as sendToCognitiveTrajectory, l as projectDirNameForCwd, m as buildCroSnapshot, n as registerWakeScheduler, o as DEFAULT_LOOKBACK_MS, p as registerDisposer, s as createResumeOne, t as createAndBindTarget, u as scanInterruptedSessions, v as addWake } from "./scheduler-CMBAoYR8.js";
5
+ import { n as checkLocalstoreGitCompliance, o as readStore, s as runLocalStore, t as LOCALSTORE_SCOPES } from "./service-BRUHmVFn.js";
6
+ import { d as findPackageRoot, i as constraintSystemPromptSource, l as resolveConstraintSystemPrompt, r as constraintCognitiveTrajectory, t as TRAJECTORY_CONSTRAINT_HINT, u as ACC_VERSION } from "./rules-BYeykzys.js";
7
+ import { C as runMsmAsync, S as runMsm, T as setWeixinSendEndpoint, _ as ACC_CATALOG, a as loadOpencodeSkill, b as findEntry, c as summarizeHostContract, f as forgetNonCccToolVisibility, g as forgetToolVisibility, h as syncToolVisibility, i as listOpencodeSkillDirs, m as registerGuards, n as readDshVersion, o as compareSemver, r as setSafeMode, s as hostContractReport, t as getStatus, v as CCC_CONFIG_REFERENCE, w as docsPointer, x as loadMsmEntries } from "./status-O7MPoKFy.js";
8
+ import { c as replacesDefaultIdentity, i as listTrajectoryConstraints, l as trajectoryCodeForSession, n as findDirNameByCode, o as readTrajectoryConstraintAt, r as isTrajectoryConstrained, s as readTrajectoryConstraintByCode, t as TRAJECTORY_CONSTRAINT_FILENAME } from "./profile-DpxC9HtB.js";
9
+ import { A as TRAJECTORY_PROMPT_FILENAME, C as recordToolUsage, D as buildResourceNameSuffix, E as buildResourceIndex, O as isSafeSkillName, S as verifyTotpCode, T as SKILL_ONTOLOGY_FILE, _ as projectKnownWorkspaces, a as trajectoryConstraintFor, b as FACE_PORTS, c as trajectoryWorkspaceMdPath, d as splitModel, f as registerCognitiveTrajectorySkillSection, g as migrateLegacyLocalstore, h as applyWirePatch, i as getTrajectoryAgent, j as hasTrajectoryPrompt, k as truncateContent, l as unregisterTrajectorySession, m as registerEntrySkillSectionGlobal, n as deliverToTrajectory, o as trajectoryConstraintMsmGate, p as registerEntrySkillSection, r as ensureWorkspacePromptSection, s as trajectoryConstraintParticipates, t as createTrajectoryAgent, u as workspaceCognitiveTrajectoryLine, v as readAdvancedSettings, w as REFERENCE_DIR, x as MECHANISM_PORTS, y as toWire } from "./session-B1a9L747.js";
10
+ import { a as ACC_MESSAGE_KIND, d as readLastBound, f as resolveSessionCognitiveTrajectoryLabel, i as toMessage, l as findTrajectoryOfSession, n as deliver, o as PLUGIN_SOURCE, r as makeInjection, s as appendBound, u as listBoundSessionIds } from "./injection-CKx49Mlf.js";
11
+ import { _ as WAKE_CATCH_UP_MS, c as formatPendingTools, d as listRunningSessionIds, f as registerCroTurnTracking, g as CARRIER_OPENING_MARK, i as sendToCognitiveTrajectory, l as projectDirNameForCwd, m as buildCroSnapshot, n as registerWakeScheduler, o as DEFAULT_LOOKBACK_MS, p as registerDisposer, s as createResumeOne, t as createAndBindTarget, u as scanInterruptedSessions, v as addWake } from "./scheduler-CgjLs5_S.js";
12
12
  import { i as sessionsRootDir } from "./cleanup-CPl1SSaK.js";
13
- import { n as readSimpleSettings, r as registerSettingsSection } from "./settings-DibHCfEU.js";
14
- import { a as readFeishuCredential, c as readWeixinSettings, d as weixinInboundDir, f as weixinSessionIdForTrajectory, i as matchWeixinRoute, n as extractWeixinText, r as hasVoiceItem, s as readWeixinCredential, t as extractWeixinMedia, u as sanitizeFileName$1 } from "./route-D-W3O2PF.js";
15
- import { i as runImBridge, n as isImWiredTrajectory, r as registerImChannel, t as imChannelIds } from "./channels-DWZlcsE0.js";
16
- import { i as subscriptionStats, n as registerTrajectorySubscriptions, r as subscriptionEval, t as defaultSubscriptionDeps } from "./subscriptions-CV-7Yhqb.js";
13
+ import { i as hostAliveProbe, n as readSimpleSettings, r as registerSettingsSection } from "./settings-CUabGkal.js";
14
+ import { a as readFeishuCredential, c as readWeixinSettings, d as weixinInboundDir, f as weixinSessionIdForTrajectory, i as matchWeixinRoute, n as extractWeixinText, r as hasVoiceItem, s as readWeixinCredential, t as extractWeixinMedia, u as sanitizeFileName$1 } from "./route-C2rARdoU.js";
15
+ import { i as runImBridge, n as isImWiredTrajectory, r as registerImChannel, t as imChannelIds } from "./channels-w8H6l04X.js";
16
+ import { i as subscriptionStats, n as registerTrajectorySubscriptions, r as subscriptionEval, t as defaultSubscriptionDeps } from "./subscriptions-C4oGjnC2.js";
17
17
  import { c as sendTextMessage, i as getUpdates, l as sendTyping, n as downloadMedia, o as markdownToPlainText, r as getConfig, s as sendFileMessage, t as TypingStatus, u as sniffImageExt } from "./ilink-CsZ-f64q.js";
18
18
  import { a as registerImAccountImpl, i as normalizeAccountChannel, n as getImAccountImpl, r as imAccountChannels } from "./accounts-BHQbakUh.js";
19
19
  import { createRequire } from "node:module";
@@ -515,7 +515,7 @@ const KIT_ACTIONS = [
515
515
  async function runKit(root, args, hostCtx) {
516
516
  switch (args.action) {
517
517
  case "health": {
518
- const { containerStatus } = await import("./observation-D0RjHk0e.js");
518
+ const { containerStatus } = await import("./observation-jNfDH9lC.js");
519
519
  const s = containerStatus({
520
520
  root,
521
521
  hostCtx
@@ -561,7 +561,7 @@ async function runKit(root, args, hostCtx) {
561
561
  }
562
562
  case "diag": {
563
563
  if (hostCtx === void 0) throw new Error("diag requires the plugin context (live session data unavailable without it)");
564
- const { runDiag, renderDiag } = await import("./service-IY3u-vea.js");
564
+ const { runDiag, renderDiag } = await import("./service-BGwhex36.js");
565
565
  return renderDiag(await runDiag(hostCtx, root ?? ""));
566
566
  }
567
567
  default: throw new Error(`Unknown action: ${args.action}`);
@@ -10680,11 +10680,11 @@ function registerStatusApi(ctx, opts = {}) {
10680
10680
  sendJson$2(res, 400, { error: chk.error });
10681
10681
  return;
10682
10682
  }
10683
- const { readWeixinSettings } = await import("./route-D-W3O2PF.js").then((n) => n.l);
10683
+ const { readWeixinSettings } = await import("./route-C2rARdoU.js").then((n) => n.l);
10684
10684
  const { weixinBridgeStatus } = await Promise.resolve().then(() => bridge_exports);
10685
10685
  const settings = readWeixinSettings(chk.root);
10686
10686
  const bridge = weixinBridgeStatus().find((b) => b.ccc === chk.root);
10687
- const { imCredentialBound } = await import("./route-D-W3O2PF.js").then((n) => n.l);
10687
+ const { imCredentialBound } = await import("./route-C2rARdoU.js").then((n) => n.l);
10688
10688
  const { normalizeAccountChannel } = await import("./accounts-BHQbakUh.js").then((n) => n.t);
10689
10689
  const accounts = (settings.accounts ?? []).map((a) => {
10690
10690
  const channel = normalizeAccountChannel(a.channel);
@@ -10721,7 +10721,7 @@ function registerStatusApi(ctx, opts = {}) {
10721
10721
  const { fetchQRCode } = await import("./ilink-CsZ-f64q.js").then((n) => n.a);
10722
10722
  const { randomUUID } = await import("node:crypto");
10723
10723
  for (const [key, v] of weixinLogins) if (Date.now() - v.startedAt > WEIXIN_LOGIN_TTL_MS) weixinLogins.delete(key);
10724
- const { readWeixinSettings } = await import("./route-D-W3O2PF.js").then((n) => n.l);
10724
+ const { readWeixinSettings } = await import("./route-C2rARdoU.js").then((n) => n.l);
10725
10725
  const qr = await fetchQRCode({ botType: readWeixinSettings(root).botType ?? void 0 });
10726
10726
  const loginKey = randomUUID();
10727
10727
  weixinLogins.set(loginKey, {
@@ -10742,7 +10742,7 @@ function registerStatusApi(ctx, opts = {}) {
10742
10742
  sendJson$2(res, 400, { error: "missing accountId" });
10743
10743
  return;
10744
10744
  }
10745
- const { removeWeixinAccount } = await import("./route-D-W3O2PF.js").then((n) => n.l);
10745
+ const { removeWeixinAccount } = await import("./route-C2rARdoU.js").then((n) => n.l);
10746
10746
  const { syncCccBridge } = await Promise.resolve().then(() => bridge_exports);
10747
10747
  removeWeixinAccount(root, body.accountId);
10748
10748
  syncCccBridge(ctx, root);
@@ -10768,8 +10768,8 @@ function registerStatusApi(ctx, opts = {}) {
10768
10768
  trajectory: code
10769
10769
  });
10770
10770
  }
10771
- const { saveWeixinRoutes } = await import("./route-D-W3O2PF.js").then((n) => n.l);
10772
- const { findDirNameByCode } = await import("./profile-Djqz4Noy.js").then((n) => n.a);
10771
+ const { saveWeixinRoutes } = await import("./route-C2rARdoU.js").then((n) => n.l);
10772
+ const { findDirNameByCode } = await import("./profile-DpxC9HtB.js").then((n) => n.a);
10773
10773
  for (const r of routes) if (findDirNameByCode(root, r.trajectory) === null) {
10774
10774
  sendJson$2(res, 400, { error: `unknown trajectory: ${r.trajectory} (no such trajectory code in ${root})` });
10775
10775
  return;
@@ -10780,7 +10780,7 @@ function registerStatusApi(ctx, opts = {}) {
10780
10780
  }
10781
10781
  if (body.action === "set-enabled") {
10782
10782
  const enabled = body.enabled === true;
10783
- const { readWeixinSettings, setWeixinEnabled } = await import("./route-D-W3O2PF.js").then((n) => n.l);
10783
+ const { readWeixinSettings, setWeixinEnabled } = await import("./route-C2rARdoU.js").then((n) => n.l);
10784
10784
  const { syncCccBridge } = await Promise.resolve().then(() => bridge_exports);
10785
10785
  const settings = readWeixinSettings(root);
10786
10786
  if (enabled && (settings.accounts ?? []).length === 0) {
@@ -10803,7 +10803,7 @@ function registerStatusApi(ctx, opts = {}) {
10803
10803
  sendJson$2(res, 400, { error: "appId 与 appSecret 都必须填(只填一个等于没绑)" });
10804
10804
  return;
10805
10805
  }
10806
- const { readWeixinSettings, upsertWeixinAccount, writeFeishuCredential, nextFeishuAccountId } = await import("./route-D-W3O2PF.js").then((n) => n.l);
10806
+ const { readWeixinSettings, upsertWeixinAccount, writeFeishuCredential, nextFeishuAccountId } = await import("./route-C2rARdoU.js").then((n) => n.l);
10807
10807
  const { syncCccBridge } = await Promise.resolve().then(() => bridge_exports);
10808
10808
  const before = readWeixinSettings(root);
10809
10809
  const accountId = (body.accountId ?? "").trim() !== "" ? body.accountId.trim() : nextFeishuAccountId(before);
@@ -10853,7 +10853,7 @@ function registerStatusApi(ctx, opts = {}) {
10853
10853
  return;
10854
10854
  }
10855
10855
  const { pollQRStatus } = await import("./ilink-CsZ-f64q.js").then((n) => n.a);
10856
- const { readWeixinSettings } = await import("./route-D-W3O2PF.js").then((n) => n.l);
10856
+ const { readWeixinSettings } = await import("./route-C2rARdoU.js").then((n) => n.l);
10857
10857
  const settings = readWeixinSettings(login.root);
10858
10858
  const status = await pollQRStatus({
10859
10859
  baseUrl: void 0,
@@ -10868,7 +10868,7 @@ function registerStatusApi(ctx, opts = {}) {
10868
10868
  });
10869
10869
  return;
10870
10870
  }
10871
- const { upsertWeixinAccount, writeWeixinCredential, nextWeixinAccountId } = await import("./route-D-W3O2PF.js").then((n) => n.l);
10871
+ const { upsertWeixinAccount, writeWeixinCredential, nextWeixinAccountId } = await import("./route-C2rARdoU.js").then((n) => n.l);
10872
10872
  const { syncCccBridge } = await Promise.resolve().then(() => bridge_exports);
10873
10873
  const accountId = nextWeixinAccountId(settings);
10874
10874
  upsertWeixinAccount(login.root, {
@@ -15194,7 +15194,7 @@ const MEDIA_MAX_BYTES = 20971520;
15194
15194
  */
15195
15195
  async function resolveCccRootByAlias(ctx, alias) {
15196
15196
  try {
15197
- const { listCccs } = await import("./ccc-roots-CsSSQjSS.js").then((n) => n.a);
15197
+ const { listCccs } = await import("./ccc-roots-CtNmjx5v.js").then((n) => n.a);
15198
15198
  const entries = await listCccs(ctx);
15199
15199
  const byName = entries.find((e) => e.name === alias);
15200
15200
  if (byName) return byName.root;
@@ -15262,7 +15262,7 @@ async function resolveInboundTarget(ctx, input) {
15262
15262
  });
15263
15263
  return null;
15264
15264
  }
15265
- const { findDirNameByCode } = await import("./profile-Djqz4Noy.js").then((n) => n.a);
15265
+ const { findDirNameByCode } = await import("./profile-DpxC9HtB.js").then((n) => n.a);
15266
15266
  if (findDirNameByCode(root, target.role) === null) {
15267
15267
  const detail = `目标 CCC "${target.ccc}" 内没有编码为 "${target.role}" 的认知轨迹`;
15268
15268
  console.error(`[serenity-hooks] ✗ human-channel: ${detail}(account=${input.account} user=${input.user})—— 该消息**未投递**,请改订阅表里的目标编码`);
@@ -15284,6 +15284,54 @@ async function resolveInboundTarget(ctx, input) {
15284
15284
  };
15285
15285
  }
15286
15286
  /**
15287
+ * 入站投递**投给哪条会话**:先问绑定真相源,派生值只作"还没有载体"时的兜底。
15288
+ *
15289
+ * ## 🔴 为什么必须有这一格(2026-11-06 生产回归,v1.121.0 `reconstruct` 引入)
15290
+ *
15291
+ * 原实现是**纯函数派生**:`weixinSessionIdForTrajectory(code)` ⇒ 恒等于 `skiff-weixin-<code>`。
15292
+ * 那个前提在 `reconstruct` 之前是成立的 —— 载体 id 一旦派生就永不变。
15293
+ *
15294
+ * 但 `reconstruct` 的语义**正是"换一条载体"**:它建新会话(`session-<uuid>`)、把轨迹绑过去、
15295
+ * **归档旧会话**。⇒ 派生值与真实载体**从此分叉**,而入站仍按派生值投递 ⇒
15296
+ * **消息被投进一条已归档的会话**。
15297
+ *
15298
+ * 真机读数(2026-11-06 08:3x,宿主日志逐字):
15299
+ * ```
15300
+ * reconstruct: 新载体 session-0fd78851… 已接管「…zhaocai-xingzai…」(旧 skiff-weixin-zhaocai-xingzai)
15301
+ * reconstruct: 旧会话 skiff-weixin-zhaocai-xingzai 已归档(attempt 1)
15302
+ * im 投递:会话 skiff-weixin-zhaocai-xingzai → followup ← 投给已归档的那条
15303
+ * ```
15304
+ * ⇒ 人在微信那头**连发四条没人应**,而**日志里每一层都报成功**(`followup` 不是空操作)。
15305
+ * 这正是本仓最怕的形态:**静默**。
15306
+ *
15307
+ * ## 判据的层级(为什么不能只改 `reconstruct`)
15308
+ *
15309
+ * | 改法 | 为什么不行 |
15310
+ * |---|---|
15311
+ * | 让 `reconstruct` 把新载体 id **派生**成 `skiff-weixin-<code>` | 撞宿主与 ACC 双方的「一个会话至多一条轨迹」;且第二次换代时旧 id 还被占着 |
15312
+ * | `reconstruct` 之后**改写派生函数** | 派生函数是**纯函数**,它不知道谁刚换代;给它加状态 = 造第二真相源 |
15313
+ * | ✅ **投递前问绑定真相源** | 绑定文件(`current.dsh_session_bind`)**本来就是**"此刻谁在承载它"的唯一真相源(D172),换来换去都写在这一个槽位里 |
15314
+ *
15315
+ * ⚠️ **兜底不是"静默退回旧行为",是"这条轨迹还没有载体"**:那时派生值是对的 ——
15316
+ * `createTrajectoryAgent` 会按它建出第一条载体。⇒ 两种状态**语义不同**,不是同一个 bug 的宽容版。
15317
+ *
15318
+ * @param ctx 插件上下文(`hostAliveProbe` 要用它取宿主事实)
15319
+ * @param root CCC 根
15320
+ * @param code 目标轨迹编码
15321
+ * @returns 该轨迹此刻的载体 id;未绑定 / 取不到事实 ⇒ 派生值
15322
+ */
15323
+ function carrierSessionIdForIm(ctx, root, code) {
15324
+ const derived = weixinSessionIdForTrajectory(code);
15325
+ try {
15326
+ const dirName = findDirNameByCode(root, code);
15327
+ if (dirName === null) return derived;
15328
+ const bound = listBoundSessionIds(root, dirName, hostAliveProbe(ctx));
15329
+ return bound.length > 0 ? bound[0] : derived;
15330
+ } catch {
15331
+ return derived;
15332
+ }
15333
+ }
15334
+ /**
15287
15335
  * 同会话入站**串行化**(2026-10-21,修"同一条消息被处理两轮"的第二个缺陷)。
15288
15336
  *
15289
15337
  * ## 为什么必须有锁(R↓,代价换来的)
@@ -15374,7 +15422,7 @@ async function handleInboundEvent(ctx, root, accountId, io, event, preset) {
15374
15422
  }
15375
15423
  let releaseLock = null;
15376
15424
  try {
15377
- const sessionId = weixinSessionIdForTrajectory(trajectory);
15425
+ const sessionId = carrierSessionIdForIm(ctx, root, trajectory);
15378
15426
  /**
15379
15427
  * 🔴 **同会话串行化**(2026-10-21 引入;**2026-10-24 理由已变,见下**)。
15380
15428
  *
@@ -16224,7 +16272,7 @@ function syncHumanChannel(ctx) {
16224
16272
  (async () => {
16225
16273
  try {
16226
16274
  stopMachineLoops();
16227
- const { listCccs } = await import("./ccc-roots-CsSSQjSS.js").then((n) => n.a);
16275
+ const { listCccs } = await import("./ccc-roots-CtNmjx5v.js").then((n) => n.a);
16228
16276
  for (const entry of await listCccs(ctx)) syncCccBridge(ctx, entry.root);
16229
16277
  } catch {}
16230
16278
  })();
@@ -16517,7 +16565,7 @@ function matchCcc(input, candidates) {
16517
16565
  }
16518
16566
  /** 组装候选列表(`ccc-roots.listCccs` 投影 + `.serenity` 名;动态 import 保持本模块静态依赖轻量) */
16519
16567
  async function collectCandidates(ctx) {
16520
- const { listCccs } = await import("./ccc-roots-CsSSQjSS.js").then((n) => n.a);
16568
+ const { listCccs } = await import("./ccc-roots-CtNmjx5v.js").then((n) => n.a);
16521
16569
  const entries = await listCccs(ctx, { defaultRoot: process.cwd() });
16522
16570
  const seen = /* @__PURE__ */ new Set();
16523
16571
  const out = [];
@@ -1,4 +1,4 @@
1
- import { r as cccRootForCwd } from "./ccc-roots-CsSSQjSS.js";
1
+ import { r as cccRootForCwd } from "./ccc-roots-CtNmjx5v.js";
2
2
  import { T as sessionsRoot, a as readBindDeclaration, b as parseTrajectoryCode, h as getLastActiveSessionInfo, i as listBindDeclarations, m as getActiveSessionInfo, n as findTrajectoryHolding, r as isBindUsable, t as claimBinding, w as sessionEvents } from "./bind-file-B0TuOP89.js";
3
3
  import { join } from "node:path";
4
4
  import { createUserMessage } from "@deepseek-ai/dsh-llm";
@@ -47,12 +47,15 @@ interface SerenityConfig {
47
47
  safeMode?: {
48
48
  blacklist?: string[];
49
49
  /**
50
- * **安全模式开启期间**额外从模型工具清单隐藏的工具(v1.51.4,owner 2026-10-09 令)。
50
+ * 🔴 **已于 v1.123.0 退役**(owner 2026-11-06 令「安全模式开关只影响 bash 开关」)。
51
51
  *
52
- * 语义(与 `exclusiveTools` 的区别,判据是"条件"):本键不是无条件的可见性白名单,
53
- * 而是**条件屏蔽**——`\.serenity-safe-on` 标记存在时才隐藏,标记消失即**全部恢复**
54
- * (基础表恒隐 `bash` 不受影响)。机制在 ACC、声明在 CCC(D23):
55
- * ACC 代码里不出现任何具体工具名。
52
+ * 原语义(v1.51.4):安全模式开启期间**额外**隐藏这些工具。
53
+ * 现语义:安全模式**只藏 `bash`**;其余"CCC 内一律关"的那批改由
54
+ * `seams/guards.ts` 的 `ALWAYS_DENY_TOOLS` **恒隐**(不再随本开关忽隐忽现)。
55
+ *
56
+ * ⚠️ 存量 CCC 里仍写着本键 ⇒ **静默忽略**(schemastery 非 strict:不报错、不生效)。
57
+ * 这正是 D151 警告的"写了但不生效、且没人知道"的形态 ⇒ 配置面已同批清空。
58
+ * 类型保留只为"读旧文件不炸",⛔ **没有任何读取方**(`readSafeModeHiddenTools` 已删)。
56
59
  */
57
60
  hiddenTools?: string[];
58
61
  };
@@ -373,11 +376,11 @@ export declare function loadSerenityConfig(root: string, paths?: string[]): Sere
373
376
  *
374
377
  * ## 失败方向 = **fail-open,但坏项逐条报告**(与另外两处刻意不同)
375
378
  *
376
- * 不订阅 ≠ 危险动作:它只是"没有通知",不会藏掉任何能力(对比 `safeMode.hiddenTools`
377
- * 是 fail-open 因为**隐藏**才是危险方向)。⇒ 整体读不到 ⇒ 空表。
379
+ * 不订阅 ≠ 危险动作:它只是"没有通知",不会藏掉任何能力(对比已删除的
380
+ * `safeMode.hiddenTools` 是 fail-open 因为**隐藏**才是危险方向)。⇒ 整体读不到 ⇒ 空表。
378
381
  *
379
382
  * 🔴 **但"坏项"不能一起吞掉**:配置里写了这一条、却因为成员名写错而**永远不触发**,
380
- * 是与 `safeMode.hiddenTools` 写错工具名**同族的静默失效**(写了但不生效,且没人知道)。
383
+ * 是与当年 `safeMode.hiddenTools` 写错工具名**同族的静默失效**(写了但不生效,且没人知道)。
381
384
  * ⇒ 本函数返回 `{ subs, problems }`:合法项照常生效,坏项进 `problems` 供调用方响亮告警。
382
385
  * ⚠️ 这与"整表读不到就空表"并不矛盾:前者是**文件级**失败(无法解析),
383
386
  * 后者是**条目级**失败(能解析但内容不成立)—— **两个粒度、两种处置**(D233 同族)。
@@ -403,26 +406,19 @@ export declare function readTrajectorySubscriptions(root: string, paths?: string
403
406
  */
404
407
  export declare function readUserQuotesEnabled(root: string, paths?: string[]): boolean;
405
408
  /**
406
- * 读取 CCC 声明的「安全模式期间隐藏的工具」清单(`safeMode.hiddenTools`,v1.51.4)。
407
- *
408
- * 语义(R↓):**标记文件存在 ⇒ 才生效**。deny = `['bash', ...本清单]`(并集去重);
409
- * 标记消失 ⇒ 连同 `bash` 一起解除(调用点在 `syncSafeModeRestriction`,与基础表同一处)。
410
- *
411
- * 失败方向 = **fail-open**(与已删除的 `exclusiveTools` 的 fail-closed 相反,理由不同):
412
- * 未配置 / 字段缺失 / 配置损坏 ⇒ **空数组** = 只隐藏基础表。本键是**附加**屏蔽,
413
- * 读不到声明就等于"没有证据要求多藏";且**隐藏是危险方向**(藏掉 agent 真正要用的工具
414
- * 会静默损害能力),而配置损坏本身已有 `loadSerenityConfig` 的响亮告警(不静默)。
409
+ * 🔴 **`readSafeModeHiddenTools` 已于 v1.123.0 删除**(owner 2026-11-06 令
410
+ * 「安全模式开关只影响 bash 开关」)。
415
411
  *
416
- * 🔴 名字在此**不做**校验——未注册的名字会被 DSH `restrict` 拒绝(宿主契约逐字:
417
- * "Empty filters, unknown names, scope-local names, and reserved transport names **fail**")
418
- * ⇒ **调用方必须按"失败退化为基础表"处理**(见 `syncSafeModeRestriction`),
419
- * 否则 CCC 写错一个名字会连 `bash` 的隐藏一起丢掉。
412
+ * 原语义:读 `safeMode.hiddenTools` —— **安全模式开启期间**的附加屏蔽。
413
+ * 删除后:安全模式只藏 `bash`;其余"在 CCC 内一律关"的那批工具**不再随开关忽隐忽现**,
414
+ * 改由 `seams/guards.ts` 的 `ALWAYS_DENY_TOOLS` 恒隐。
420
415
  *
421
- * @param root CCC 根
422
- * @param paths 候选配置相对路径
423
- * @returns 去空白后的工具名列表(非字符串/空白项被丢弃)
416
+ * ⛔ 别为了"以后可能还要按开关多藏几件"把它加回来:
417
+ * 实测(2026-11-06 本机 0.2.2-rc.1)该键当时那 11 项里 **3 项宿主根本没注册**(空转,
418
+ * 因宿主 `restrict()` 对未知名只会剔除 ⇒ 零信号),其余 7 项**任何时候都该关**
419
+ * (跟着文件开关忽隐忽现反而是缺陷)。⇒ 若将来真要再引入"随开关变化的屏蔽面",
420
+ * 第一个要回答的问题是"**它为什么不该一直关**"。
424
421
  */
425
- export declare function readSafeModeHiddenTools(root: string, paths?: string[]): string[];
426
422
  /**
427
423
  * 读取 CCC 声明的「轨迹默认 skill」清单(`trajectory.skills`,v1.44.0)。
428
424
  *
@@ -1,7 +1,7 @@
1
- import { d as readCccName, i as findGitRoot, l as pathInside, s as loadSerenityConfig, t as DEFAULT_SERENITY_CONFIG_PATHS } from "./ccc-x94FCzOv.js";
2
- import { u as ACC_VERSION } from "./rules-DKlpuFN_.js";
3
- import { n as readDshVersion, s as hostContractReport, y as checkRegistryQuality } from "./status-DU4k3Wqe.js";
4
- import { a as wakeSchedulerState, y as listWakes } from "./scheduler-CMBAoYR8.js";
1
+ import { d as readCccName, i as findGitRoot, l as pathInside, s as loadSerenityConfig, t as DEFAULT_SERENITY_CONFIG_PATHS } from "./ccc-DSMqTrRU.js";
2
+ import { u as ACC_VERSION } from "./rules-BYeykzys.js";
3
+ import { n as readDshVersion, s as hostContractReport, y as checkRegistryQuality } from "./status-O7MPoKFy.js";
4
+ import { a as wakeSchedulerState, y as listWakes } from "./scheduler-CgjLs5_S.js";
5
5
  import { resolve } from "node:path";
6
6
  import { existsSync, readFileSync, statSync } from "node:fs";
7
7
  //#region src/surface/observation.ts
@@ -1,5 +1,5 @@
1
1
  import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.js";
2
- import { _ as resolveInside, g as readUtf8 } from "./ccc-x94FCzOv.js";
2
+ import { g as resolveInside, h as readUtf8 } from "./ccc-DSMqTrRU.js";
3
3
  import { N as findTrajectoryFile, T as sessionsRoot, b as parseTrajectoryCode, i as listBindDeclarations, j as TRAJECTORY_FILENAME } from "./bind-file-B0TuOP89.js";
4
4
  import { join } from "node:path";
5
5
  import { readdirSync } from "node:fs";
@@ -1,6 +1,6 @@
1
1
  import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.js";
2
- import { s as loadSerenityConfig, t as DEFAULT_SERENITY_CONFIG_PATHS } from "./ccc-x94FCzOv.js";
3
- import { c as unsetEntry, l as writeEntry, r as getEntry } from "./service-Dv-8E2bI.js";
2
+ import { s as loadSerenityConfig, t as DEFAULT_SERENITY_CONFIG_PATHS } from "./ccc-DSMqTrRU.js";
3
+ import { c as unsetEntry, l as writeEntry, r as getEntry } from "./service-BRUHmVFn.js";
4
4
  import { join, resolve } from "node:path";
5
5
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
6
6
  import { createHash } from "node:crypto";
@@ -1,4 +1,4 @@
1
- import { _ as resolveInside, g as readUtf8 } from "./ccc-x94FCzOv.js";
1
+ import { g as resolveInside, h as readUtf8 } from "./ccc-DSMqTrRU.js";
2
2
  import { dirname, join } from "node:path";
3
3
  import { existsSync, readFileSync, statSync } from "node:fs";
4
4
  import { fileURLToPath } from "node:url";
@@ -1,10 +1,10 @@
1
1
  import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.js";
2
- import { c as hostAgents, o as listCccs, u as hostService } from "./ccc-roots-CsSSQjSS.js";
3
- import { _ as resolveInside } from "./ccc-x94FCzOv.js";
2
+ import { c as hostAgents, o as listCccs, u as hostService } from "./ccc-roots-CtNmjx5v.js";
3
+ import { g as resolveInside } from "./ccc-DSMqTrRU.js";
4
4
  import { F as isoLocal, L as localHuman, P as readTrajectoryFile, R as localIdStamp, T as sessionsRoot, b as parseTrajectoryCode, j as TRAJECTORY_FILENAME, k as trajectoryDescOf, p as findSession, v as namingTitleFor } from "./bind-file-B0TuOP89.js";
5
- import { c as carrierState, i as toMessage, n as deliver, r as makeInjection, s as appendBound, t as assertInjection, u as listBoundSessionIds } from "./injection-B5jZxemg.js";
6
- import { i as sessionsRootDir, n as findSessionLog, r as hasSessionLogById } from "./cleanup-CPl1SSaK.js";
7
- import { n as readSimpleSettings } from "./settings-DibHCfEU.js";
5
+ import { c as carrierState, i as toMessage, n as deliver, r as makeInjection, s as appendBound, t as assertInjection, u as listBoundSessionIds } from "./injection-CKx49Mlf.js";
6
+ import { i as sessionsRootDir, n as findSessionLog } from "./cleanup-CPl1SSaK.js";
7
+ import { i as hostAliveProbe, n as readSimpleSettings } from "./settings-CUabGkal.js";
8
8
  import { basename, dirname, join } from "node:path";
9
9
  import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, realpathSync, renameSync, statSync, writeFileSync } from "node:fs";
10
10
  import { spawn } from "node:child_process";
@@ -499,102 +499,6 @@ function deliverCarrierOpening(agent, text) {
499
499
  }
500
500
  }
501
501
  //#endregion
502
- //#region src/trajectory/alive.ts
503
- /**
504
- * trajectory/alive.ts — **"这个 dsh 会话还活着吗"的唯一判据**(owner 2026-10-20 裁决)
505
- *
506
- * ## owner 的原话(本模块的全部设计依据)
507
- *
508
- * > 「死应该包含归档判断;只有 ① 或者 ②且不在归档集 才算活」
509
- * > 「use 只要被调用了,可以无条件覆盖绑定到当前会话(这说明当前会话肯定活着啊)」
510
- *
511
- * ## 为什么必须收成一个判据(在此之前有三个互不一致的判据)
512
- *
513
- * | # | 判据 | 旧实现位置 | 单独使用时的漏洞 |
514
- * |---|---|---|---|
515
- * | ① | 进程内 loaded agent | `hostAgents(ctx).get(id)` | 冷会话全判死 |
516
- * | ② | 磁盘上有会话日志 | `hasSessionLogById()` | **归档后日志逐字节不动** ⇒ 归档会话判活 |
517
- * | ③ | 宿主归档集 | `workspaceRegistry.archivedSessionIds` | 旧 dsp **零引用**(整个仓库 0 处) |
518
- *
519
- * 宿主的归档语义是**只往集合里加一个 id、不动日志**(`dsh-workspace` 的
520
- * `archiveSession` 注释:「Archiving never touches workspace accounting」)。
521
- * ⇒ 只问 ② 的实现在归档上**必然判错**,而那个错误没有任何机械信号。
522
- *
523
- * ## 判据(owner 给定,逐字实现)
524
- *
525
- * ```text
526
- * 活 ⟺ ① (进程内 loaded ⇒ 一定在)
527
- * ∨ (② ∧ 不在归档集) (日志在、且没人把它归档掉)
528
- * ```
529
- *
530
- * 🔴 **一处对原话的收紧(必须说出来,不许默默改)**:owner 的 ① 未附加"不在归档集",
531
- * 而本模块把**归档判定排在最前** —— 即 `归档 ∧ live ⇒ 判死`。理由:归档是**人对这条会话
532
- * 的处置声明**(宿主会把它从所有分组面隐藏),若仍被当成载体,唤醒调度器会去驱动一条
533
- * **使用者以为已经收起来**的会话。⚠️ 与字面规则的差异仅此一格;`use` 不受影响
534
- * (见下方 §use 逃生门),因此真需要复活一条已归档会话时**仍然有受支持的路**。
535
- *
536
- * ## 🔴 `use` 的逃生门(owner 第二条,写在调用点)
537
- *
538
- * **`use` 不查存活**:它被调用这件事本身证明**当前会话活着**(本模块的被测对象是
539
- * "别人写的那个 id",而 `use` 手里拿的是**自己**)。⇒ `use` 走无条件覆盖
540
- * (`claimBinding` 的 `takeover`),因此**判据再严也不会把一条轨迹锁死**。
541
- * 这条逃生门是判据可以取严的前提,两者必须一起存在。
542
- *
543
- * ## 依赖纪律
544
- *
545
- * 纯判据 `isSessionAlive` 零依赖、可单测;宿主面只在 `hostAliveProbe` 里,
546
- * 且**不抛错**(服务缺失 ⇒ 该维度作废,而不是让 ACC 工具整块失败)。
547
- */
548
- /** 宿主侧的归档集读取(不可用 ⇒ 空集 = 该维度作废,**不是**把所有会话判死) */
549
- function archivedIdsOf(ctx) {
550
- try {
551
- const ids = hostService(ctx, "workspaceRegistry")?.archivedSessionIds;
552
- return new Set(Array.isArray(ids) ? ids : []);
553
- } catch {
554
- return /* @__PURE__ */ new Set();
555
- }
556
- }
557
- /**
558
- * **宿主面的判活探针**(`(sessionId) => boolean`)——所有需要"这条会话还活着吗"的
559
- * 生产代码都应当用这一个,不要自己拼 `agents.get` + `hasSessionLogById`。
560
- *
561
- * 语义 = {@link isSessionAlive},其中:
562
- * · `liveIds` 因为宿主只给 `get(id)` 而**按 id 逐次问**(不是集合);
563
- * · `archivedIds` 在**首次调用时**取一次快照并在闭包内复用(每 tick 一个探针,
564
- * 归档集在一个 tick 内不变)—— 避免为每条轨迹重复读存储域。
565
- *
566
- * ⚠️ **快照的代价**:同一探针内若有人中途归档了某会话,本探针直到下次新建才看见。
567
- * 调度器是每 tick 新建一个探针(见 `wake/scheduler.ts`),故实际窗口 ≤1 tick。
568
- *
569
- * @param ctx 插件上下文(取 `agents` 与 `workspaceRegistry`)
570
- * @returns 探针;**永不抛**
571
- */
572
- function hostAliveProbe(ctx) {
573
- let archived;
574
- const archivedOnce = () => archived ??= archivedIdsOf(ctx);
575
- return (sessionId) => {
576
- if (typeof sessionId !== "string" || sessionId === "") return false;
577
- if (archivedOnce().has(sessionId)) return false;
578
- try {
579
- if (hostAgents(ctx)?.get?.(sessionId)) return true;
580
- } catch {}
581
- try {
582
- return hasSessionLogById(sessionsRootDir(), sessionId);
583
- } catch {
584
- return true;
585
- }
586
- };
587
- }
588
- /**
589
- * 判据只有**两个**出口,别再开第三个:
590
- * · {@link isSessionAlive} —— 纯判据(给定事实),单测的靶子;
591
- * · {@link hostAliveProbe} —— 生产入口(自己去宿主与磁盘取事实)。
592
- *
593
- * ⚠️ 曾有一个 `aliveFactsFor`(把探针摊平成 `SessionAliveFacts`),**全仓零调用点**,
594
- * 已删除 —— 留一个"看起来有用、实际无人调用"的导出,会让下一个人以为存在第二条判活路径
595
- * (本仓同族教训:`cheapWorkerPresetInheritance` 全仓零调用点 ⇒ 接线断了却看不出来)。
596
- */
597
- //#endregion
598
502
  //#region src/cro/core.ts
599
503
  /**
600
504
  * cro/core.ts — CRO(Continuous Re-Occurrence · 持续再发生)机制层(S142 §7.8,2026-09-19)