@shgroup/dsh-serenity-hooks 1.139.2 → 1.139.4

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.139.2",
3
+ "version": "1.139.4",
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": {
@@ -682,6 +682,65 @@ function namingTitleFor(active, summary) {
682
682
  }
683
683
  return active.dirName;
684
684
  }
685
+ /**
686
+ * 是否应当**跳过**重命名(用户手改过的标题优先级最高,不覆盖)。
687
+ *
688
+ * ## 需求来源(owner 2026-11-25 原话)
689
+ *
690
+ * 「就是上下文交接以后我得重命名会被覆盖」「按理说自己重命名的应该是优先级最高的吧」
691
+ * ⇒ 用户手工起的名字**必须压过**我们按 `编号-日期-概括` 自动生成的名字。
692
+ *
693
+ * ## 为什么⛔不能直接看宿主 `source.kind === 'user'`
694
+ *
695
+ * 宿主 `sessionTitle.rename()` —— **我们自己改名走的也是它** —— 落盘的来源**恒为**
696
+ * `{ kind: 'user' }`(`dsh-session-title` 逐字:`session.append('session/title', { … source: { kind: 'user' } })`)。
697
+ * ⇒ 若把"来源=user"当作"人改的",**连我们自己每次 regenerate 都会被自己挡住**,
698
+ * 概要再也更新不了(那是把功能焊死,不是尊重用户)。
699
+ *
700
+ * ## 判据:认**形状**,不认来源
701
+ *
702
+ * 我们生成的标题必然以 `<S编号>-<日期>` 开头(无日期时以 `<S编号>` 开头)。
703
+ * ⇒ **当前标题不符合这个前缀** ⟺ 用户改过 ⟺ 不动它。
704
+ * ⇒ 符合前缀 ⇒ 那(几乎必然)是我们上一轮写的,允许用新概括覆盖。
705
+ *
706
+ * 🔴 **"读不到"≠"用户改过"**(2026-11-25 首次实现写错的地方):
707
+ * 会话**还没有标题**时(新建载体、替身服务不提供读口)⇒ 我们起**第一个**名字,
708
+ * 那是"命名"而不是"覆盖",**必须允许**。
709
+ * 把它判成"保留"会让整条命名链在服务形态不完整时**整体失效**
710
+ * (实证:一次错误收窄让 11 条既有用例全红,功能等于被自己焊死)。
711
+ *
712
+ * @param currentTitle 会话当前标题(`undefined`/空串 = 尚无标题)
713
+ * @param expectedPrefix 我们这一轮本该生成的标题前缀(`namingTitleFor` 去掉概括部分)
714
+ * @returns true = 跳过重命名(保留用户的名字);false = 可以写
715
+ */
716
+ function shouldKeepUserTitle(currentTitle, expectedPrefix) {
717
+ if (typeof currentTitle !== "string" || currentTitle.trim() === "") return false;
718
+ if (expectedPrefix === "") return false;
719
+ const t = currentTitle.trim();
720
+ if (t === expectedPrefix) return false;
721
+ return !t.startsWith(`${expectedPrefix}-`);
722
+ }
723
+ /**
724
+ * 读会话当前标题;**读口本身缺失时返回 `null`**(= 结构上无法判断,与"读到空标题"分开)。
725
+ *
726
+ * 🔴 这两种情形必须分开(2026-11-25 首次实现把它们混成一个值):
727
+ * - `null` ⇒ 宿主服务**没有读口** ⇒ 无法判断 ⇒ 调用方**按旧行为**直接写(不引入回归)
728
+ * - `''` ⇒ 读到了,但**尚无标题** ⇒ 不是覆盖 ⇒ 允许写
729
+ * @param titles 宿主 sessionTitle 服务对象(可能是替身/旧形态)
730
+ * @param session 目标会话
731
+ */
732
+ function readCurrentTitle(titles, session) {
733
+ if (!titles || typeof titles.get !== "function") return { state: "unreadable" };
734
+ try {
735
+ const snap = titles.get(session);
736
+ return {
737
+ state: "ok",
738
+ title: typeof snap?.title === "string" ? snap.title : void 0
739
+ };
740
+ } catch {
741
+ return { state: "unreadable" };
742
+ }
743
+ }
685
744
  /** 内存活跃会话:scope(dsh 会话 id)→ 会话信息(不落盘;并行多会话各自 key 隔离) */
686
745
  const activeStore = /* @__PURE__ */ new Map();
687
746
  /** 全局最近活跃(对齐 osp lastActive;供无 scope 上下文使用) */
@@ -1248,4 +1307,4 @@ function claimBinding(sessionsRoot, dirName, decl, opts = {}) {
1248
1307
  };
1249
1308
  }
1250
1309
  //#endregion
