@shgroup/dsh-serenity-hooks 1.79.2 → 1.79.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dsh.plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-serenity-hooks",
3
- "version": "1.79.2",
3
+ "version": "1.79.3",
4
4
  "main": "lib/index.js",
5
5
  "description": "宁静号 ACC harness(Native Cordis 插件):给 DSH 装一个「AI 工作区」——14 个工具(container_fs/cognitive_trajectory/dashboard/container_git/msm/praxis/ontology/serenity-skill-creator/cheap-worker/localstore/container_admin;另三个 im-bridge/acc-diag/diagram 按配置条件出现)+ 机械约束(安全模式/工作区围墙/密钥守卫)+ 认知轨迹日志与原地重建 + 网页登录入口/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": {
@@ -227,7 +227,7 @@ async function listCccs(ctx, opts = {}) {
227
227
  if (typeof defaultRoot === "string" && defaultRoot !== "" && !c.roots.includes(defaultRoot)) c.roots.unshift(defaultRoot);
228
228
  let rolesOf = null;
229
229
  if (opts.withRoles === true) {
230
- const { listTrajectoryConstraints } = await import("./profile-C7BuyZK7.js").then((n) => n.i);
230
+ const { listTrajectoryConstraints } = await import("./profile-5TQ_C1xi.js").then((n) => n.i);
231
231
  rolesOf = (root) => {
232
232
  try {
233
233
  return listTrajectoryConstraints(root).map((p) => p.code);
package/lib/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { i as __toESM, n as __exportAll } from "./rolldown-runtime-B4iAMlE-.js";
2
- import { c as hostInjected, d as hostSessions, f as hostSettings, h as hostWebServer, i as cccRootForExec, l as hostLlm, m as hostWeb, n as agentCwdFor, o as listCccs, p as hostSubagents, r as cccRootForCwd, s as hostAgents, t as NO_CCC_FROM_AGENT_CWD, u as hostService } from "./ccc-roots-D3ty1C8P.js";
2
+ import { c as hostInjected, d as hostSessions, f as hostSettings, h as hostWebServer, i as cccRootForExec, l as hostLlm, m as hostWeb, n as agentCwdFor, o as listCccs, p as hostSubagents, r as cccRootForCwd, s as hostAgents, t as NO_CCC_FROM_AGENT_CWD, u as hostService } from "./ccc-roots-DAwz9Li1.js";
3
3
  import { _ as resolveInside, a as findSerenityRoot$1, c as matchBlacklist, d as readCccName$1, f as readCheapWorkerConfig, h as readSafeModeHiddenTools, i as findGitRoot, l as pathInside, m as readExclusiveTools, n as SAFE_MODE_MARKER, o as isSafeModeOn, r as classifyPath, s as loadSerenityConfig, t as DEFAULT_SERENITY_CONFIG_PATHS, u as readBlacklist } from "./ccc-CyYJL4F2.js";
4
- import { A as sessionEvents, B as isoLocal, C as listSessions, E as parseTrajectoryCode, F as trajectoryDescOf, H as localHuman, I as useSession, L as TRAJECTORY_FILENAME, M as setActiveSessionInfo, N as showSession, O as readTrajectoryUid, P as summarize, R as TRAJECTORY_LEGACY_FILENAMES, S as listActiveTrajectories, T as parseSessionContextFromEvents, U as localIdStamp, V as localFileStamp, _ as createSession, a as readTrajectoryConstraintAt, b as getActiveSessionInfo, c as trajectoryConstraintForSession, f as COGNITIVE_TRAJECTORY_ACTIONS, g as clearActiveSessionInfo, h as archiveSession, j as sessionsRoot, k as resolveSessionByTitle, m as UID_FILENAME, n as isTrajectoryConstrained, o as readTrajectoryConstraintByCode, r as listTrajectoryConstraints, s as replacesDefaultIdentity, t as TRAJECTORY_CONSTRAINT_FILENAME, v as extractSessionMdPathFromText, w as namingTitleFor, y as findSession, z as readTrajectoryFile } from "./profile-C7BuyZK7.js";
4
+ import { A as sessionEvents, B as isoLocal, C as listSessions, E as parseTrajectoryCode, F as trajectoryDescOf, H as localHuman, I as useSession, L as TRAJECTORY_FILENAME, M as setActiveSessionInfo, N as showSession, O as readTrajectoryUid, P as summarize, R as TRAJECTORY_LEGACY_FILENAMES, S as listActiveTrajectories, T as parseSessionContextFromEvents, U as localIdStamp, V as localFileStamp, _ as createSession, a as readTrajectoryConstraintAt, b as getActiveSessionInfo, c as trajectoryConstraintForSession, f as COGNITIVE_TRAJECTORY_ACTIONS, g as clearActiveSessionInfo, h as archiveSession, j as sessionsRoot, k as resolveSessionByTitle, m as UID_FILENAME, n as isTrajectoryConstrained, o as readTrajectoryConstraintByCode, r as listTrajectoryConstraints, s as replacesDefaultIdentity, t as TRAJECTORY_CONSTRAINT_FILENAME, v as extractSessionMdPathFromText, w as namingTitleFor, y as findSession, z as readTrajectoryFile } from "./profile-5TQ_C1xi.js";
5
5
  import { n as checkLocalstoreGitCompliance, o as readStore, s as runLocalStore, t as LOCALSTORE_SCOPES } from "./service-DDmHSglV.js";
6
- import { _ as ACC_VERSION, a as listBoundSessionIds, d as constraintCognitiveTrajectory, f as constraintSystemPromptSource, g as resolveConstraintSystemPrompt, h as profileToolWhitelist, i as carrierState, l as TRAJECTORY_CONSTRAINT_HINT, n as PLUGIN_SOURCE, o as readLastBound, r as appendBound, s as resolveSessionCognitiveTrajectoryLabel, t as ACC_MESSAGE_KIND, v as findPackageRoot } from "./message-source-BJO5q-rD.js";
7
- import { A as buildResourceIndex, C as verifyPassword, D as recordToolUsage, E as verifyTotpCode, F as hasTrajectoryPrompt, M as isSafeSkillName, N as truncateContent, O as REFERENCE_DIR, P as TRAJECTORY_PROMPT_FILENAME, S as toWire, T as MECHANISM_PORTS, _ as registerEntrySkillSectionGlobal, a as trajectoryConstraintFor, b as projectKnownWorkspaces, c as trajectoryWorkspaceMdPath, d as CHEAP_WORKER_GUIDE, f as providerAvailabilityError, g as registerEntrySkillSection, h as registerCognitiveTrajectorySkillSection, i as getTrajectoryAgent, j as buildResourceNameSuffix, k as SKILL_ONTOLOGY_FILE, l as unregisterTrajectorySession, m as splitModel, n as createTrajectoryAgent, o as trajectoryConstraintMsmGate, p as requireWhitelistedModel, r as ensureWorkspacePromptSection, s as trajectoryConstraintParticipates, t as askTrajectory, u as workspaceCognitiveTrajectoryLine, v as applyWirePatch, w as FACE_PORTS, x as readAdvancedSettings, y as migrateLegacyLocalstore } from "./session-B4eZD3Hv.js";
6
+ import { _ as ACC_VERSION, a as listBoundSessionIds, d as constraintCognitiveTrajectory, f as constraintSystemPromptSource, g as resolveConstraintSystemPrompt, h as profileToolWhitelist, i as carrierState, l as TRAJECTORY_CONSTRAINT_HINT, n as PLUGIN_SOURCE, o as readLastBound, r as appendBound, s as resolveSessionCognitiveTrajectoryLabel, t as ACC_MESSAGE_KIND, v as findPackageRoot } from "./message-source-DK2CnXlh.js";
7
+ import { A as buildResourceIndex, C as verifyPassword, D as recordToolUsage, E as verifyTotpCode, F as hasTrajectoryPrompt, M as isSafeSkillName, N as truncateContent, O as REFERENCE_DIR, P as TRAJECTORY_PROMPT_FILENAME, S as toWire, T as MECHANISM_PORTS, _ as registerEntrySkillSectionGlobal, a as trajectoryConstraintFor, b as projectKnownWorkspaces, c as trajectoryWorkspaceMdPath, d as CHEAP_WORKER_GUIDE, f as providerAvailabilityError, g as registerEntrySkillSection, h as registerCognitiveTrajectorySkillSection, i as getTrajectoryAgent, j as buildResourceNameSuffix, k as SKILL_ONTOLOGY_FILE, l as unregisterTrajectorySession, m as splitModel, n as createTrajectoryAgent, o as trajectoryConstraintMsmGate, p as requireWhitelistedModel, r as ensureWorkspacePromptSection, s as trajectoryConstraintParticipates, t as askTrajectory, u as workspaceCognitiveTrajectoryLine, v as applyWirePatch, w as FACE_PORTS, x as readAdvancedSettings, y as migrateLegacyLocalstore } from "./session-BYC1uWi0.js";
8
8
  import { n as hasSessionLogById, r as sessionsRootDir } from "./cleanup-C-92qnDs.js";
9
- import { n as readSimpleSettings, r as registerSettingsSection } from "./settings-Bb4OnEdI.js";
9
+ import { n as readSimpleSettings, r as registerSettingsSection } from "./settings-B-vn8j4g.js";
10
10
  import { REGISTERED_TOOLS } from "./invariant.js";
11
11
  import { a as readFeishuCredential, d as weixinSessionIdForTrajectory, i as matchWeixinRoute, l as sanitizeFileName$1, n as extractWeixinText, o as readWeixinCredential, r as hasVoiceItem, s as readWeixinSettings, t as extractWeixinMedia, u as weixinInboundDir } from "./route-Dr0SFD8A.js";
12
12
  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-BMk2w2KY.js";
@@ -819,6 +819,7 @@ function runGit(root, args) {
819
819
  if (!scoped && !hasChanges(root)) return "(nothing to commit — working tree clean)";
820
820
  const addR = git(root, scoped ? [
821
821
  "add",
822
+ "-A",
822
823
  "--",
823
824
  ...paths
824
825
  ] : ["add", "-A"]);
@@ -14077,7 +14078,7 @@ function registerStatusApi(ctx, opts = {}) {
14077
14078
  });
14078
14079
  }
14079
14080
  const { saveWeixinRoutes } = await import("./route-Dr0SFD8A.js").then((n) => n.c);
14080
- const { findDirNameByCode } = await import("./profile-C7BuyZK7.js").then((n) => n.i);
14081
+ const { findDirNameByCode } = await import("./profile-5TQ_C1xi.js").then((n) => n.i);
14081
14082
  for (const r of routes) if (findDirNameByCode(root, r.trajectory) === null) {
14082
14083
  sendJson$2(res, 400, { error: `unknown trajectory: ${r.trajectory} (no such trajectory code in ${root})` });
14083
14084
  return;
@@ -19074,7 +19075,7 @@ const MEDIA_MAX_BYTES = 20971520;
19074
19075
  */
19075
19076
  async function resolveCccRootByAlias(ctx, alias) {
19076
19077
  try {
19077
- const { listCccs } = await import("./ccc-roots-D3ty1C8P.js").then((n) => n.a);
19078
+ const { listCccs } = await import("./ccc-roots-DAwz9Li1.js").then((n) => n.a);
19078
19079
  const entries = await listCccs(ctx);
19079
19080
  const byName = entries.find((e) => e.name === alias);
19080
19081
  if (byName) return byName.root;
@@ -19142,7 +19143,7 @@ async function resolveInboundTarget(ctx, input) {
19142
19143
  });
19143
19144
  return null;
19144
19145
  }
19145
- const { findDirNameByCode } = await import("./profile-C7BuyZK7.js").then((n) => n.i);
19146
+ const { findDirNameByCode } = await import("./profile-5TQ_C1xi.js").then((n) => n.i);
19146
19147
  if (findDirNameByCode(root, target.role) === null) {
19147
19148
  const detail = `目标 CCC "${target.ccc}" 内没有编码为 "${target.role}" 的认知轨迹`;
19148
19149
  console.error(`[serenity-hooks] ✗ human-channel: ${detail}(account=${input.account} user=${input.user})—— 该消息**未投递**,请改订阅表里的目标编码`);
@@ -19982,7 +19983,7 @@ function syncHumanChannel(ctx) {
19982
19983
  (async () => {
19983
19984
  try {
19984
19985
  stopMachineLoops();
19985
- const { listCccs } = await import("./ccc-roots-D3ty1C8P.js").then((n) => n.a);
19986
+ const { listCccs } = await import("./ccc-roots-DAwz9Li1.js").then((n) => n.a);
19986
19987
  for (const entry of await listCccs(ctx)) syncCccBridge(ctx, entry.root);
19987
19988
  } catch {}
19988
19989
  })();
@@ -20246,7 +20247,7 @@ function matchCcc(input, candidates) {
20246
20247
  }
20247
20248
  /** 组装候选列表(`ccc-roots.listCccs` 投影 + `.serenity` 名;动态 import 保持本模块静态依赖轻量) */
20248
20249
  async function collectCandidates(ctx) {
20249
- const { listCccs } = await import("./ccc-roots-D3ty1C8P.js").then((n) => n.a);
20250
+ const { listCccs } = await import("./ccc-roots-DAwz9Li1.js").then((n) => n.a);
20250
20251
  const entries = await listCccs(ctx, { defaultRoot: process.cwd() });
20251
20252
  const seen = /* @__PURE__ */ new Set();
20252
20253
  const out = [];
@@ -1,6 +1,6 @@
1
- import { r as cccRootForCwd } from "./ccc-roots-D3ty1C8P.js";
1
+ import { r as cccRootForCwd } from "./ccc-roots-DAwz9Li1.js";
2
2
  import { _ as resolveInside, g as readUtf8 } from "./ccc-CyYJL4F2.js";
3
- import { A as sessionEvents, E as parseTrajectoryCode, b as getActiveSessionInfo, j as sessionsRoot, x as getLastActiveSessionInfo } from "./profile-C7BuyZK7.js";
3
+ import { A as sessionEvents, E as parseTrajectoryCode, b as getActiveSessionInfo, j as sessionsRoot, x as getLastActiveSessionInfo } from "./profile-5TQ_C1xi.js";
4
4
  import { dirname, join } from "node:path";
5
5
  import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, statSync, writeFileSync } from "node:fs";
6
6
  import { fileURLToPath } from "node:url";
@@ -271,6 +271,32 @@ const ARCHIVED_DIR = "_archived";
271
271
  function sessionsRoot(root) {
272
272
  return join(root, "AGENT_SESSIONS");
273
273
  }
274
+ /** 归档区绝对路径(`<CCC>/AGENT_SESSIONS/_archived`) */
275
+ function archivedSessionsDir(sessionsDir) {
276
+ return join(sessionsDir, ARCHIVED_DIR);
277
+ }
278
+ /**
279
+ * **编码是否已被占用**(活跃区 + 归档区,**全仓**)。
280
+ *
281
+ * 🔴 为什么必须扫归档区(2026-10-20,S222 报告 / owner 转 S142 处置):
282
+ * 编码是**终身身份**(AXIOM 3),而归档只改位置、不改身份 ⇒
283
+ * 若分配器只看活跃区,归档过的码会被**重新发出**,于是同一个身份挂在两个载体上
284
+ * (实测:`S222` 活跃+归档并存;更早 `S140` 被两条轨迹共用,08-27 就登记过、一直没判据)。
285
+ * 一个可复用的身份码会让历史 `send-now` / 唤醒条目 / 文档引用**静默指向另一个对象**。
286
+ *
287
+ * ⚠️ 与 `readAllSessions` 的分工:那个函数回答"**眼下有哪些活跃轨迹**"(该跳 `_` 前缀),
288
+ * 本函数回答"**这个码有没有人用过**"(必须看全仓)。**两个问题,两个扫描域** ——
289
+ * 把它们合并成一个才是错的。
290
+ *
291
+ * @returns 撞车时返回**占用者的完整路径**(活跃区优先说明);无冲突 ⇒ `null`
292
+ */
293
+ function findCodeCollision(sessionsDir, code) {
294
+ for (const dir of [sessionsDir, archivedSessionsDir(sessionsDir)]) {
295
+ const hit = readAllSessions(dir).find((s) => parseTrajectoryCode(s.dirName) === code);
296
+ if (hit) return hit.path;
297
+ }
298
+ return null;
299
+ }
274
300
  /**
275
301
  * 解析 SESSION.md 存在性。
276
302
  *
@@ -572,10 +598,14 @@ function createSession(opts) {
572
598
  if (desc.length > 200) throw new Error(`description too long: ${desc.length} chars (max 200)`);
573
599
  const sessions = readAllSessions(sessionsDir);
574
600
  let code;
575
- if (requestedId !== void 0 && requestedId !== "") code = requestedId;
576
- else {
601
+ if (requestedId !== void 0 && requestedId !== "") {
602
+ code = requestedId;
603
+ const dup = findCodeCollision(sessionsDir, code);
604
+ if (dup !== null) throw new Error(`编码「${code}」已被占用:${dup}\n认知轨迹的编码是**终身身份**(AXIOM 3:identity = 编码),归档不会释放它 —— 归档只改位置,不改身份。
605
+ ⇒ 换一个编码(\`create --id <新码>\`),或用 \`create\` 的自动分配(会跳过全部已用码)。`);
606
+ } else {
577
607
  let maxId = 0;
578
- for (const s of sessions) {
608
+ for (const s of [...sessions, ...readAllSessions(archivedSessionsDir(sessionsDir))]) {
579
609
  const m = parseTrajectoryCode(s.dirName)?.match(/^S(\d{3,})$/);
580
610
  if (m) {
581
611
  const num = parseInt(m[1], 10);
@@ -1,8 +1,8 @@
1
- import { n as agentCwdFor, r as cccRootForCwd, s as hostAgents } from "./ccc-roots-D3ty1C8P.js";
1
+ import { n as agentCwdFor, r as cccRootForCwd, s as hostAgents } from "./ccc-roots-DAwz9Li1.js";
2
2
  import { g as readUtf8, o as isSafeModeOn, p as readCognitiveTrajectorySkills, u as readBlacklist } from "./ccc-CyYJL4F2.js";
3
- import { B as isoLocal, D as readActiveSessionMd, a as readTrajectoryConstraintAt, c as trajectoryConstraintForSession, d as unregisterTrajectorySession$1, j as sessionsRoot, l as registerTrajectorySession$1, p as DEFAULT_SESSION_SCOPE, u as trajectoryDirNameForSession } from "./profile-C7BuyZK7.js";
3
+ import { B as isoLocal, D as readActiveSessionMd, a as readTrajectoryConstraintAt, c as trajectoryConstraintForSession, d as unregisterTrajectorySession$1, j as sessionsRoot, l as registerTrajectorySession$1, p as DEFAULT_SESSION_SCOPE, u as trajectoryDirNameForSession } from "./profile-5TQ_C1xi.js";
4
4
  import { a as readGitTrack, i as localstorePath } from "./service-DDmHSglV.js";
5
- import { _ as ACC_VERSION, d as constraintCognitiveTrajectory, m as profileMsmWhitelist, n as PLUGIN_SOURCE, o as readLastBound, p as createProfilePromptReader, u as buildTrajectoryBasePrompt } from "./message-source-BJO5q-rD.js";
5
+ import { _ as ACC_VERSION, d as constraintCognitiveTrajectory, m as profileMsmWhitelist, n as PLUGIN_SOURCE, o as readLastBound, p as createProfilePromptReader, u as buildTrajectoryBasePrompt } from "./message-source-DK2CnXlh.js";
6
6
  import { basename, dirname, join, resolve } from "node:path";
7
7
  import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, statSync, writeFileSync } from "node:fs";
8
8
  import { createUserMessage } from "@deepseek-ai/dsh-llm";
@@ -1,4 +1,4 @@
1
- import { f as hostSettings } from "./ccc-roots-D3ty1C8P.js";
1
+ import { f as hostSettings } from "./ccc-roots-DAwz9Li1.js";
2
2
  //#region src/surface/settings.ts
3
3
  /**
4
4
  * 设置面板命名空间 = **profile 条目 id**(v0.1.7 起;与旧 `settings.yaml` 段名逐字相同)。
@@ -79,6 +79,24 @@ export declare function sessionEvents<T = unknown>(session: unknown): readonly T
79
79
  /** 归档区目录名(`_` 前缀 ⇒ 不是轨迹,见 readAllSessions 的跳过判据) */
80
80
  export declare const ARCHIVED_DIR = "_archived";
81
81
  export declare function sessionsRoot(root: string): string;
82
+ /** 归档区绝对路径(`<CCC>/AGENT_SESSIONS/_archived`) */
83
+ export declare function archivedSessionsDir(sessionsDir: string): string;
84
+ /**
85
+ * **编码是否已被占用**(活跃区 + 归档区,**全仓**)。
86
+ *
87
+ * 🔴 为什么必须扫归档区(2026-10-20,S222 报告 / owner 转 S142 处置):
88
+ * 编码是**终身身份**(AXIOM 3),而归档只改位置、不改身份 ⇒
89
+ * 若分配器只看活跃区,归档过的码会被**重新发出**,于是同一个身份挂在两个载体上
90
+ * (实测:`S222` 活跃+归档并存;更早 `S140` 被两条轨迹共用,08-27 就登记过、一直没判据)。
91
+ * 一个可复用的身份码会让历史 `send-now` / 唤醒条目 / 文档引用**静默指向另一个对象**。
92
+ *
93
+ * ⚠️ 与 `readAllSessions` 的分工:那个函数回答"**眼下有哪些活跃轨迹**"(该跳 `_` 前缀),
94
+ * 本函数回答"**这个码有没有人用过**"(必须看全仓)。**两个问题,两个扫描域** ——
95
+ * 把它们合并成一个才是错的。
96
+ *
97
+ * @returns 撞车时返回**占用者的完整路径**(活跃区优先说明);无冲突 ⇒ `null`
98
+ */
99
+ export declare function findCodeCollision(sessionsDir: string, code: string): string | null;
82
100
  /**
83
101
  * 轨迹的**存在形态**(🔴 **2026-10-18 起不再是"生命周期"**)。
84
102
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shgroup/dsh-serenity-hooks",
3
- "version": "1.79.2",
3
+ "version": "1.79.3",
4
4
  "description": "宁静号 ACC harness(Native Cordis 插件)——给 DeepSeek Harness 装一个「AI 工作区」:14 个工具(container_fs/cognitive_trajectory/dashboard/container_git/msm/praxis/ontology/serenity-skill-creator/cheap-worker/localstore/container_admin;另三个 im-bridge/acc-diag/diagram 按配置条件出现)+ 机械约束(安全模式/工作区围墙/密钥守卫/对外输出守卫)+ 认知轨迹日志与原地重建 + 网页登录入口/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(三档)。",
5
5
  "license": "MIT",
6
6
  "repository": {