dsh-plugin-om 0.0.51 → 0.0.53
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 +17 -5
- package/dist/client/OmCompactionCard.d.ts +4 -1
- package/dist/client/OmCompactionCard.d.ts.map +1 -1
- package/dist/client/OmRecompressMenu.d.ts +13 -0
- package/dist/client/OmRecompressMenu.d.ts.map +1 -0
- package/dist/client/definition.d.ts +10 -0
- package/dist/client/definition.d.ts.map +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/locales.d.ts +23 -2
- package/dist/client/locales.d.ts.map +1 -1
- package/dist/client/om-config-controller.d.ts +13 -1
- package/dist/client/om-config-controller.d.ts.map +1 -1
- package/dist/client/recompress-inject.d.ts +9 -0
- package/dist/client/recompress-inject.d.ts.map +1 -0
- package/dist/client/recompress-run.d.ts +73 -0
- package/dist/client/recompress-run.d.ts.map +1 -0
- package/dist/client.js +472 -54
- package/dist/client.js.map +1 -1
- package/dist/compaction-log.d.ts +28 -4
- package/dist/compaction-log.d.ts.map +1 -1
- package/dist/compress-loop.d.ts +6 -0
- package/dist/compress-loop.d.ts.map +1 -1
- package/dist/compress.d.ts +7 -3
- package/dist/compress.d.ts.map +1 -1
- package/dist/config.d.ts +16 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/format.d.ts +8 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +325 -65
- package/dist/recall.d.ts.map +1 -1
- package/dist/recompress.d.ts +66 -0
- package/dist/recompress.d.ts.map +1 -0
- package/dist/system-reminder.d.ts +15 -14
- package/dist/system-reminder.d.ts.map +1 -1
- package/dist/types.d.ts +1 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +3 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +4 -1
- package/dist/client/format.d.ts +0 -6
- package/dist/client/format.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CompactionId } from "@deepseek-ai/dsh-compaction";
|
|
2
|
-
import { BlockAssembler, createToolResultMessage, createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
2
|
+
import { BlockAssembler, createAssistantMessage, createToolResultMessage, createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
3
3
|
import { scopeOf } from "@deepseek-ai/dsh-scope";
|
|
4
4
|
import { SessionId, SessionSeq } from "@deepseek-ai/dsh-session";
|
|
5
5
|
import { renderPrompt } from "@deepseek-ai/dsh-system-prompt";
|
|
@@ -15,6 +15,26 @@ import { AttachmentId } from "@deepseek-ai/dsh-attachment";
|
|
|
15
15
|
//#region \0rolldown/runtime.js
|
|
16
16
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
17
17
|
//#endregion
|
|
18
|
+
//#region src/format.ts
|
|
19
|
+
/**
|
|
20
|
+
* 紧凑数字格式化(压缩卡片、重压缩记录与压缩日志共用)。零依赖,服务端与浏览器均可引用。导出 formatCompactCount / formatSeconds。
|
|
21
|
+
* <1k 原样;≥1k 用 k;≥1w(万)用 w;≥1M 用 M;保留 1 位小数并去掉末尾 .0。
|
|
22
|
+
*/
|
|
23
|
+
function formatCompactCount(value) {
|
|
24
|
+
const trim = (n) => {
|
|
25
|
+
const text = String(Math.round(n * 10) / 10);
|
|
26
|
+
return text.endsWith(".0") ? text.slice(0, -2) : text;
|
|
27
|
+
};
|
|
28
|
+
if (value >= 1e6) return `${trim(value / 1e6)}M`;
|
|
29
|
+
if (value >= 1e4) return `${trim(value / 1e4)}w`;
|
|
30
|
+
if (value >= 1e3) return `${trim(value / 1e3)}k`;
|
|
31
|
+
return String(value);
|
|
32
|
+
}
|
|
33
|
+
/** 毫秒耗时格式化为一位小数的秒数,如 63.1s。 */
|
|
34
|
+
function formatSeconds(durationMs) {
|
|
35
|
+
return `${(durationMs / 1e3).toFixed(1)}s`;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
18
38
|
//#region src/constants.ts
|
|
19
39
|
/** 插件标识:日志前缀与历史日志的 source.plugin 取值。 */
|
|
20
40
|
const PLUGIN_LABEL = "dsh-plugin-om";
|
|
@@ -36,7 +56,7 @@ const HISTORY_TAG = "history";
|
|
|
36
56
|
/** 压缩日志块开标签的 tip 属性(对 AI 的提醒:本块是历史压缩产物,不要复述)。 */
|
|
37
57
|
const HISTORY_TIP = "当前块是历史消息的压缩产物,不要复述";
|
|
38
58
|
/**
|
|
39
|
-
*
|
|
59
|
+
* 「完整消息」定义(压缩提示词、recall 工具描述与 <history> 块顶注释共用)。
|
|
40
60
|
* 完整消息是摘要日志与 recall 共用的定位单位;首条 index 为 0,按会话顺序递增、全局稳定。
|
|
41
61
|
*/
|
|
42
62
|
const COMPLETE_MESSAGE_DEFINITION = "`完整消息`指一条`用户消息`、`模型输出文本`或`具有result的toolcall`;首条 index 为 0,按会话顺序递增。";
|
|
@@ -46,7 +66,11 @@ const COMPLETE_MESSAGE_DEFINITION = "`完整消息`指一条`用户消息`、`
|
|
|
46
66
|
* <skill_content> / <ask-user-question> 的条目说明仅在块内存在对应条目时追加。
|
|
47
67
|
*/
|
|
48
68
|
function historyFormatNote(sections = {}) {
|
|
49
|
-
const parts = [
|
|
69
|
+
const parts = [
|
|
70
|
+
COMPLETE_MESSAGE_DEFINITION,
|
|
71
|
+
"<TAG index=\"N\">表示单条完整消息,<TAG start=\"A\" end=\"B\"> 表示多条连续消息,start/end 是首尾完整消息的 index;消息块的内容是用CDATA包裹的纯文本",
|
|
72
|
+
"<assistant type=\"toolcall\" tool-name=\"T\" callId=\"C\" index=\"N\"> 表示工具调用,内含 <tool-args> 与 <tool-result> 两个CDATA子元素(调用参数与工具返回内容)"
|
|
73
|
+
];
|
|
50
74
|
if (sections.user) parts.push("<user_message index=\"N\"> 表示用户消息原文");
|
|
51
75
|
if (sections.skill) parts.push("<skill_content name=\"S\" index=\"N\"> 表示未压缩的原始 skill");
|
|
52
76
|
if (sections.askUserQuestion) parts.push("<ask-user-question index=\"N\"> 表示向用户提问,CDATA 内为逐题成对的 q:(提问)与 a:(用户回答)行,未作答的题记为 a:(未回答)");
|
|
@@ -122,6 +146,14 @@ function textCharCount(message) {
|
|
|
122
146
|
else if (block.type === "tool-result") total += blocksToText(block.content).length;
|
|
123
147
|
return total;
|
|
124
148
|
}
|
|
149
|
+
/** 一组表层事件 seq 派生消息的字符数之和(OM 卡片「原始字符」口径)。 */
|
|
150
|
+
function seqsCharCount(session, seqs) {
|
|
151
|
+
const events = session.snapshotEvents();
|
|
152
|
+
return seqs.reduce((total, seq) => {
|
|
153
|
+
const event = events[seq];
|
|
154
|
+
return total + textCharCount(event ? session.deriveEventMessage(event) : null);
|
|
155
|
+
}, 0);
|
|
156
|
+
}
|
|
125
157
|
/** 面向 recall 的完整消息呈现:text 原样;tool-call 展开(参数=代码);tool-result 取文本。 */
|
|
126
158
|
function renderMessageText(message) {
|
|
127
159
|
if (!message || !Array.isArray(message.content)) return "";
|
|
@@ -185,9 +217,23 @@ function phaseLabel(phase) {
|
|
|
185
217
|
if (phase === "reflect") return "反思";
|
|
186
218
|
return "压缩";
|
|
187
219
|
}
|
|
188
|
-
/**
|
|
189
|
-
|
|
190
|
-
|
|
220
|
+
/**
|
|
221
|
+
* 压缩会话记录 label:成功为会话记录、失败为失败日志,均含压缩阶段与轮数;
|
|
222
|
+
* 换模型重压缩传入 retryTarget,label 末尾追加「重压缩 provider/model」以区分。
|
|
223
|
+
*/
|
|
224
|
+
function compressionRecordLabel(phase, rounds, success, retryTarget) {
|
|
225
|
+
const retry = retryTarget === void 0 ? "" : ` · 重压缩 ${retryTarget.provider}/${retryTarget.model}`;
|
|
226
|
+
return `OM 压缩${success ? "会话记录" : "失败日志"}(${phaseLabel(phase)} · ${rounds} 轮${retry})`;
|
|
227
|
+
}
|
|
228
|
+
/** 生成模型信息:压缩模型、思考等级、原始消息与压缩产物的字符数(k 单位)。 */
|
|
229
|
+
function compressionInfo(info) {
|
|
230
|
+
const effort = info.reasoningEffort ?? "默认思考等级";
|
|
231
|
+
const result = info.resultChars === void 0 ? "无(压缩失败)" : `${formatCompactCount(info.resultChars)} 字符`;
|
|
232
|
+
return {
|
|
233
|
+
text: `压缩使用模型 ${info.target.provider}/${info.target.model}(${effort}),原始消息 ${formatCompactCount(info.originalChars)} 字符,压缩产物 ${result}`,
|
|
234
|
+
provider: info.target.provider,
|
|
235
|
+
model: info.target.model
|
|
236
|
+
};
|
|
191
237
|
}
|
|
192
238
|
/**
|
|
193
239
|
* 构造一个 seed 事件信封:seq 由调用方按顺序传入,surface 事件附 surfaceOp:'append'。
|
|
@@ -212,7 +258,7 @@ function seedEvent(type, seq, time, data, surfaceOp) {
|
|
|
212
258
|
* 时间全程单调不减;轮次数组短于 assistant 数时(流错误注入的部分 assistant)回落上一
|
|
213
259
|
* 轮结束时刻与循环结束时刻。
|
|
214
260
|
*/
|
|
215
|
-
function buildCompressionSeed(messages, stats, label) {
|
|
261
|
+
function buildCompressionSeed(messages, stats, label, info) {
|
|
216
262
|
const seed = [];
|
|
217
263
|
const push = (type, time, data, surfaceOp) => {
|
|
218
264
|
seed.push(seedEvent(type, seed.length, time, data, surfaceOp));
|
|
@@ -304,6 +350,32 @@ function buildCompressionSeed(messages, stats, label) {
|
|
|
304
350
|
}, "append");
|
|
305
351
|
else push("user/message", at(step === 0 ? stats.startedAt : stepTime), message, "append");
|
|
306
352
|
closeStep();
|
|
353
|
+
if (info !== void 0) {
|
|
354
|
+
step += 1;
|
|
355
|
+
push("step/start", at(stats.completedAt), {
|
|
356
|
+
turn: 1,
|
|
357
|
+
step
|
|
358
|
+
});
|
|
359
|
+
push("assistant/message", at(stats.completedAt), {
|
|
360
|
+
turn: 1,
|
|
361
|
+
step,
|
|
362
|
+
message: createAssistantMessage({
|
|
363
|
+
content: [{
|
|
364
|
+
type: "text",
|
|
365
|
+
text: info.text
|
|
366
|
+
}],
|
|
367
|
+
source: {
|
|
368
|
+
provider: info.provider,
|
|
369
|
+
model: info.model
|
|
370
|
+
}
|
|
371
|
+
}),
|
|
372
|
+
stream: []
|
|
373
|
+
}, "append");
|
|
374
|
+
push("step/end", at(stats.completedAt), {
|
|
375
|
+
turn: 1,
|
|
376
|
+
step
|
|
377
|
+
});
|
|
378
|
+
}
|
|
307
379
|
push("turn/end", at(stats.completedAt), {
|
|
308
380
|
turn: 1,
|
|
309
381
|
reason: { kind: "completed" }
|
|
@@ -314,7 +386,7 @@ function buildCompressionSeed(messages, stats, label) {
|
|
|
314
386
|
* 把一次压缩工具循环的完整会话消息组落盘为子会话:以重建时间线的 seed 事件经
|
|
315
387
|
* ctx.sessions.create 构造子会话(header origin 'subagent'、parentSession 指向主会话、
|
|
316
388
|
* delegationDepth = 父 + 1、cwd 继承主会话;首事件 one-shot descriptor,provider
|
|
317
|
-
* om-compaction-log,label
|
|
389
|
+
* om-compaction-log,label 含压缩阶段与轮数;info 存在时尾部追加一条模型文本),flush 持久化,在父会话登记
|
|
318
390
|
* subagent/catalog,返回子会话 id。成功与失败均调用;落盘自身绝不抛错,任何失败仅
|
|
319
391
|
* logger.warn 并返回 undefined。
|
|
320
392
|
*/
|
|
@@ -322,8 +394,8 @@ async function recordCompressionSession(ctx, parentSession, options) {
|
|
|
322
394
|
const logger = makeLogger(ctx, options.debug);
|
|
323
395
|
try {
|
|
324
396
|
const header = parentSession.header;
|
|
325
|
-
const label = compressionRecordLabel(options.phase, options.stats.rounds.length, options.success);
|
|
326
|
-
const seed = buildCompressionSeed(options.messages, options.stats, label);
|
|
397
|
+
const label = compressionRecordLabel(options.phase, options.stats.rounds.length, options.success, options.retryTarget);
|
|
398
|
+
const seed = buildCompressionSeed(options.messages, options.stats, label, options.info);
|
|
327
399
|
const child = ctx.sessions.create(SessionId(`om-compaction-log-${uuid()}`), {
|
|
328
400
|
seed,
|
|
329
401
|
meta: {
|
|
@@ -8873,6 +8945,10 @@ const ASK_COMPRESSION_PROMPT = [
|
|
|
8873
8945
|
].join("\n");
|
|
8874
8946
|
/** 模型输出纯文本(无工具调用)时追加的提醒消息文本。 */
|
|
8875
8947
|
const COMPRESSION_NUDGE_TEXT = "请通过工具执行压缩:用 getHistory 查看区间条目,用 compressHistory 压缩 assistant 条目,完成后调用 completeCompression。不要输出与工具调用无关的文本。";
|
|
8948
|
+
/** 视图原始消息字符数估算:非 reasoning 条目之和;工具调用条目的 text 已含参数与结果,不重复计入。 */
|
|
8949
|
+
function viewCharCount(view) {
|
|
8950
|
+
return view.entries.reduce((total, entry) => entry.kind === "reasoning" ? total : total + entry.text.length, 0);
|
|
8951
|
+
}
|
|
8876
8952
|
/** 构造插件自产 user 消息(压缩指令/提醒;source 为插件自有 kind)。 */
|
|
8877
8953
|
function makePluginUserMessage(text) {
|
|
8878
8954
|
return createUserMessage({
|
|
@@ -8952,12 +9028,19 @@ async function runCompressionLoop(ctx, session, options) {
|
|
|
8952
9028
|
rounds: roundStats
|
|
8953
9029
|
};
|
|
8954
9030
|
};
|
|
8955
|
-
const recordSessionId = async (success, stats) => recordCompressionSession(ctx, session, {
|
|
9031
|
+
const recordSessionId = async (success, stats, resultChars) => recordCompressionSession(ctx, session, {
|
|
8956
9032
|
phase: options.phase,
|
|
8957
9033
|
messages,
|
|
8958
9034
|
stats,
|
|
8959
9035
|
success,
|
|
8960
|
-
debug: options.debug
|
|
9036
|
+
debug: options.debug,
|
|
9037
|
+
info: compressionInfo({
|
|
9038
|
+
target: options.target,
|
|
9039
|
+
originalChars: options.originalChars ?? viewCharCount(options.view),
|
|
9040
|
+
...options.reasoningEffort === void 0 ? {} : { reasoningEffort: options.reasoningEffort },
|
|
9041
|
+
...resultChars === void 0 ? {} : { resultChars }
|
|
9042
|
+
}),
|
|
9043
|
+
...options.retryTarget === void 0 ? {} : { retryTarget: options.retryTarget }
|
|
8961
9044
|
});
|
|
8962
9045
|
const failWith = async (error, aborted) => {
|
|
8963
9046
|
const stats = buildStats();
|
|
@@ -9059,7 +9142,7 @@ async function runCompressionLoop(ctx, session, options) {
|
|
|
9059
9142
|
if (state.replacementCount === 0 && state.rewriteCount === 0) logger.warn("压缩完成但未执行任何压缩替换(空提交)");
|
|
9060
9143
|
logger.info(`压缩循环完成(${rounds} 轮,${state.replacementCount} 次压缩替换,${state.rewriteCount} 条提问重写,输出 ${text.length} 字符)`);
|
|
9061
9144
|
const stats = buildStats();
|
|
9062
|
-
const id = await recordSessionId(true, stats);
|
|
9145
|
+
const id = await recordSessionId(true, stats, text.length);
|
|
9063
9146
|
return {
|
|
9064
9147
|
ok: true,
|
|
9065
9148
|
text,
|
|
@@ -9193,7 +9276,7 @@ function reportDegrade(session, logger, problem) {
|
|
|
9193
9276
|
/**
|
|
9194
9277
|
* 两级自动压缩(观察/反思)与 compaction 生命周期提交。
|
|
9195
9278
|
* 导出 estimateTextTokens / isPairBalancedAfter / computeCompressRange / historySection /
|
|
9196
|
-
*
|
|
9279
|
+
* historyTextOf / findObservePending / reflectPass / observePass / maybeCompress。
|
|
9197
9280
|
*
|
|
9198
9281
|
* - 摘要生成走工具驱动的压缩循环(compress-loop.ts runCompressionLoop):首条 user
|
|
9199
9282
|
* 消息仅含压缩指令与 start/end 区间,模型经 getHistory / compressHistory /
|
|
@@ -9395,11 +9478,6 @@ function historySection(session) {
|
|
|
9395
9478
|
boundarySeq
|
|
9396
9479
|
};
|
|
9397
9480
|
}
|
|
9398
|
-
/** 表层是否存在合法 <history> 压缩日志块。 */
|
|
9399
|
-
function hasHistoryBlock(session) {
|
|
9400
|
-
for (const seq of session.surface.nodes) if (historyTextOf(session.snapshotEvents()[seq]) !== void 0) return true;
|
|
9401
|
-
return false;
|
|
9402
|
-
}
|
|
9403
9481
|
/**
|
|
9404
9482
|
* 查找当前活跃的观察压缩待定标记:按日志顺序取最后一条 om/observe-pending 信封事件,
|
|
9405
9483
|
* 其后须无引用它的 om/observe-invalidate(已失效),且其后的压缩边界 seq 不大于标记
|
|
@@ -9563,6 +9641,7 @@ async function reflectPass(ctx, agent, config, target, signal, reasoningEffort)
|
|
|
9563
9641
|
}
|
|
9564
9642
|
const summaryResult = await runPassLoop(ctx, session, lifecycle, {
|
|
9565
9643
|
view,
|
|
9644
|
+
originalChars: shadowedCharCount,
|
|
9566
9645
|
phase: "reflect",
|
|
9567
9646
|
taskText: buildCompressionTaskText("reflect", view.minIndex, view.maxIndex),
|
|
9568
9647
|
target,
|
|
@@ -9765,6 +9844,7 @@ async function observePass(ctx, agent, config, waitCount, target, signal, reason
|
|
|
9765
9844
|
clearPending();
|
|
9766
9845
|
return { failed: false };
|
|
9767
9846
|
}
|
|
9847
|
+
const shadowedCharCount = seqsCharCount(session, replaceSeqs);
|
|
9768
9848
|
const view = buildObserveView(session, replaceSeqs, { skipReasoning: config.compressSkipReasoning });
|
|
9769
9849
|
if (view.minIndex === void 0 || view.maxIndex === void 0) {
|
|
9770
9850
|
logger.step("观察:区间内无可定位条目,清除待定标记视为完成");
|
|
@@ -9786,6 +9866,7 @@ async function observePass(ctx, agent, config, waitCount, target, signal, reason
|
|
|
9786
9866
|
}
|
|
9787
9867
|
const summaryResult = await runPassLoop(ctx, session, lifecycle, {
|
|
9788
9868
|
view,
|
|
9869
|
+
originalChars: shadowedCharCount,
|
|
9789
9870
|
phase: "observe",
|
|
9790
9871
|
taskText: buildCompressionTaskText("observe", view.minIndex, view.maxIndex),
|
|
9791
9872
|
target,
|
|
@@ -9815,11 +9896,6 @@ async function observePass(ctx, agent, config, waitCount, target, signal, reason
|
|
|
9815
9896
|
}
|
|
9816
9897
|
return total + tokens;
|
|
9817
9898
|
}, 0);
|
|
9818
|
-
const shadowedCharCount = replaceSeqs.reduce((total, seq) => {
|
|
9819
|
-
const event = session.snapshotEvents()[seq];
|
|
9820
|
-
const message = event ? session.deriveEventMessage(event) : null;
|
|
9821
|
-
return total + (message ? textCharCount(message) : 0);
|
|
9822
|
-
}, 0);
|
|
9823
9899
|
try {
|
|
9824
9900
|
logger.step("观察提交:追加 compaction/summary(影子价格认领)");
|
|
9825
9901
|
const summarySeq = appendCompactionSummary(session, {
|
|
@@ -10112,6 +10188,10 @@ const DEFAULT_CONFIG = Object.freeze({
|
|
|
10112
10188
|
tailMessageCount: 20,
|
|
10113
10189
|
compressSkipReasoning: true,
|
|
10114
10190
|
omEnabled: true,
|
|
10191
|
+
progressReminderEnabled: true,
|
|
10192
|
+
progressReminderIdleEnabled: true,
|
|
10193
|
+
progressReminderIdleSteps: 4,
|
|
10194
|
+
progressReminderIdleToolCalls: 10,
|
|
10115
10195
|
debug: false,
|
|
10116
10196
|
recallEnabled: true,
|
|
10117
10197
|
semanticRecallEnabled: true,
|
|
@@ -10129,6 +10209,10 @@ const Config = Schema.object({
|
|
|
10129
10209
|
tailMessageCount: Schema.number().step(1).default(DEFAULT_CONFIG.tailMessageCount).volatile(),
|
|
10130
10210
|
compressSkipReasoning: Schema.boolean().default(DEFAULT_CONFIG.compressSkipReasoning).volatile(),
|
|
10131
10211
|
omEnabled: Schema.boolean().default(DEFAULT_CONFIG.omEnabled).volatile(),
|
|
10212
|
+
progressReminderEnabled: Schema.boolean().default(DEFAULT_CONFIG.progressReminderEnabled).volatile(),
|
|
10213
|
+
progressReminderIdleEnabled: Schema.boolean().default(DEFAULT_CONFIG.progressReminderIdleEnabled).volatile(),
|
|
10214
|
+
progressReminderIdleSteps: Schema.number().step(1).min(1).default(DEFAULT_CONFIG.progressReminderIdleSteps).volatile(),
|
|
10215
|
+
progressReminderIdleToolCalls: Schema.number().step(1).min(0).default(DEFAULT_CONFIG.progressReminderIdleToolCalls).volatile(),
|
|
10132
10216
|
debug: Schema.boolean().default(process.env.NODE_ENV !== "production").volatile(),
|
|
10133
10217
|
recallEnabled: Schema.boolean().default(DEFAULT_CONFIG.recallEnabled).volatile(),
|
|
10134
10218
|
semanticRecallEnabled: Schema.boolean().default(DEFAULT_CONFIG.semanticRecallEnabled).volatile(),
|
|
@@ -10147,13 +10231,23 @@ function currentConfig(config) {
|
|
|
10147
10231
|
}
|
|
10148
10232
|
return resolveConfig(values);
|
|
10149
10233
|
}
|
|
10150
|
-
/** 数值键校验参数表:键名 + [
|
|
10234
|
+
/** 数值键校验参数表:键名 + [是否必须为整数, 下限(含)]。 */
|
|
10151
10235
|
const NUMBER_KEYS = [
|
|
10152
10236
|
["observeThresholdTokens", true],
|
|
10153
10237
|
["reflectThresholdTokens", true],
|
|
10154
10238
|
["compressMaxTokens", true],
|
|
10155
10239
|
["rateLimitWaitMs", true],
|
|
10156
|
-
["tailMessageCount", true]
|
|
10240
|
+
["tailMessageCount", true],
|
|
10241
|
+
[
|
|
10242
|
+
"progressReminderIdleSteps",
|
|
10243
|
+
true,
|
|
10244
|
+
1
|
|
10245
|
+
],
|
|
10246
|
+
[
|
|
10247
|
+
"progressReminderIdleToolCalls",
|
|
10248
|
+
true,
|
|
10249
|
+
0
|
|
10250
|
+
]
|
|
10157
10251
|
];
|
|
10158
10252
|
/** 归一化原始配置输入:缺省 / null / 空串 / 非对象视为空对象。 */
|
|
10159
10253
|
function normalizeConfigInput(raw) {
|
|
@@ -10177,16 +10271,19 @@ function resolveOptionalString(raw) {
|
|
|
10177
10271
|
function resolveConfig(raw) {
|
|
10178
10272
|
const input = normalizeConfigInput(raw);
|
|
10179
10273
|
const config = { ...DEFAULT_CONFIG };
|
|
10180
|
-
for (const [key, integer] of NUMBER_KEYS) {
|
|
10274
|
+
for (const [key, integer, min] of NUMBER_KEYS) {
|
|
10181
10275
|
const value = input[key];
|
|
10182
10276
|
if (value === void 0 || value === null) continue;
|
|
10183
10277
|
if (typeof value === "string" && value.trim() === "") continue;
|
|
10184
10278
|
if (typeof value !== "number" || !Number.isFinite(value)) continue;
|
|
10185
10279
|
if (integer && !Number.isInteger(value)) continue;
|
|
10280
|
+
if (min !== void 0 && value < min) continue;
|
|
10186
10281
|
config[key] = value;
|
|
10187
10282
|
}
|
|
10188
10283
|
config.compressSkipReasoning = resolveBoolean(input.compressSkipReasoning, true);
|
|
10189
10284
|
config.omEnabled = resolveBoolean(input.omEnabled, true);
|
|
10285
|
+
config.progressReminderEnabled = resolveBoolean(input.progressReminderEnabled, true);
|
|
10286
|
+
config.progressReminderIdleEnabled = resolveBoolean(input.progressReminderIdleEnabled, true);
|
|
10190
10287
|
config.debug = resolveBoolean(input.debug, process.env.NODE_ENV !== "production");
|
|
10191
10288
|
config.recallEnabled = resolveBoolean(input.recallEnabled, true);
|
|
10192
10289
|
config.semanticRecallEnabled = config.recallEnabled && resolveBoolean(input.semanticRecallEnabled, true);
|
|
@@ -10595,9 +10692,9 @@ function parseRecallArgs(raw, semantic = false) {
|
|
|
10595
10692
|
return result.data;
|
|
10596
10693
|
}
|
|
10597
10694
|
/** 基础工具描述。 */
|
|
10598
|
-
const RECALL_DESCRIPTION =
|
|
10695
|
+
const RECALL_DESCRIPTION = `在你需要查看历史消息时调用。${COMPLETE_MESSAGE_DEFINITION}此工具按 index 区间精确返回区间内全部完整消息的内容。`;
|
|
10599
10696
|
/** 语义增强启用时的工具描述。 */
|
|
10600
|
-
const ENHANCED_RECALL_DESCRIPTION =
|
|
10697
|
+
const ENHANCED_RECALL_DESCRIPTION = `在你需要查看历史消息时调用。${COMPLETE_MESSAGE_DEFINITION}两种用法:1) 给出 start 与 end 或 offset,按 index 区间精确返回区间内全部完整消息的内容;2) 给出 query,按自然语言含义检索最符合的完整消息,默认全量搜索,可用 start/end/offset 限定区间。注意:query 只匹配文本。`;
|
|
10601
10698
|
/**
|
|
10602
10699
|
* 构建 recall 工具定义:按 start/end/offset 定位完整消息区间并渲染原始内容(标 index);
|
|
10603
10700
|
* 传入 semantic 选项时额外支持 query 语义检索。
|
|
@@ -10665,20 +10762,178 @@ function buildRecallTool(options) {
|
|
|
10665
10762
|
};
|
|
10666
10763
|
}
|
|
10667
10764
|
//#endregion
|
|
10765
|
+
//#region src/recompress.ts
|
|
10766
|
+
/** 命令行用法提示。 */
|
|
10767
|
+
const USAGE = "用法:/om-recompress <compactionId> <provider> <model> [思考等级]";
|
|
10768
|
+
/** 解析命令行:compactionId provider model [reasoningEffort],空白分隔。 */
|
|
10769
|
+
function parseRecompressInput(rawInput) {
|
|
10770
|
+
const parts = rawInput.trim().split(/\s+/).filter((part) => part !== "");
|
|
10771
|
+
const [compactionId, provider, model, reasoningEffort] = parts;
|
|
10772
|
+
if (compactionId === void 0 || provider === void 0 || model === void 0 || parts.length > 4) return {
|
|
10773
|
+
ok: false,
|
|
10774
|
+
error: USAGE
|
|
10775
|
+
};
|
|
10776
|
+
return {
|
|
10777
|
+
ok: true,
|
|
10778
|
+
request: {
|
|
10779
|
+
compactionId,
|
|
10780
|
+
provider,
|
|
10781
|
+
model,
|
|
10782
|
+
...reasoningEffort === void 0 ? {} : { reasoningEffort }
|
|
10783
|
+
}
|
|
10784
|
+
};
|
|
10785
|
+
}
|
|
10786
|
+
/** 按 compactionId 收集 start/summary/end 载荷。 */
|
|
10787
|
+
function findLifecycle(session, compactionId) {
|
|
10788
|
+
const lifecycle = {
|
|
10789
|
+
phase: void 0,
|
|
10790
|
+
summary: void 0,
|
|
10791
|
+
end: void 0
|
|
10792
|
+
};
|
|
10793
|
+
for (const event of session.snapshotEvents()) if (event.type === "compaction/start") {
|
|
10794
|
+
const data = event.data;
|
|
10795
|
+
if (String(data.compactionId) === compactionId) lifecycle.phase = data.phase;
|
|
10796
|
+
} else if (event.type === "compaction/summary") {
|
|
10797
|
+
const data = event.data;
|
|
10798
|
+
if (String(data.compactionId) === compactionId) lifecycle.summary = data;
|
|
10799
|
+
} else if (event.type === "compaction/end") {
|
|
10800
|
+
const data = event.data;
|
|
10801
|
+
if (String(data.compactionId) === compactionId) lifecycle.end = data;
|
|
10802
|
+
}
|
|
10803
|
+
return lifecycle;
|
|
10804
|
+
}
|
|
10805
|
+
/** 重建被压缩内容的视图;不可重建时返回错误。 */
|
|
10806
|
+
function rebuildView(session, phase, shadowedSeqs, skipReasoning) {
|
|
10807
|
+
if (phase === "reflect") return buildReflectView(shadowedSeqs.flatMap((seq) => {
|
|
10808
|
+
const text = historyTextOf(session.snapshotEvents()[seq]);
|
|
10809
|
+
return text === void 0 ? [] : [{
|
|
10810
|
+
text,
|
|
10811
|
+
seq
|
|
10812
|
+
}];
|
|
10813
|
+
}), { skipReasoning });
|
|
10814
|
+
return buildObserveView(session, shadowedSeqs, { skipReasoning });
|
|
10815
|
+
}
|
|
10816
|
+
/**
|
|
10817
|
+
* 对已成功的 compaction 用目标模型重压缩一次。校验失败、压缩循环失败均以
|
|
10818
|
+
* { ok: false } 返回,不抛错;会话本身不被修改(见文件头说明)。
|
|
10819
|
+
*/
|
|
10820
|
+
async function recompress(ctx, agent, config, request, signal) {
|
|
10821
|
+
const session = agent.session;
|
|
10822
|
+
if (!isMainSession(session)) return {
|
|
10823
|
+
ok: false,
|
|
10824
|
+
error: "重压缩仅支持主会话"
|
|
10825
|
+
};
|
|
10826
|
+
const lifecycle = findLifecycle(session, request.compactionId);
|
|
10827
|
+
if (lifecycle.phase === void 0 && lifecycle.summary === void 0) return {
|
|
10828
|
+
ok: false,
|
|
10829
|
+
error: `未找到压缩 ${request.compactionId}`
|
|
10830
|
+
};
|
|
10831
|
+
const summary = lifecycle.summary;
|
|
10832
|
+
if (summary === void 0 || lifecycle.end === void 0 || lifecycle.end.error !== void 0) return {
|
|
10833
|
+
ok: false,
|
|
10834
|
+
error: `压缩 ${request.compactionId} 未成功完成,无法重压缩`
|
|
10835
|
+
};
|
|
10836
|
+
const shadowedSeqs = (summary.shadowedSeqs ?? []).map(Number);
|
|
10837
|
+
if (shadowedSeqs.length === 0) return {
|
|
10838
|
+
ok: false,
|
|
10839
|
+
error: `压缩 ${request.compactionId} 缺少 shadowedSeqs,无法重放`
|
|
10840
|
+
};
|
|
10841
|
+
const firstEvent = session.snapshotEvents()[shadowedSeqs[0] ?? -1];
|
|
10842
|
+
const phase = lifecycle.phase ?? (historyTextOf(firstEvent) === void 0 ? "observe" : "reflect");
|
|
10843
|
+
const view = rebuildView(session, phase, shadowedSeqs, config.compressSkipReasoning);
|
|
10844
|
+
if (typeof view === "string") return {
|
|
10845
|
+
ok: false,
|
|
10846
|
+
error: view
|
|
10847
|
+
};
|
|
10848
|
+
if (view.minIndex === void 0 || view.maxIndex === void 0) return {
|
|
10849
|
+
ok: false,
|
|
10850
|
+
error: `压缩 ${request.compactionId} 的原内容无可定位条目`
|
|
10851
|
+
};
|
|
10852
|
+
if (signal?.aborted === true) return {
|
|
10853
|
+
ok: false,
|
|
10854
|
+
error: COMPACTION_ABORTED_ERROR
|
|
10855
|
+
};
|
|
10856
|
+
const target = {
|
|
10857
|
+
provider: request.provider,
|
|
10858
|
+
model: request.model
|
|
10859
|
+
};
|
|
10860
|
+
makeLogger(ctx, config.debug).step(`重压缩:${request.compactionId}(${phase})→ ${target.provider}/${target.model}${request.reasoningEffort === void 0 ? "" : ` · ${request.reasoningEffort}`}`);
|
|
10861
|
+
const originalChars = summary.shadowedCharCount ?? (phase === "observe" ? seqsCharCount(session, shadowedSeqs) : viewCharCount(view));
|
|
10862
|
+
const outcome = await runCompressionLoop(ctx, session, {
|
|
10863
|
+
view,
|
|
10864
|
+
originalChars,
|
|
10865
|
+
phase,
|
|
10866
|
+
taskText: buildCompressionTaskText(phase, view.minIndex, view.maxIndex),
|
|
10867
|
+
target,
|
|
10868
|
+
maxTokens: config.compressMaxTokens,
|
|
10869
|
+
rateLimitWaitMs: config.rateLimitWaitMs,
|
|
10870
|
+
skipReasoning: config.compressSkipReasoning,
|
|
10871
|
+
debug: config.debug,
|
|
10872
|
+
retryTarget: target,
|
|
10873
|
+
...request.reasoningEffort === void 0 ? {} : { reasoningEffort: request.reasoningEffort },
|
|
10874
|
+
...signal === void 0 ? {} : { signal }
|
|
10875
|
+
});
|
|
10876
|
+
if (!outcome.ok) return {
|
|
10877
|
+
ok: false,
|
|
10878
|
+
error: outcome.error,
|
|
10879
|
+
...outcome.recordSessionId === void 0 ? {} : { recordSessionId: outcome.recordSessionId }
|
|
10880
|
+
};
|
|
10881
|
+
return {
|
|
10882
|
+
ok: true,
|
|
10883
|
+
text: outcome.text,
|
|
10884
|
+
phase,
|
|
10885
|
+
rounds: outcome.rounds,
|
|
10886
|
+
originalChars,
|
|
10887
|
+
newChars: outcome.text.length,
|
|
10888
|
+
durationMs: outcome.stats.durationMs,
|
|
10889
|
+
...outcome.recordSessionId === void 0 ? {} : { recordSessionId: outcome.recordSessionId }
|
|
10890
|
+
};
|
|
10891
|
+
}
|
|
10892
|
+
/** 重压缩命令名(压缩卡片按钮经宿主命令通道调用)。 */
|
|
10893
|
+
const RECOMPRESS_COMMAND_NAME = "om-recompress";
|
|
10894
|
+
/** 渲染命令结果文本:成功为「字符 原始消息 → 产物,耗时,模型(等级)」,失败给出原因。 */
|
|
10895
|
+
function describeResult(request, result) {
|
|
10896
|
+
const label = `${request.provider}/${request.model}(${request.reasoningEffort ?? "默认"})`;
|
|
10897
|
+
if (!result.ok) return `重压缩失败 ${label}:${result.error}`;
|
|
10898
|
+
return `重压缩完成 字符 ${formatCompactCount(result.originalChars)} → ${formatCompactCount(result.newChars)},${formatSeconds(result.durationMs)},${label}`;
|
|
10899
|
+
}
|
|
10900
|
+
/** 构造 /om-recompress 命令定义;配置按调用时刻读取。 */
|
|
10901
|
+
function buildRecompressCommand(ctx, getConfig) {
|
|
10902
|
+
return {
|
|
10903
|
+
name: RECOMPRESS_COMMAND_NAME,
|
|
10904
|
+
description: "由压缩卡片调用:用另一模型重新压缩一次已完成的压缩",
|
|
10905
|
+
input: { hint: "<compactionId> <provider> <model> [思考等级]" },
|
|
10906
|
+
handler: async ({ agent, rawInput, signal }) => {
|
|
10907
|
+
const parsed = parseRecompressInput(rawInput);
|
|
10908
|
+
if (!parsed.ok) return {
|
|
10909
|
+
kind: "error",
|
|
10910
|
+
text: parsed.error
|
|
10911
|
+
};
|
|
10912
|
+
const result = await recompress(ctx, agent, getConfig(), parsed.request, signal);
|
|
10913
|
+
const text = describeResult(parsed.request, result);
|
|
10914
|
+
return result.ok ? {
|
|
10915
|
+
kind: "success",
|
|
10916
|
+
text
|
|
10917
|
+
} : {
|
|
10918
|
+
kind: "error",
|
|
10919
|
+
text
|
|
10920
|
+
};
|
|
10921
|
+
}
|
|
10922
|
+
};
|
|
10923
|
+
}
|
|
10924
|
+
//#endregion
|
|
10668
10925
|
//#region src/system-reminder.ts
|
|
10669
10926
|
/**
|
|
10670
|
-
* system-reminder:以 <system-reminder>
|
|
10671
|
-
*
|
|
10672
|
-
*
|
|
10673
|
-
* 每个 step 检查表层;真实用户消息、非空模型 text
|
|
10674
|
-
* 导出 PROGRESS_REMINDER_SOURCE_KIND /
|
|
10675
|
-
*
|
|
10676
|
-
* activeSystemReminders / ensureSystemReminders。
|
|
10927
|
+
* system-reminder:以 <system-reminder> 用户消息向主会话注入进度提醒,不进系统提示词。
|
|
10928
|
+
* 进度提醒:表层缺少同 kind 消息时补发;开启活动重发时,无记录活动累计至少 N 个已结束 step、
|
|
10929
|
+
* 且工具调用超过 M 次时重发(N、M 与开关均来自配置,默认 4 与 10)。
|
|
10930
|
+
* 每个 step 检查表层;真实用户消息、非空模型 text 与进度提醒重置活动窗口。
|
|
10931
|
+
* 导出 PROGRESS_REMINDER_SOURCE_KIND / ProgressReminderSource / SystemReminder /
|
|
10932
|
+
* PROGRESS_REMINDER / ProgressIdleOptions / DEFAULT_PROGRESS_IDLE / progressIdleOptions /
|
|
10933
|
+
* systemReminderMessage / activeSystemReminders / ensureSystemReminders。
|
|
10677
10934
|
*/
|
|
10678
10935
|
/** 进度提醒的 producer-owned source kind(区别于压缩日志消息的 plugin:dsh-plugin-om)。 */
|
|
10679
10936
|
const PROGRESS_REMINDER_SOURCE_KIND = "plugin:dsh-plugin-om:progress";
|
|
10680
|
-
/** 完整消息定义提醒的 producer-owned source kind。 */
|
|
10681
|
-
const DEFINITION_REMINDER_SOURCE_KIND = "plugin:dsh-plugin-om:definition";
|
|
10682
10937
|
/** 用 system-reminder 标签包裹提醒正文。 */
|
|
10683
10938
|
function wrap(lines) {
|
|
10684
10939
|
return [
|
|
@@ -10691,18 +10946,13 @@ function wrap(lines) {
|
|
|
10691
10946
|
const PROGRESS_REMINDER = {
|
|
10692
10947
|
kind: PROGRESS_REMINDER_SOURCE_KIND,
|
|
10693
10948
|
text: wrap([
|
|
10694
|
-
"
|
|
10949
|
+
"在本会话中,你应当持续输出文本,记录最近几步的成果:",
|
|
10695
10950
|
"- 1-2句话即可,概括为主,不必覆盖所有细节",
|
|
10696
10951
|
"- 承上启下,突出要点,例如“读 f1,发现 L1 关联了 f2-L2,读 f2”,“m1 完成,按计划开始 m2”",
|
|
10697
10952
|
"- 记录后继续完成任务,不要等待确认",
|
|
10698
10953
|
"- 记录仅是中间产物,最终输出需要另行构建"
|
|
10699
10954
|
])
|
|
10700
10955
|
};
|
|
10701
|
-
/** 完整消息定义提醒。 */
|
|
10702
|
-
const DEFINITION_REMINDER = {
|
|
10703
|
-
kind: DEFINITION_REMINDER_SOURCE_KIND,
|
|
10704
|
-
text: wrap([COMPLETE_MESSAGE_DEFINITION])
|
|
10705
|
-
};
|
|
10706
10956
|
/** 构造一条新的提醒消息。 */
|
|
10707
10957
|
function systemReminderMessage(reminder) {
|
|
10708
10958
|
return createUserMessage({
|
|
@@ -10716,21 +10966,29 @@ function systemReminderMessage(reminder) {
|
|
|
10716
10966
|
}
|
|
10717
10967
|
});
|
|
10718
10968
|
}
|
|
10719
|
-
/**
|
|
10720
|
-
function activeSystemReminders(config
|
|
10721
|
-
|
|
10722
|
-
if (config.omEnabled) reminders.push(PROGRESS_REMINDER);
|
|
10723
|
-
if (config.recallEnabled || hasHistory) reminders.push(DEFINITION_REMINDER);
|
|
10724
|
-
return reminders;
|
|
10969
|
+
/** 按配置返回应注入的提醒:omEnabled 与 progressReminderEnabled 同时开启时为进度提醒。 */
|
|
10970
|
+
function activeSystemReminders(config) {
|
|
10971
|
+
return config.omEnabled && config.progressReminderEnabled ? [PROGRESS_REMINDER] : [];
|
|
10725
10972
|
}
|
|
10726
|
-
/**
|
|
10727
|
-
|
|
10728
|
-
|
|
10973
|
+
/** 默认活动重发判定,与配置默认值一致。 */
|
|
10974
|
+
const DEFAULT_PROGRESS_IDLE = Object.freeze({
|
|
10975
|
+
enabled: true,
|
|
10976
|
+
steps: 4,
|
|
10977
|
+
toolCalls: 10
|
|
10978
|
+
});
|
|
10979
|
+
/** 由配置取出活动重发判定。 */
|
|
10980
|
+
function progressIdleOptions(config) {
|
|
10981
|
+
return {
|
|
10982
|
+
enabled: config.progressReminderIdleEnabled,
|
|
10983
|
+
steps: config.progressReminderIdleSteps,
|
|
10984
|
+
toolCalls: config.progressReminderIdleToolCalls
|
|
10985
|
+
};
|
|
10729
10986
|
}
|
|
10730
|
-
/**
|
|
10731
|
-
function progressReminderTrigger(surface, events, messages) {
|
|
10987
|
+
/** 进度提醒在表层缺失,或开启活动重发且静默窗口达到 idle 阈值时补发。 */
|
|
10988
|
+
function progressReminderTrigger(surface, events, messages, idle) {
|
|
10732
10989
|
if (messages.some((message) => message.source.kind === "plugin:dsh-plugin-om:progress")) return void 0;
|
|
10733
10990
|
if (!surface.some((event) => event.type === "user/message" && event.data.source.kind === "plugin:dsh-plugin-om:progress")) return "missing";
|
|
10991
|
+
if (!idle.enabled) return void 0;
|
|
10734
10992
|
if (messages.some((message) => message.source.kind === "user")) return void 0;
|
|
10735
10993
|
const ended = /* @__PURE__ */ new Set();
|
|
10736
10994
|
for (const event of events) if (event.type === "step/end") ended.add(`${event.data.turn}:${event.data.step}`);
|
|
@@ -10756,13 +11014,13 @@ function progressReminderTrigger(surface, events, messages) {
|
|
|
10756
11014
|
toolCalls += message.content.filter((block) => block.type === "tool-call").length;
|
|
10757
11015
|
}
|
|
10758
11016
|
}
|
|
10759
|
-
return steps.size >=
|
|
11017
|
+
return steps.size >= idle.steps && toolCalls > idle.toolCalls ? "activity" : void 0;
|
|
10760
11018
|
}
|
|
10761
11019
|
/**
|
|
10762
11020
|
* 按表层与待输入消息补发提醒,追加到末尾且不修改入参。
|
|
10763
|
-
* 进度提醒按 kind
|
|
11021
|
+
* 进度提醒按 kind 去重并按 idle 检测活动窗口(缺省沿用默认阈值),活动达标时追加立刻记录要求。
|
|
10764
11022
|
*/
|
|
10765
|
-
function ensureSystemReminders(session, messages, reminders) {
|
|
11023
|
+
function ensureSystemReminders(session, messages, reminders, idle = DEFAULT_PROGRESS_IDLE) {
|
|
10766
11024
|
const result = [...messages];
|
|
10767
11025
|
if (reminders.length === 0) return result;
|
|
10768
11026
|
const events = session.snapshotEvents();
|
|
@@ -10770,16 +11028,15 @@ function ensureSystemReminders(session, messages, reminders) {
|
|
|
10770
11028
|
const event = events[seq];
|
|
10771
11029
|
return event === void 0 ? [] : [event];
|
|
10772
11030
|
});
|
|
10773
|
-
const
|
|
10774
|
-
|
|
10775
|
-
const trigger = progressReminderTrigger(surface, events, result);
|
|
11031
|
+
for (const reminder of reminders) {
|
|
11032
|
+
const trigger = progressReminderTrigger(surface, events, result, idle);
|
|
10776
11033
|
if (trigger === void 0) continue;
|
|
10777
11034
|
const progress = trigger === "activity" ? {
|
|
10778
11035
|
...reminder,
|
|
10779
11036
|
text: reminder.text.replace("\n</system-reminder>", "\n你应当*立刻*输出一条记录\n</system-reminder>")
|
|
10780
11037
|
} : reminder;
|
|
10781
11038
|
result.push(systemReminderMessage(progress));
|
|
10782
|
-
}
|
|
11039
|
+
}
|
|
10783
11040
|
return result;
|
|
10784
11041
|
}
|
|
10785
11042
|
//#endregion
|
|
@@ -10830,6 +11087,9 @@ function apply(ctx, config) {
|
|
|
10830
11087
|
}
|
|
10831
11088
|
syncTools();
|
|
10832
11089
|
ctx.on("loader/volatile-update", () => syncTools());
|
|
11090
|
+
ctx.inject(["commands"], (inner) => {
|
|
11091
|
+
inner.effect(() => inner.commands.register(buildRecompressCommand(ctx, () => currentConfig(config))), "dsh-plugin-om: recompress command");
|
|
11092
|
+
});
|
|
10833
11093
|
ctx.on("agent/pre-step", async ({ agent, signal }, next) => {
|
|
10834
11094
|
let outcome = { failed: false };
|
|
10835
11095
|
try {
|
|
@@ -10848,11 +11108,11 @@ function apply(ctx, config) {
|
|
|
10848
11108
|
return { kind: "reject" };
|
|
10849
11109
|
}
|
|
10850
11110
|
const decision = await next();
|
|
10851
|
-
const
|
|
10852
|
-
const reminders = activeSystemReminders(
|
|
11111
|
+
const latest = currentConfig(config);
|
|
11112
|
+
const reminders = activeSystemReminders(latest);
|
|
10853
11113
|
if (decision.kind === "enter" && !signal.aborted && reminders.length > 0 && isMainSession(agent.session)) return {
|
|
10854
11114
|
...decision,
|
|
10855
|
-
messages: ensureSystemReminders(agent.session, decision.messages, reminders)
|
|
11115
|
+
messages: ensureSystemReminders(agent.session, decision.messages, reminders, progressIdleOptions(latest))
|
|
10856
11116
|
};
|
|
10857
11117
|
return decision;
|
|
10858
11118
|
});
|
package/dist/recall.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recall.d.ts","sourceRoot":"","sources":["../src/recall.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"recall.d.ts","sourceRoot":"","sources":["../src/recall.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,OAAO,EAAE,KAAK,eAAe,EAAkB,MAAM,sBAAsB,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,YAAY,CAAC;AAGjE;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;iBAYzB,CAAC;AAEL;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;;iBAoCjC,CAAC;AAEL,oDAAoD;AACpD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAElE,8DAA8D;AAC9D,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,UAAQ,GAAG,UAAU,CAU1E;AAQD,mBAAmB;AACnB,MAAM,MAAM,iBAAiB,GAAG;IAC9B,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC;IAC1B,oCAAoC;IACpC,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,cAAc,CA2E3E"}
|