@shgroup/dsh-serenity-hooks 1.73.0 → 1.75.0

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 (48) hide show
  1. package/README.md +18 -12
  2. package/dsh.plugin.json +2 -2
  3. package/lib/accounts-BHQbakUh.js +33 -0
  4. package/lib/{ccc-CZUOq3NY.js → ccc-CyYJL4F2.js} +9 -9
  5. package/lib/{ccc-roots-BhoA7G-0.js → ccc-roots-BVxn97dY.js} +4 -4
  6. package/lib/client.js +116 -1
  7. package/lib/cro/core.d.ts +11 -1
  8. package/lib/cro/log.d.ts +54 -4
  9. package/lib/guard/seam.d.ts +4 -4
  10. package/lib/host/effect.d.ts +1 -1
  11. package/lib/im/bridge.d.ts +3 -3
  12. package/lib/im/endpoint.d.ts +2 -2
  13. package/lib/im/guard.d.ts +1 -1
  14. package/lib/im/hook.d.ts +1 -1
  15. package/lib/im/inbound-event.d.ts +6 -6
  16. package/lib/im/route.d.ts +25 -3
  17. package/lib/index.d.ts +5 -5
  18. package/lib/index.js +680 -295
  19. package/lib/kernel/ccc-roots.d.ts +4 -4
  20. package/lib/kernel/ccc.d.ts +20 -19
  21. package/lib/kernel/ports.d.ts +1 -1
  22. package/lib/{message-source-ChyVfev9.js → message-source-JhN-qyfn.js} +2 -2
  23. package/lib/patches/opencode-provider.d.ts +1 -1
  24. package/lib/{profile-BIQ2widI.js → profile-Cz4oBXlI.js} +197 -65
  25. package/lib/{route-ItCgAsnz.js → route-COOFLTpU.js} +44 -6
  26. package/lib/seams/guards.d.ts +14 -14
  27. package/lib/seams/keeper.d.ts +1 -1
  28. package/lib/seams/lifecycle.d.ts +2 -2
  29. package/lib/{settings-UcwIPJhM.js → settings-CII0Y597.js} +40 -26
  30. package/lib/surface/faces.d.ts +1 -1
  31. package/lib/surface/http.d.ts +1 -1
  32. package/lib/surface/settings.d.ts +7 -7
  33. package/lib/surface/text.d.ts +3 -3
  34. package/lib/tools/config-docs.d.ts +71 -0
  35. package/lib/tools/container-admin.d.ts +24 -12
  36. package/lib/tools/msm/service.d.ts +18 -0
  37. package/lib/tools/trajectory-constraint-admin.d.ts +30 -0
  38. package/lib/trajectory/carrier.d.ts +1 -1
  39. package/lib/trajectory/core.d.ts +11 -1
  40. package/lib/trajectory/policy/files.d.ts +75 -0
  41. package/lib/trajectory/policy/profile.d.ts +41 -36
  42. package/lib/trajectory/policy/rules.d.ts +33 -20
  43. package/lib/trajectory/policy/window.d.ts +13 -13
  44. package/lib/trajectory/prompt.d.ts +12 -12
  45. package/lib/trajectory/rebuild.d.ts +2 -2
  46. package/lib/trajectory/session.d.ts +49 -49
  47. package/package.json +2 -2
  48. package/lib/tools/skiff-admin.d.ts +0 -30
package/lib/im/hook.d.ts CHANGED
@@ -33,7 +33,7 @@ interface WeixinHookEventBase {
33
33
  userId: string;
34
34
  /** 固定会话 id(同用户长期同一:skiff-weixin-xxx) */
35
35
  sessionId: string;
36
- /** 路由命中的 skiff role */
36
+ /** 路由命中的 轨迹约束 role */
37
37
  role: string;
38
38
  }
39
39
  /** incoming 事件(用户 → bot):文本(含语音转写)+ 媒体(已落盘 relPath) */
@@ -29,7 +29,7 @@
29
29
  * - ✅ 只负责:「一条已到达的消息,该投到哪条认知轨迹、怎么答、怎么记账」。
30
30
  */
31
31
  import type { Context } from 'cordis';
