@shgroup/dsh-serenity-hooks 1.104.0 → 1.107.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.
- package/README.md +4 -3
- package/dsh.plugin.json +2 -3
- package/lib/{profile-Dpg3wYO5.js → bind-file-B0TuOP89.js} +1 -333
- package/lib/{ccc-B-h_A7uc.js → ccc-BmpE3cQz.js} +64 -12
- package/lib/{ccc-roots-BIdg0EyM.js → ccc-roots-DPMwBywc.js} +15 -3
- package/lib/{channels-BItMJUO8.js → channels-Dty_NIl_.js} +2 -146
- package/lib/contract-BiNzzd77.js +2197 -0
- package/lib/host/access.d.ts +30 -0
- package/lib/index.js +176 -6355
- package/lib/invariant.js +1 -2
- package/lib/kernel/ccc.d.ts +60 -13
- package/lib/kernel/invariant.d.ts +2 -2
- package/lib/message-source-BTIe2cVO.js +254 -0
- package/lib/observation-BWpkA865.js +210 -0
- package/lib/profile-BjBn_-be.js +336 -0
- package/lib/{route-CmEoKp9w.js → route-reyv8qcB.js} +2 -2
- package/lib/rules-BLkYTPUy.js +261 -0
- package/lib/scheduler-B0pB9mxI.js +3603 -0
- package/lib/seams/guards.d.ts +0 -4
- package/lib/{service-Cndtf7q4.js → service-Z3aSR1cn.js} +1 -1
- package/lib/service-xvjwsX3p.js +249 -0
- package/lib/{session-CaNqSHVB.js → session-BlgUdKH4.js} +55 -6
- package/lib/settings-DY4_DYYY.js +145 -0
- package/lib/subscriptions-CyrfNpcG.js +273 -0
- package/lib/tools/diag/service.d.ts +74 -24
- package/lib/tools/kit/service.d.ts +1 -1
- package/lib/tools/msm/service.d.ts +2 -2
- package/lib/trajectory/subscriptions.d.ts +170 -0
- package/package.json +2 -2
- package/lib/message-source-CKJPJCzc.js +0 -513
- package/lib/tools/diag/index.d.ts +0 -25
|
@@ -1,150 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as readWeixinSettings, o as readImSettings } from "./route-CmEoKp9w.js";
|
|
1
|
+
import { c as readWeixinSettings, o as readImSettings } from "./route-reyv8qcB.js";
|
|
3
2
|
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
4
3
|
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
5
|
-
//#region src/surface/settings.ts
|
|
6
|
-
/**
|
|
7
|
-
* 设置面板命名空间 = **profile 条目 id**(v0.1.7 起;与旧 `settings.yaml` 段名逐字相同)。
|
|
8
|
-
*/
|
|
9
|
-
const SERENITY_SETTINGS_NS = "serenity-hooks";
|
|
10
|
-
/** 进程级默认(无 Config 可读时的兜底;与 Config 各字段的缺省一致) */
|
|
11
|
-
function defaultSimpleSettings() {
|
|
12
|
-
return {
|
|
13
|
-
gatewayEnabled: false,
|
|
14
|
-
rebuildThresholdK: 400,
|
|
15
|
-
croEnabled: true,
|
|
16
|
-
diagramEnabled: false,
|
|
17
|
-
humanChannel: defaultHumanChannelSettings()
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* volatile 字段的**结构化解包**(v1.47.2;本文件读取语义的第一道)。
|
|
22
|
-
*
|
|
23
|
-
* ## 为什么必须有它(两个事实的合成,缺一即错)
|
|
24
|
-
* ① **0.1.7 的面板层字段必须标 `.volatile()`** —— 否则本插件命名空间整个不进宿主的
|
|
25
|
-
* `settings.describe()`(`volatileForm()` 只认 `meta.volatile`)⇒ **设置面板那一节消失**。
|
|
26
|
-
* ② **标了之后,运行期拿到的是引用包装,不是裸值** —— schemastery 的 `Schema.resolve()` 对
|
|
27
|
-
* `meta.volatile` **无条件**包 `createVolatile(value)`,且该分支排在"缺省值回退"那一段
|
|
28
|
-
* **之前** ⇒ **"用户没设过"的字段也是恒真对象**(`.get()` 返回 `undefined`),**不是 `undefined`**。
|
|
29
|
-
*
|
|
30
|
-
* ⇒ 若这里不解包,下面十行的 `??` 链会**短路在这层包装上** ⇒ 网关 / 轨迹约束 会被
|
|
31
|
-
* **无意打开**(比"面板不显示"更坏:静默改变对外暴露面)。
|
|
32
|
-
*
|
|
33
|
-
* ## 为什么用结构判定
|
|
34
|
-
* 可观察形状就是"有 `get()`"(cosmokit 的 `isVolatile` 也这么判);本模块不引它的运行时依赖。
|
|
35
|
-
*
|
|
36
|
-
* @param value - volatile 引用 | 裸值 | undefined
|
|
37
|
-
* @returns 解包后的裸值(引用 ⇒ `.get()`;裸值原样;缺省 ⇒ `undefined`)
|
|
38
|
-
*/
|
|
39
|
-
function unwrapVolatile(value) {
|
|
40
|
-
if (value === void 0 || value === null) return void 0;
|
|
41
|
-
if (typeof value.get === "function") return value.get();
|
|
42
|
-
return value;
|
|
43
|
-
}
|
|
44
|
-
/** human-channel 的内建缺省(与 `Config` 的 schema 缺省**同源**:这里是读取面,那里是解析面) */
|
|
45
|
-
function defaultHumanChannelSettings() {
|
|
46
|
-
return {
|
|
47
|
-
accounts: [],
|
|
48
|
-
subscriptions: [],
|
|
49
|
-
relayCcc: null,
|
|
50
|
-
sendingAllow: ["*"]
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
/** 取"有内容的字符串"(首尾空白剥掉;空白串 ⇒ `undefined`)—— 面板空文本框会写 `''`,那是"没填"不是"填了个空名" */
|
|
54
|
-
function nonEmptyText(value) {
|
|
55
|
-
if (typeof value !== "string") return void 0;
|
|
56
|
-
const trimmed = value.trim();
|
|
57
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* `humanChannel` 片段 → 运行时归一形态。**优先级:显式值 > 内建缺省**(与 `simpleSettingsFromConfig` 同族)。
|
|
61
|
-
*
|
|
62
|
-
* 🔴 三处"缺省 vs 显式"的语义差别,别写反:
|
|
63
|
-
* ① `sending.allow: []` ⇒ **`[]`**("谁都不许"),**不是**回退到 `['*']` —— 故用 `??`
|
|
64
|
-
* (只对 `undefined`/`null` 回退)。⚠️ **别拿 `??`→`||` 当变异探针**:空数组在 JS 里是
|
|
65
|
-
* **真值** ⇒ 两种写法在这个输入上**恰好同效**,那是**非变异**(会得出"测试不承重"的假结论)。
|
|
66
|
-
* ② `relay.ccc` 空白 ⇒ `null`("没填"与"没这一项"同义),**不是**把空白当 CCC 名;
|
|
67
|
-
* ③ 账号 `enabled` 缺省 **true**(老账号表里 `enabled` 不写就是开)。
|
|
68
|
-
*
|
|
69
|
-
* 🔴 **旧 CCC 侧 `weixin.*` 不在这里、也不该在这里**:机器级面**只**认 `humanChannel`
|
|
70
|
-
* (硬切无别名,同 D61 先例)⇒ 传进来的旧键**一律不进结构**(回归钉见
|
|
71
|
-
* `tests/human-channel-config.test.ts`;CCC 侧旧读取面的退役在 P0-2~P0-4)。
|
|
72
|
-
* @param fragment - `Config.humanChannel`(可能整个不存在 —— 那是**合法**初始态)
|
|
73
|
-
* @returns 归一形态(永不 `undefined`)
|
|
74
|
-
*/
|
|
75
|
-
function humanChannelSettingsFromConfig(fragment) {
|
|
76
|
-
const d = defaultHumanChannelSettings();
|
|
77
|
-
if (!fragment) return d;
|
|
78
|
-
return {
|
|
79
|
-
accounts: (fragment.accounts ?? []).map((a) => ({
|
|
80
|
-
id: nonEmptyText(a?.id),
|
|
81
|
-
channel: nonEmptyText(a?.channel),
|
|
82
|
-
enabled: a?.enabled !== false,
|
|
83
|
-
token: a?.token,
|
|
84
|
-
userId: a?.userId
|
|
85
|
-
})),
|
|
86
|
-
subscriptions: (fragment.subscriptions ?? []).map((s) => ({
|
|
87
|
-
account: nonEmptyText(s?.account),
|
|
88
|
-
user: nonEmptyText(s?.user),
|
|
89
|
-
ccc: nonEmptyText(s?.ccc),
|
|
90
|
-
role: nonEmptyText(s?.role)
|
|
91
|
-
})),
|
|
92
|
-
relayCcc: nonEmptyText(fragment.relay?.ccc) ?? d.relayCcc,
|
|
93
|
-
sendingAllow: fragment.sending?.allow ?? d.sendingAllow
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Config(宿主 Loader 校验后的解析值)→ 扁平简单配置。**本文件唯一的读取语义**。
|
|
98
|
-
*
|
|
99
|
-
* 优先级:**面板层(扁平键)> 部署层(嵌套段)> 内建缺省**。
|
|
100
|
-
* @param config - 插件 Config(`fiber.config` 或 apply 收到的 config)
|
|
101
|
-
* @returns 扁平开关集合
|
|
102
|
-
*/
|
|
103
|
-
function simpleSettingsFromConfig(config) {
|
|
104
|
-
const d = defaultSimpleSettings();
|
|
105
|
-
return {
|
|
106
|
-
gatewayEnabled: unwrapVolatile(config.gatewayEnabled) ?? config.gateway?.enabled ?? d.gatewayEnabled,
|
|
107
|
-
rebuildThresholdK: unwrapVolatile(config.rebuildThresholdK) ?? config.rebuild?.thresholdK ?? d.rebuildThresholdK,
|
|
108
|
-
croEnabled: unwrapVolatile(config.croEnabled) ?? d.croEnabled,
|
|
109
|
-
diagramEnabled: unwrapVolatile(config.diagramEnabled) ?? config.diagram?.enabled ?? d.diagramEnabled,
|
|
110
|
-
humanChannel: humanChannelSettingsFromConfig(config.humanChannel)
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
/** 运行时源(`registerSettingsSection` 装配:读本插件 fiber 的**当前** Config) */
|
|
114
|
-
let simpleSource = null;
|
|
115
|
-
/**
|
|
116
|
-
* 读取当前简单配置(各功能 gateway/rebuild/轨迹约束/… 的启动与运行时判断都经此)。
|
|
117
|
-
*
|
|
118
|
-
* 源 = 本插件 fiber 的 `config`(宿主在配置变更时走 `fiber.update()` ⇒ `config` 始终最新,
|
|
119
|
-
* **不必**依赖 apply 重跑,也不必缓存)。
|
|
120
|
-
* @returns 扁平开关集合
|
|
121
|
-
*/
|
|
122
|
-
function readSimpleSettings() {
|
|
123
|
-
return simpleSource ? simpleSource() : defaultSimpleSettings();
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* 装配简单配置读取面(v1.21 分层;**v0.1.7 起不再注册任何 section**)。
|
|
127
|
-
*
|
|
128
|
-
* 两件事:
|
|
129
|
-
* 1. 把"本插件自己的 Config"接成简单配置源 —— 读 `ctx.fiber.config`(宿主 `fiber.update()`
|
|
130
|
-
* 保证最新),拿不到 fiber 时退回 apply 收到的 `config`。
|
|
131
|
-
* 2. 关掉宿主按 Config schema **自动生成**的通用页(`settings.configure({ auto: false })`)——
|
|
132
|
-
* 门面是我们的自定义页 `client/SettingsSection.tsx`(同一个命名空间,同一份数据)。
|
|
133
|
-
*
|
|
134
|
-
* ⚠️ 两个失败都不阻断插件装载(面板是附属能力,绝不能成为启动单点)。
|
|
135
|
-
* @param ctx - 插件上下文
|
|
136
|
-
* @param config - apply 收到的 Config(fiber.config 不可用时的兜底)
|
|
137
|
-
*/
|
|
138
|
-
function registerSettingsSection(ctx, config) {
|
|
139
|
-
const fiber = ctx.fiber;
|
|
140
|
-
const readConfig = () => fiber?.config ?? config;
|
|
141
|
-
simpleSource = () => simpleSettingsFromConfig(readConfig());
|
|
142
|
-
const settings = hostSettings(ctx);
|
|
143
|
-
try {
|
|
144
|
-
settings?.configure?.({ auto: false }, fiber);
|
|
145
|
-
} catch {}
|
|
146
|
-
}
|
|
147
|
-
//#endregion
|
|
148
4
|
//#region src/im/log-scan.ts
|
|
149
5
|
/**
|
|
150
6
|
* im/log-scan.ts — 读聊天记录落盘,汇总出「与谁有过往来」(`contacts` 的数据源)
|
|
@@ -599,4 +455,4 @@ async function runImBridge(root, req) {
|
|
|
599
455
|
return fail("ACTION_UNKNOWN", `unknown action "${action}"`);
|
|
600
456
|
}
|
|
601
457
|
//#endregion
|
|
602
|
-
export {
|
|
458
|
+
export { runImBridge as i, isImWiredTrajectory as n, registerImChannel as r, imChannelIds as t };
|