@shgroup/dsh-serenity-hooks 1.32.0 → 1.34.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.
Files changed (100) hide show
  1. package/README.md +12 -11
  2. package/dsh.plugin.json +5 -5
  3. package/lib/acp-core.d.ts +2 -22
  4. package/lib/acp-http.d.ts +8 -0
  5. package/lib/api.d.ts +12 -4
  6. package/lib/autopilot-chain.d.ts +76 -0
  7. package/lib/autopilot-core-DCRkiWEe.js +229 -0
  8. package/lib/autopilot-core.d.ts +132 -0
  9. package/lib/autopilot-ops.d.ts +48 -0
  10. package/lib/autopilot-trajectory-D9Znxo75.js +782 -0
  11. package/lib/autopilot-trajectory.d.ts +79 -83
  12. package/lib/{ccc-DAsSHsub.js → ccc-NlLr_sxy.js} +18 -2
  13. package/lib/ccc-roots-Bd_SjEs7.js +152 -0
  14. package/lib/ccc-roots.d.ts +105 -0
  15. package/lib/ccc.d.ts +23 -6
  16. package/lib/client.js +30 -10
  17. package/lib/clock-runtime.d.ts +197 -0
  18. package/lib/config-ops.d.ts +9 -14
  19. package/lib/constants.d.ts +0 -2
  20. package/lib/container-status.d.ts +183 -0
  21. package/lib/diag-ops.d.ts +76 -0
  22. package/lib/face-host.d.ts +110 -0
  23. package/lib/fs-ops.d.ts +3 -2
  24. package/lib/gateway-auth.d.ts +2 -5
  25. package/lib/gateway.d.ts +0 -34
  26. package/lib/git-ops.d.ts +3 -2
  27. package/lib/handyman-ops.d.ts +3 -2
  28. package/lib/handyman-preset-inherit.d.ts +2 -1
  29. package/lib/host/access.d.ts +8 -7
  30. package/lib/host/contract.d.ts +17 -6
  31. package/lib/host/type-contract.d.ts +1 -2
  32. package/lib/im-bridge.d.ts +6 -5
  33. package/lib/index.d.ts +1 -1
  34. package/lib/index.js +11053 -8305
  35. package/lib/invariant.d.ts +5 -16
  36. package/lib/invariant.js +8 -4
  37. package/lib/json.d.ts +1 -1
  38. package/lib/kit-ops.d.ts +11 -31
  39. package/lib/localstore-ops.d.ts +3 -17
  40. package/lib/msm-ops.d.ts +34 -52
  41. package/lib/opencode-provider.d.ts +4 -5
  42. package/lib/output-guard-seam.d.ts +1 -4
  43. package/lib/output-guard.d.ts +12 -3
  44. package/lib/ports.d.ts +59 -0
  45. package/lib/rebuild.d.ts +5 -4
  46. package/lib/seams/bootstrap.d.ts +4 -3
  47. package/lib/seams/compact.d.ts +2 -1
  48. package/lib/seams/context.d.ts +2 -4
  49. package/lib/seams/env.d.ts +2 -1
  50. package/lib/seams/guards.d.ts +22 -34
  51. package/lib/seams/keeper.d.ts +4 -4
  52. package/lib/seams/system-prompt.d.ts +1 -5
  53. package/lib/session-cleanup.d.ts +3 -2
  54. package/lib/{settings-section-Bm-xG-NR.js → settings-section-DTYZjwUs.js} +70 -15
  55. package/lib/settings-section.d.ts +14 -35
  56. package/lib/skiff-core.d.ts +5 -10
  57. package/lib/skiff-debug.d.ts +15 -21
  58. package/lib/skiff-registry-FTjoWQTQ.js +25 -0
  59. package/lib/skiff-registry.d.ts +2 -1
  60. package/lib/{skiff-role-BYvNnwv1.js → skiff-role-CEHL5cek.js} +1 -1
  61. package/lib/skiff-role.d.ts +2 -2
  62. package/lib/skills/opencode-scan.d.ts +3 -2
  63. package/lib/skills-discovery.d.ts +15 -2
  64. package/lib/status.d.ts +2 -1
  65. package/lib/tools/acc-diag.d.ts +22 -0
  66. package/lib/tools/cce.d.ts +1 -2
  67. package/lib/tools/container-admin.d.ts +7 -3
  68. package/lib/tools/eap.d.ts +2 -3
  69. package/lib/tools/handyman.d.ts +0 -29
  70. package/lib/tools/msm.d.ts +0 -4
  71. package/lib/tools/neat.d.ts +1 -2
  72. package/lib/tools/praxis.d.ts +0 -1
  73. package/lib/tools/skiff-admin.d.ts +2 -2
  74. package/lib/tools/{session.d.ts → trajectory.d.ts} +25 -17
  75. package/lib/totp.d.ts +0 -4
  76. package/lib/trajectory-assistant.d.ts +2 -1
  77. package/lib/trajectory-bound-Cax1p9ut.js +190 -0
  78. package/lib/{session-bound.d.ts → trajectory-bound.d.ts} +5 -6
  79. package/lib/trajectory-ops-mrXK0H0I.js +410 -0
  80. package/lib/{session-ops.d.ts → trajectory-ops.d.ts} +27 -36
  81. package/lib/trajectory-skills.d.ts +71 -0
  82. package/lib/wake-registry-CYxIb484.js +257 -0
  83. package/lib/wake-registry.d.ts +3 -11
  84. package/lib/wake-scheduler.d.ts +23 -20
  85. package/lib/web-fetch-provider.d.ts +0 -21
  86. package/lib/{weixin-api-PjEhmjlZ.js → weixin-api-CtFYm53S.js} +3 -9
  87. package/lib/weixin-api.d.ts +6 -37
  88. package/lib/weixin-bridge.d.ts +5 -24
  89. package/lib/weixin-hook.d.ts +6 -12
  90. package/lib/weixin-output-guard.d.ts +2 -1
  91. package/lib/{weixin-route-wWk4AIwV.js → weixin-route-B2ajFypI.js} +4 -5
  92. package/lib/weixin-route.d.ts +0 -2
  93. package/lib/weixin-send-api.d.ts +15 -6
  94. package/package.json +3 -5
  95. package/experiments/autopilot-trajectory/SKILL.md +0 -115
  96. package/experiments/autopilot-trajectory/scripts/autopilot-trajectory.ts +0 -522
  97. package/lib/session-bound-NHozeLFc.js +0 -822
  98. package/lib/skiff-debug-K2k1JnGj.js +0 -2867
  99. package/lib/tools/autopilot-trajectory.d.ts +0 -25
  100. package/lib/{session-cleanup-CMT4mHWt.js → session-cleanup-B6IHZgww.js} +1 -1