32
- import { type SkiffProfile } from '../trajectory/policy/profile.js';
32
+ import { type TrajectoryConstraint } from '../trajectory/policy/profile.js';
33
33
  /**
34
34
  * 一条**已到达**的入站消息(归一后)。
35
35
  *
@@ -91,7 +91,7 @@ export interface ImAccountIo {
91
91
  }): Promise<void>;
92
92
  }
93
93
  /**
94
- * 路由解析结果:目标根 + **轨迹编码** + **该轨迹的 skiff 约束面**。
94
+ * 路由解析结果:目标根 + **轨迹编码** + **该轨迹的 轨迹约束面**。
95
95
  * `null` 从本函数出去 ⇒ **不投递**(未命中已留痕 / 目标不存在已响亮出声)。
96
96
  */
97
97
  export interface ResolvedInboundTarget {
@@ -99,11 +99,11 @@ export interface ResolvedInboundTarget {
99
99
  /** 目标认知轨迹编码(= 新模型里的"身份";旧模型的角色名已退役) */
100
100
  trajectory: string;
101
101
  /**
102
- * 该轨迹的 skiff 约束面。
103
- * ⚠️ **可能为 `null`**:轨迹存在但没有 `skiff.json` ⇒ 它是一条**普通轨迹**,
104
- * IM 桥照样可以往里投,只是不施加 skiff 约束。
102
+ * 该轨迹的 轨迹约束面。
103
+ * ⚠️ **可能为 `null`**:轨迹存在但没有 `trajectory-constraint.json` ⇒ 它是一条**普通轨迹**,
104
+ * IM 桥照样可以往里投,只是不施加 轨迹约束 约束。
105
105
  */
106
- profile: SkiffProfile | null;
106
+ profile: TrajectoryConstraint | null;
107
107
  }
108
108
  /**
109
109
  * **入站路由的单一解析处**(P0-3):机器级订阅表优先 → CCC 级回退;三档语义都在这里落地。
package/lib/im/route.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * 职责(零 DSH 依赖,可独立单测):
5
5
  * - 读取 CCC 的 weixin 配置(.opencode/serenity.json weixin 段——结构/路由/开关)
6
6
  * - 读取/写入 CCC localstore 的账号凭据(weixin.accounts.<accountId>.token/.baseUrl/.userId)
7
- * - 微信用户 → skiff 会话 id 映射(固定可重建:skiff-weixin-<sha256(userid)>.slice(1, 17);
7
+ * - 微信用户 → 轨迹约束会话 id 映射(固定可重建:skiff-weixin-<sha256(userid)>.slice(1, 17);
8
8
  * v1.27.3 错位一位避开损坏 log)
9
9
  * - 路由匹配(exact user → 通配 * 兜底)
10
10
  *
@@ -13,7 +13,7 @@
13
13
  */
14
14
  import { type WeixinSettings, type WeixinRouteConfig, type WeixinAccountConfig, type ImSettings } from '../kernel/ccc.js';
15
15
  import type { WeixinMediaRef, WeixinMessageItem } from './ilink.js';
16
- /** 判定 sessionId 是否为微信桥会话(**命名形态**判定;权力面判据见 `isSkiffSession`) */
16
+ /** 判定 sessionId 是否为微信桥会话(**命名形态**判定;权力面判据见 `isTrajectoryConstrained`) */
17
17
  export declare function isWeixinSessionId(sessionId: string | undefined): boolean;
18
18
  /**
19
19
  * **轨迹编码 → 固定的 dsh 会话 id**(2026-10-19 重做:身份挂在轨迹上,不挂在用户上)。
@@ -25,7 +25,7 @@ export declare function isWeixinSessionId(sessionId: string | undefined): boolea
25
25
  * 对不上旧会话的历史工具清单)。⇒ 那不是"轨迹是一等公民",那是"用户是一等公民"。
26
26
  *
27
27
  * 新派生 = **由轨迹编码决定**:同一条轨迹 ⇒ 恒同一条 dsh 会话(无论谁在跟它说话);
28
- * 换轨迹 ⇒ 新会话。这正是"skiff 是认知轨迹的一种"。
28
+ * 换轨迹 ⇒ 新会话。这正是"轨迹约束是认知轨迹的一种"。
29
29
  *
30
30
  * ## 连带删掉的东西
31
31
  *
@@ -91,6 +91,20 @@ export declare function readFeishuCredential(root: string, accountId: string): F
91
91
  export declare function writeFeishuCredential(root: string, accountId: string, cred: FeishuAccountCredential): void;
92
92
  /** 清除飞书账号凭据(移除账号时) */
93
93
  export declare function clearFeishuCredential(root: string, accountId: string): void;
94
+ /**
95
+ * **按渠道判「该账号是否已绑定凭据」**(面板读数用;单一处)。
96
+ *
97
+ * 🔴 为什么需要它(2026-10-19 P2 面板实测缺陷):面板原先对所有账号都调
98
+ * `readWeixinCredential`(只看 `WEIXIN_<A>_TOKEN`)。一个**飞书**账号的凭据在
99
+ * `FEISHU_<A>_APPID|SECRET`,走那条读法**必然读到 null** ⇒ 面板把一个配好的飞书账号
100
+ * 显示成「未绑定凭据」,用户据此以为没配上。
101
+ *
102
+ * 判据与装配处**同源**(`im/bridge.ts` 的 `readImCredentialByChannel`):飞书要 appId **且**
103
+ * appSecret,微信只要有 token。两处若各写一份判据,就会重演"两个读数器给出不同答案"。
104
+ *
105
+ * ⚠️ 只回**布尔**,不回任何凭据值 —— 这是 wire 面。
106
+ */
107
+ export declare function imCredentialBound(root: string, accountId: string, channel: string | undefined): boolean;
94
108
  /**
95
109
  * 路由匹配:exact user 优先,通配 `*` 兜底。
96
110
  * @returns 命中的**轨迹编码**;未命中 → null(无路由 → 消息不回复/忽略)
@@ -145,5 +159,13 @@ export declare function saveWeixinRoutes(root: string, routes: WeixinRouteConfig
145
159
  * 移除中间账号后不冲突(wechat-2 被删 → 新账号复用 wechat-2 而非跳到 4)。
146
160
  */
147
161
  export declare function nextWeixinAccountId(settings: WeixinSettings): string;
162
+ /**
163
+ * 生成下一个可用飞书账号 id(`feishu-N`,N 取**最小未占用**)。
164
+ *
165
+ * 与 {@link nextWeixinAccountId} 分开而不是加参数:两者的**前缀不同**,
166
+ * 而前缀是给人看的(面板上一眼分清哪些账号来自哪个渠道)。
167
+ * 判据相同(最小未占用,删中间不跳号)。
168
+ */
169
+ export declare function nextFeishuAccountId(settings: WeixinSettings): string;
148
170
  /** 切换总开关 */
149
171
  export declare function setWeixinEnabled(root: string, enabled: boolean): WeixinSettings;
package/lib/index.d.ts CHANGED
@@ -68,7 +68,7 @@ export type HumanChannelSubscriptionConfig = {
68
68
  user?: string;
69
69
  /** 目标 CCC(别名) */
70
70
  ccc?: string;
71
- /** 目标 skiff 角色名(∈ 该 CCC 的 `skiff.roles`) */
71
+ /** 目标 轨迹约束角色名(∈ 该 CCC 的 `轨迹约束.roles`) */
72
72
  role?: string;
73
73
  };
74
74
  export interface HumanChannelConfig {
@@ -76,8 +76,8 @@ export interface HumanChannelConfig {
76
76
  accounts?: HumanChannelAccountConfig[];
77
77
  /**
78
78
  * 订阅表:`(账号, 用户) → (CCC, 角色)` —— **收到**谁的消息。
79
- * 🔴 机器级**显式表**,**不得**由"该 CCC 有没有 skiff 角色"推断(owner 2026-09-26 更正):
80
- * skiff 用途很多(传话员只是其一),推断会让**为别的目的建的 skiff 被静默误接上微信**。
79
+ * 🔴 机器级**显式表**,**不得**由"该 CCC 有没有 轨迹约束角色"推断(owner 2026-09-26 更正):
80
+ * 轨迹约束 用途很多(传话员只是其一),推断会让**为别的目的建的 轨迹约束 被静默误接上微信**。
81
81
  */
82
82
  subscriptions?: HumanChannelSubscriptionConfig[];
83
83
  /** 主控(relay):**唯一**可做跨 CCC 动作的 CCC */
@@ -124,8 +124,8 @@ export interface Config {
124
124
  enabled?: boolean;
125
125
  thresholdK?: number;
126
126
  };
127
- /** F4 Skiff(实验性):调试服务启停(entry 默认值,运行时经 DSH settings) */
128
- skiff?: {
127
+ /** F4 轨迹约束(实验性):调试服务启停(entry 默认值,运行时经 DSH settings) */
128
+ 轨迹约束?: {
129
129
  enabled?: boolean;
130
130
  debugPort?: number;
131
131
  };