dsh-plugin-om 0.0.61 → 0.0.63
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 +34 -17
- package/cordis.patch.yml +2 -0
- package/dist/client/OmEvalModelPanel.d.ts.map +1 -1
- package/dist/client/eval-model-register.d.ts +5 -2
- package/dist/client/eval-model-register.d.ts.map +1 -1
- package/dist/client/index.d.ts +2 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/locales.d.ts +3 -5
- package/dist/client/locales.d.ts.map +1 -1
- package/dist/client/om-config-controller.d.ts +3 -4
- package/dist/client/om-config-controller.d.ts.map +1 -1
- package/dist/client.js +34 -26
- package/dist/client.js.map +1 -1
- package/dist/compaction-eval/index.d.ts +8 -0
- package/dist/compaction-eval/index.d.ts.map +1 -0
- package/dist/compaction-eval/index.mjs +206 -0
- package/dist/compaction-eval-command.d.ts +6 -3
- package/dist/compaction-eval-command.d.ts.map +1 -1
- package/dist/compress.d.ts +1 -1
- package/dist/compress.d.ts.map +1 -1
- package/dist/config.d.ts +4 -8
- package/dist/config.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +38 -307
- package/dist/recompress.d.ts +5 -3
- package/dist/recompress.d.ts.map +1 -1
- package/dist/skill/compaction-eval/scripts/compress.mjs +21 -14
- package/dist/skill/compaction-eval/scripts/view.mjs +21 -14
- package/dist/system-reminder.d.ts +2 -2
- package/dist/system-reminder.d.ts.map +1 -1
- package/dist/utils-D-cEbiTF.mjs +89 -0
- package/locale/compaction-eval/en.json +6 -0
- package/locale/compaction-eval/zh.json +6 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +9 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { brandString } from "@deepseek-ai/dsh-brand";
|
|
1
|
+
import { a as renderMessageText, c as toolArgsJson, i as isRecord$1, l as uuid, n as blocksToText, o as routedTarget, r as isMainSession, s as seqsCharCount, t as appendCdataText } from "./utils-D-cEbiTF.mjs";
|
|
4
2
|
import { CompactionId } from "@deepseek-ai/dsh-compaction";
|
|
5
3
|
import { BlockAssembler, createAssistantMessage, createSystemMessage, createToolResultMessage, createUserMessage, freezeMessage, isAgentLoopRequest, markAgentLoopRequest } from "@deepseek-ai/dsh-llm";
|
|
6
4
|
import { scopeOf } from "@deepseek-ai/dsh-scope";
|
|
@@ -9,288 +7,15 @@ import { renderPrompt } from "@deepseek-ai/dsh-system-prompt";
|
|
|
9
7
|
import { z } from "zod";
|
|
10
8
|
import { SUBAGENT_DESCRIPTOR_VERSION } from "@deepseek-ai/dsh-subagent";
|
|
11
9
|
import Schema from "@deepseek-ai/schemastery";
|
|
10
|
+
import { copyFileSync, existsSync, mkdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
12
11
|
import { homedir } from "node:os";
|
|
13
12
|
import path from "node:path";
|
|
13
|
+
import { fileURLToPath } from "node:url";
|
|
14
14
|
import { toJSONSchema } from "zod/v4/core";
|
|
15
15
|
import { AttachmentId } from "@deepseek-ai/dsh-attachment";
|
|
16
16
|
//#region \0rolldown/runtime.js
|
|
17
17
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
18
18
|
//#endregion
|
|
19
|
-
//#region src/eval-session-text.ts
|
|
20
|
-
/**
|
|
21
|
-
* /om-compaction-eval 的文本契约:命令名与描述、新会话首条消息、成功文本及其反解。
|
|
22
|
-
* 宿主命令与客户端跳转共用本模块,因此不得引入 Node 专有依赖(客户端 bundle 会内联它)。
|
|
23
|
-
* 导出 EVAL_COMMAND_NAME / EVAL_COMMAND_DESCRIPTION / EvalPromptInput / buildEvalPrompt /
|
|
24
|
-
* evalStartedText / parseEvalSessionId。
|
|
25
|
-
*/
|
|
26
|
-
/** 命令名(无参数,裸调用即执行)。 */
|
|
27
|
-
const EVAL_COMMAND_NAME = "om-compaction-eval";
|
|
28
|
-
/** 命令描述(斜杠菜单与命令目录展示)。 */
|
|
29
|
-
const EVAL_COMMAND_DESCRIPTION = "ai分析OM结果";
|
|
30
|
-
/** 新会话首条消息:只给文档路径与会话标识,评估步骤全部由文档决定。 */
|
|
31
|
-
function buildEvalPrompt(input) {
|
|
32
|
-
const workspaceId = input.workspaceId === void 0 ? "" : ` workspace_id ${input.workspaceId}`;
|
|
33
|
-
return `按照 ${input.docPath} 分析会话。workspace ${input.cwd}${workspaceId} session_id ${input.sessionId}`;
|
|
34
|
-
}
|
|
35
|
-
/** 成功文本前缀;客户端按同一格式反解新会话 id 用于跳转。 */
|
|
36
|
-
const STARTED_PREFIX = "已启动 OM 结果分析会话 ";
|
|
37
|
-
/** 命令成功文本。 */
|
|
38
|
-
function evalStartedText(sessionId) {
|
|
39
|
-
return `${STARTED_PREFIX}${sessionId}`;
|
|
40
|
-
}
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region src/utils.ts
|
|
43
|
-
/** 判断值是否为普通对象(非 null、非数组)。 */
|
|
44
|
-
function isRecord$1(value) {
|
|
45
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
46
|
-
}
|
|
47
|
-
/** 生成 uuid:优先 crypto.randomUUID,回退为时间戳+随机串拼接。 */
|
|
48
|
-
function uuid() {
|
|
49
|
-
const cryptoObj = globalThis.crypto;
|
|
50
|
-
if (cryptoObj && typeof cryptoObj.randomUUID === "function") return cryptoObj.randomUUID();
|
|
51
|
-
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
|
|
52
|
-
}
|
|
53
|
-
/** 提取 content 数组中的纯文本块(type === 'text' 的 block.text 拼接)。 */
|
|
54
|
-
function blocksToText(blocks) {
|
|
55
|
-
if (!Array.isArray(blocks)) return "";
|
|
56
|
-
const out = [];
|
|
57
|
-
for (const block of blocks) if (isRecord$1(block) && block.type === "text" && typeof block.text === "string") out.push(block.text);
|
|
58
|
-
return out.join("");
|
|
59
|
-
}
|
|
60
|
-
/** 消息内容的字符数:递归计入 text 块与 tool-result 内嵌文本。 */
|
|
61
|
-
function textCharCount(message) {
|
|
62
|
-
if (!message || !Array.isArray(message.content)) return 0;
|
|
63
|
-
let total = 0;
|
|
64
|
-
for (const block of message.content) if (block.type === "text") total += block.text.length;
|
|
65
|
-
else if (block.type === "tool-result") total += blocksToText(block.content).length;
|
|
66
|
-
return total;
|
|
67
|
-
}
|
|
68
|
-
/** 一组表层事件 seq 派生消息的字符数之和(OM 卡片「原始字符」口径)。 */
|
|
69
|
-
function seqsCharCount(session, seqs) {
|
|
70
|
-
const events = session.snapshotEvents();
|
|
71
|
-
return seqs.reduce((total, seq) => {
|
|
72
|
-
const event = events[seq];
|
|
73
|
-
return total + textCharCount(event ? session.deriveEventMessage(event) : null);
|
|
74
|
-
}, 0);
|
|
75
|
-
}
|
|
76
|
-
/** 面向 recall 的完整消息呈现:text 原样;tool-call 展开(参数=代码);tool-result 取文本。 */
|
|
77
|
-
function renderMessageText(message) {
|
|
78
|
-
if (!message || !Array.isArray(message.content)) return "";
|
|
79
|
-
const parts = [];
|
|
80
|
-
for (const block of message.content) if (block.type === "text") parts.push(block.text);
|
|
81
|
-
else if (block.type === "tool-call") parts.push(`[tool-call ${block.name} id=${String(block.id)}]
|
|
82
|
-
${toolArgsJson(block.arguments)}`);
|
|
83
|
-
else if (block.type === "tool-result") parts.push(blocksToText(block.content));
|
|
84
|
-
return parts.join("\n");
|
|
85
|
-
}
|
|
86
|
-
/** 安全 JSON 序列化:序列化失败时退回 String 呈现。 */
|
|
87
|
-
function safeJson(value) {
|
|
88
|
-
try {
|
|
89
|
-
return JSON.stringify(value, null, 2);
|
|
90
|
-
} catch {
|
|
91
|
-
return String(value);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* 工具调用参数的 JSON 文本(CDATA 内保持只有一层 JSON 转义):
|
|
96
|
-
* 字符串参数是模型产出的原始 JSON 串,原样返回(本身即合法 JSON,不再二次序列化);
|
|
97
|
-
* 其余结构 JSON.stringify 序列化一次。
|
|
98
|
-
*/
|
|
99
|
-
function toolArgsJson(args) {
|
|
100
|
-
if (typeof args === "string") return args;
|
|
101
|
-
return safeJson(args);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* 向元素追加 CDATA 正文:正文统一以 CDATA 包裹(逐字原样,不做实体转义)。
|
|
105
|
-
* 正文含 ]]> 时拆为相邻多个 CDATA 段,拼接后逐字还原原文,对读取方透明。
|
|
106
|
-
*/
|
|
107
|
-
function appendCdataText(doc, el, text) {
|
|
108
|
-
const parts = text.split("]]>");
|
|
109
|
-
for (let i = 0; i < parts.length; i += 1) if (i === 0) el.appendChild(doc.createCDATASection(parts[0] ?? ""));
|
|
110
|
-
else {
|
|
111
|
-
el.appendChild(doc.createCDATASection("]]"));
|
|
112
|
-
el.appendChild(doc.createCDATASection(`>${parts[i] ?? ""}`));
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
/** 主会话判定:subagent 会话 header.origin === 'subagent'。 */
|
|
116
|
-
function isMainSession(session) {
|
|
117
|
-
return session.header?.origin !== "subagent";
|
|
118
|
-
}
|
|
119
|
-
/** 解析会话路由目标(provider/model),未路由时返回 undefined。 */
|
|
120
|
-
function routedTarget(session) {
|
|
121
|
-
try {
|
|
122
|
-
const config = session.requestHeader()?.config;
|
|
123
|
-
if (config?.provider && config.model) return {
|
|
124
|
-
provider: config.provider,
|
|
125
|
-
model: config.model
|
|
126
|
-
};
|
|
127
|
-
} catch {}
|
|
128
|
-
}
|
|
129
|
-
//#endregion
|
|
130
|
-
//#region src/compaction-eval-command.ts
|
|
131
|
-
/**
|
|
132
|
-
* /om-compaction-eval 命令:在被分析会话所属工作区新建一个会话,由它按随包发布的
|
|
133
|
-
* compaction-eval 文档分析当前会话的 OM 压缩结果,本会话上下文不受影响。
|
|
134
|
-
* 文档路径由本模块自身位置推出:发布产物优先,仓库源码兜底。
|
|
135
|
-
* 新会话的模型与思考等级默认沿用当前会话,可由命令参数 `provider/model [思考等级]` 指定。
|
|
136
|
-
* 导出 skillDocCandidates / skillDocPath / EvalModel / parseEvalModelInput /
|
|
137
|
-
* StartEvalResult / startEvalSession / buildCompactionEvalCommand。
|
|
138
|
-
*/
|
|
139
|
-
const MODEL_USAGE = "用法:/om-compaction-eval [provider/model [思考等级]]";
|
|
140
|
-
/**
|
|
141
|
-
* 解析命令参数 `provider/model [思考等级]`:以第一个 `/` 切分 provider 与 model,空白分隔等级。
|
|
142
|
-
* @returns 无参数时 model 为 undefined(沿用当前会话);格式错误返回用法说明。
|
|
143
|
-
*/
|
|
144
|
-
function parseEvalModelInput(rawInput) {
|
|
145
|
-
const parts = rawInput.split(/\s+/).filter((part) => part !== "");
|
|
146
|
-
if (parts.length === 0) return {
|
|
147
|
-
ok: true,
|
|
148
|
-
model: void 0
|
|
149
|
-
};
|
|
150
|
-
const [route, reasoningEffort] = parts;
|
|
151
|
-
const slash = route?.indexOf("/") ?? -1;
|
|
152
|
-
if (route === void 0 || slash <= 0 || slash === route.length - 1 || parts.length > 2) return {
|
|
153
|
-
ok: false,
|
|
154
|
-
error: MODEL_USAGE
|
|
155
|
-
};
|
|
156
|
-
return {
|
|
157
|
-
ok: true,
|
|
158
|
-
model: {
|
|
159
|
-
provider: route.slice(0, slash),
|
|
160
|
-
model: route.slice(slash + 1),
|
|
161
|
-
...reasoningEffort === void 0 ? {} : { reasoningEffort }
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
/** 当前会话最近一次请求使用的模型与思考等级;尚未请求过时 undefined。 */
|
|
166
|
-
function currentModel(session) {
|
|
167
|
-
try {
|
|
168
|
-
const config = session.requestHeader()?.config;
|
|
169
|
-
if (!config?.provider || !config.model) return void 0;
|
|
170
|
-
return {
|
|
171
|
-
provider: config.provider,
|
|
172
|
-
model: config.model,
|
|
173
|
-
...config.reasoningEffort === void 0 ? {} : { reasoningEffort: config.reasoningEffort }
|
|
174
|
-
};
|
|
175
|
-
} catch {
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* skill 文档候选绝对路径,按优先级排列:
|
|
181
|
-
* 1. 发布产物 dist/skill/compaction-eval/SKILL.md(脚本为自包含 .mjs);
|
|
182
|
-
* 2. 仓库源码 .agents/skills/compaction-eval/SKILL.md(开发时 dist 未构建)。
|
|
183
|
-
* @param fromUrl - 入口模块 URL,缺省为本模块(打包后即 dist/index.mjs)。
|
|
184
|
-
*/
|
|
185
|
-
function skillDocCandidates(fromUrl = import.meta.url) {
|
|
186
|
-
return [fileURLToPath(new URL("./skill/compaction-eval/SKILL.md", fromUrl)), fileURLToPath(new URL("../.agents/skills/compaction-eval/SKILL.md", fromUrl))];
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* 第一个存在的 skill 文档路径。
|
|
190
|
-
* @param fromUrl - 入口模块 URL,缺省为本模块。
|
|
191
|
-
* @returns 文档绝对路径;都不存在时 undefined。
|
|
192
|
-
*/
|
|
193
|
-
function skillDocPath(fromUrl = import.meta.url) {
|
|
194
|
-
return skillDocCandidates(fromUrl).find((candidate) => existsSync(candidate));
|
|
195
|
-
}
|
|
196
|
-
/** 当前会话所属工作区 id;宿主无 workspaceRegistry 或会话未归属时 undefined。 */
|
|
197
|
-
function workspaceOf(ctx, sessionId) {
|
|
198
|
-
const registry = ctx.get("workspaceRegistry");
|
|
199
|
-
if (registry === void 0) return void 0;
|
|
200
|
-
return registry.list().find((workspace) => workspace.sessionIds.includes(sessionId))?.id;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* 新建同工作区会话并投递首条消息。
|
|
204
|
-
* 非主会话、会话无 cwd、文档缺失或宿主缺 sessionController 时返回失败且不建会话;
|
|
205
|
-
* 建会话与投递的异常归一为失败原因。
|
|
206
|
-
* @param ctx - 宿主上下文(经 ctx.get 容错读取 sessionController 与 workspaceRegistry)。
|
|
207
|
-
* @param agent - 命令所针对的会话,其 id 与 cwd 决定分析目标与新会话位置。
|
|
208
|
-
* @param signal - 命令取消信号,透传给投递。
|
|
209
|
-
* @param model - 新会话模型;缺省沿用当前会话,当前会话尚未请求过时用宿主默认。
|
|
210
|
-
*/
|
|
211
|
-
async function startEvalSession(ctx, agent, signal, model) {
|
|
212
|
-
const session = agent.session;
|
|
213
|
-
if (!isMainSession(session)) return {
|
|
214
|
-
ok: false,
|
|
215
|
-
error: "OM 结果分析仅支持主会话"
|
|
216
|
-
};
|
|
217
|
-
const cwd = session.header?.cwd;
|
|
218
|
-
if (cwd === void 0 || cwd === "") return {
|
|
219
|
-
ok: false,
|
|
220
|
-
error: "当前会话没有工作区信息"
|
|
221
|
-
};
|
|
222
|
-
const docPath = skillDocPath();
|
|
223
|
-
if (docPath === void 0) return {
|
|
224
|
-
ok: false,
|
|
225
|
-
error: "找不到 compaction-eval 文档"
|
|
226
|
-
};
|
|
227
|
-
const controller = ctx.get("sessionController");
|
|
228
|
-
if (controller === void 0) return {
|
|
229
|
-
ok: false,
|
|
230
|
-
error: "宿主未提供 sessionController 服务"
|
|
231
|
-
};
|
|
232
|
-
const workspaceId = workspaceOf(ctx, session.id);
|
|
233
|
-
const preset = session.header?.agentPreset;
|
|
234
|
-
try {
|
|
235
|
-
const created = await controller.create({
|
|
236
|
-
...workspaceId === void 0 ? { cwd } : { workspaceId },
|
|
237
|
-
...preset === void 0 ? {} : { agentPreset: preset }
|
|
238
|
-
});
|
|
239
|
-
const selected = model ?? currentModel(session);
|
|
240
|
-
if (selected !== void 0) await controller.selectModel({
|
|
241
|
-
sessionId: created.sessionId,
|
|
242
|
-
...selected
|
|
243
|
-
});
|
|
244
|
-
await controller.prompt({
|
|
245
|
-
requestId: brandString(uuid()),
|
|
246
|
-
sessionId: created.sessionId,
|
|
247
|
-
mode: "queue",
|
|
248
|
-
content: [{
|
|
249
|
-
type: "text",
|
|
250
|
-
text: buildEvalPrompt({
|
|
251
|
-
docPath,
|
|
252
|
-
cwd,
|
|
253
|
-
...workspaceId === void 0 ? {} : { workspaceId },
|
|
254
|
-
sessionId: session.id
|
|
255
|
-
})
|
|
256
|
-
}]
|
|
257
|
-
}, signal);
|
|
258
|
-
return {
|
|
259
|
-
ok: true,
|
|
260
|
-
sessionId: created.sessionId,
|
|
261
|
-
text: evalStartedText(created.sessionId)
|
|
262
|
-
};
|
|
263
|
-
} catch (error) {
|
|
264
|
-
return {
|
|
265
|
-
ok: false,
|
|
266
|
-
error: error instanceof Error ? error.message : String(error)
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
/** 构造 /om-compaction-eval 命令定义:可选参数指定新会话的模型与思考等级。 */
|
|
271
|
-
function buildCompactionEvalCommand(ctx) {
|
|
272
|
-
return {
|
|
273
|
-
name: EVAL_COMMAND_NAME,
|
|
274
|
-
description: EVAL_COMMAND_DESCRIPTION,
|
|
275
|
-
input: { hint: "[provider/model [思考等级]]" },
|
|
276
|
-
handler: async ({ agent, rawInput, signal }) => {
|
|
277
|
-
const parsed = parseEvalModelInput(rawInput);
|
|
278
|
-
if (!parsed.ok) return {
|
|
279
|
-
kind: "error",
|
|
280
|
-
text: parsed.error
|
|
281
|
-
};
|
|
282
|
-
const result = await startEvalSession(ctx, agent, signal, parsed.model);
|
|
283
|
-
return result.ok ? {
|
|
284
|
-
kind: "success",
|
|
285
|
-
text: result.text
|
|
286
|
-
} : {
|
|
287
|
-
kind: "error",
|
|
288
|
-
text: result.error
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
//#endregion
|
|
294
19
|
//#region node_modules/.pnpm/@xmldom+xmldom@0.9.11/node_modules/@xmldom/xmldom/lib/conventions.js
|
|
295
20
|
var require_conventions = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
296
21
|
/**
|
|
@@ -10203,7 +9928,7 @@ function disposeAllReflections() {
|
|
|
10203
9928
|
* om/observe-pending / om/observe-invalidate / om/observe-summary,见 om-event.ts)
|
|
10204
9929
|
* 持久化在会话日志中(重启后从日志恢复);压缩失败保留待定,下个 pre-step 重启任务重试
|
|
10205
9930
|
* - pre-step 先做反思检查(只启动或跳过,不阻塞),再执行观察(压缩主体在后台运行,
|
|
10206
|
-
* pre-step
|
|
9931
|
+
* pre-step 仅在到期结果未就绪时阻塞等待);仅主会话生效;关闭包根行即停用
|
|
10207
9932
|
* - 压缩目标默认跟随会话路由;compressProvider + compressModel 成对配置时覆盖路由
|
|
10208
9933
|
* (成对配置下未路由会话也执行压缩);compressReasoningEffort 配置时压缩前经
|
|
10209
9934
|
* ctx.llm.resolveModelInfo 校验目标模型 reasoning.efforts(按 provider+model 缓存),
|
|
@@ -11097,10 +10822,6 @@ async function observePass(ctx, agent, config, waitCount, target, signal, reason
|
|
|
11097
10822
|
async function maybeCompress(ctx, agent, config, signal) {
|
|
11098
10823
|
const session = agent.session;
|
|
11099
10824
|
const logger = makeLogger(ctx, config.debug);
|
|
11100
|
-
if (!config.omEnabled) {
|
|
11101
|
-
logger.step("omEnabled=false,跳过压缩");
|
|
11102
|
-
return { failed: false };
|
|
11103
|
-
}
|
|
11104
10825
|
const target = compressionTarget(config, session);
|
|
11105
10826
|
if (target === void 0) {
|
|
11106
10827
|
logger.step("会话未路由(无 provider/model)且未配置压缩目标覆盖,跳过压缩");
|
|
@@ -11326,8 +11047,8 @@ function cosineSimilarity(a, b) {
|
|
|
11326
11047
|
//#region src/config.ts
|
|
11327
11048
|
/**
|
|
11328
11049
|
* 插件配置:宿主 Config 严格校验、volatile 引用读取与兼容 YAML 的宽松合并。
|
|
11329
|
-
* 导出 Config / PluginConfig / DEFAULT_CONFIG / currentConfig / resolveConfig
|
|
11330
|
-
*
|
|
11050
|
+
* 导出 Config / PluginConfig / DEFAULT_CONFIG / currentConfig / resolveConfig。
|
|
11051
|
+
* 宽松解析时未知键忽略、非法值回退默认值。
|
|
11331
11052
|
*/
|
|
11332
11053
|
/** 默认配置(冻结对象,resolveConfig 合并的基底;debug 缺省值在解析时按 NODE_ENV 判定)。 */
|
|
11333
11054
|
const DEFAULT_CONFIG = Object.freeze({
|
|
@@ -11338,7 +11059,6 @@ const DEFAULT_CONFIG = Object.freeze({
|
|
|
11338
11059
|
recompressConcurrency: 2,
|
|
11339
11060
|
tailMessageCount: 20,
|
|
11340
11061
|
compressSkipReasoning: true,
|
|
11341
|
-
omEnabled: true,
|
|
11342
11062
|
progressReminderEnabled: true,
|
|
11343
11063
|
progressReminderIdleEnabled: false,
|
|
11344
11064
|
progressReminderIdleSteps: 4,
|
|
@@ -11350,6 +11070,10 @@ const DEFAULT_CONFIG = Object.freeze({
|
|
|
11350
11070
|
compressModel: void 0,
|
|
11351
11071
|
compressReasoningEffort: void 0
|
|
11352
11072
|
});
|
|
11073
|
+
/** debug 开关 schema:缺省按 NODE_ENV !== 'production' 判定。 */
|
|
11074
|
+
function debugSchema() {
|
|
11075
|
+
return Schema.boolean().default(process.env.NODE_ENV !== "production").volatile();
|
|
11076
|
+
}
|
|
11353
11077
|
/** 宿主保存时严格校验,所有字段均为稳定 volatile 引用,运行时由 Loader 原地提交。 */
|
|
11354
11078
|
const Config = Schema.object({
|
|
11355
11079
|
observeThresholdTokens: Schema.number().step(1).default(DEFAULT_CONFIG.observeThresholdTokens).volatile(),
|
|
@@ -11359,27 +11083,30 @@ const Config = Schema.object({
|
|
|
11359
11083
|
recompressConcurrency: Schema.number().step(1).min(1).default(DEFAULT_CONFIG.recompressConcurrency).volatile(),
|
|
11360
11084
|
tailMessageCount: Schema.number().step(1).default(DEFAULT_CONFIG.tailMessageCount).volatile(),
|
|
11361
11085
|
compressSkipReasoning: Schema.boolean().default(DEFAULT_CONFIG.compressSkipReasoning).volatile(),
|
|
11362
|
-
omEnabled: Schema.boolean().default(DEFAULT_CONFIG.omEnabled).volatile(),
|
|
11363
11086
|
progressReminderEnabled: Schema.boolean().default(DEFAULT_CONFIG.progressReminderEnabled).volatile(),
|
|
11364
11087
|
progressReminderIdleEnabled: Schema.boolean().default(DEFAULT_CONFIG.progressReminderIdleEnabled).volatile(),
|
|
11365
11088
|
progressReminderIdleSteps: Schema.number().step(1).min(1).default(DEFAULT_CONFIG.progressReminderIdleSteps).volatile(),
|
|
11366
11089
|
progressReminderIdleToolCalls: Schema.number().step(1).min(0).default(DEFAULT_CONFIG.progressReminderIdleToolCalls).volatile(),
|
|
11367
|
-
debug:
|
|
11090
|
+
debug: debugSchema(),
|
|
11368
11091
|
semanticRecallEnabled: Schema.boolean().default(DEFAULT_CONFIG.semanticRecallEnabled).volatile(),
|
|
11369
11092
|
modelDir: Schema.string().default(DEFAULT_CONFIG.modelDir).volatile(),
|
|
11370
11093
|
compressProvider: Schema.string().volatile(),
|
|
11371
11094
|
compressModel: Schema.string().volatile(),
|
|
11372
11095
|
compressReasoningEffort: Schema.string().volatile()
|
|
11373
11096
|
}).default({});
|
|
11374
|
-
/**
|
|
11375
|
-
function
|
|
11376
|
-
if (!isRecord$1(config)) return
|
|
11097
|
+
/** 取出 keys 对应的当前值:volatile 引用解开 get(),原始值原样保留;非对象返回 undefined。 */
|
|
11098
|
+
function readVolatile(config, keys) {
|
|
11099
|
+
if (!isRecord$1(config)) return void 0;
|
|
11377
11100
|
const values = {};
|
|
11378
|
-
for (const key of
|
|
11101
|
+
for (const key of keys) {
|
|
11379
11102
|
const value = config[key];
|
|
11380
11103
|
values[key] = isRecord$1(value) && typeof value.get === "function" ? value.get() : value;
|
|
11381
11104
|
}
|
|
11382
|
-
return
|
|
11105
|
+
return values;
|
|
11106
|
+
}
|
|
11107
|
+
/** 解析宿主 volatile 引用中的当前值,也兼容直接传入的原始配置对象。 */
|
|
11108
|
+
function currentConfig(config) {
|
|
11109
|
+
return resolveConfig(readVolatile(config, Object.keys(DEFAULT_CONFIG)) ?? config);
|
|
11383
11110
|
}
|
|
11384
11111
|
/** 数值键校验参数表:键名 + [是否必须为整数, 下限(含)]。 */
|
|
11385
11112
|
const NUMBER_KEYS = [
|
|
@@ -11404,6 +11131,13 @@ const NUMBER_KEYS = [
|
|
|
11404
11131
|
0
|
|
11405
11132
|
]
|
|
11406
11133
|
];
|
|
11134
|
+
/** 校验数值:有限数,integer 时须为整数,且不小于 min;不合法返回 undefined。 */
|
|
11135
|
+
function resolveNumber(raw, integer, min) {
|
|
11136
|
+
if (typeof raw !== "number" || !Number.isFinite(raw)) return void 0;
|
|
11137
|
+
if (integer && !Number.isInteger(raw)) return void 0;
|
|
11138
|
+
if (min !== void 0 && raw < min) return void 0;
|
|
11139
|
+
return raw;
|
|
11140
|
+
}
|
|
11407
11141
|
/** 归一化原始配置输入:缺省 / null / 空串 / 非对象视为空对象。 */
|
|
11408
11142
|
function normalizeConfigInput(raw) {
|
|
11409
11143
|
if (raw === void 0 || raw === null) return {};
|
|
@@ -11418,6 +11152,10 @@ function resolveBoolean(raw, defaultValue) {
|
|
|
11418
11152
|
if (typeof raw === "boolean") return raw;
|
|
11419
11153
|
return defaultValue;
|
|
11420
11154
|
}
|
|
11155
|
+
/** 解析 debug 开关:非 boolean 回退 NODE_ENV !== 'production'。 */
|
|
11156
|
+
function resolveDebug(raw) {
|
|
11157
|
+
return resolveBoolean(raw, process.env.NODE_ENV !== "production");
|
|
11158
|
+
}
|
|
11421
11159
|
/** 解析字符串配置值:非空字符串才生效,缺省 / null / 空白串 / 非字符串回退 undefined。 */
|
|
11422
11160
|
function resolveOptionalString(raw) {
|
|
11423
11161
|
if (typeof raw === "string" && raw.trim() !== "") return raw;
|
|
@@ -11427,19 +11165,13 @@ function resolveConfig(raw) {
|
|
|
11427
11165
|
const input = normalizeConfigInput(raw);
|
|
11428
11166
|
const config = { ...DEFAULT_CONFIG };
|
|
11429
11167
|
for (const [key, integer, min] of NUMBER_KEYS) {
|
|
11430
|
-
const value = input[key];
|
|
11431
|
-
if (value
|
|
11432
|
-
if (typeof value === "string" && value.trim() === "") continue;
|
|
11433
|
-
if (typeof value !== "number" || !Number.isFinite(value)) continue;
|
|
11434
|
-
if (integer && !Number.isInteger(value)) continue;
|
|
11435
|
-
if (min !== void 0 && value < min) continue;
|
|
11436
|
-
config[key] = value;
|
|
11168
|
+
const value = resolveNumber(input[key], integer, min);
|
|
11169
|
+
if (value !== void 0) config[key] = value;
|
|
11437
11170
|
}
|
|
11438
11171
|
config.compressSkipReasoning = resolveBoolean(input.compressSkipReasoning, true);
|
|
11439
|
-
config.omEnabled = resolveBoolean(input.omEnabled, true);
|
|
11440
11172
|
config.progressReminderEnabled = resolveBoolean(input.progressReminderEnabled, true);
|
|
11441
11173
|
config.progressReminderIdleEnabled = resolveBoolean(input.progressReminderIdleEnabled, DEFAULT_CONFIG.progressReminderIdleEnabled);
|
|
11442
|
-
config.debug =
|
|
11174
|
+
config.debug = resolveDebug(input.debug);
|
|
11443
11175
|
config.semanticRecallEnabled = resolveBoolean(input.semanticRecallEnabled, true);
|
|
11444
11176
|
const modelDir = input.modelDir;
|
|
11445
11177
|
if (typeof modelDir === "string" && modelDir.trim() !== "") config.modelDir = modelDir;
|
|
@@ -12238,9 +11970,9 @@ function systemReminderMessage(reminder) {
|
|
|
12238
11970
|
}
|
|
12239
11971
|
});
|
|
12240
11972
|
}
|
|
12241
|
-
/** 按配置返回应注入的提醒:
|
|
11973
|
+
/** 按配置返回应注入的提醒:progressReminderEnabled 开启时为进度提醒。 */
|
|
12242
11974
|
function activeSystemReminders(config) {
|
|
12243
|
-
return config.
|
|
11975
|
+
return config.progressReminderEnabled ? [PROGRESS_REMINDER] : [];
|
|
12244
11976
|
}
|
|
12245
11977
|
/** 默认活动重发判定,与配置默认值一致。 */
|
|
12246
11978
|
const DEFAULT_PROGRESS_IDLE = Object.freeze({
|
|
@@ -12440,11 +12172,11 @@ const inject = ["llm", "tokenMeter"];
|
|
|
12440
12172
|
function apply(ctx, config) {
|
|
12441
12173
|
const resolved = currentConfig(config);
|
|
12442
12174
|
const logger = makeLogger(ctx, () => currentConfig(config).debug);
|
|
12443
|
-
logger.step(`apply 启动:observeThresholdTokens=${String(resolved.observeThresholdTokens)} reflectThresholdTokens=${String(resolved.reflectThresholdTokens)} compressMaxTokens=${resolved.compressMaxTokens === void 0 ? "未设置" : String(resolved.compressMaxTokens)} tailMessageCount=${String(resolved.tailMessageCount)}
|
|
12175
|
+
logger.step(`apply 启动:observeThresholdTokens=${String(resolved.observeThresholdTokens)} reflectThresholdTokens=${String(resolved.reflectThresholdTokens)} compressMaxTokens=${resolved.compressMaxTokens === void 0 ? "未设置" : String(resolved.compressMaxTokens)} tailMessageCount=${String(resolved.tailMessageCount)} debug=${String(resolved.debug)} compressProvider=${resolved.compressProvider ?? "跟随会话路由"} compressModel=${resolved.compressModel ?? "跟随会话路由"} compressReasoningEffort=${resolved.compressReasoningEffort ?? "模型默认"}`);
|
|
12444
12176
|
const warnModel = (message) => ctx.logger.warn(`dsh-plugin-om: ${message}`);
|
|
12445
12177
|
const logModel = (message) => logger.info(message);
|
|
12446
12178
|
if (ctx.get("tools") === void 0) logger.warn("tools 服务未挂载,recall 暂不可用");
|
|
12447
|
-
if (ctx.get("commands") === void 0) logger.warn("commands
|
|
12179
|
+
if (ctx.get("commands") === void 0) logger.warn("commands 服务未挂载,重压缩命令暂不可用");
|
|
12448
12180
|
ctx.inject(["tools"], (inner) => {
|
|
12449
12181
|
let disposeRecall;
|
|
12450
12182
|
/** 当前已注册 recall 对应的语义增强开关与模型目录。 */
|
|
@@ -12483,7 +12215,6 @@ function apply(ctx, config) {
|
|
|
12483
12215
|
});
|
|
12484
12216
|
ctx.inject(["commands"], (inner) => {
|
|
12485
12217
|
inner.effect(() => inner.commands.register(buildRecompressCommand(ctx, () => currentConfig(config))), "dsh-plugin-om: recompress command");
|
|
12486
|
-
inner.effect(() => inner.commands.register(buildCompactionEvalCommand(ctx)), "dsh-plugin-om: compaction eval command");
|
|
12487
12218
|
});
|
|
12488
12219
|
ctx.inject(["sessions"], (inner) => registerThinkingBinding(inner, logger));
|
|
12489
12220
|
ctx.on("session/disposed", (session) => disposePrecompression(session.id));
|
package/dist/recompress.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 换模型重压缩:对已成功的 compaction 用另一模型在临时循环里重新压缩一次,便于对比
|
|
3
3
|
* 不同模型的压缩效果。导出 parseRecompressInput / compactionView / recompress /
|
|
4
|
-
* RecompressRequest / RecompressResult / ReplayView /
|
|
5
|
-
* RECOMPRESS_COMMAND_NAME。
|
|
4
|
+
* RecompressRequest / RecompressResult / ReplayView /
|
|
5
|
+
* buildRecompressCommand / RECOMPRESS_COMMAND_NAME。
|
|
6
6
|
*
|
|
7
7
|
* - 视图重放:compaction/summary 载荷的 shadowedSeqs 加 compaction/start 的 phase 足以
|
|
8
8
|
* 重建当时的压缩视图(观察取被遮蔽的原消息,反思取被归档的 <history> 块),二者都只
|
|
@@ -13,12 +13,14 @@
|
|
|
13
13
|
* compressModel 配置影响
|
|
14
14
|
* - 仅主会话可用;同一会话允许多次重压缩并行,互不影响;命令并发数受
|
|
15
15
|
* recompressConcurrency 配置限制,超出的先进先出排队,排队中中止返回中止错误
|
|
16
|
+
* - 压缩参数(maxTokens / rateLimitWaitMs / skipReasoning)与 debug 均读插件配置
|
|
16
17
|
* - 命令 /om-recompress 是压缩卡片按钮到服务端的内部通道(宿主命令通道),结果文本
|
|
17
18
|
* 由发起方 UI 渲染,命令事件 log-only 不进模型上下文
|
|
18
19
|
*/
|
|
19
20
|
import type { CommandDefinition } from '@deepseek-ai/dsh-commands';
|
|
20
21
|
import { type CompressionView } from './compress-view.ts';
|
|
21
|
-
import type {
|
|
22
|
+
import type { PluginConfig } from './config.ts';
|
|
23
|
+
import type { Agent, Context, Session } from './types.ts';
|
|
22
24
|
/** 重压缩请求:被重放的 compaction 与目标模型。 */
|
|
23
25
|
export type RecompressRequest = {
|
|
24
26
|
compactionId: string;
|
package/dist/recompress.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recompress.d.ts","sourceRoot":"","sources":["../src/recompress.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"recompress.d.ts","sourceRoot":"","sources":["../src/recompress.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAUnE,OAAO,EAAsC,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKhD,OAAO,KAAK,EACV,KAAK,EAIL,OAAO,EACP,OAAO,EACR,MAAM,YAAY,CAAC;AAGpB,mCAAmC;AACnC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,0CAA0C;AAC1C,MAAM,MAAM,gBAAgB,GACxB;IACE,EAAE,EAAE,IAAI,CAAC;IACT,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB;IAChB,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;IAC7B,cAAc;IACd,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GACD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAK3D,gEAAgE;AAChE,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,GACf;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,iBAAiB,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAuBzE;AA4CD,8BAA8B;AAC9B,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;IAC7B,IAAI,EAAE,eAAe,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/D,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,iDAAiD;AACjD,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,OAAO,GACrB,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CA0BhC;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,EAC9B,OAAO,EAAE,iBAAiB,EAC1B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,gBAAgB,CAAC,CAkD3B;AAED,+BAA+B;AAC/B,eAAO,MAAM,uBAAuB,kBAAkB,CAAC;AASvD,wCAAwC;AACxC,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,MAAM,QAAQ,CAAC,YAAY,CAAC,GACtC,iBAAiB,CA2BnB"}
|
|
@@ -15478,8 +15478,8 @@ function sharedModelDir() {
|
|
|
15478
15478
|
//#region src/config.ts
|
|
15479
15479
|
/**
|
|
15480
15480
|
* 插件配置:宿主 Config 严格校验、volatile 引用读取与兼容 YAML 的宽松合并。
|
|
15481
|
-
* 导出 Config / PluginConfig / DEFAULT_CONFIG / currentConfig / resolveConfig
|
|
15482
|
-
*
|
|
15481
|
+
* 导出 Config / PluginConfig / DEFAULT_CONFIG / currentConfig / resolveConfig。
|
|
15482
|
+
* 宽松解析时未知键忽略、非法值回退默认值。
|
|
15483
15483
|
*/
|
|
15484
15484
|
/** 默认配置(冻结对象,resolveConfig 合并的基底;debug 缺省值在解析时按 NODE_ENV 判定)。 */
|
|
15485
15485
|
const DEFAULT_CONFIG = Object.freeze({
|
|
@@ -15490,7 +15490,6 @@ const DEFAULT_CONFIG = Object.freeze({
|
|
|
15490
15490
|
recompressConcurrency: 2,
|
|
15491
15491
|
tailMessageCount: 20,
|
|
15492
15492
|
compressSkipReasoning: true,
|
|
15493
|
-
omEnabled: true,
|
|
15494
15493
|
progressReminderEnabled: true,
|
|
15495
15494
|
progressReminderIdleEnabled: false,
|
|
15496
15495
|
progressReminderIdleSteps: 4,
|
|
@@ -15502,6 +15501,10 @@ const DEFAULT_CONFIG = Object.freeze({
|
|
|
15502
15501
|
compressModel: void 0,
|
|
15503
15502
|
compressReasoningEffort: void 0
|
|
15504
15503
|
});
|
|
15504
|
+
/** debug 开关 schema:缺省按 NODE_ENV !== 'production' 判定。 */
|
|
15505
|
+
function debugSchema() {
|
|
15506
|
+
return Schema.boolean().default(process.env.NODE_ENV !== "production").volatile();
|
|
15507
|
+
}
|
|
15505
15508
|
Schema.object({
|
|
15506
15509
|
observeThresholdTokens: Schema.number().step(1).default(DEFAULT_CONFIG.observeThresholdTokens).volatile(),
|
|
15507
15510
|
reflectThresholdTokens: Schema.number().step(1).default(DEFAULT_CONFIG.reflectThresholdTokens).volatile(),
|
|
@@ -15510,12 +15513,11 @@ Schema.object({
|
|
|
15510
15513
|
recompressConcurrency: Schema.number().step(1).min(1).default(DEFAULT_CONFIG.recompressConcurrency).volatile(),
|
|
15511
15514
|
tailMessageCount: Schema.number().step(1).default(DEFAULT_CONFIG.tailMessageCount).volatile(),
|
|
15512
15515
|
compressSkipReasoning: Schema.boolean().default(DEFAULT_CONFIG.compressSkipReasoning).volatile(),
|
|
15513
|
-
omEnabled: Schema.boolean().default(DEFAULT_CONFIG.omEnabled).volatile(),
|
|
15514
15516
|
progressReminderEnabled: Schema.boolean().default(DEFAULT_CONFIG.progressReminderEnabled).volatile(),
|
|
15515
15517
|
progressReminderIdleEnabled: Schema.boolean().default(DEFAULT_CONFIG.progressReminderIdleEnabled).volatile(),
|
|
15516
15518
|
progressReminderIdleSteps: Schema.number().step(1).min(1).default(DEFAULT_CONFIG.progressReminderIdleSteps).volatile(),
|
|
15517
15519
|
progressReminderIdleToolCalls: Schema.number().step(1).min(0).default(DEFAULT_CONFIG.progressReminderIdleToolCalls).volatile(),
|
|
15518
|
-
debug:
|
|
15520
|
+
debug: debugSchema(),
|
|
15519
15521
|
semanticRecallEnabled: Schema.boolean().default(DEFAULT_CONFIG.semanticRecallEnabled).volatile(),
|
|
15520
15522
|
modelDir: Schema.string().default(DEFAULT_CONFIG.modelDir).volatile(),
|
|
15521
15523
|
compressProvider: Schema.string().volatile(),
|
|
@@ -15545,6 +15547,13 @@ const NUMBER_KEYS = [
|
|
|
15545
15547
|
0
|
|
15546
15548
|
]
|
|
15547
15549
|
];
|
|
15550
|
+
/** 校验数值:有限数,integer 时须为整数,且不小于 min;不合法返回 undefined。 */
|
|
15551
|
+
function resolveNumber(raw, integer, min) {
|
|
15552
|
+
if (typeof raw !== "number" || !Number.isFinite(raw)) return void 0;
|
|
15553
|
+
if (integer && !Number.isInteger(raw)) return void 0;
|
|
15554
|
+
if (min !== void 0 && raw < min) return void 0;
|
|
15555
|
+
return raw;
|
|
15556
|
+
}
|
|
15548
15557
|
/** 归一化原始配置输入:缺省 / null / 空串 / 非对象视为空对象。 */
|
|
15549
15558
|
function normalizeConfigInput(raw) {
|
|
15550
15559
|
if (raw === void 0 || raw === null) return {};
|
|
@@ -15559,6 +15568,10 @@ function resolveBoolean(raw, defaultValue) {
|
|
|
15559
15568
|
if (typeof raw === "boolean") return raw;
|
|
15560
15569
|
return defaultValue;
|
|
15561
15570
|
}
|
|
15571
|
+
/** 解析 debug 开关:非 boolean 回退 NODE_ENV !== 'production'。 */
|
|
15572
|
+
function resolveDebug(raw) {
|
|
15573
|
+
return resolveBoolean(raw, process.env.NODE_ENV !== "production");
|
|
15574
|
+
}
|
|
15562
15575
|
/** 解析字符串配置值:非空字符串才生效,缺省 / null / 空白串 / 非字符串回退 undefined。 */
|
|
15563
15576
|
function resolveOptionalString(raw) {
|
|
15564
15577
|
if (typeof raw === "string" && raw.trim() !== "") return raw;
|
|
@@ -15568,19 +15581,13 @@ function resolveConfig(raw) {
|
|
|
15568
15581
|
const input = normalizeConfigInput(raw);
|
|
15569
15582
|
const config = { ...DEFAULT_CONFIG };
|
|
15570
15583
|
for (const [key, integer, min] of NUMBER_KEYS) {
|
|
15571
|
-
const value = input[key];
|
|
15572
|
-
if (value
|
|
15573
|
-
if (typeof value === "string" && value.trim() === "") continue;
|
|
15574
|
-
if (typeof value !== "number" || !Number.isFinite(value)) continue;
|
|
15575
|
-
if (integer && !Number.isInteger(value)) continue;
|
|
15576
|
-
if (min !== void 0 && value < min) continue;
|
|
15577
|
-
config[key] = value;
|
|
15584
|
+
const value = resolveNumber(input[key], integer, min);
|
|
15585
|
+
if (value !== void 0) config[key] = value;
|
|
15578
15586
|
}
|
|
15579
15587
|
config.compressSkipReasoning = resolveBoolean(input.compressSkipReasoning, true);
|
|
15580
|
-
config.omEnabled = resolveBoolean(input.omEnabled, true);
|
|
15581
15588
|
config.progressReminderEnabled = resolveBoolean(input.progressReminderEnabled, true);
|
|
15582
15589
|
config.progressReminderIdleEnabled = resolveBoolean(input.progressReminderIdleEnabled, DEFAULT_CONFIG.progressReminderIdleEnabled);
|
|
15583
|
-
config.debug =
|
|
15590
|
+
config.debug = resolveDebug(input.debug);
|
|
15584
15591
|
config.semanticRecallEnabled = resolveBoolean(input.semanticRecallEnabled, true);
|
|
15585
15592
|
const modelDir = input.modelDir;
|
|
15586
15593
|
if (typeof modelDir === "string" && modelDir.trim() !== "") config.modelDir = modelDir;
|