@shgroup/dsh-serenity-hooks 1.40.0 → 1.40.1

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.40.0",
3
+ "version": "1.40.1",
4
4
  "main": "lib/index.js",
5
5
  "description": "宁静号 ACC harness(Native Cordis 插件):给 DSH 装一个「AI 工作区」——11 个工具(container_fs/container_trajectory/dashboard/container_git/msm/praxis/handyman/localstore/container_admin/im-bridge/acc-diag;后两个按配置条件出现)+ 机械约束(安全模式/工作区围墙/密钥守卫)+ 轨迹日志与原地重建 + 网页登录入口/微信桥/子角色/对外问答页/trajectory 唤醒注册表。适配 DSH 0.1.5-rc.2(deepseek-ai/deepseek-harness)。",
6
6
  "engines": {
package/lib/index.js CHANGED
@@ -2,12 +2,12 @@ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
2
  import { a as hostSettings, c as hostWebServer, i as hostSessions, n as hostInjected, o as hostSubagents, r as hostService, s as hostWeb, t as hostAgents } from "./access-fiehjxV6.js";
3
3
  import { a as findSerenityRoot, c as matchBlacklist, d as readCccName$1, f as readExclusiveTools, h as resolveInside, i as findGitRoot, l as pathInside, n as SAFE_MODE_MARKER, o as isSafeModeOn, p as readHandymanConfig, r as classifyPath, s as loadSerenityConfig, t as DEFAULT_SERENITY_CONFIG_PATHS, u as readBlacklist } from "./ccc-NlLr_sxy.js";
4
4
  import { i as cccRootForExec, n as agentCwdFor, o as listCccs, r as cccRootForCwd, t as NO_CCC_FROM_AGENT_CWD } from "./ccc-roots-Bd_SjEs7.js";
5
- import { C as showSession, D as localFileStamp, E as isoLocal, S as setActiveSessionInfo, T as useSession, _ as parseSessionContextFromEvents, a as readLastBound, b as sessionEvents$1, c as supersedeOtherBindings, d as clearActiveSessionInfo, f as createSession, g as listSessions, h as getActiveSessionInfo, i as pruneMissingBindings, l as DEFAULT_SESSION_SCOPE, m as findSession, o as resolveSessionTrajectoryLabel, p as extractSessionMdPathFromText, r as migrateBindingsToDomain, s as setBindingStore, t as appendBound, u as TRAJECTORY_ACTIONS, v as readActiveSessionMd, w as summarize, x as sessionsRoot, y as resolveSessionByTitle } from "./trajectory-bound-CQTh86vq.js";
5
+ import { C as summarize, E as localFileStamp, S as showSession, T as isoLocal, _ as readActiveSessionMd, a as resolveSessionTrajectoryLabel, b as sessionsRoot, c as DEFAULT_SESSION_SCOPE, d as createSession, f as extractSessionMdPathFromText, g as parseSessionContextFromEvents, h as listSessions, i as readLastBound, l as TRAJECTORY_ACTIONS, m as getActiveSessionInfo, o as setBindingStore, p as findSession, r as pruneMissingBindings, s as supersedeOtherBindings, t as appendBound, u as clearActiveSessionInfo, v as resolveSessionByTitle, w as useSession, x as setActiveSessionInfo, y as sessionEvents$1 } from "./trajectory-bound-4xkZDfmO.js";
6
6
  import { a as readWeixinCredential, c as weixinInboundDir, d as LOCALSTORE_SCOPES, f as checkLocalstoreGitCompliance, g as runLocalStore, h as readStore, i as matchWeixinRoute, l as weixinSessionIdFor, m as readGitTrack, n as extractWeixinText, o as readWeixinSettings, p as localstorePath, r as hasVoiceItem, s as sanitizeFileName$1, t as extractWeixinMedia } from "./weixin-route-B2ajFypI.js";
7
7
  import { a as readSkiffRoles, c as roleMsmWhitelist, d as systemPromptSource, f as trajectorySubset, i as isSkiffSessionId, l as roleToolWhitelist, n as buildSkiffBasePrompt, o as resolveRoleSystemPrompt, r as createRolePromptReader, s as resolveSkiffKind } from "./skiff-role-CEHL5cek.js";
8
8
  import { a as unregisterSkiffSession$1, i as skiffSessionSnapshot$1, n as skiffRoleFor$1, r as skiffSessionInfo$1, t as registerSkiffSession$1 } from "./skiff-registry-FTjoWQTQ.js";
9
9
  import { r as sessionsRootDir, t as hasSessionLogById } from "./session-cleanup-BtkSmry8.js";
10
- import { a as WAKE_CATCH_UP_MS, i as registerDisposer, n as sendToTrajectory, o as addWake, r as wakeSchedulerState, s as listWakes, t as registerWakeScheduler } from "./wake-scheduler-UTh4t14k.js";
10
+ import { a as WAKE_CATCH_UP_MS, i as registerDisposer, n as sendToTrajectory, o as addWake, r as wakeSchedulerState, s as listWakes, t as registerWakeScheduler } from "./wake-scheduler-BRnPUnER.js";
11
11
  import { a as FACE_PORTS, c as MECHANISM_PORTS, i as ACP_HTTP_PORT, l as SKIFF_DEBUG_PORT, n as registerSettingsSection, o as GATEWAY_PORT, s as MAIN_WEB_PORT, t as readSimpleSettings, u as WEIXIN_SEND_PORT } from "./settings-section-DMDUoQum.js";
12
12
  import { a as markdownToPlainText, c as sendTyping, i as getUpdates, l as sniffImageExt, n as downloadMedia, o as sendFileMessage, r as getConfig, s as sendTextMessage, t as TypingStatus } from "./weixin-api-CtFYm53S.js";
13
13
  import z from "@deepseek-ai/schemastery";
@@ -14665,11 +14665,7 @@ function apply(ctx, config) {
14665
14665
  try {
14666
14666
  const domain = await openBindingDomain(ctx);
14667
14667
  setBindingStore(bindingStore(domain));
14668
- if (domain) {
14669
- const root = process.cwd();
14670
- const stats = migrateBindingsToDomain(root);
14671
- if (stats.migrated > 0) console.log(`[serenity-hooks] §0L 绑定已迁移入宿主存储域:${stats.migrated} 条(跳过 ${stats.skipped})`);
14672
- } else console.log("[serenity-hooks] §0L 存储域不可用 → 绑定继续走 CCC 内 .bindings.json(向前兼容回落)");
14668
+ if (!domain) console.log("[serenity-hooks] §0L 存储域不可用 → 绑定继续走 CCC 内 .bindings.json(向前兼容回落)");
14673
14669
  } catch {
14674
14670
  setBindingStore(null);
14675
14671
  }
@@ -599,8 +599,32 @@ function migrateBindingsToDomain(root) {
599
599
  out.failed += 1;
600
600
  }
601
601
  }
602
+ if (out.migrated > 0) migratedRoots.add(root);
602
603
  return out;
603
604
  }
