@shgroup/dsh-serenity-hooks 1.69.0 → 1.69.2

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.
@@ -1,4 +1,4 @@
1
- import { r as cccRootForCwd } from "./ccc-roots-RMzGU-CJ.js";
1
+ import { r as cccRootForCwd } from "./ccc-roots-RzasspMr.js";
2
2
  import { basename, dirname, join } from "node:path";
3
3
  import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
4
4
  //#region src/time.ts
package/lib/ports.d.ts CHANGED
@@ -20,8 +20,8 @@
20
20
  * 本模块是**零依赖叶模块**(纯常量,无 import)——output-guard(守卫词表)、config-ops
21
21
  * (默认值)、settings-section(面板默认)、index(Config 默认)都可安全引用而不引入依赖环。
22
22
  */
23
- /** 面标识(五个对外面;A 由宿主监听,B/C/D/E 由本插件监听) */
24
- export type FaceId = 'main' | 'gateway' | 'weixinSend' | 'skiffDebug' | 'acp';
23
+ /** 面标识(四个对外面;A 由宿主监听,B/C/D 由本插件监听) */
24
+ export type FaceId = 'main' | 'gateway' | 'weixinSend' | 'skiffDebug';
25
25
  /** 一个面的端口语义 */
26
26
  export interface PortSpec {
27
27
  /** 端口号 */
@@ -36,7 +36,7 @@ export interface PortSpec {
36
36
  /**
37
37
  * 集中端口表。
38
38
  * A=宿主主面(插件不监听)/ B=网关(可配,默认关)/ C=微信发送(默认开,仅 loopback)
39
- * / D=Skiff 调试(默认关)/ E=ACP(默认关,`0.0.0.0`)。
39
+ * / D=Skiff 调试(默认关)。
40
40
  */
41
41
  export declare const FACE_PORTS: Readonly<Record<FaceId, PortSpec>>;
42
42
  /** 宿主主 WebUI 端口(面 A:插件**不监听**,只读取;`readWebPort` 的回退值) */
@@ -47,8 +47,6 @@ export declare const GATEWAY_PORT: number;
47
47
  export declare const WEIXIN_SEND_PORT: number;
48
48
  /** Skiff 调试页端口默认值(面 D) */
49
49
  export declare const SKIFF_DEBUG_PORT: number;
50
- /** 官方 ACP 面端口默认值(面 E,2026-10-16) */
51
- export declare const ACP_PORT: number;
52
50
  /**
53
51
  * **机制端口**词表(output-guard 用:agent 在**用户可见输出**里提及内部端口即打回)。
54
52
  *
@@ -1,4 +1,4 @@
1
- import { f as hostSettings } from "./ccc-roots-RMzGU-CJ.js";
1
+ import { f as hostSettings } from "./ccc-roots-RzasspMr.js";
2
2
  import { dirname, join } from "node:path";
3
3
  import { readFileSync } from "node:fs";
4
4
  import { fileURLToPath } from "node:url";
@@ -41,7 +41,7 @@ function unregisterSkiffSession(sessionId) {
41
41
  /**
42
42
  * 集中端口表。
43
43
  * A=宿主主面(插件不监听)/ B=网关(可配,默认关)/ C=微信发送(默认开,仅 loopback)
44
- * / D=Skiff 调试(默认关)/ E=ACP(默认关,`0.0.0.0`)。
44
+ * / D=Skiff 调试(默认关)。
45
45
  */
46
46
  const FACE_PORTS = {
47
47
  main: {
@@ -67,26 +67,6 @@ const FACE_PORTS = {
67
67
  host: "127.0.0.1",
68
68
  defaultEnabled: false,
69
69
  meaning: "Skiff 调试问答面(人工调试子角色;无认证,仅靠 loopback)"
70
- },
71
- /**
72
- * 🔴 面 E:**官方 ACP 面**(2026-10-16,owner 令「跑在 dsh web 进程内」→ 已实测跑通)。
73
- *
74
- * 与已退役的**旧面 E(3100)不是一回事**,别混淆:
75
- * · 旧面 E = 当年**自造**的 HTTP+HTML 问答面,2026-10-15 owner 裁「砍掉外部问答」时**整组退役**;
76
- * · 本面 = **官方 `@deepseek-ai/dsh-acp`**(官方 SDK + 现成客户端 Agmente),
77
- * 且**跑在宿主 web 进程内**(不另起进程、不需要 stdio 桥)。
78
- * ⇒ 端口**另选 3200**:既避开 3080/3081/3082/3099,也让"新旧一眼可分"。
79
- *
80
- * ⚠️ **安全边界(不许含混)**:**ACP 协议本身不做认证**(`dsh-acp` 的 `authenticate` 恒成功),
81
- * 而本面按 owner 裁决绑 **`0.0.0.0`**(局域网内任何设备可连)⇒ **必须靠外部接入层兜底**
82
- * (现为 Cloudflare Access)。⛔ **"隧道不是 ACC 该关心的事"(Q3 裁决)成立,但
83
- * "所以不需要认证层"不成立** —— 交付文档与诊断输出里都要显式带这个前提。
84
- */
85
- acp: {
86
- port: 3200,
87
- host: "0.0.0.0",
88
- defaultEnabled: false,
89
- meaning: "官方 ACP 面(Agmente 等标准客户端登入本 CCC;**协议无认证**,靠外部 Access 兜底)"
90
70
  }
91
71
  };
92
72
  /** 宿主主 WebUI 端口(面 A:插件**不监听**,只读取;`readWebPort` 的回退值) */
@@ -97,8 +77,6 @@ const GATEWAY_PORT = FACE_PORTS.gateway.port;
97
77
  const WEIXIN_SEND_PORT = FACE_PORTS.weixinSend.port;
98
78
  /** Skiff 调试页端口默认值(面 D) */
99
79
  const SKIFF_DEBUG_PORT = FACE_PORTS.skiffDebug.port;
100
- /** 官方 ACP 面端口默认值(面 E,2026-10-16) */
101
- const ACP_PORT = FACE_PORTS.acp.port;
102
80
  /**
103
81
  * **机制端口**词表(output-guard 用:agent 在**用户可见输出**里提及内部端口即打回)。
104
82
  *
@@ -124,8 +102,6 @@ function defaultSimpleSettings() {
124
102
  skiffDebugPort: SKIFF_DEBUG_PORT,
125
103
  croEnabled: true,
126
104
  diagramEnabled: false,
127
- acpFaceEnabled: false,
128
- acpFacePort: ACP_PORT,
129
105
  humanChannel: defaultHumanChannelSettings()
130
106
  };
131
107
  }
@@ -221,8 +197,6 @@ function simpleSettingsFromConfig(config) {
221
197
  skiffDebugPort: unwrapVolatile(config.skiffDebugPort) ?? config.skiff?.debugPort ?? d.skiffDebugPort,
222
198
  croEnabled: unwrapVolatile(config.croEnabled) ?? d.croEnabled,
223
199
  diagramEnabled: unwrapVolatile(config.diagramEnabled) ?? config.diagram?.enabled ?? d.diagramEnabled,
224
- acpFaceEnabled: unwrapVolatile(config.acpFaceEnabled) ?? config.acpFace?.enabled ?? d.acpFaceEnabled,
225
- acpFacePort: unwrapVolatile(config.acpFacePort) ?? config.acpFace?.port ?? d.acpFacePort,
226
200
  humanChannel: humanChannelSettingsFromConfig(config.humanChannel)
227
201
  };
228
202
  }
@@ -261,4 +235,4 @@ function registerSettingsSection(ctx, config) {
261
235
  } catch {}
262
236
  }
263
237
  //#endregion
264
- export { FACE_PORTS as a, MECHANISM_PORTS as c, registerSkiffSession as d, skiffRoleFor as f, ACC_VERSION as h, ACP_PORT as i, SKIFF_DEBUG_PORT as l, unregisterSkiffSession as m, readSimpleSettings as n, GATEWAY_PORT as o, skiffSessionInfo as p, registerSettingsSection as r, MAIN_WEB_PORT as s, SERENITY_SETTINGS_NS as t, WEIXIN_SEND_PORT as u };
238
+ export { GATEWAY_PORT as a, SKIFF_DEBUG_PORT as c, skiffRoleFor as d, skiffSessionInfo as f, FACE_PORTS as i, WEIXIN_SEND_PORT as l, ACC_VERSION as m, readSimpleSettings as n, MAIN_WEB_PORT as o, unregisterSkiffSession as p, registerSettingsSection as r, MECHANISM_PORTS as s, SERENITY_SETTINGS_NS as t, registerSkiffSession as u };
@@ -69,13 +69,6 @@ interface SimpleConfigFragment {
69
69
  diagram?: {
70
70
  enabled?: boolean;
71
71
  };
72
- /** 🔴 面 E(官方 ACP,2026-10-16 owner 令「跑在 dsh web 进程内」):部署层嵌套段。
73
- * ⚠️ **键名刻意不用 `acp.*`** —— 旧面 E 退役时 `acp.*` 是**被静默忽略**的遗留名,
74
- * 复用会让"当年那份旧配置"在新面上复活(判据:退役 ≠ 删名,名字仍需保留为"无人读")。 */
75
- acpFace?: {
76
- enabled?: boolean;
77
- port?: number;
78
- };
79
72
  /** human-channel(人机信道;**机器级**;2026-09-26 owner 定案):账号 / 订阅表 / 主控 / 出站白名单 */
80
73
  humanChannel?: HumanChannelConfigFragment;
81
74
  gatewayEnabled?: PanelBoolean;
@@ -84,9 +77,6 @@ interface SimpleConfigFragment {
84
77
  skiffDebugPort?: PanelNumber;
85
78
  croEnabled?: PanelBoolean;
86
79
  diagramEnabled?: PanelBoolean;
87
- /** 🔴 面 E(官方 ACP,2026-10-16):开关 + 端口(面板层扁平键) */
88
- acpFaceEnabled?: PanelBoolean;
89
- acpFacePort?: PanelNumber;
90
80
  }
91
81
  /**
92
82
  * 设置面板命名空间 = **profile 条目 id**(v0.1.7 起;与旧 `settings.yaml` 段名逐字相同)。
@@ -122,18 +112,6 @@ interface SerenitySimpleSettings {
122
112
  * 零 token、不会被误调),同 `skiff` 的"未开启零资源占用"口径。
123
113
  * 依赖面:随包分发 3.8 MB 内置字体(`assets/diagram/`,wasm 对系统字体不可见)。 */
124
114
  diagramEnabled: boolean;
125
- /** 🔴 **面 E:官方 ACP 总开关**(2026-10-16 owner 令「跑在 dsh web 进程内」;**缺省关**)。
126
- *
127
- * 开启后:ACC 在自己进程里起一个 **ACP 服务面**(面宿主统一建 listener),
128
- * 标准 ACP 客户端(Agmente 等)经 WebSocket 登入本 CCC —— **不另起进程、不需 stdio 桥**。
129
- * **缺省关**:① 它把本 CCC 开给外部客户端;② ⚠️ **ACP 协议本身无认证**(`dsh-acp` 的
130
- * `authenticate` 恒成功),而本面按 owner 裁决绑 **`0.0.0.0`** ⇒ **开之前必须有外部接入层
131
- * 兜底**(现为 Cloudflare Access)。缺省关 = "不配就没有暴露面"。
132
- * ⚠️ **与已退役的旧面 E(3100 自造问答面)无关**:本面是**官方** `@deepseek-ai/dsh-acp`。
133
- * 实测(P0′,8/8)见 S142 `2026-10-16T0745-…-p0prime-inproc-findings.md`。 */
134
- acpFaceEnabled: boolean;
135
- /** 面 E 端口(默认 3200;避开 3080/3081/3082/3099 与已退役的 3100) */
136
- acpFacePort: number;
137
115
  /** **human-channel(人机信道)机器级配置**(2026-09-26 owner 定案;P0-1 立 schema + 投影)。
138
116
  * 三张表(账号 / 订阅 / 主控)+ 出站白名单;**跨 CCC** ⇒ 归机器级,CCC 侧 `weixin.*` 随之退役
139
117
  * (退役动作在 P0-2~P0-4;本版**只立机器级面**,旧面照旧)。缺省与归一规则见
@@ -166,25 +166,38 @@ function createRolePromptReader(root, role) {
166
166
  };
167
167
  }
168
168
  /**
169
- * Skiff 基础提示词(dsp 只给这部分;CCC 的 systemPrompt 段由调用方拼接):
170
- * 身份 + 可用 MSM/工具清单 + 调用协议 + 边界声明。动态生成(清单来自角色白名单)。
169
+ * Skiff 基础提示词(dsp 只给这部分;CCC 的 systemPrompt 段由调用方拼接)。
170
+ *
171
+ * ## 🔴 为什么**不再枚举**清单(owner 2026-10-19 令)
172
+ *
173
+ * 旧版在这里抄了两份清单(`MSMs: a, b, c` / `Tools: read, grep, …`)。那是**第二真相源**,
174
+ * 而真相源本来就在模型自己手里:
175
+ * · **工具清单** = 这一轮实际注册给它的 tool schema —— 模型已经看得见,抄一遍只会漂
176
+ * · **MSM 清单** = `msm()` 无参调用返回的目录 —— 已按角色白名单过滤,且**每次实时读配置**
177
+ *
178
+ * ⚠️ **漂移不是理论风险,是已发生的缺陷**(2026-10-19):角色配置早就长到 8 个工具,
179
+ * 而这个函数是从**创建时冻结的 role 快照**求值的 ⇒ 提示词里一直写着旧的 4 个
180
+ * ⇒ 模型照着提示词办事,**它自己以为没有的能力就不去调** ⇒ 症状是"工具用不了",
181
+ * 而守卫那边(每调用实时读配置)其实是放行的。两个真相源打架,输的总是提示词。
182
+ *
183
+ * ⇒ 现在只声明**边界与发现路径**,不抄内容:清单在哪,怎么取,越界会怎样。
184
+ *
185
+ * @param roleName 角色名(CCC 定义;用于身份声明)
171
186
  */
172
- function buildSkiffBasePrompt(roleName, role) {
173
- const msms = role?.msms ?? [];
174
- const tools = role?.tools ?? [];
175
- const lines = [
187
+ function buildSkiffBasePrompt(roleName) {
188
+ return [
176
189
  "=== Serenity Skiff ===",
177
190
  `Role: ${roleName} (defined by this CCC)`,
178
- "You interact with this CCC ONLY through the exposed surface below:"
179
- ];
180
- if (msms.length > 0) lines.push(` MSMs: ${msms.join(", ")} (call msm("<name>", ["<args>"]) ; pass inspect=true or "--help" as first arg for usage)`);
181
- else lines.push(" MSMs: (none)");
182
- lines.push(` Tools: ${tools.length > 0 ? tools.join(", ") : "(none)"}`);
183
- lines.push("No other tools are available. Your capability boundary is this surface.");
184
- lines.push("");
185
- lines.push("---");
186
- lines.push("");
187
- return lines.join("\n");
191
+ "Your capability boundary is enforced mechanically by this CCC — anything outside it is rejected at the call site, not by your judgment.",
192
+ "Discover your surface, do not memorize it (both are generated from the live config on every turn):",
193
+ " · Your tools are exactly the tool schemas you see in this session — if a tool is not in your schema, it is not available.",
194
+ " · Your MSMs are listed by calling msm() with no arguments — that directory is already filtered to this role.",
195
+ " · Usage for any MSM: msm(\"<name>\", [], inspect=true) or pass \"--help\" as the first argument.",
196
+ "Do not infer unavailability from anything you remember or from an earlier list: this surface changes when the CCC configuration changes, and it takes effect without restarting.",
197
+ "",
198
+ "---",
199
+ ""
200
+ ].join("\n");
188
201
  }
189
202
  //#endregion
190
203
  export { isSkiffSessionId as a, resolveSkiffKind as c, skiff_role_exports as d, systemPromptSource as f, createRolePromptReader as i, roleMsmWhitelist as l, buildSkiffBasePrompt as n, readSkiffRoles as o, cognitiveTrajectorySubset as r, resolveRoleSystemPrompt as s, SKIFF_SESSION_PREFIX as t, roleToolWhitelist as u };
@@ -68,7 +68,22 @@ export declare function resolveSkiffKind(role: SkiffRoleConfig | undefined, hasS
68
68
  */
69
69
  export declare function createRolePromptReader(root: string, role: SkiffRoleConfig | undefined): () => string;
70
70
  /**
71
- * Skiff 基础提示词(dsp 只给这部分;CCC 的 systemPrompt 段由调用方拼接):
72
- * 身份 + 可用 MSM/工具清单 + 调用协议 + 边界声明。动态生成(清单来自角色白名单)。
71
+ * Skiff 基础提示词(dsp 只给这部分;CCC 的 systemPrompt 段由调用方拼接)。
72
+ *
73
+ * ## 🔴 为什么**不再枚举**清单(owner 2026-10-19 令)
74
+ *
75
+ * 旧版在这里抄了两份清单(`MSMs: a, b, c` / `Tools: read, grep, …`)。那是**第二真相源**,
76
+ * 而真相源本来就在模型自己手里:
77
+ * · **工具清单** = 这一轮实际注册给它的 tool schema —— 模型已经看得见,抄一遍只会漂
78
+ * · **MSM 清单** = `msm()` 无参调用返回的目录 —— 已按角色白名单过滤,且**每次实时读配置**
79
+ *
80
+ * ⚠️ **漂移不是理论风险,是已发生的缺陷**(2026-10-19):角色配置早就长到 8 个工具,
81
+ * 而这个函数是从**创建时冻结的 role 快照**求值的 ⇒ 提示词里一直写着旧的 4 个
82
+ * ⇒ 模型照着提示词办事,**它自己以为没有的能力就不去调** ⇒ 症状是"工具用不了",
83
+ * 而守卫那边(每调用实时读配置)其实是放行的。两个真相源打架,输的总是提示词。
84
+ *
85
+ * ⇒ 现在只声明**边界与发现路径**,不抄内容:清单在哪,怎么取,越界会怎样。
86
+ *
87
+ * @param roleName 角色名(CCC 定义;用于身份声明)
73
88
  */
74
- export declare function buildSkiffBasePrompt(roleName: string, role: SkiffRoleConfig | undefined): string;
89
+ export declare function buildSkiffBasePrompt(roleName: string): string;