@@ -21,36 +21,7 @@ export interface GuardInput {
21
21
  /** 当前 agent 的 dsh 会话 id(Skiff 角色白名单判定;非 skiff 会话不判定) */
22
22
  skiffSessionId?: string;
23
23
  }
24
- /**
25
- * 凭据文件硬名单(数据面守卫,v1.26.3,S142 用户:localstore.json 需要在 read 工具的黑名单里):
26
- * **任何工具**(含 read/grep/glob/container_fs 只读子命令)命中这些相对 CCC 根的路径 → deny。
27
- *
28
- * 与 safeMode.blacklist(写黑名单,v1.18.5 决策只拦写)语义独立:
29
- * - 黑名单 = 用户可配置的写保护(REPOSITORIES/ 等只读参考源不误伤读)
30
- * - 凭据硬名单 = **结构性数据面边界**(不依赖 safe-mode 开关,凭据文件任何时候不可读)——
31
- * 对齐 CCE Bounded Space + wardn "structural guarantee, not policy":localstore.json
32
- * 含 API keys/tokens/SSH 密码,即使 prompt 纪律失败也无值可吐(机械保证)。
33
- */
34
- export declare const SENSITIVE_CREDENTIAL_FILES: Set<string>;
35
- /**
36
- * MSM 注册表写保护(需求⑤b S142 用户拍板:"msm注册的文件需要写保护起来,避免CCC意外写坏搞崩自己"):
37
- * mech-registry.json 是 CCC 执行层地基(坏 → loadMsmEntries 抛 → container_admin/output-guard 全崩,
38
- * register 也崩 → 自锁)。**写 deny、读 allow**(与 localstore 读 deny 语义区分 R6——注册表是
39
- * 结构核心不是秘密,需被 output-guard/skiff-admin 读取建 MSM 词表)。
40
- *
41
- * 单级化(需求⑤a)后**唯一合法注册表 = cccName 聚合档**
42
- * `.opencode/skills/<cccName>/references/mech-registry.json`(cccName = .serenity 首行)。
43
- * 历史 root 级 `mech-registry.json` 与各 skill 分散注册表已废弃:**不再保护**
44
- * (review P1:保护一个永不被读的文件 = 死锁——MSM 既不可见又不可删/迁移)。
45
- * 写工具命中聚合档 → deny(唯一合法写通道 = container_admin msm register/deregister
46
- * 内部 writeRegistry,走工具实现不经 pre-execute → 天然豁免);读工具放行。
47
- */
48
- export declare function isProtectedRegistryRel(root: string, rel: string): boolean;
49
- /** 判定工具是否为读类(read/grep/glob + container_fs 只读子命令):凭据文件对读工具同样 deny */
50
- export declare function isReadTool(toolName: string, action?: string): boolean;
51
- /** 判定工具是否为写类:普通工具按名;container_fs 复合工具按子命令 action */
52
- export declare function isWriteTool(toolName: string, action?: string): boolean;
53
- export interface GuardDecisionResult {
24
+ interface GuardDecisionResult {
54
25
  deny?: string;
55
26
  kind: 'allow' | 'deny';
56
27
  }
@@ -62,7 +33,7 @@ export interface GuardDecisionResult {
62
33
  */
63
34
  export declare function decideGuard(input: GuardInput): GuardDecisionResult;
64
35
  /** restrict 诊断状态(status API 暴露;排查 restrict 未生效问题) */
65
- export interface RestrictDiagnostics {
36
+ interface RestrictDiagnostics {
66
37
  lastKey: string | null;
67
38
  lastAttemptAt: string | null;
68
39
  lastSuccess: boolean | null;
@@ -75,8 +46,6 @@ export declare function getRestrictDiagnostics(): RestrictDiagnostics;
75
46
  * 标记消失 → 解除。pre-step 每步调用 → 切换实时生效。
76
47
  */
77
48
  export declare function syncSafeModeRestriction(agent: Agent, root: string): void;
78
- /** 条件可见的 IM 工具名(与 tools/im-bridge.ts 的注册名一致) */
79
- export declare const IM_BRIDGE_TOOL_NAME = "im-bridge";
80
49
  /** im-bridge 隐藏诊断(排查"工具为什么不在清单里") */
81
50
  export declare function getImBridgeVisibilityDiagnostics(): {
82
51
  hiddenKeys: string[];
@@ -95,7 +64,25 @@ export declare function getImBridgeVisibilityDiagnostics(): {
95
64
  export declare function syncImBridgeVisibility(agent: Agent, root: string): void;
96
65
  /** 会话销毁清理(lifecycle 调用;防 per-会话 Map 无界增长——review F-08 同族) */
97
66
  export declare function forgetImBridgeVisibility(sessionId: string): void;
98
- export interface GuardRegistration {
67
+ /** 专属工具隐藏诊断(排查"工具为什么不在清单里") */
68
+ export declare function getExclusiveToolsDiagnostics(): {
69
+ hidden: string[];
70
+ };
71
+ /**
72
+ * 同步专属工具可见性(v1.33)。
73
+ *
74
+ * 判据 = CCC 配置 `exclusiveTools`(`readExclusiveTools`):
75
+ * - **未声明** → `agent.ctx.tools.restrict({ deny: [tool] })`:从 schema 移除(模型看不到)
76
+ * - **声明** → 解除隐藏(CCC 配置热更新即时生效)
77
+ *
78
+ * 判据失败按"未声明"处理(fail-closed:专属工具默认隐藏),原因见 `readExclusiveTools` 注释。
79
+ * 与 `syncImBridgeVisibility` 同点调用(pre-step 每步 + 会话就绪),失败不阻断一步——
80
+ * 最坏情况是"看得到但被拒",而不是让 step 出错。
81
+ */
82
+ export declare function syncExclusiveToolsVisibility(agent: Agent, root: string): void;
83
+ /** 会话销毁清理(lifecycle 调用;本函数按 `${sessionId}::` 前缀回收全部专属工具项) */
84
+ export declare function forgetExclusiveToolsVisibility(sessionId: string): void;
85
+ interface GuardRegistration {
99
86
  /** 配置路径;缺省用 DEFAULT_SERENITY_CONFIG_PATHS */
100
87
  configPaths?: string[];
101
88
  }
@@ -104,3 +91,4 @@ export interface GuardRegistration {
104
91
  * 两者都从 CCC 根实时读取配置(无状态、无缓存)。
105
92
  */
106
93
  export declare function registerGuards(ctx: Context, opts?: GuardRegistration): void;
94
+ export {};
@@ -36,7 +36,7 @@ export declare function reminderText(code: string, score: number): string;
36
36
  * 简短留自由度(不提"加载 eap 工具",模型自知;只说修订 skill + 新建 skill 落 SESSION)。
37
37
  *
38
38
  * escalated=true(v1.23.3):连续多轮超阈值仍未 rebuild → 升级强制语气
39
- * (STOP and rebuild now,持续注入直到调用 logbook rebuild)。
39
+ * (STOP and rebuild now,持续注入直到调用 container_trajectory rebuild)。
40
40
  *
41
41
  * 需求①(S142 用户拍板):百分比比例 → K 数值——tokensK = 实际占用(千 token),
42
42
  * thresholdK = 配置阈值(千 token);文案 `Context usage at NNNK (threshold NNNK)`。
@@ -76,7 +76,7 @@ export declare function __resetLogbookCompactionForTest(): void;
76
76
  * 解析**活跃** SESSION.md 绝对路径(缓存 60s)。
77
77
  *
78
78
  * 候选链(刻意比 rebuild 的完整链短——这里每个工具调用都要跑,贵候选不划算):
79
- * ① `getActiveSessionInfo(scope).mdPath`(`logbook use` / skiff 绑定 / 重启恢复都会写)
79
+ * ① `getActiveSessionInfo(scope).mdPath`(`container_trajectory use` / skiff 绑定 / 重启恢复都会写)
80
80
  * ② `readLastBound(session).mdPath`(`.bindings.json` 权威绑定——重启后内存空时兜底)
81
81
  * 两者都拿不到 → null(**不猜**:宁可不提醒,也不去猜别的轨迹——对齐 v1.30.13 D4 的教训)。
82
82
  */
@@ -98,13 +98,13 @@ export declare function readSessionMdMaxKB(root: string, configPaths?: string[],
98
98
  * ③ 允许整合不重要事项(被取代的决策 / 已解决问题 / 中间态)
99
99
  * ④ 自主裁量权充分允许(唯一硬要求 = 骨架 + 未决项/决策理由/下一步仍可重建)
100
100
  */
101
- export declare function logbookCompactionReminderText(input: {
101
+ export declare function trajectoryCompactionReminderText(input: {
102
102
  sizeKB: number;
103
103
  limitKB: number;
104
104
  mdPath: string;
105
105
  escalated?: boolean;
106
106
  }): string;
107
- export interface KeeperRegistration {
107
+ interface KeeperRegistration {
108
108
  /** 缺省阈值(serenity.json sessionKeeper.threshold 优先,其次此值) */
109
109
  defaultThreshold?: number;
110
110
  /** CCC 配置相对路径 */
@@ -25,11 +25,6 @@
25
25
  */
26
26
  import type { Agent } from '@deepseek-ai/dsh-agent';
27
27
  import type { Context } from 'cordis';
28
- /** 读取 persona 彩蛋配置(plugin 全局;未配置 → mode='' 彩蛋关闭) */
29
- export declare function readPersonaSettings(): {
30
- mode: string;
31
- overrideText: string;
32
- };
33
28
  /** 1) 身份块:ACC 身份 + CCC 名 + 平台工具说明(需求③ S142:工具清单移出为独立 toolsBlock 放装配末尾——身份先行、工具参考殿后) */
34
29
  export declare function identityBlock(root: string): string;
35
30
  /**
@@ -130,3 +125,4 @@ export declare function codeModeAdaptationLine(ctx: Context, scope?: unknown): s
130
125
  */
131
126
  export declare function registerEntrySkillSectionGlobal(ctx: Context): void;
132
127
  export declare function registerEntrySkillSection(agent: Agent, root: string): boolean;
128
+ export declare function registerTrajectorySkillSection(agent: Agent, root: string): boolean;
@@ -19,7 +19,7 @@
19
19
  /** DSH 会话 root:env DSH_HOME → ~/.dsh(config-ops globalConfigPath 同款推导) */
20
20
  export declare function sessionsRootDir(): string;
21
21
  /** 一个候选会话(删除前预览信息) */
22
- export interface CandidateSession {
22
+ interface CandidateSession {
23
23
  /** 会话 id(目录名) */
24
24
  id: string;
25
25
  /** 项目目录(父目录名,如 --home-yh-home-home-serenity--) */
@@ -55,7 +55,7 @@ export declare function sessionLogArtifacts(sessionDirPath: string): Array<{
55
55
  */
56
56
  export declare function findSessionLog(sessionDirPath: string): string | null;
57
57
  /** 删除执行结果 */
58
- export interface CleanupResult {
58
+ interface CleanupResult {
59
59
  deleted: string[];
60
60
  /** 尝试删除但失败的会话目录(权限/竞态) */
61
61
  errors: Array<{
@@ -75,3 +75,4 @@ export declare function performCleanup(root: string, cutoffMs: number, liveIds?:
75
75
  };
76
76
  /** 便捷:默认 N 天前为 cutoff(供 API/调用方) */
77
77
  export declare function cutoffDaysAgo(days: number, nowMs?: number): number;
78
+ export {};
@@ -1,14 +1,70 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
2
  import { a as hostSettings } from "./access-fiehjxV6.js";
3
3
  import z from "@deepseek-ai/schemastery";
4
+ //#region src/ports.ts
5
+ /**
6
+ * 集中端口表。
7
+ * A=宿主主面(插件不监听)/ B=网关(可配,默认关)/ C=微信发送(默认开,仅 loopback)
8
+ * / D=Skiff 调试(默认关)/ E=ACP+问答(默认关)。
9
+ */
10
+ const FACE_PORTS = {
11
+ main: {
12
+ port: 3080,
13
+ host: null,
14
+ defaultEnabled: true,
15
+ meaning: "宿主 DSH 主 WebUI + 插件 /serenity/* 路由面(**插件不起此 listener**,端口自宿主读)"
16
+ },
17
+ gateway: {
18
+ port: 3081,
19
+ host: "0.0.0.0",
20
+ defaultEnabled: false,
21
+ meaning: "双端口网关(外部登录 + 全量反代宿主主面;host/port 走 plugin 全局配置)"
22
+ },
23
+ weixinSend: {
24
+ port: 3082,
25
+ host: "127.0.0.1",
26
+ defaultEnabled: true,
27
+ meaning: "微信主动发送面(容器外进程 → POST /send;与 3080 显式解耦,不经网关)"
28
+ },
29
+ skiffDebug: {
30
+ port: 3099,
31
+ host: "127.0.0.1",
32
+ defaultEnabled: false,
33
+ meaning: "Skiff 调试问答面(人工调试子角色;无认证,仅靠 loopback)"
34
+ },
35
+ acpHttp: {
36
+ port: 3100,
37
+ host: "127.0.0.1",
38
+ defaultEnabled: false,
39
+ meaning: "ACP JSON-RPC + 对外问答面(外部程序 + key 认证的问答页共用一 listener)"
40
+ }
41
+ };
42
+ /** 宿主主 WebUI 端口(面 A:插件**不监听**,只读取;`readWebPort` 的回退值) */
43
+ const MAIN_WEB_PORT = FACE_PORTS.main.port;
44
+ /** 网关端口默认值(面 B) */
45
+ const GATEWAY_PORT = FACE_PORTS.gateway.port;
46
+ /** 微信主动发送端口默认值(面 C) */
47
+ const WEIXIN_SEND_PORT = FACE_PORTS.weixinSend.port;
48
+ /** Skiff 调试页端口默认值(面 D) */
49
+ const SKIFF_DEBUG_PORT = FACE_PORTS.skiffDebug.port;
50
+ /** ACP / 对外问答端口默认值(面 E) */
51
+ const ACP_HTTP_PORT = FACE_PORTS.acpHttp.port;
52
+ /**
53
+ * **机制端口**词表(output-guard 用:agent 在**用户可见输出**里提及内部端口即打回)。
54
+ *
55
+ * 由 {@link FACE_PORTS} 机械派生 ⇒ 与面清单**永不漂移**。
56
+ * ⚠️ 修复记录(C4 块 B,2026-09-15):旧常量硬写 `['3080','3081','3099','3100']`
57
+ * ——**漏 3082**(微信发送面,默认开)⇒ 守卫拦不住"3082"这类提及。现由表派生,五面齐全。
58
+ */
59
+ const MECHANISM_PORTS = Object.keys(FACE_PORTS).map((id) => String(FACE_PORTS[id].port));
60
+ //#endregion
4
61
  //#region src/settings-section.ts
5
62
  var settings_section_exports = /* @__PURE__ */ __exportAll({
6
63
  SERENITY_SETTINGS_NS: () => SERENITY_SETTINGS_NS,
7
64
  defaultSimpleSettings: () => defaultSimpleSettings,
8
65
  entryDefaults: () => entryDefaults,
9
66
  readSimpleSettings: () => readSimpleSettings,
10
- registerSettingsSection: () => registerSettingsSection,
11
- simpleSettingsSchema: () => simpleSettingsSchema
67
+ registerSettingsSection: () => registerSettingsSection
12
68
  });
13
69
  /** 简单配置命名空间(dsh 设置面板的 section id / settings.yaml section) */
14
70
  const SERENITY_SETTINGS_NS = "serenity-hooks";
@@ -18,12 +74,13 @@ const simpleSettingsSchema = z.object({
18
74
  rebuildEnabled: z.boolean().default(true),
19
75
  rebuildThresholdK: z.number().min(50).max(4e3).default(400),
20
76
  skiffEnabled: z.boolean().default(false),
21
- skiffDebugPort: z.number().min(1024).max(65535).default(3099),
77
+ skiffDebugPort: z.number().min(1024).max(65535).default(SKIFF_DEBUG_PORT),
22
78
  acpEnabled: z.boolean().default(false),
23
- acpHttpPort: z.number().min(1024).max(65535).default(3100),
79
+ acpHttpPort: z.number().min(1024).max(65535).default(ACP_HTTP_PORT),
24
80
  publicAskEnabled: z.boolean().default(false),
25
- autopilotEnabled: z.boolean().default(false),
26
- trajectoryEnabled: z.boolean().default(false)
81
+ autopilotWakeEnabled: z.boolean().required(false),
82
+ autopilotEnabled: z.boolean().required(false),
83
+ wakeSchedulerEnabled: z.boolean().default(true)
27
84
  });
28
85
  /** 从插件 Config 提取 entry 默认(settings base 层) */
29
86
  function entryDefaults(config) {
@@ -32,12 +89,11 @@ function entryDefaults(config) {
32
89
  rebuildEnabled: config.rebuild?.enabled ?? true,
33
90
  rebuildThresholdK: config.rebuild?.thresholdK ?? 400,
34
91
  skiffEnabled: config.skiff?.enabled ?? false,
35
- skiffDebugPort: config.skiff?.debugPort ?? 3099,
92
+ skiffDebugPort: config.skiff?.debugPort ?? SKIFF_DEBUG_PORT,
36
93
  acpEnabled: config.acp?.enabled ?? false,
37
- acpHttpPort: config.acp?.httpPort ?? 3100,
94
+ acpHttpPort: config.acp?.httpPort ?? ACP_HTTP_PORT,
38
95
  publicAskEnabled: config.publicAsk?.enabled ?? false,
39
- autopilotEnabled: false,
40
- trajectoryEnabled: false
96
+ wakeSchedulerEnabled: true
41
97
  };
42
98
  }
43
99
  /** 运行时源(installSettingsSection 注入:settings scope 或 entry fallback) */
@@ -51,12 +107,11 @@ function defaultSimpleSettings() {
51
107
  rebuildEnabled: true,
52
108
  rebuildThresholdK: 400,
53
109
  skiffEnabled: false,
54
- skiffDebugPort: 3099,
110
+ skiffDebugPort: SKIFF_DEBUG_PORT,
55
111
  acpEnabled: false,
56
- acpHttpPort: 3100,
112
+ acpHttpPort: ACP_HTTP_PORT,
57
113
  publicAskEnabled: false,
58
- autopilotEnabled: false,
59
- trajectoryEnabled: false
114
+ wakeSchedulerEnabled: true
60
115
  };
61
116
  }
62
117
  /**
@@ -98,4 +153,4 @@ function registerSettingsSection(ctx, config) {
98
153
  hooks.onChange();
99
154
  }
100
155
  //#endregion
101
- export { registerSettingsSection as n, settings_section_exports as r, readSimpleSettings as t };
156
+ export { FACE_PORTS as a, MECHANISM_PORTS as c, ACP_HTTP_PORT as i, SKIFF_DEBUG_PORT as l, registerSettingsSection as n, GATEWAY_PORT as o, settings_section_exports as r, MAIN_WEB_PORT as s, readSimpleSettings as t, WEIXIN_SEND_PORT as u };
@@ -16,9 +16,8 @@
16
16
  * 则显示降级提示(引导去宁静号面板),在则渲染 schema 表单。零配置自动适配。
17
17
  */
18
18
  import type { Context } from 'cordis';
19
- import z from '@deepseek-ai/schemastery';
20
19
  /** 插件 Config 的简单配置片段(index.ts Config 组合;settings entry base) */
21
- export interface SimpleConfigFragment {
20
+ interface SimpleConfigFragment {
22
21
  gateway?: {
23
22
  enabled?: boolean;
24
23
  };
@@ -47,7 +46,7 @@ export declare const SERENITY_SETTINGS_NS = "serenity-hooks";
47
46
  * 简单配置 schema(schemastery):三功能总开关 + F2 阈值 + F4 Skiff 启停。
48
47
  * 与 DSH settings 的 schema 语义一致(z.object 布尔/数字)。
49
48
  */
50
- export interface SerenitySimpleSettings {
49
+ interface SerenitySimpleSettings {
51
50
  /** F1 双端口网关总开关 */
52
51
  gatewayEnabled: boolean;
53
52
  /** F2 超限重建总开关 */
@@ -64,41 +63,20 @@ export interface SerenitySimpleSettings {
64
63
  acpHttpPort: number;
65
64
  /** F4d 建议问答页总开关(实验性;默认关——按认知容器暴露问答页,key 认证) */
66
65
  publicAskEnabled: boolean;
67
- /** Autopilot Trajectory 全局总开关(v1.27.9,默认关——只在指定电脑开启;
68
- * 关了即使 CCC 配置 enabled=true 也不启动定时器;CCC 级 enabled 仍为必要条件) */
69
- autopilotEnabled: boolean;
70
- /** trajectory 全局总开关(D58/M-1,S142 2026-09-13):**autopilot 与唤醒调度器共用**。
71
- * 读取顺序:`trajectoryEnabled` → 旧键 `autopilotEnabled`(逐级回退,不回写)。 */
72
- trajectoryEnabled: boolean;
66
+ /** **周期自唤醒(autopilot)全局闸** —— v1.34 更名收窄(原 `autopilotEnabled`)。
67
+ * **只管周期自唤醒**:关掉它**不**影响一次性唤醒 `container_trajectory wake-later`(后者归 {@link wakeSchedulerEnabled})。
68
+ * 缺省关(多台电脑装 dsp 时只在指定电脑跑周期自唤醒)。
69
+ * 可选类型是为了**迁移语义精确**:老装机里存的旧键 `autopilotEnabled` 仍应生效,而"新键显式 false"必须能覆盖它。 */
70
+ autopilotWakeEnabled?: boolean;
71
+ /** @deprecated v1.34 前的旧键(**仅迁移期回退读**,不回写)。新装/已迁移请用 `autopilotWakeEnabled` */
72
+ autopilotEnabled?: boolean;
73
+ /** **唤醒调度器全局闸** —— v1.34 更名(原 `trajectoryEnabled`):投递已登记的"未来时刻 + 一条 message"。
74
+ * **缺省开**:它是 trajectory 的基础能力(D58),且**不得**被"关掉周期自唤醒"连带关掉
75
+ * ——用户 2026-09-15 裁决:「auto-trajectory 的开关只关闭 auto-trajectory 唤醒」。 */
76
+ wakeSchedulerEnabled: boolean;
73
77
  }
74
- /** schemastery schema(与 DSH 各插件 Config 同款) */
75
- export declare const simpleSettingsSchema: z<Schemastery.ObjectS<{
76
- gatewayEnabled: z<boolean, boolean>;
77
- rebuildEnabled: z<boolean, boolean>;
78
- rebuildThresholdK: z<number, number>;
79
- skiffEnabled: z<boolean, boolean>;
80
- skiffDebugPort: z<number, number>;
81
- acpEnabled: z<boolean, boolean>;
82
- acpHttpPort: z<number, number>;
83
- publicAskEnabled: z<boolean, boolean>;
84
- autopilotEnabled: z<boolean, boolean>;
85
- trajectoryEnabled: z<boolean, boolean>;
86
- }>, Schemastery.ObjectT<{
87
- gatewayEnabled: z<boolean, boolean>;
88
- rebuildEnabled: z<boolean, boolean>;
89
- rebuildThresholdK: z<number, number>;
90
- skiffEnabled: z<boolean, boolean>;
91
- skiffDebugPort: z<number, number>;
92
- acpEnabled: z<boolean, boolean>;
93
- acpHttpPort: z<number, number>;
94
- publicAskEnabled: z<boolean, boolean>;
95
- autopilotEnabled: z<boolean, boolean>;
96
- trajectoryEnabled: z<boolean, boolean>;
97
- }>>;
98
78
  /** 从插件 Config 提取 entry 默认(settings base 层) */
99
79
  export declare function entryDefaults(config: SimpleConfigFragment): SerenitySimpleSettings;
100
- /** 测试辅助:重置"缺 settings provider"告警去重(生产零调用) */
101
- export declare function __resetSettingsWarningsForTest(): void;
102
80
  /** 进程级默认(无 settings 服务时的兜底) */
103
81
  export declare function defaultSimpleSettings(): SerenitySimpleSettings;
104
82
  /**
@@ -120,3 +98,4 @@ export declare function __setSimpleSourceForTest(source: (() => SerenitySimpleSe
120
98
  * (owner = consumer 插件 ctx;ns 直接字符串)。
121
99
  */
122
100
  export declare function registerSettingsSection(ctx: Context, config: SimpleConfigFragment): void;
101
+ export {};
@@ -31,7 +31,7 @@ export declare function skiffSessionSnapshot(): ReadonlyMap<string, {
31
31
  * 系统提示词中的**工作台纪律块**(v1.30.4 升级:从单行路径 → 完整 ACC 层约束)。
32
32
  * 用户点破(S142):只给路径 LLM 不会主动用——需注入「已绑定 + 使用纪律 + 动作指引」。
33
33
  * SESSION = 工作台——skiff 与主舱同一套机制(零特调,用户拍板):
34
- * 自动绑定已生效(无需 logbook use)、SESSION.md 是持久记忆载体、rebuild 自动从本 SESSION 续接。
34
+ * 自动绑定已生效(无需 container_trajectory use)、SESSION.md 是持久记忆载体、rebuild 自动从本 SESSION 续接。
35
35
  * 注入 agent 系统提示词(用户对话面不可见)。
36
36
  *
37
37
  * v1.30.13(S142 诊断 D5):写入纪律**不点名具体工具**。旧文案写死 "with write/edit",
@@ -81,13 +81,7 @@ export declare function ensureWorkspacePromptSection(agent: Agent, scope: string
81
81
  * @returns 绑定后的 SESSION.md 绝对路径(供提示词注入);不适用/失败 → null
82
82
  */
83
83
  export declare function ensureSkiffSession(root: string, agent: Agent, roleName: string, role: SkiffRoleConfig, persistent?: boolean): string | null;
84
- /** 当前 scope 是否已激活(幂等判定:getActiveSessionInfo 命中同 dirName)——测试用 */
85
- export declare function skiffSessionActiveFor(sessionId: string): {
86
- sessionId: string;
87
- dirName: string;
88
- mdPath: string;
89
- } | null;
90
- export interface SkiffAgentRef {
84
+ interface SkiffAgentRef {
91
85
  handle: AgentHandle;
92
86
  agent: Agent;
93
87
  sessionId: string;
@@ -114,7 +108,7 @@ export interface SkiffTrajectoryEntry {
114
108
  /** assistant 的工具调用名(有则填) */
115
109
  tool?: string;
116
110
  }
117
- export interface SkiffAskResult {
111
+ interface SkiffAskResult {
118
112
  answer: string;
119
113
  sessionId: string;
120
114
  trajectory: SkiffTrajectoryEntry[];
@@ -135,7 +129,7 @@ export declare function askSkiff(ctx: Context, agent: Agent, question: string, e
135
129
  * 注册表缺失(进程重启遗留等)→ 保守旁路(false,完全独立)。
136
130
  */
137
131
  export declare function skiffTrajectoryEnabled(root: string, sessionId: string | undefined, key: 'session' | 'keeper' | 'rebuild'): boolean;
138
- export interface SkiffMsmGate {
132
+ interface SkiffMsmGate {
139
133
  /** 拒绝原因(有则拒绝执行) */
140
134
  reject?: string;
141
135
  /** list 显示白名单(msms);仅 action==='list' 时有值 */
@@ -147,3 +141,4 @@ export interface SkiffMsmGate {
147
141
  * list 白名单过滤、check/guide/ccc-config 只读放行。
148
142
  */
149
143
  export declare function skiffMsmGate(root: string, sessionId: string | undefined, action: string, name?: string): SkiffMsmGate;
144
+ export {};
@@ -18,30 +18,19 @@
18
18
  * 实验性质:未开启时零资源占用(无监听、无 agent 创建)。
19
19
  */
20
20
  import type { Context } from 'cordis';
21
- import { type SkiffTrajectoryEntry } from './skiff-core.js';
21
+ import { type CccEntry } from './ccc-roots.js';
22
+ import { type FaceSpec } from './face-host.js';
22
23
  export declare function skiffDebugActive(): boolean;
23
24
  export declare function skiffDebugPort(): number | null;
24
- /** 候选 CCC 条目(调试页 CCC 切换器数据) */
25
- export interface SkiffCccEntry {
26
- /** CCC 根(绝对路径) */
27
- root: string;
28
- /** 目录名(展示用) */
29
- name: string;
30
- /** 该 CCC 的 skiff 角色名列表(实时读取) */
31
- roles: string[];
32
- }
33
25
  /**
34
- * 发现候选 CCC 列表(多 CCC 手工切换,v1.25.6):
35
- * ① **dsh 工作区注册表**(workspaceRegistry.list,持久化——所有工作目录即使无 live 会话;
36
- * S142 用户 2026-08-29:应直接拉 dsh 工作区,且只列具体 CCC)
37
- * ② **sessionPersistence 兜底**(持久化会话 headers——必装配服务,覆盖所有历史会话工作目录;
38
- * 用户实测 workspaceRegistry 拉取仍空时兜底)
39
- * ③ live 会话兜底
40
- * ④ 默认绑定 root 兜底(不在列表时放首位)
26
+ * 候选 CCC 条目(调试页 CCC 切换器数据)。
27
+ *
28
+ * C2:定义已迁至 `ccc-roots.ts`(L2 枚举的唯一真相源)——此处只在**类型层**转出
29
+ * (零运行时重导出,避免把 `ccc-roots` 拉进本模块的运行时静态链)。
41
30
  */
42
- export declare function discoverCccs(ctx: Context, defaultRoot: string): Promise<SkiffCccEntry[]>;
31
+ export type { CccEntry };
43
32
  /** 问答页 HTML:CCC 切换器 + 角色下拉 + 输入 + 答案区 + 轨迹区(JS 渲染)+ WebUI 链接 */
44
- export declare function skiffDebugPage(cccs: SkiffCccEntry[], defaultRoot: string, webPort: number): string;
33
+ export declare function skiffDebugPage(cccs: CccEntry[], defaultRoot: string, webPort: number): string;
45
34
  /**
46
35
  * JSC (Safari/iOS) JSON.parse 快速路径正则兼容化(v1.26.9,S142 调研定稿)。
47
36
  *
@@ -76,6 +65,11 @@ export declare function renderSkiffMarkdown(raw: string, hideThink?: boolean): s
76
65
  * 未闭合 think 优雅截断。适用于纯文本输出面(微信等不支持 think 折叠的通道)。
77
66
  */
78
67
  export declare function stripThink(raw: string): string;
68
+ /**
69
+ * 本面的规格(C4 块 A/④:**只提供** name/port/host/enabled/handler)。
70
+ * 路由/鉴权/HTML 全部仍归本模块的 {@link handle}(面宿主不介入面语义)。
71
+ */
72
+ export declare function skiffDebugSpec(ctx: Context, root: string, port: number, webPort: number): FaceSpec;
79
73
  /**
80
74
  * 启动调试问答服务(单实例;重复启动幂等返回既有实例)。
81
75
  *
@@ -83,11 +77,11 @@ export declare function stripThink(raw: string): string;
83
77
  * 解析:live 会话中**含 skiff.roles 的 CCC 优先**);v1.25.4 起页面可**手工切换**到
84
78
  * 其它候选 CCC(live 会话发现的全部 CCC);角色配置**每次请求实时读取**(不缓存快照)。
85
79
  *
80
+ * C4 块 A:listener 的创建/监听/错误/端口占用/关闭归 `face-host`(本函数只提供规格 + 记日志)。
81
+ *
86
82
  * @param root 默认绑定的 CCC 根(首次加载选中;角色配置读取 + skiff agent cwd)
87
83
  * @param port 调试端口(仅 127.0.0.1)
88
84
  * @param webPort 主 WebUI 端口(WebUI 链接)
89
85
  */
90
86
  export declare function startSkiffDebugServer(ctx: Context, root: string, port: number, webPort: number): Promise<void>;
91
87
  export declare function stopSkiffDebugServer(): void;
92
- /** 导出类型引用(测试断言轨迹结构) */
93
- export type { SkiffTrajectoryEntry };
@@ -0,0 +1,25 @@
1
+ //#region src/skiff-registry.ts
2
+ const skiffSessions = /* @__PURE__ */ new Map();
3
+ /** 查 sessionId 的 Skiff 角色名(无 → null)——向后兼容(guards/seams 依赖) */
4
+ function skiffRoleFor(sessionId) {
5
+ return skiffSessions.get(sessionId)?.role ?? null;
6
+ }
7
+ /** 查 sessionId 的完整绑定(role + ccc;无 → null)——v1.25.10 会话追问校验 */
8
+ function skiffSessionInfo(sessionId) {
9
+ return skiffSessions.get(sessionId) ?? null;
10
+ }
11
+ function registerSkiffSession(sessionId, role, ccc) {
12
+ skiffSessions.set(sessionId, {
13
+ role,
14
+ ccc
15
+ });
16
+ }
17
+ function unregisterSkiffSession(sessionId) {
18
+ skiffSessions.delete(sessionId);
19
+ }
20
+ /** 测试/调试:注册表快照(sessionId → {role, ccc}) */
21
+ function skiffSessionSnapshot() {
22
+ return new Map(skiffSessions);
23
+ }
24
+ //#endregion
25
+ export { unregisterSkiffSession as a, skiffSessionSnapshot as i, skiffRoleFor as n, skiffSessionInfo as r, registerSkiffSession as t };
@@ -11,7 +11,7 @@
11
11
  * 生命周期:进程内存态;连接/页面关闭时 unregister;进程重启自然清空(skiff 会话不复存在)。
12
12
  */
13
13
  /** 注册表值:会话绑定的角色 + CCC 根(追问延续校验用) */
14
- export interface SkiffSessionBinding {
14
+ interface SkiffSessionBinding {
15
15
  role: string;
16
16
  ccc: string;
17
17
  }
@@ -23,3 +23,4 @@ export declare function registerSkiffSession(sessionId: string, role: string, cc
23
23
  export declare function unregisterSkiffSession(sessionId: string): void;
24
24
  /** 测试/调试:注册表快照(sessionId → {role, ccc}) */
25
25
  export declare function skiffSessionSnapshot(): ReadonlyMap<string, SkiffSessionBinding>;
26
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
- import { m as resolveInside, p as readUtf8, s as loadSerenityConfig, t as DEFAULT_SERENITY_CONFIG_PATHS } from "./ccc-DAsSHsub.js";
2
+ import { h as resolveInside, m as readUtf8, s as loadSerenityConfig, t as DEFAULT_SERENITY_CONFIG_PATHS } from "./ccc-NlLr_sxy.js";
3
3
  import { existsSync, statSync } from "node:fs";
4
4
  //#region src/skiff-role.ts
5
5
  /**
@@ -20,7 +20,7 @@ export declare function isSkiffSessionId(sessionId: string | undefined): boolean
20
20
  */
21
21
  export declare function readSkiffRoles(root: string, paths?: string[]): Map<string, SkiffRoleConfig>;
22
22
  /** 某角色的轨迹纪律子集(缺省全 false = 完全独立) */
23
- export interface SkiffTrajectorySubset {
23
+ interface SkiffTrajectorySubset {
24
24
  session: boolean;
25
25
  keeper: boolean;
26
26
  rebuild: boolean;
@@ -49,7 +49,7 @@ export declare function systemPromptSource(role: SkiffRoleConfig | undefined): '
49
49
  * - 缺省 = 隐式推断:调用方给出**稳定 sessionId** → persistent;否则 temporary
50
50
  * (存量配置零迁移;微信桥传固定会话 id → persistent,ACP/调试页随机 id → temporary)
51
51
  */
52
- export type SkiffKind = 'temporary' | 'persistent';
52
+ type SkiffKind = 'temporary' | 'persistent';
53
53
  export declare function resolveSkiffKind(role: SkiffRoleConfig | undefined, hasStableId: boolean): SkiffKind;
54
54
  /**
55
55
  * 角色提示词**读取器**(v1.30.15,方案 A:长期型热更新)。
@@ -4,12 +4,12 @@
4
4
  * 兼容 opencode 的 skill 标准:`.opencode/skills/<name>/SKILL.md`
5
5
  * (frontmatter: name/description/whenToUse;结构含 references/、scripts/)。
6
6
  */
7
- export interface OpencodeSkillMeta {
7
+ interface OpencodeSkillMeta {
8
8
  name: string;
9
9
  description: string;
10
10
  whenToUse?: string;
11
11
  }
12
- export interface OpencodeSkill {
12
+ interface OpencodeSkill {
13
13
  name: string;
14
14
  dir: string;
15
15
  meta: OpencodeSkillMeta;
@@ -25,3 +25,4 @@ export declare function parseFrontmatter(raw: string): {
25
25
  export declare function listOpencodeSkillDirs(root: string): string[];
26
26
  /** 加载一个 opencode skill(frontmatter 解析 + 正文);读失败(EPERM/占用等)返回 null,单目录容错 */
27
27
  export declare function loadOpencodeSkill(skillDir: string): OpencodeSkill | null;
28
+ export {};
@@ -12,14 +12,27 @@
12
12
  *
13
13
  * 任何 CCC 都能自动注入其顶层入口 skill 全文(不硬编码名字)。
14
14
  */
15
- export type EntrySkillSource = 'serenity-marker' | 'pointer' | 'opencode' | 'dsh';
16
- export interface EntrySkill {
15
+ type EntrySkillSource = 'serenity-marker' | 'pointer' | 'opencode' | 'dsh';
16
+ interface EntrySkill {
17
17
  name: string;
18
18
  content: string;
19
19
  source: EntrySkillSource;
20
20
  }
21
+ /**
22
+ * 防穿越:skill 名必须是简单目录名(拒绝分隔符与 `..`/`.` 路径段)。
23
+ * v1.34.1:导出——轨迹 skill 声明(CCC 数据)的名字也要**先过这一关**才能用于拼路径
24
+ * (规格 `docs/trajectory-skill-injection.md` §3「名字安全(必做)」)。
25
+ */
26
+ export declare function isSafeSkillName(name: string): boolean;
27
+ /**
28
+ * 按名在两个 skills 根下定位 SKILL.md(`.dsh/skills` 优先,其次 `.opencode/skills`)。
29
+ * v1.34.1:导出——轨迹 skill 注入复用本函数(不新造发现逻辑);不安全名在此**先行拒绝**
30
+ * (返回 null,且不发生任何以该名拼出的 fs 访问)。
31
+ */
32
+ export declare function findSkillMd(root: string, name: string): string | null;
21
33
  /** 发现全部入口技能(原文全量,不截断) */
22
34
  export declare function findEntrySkills(root: string): EntrySkill[];
23
35
  /** 兼容旧接口:第一个入口(或 null) */
24
36
  export declare function findEntrySkill(root: string): EntrySkill | null;
25
37
  export declare function truncateContent(content: string, maxChars: number): string;
38
+ export {};
package/lib/status.d.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  * 依次尝试 npm_config_prefix / APPDATA\npm / ~/.npm-global。
11
11
  */
12
12
  export declare function readDshVersion(): string | null;
13
- export interface SerenityStatus {
13
+ interface SerenityStatus {
14
14
  root: string | null;
15
15
  accVersion: string;
16
16
  dshVersion: string | null;
@@ -36,3 +36,4 @@ export declare function getStatus(cwd: string, configPaths?: string[]): Serenity
36
36
  export declare function setSafeMode(root: string, on: boolean): {
37
37
  on: boolean;
38
38
  };
39
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * acc-diag.ts(工具面)— ACC 负责人专用的运行态诊断(v1.33,S142 §32.11)
3
+ *
4
+ * 用户裁决(2026-09-14):「不要 diag-live 了;或者变成一个隐藏 tool **只对 home-serenity 可见**,
5
+ * 做成我们专属的运行时诊断工具」。⇒ 合并原 `diag`(脚本侧条件链)+ `diag-live`(进程内运行态),
6
+ * 一次调用出全报告,并**从 CCC 工具面默认移除**。
7
+ *
8
+ * 可见性不在本文件判定(与 im-bridge 同一套机制):`seams/guards.ts`
9
+ * `syncExclusiveToolsVisibility` 在会话就绪 / pre-step 时按 CCC 配置
10
+ * `exclusiveTools` 决定是否 `agent.ctx.tools.restrict({ deny: ['acc-diag'] })`——
11
+ * **未声明的 CCC 看不到它**(不是"看得到但被拒")。
12
+ *
13
+ * 为什么必须是独立工具而不是 `container_admin` 的一个域(§32.11 ②):
14
+ * `tools.restrict` 是**工具级** deny,没有域级粒度——放进 container_admin 就等于
15
+ * 要隐藏它必须连 role/msm/config 一起隐藏。
16
+ */
17
+ import type { Context } from 'cordis';
18
+ /**
19
+ * 运行态诊断工具(`acc-diag`)。**无动作参数**:一次调用即全报告
20
+ * (live 运行态 / 面板解析 / 唤醒注册表 / 唤起条件链)。
21
+ */
22
+ export declare function createAccDiagTool(ctx: Context): import("@deepseek-ai/dsh-tools").ToolDefinition;