605
+ /** 已补过迁移的 CCC 根(进程内去重;跨进程各补一次是可接受的——迁移幂等) */
606
+ const migratedRoots = /* @__PURE__ */ new Set();
607
+ /**
608
+ * **按 CCC 惰性补迁移**(§0L 修正,S142 2026-09-19)。
609
+ *
610
+ * 🔴 为什么需要它(实测缺陷,R↓):
611
+ * 装载期那次迁移用的是 `process.cwd()` —— 而 dsh **服务进程的 cwd 是 `/home/yh`**,
612
+ * **不是 CCC 根**(实测 `acc-diag`:`进程 cwd: /home/yh | 进程 CCC: (无)`)。
613
+ * ⇒ 迁移读的是一个**不存在的文件**,静默迁移 0 条
614
+ * (症状:发布后 `~/.dsh/storages/serenity_bindings.json` **没出现**)。
615
+ *
616
+ * 现在改为:**任何一次能定位到 CCC 根的路径**都顺手补一次迁移(幂等 + 进程内去重)。
617
+ * 这样无论服务从哪个 cwd 启动,只要那条 CCC 有会话活动,它的绑定就会被带上。
618
+ *
619
+ * @param root CCC 根
620
+ */
621
+ function ensureBindingsMigrated(root) {
622
+ if (!domainStore?.available) return;
623
+ if (migratedRoots.has(root)) return;
624
+ try {
625
+ migrateBindingsToDomain(root);
626
+ } catch {}
627
+ }
604
628
  /**
605
629
  * 域内读一条(同步)。域不可用 → `undefined`(调用方据此回落文件)。
606
630
  * @param sessionId dsh 会话 id
@@ -638,6 +662,7 @@ function bindingsPathFor(session) {
638
662
  if (typeof header?.cwd !== "string") return null;
639
663
  const root = cccRootForCwd(header.cwd);
640
664
  if (!root) return null;
665
+ ensureBindingsMigrated(root);
641
666
  return join(root, BINDINGS_REL_PATH);
642
667
  }
643
668
  function readBindingsFile(path) {
@@ -908,4 +933,4 @@ function appendBound(session, action, rec) {
908
933
  }
909
934
  }
910
935
  //#endregion
911
- export { showSession as C, localFileStamp as D, isoLocal as E, localHuman as O, setActiveSessionInfo as S, useSession as T, parseSessionContextFromEvents as _, readLastBound as a, sessionEvents as b, supersedeOtherBindings as c, clearActiveSessionInfo as d, createSession as f, listSessions as g, getActiveSessionInfo as h, pruneMissingBindings as i, localIdStamp as k, DEFAULT_SESSION_SCOPE as l, findSession as m, listBoundSessionIds as n, resolveSessionTrajectoryLabel as o, extractSessionMdPathFromText as p, migrateBindingsToDomain as r, setBindingStore as s, appendBound as t, TRAJECTORY_ACTIONS as u, readActiveSessionMd as v, summarize as w, sessionsRoot as x, resolveSessionByTitle as y };
936
+ export { summarize as C, localHuman as D, localFileStamp as E, localIdStamp as O, showSession as S, isoLocal as T, readActiveSessionMd as _, resolveSessionTrajectoryLabel as a, sessionsRoot as b, DEFAULT_SESSION_SCOPE as c, createSession as d, extractSessionMdPathFromText as f, parseSessionContextFromEvents as g, listSessions as h, readLastBound as i, TRAJECTORY_ACTIONS as l, getActiveSessionInfo as m, listBoundSessionIds as n, setBindingStore as o, findSession as p, pruneMissingBindings as r, supersedeOtherBindings as s, appendBound as t, clearActiveSessionInfo as u, resolveSessionByTitle as v, useSession as w, setActiveSessionInfo as x, sessionEvents as y };
@@ -72,6 +72,21 @@ export declare function migrateBindingsToDomain(root: string): {
72
72
  skipped: number;
73
73
  failed: number;
74
74
  };
75
+ /**
76
+ * **按 CCC 惰性补迁移**(§0L 修正,S142 2026-09-19)。
77
+ *
78
+ * 🔴 为什么需要它(实测缺陷,R↓):
79
+ * 装载期那次迁移用的是 `process.cwd()` —— 而 dsh **服务进程的 cwd 是 `/home/yh`**,
80
+ * **不是 CCC 根**(实测 `acc-diag`:`进程 cwd: /home/yh | 进程 CCC: (无)`)。
81
+ * ⇒ 迁移读的是一个**不存在的文件**,静默迁移 0 条
82
+ * (症状:发布后 `~/.dsh/storages/serenity_bindings.json` **没出现**)。
83
+ *
84
+ * 现在改为:**任何一次能定位到 CCC 根的路径**都顺手补一次迁移(幂等 + 进程内去重)。
85
+ * 这样无论服务从哪个 cwd 启动,只要那条 CCC 有会话活动,它的绑定就会被带上。
86
+ *
87
+ * @param root CCC 根
88
+ */
89
+ export declare function ensureBindingsMigrated(root: string): void;
75
90
  /** 绑定文件绝对路径(由会话 cwd 上溯 .serenity 定位 CCC 根);无法定位返回 null */