1251
- export { useSession as A, resolveSessionByTitle as C, showSession as D, setActiveSessionInfo as E, isoLocal as F, localFileStamp as I, localHuman as L, TRAJECTORY_LEGACY_FILENAMES as M, findTrajectoryFile as N, summarize as O, readTrajectoryFile as P, localIdStamp as R, readTrajectoryUid as S, sessionsRoot as T, listSessions as _, readBindDeclaration as a, parseTrajectoryCode as b, UID_FILENAME as c, createSession as d, extractSessionMdPathFromText as f, listActiveTrajectories as g, getLastActiveSessionInfo as h, listBindDeclarations as i, TRAJECTORY_FILENAME as j, trajectoryDescOf as k, archiveSession as l, getActiveSessionInfo as m, findTrajectoryHolding as n, COGNITIVE_TRAJECTORY_ACTIONS as o, findSession as p, isBindUsable as r, DEFAULT_SESSION_SCOPE as s, claimBinding as t, clearActiveSessionInfo as u, namingTitleFor as v, sessionEvents as w, readActiveSessionMd as x, parseSessionContextFromEvents as y };
1310
+ export { summarize as A, localIdStamp as B, readTrajectoryUid as C, setActiveSessionInfo as D, sessionsRoot as E, findTrajectoryFile as F, readTrajectoryFile as I, isoLocal as L, useSession as M, TRAJECTORY_FILENAME as N, shouldKeepUserTitle as O, TRAJECTORY_LEGACY_FILENAMES as P, localFileStamp as R, readCurrentTitle as S, sessionEvents as T, listSessions as _, readBindDeclaration as a, parseTrajectoryCode as b, UID_FILENAME as c, createSession as d, extractSessionMdPathFromText as f, listActiveTrajectories as g, getLastActiveSessionInfo as h, listBindDeclarations as i, trajectoryDescOf as j, showSession as k, archiveSession as l, getActiveSessionInfo as m, findTrajectoryHolding as n, COGNITIVE_TRAJECTORY_ACTIONS as o, findSession as p, isBindUsable as r, DEFAULT_SESSION_SCOPE as s, claimBinding as t, clearActiveSessionInfo as u, namingTitleFor as v, resolveSessionByTitle as w, readActiveSessionMd as x, parseSessionContextFromEvents as y, localHuman as z };
@@ -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-CRcW3ifg.js").then((n) => n.a);
238
+ const { listTrajectoryConstraints } = await import("./profile-B6H_mm98.js").then((n) => n.a);
239
239
  rolesOf = (root) => {
240
240
  try {
241
241
  return listTrajectoryConstraints(root).map((p) => p.code);
@@ -1,7 +1,7 @@
1
- import { l as hostInjected, r as cccRootForCwd, u as hostService } from "./ccc-roots-B6dJON2X.js";
1
+ import { l as hostInjected, r as cccRootForCwd, u as hostService } from "./ccc-roots-bcRvqzqJ.js";
2
2
  import { d as readCccName$1, 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-DSMqTrRU.js";
3
- import { F as isoLocal, g as listActiveTrajectories } from "./bind-file-Dy6Qmm7z.js";
4
- import { S as ACC_VERSION, o as getRestrictDiagnostics } from "./guards-is79hFAc.js";
3
+ import { L as isoLocal, g as listActiveTrajectories } from "./bind-file-BU-qo8W4.js";
4
+ import { S as ACC_VERSION, o as getRestrictDiagnostics } from "./guards-BNaxez2a.js";
5
5
  import { basename, dirname, join, relative, resolve } from "node:path";
6
6
  import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
7
7
  import { execFile, execFileSync, spawnSync } from "node:child_process";
@@ -1,7 +1,7 @@
1
- import { r as cccRootForCwd } from "./ccc-roots-B6dJON2X.js";
1
+ import { r as cccRootForCwd } from "./ccc-roots-bcRvqzqJ.js";
2
2
  import { c as matchBlacklist, d as readCccName, g as resolveInside, h as readUtf8, l as pathInside, o as isSafeModeOn, u as readBlacklist } from "./ccc-DSMqTrRU.js";
3
3
  import { c as readWeixinSettings, o as readImSettings } from "./route-BGKbuE3M.js";
4
- import { l as trajectoryCodeForSession, u as trajectoryConstraintForSession } from "./profile-CRcW3ifg.js";
4
+ import { l as trajectoryCodeForSession, u as trajectoryConstraintForSession } from "./profile-B6H_mm98.js";
5
5
  import { REGISTERED_TOOLS } from "./invariant.js";
6
6
  import { dirname, isAbsolute, join, relative, resolve } from "node:path";
7
7
  import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
@@ -22,3 +22,28 @@ export declare function __resetDisposerWarningsForTest(): void;
22
22
  * @returns 是否成功装配(false = 宿主无 `ctx.effect`,已告警)
23
23
  */
24
24
  export declare function registerDisposer(ctx: unknown, label: string, cleanup: () => void): boolean;
25
+ /**
26
+ * 把一个 HTTP 路由注册器包成「注册即撤销」。
27
+ *
28
+ * ## 为什么必须有这一层(2026-11-24 真机事故)
29
+ *
30
+ * 宿主 `WebServer.register()` 只把 disposer **返回**给调用方,**自己不代管**
31
+ * (`dsh-host-webserver` 逐字:同路径第二次注册 `throw new Error('webserver: duplicate … route')`;
32
+ * 同类的 `listen()` 反而走 `ctx.effect` ⇒ **拆卸登记是调用方的责任**)。
33
+ *
34
+ * 我们此前 11 处注册**全部丢弃返回值** ⇒ 路由挂在宿主表上、插件卸下时无人摘除。
35
+ * 后果不是"泄漏一点内存":同一进程内再装配一次就撞上那条 throw,
36
+ * 而宿主对插件抛错的处理是**整份插件判失败** ⇒ 工具面与附带服务面一起消失,
37
+ * 而宿主本身照常运行(现象:ACC「突然没了」)。
38
+ *
39
+ * ## 形态
40
+ *
41
+ * 返回一个与 `ctx.webServer` 同形的对象,`register()` 内部照旧调用真宿主并把
42
+ * disposer 交给 `registerDisposer`。既有调用点**只改传入的对象**,路由定义一个字不动。
43
+ *
44
+ * @param ctx 宿主插件上下文(交给 `registerDisposer` 登记拆卸)
45
+ * @param label 日志标签,指明是哪一面
46
+ * @param webServer 真宿主服务(可能是测试替身)
47
+ * @returns 同形对象;`effect` 不可用时仍照常注册(响亮降级,见 `registerDisposer`)
48
+ */
49
+ export declare function withRouteDisposal<T extends object>(ctx: unknown, label: string, webServer: T): T;
package/lib/index.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import { i as __toESM, n as __exportAll } from "./rolldown-runtime-B4iAMlE-.js";
2
- import { 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-B6dJON2X.js";
2
+ import { 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-bcRvqzqJ.js";
3
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
- 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, 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-Dy6Qmm7z.js";
4
+ import { A as summarize, C as readTrajectoryUid, D as setActiveSessionInfo, E as sessionsRoot, L as isoLocal, M as useSession, N as TRAJECTORY_FILENAME, O as shouldKeepUserTitle, P as TRAJECTORY_LEGACY_FILENAMES, R as localFileStamp, S as readCurrentTitle, T as sessionEvents, _ as listSessions, b as parseTrajectoryCode, c as UID_FILENAME, d as createSession, j as trajectoryDescOf, k as showSession, l as archiveSession, m as getActiveSessionInfo, o as COGNITIVE_TRAJECTORY_ACTIONS, p as findSession, u as clearActiveSessionInfo, v as namingTitleFor, w as resolveSessionByTitle, y as parseSessionContextFromEvents } from "./bind-file-BU-qo8W4.js";
5
5
  import { _ as readStore, a as readFeishuCredential, c as readWeixinSettings, d as weixinInboundDir, f as weixinSessionIdForTrajectory, i as matchWeixinRoute, m as checkLocalstoreGitCompliance, n as extractWeixinText, p as LOCALSTORE_SCOPES, r as hasVoiceItem, s as readWeixinCredential, t as extractWeixinMedia, u as sanitizeFileName$1, v as runLocalStore } from "./route-BGKbuE3M.js";
6
- import { C as findPackageRoot, S as ACC_VERSION, _ as constraintCognitiveTrajectory, d as imChannelIds, f as isImWiredTrajectory, h as TRAJECTORY_CONSTRAINT_HINT, i as forgetNonCccToolVisibility, l as syncToolVisibility, m as runImBridge, p as registerImChannel, s as registerGuards, u as forgetToolVisibility, v as constraintSystemPromptSource, x as resolveConstraintSystemPrompt } from "./guards-is79hFAc.js";
7
- import { a as setSafeMode, c as ACC_CATALOG, d as findEntry, f as loadMsmEntries, g as setWeixinSendEndpoint, h as docsPointer, i as readDshVersion, l as CCC_CONFIG_REFERENCE, m as runMsmAsync, n as summarizeHostContract, o as listOpencodeSkillDirs, p as runMsm, r as getStatus, s as loadOpencodeSkill, t as hostContractReport } from "./contract-DXaIXQvh.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-CRcW3ifg.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-BTOngenk.js";
10
- import { 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-ME-aoZVl.js";
11
- import { c as buildCroSnapshot, d as WAKE_CATCH_UP_MS, f as addWake, i as sendToCognitiveTrajectory, n as registerWakeScheduler, o as registerCroTurnTracking, s as registerDisposer, t as createAndBindTarget, u as CARRIER_OPENING_MARK } from "./scheduler-pOtONqPy.js";
12
- import { i as hostAliveProbe, n as readSimpleSettings, r as registerSettingsSection } from "./settings-YC-csZus.js";
13
- import { a as ACK_PREFIX, c as eventToken, i as resolveSessionMdPath, l as DEFAULT_FAKE_INITIAL_MESSAGES, o as ASSISTANT_PREFIX, r as registerRebuildTurnHook, s as LOG_FILE_REL, t as buildRebuildAnchor, u as registerBootstrap } from "./rebuild-bySH_ZPq.js";
14
- import { i as subscriptionStats, n as registerTrajectorySubscriptions, r as subscriptionEval, t as defaultSubscriptionDeps } from "./subscriptions-DBoO0GSO.js";
6
+ import { C as findPackageRoot, S as ACC_VERSION, _ as constraintCognitiveTrajectory, d as imChannelIds, f as isImWiredTrajectory, h as TRAJECTORY_CONSTRAINT_HINT, i as forgetNonCccToolVisibility, l as syncToolVisibility, m as runImBridge, p as registerImChannel, s as registerGuards, u as forgetToolVisibility, v as constraintSystemPromptSource, x as resolveConstraintSystemPrompt } from "./guards-BNaxez2a.js";
7
+ import { a as setSafeMode, c as ACC_CATALOG, d as findEntry, f as loadMsmEntries, g as setWeixinSendEndpoint, h as docsPointer, i as readDshVersion, l as CCC_CONFIG_REFERENCE, m as runMsmAsync, n as summarizeHostContract, o as listOpencodeSkillDirs, p as runMsm, r as getStatus, s as loadOpencodeSkill, t as hostContractReport } from "./contract-Cj2msyTr.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-B6H_mm98.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-CVLuxABj.js";
10
+ import { 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-DGN8AyPT.js";
11
+ import { c as withRouteDisposal, d as CARRIER_OPENING_MARK, f as WAKE_CATCH_UP_MS, i as sendToCognitiveTrajectory, l as buildCroSnapshot, n as registerWakeScheduler, o as registerCroTurnTracking, p as addWake, s as registerDisposer, t as createAndBindTarget } from "./scheduler-DeRr-7uf.js";
12
+ import { i as hostAliveProbe, n as readSimpleSettings, r as registerSettingsSection } from "./settings-e3pTbQ4_.js";
13
+ import { a as ACK_PREFIX, c as eventToken, i as resolveSessionMdPath, l as DEFAULT_FAKE_INITIAL_MESSAGES, o as ASSISTANT_PREFIX, r as registerRebuildTurnHook, s as LOG_FILE_REL, t as buildRebuildAnchor, u as registerBootstrap } from "./rebuild-DRVxdLeL.js";
14
+ import { i as subscriptionStats, n as registerTrajectorySubscriptions, r as subscriptionEval, t as defaultSubscriptionDeps } from "./subscriptions-CsHUgUeY.js";
15
15
  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";
16
16
  import { a as registerImAccountImpl, i as normalizeAccountChannel, n as getImAccountImpl, r as imAccountChannels } from "./accounts-BHQbakUh.js";
17
17
  import { createRequire } from "node:module";
@@ -512,7 +512,7 @@ const KIT_ACTIONS = [
512
512
  async function runKit(root, args, hostCtx) {
513
513
  switch (args.action) {
514
514
  case "health": {
515
- const { containerStatus } = await import("./observation-BMS74GF_.js");
515
+ const { containerStatus } = await import("./observation-D1llub54.js");
516
516
  const s = containerStatus({
517
517
  root,
518
518
  hostCtx
@@ -558,7 +558,7 @@ async function runKit(root, args, hostCtx) {
558
558
  }
559
559
  case "diag": {
560
560
  if (hostCtx === void 0) throw new Error("diag requires the plugin context (live session data unavailable without it)");
561
- const { runDiag, renderDiag } = await import("./service-BYIKwXsG.js");
561
+ const { runDiag, renderDiag } = await import("./service-BVPfj2rn.js");
562
562
  return renderDiag(await runDiag(hostCtx, root ?? ""));
563
563
  }
564
564
  default: throw new Error(`Unknown action: ${args.action}`);
@@ -6415,6 +6415,13 @@ function renameDshSessionOnUse(deps, session, titles, active, summary) {
6415
6415
  reason: "sessionTitle service unavailable"
6416
6416
  };
6417
6417
  const title = namingTitleFor(active, summary);
6418
+ const prefix = namingTitleFor(active);
6419
+ const read = readCurrentTitle(titles, session);
6420
+ if (read.state === "ok" && shouldKeepUserTitle(read.title, prefix)) return {
6421
+ ok: true,
6422
+ title: read.title ?? "",
6423
+ kept: true
6424
+ };
6418
6425
  try {
6419
6426
  titles.rename(session, title);
6420
6427
  return {
@@ -6445,7 +6452,8 @@ function renameDshSessionForActive(ctx, exec, info, summary) {
6445
6452
  return;
6446
6453
  }
6447
6454
  const result = renameDshSessionOnUse({ sessionTitleAvailable: true }, dshSession, titles, info, summary);
6448
- if (result.ok) console.log(`[serenity-hooks] dsh 会话已重命名: ${String(dshSession.id ?? "?")} → ${result.title}`);
6455
+ if (result.ok && result.kept) console.log(`[serenity-hooks] 保留用户自定义标题,不覆盖: ${result.title}`);
6456
+ else if (result.ok) console.log(`[serenity-hooks] dsh 会话已重命名: ${String(dshSession.id ?? "?")} → ${result.title}`);
6449
6457
  else console.warn(`[serenity-hooks] dsh 会话重命名未执行: ${result.reason}`);
6450
6458
  } catch (err) {
6451
6459
  console.warn(`[serenity-hooks] dsh 会话重命名异常: ${String(err?.message ?? err)}`);
@@ -6698,7 +6706,7 @@ function createCognitiveTrajectoryTool(ctx) {
6698
6706
  } catch {}
6699
6707
  }
6700
6708
  }
6701
- const { queueRebuild } = await import("./rebuild-bySH_ZPq.js").then((n) => n.n);
6709
+ const { queueRebuild } = await import("./rebuild-DRVxdLeL.js").then((n) => n.n);
6702
6710
  const result = await queueRebuild(ctx, {
6703
6711
  root,
6704
6712
  note: args.note,
@@ -9672,7 +9680,8 @@ function resolveWorkspace(ctx, params) {
9672
9680
  }
9673
9681
  function registerStatusApi(ctx, opts = {}) {
9674
9682
  const configPaths = opts.configPaths ?? DEFAULT_SERENITY_CONFIG_PATHS;
9675
- ctx.webServer.register({
9683
+ const webServer = withRouteDisposal(ctx, "serenity status api routes", ctx.webServer);
9684
+ webServer.register({
9676
9685
  kind: "exact",
9677
9686
  path: UPLOAD_PATH,
9678
9687
  handler: async (req, res) => {
@@ -9699,7 +9708,7 @@ function registerStatusApi(ctx, opts = {}) {
9699
9708
  }
9700
9709
  }
9701
9710
  });
9702
- ctx.webServer.register({
9711
+ webServer.register({
9703
9712
  kind: "exact",
9704
9713
  path: FILE_UPLOAD_PATH,
9705
9714
  handler: async (req, res) => {
@@ -9726,7 +9735,7 @@ function registerStatusApi(ctx, opts = {}) {
9726
9735
  }
9727
9736
  }
9728
9737
  });
9729
- ctx.webServer.register({
9738
+ webServer.register({
9730
9739
  kind: "exact",
9731
9740
  path: ROUTE_PATH,
9732
9741
  handler: async (req, res) => {
@@ -9775,7 +9784,7 @@ function registerStatusApi(ctx, opts = {}) {
9775
9784
  }
9776
9785
  }
9777
9786
  });
9778
- ctx.webServer.register({
9787
+ webServer.register({
9779
9788
  kind: "exact",
9780
9789
  path: CONFIG_PATH,
9781
9790
  handler: async (req, res) => {
@@ -9810,7 +9819,7 @@ function registerStatusApi(ctx, opts = {}) {
9810
9819
  }
9811
9820
  }
9812
9821
  });
9813
- ctx.webServer.register({
9822
+ webServer.register({
9814
9823
  kind: "exact",
9815
9824
  path: CCCS_PATH,
9816
9825
  handler: async (req, res) => {
@@ -9834,7 +9843,7 @@ function registerStatusApi(ctx, opts = {}) {
9834
9843
  }
9835
9844
  }
9836
9845
  });
9837
- ctx.webServer.register({
9846
+ webServer.register({
9838
9847
  kind: "exact",
9839
9848
  path: SUBSCRIPTIONS_PATH,
9840
9849
  handler: async (req, res) => {
@@ -9871,7 +9880,7 @@ function registerStatusApi(ctx, opts = {}) {
9871
9880
  }
9872
9881
  }
9873
9882
  });
9874
- ctx.webServer.register({
9883
+ webServer.register({
9875
9884
  kind: "exact",
9876
9885
  path: WEIXIN_PATH,
9877
9886
  handler: async (req, res) => {
@@ -9973,7 +9982,7 @@ function registerStatusApi(ctx, opts = {}) {
9973
9982
  });
9974
9983
  }
9975
9984
  const { saveWeixinRoutes } = await import("./route-BGKbuE3M.js").then((n) => n.l);
9976
- const { findDirNameByCode } = await import("./profile-CRcW3ifg.js").then((n) => n.a);
9985
+ const { findDirNameByCode } = await import("./profile-B6H_mm98.js").then((n) => n.a);
9977
9986
  for (const r of routes) if (findDirNameByCode(root, r.trajectory) === null) {
9978
9987
  sendJson$2(res, 400, { error: `unknown trajectory: ${r.trajectory} (no such trajectory code in ${root})` });
9979
9988
  return;
@@ -10035,7 +10044,7 @@ function registerStatusApi(ctx, opts = {}) {
10035
10044
  }
10036
10045
  }
10037
10046
  });
10038
- ctx.webServer.register({
10047
+ webServer.register({
10039
10048
  kind: "exact",
10040
10049
  path: `${WEIXIN_PATH}/login`,
10041
10050
  handler: async (req, res) => {
@@ -10107,7 +10116,7 @@ function registerStatusApi(ctx, opts = {}) {
10107
10116
  }
10108
10117
  }
10109
10118
  });
10110
- ctx.webServer.register({
10119
+ webServer.register({
10111
10120
  kind: "exact",
10112
10121
  path: "/serenity/session-cleanup",
10113
10122
  handler: async (req, res) => {
@@ -10369,7 +10378,7 @@ function sendJson$1(res, status, body) {
10369
10378
  * 显示的还是 home-serenity 的信息」)。不传 ⇒ 不注入(保持资产原样 = 旧行为)。
10370
10379
  */
10371
10380
  function registerVoyageApi(ctx, opts = {}) {
10372
- ctx.webServer.register({
10381
+ withRouteDisposal(ctx, "serenity voyage api route", ctx.webServer).register({
10373
10382
  kind: "exact",
10374
10383
  path: VOYAGE_PATH,
10375
10384
  handler: (req, res) => {
@@ -14337,7 +14346,7 @@ const MEDIA_MAX_BYTES = 20971520;
14337
14346
  */
14338
14347
  async function resolveCccRootByAlias(ctx, alias) {
14339
14348
  try {
14340
- const { listCccs } = await import("./ccc-roots-B6dJON2X.js").then((n) => n.a);
14349
+ const { listCccs } = await import("./ccc-roots-bcRvqzqJ.js").then((n) => n.a);
14341
14350
  const entries = await listCccs(ctx);
14342
14351
  const byName = entries.find((e) => e.name === alias);
14343
14352
  if (byName) return byName.root;
@@ -14405,7 +14414,7 @@ async function resolveInboundTarget(ctx, input) {
14405
14414
  });
14406
14415
  return null;
14407
14416
  }
14408
- const { findDirNameByCode } = await import("./profile-CRcW3ifg.js").then((n) => n.a);
14417
+ const { findDirNameByCode } = await import("./profile-B6H_mm98.js").then((n) => n.a);
14409
14418
  if (findDirNameByCode(root, target.role) === null) {
14410
14419
  const detail = `目标 CCC "${target.ccc}" 内没有编码为 "${target.role}" 的认知轨迹`;
14411
14420
  console.error(`[serenity-hooks] ✗ human-channel: ${detail}(account=${input.account} user=${input.user})—— 该消息**未投递**,请改订阅表里的目标编码`);
@@ -15415,7 +15424,7 @@ function syncHumanChannel(ctx) {
15415
15424
  (async () => {
15416
15425
  try {
15417
15426
  stopMachineLoops();
15418
- const { listCccs } = await import("./ccc-roots-B6dJON2X.js").then((n) => n.a);
15427
+ const { listCccs } = await import("./ccc-roots-bcRvqzqJ.js").then((n) => n.a);
15419
15428
  for (const entry of await listCccs(ctx)) syncCccBridge(ctx, entry.root);
15420
15429
  } catch {}
15421
15430
  })();
@@ -15708,7 +15717,7 @@ function matchCcc(input, candidates) {
15708
15717
  }
15709
15718
  /** 组装候选列表(`ccc-roots.listCccs` 投影 + `.serenity` 名;动态 import 保持本模块静态依赖轻量) */
15710
15719
  async function collectCandidates(ctx) {
15711
- const { listCccs } = await import("./ccc-roots-B6dJON2X.js").then((n) => n.a);
15720
+ const { listCccs } = await import("./ccc-roots-bcRvqzqJ.js").then((n) => n.a);
15712
15721
  const entries = await listCccs(ctx, { defaultRoot: process.cwd() });
15713
15722
  const seen = /* @__PURE__ */ new Set();
15714
15723
  const out = [];
@@ -1,5 +1,5 @@
1
- import { r as cccRootForCwd } from "./ccc-roots-B6dJON2X.js";
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-Dy6Qmm7z.js";
1
+ import { r as cccRootForCwd } from "./ccc-roots-bcRvqzqJ.js";
2
+ import { E as sessionsRoot, T as sessionEvents, a as readBindDeclaration, b as parseTrajectoryCode, h as getLastActiveSessionInfo, i as listBindDeclarations, m as getActiveSessionInfo, n as findTrajectoryHolding, r as isBindUsable, t as claimBinding } from "./bind-file-BU-qo8W4.js";
3
3
  import { join } from "node:path";
4
4
  import { createUserMessage } from "@deepseek-ai/dsh-llm";
5
5
  //#region src/trajectory/bound.ts
@@ -1,7 +1,7 @@
1
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 { S as ACC_VERSION } from "./guards-is79hFAc.js";
3
- import { i as readDshVersion, t as hostContractReport, u as checkRegistryQuality } from "./contract-DXaIXQvh.js";
4
- import { a as wakeSchedulerState, p as listWakes } from "./scheduler-pOtONqPy.js";
2
+ import { S as ACC_VERSION } from "./guards-BNaxez2a.js";
3
+ import { i as readDshVersion, t as hostContractReport, u as checkRegistryQuality } from "./contract-Cj2msyTr.js";
4
+ import { a as wakeSchedulerState, m as listWakes } from "./scheduler-DeRr-7uf.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,6 +1,6 @@
1
1
  import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.js";
2
2
  import { g as resolveInside, h as readUtf8 } from "./ccc-DSMqTrRU.js";
3
- import { N as findTrajectoryFile, T as sessionsRoot, b as parseTrajectoryCode, i as listBindDeclarations, j as TRAJECTORY_FILENAME } from "./bind-file-Dy6Qmm7z.js";
3
+ import { E as sessionsRoot, F as findTrajectoryFile, N as TRAJECTORY_FILENAME, b as parseTrajectoryCode, i as listBindDeclarations } from "./bind-file-BU-qo8W4.js";
4
4
  import { join } from "node:path";
5
5
  import { readdirSync } from "node:fs";
6
6
  //#region src/trajectory/policy/window.ts
@@ -1,9 +1,9 @@
1
1
  import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.js";
2
- import { n as agentCwdFor, r as cccRootForCwd, u as hostService } from "./ccc-roots-B6dJON2X.js";
3
- import { F as isoLocal, b as parseTrajectoryCode, f as extractSessionMdPathFromText, m as getActiveSessionInfo, v as namingTitleFor, w as sessionEvents, y as parseSessionContextFromEvents } from "./bind-file-Dy6Qmm7z.js";
4
- import { c as replacesDefaultIdentity } from "./profile-CRcW3ifg.js";
5
- import { a as trajectoryConstraintFor } from "./session-BTOngenk.js";
6
- import { a as ACC_MESSAGE_KIND, d as readLastBound, n as deliver, r as makeInjection, s as appendBound } from "./injection-ME-aoZVl.js";
2
+ import { n as agentCwdFor, r as cccRootForCwd, u as hostService } from "./ccc-roots-bcRvqzqJ.js";
3
+ import { L as isoLocal, O as shouldKeepUserTitle, S as readCurrentTitle, T as sessionEvents, b as parseTrajectoryCode, f as extractSessionMdPathFromText, m as getActiveSessionInfo, v as namingTitleFor, y as parseSessionContextFromEvents } from "./bind-file-BU-qo8W4.js";
4
+ import { c as replacesDefaultIdentity } from "./profile-B6H_mm98.js";
5
+ import { a as trajectoryConstraintFor } from "./session-CVLuxABj.js";
6
+ import { a as ACC_MESSAGE_KIND, d as readLastBound, n as deliver, r as makeInjection, s as appendBound } from "./injection-DGN8AyPT.js";
7
7
  import { basename, dirname, join, resolve } from "node:path";
8
8
  import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, statSync, writeFileSync } from "node:fs";
9
9
  import { deriveEventMessage } from "@deepseek-ai/dsh-session";
@@ -1102,6 +1102,12 @@ function renameAfterRebuild(ctx, agent, pending) {
1102
1102
  console.warn("[serenity-hooks] rebuild 后重命名跳过: sessionTitle 服务不可用");
1103
1103
  return;
1104
1104
  }
1105
+ const prefix = namingTitleFor(info);
1106
+ const read = readCurrentTitle(titles, agent.session);
1107
+ if (read.state === "ok" && shouldKeepUserTitle(read.title, prefix)) {
1108
+ console.log(`[serenity-hooks] rebuild 后保留用户自定义标题,不覆盖: ${read.title ?? ""}`);
1109
+ return;
1110
+ }
1105
1111
  titles.rename(agent.session, title);
1106
1112
  console.log(`[serenity-hooks] rebuild 后会话重命名: ${agent.id} → ${title}`);
1107
1113
  } catch (error) {
@@ -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-B6dJON2X.js";
2
+ import { c as hostAgents, o as listCccs, u as hostService } from "./ccc-roots-bcRvqzqJ.js";
3
3
  import { g as resolveInside } from "./ccc-DSMqTrRU.js";
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-Dy6Qmm7z.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-ME-aoZVl.js";
4
+ import { B as localIdStamp, E as sessionsRoot, I as readTrajectoryFile, L as isoLocal, N as TRAJECTORY_FILENAME, O as shouldKeepUserTitle, S as readCurrentTitle, b as parseTrajectoryCode, j as trajectoryDescOf, p as findSession, v as namingTitleFor, z as localHuman } from "./bind-file-BU-qo8W4.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-DGN8AyPT.js";
6
6
  import { i as sessionsRootDir, n as findSessionLog } from "./cleanup-CPl1SSaK.js";
7
- import { i as hostAliveProbe, n as readSimpleSettings } from "./settings-YC-csZus.js";
7
+ import { i as hostAliveProbe, n as readSimpleSettings } from "./settings-e3pTbQ4_.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";
@@ -1167,6 +1167,49 @@ function registerDisposer(ctx, label, cleanup) {
1167
1167
  return false;
1168
1168
  }
1169
1169
  }
1170
+ /**
1171
+ * 把一个 HTTP 路由注册器包成「注册即撤销」。
1172
+ *
1173
+ * ## 为什么必须有这一层(2026-11-24 真机事故)
1174
+ *
1175
+ * 宿主 `WebServer.register()` 只把 disposer **返回**给调用方,**自己不代管**
1176
+ * (`dsh-host-webserver` 逐字:同路径第二次注册 `throw new Error('webserver: duplicate … route')`;
1177
+ * 同类的 `listen()` 反而走 `ctx.effect` ⇒ **拆卸登记是调用方的责任**)。
1178
+ *
1179
+ * 我们此前 11 处注册**全部丢弃返回值** ⇒ 路由挂在宿主表上、插件卸下时无人摘除。
1180
+ * 后果不是"泄漏一点内存":同一进程内再装配一次就撞上那条 throw,
1181
+ * 而宿主对插件抛错的处理是**整份插件判失败** ⇒ 工具面与附带服务面一起消失,
1182
+ * 而宿主本身照常运行(现象:ACC「突然没了」)。
1183
+ *
1184
+ * ## 形态
1185
+ *
1186
+ * 返回一个与 `ctx.webServer` 同形的对象,`register()` 内部照旧调用真宿主并把
1187
+ * disposer 交给 `registerDisposer`。既有调用点**只改传入的对象**,路由定义一个字不动。
1188
+ *
1189
+ * @param ctx 宿主插件上下文(交给 `registerDisposer` 登记拆卸)
1190
+ * @param label 日志标签,指明是哪一面
1191
+ * @param webServer 真宿主服务(可能是测试替身)
1192
+ * @returns 同形对象;`effect` 不可用时仍照常注册(响亮降级,见 `registerDisposer`)
1193
+ */
1194
+ function withRouteDisposal(ctx, label, webServer) {
1195
+ const real = webServer;
1196
+ const disposers = [];
1197
+ registerDisposer(ctx, label, () => {
1198
+ for (let i = disposers.length - 1; i >= 0; i--) try {
1199
+ disposers[i]?.();
1200
+ } catch (err) {
1201
+ console.warn(`[serenity-hooks] ✗ 路由摘除失败(${label} #${i}): ${String(err?.message ?? err)}`);
1202
+ }
1203
+ disposers.length = 0;
1204
+ });
1205
+ const proxy = Object.create(webServer);
1206
+ proxy.register = ((route) => {
1207
+ const dispose = real.register(route);
1208
+ if (typeof dispose === "function") disposers.push(dispose);
1209
+ return dispose;
1210
+ });
1211
+ return proxy;
1212
+ }
1170
1213
  //#endregion
1171
1214
  //#region src/cro/turns.ts
1172
1215
  /**
@@ -3234,12 +3277,15 @@ function renameCarrierTitle(ctx, agent, root, dirName) {
3234
3277
  if (!titles || typeof titles.rename !== "function") return ", ⚠️ 标题未写(sessionTitle 不可用)";
3235
3278
  const session = agent.session;
3236
3279
  if (!session || typeof session !== "object") return ", ⚠️ 标题未写(无 session)";
3237
- const title = namingTitleFor({
3280
+ const info = {
3238
3281
  sessionId: parseTrajectoryCode(dirName) ?? dirName,
3239
3282
  dirName,
3240
3283
  mdPath: join(root, "AGENT_SESSIONS", dirName, "SESSION.md")
3241
- });
3242
- titles.rename(session, title);
3284
+ };
3285
+ const prefix = namingTitleFor(info);
3286
+ const read = readCurrentTitle(titles, session);
3287
+ if (read.state === "ok" && shouldKeepUserTitle(read.title, prefix)) return ", 保留用户标题";
3288
+ titles.rename(session, namingTitleFor(info));
3243
3289
  return ", titled";
3244
3290
  } catch (err) {
3245
3291
  return `, ⚠️ 标题未写(${String(err?.message ?? err)})`;
@@ -3787,4 +3833,4 @@ function registerWakeScheduler(ctx) {
3787
3833
  registerDisposer(ctx, "认知轨迹唤醒调度器", () => clock.dispose());
3788
3834
  }
3789
3835
  //#endregion
3790
- export { wakeSchedulerState as a, buildCroSnapshot as c, WAKE_CATCH_UP_MS as d, addWake as f, sendToCognitiveTrajectory as i, listCroCognitiveTrajectories as l, registerWakeScheduler as n, registerCroTurnTracking as o, listWakes as p, scheduler_exports as r, registerDisposer as s, createAndBindTarget as t, CARRIER_OPENING_MARK as u };
3836
+ export { wakeSchedulerState as a, withRouteDisposal as c, CARRIER_OPENING_MARK as d, WAKE_CATCH_UP_MS as f, sendToCognitiveTrajectory as i, buildCroSnapshot as l, listWakes as m, registerWakeScheduler as n, registerCroTurnTracking as o, addWake as p, scheduler_exports as r, registerDisposer as s, createAndBindTarget as t, listCroCognitiveTrajectories as u };
@@ -1,10 +1,10 @@
1
- import { d as hostSessions, r as cccRootForCwd } from "./ccc-roots-B6dJON2X.js";
1
+ import { d as hostSessions, r as cccRootForCwd } from "./ccc-roots-bcRvqzqJ.js";
2
2
  import { p as readTrajectorySubscriptions } from "./ccc-DSMqTrRU.js";
3
- import { F as isoLocal, w as sessionEvents } from "./bind-file-Dy6Qmm7z.js";
4
- import { d as WAKE_CATCH_UP_MS, l as listCroCognitiveTrajectories } from "./scheduler-pOtONqPy.js";
5
- import { n as readSimpleSettings } from "./settings-YC-csZus.js";
6
- import { i as subscriptionStats, r as subscriptionEval } from "./subscriptions-DBoO0GSO.js";
7
- import { containerClocks, containerWakes } from "./observation-BMS74GF_.js";
3
+ import { L as isoLocal, T as sessionEvents } from "./bind-file-BU-qo8W4.js";
4
+ import { f as WAKE_CATCH_UP_MS, u as listCroCognitiveTrajectories } from "./scheduler-DeRr-7uf.js";
5
+ import { n as readSimpleSettings } from "./settings-e3pTbQ4_.js";
6
+ import { i as subscriptionStats, r as subscriptionEval } from "./subscriptions-CsHUgUeY.js";
7
+ import { containerClocks, containerWakes } from "./observation-D1llub54.js";
8
8
  //#region src/trajectory/live.ts
9
9
  /**
10
10
  * trajectory/live.ts — 进程内 live 会话取数 + 精简诊断
@@ -1,10 +1,10 @@
1
- import { c as hostAgents, n as agentCwdFor, r as cccRootForCwd, s as hostAgentDefaultModel } from "./ccc-roots-B6dJON2X.js";
1
+ import { c as hostAgents, n as agentCwdFor, r as cccRootForCwd, s as hostAgentDefaultModel } from "./ccc-roots-bcRvqzqJ.js";
2
2
  import { f as readCognitiveTrajectorySkills, h as readUtf8, o as isSafeModeOn, u as readBlacklist } from "./ccc-DSMqTrRU.js";
3
- import { F as isoLocal, T as sessionsRoot, s as DEFAULT_SESSION_SCOPE, x as readActiveSessionMd } from "./bind-file-Dy6Qmm7z.js";
3
+ import { E as sessionsRoot, L as isoLocal, s as DEFAULT_SESSION_SCOPE, x as readActiveSessionMd } from "./bind-file-BU-qo8W4.js";
4
4
  import { g as readGitTrack, h as localstorePath } from "./route-BGKbuE3M.js";
5
- import { S as ACC_VERSION, _ as constraintCognitiveTrajectory, b as profileMsmWhitelist, c as shellToolNameFor, g as buildTrajectoryBasePrompt, y as createProfilePromptReader } from "./guards-is79hFAc.js";
6
- import { d as registerTrajectorySession$1, f as trajectoryDirNameForSession, o as readTrajectoryConstraintAt, p as unregisterTrajectorySession$1, u as trajectoryConstraintForSession } from "./profile-CRcW3ifg.js";
7
- import { d as readLastBound, i as toMessage, r as makeInjection } from "./injection-ME-aoZVl.js";
5
+ import { S as ACC_VERSION, _ as constraintCognitiveTrajectory, b as profileMsmWhitelist, c as shellToolNameFor, g as buildTrajectoryBasePrompt, y as createProfilePromptReader } from "./guards-BNaxez2a.js";
6
+ import { d as registerTrajectorySession$1, f as trajectoryDirNameForSession, o as readTrajectoryConstraintAt, p as unregisterTrajectorySession$1, u as trajectoryConstraintForSession } from "./profile-B6H_mm98.js";
7
+ import { d as readLastBound, i as toMessage, r as makeInjection } from "./injection-DGN8AyPT.js";
8
8
  import { basename, dirname, join, resolve } from "node:path";
9
9
  import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, statSync, writeFileSync } from "node:fs";
10
10
  import { createHmac, randomBytes, randomUUID, scryptSync } from "node:crypto";
@@ -1,4 +1,4 @@
1
- import { c as hostAgents, f as hostSettings, u as hostService } from "./ccc-roots-B6dJON2X.js";
1
+ import { c as hostAgents, f as hostSettings, u as hostService } from "./ccc-roots-bcRvqzqJ.js";
2
2
  import { i as sessionsRootDir, r as hasSessionLogById } from "./cleanup-CPl1SSaK.js";
3
3
  //#region src/trajectory/alive.ts
4
4
  /**
@@ -1,7 +1,7 @@
1
- import { r as cccRootForCwd } from "./ccc-roots-B6dJON2X.js";
1
+ import { r as cccRootForCwd } from "./ccc-roots-bcRvqzqJ.js";
2
2
  import { p as readTrajectorySubscriptions } from "./ccc-DSMqTrRU.js";
3
- import { L as localHuman, n as findTrajectoryHolding } from "./bind-file-Dy6Qmm7z.js";
4
- import { s as registerDisposer } from "./scheduler-pOtONqPy.js";
3
+ import { n as findTrajectoryHolding, z as localHuman } from "./bind-file-BU-qo8W4.js";
4
+ import { s as registerDisposer } from "./scheduler-DeRr-7uf.js";
5
5
  //#region src/trajectory/subscriptions.ts
6
6
  /**
7
7
  * trajectory/subscriptions.ts — 轨迹消息订阅(v1.107.0,owner 2026-11-01 令)
@@ -306,7 +306,7 @@ function defaultSubscriptionDeps(ctx) {
306
306
  readSubs: (root) => readTrajectorySubscriptions(root),
307
307
  dirForSession: (root, sessionId) => findTrajectoryHolding(`${root}/AGENT_SESSIONS`, sessionId),
308
308
  deliver: async (root, target, message) => {
309
- const { sendToCognitiveTrajectory } = await import("./scheduler-pOtONqPy.js").then((n) => n.r);
309
+ const { sendToCognitiveTrajectory } = await import("./scheduler-DeRr-7uf.js").then((n) => n.r);
310
310
  const res = await sendToCognitiveTrajectory(ctx, root, target, message, "trajectory-subscription");
311
311
  return {
312
312
  ok: res.ok,
@@ -61,9 +61,17 @@ interface RenameOnUseDeps {
61
61
  */
62
62
  export declare function renameDshSessionOnUse(deps: RenameOnUseDeps, session: unknown, titles: {
63
63
  rename: (session: unknown, title: string) => unknown;
64
+ get?: (session: unknown) => {
65
+ title?: unknown;
66
+ } | undefined;
64
67
  } | undefined, active: ActiveSessionInfo, summary?: string): {
65
68
  ok: true;
66
69
  title: string;
70
+ kept?: false;
71
+ } | {
72
+ ok: true;
73
+ title: string;
74
+ kept: true;
67
75
  } | {
68
76
  ok: false;
69
77
  reason: string;
@@ -310,6 +310,57 @@ export declare function sanitizeSessionSummary(summary: string): string;
310
310
  * @returns `S143-2026-08-26-概括` / `S143-2026-08-26` / 原目录名
311
311
  */
312
312
  export declare function namingTitleFor(active: ActiveSessionInfo, summary?: string): string;
313
+ /**
314
+ * 是否应当**跳过**重命名(用户手改过的标题优先级最高,不覆盖)。
315
+ *
316
+ * ## 需求来源(owner 2026-11-25 原话)
317
+ *
318
+ * 「就是上下文交接以后我得重命名会被覆盖」「按理说自己重命名的应该是优先级最高的吧」
319
+ * ⇒ 用户手工起的名字**必须压过**我们按 `编号-日期-概括` 自动生成的名字。
320
+ *
321
+ * ## 为什么⛔不能直接看宿主 `source.kind === 'user'`
322
+ *
323
+ * 宿主 `sessionTitle.rename()` —— **我们自己改名走的也是它** —— 落盘的来源**恒为**
324
+ * `{ kind: 'user' }`(`dsh-session-title` 逐字:`session.append('session/title', { … source: { kind: 'user' } })`)。
325
+ * ⇒ 若把"来源=user"当作"人改的",**连我们自己每次 regenerate 都会被自己挡住**,
326
+ * 概要再也更新不了(那是把功能焊死,不是尊重用户)。
327
+ *
328
+ * ## 判据:认**形状**,不认来源
329
+ *
330
+ * 我们生成的标题必然以 `<S编号>-<日期>` 开头(无日期时以 `<S编号>` 开头)。
331
+ * ⇒ **当前标题不符合这个前缀** ⟺ 用户改过 ⟺ 不动它。
332
+ * ⇒ 符合前缀 ⇒ 那(几乎必然)是我们上一轮写的,允许用新概括覆盖。
333
+ *
334
+ * 🔴 **"读不到"≠"用户改过"**(2026-11-25 首次实现写错的地方):
335
+ * 会话**还没有标题**时(新建载体、替身服务不提供读口)⇒ 我们起**第一个**名字,
336
+ * 那是"命名"而不是"覆盖",**必须允许**。
337
+ * 把它判成"保留"会让整条命名链在服务形态不完整时**整体失效**
338
+ * (实证:一次错误收窄让 11 条既有用例全红,功能等于被自己焊死)。
339
+ *
340
+ * @param currentTitle 会话当前标题(`undefined`/空串 = 尚无标题)
341
+ * @param expectedPrefix 我们这一轮本该生成的标题前缀(`namingTitleFor` 去掉概括部分)
342
+ * @returns true = 跳过重命名(保留用户的名字);false = 可以写
343
+ */
344
+ export declare function shouldKeepUserTitle(currentTitle: string | undefined, expectedPrefix: string): boolean;
345
+ /**
346
+ * 读会话当前标题;**读口本身缺失时返回 `null`**(= 结构上无法判断,与"读到空标题"分开)。
347
+ *
348
+ * 🔴 这两种情形必须分开(2026-11-25 首次实现把它们混成一个值):
349
+ * - `null` ⇒ 宿主服务**没有读口** ⇒ 无法判断 ⇒ 调用方**按旧行为**直接写(不引入回归)
350
+ * - `''` ⇒ 读到了,但**尚无标题** ⇒ 不是覆盖 ⇒ 允许写
351
+ * @param titles 宿主 sessionTitle 服务对象(可能是替身/旧形态)
352
+ * @param session 目标会话
353
+ */
354
+ export declare function readCurrentTitle(titles: {
355
+ get?: (session: unknown) => {
356
+ title?: unknown;
357
+ } | undefined;
358
+ } | undefined, session: unknown): {
359
+ state: 'unreadable';
360
+ } | {
361
+ state: 'ok';
362
+ title: string | undefined;
363
+ };
313
364
  export declare function getActiveSessionInfo(scope: string): ActiveSessionInfo | null;
314
365
  export declare function getLastActiveSessionInfo(): ActiveSessionInfo | null;
315
366
  export declare function setActiveSessionInfo(scope: string, info: ActiveSessionInfo): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shgroup/dsh-serenity-hooks",
3
- "version": "1.139.2",
3
+ "version": "1.139.4",
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": {