@shgroup/dsh-serenity-hooks 1.139.2 → 1.139.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.139.2",
3
+ "version": "1.139.3",
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": {
@@ -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
@@ -8,10 +8,10 @@ import { a as setSafeMode, c as ACC_CATALOG, d as findEntry, f as loadMsmEntries
8
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
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
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";
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-4EvElf11.js";
12
12
  import { i as hostAliveProbe, n as readSimpleSettings, r as registerSettingsSection } from "./settings-YC-csZus.js";
13
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";
14
+ import { i as subscriptionStats, n as registerTrajectorySubscriptions, r as subscriptionEval, t as defaultSubscriptionDeps } from "./subscriptions-BlxA1n2N.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-BU6BZjsW.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-C3vpKGcT.js");
562
562
  return renderDiag(await runDiag(hostCtx, root ?? ""));
563
563
  }
564
564
  default: throw new Error(`Unknown action: ${args.action}`);
@@ -9672,7 +9672,8 @@ function resolveWorkspace(ctx, params) {
9672
9672
  }
9673
9673
  function registerStatusApi(ctx, opts = {}) {
9674
9674
  const configPaths = opts.configPaths ?? DEFAULT_SERENITY_CONFIG_PATHS;
9675
- ctx.webServer.register({
9675
+ const webServer = withRouteDisposal(ctx, "serenity status api routes", ctx.webServer);
9676
+ webServer.register({
9676
9677
  kind: "exact",
9677
9678
  path: UPLOAD_PATH,
9678
9679
  handler: async (req, res) => {
@@ -9699,7 +9700,7 @@ function registerStatusApi(ctx, opts = {}) {
9699
9700
  }
9700
9701
  }
9701
9702
  });
9702
- ctx.webServer.register({
9703
+ webServer.register({
9703
9704
  kind: "exact",
9704
9705
  path: FILE_UPLOAD_PATH,
9705
9706
  handler: async (req, res) => {
@@ -9726,7 +9727,7 @@ function registerStatusApi(ctx, opts = {}) {
9726
9727
  }
9727
9728
  }
9728
9729
  });
9729
- ctx.webServer.register({
9730
+ webServer.register({
9730
9731
  kind: "exact",
9731
9732
  path: ROUTE_PATH,
9732
9733
  handler: async (req, res) => {
@@ -9775,7 +9776,7 @@ function registerStatusApi(ctx, opts = {}) {
9775
9776
  }
9776
9777
  }
9777
9778
  });
9778
- ctx.webServer.register({
9779
+ webServer.register({
9779
9780
  kind: "exact",
9780
9781
  path: CONFIG_PATH,
9781
9782
  handler: async (req, res) => {
@@ -9810,7 +9811,7 @@ function registerStatusApi(ctx, opts = {}) {
9810
9811
  }
9811
9812
  }
9812
9813
  });
9813
- ctx.webServer.register({
9814
+ webServer.register({
9814
9815
  kind: "exact",
9815
9816
  path: CCCS_PATH,
9816
9817
  handler: async (req, res) => {
@@ -9834,7 +9835,7 @@ function registerStatusApi(ctx, opts = {}) {
9834
9835
  }
9835
9836
  }
9836
9837
  });
9837
- ctx.webServer.register({
9838
+ webServer.register({
9838
9839
  kind: "exact",
9839
9840
  path: SUBSCRIPTIONS_PATH,
9840
9841
  handler: async (req, res) => {
@@ -9871,7 +9872,7 @@ function registerStatusApi(ctx, opts = {}) {
9871
9872
  }
9872
9873
  }
9873
9874
  });
9874
- ctx.webServer.register({
9875
+ webServer.register({
9875
9876
  kind: "exact",
9876
9877
  path: WEIXIN_PATH,
9877
9878
  handler: async (req, res) => {
@@ -10035,7 +10036,7 @@ function registerStatusApi(ctx, opts = {}) {
10035
10036
  }
10036
10037
  }
10037
10038
  });
10038
- ctx.webServer.register({
10039
+ webServer.register({
10039
10040
  kind: "exact",
10040
10041
  path: `${WEIXIN_PATH}/login`,
10041
10042
  handler: async (req, res) => {
@@ -10107,7 +10108,7 @@ function registerStatusApi(ctx, opts = {}) {
10107
10108
  }
10108
10109
  }
10109
10110
  });
10110
- ctx.webServer.register({
10111
+ webServer.register({
10111
10112
  kind: "exact",
10112
10113
  path: "/serenity/session-cleanup",
10113
10114
  handler: async (req, res) => {
@@ -10369,7 +10370,7 @@ function sendJson$1(res, status, body) {
10369
10370
  * 显示的还是 home-serenity 的信息」)。不传 ⇒ 不注入(保持资产原样 = 旧行为)。
10370
10371
  */
10371
10372
  function registerVoyageApi(ctx, opts = {}) {
10372
- ctx.webServer.register({
10373
+ withRouteDisposal(ctx, "serenity voyage api route", ctx.webServer).register({
10373
10374
  kind: "exact",
10374
10375
  path: VOYAGE_PATH,
10375
10376
  handler: (req, res) => {
@@ -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
2
  import { S as ACC_VERSION } from "./guards-is79hFAc.js";
3
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";
4
+ import { a as wakeSchedulerState, m as listWakes } from "./scheduler-4EvElf11.js";
5
5
  import { resolve } from "node:path";
6
6
  import { existsSync, readFileSync, statSync } from "node:fs";
7
7
  //#region src/surface/observation.ts
@@ -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
  /**
@@ -3787,4 +3830,4 @@ function registerWakeScheduler(ctx) {
3787
3830
  registerDisposer(ctx, "认知轨迹唤醒调度器", () => clock.dispose());
3788
3831
  }
3789
3832
  //#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 };
3833
+ 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
1
  import { d as hostSessions, r as cccRootForCwd } from "./ccc-roots-B6dJON2X.js";
2
2
  import { p as readTrajectorySubscriptions } from "./ccc-DSMqTrRU.js";
3
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";
4
+ import { f as WAKE_CATCH_UP_MS, u as listCroCognitiveTrajectories } from "./scheduler-4EvElf11.js";
5
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";
6
+ import { i as subscriptionStats, r as subscriptionEval } from "./subscriptions-BlxA1n2N.js";
7
+ import { containerClocks, containerWakes } from "./observation-BU6BZjsW.js";
8
8
  //#region src/trajectory/live.ts
9
9
  /**
10
10
  * trajectory/live.ts — 进程内 live 会话取数 + 精简诊断
@@ -1,7 +1,7 @@
1
1
  import { r as cccRootForCwd } from "./ccc-roots-B6dJON2X.js";
2
2
  import { p as readTrajectorySubscriptions } from "./ccc-DSMqTrRU.js";
3
3
  import { L as localHuman, n as findTrajectoryHolding } from "./bind-file-Dy6Qmm7z.js";
4
- import { s as registerDisposer } from "./scheduler-pOtONqPy.js";
4
+ import { s as registerDisposer } from "./scheduler-4EvElf11.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-4EvElf11.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,
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.3",
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": {