76
91
  export declare function bindingsPathFor(session: unknown): string | null;
77
92
  /**
@@ -1,6 +1,6 @@
1
1
  import { r as hostService, t as hostAgents } from "./access-fiehjxV6.js";
2
2
  import { o as listCccs } from "./ccc-roots-Bd_SjEs7.js";
3
- import { E as isoLocal, O as localHuman, k as localIdStamp, m as findSession, n as listBoundSessionIds, x as sessionsRoot } from "./trajectory-bound-CQTh86vq.js";
3
+ import { D as localHuman, O as localIdStamp, T as isoLocal, b as sessionsRoot, n as listBoundSessionIds, p as findSession } from "./trajectory-bound-4xkZDfmO.js";
4
4
  import { t as readSimpleSettings } from "./settings-section-DMDUoQum.js";
5
5
  import { basename, dirname, join } from "node:path";
6
6
  import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shgroup/dsh-serenity-hooks",
3
- "version": "1.40.0",
3
+ "version": "1.40.1",
4
4
  "description": "宁静号 ACC harness(Native Cordis 插件)——给 DeepSeek Harness 装一个「AI 工作区」:11 个工具(container_fs/container_trajectory/dashboard/container_git/msm/praxis/handyman/localstore/container_admin/im-bridge/acc-diag)+ 机械约束(安全模式/工作区围墙/密钥守卫/对外输出守卫)+ 工作日志与原地重建 + 网页登录入口/微信桥/子角色/对外问答页/trajectory 唤醒注册表。适配 DSH 0.1.5-rc.2。",
5
5
  "license": "MIT",
6
6
  "repository": {