dsh-plugin-om 0.0.52 → 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/dist/config.d.ts CHANGED
@@ -20,6 +20,14 @@ export type PluginConfig = {
20
20
  compressSkipReasoning: boolean;
21
21
  /** 是否启用自动压缩(观察/反思)。 */
22
22
  omEnabled: boolean;
23
+ /** 是否注入进度提醒(与 omEnabled 同时开启才注入)。 */
24
+ progressReminderEnabled: boolean;
25
+ /** 无记录活动达标时是否重发进度提醒(false 时仅在表层缺失时补发)。 */
26
+ progressReminderIdleEnabled: boolean;
27
+ /** 重发判定:静默窗口内已结束模型 step 数下限(≥ 1)。 */
28
+ progressReminderIdleSteps: number;
29
+ /** 重发判定:静默窗口内工具调用数须超过该值(≥ 0)。 */
30
+ progressReminderIdleToolCalls: number;
23
31
  /** 步骤级日志开关(缺省按 NODE_ENV !== 'production' 判定)。 */
24
32
  debug: boolean;
25
33
  /** 是否注册 recall 工具。 */
@@ -46,6 +54,10 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
46
54
  tailMessageCount: Schema<number, number, "volatile-defined">;
47
55
  compressSkipReasoning: Schema<boolean, boolean, "volatile-defined">;
48
56
  omEnabled: Schema<boolean, boolean, "volatile-defined">;
57
+ progressReminderEnabled: Schema<boolean, boolean, "volatile-defined">;
58
+ progressReminderIdleEnabled: Schema<boolean, boolean, "volatile-defined">;
59
+ progressReminderIdleSteps: Schema<number, number, "volatile-defined">;
60
+ progressReminderIdleToolCalls: Schema<number, number, "volatile-defined">;
49
61
  debug: Schema<boolean, boolean, "volatile-defined">;
50
62
  recallEnabled: Schema<boolean, boolean, "volatile-defined">;
51
63
  semanticRecallEnabled: Schema<boolean, boolean, "volatile-defined">;
@@ -61,6 +73,10 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
61
73
  tailMessageCount: Schema<number, number, "volatile-defined">;
62
74
  compressSkipReasoning: Schema<boolean, boolean, "volatile-defined">;
63
75
  omEnabled: Schema<boolean, boolean, "volatile-defined">;
76
+ progressReminderEnabled: Schema<boolean, boolean, "volatile-defined">;
77
+ progressReminderIdleEnabled: Schema<boolean, boolean, "volatile-defined">;
78
+ progressReminderIdleSteps: Schema<number, number, "volatile-defined">;
79
+ progressReminderIdleToolCalls: Schema<number, number, "volatile-defined">;
64
80
  debug: Schema<boolean, boolean, "volatile-defined">;
65
81
  recallEnabled: Schema<boolean, boolean, "volatile-defined">;
66
82
  semanticRecallEnabled: Schema<boolean, boolean, "volatile-defined">;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,MAAM,MAAM,0BAA0B,CAAC;AAI9C,kCAAkC;AAClC,MAAM,MAAM,YAAY,GAAG;IACzB,oCAAoC;IACpC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,wDAAwD;IACxD,sBAAsB,EAAE,MAAM,CAAC;IAC/B,2DAA2D;IAC3D,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,sCAAsC;IACtC,eAAe,EAAE,MAAM,CAAC;IACxB,yDAAyD;IACzD,gBAAgB,EAAE,MAAM,CAAC;IACzB,oEAAoE;IACpE,qBAAqB,EAAE,OAAO,CAAC;IAC/B,uBAAuB;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,iDAAiD;IACjD,KAAK,EAAE,OAAO,CAAC;IACf,sBAAsB;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,0DAA0D;IAC1D,qBAAqB,EAAE,OAAO,CAAC;IAC/B,kBAAkB;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,yDAAyD;IACzD,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,yCAAyC;IACzC,uBAAuB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7C,CAAC;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,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,yDAAyD;IACzD,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,yCAAyC;IACzC,uBAAuB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7C,CAAC;AAEF,iEAAiE;AACjE,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,YAAY,CAmBhD,CAAC;AAEH,uDAAuD;AACvD,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAuCL,CAAC;AAEf,4CAA4C;AAC5C,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC,YAAY,CAAC,CAQtE;AA4CD,wCAAwC;AACxC,wBAAgB,aAAa,CAAC,GAAG,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC,YAAY,CAAC,CA6BnE"}
package/dist/format.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  /**
2
- * 紧凑数字格式化(压缩卡片、重压缩记录与压缩日志共用)。零依赖,服务端与浏览器均可引用。导出 formatCompactCount。
2
+ * 紧凑数字格式化(压缩卡片、重压缩记录与压缩日志共用)。零依赖,服务端与浏览器均可引用。导出 formatCompactCount / formatSeconds。
3
3
  * <1k 原样;≥1k 用 k;≥1w(万)用 w;≥1M 用 M;保留 1 位小数并去掉末尾 .0。
4
4
  */
5
5
  export declare function formatCompactCount(value: number): string;
6
+ /** 毫秒耗时格式化为一位小数的秒数,如 63.1s。 */
7
+ export declare function formatSeconds(durationMs: number): string;
6
8
  //# sourceMappingURL=format.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CASxD"}
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CASxD;AAED,+BAA+B;AAC/B,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAExD"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,MAAM,EAAiB,MAAM,aAAa,CAAC;AAMpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C,6BAA6B;AAC7B,eAAO,MAAM,IAAI,kBAAkB,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB,wDAAwD;AACxD,eAAO,MAAM,MAAM,UAA6C,CAAC;AAEjE,8CAA8C;AAC9C,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CA2G1D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,MAAM,EAAiB,MAAM,aAAa,CAAC;AAUpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C,6BAA6B;AAC7B,eAAO,MAAM,IAAI,kBAAkB,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB,wDAAwD;AACxD,eAAO,MAAM,MAAM,UAA6C,CAAC;AAEjE,8CAA8C;AAC9C,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAiH1D"}
package/dist/index.mjs CHANGED
@@ -17,7 +17,7 @@ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).expor
17
17
  //#endregion
18
18
  //#region src/format.ts
19
19
  /**
20
- * 紧凑数字格式化(压缩卡片、重压缩记录与压缩日志共用)。零依赖,服务端与浏览器均可引用。导出 formatCompactCount。
20
+ * 紧凑数字格式化(压缩卡片、重压缩记录与压缩日志共用)。零依赖,服务端与浏览器均可引用。导出 formatCompactCount / formatSeconds。
21
21
  * <1k 原样;≥1k 用 k;≥1w(万)用 w;≥1M 用 M;保留 1 位小数并去掉末尾 .0。
22
22
  */
23
23
  function formatCompactCount(value) {
@@ -30,6 +30,10 @@ function formatCompactCount(value) {
30
30
  if (value >= 1e3) return `${trim(value / 1e3)}k`;
31
31
  return String(value);
32
32
  }
33
+ /** 毫秒耗时格式化为一位小数的秒数,如 63.1s。 */
34
+ function formatSeconds(durationMs) {
35
+ return `${(durationMs / 1e3).toFixed(1)}s`;
36
+ }
33
37
  //#endregion
34
38
  //#region src/constants.ts
35
39
  /** 插件标识:日志前缀与历史日志的 source.plugin 取值。 */
@@ -10184,6 +10188,10 @@ const DEFAULT_CONFIG = Object.freeze({
10184
10188
  tailMessageCount: 20,
10185
10189
  compressSkipReasoning: true,
10186
10190
  omEnabled: true,
10191
+ progressReminderEnabled: true,
10192
+ progressReminderIdleEnabled: true,
10193
+ progressReminderIdleSteps: 4,
10194
+ progressReminderIdleToolCalls: 10,
10187
10195
  debug: false,
10188
10196
  recallEnabled: true,
10189
10197
  semanticRecallEnabled: true,
@@ -10201,6 +10209,10 @@ const Config = Schema.object({
10201
10209
  tailMessageCount: Schema.number().step(1).default(DEFAULT_CONFIG.tailMessageCount).volatile(),
10202
10210
  compressSkipReasoning: Schema.boolean().default(DEFAULT_CONFIG.compressSkipReasoning).volatile(),
10203
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(),
10204
10216
  debug: Schema.boolean().default(process.env.NODE_ENV !== "production").volatile(),
10205
10217
  recallEnabled: Schema.boolean().default(DEFAULT_CONFIG.recallEnabled).volatile(),
10206
10218
  semanticRecallEnabled: Schema.boolean().default(DEFAULT_CONFIG.semanticRecallEnabled).volatile(),
@@ -10219,13 +10231,23 @@ function currentConfig(config) {
10219
10231
  }
10220
10232
  return resolveConfig(values);
10221
10233
  }
10222
- /** 数值键校验参数表:键名 + [是否必须为整数]。 */
10234
+ /** 数值键校验参数表:键名 + [是否必须为整数, 下限(含)]。 */
10223
10235
  const NUMBER_KEYS = [
10224
10236
  ["observeThresholdTokens", true],
10225
10237
  ["reflectThresholdTokens", true],
10226
10238
  ["compressMaxTokens", true],
10227
10239
  ["rateLimitWaitMs", true],
10228
- ["tailMessageCount", true]
10240
+ ["tailMessageCount", true],
10241
+ [
10242
+ "progressReminderIdleSteps",
10243
+ true,
10244
+ 1
10245
+ ],
10246
+ [
10247
+ "progressReminderIdleToolCalls",
10248
+ true,
10249
+ 0
10250
+ ]
10229
10251
  ];
10230
10252
  /** 归一化原始配置输入:缺省 / null / 空串 / 非对象视为空对象。 */
10231
10253
  function normalizeConfigInput(raw) {
@@ -10249,16 +10271,19 @@ function resolveOptionalString(raw) {
10249
10271
  function resolveConfig(raw) {
10250
10272
  const input = normalizeConfigInput(raw);
10251
10273
  const config = { ...DEFAULT_CONFIG };
10252
- for (const [key, integer] of NUMBER_KEYS) {
10274
+ for (const [key, integer, min] of NUMBER_KEYS) {
10253
10275
  const value = input[key];
10254
10276
  if (value === void 0 || value === null) continue;
10255
10277
  if (typeof value === "string" && value.trim() === "") continue;
10256
10278
  if (typeof value !== "number" || !Number.isFinite(value)) continue;
10257
10279
  if (integer && !Number.isInteger(value)) continue;
10280
+ if (min !== void 0 && value < min) continue;
10258
10281
  config[key] = value;
10259
10282
  }
10260
10283
  config.compressSkipReasoning = resolveBoolean(input.compressSkipReasoning, true);
10261
10284
  config.omEnabled = resolveBoolean(input.omEnabled, true);
10285
+ config.progressReminderEnabled = resolveBoolean(input.progressReminderEnabled, true);
10286
+ config.progressReminderIdleEnabled = resolveBoolean(input.progressReminderIdleEnabled, true);
10262
10287
  config.debug = resolveBoolean(input.debug, process.env.NODE_ENV !== "production");
10263
10288
  config.recallEnabled = resolveBoolean(input.recallEnabled, true);
10264
10289
  config.semanticRecallEnabled = config.recallEnabled && resolveBoolean(input.semanticRecallEnabled, true);
@@ -10758,8 +10783,6 @@ function parseRecompressInput(rawInput) {
10758
10783
  }
10759
10784
  };
10760
10785
  }
10761
- /** 正在重压缩的会话 id(同一会话同时仅一次)。 */
10762
- const running = /* @__PURE__ */ new Set();
10763
10786
  /** 按 compactionId 收集 start/summary/end 载荷。 */
10764
10787
  function findLifecycle(session, compactionId) {
10765
10788
  const lifecycle = {
@@ -10830,63 +10853,49 @@ async function recompress(ctx, agent, config, request, signal) {
10830
10853
  ok: false,
10831
10854
  error: COMPACTION_ABORTED_ERROR
10832
10855
  };
10833
- if (running.has(session.id)) return {
10834
- ok: false,
10835
- error: "该会话已有重压缩进行中"
10836
- };
10837
10856
  const target = {
10838
10857
  provider: request.provider,
10839
10858
  model: request.model
10840
10859
  };
10841
- const logger = makeLogger(ctx, config.debug);
10842
- running.add(session.id);
10843
- try {
10844
- logger.step(`重压缩:${request.compactionId}(${phase})→ ${target.provider}/${target.model}${request.reasoningEffort === void 0 ? "" : ` · ${request.reasoningEffort}`}`);
10845
- const originalChars = summary.shadowedCharCount ?? (phase === "observe" ? seqsCharCount(session, shadowedSeqs) : viewCharCount(view));
10846
- const outcome = await runCompressionLoop(ctx, session, {
10847
- view,
10848
- originalChars,
10849
- phase,
10850
- taskText: buildCompressionTaskText(phase, view.minIndex, view.maxIndex),
10851
- target,
10852
- maxTokens: config.compressMaxTokens,
10853
- rateLimitWaitMs: config.rateLimitWaitMs,
10854
- skipReasoning: config.compressSkipReasoning,
10855
- debug: config.debug,
10856
- retryTarget: target,
10857
- ...request.reasoningEffort === void 0 ? {} : { reasoningEffort: request.reasoningEffort },
10858
- ...signal === void 0 ? {} : { signal }
10859
- });
10860
- if (!outcome.ok) return {
10861
- ok: false,
10862
- error: outcome.error,
10863
- ...outcome.recordSessionId === void 0 ? {} : { recordSessionId: outcome.recordSessionId }
10864
- };
10865
- return {
10866
- ok: true,
10867
- text: outcome.text,
10868
- phase,
10869
- rounds: outcome.rounds,
10870
- originalChars,
10871
- newChars: outcome.text.length,
10872
- durationMs: outcome.stats.durationMs,
10873
- ...outcome.recordSessionId === void 0 ? {} : { recordSessionId: outcome.recordSessionId }
10874
- };
10875
- } finally {
10876
- running.delete(session.id);
10877
- }
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
+ };
10878
10891
  }
10879
10892
  /** 重压缩命令名(压缩卡片按钮经宿主命令通道调用)。 */
10880
10893
  const RECOMPRESS_COMMAND_NAME = "om-recompress";
10881
- /** 毫秒耗时的简短文本。 */
10882
- function secondsText(durationMs) {
10883
- return `${(durationMs / 1e3).toFixed(1)}s`;
10884
- }
10885
- /** 渲染命令结果文本:成功为「模型(等级),原始消息 → 产物,耗时」,失败给出原因。 */
10894
+ /** 渲染命令结果文本:成功为「字符 原始消息 → 产物,耗时,模型(等级)」,失败给出原因。 */
10886
10895
  function describeResult(request, result) {
10887
10896
  const label = `${request.provider}/${request.model}(${request.reasoningEffort ?? "默认"})`;
10888
10897
  if (!result.ok) return `重压缩失败 ${label}:${result.error}`;
10889
- return `重压缩完成 ${label},${formatCompactCount(result.originalChars)} → ${formatCompactCount(result.newChars)},${secondsText(result.durationMs)}`;
10898
+ return `重压缩完成 字符 ${formatCompactCount(result.originalChars)} → ${formatCompactCount(result.newChars)},${formatSeconds(result.durationMs)},${label}`;
10890
10899
  }
10891
10900
  /** 构造 /om-recompress 命令定义;配置按调用时刻读取。 */
10892
10901
  function buildRecompressCommand(ctx, getConfig) {
@@ -10916,10 +10925,12 @@ function buildRecompressCommand(ctx, getConfig) {
10916
10925
  //#region src/system-reminder.ts
10917
10926
  /**
10918
10927
  * system-reminder:以 <system-reminder> 用户消息向主会话注入进度提醒,不进系统提示词。
10919
- * 进度提醒:表层缺少同 kind 消息时补发,或无记录活动累计至少 4 个已结束 step、超过 10 次工具调用时重发。
10928
+ * 进度提醒:表层缺少同 kind 消息时补发;开启活动重发时,无记录活动累计至少 N 个已结束 step、
10929
+ * 且工具调用超过 M 次时重发(N、M 与开关均来自配置,默认 4 与 10)。
10920
10930
  * 每个 step 检查表层;真实用户消息、非空模型 text 与进度提醒重置活动窗口。
10921
10931
  * 导出 PROGRESS_REMINDER_SOURCE_KIND / ProgressReminderSource / SystemReminder /
10922
- * PROGRESS_REMINDER / systemReminderMessage / activeSystemReminders / ensureSystemReminders。
10932
+ * PROGRESS_REMINDER / ProgressIdleOptions / DEFAULT_PROGRESS_IDLE / progressIdleOptions /
10933
+ * systemReminderMessage / activeSystemReminders / ensureSystemReminders。
10923
10934
  */
10924
10935
  /** 进度提醒的 producer-owned source kind(区别于压缩日志消息的 plugin:dsh-plugin-om)。 */
10925
10936
  const PROGRESS_REMINDER_SOURCE_KIND = "plugin:dsh-plugin-om:progress";
@@ -10955,14 +10966,29 @@ function systemReminderMessage(reminder) {
10955
10966
  }
10956
10967
  });
10957
10968
  }
10958
- /** 按配置返回应注入的提醒:omEnabled 时为进度提醒。 */
10969
+ /** 按配置返回应注入的提醒:omEnabled 与 progressReminderEnabled 同时开启时为进度提醒。 */
10959
10970
  function activeSystemReminders(config) {
10960
- return config.omEnabled ? [PROGRESS_REMINDER] : [];
10971
+ return config.omEnabled && config.progressReminderEnabled ? [PROGRESS_REMINDER] : [];
10972
+ }
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
+ };
10961
10986
  }
10962
- /** 进度提醒在表层缺失,或静默窗口达到 4 个已结束 step 且超过 10 次调用时补发。 */
10963
- function progressReminderTrigger(surface, events, messages) {
10987
+ /** 进度提醒在表层缺失,或开启活动重发且静默窗口达到 idle 阈值时补发。 */
10988
+ function progressReminderTrigger(surface, events, messages, idle) {
10964
10989
  if (messages.some((message) => message.source.kind === "plugin:dsh-plugin-om:progress")) return void 0;
10965
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;
10966
10992
  if (messages.some((message) => message.source.kind === "user")) return void 0;
10967
10993
  const ended = /* @__PURE__ */ new Set();
10968
10994
  for (const event of events) if (event.type === "step/end") ended.add(`${event.data.turn}:${event.data.step}`);
@@ -10988,13 +11014,13 @@ function progressReminderTrigger(surface, events, messages) {
10988
11014
  toolCalls += message.content.filter((block) => block.type === "tool-call").length;
10989
11015
  }
10990
11016
  }
10991
- return steps.size >= 4 && toolCalls > 10 ? "activity" : void 0;
11017
+ return steps.size >= idle.steps && toolCalls > idle.toolCalls ? "activity" : void 0;
10992
11018
  }
10993
11019
  /**
10994
11020
  * 按表层与待输入消息补发提醒,追加到末尾且不修改入参。
10995
- * 进度提醒按 kind 去重并检测活动窗口,活动达标时追加立刻记录要求。
11021
+ * 进度提醒按 kind 去重并按 idle 检测活动窗口(缺省沿用默认阈值),活动达标时追加立刻记录要求。
10996
11022
  */
10997
- function ensureSystemReminders(session, messages, reminders) {
11023
+ function ensureSystemReminders(session, messages, reminders, idle = DEFAULT_PROGRESS_IDLE) {
10998
11024
  const result = [...messages];
10999
11025
  if (reminders.length === 0) return result;
11000
11026
  const events = session.snapshotEvents();
@@ -11003,7 +11029,7 @@ function ensureSystemReminders(session, messages, reminders) {
11003
11029
  return event === void 0 ? [] : [event];
11004
11030
  });
11005
11031
  for (const reminder of reminders) {
11006
- const trigger = progressReminderTrigger(surface, events, result);
11032
+ const trigger = progressReminderTrigger(surface, events, result, idle);
11007
11033
  if (trigger === void 0) continue;
11008
11034
  const progress = trigger === "activity" ? {
11009
11035
  ...reminder,
@@ -11082,10 +11108,11 @@ function apply(ctx, config) {
11082
11108
  return { kind: "reject" };
11083
11109
  }
11084
11110
  const decision = await next();
11085
- const reminders = activeSystemReminders(currentConfig(config));
11111
+ const latest = currentConfig(config);
11112
+ const reminders = activeSystemReminders(latest);
11086
11113
  if (decision.kind === "enter" && !signal.aborted && reminders.length > 0 && isMainSession(agent.session)) return {
11087
11114
  ...decision,
11088
- messages: ensureSystemReminders(agent.session, decision.messages, reminders)
11115
+ messages: ensureSystemReminders(agent.session, decision.messages, reminders, progressIdleOptions(latest))
11089
11116
  };
11090
11117
  return decision;
11091
11118
  });
@@ -10,7 +10,7 @@
10
10
  * 会话记录子会话及其在父会话的 subagent/catalog,标题带「重压缩 provider/model」
11
11
  * - 目标模型与思考等级由调用方显式指定,不做模型信息校验,也不受 compressProvider /
12
12
  * compressModel 配置影响
13
- * - 仅主会话可用;同一会话同时仅允许一次重压缩
13
+ * - 仅主会话可用;同一会话允许多次重压缩并行,互不影响
14
14
  * - 命令 /om-recompress 是压缩卡片按钮到服务端的内部通道(宿主命令通道),结果文本
15
15
  * 由发起方 UI 渲染,命令事件 log-only 不进模型上下文
16
16
  */
@@ -1 +1 @@
1
- {"version":3,"file":"recompress.d.ts","sourceRoot":"","sources":["../src/recompress.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAcnE,OAAO,KAAK,EACV,KAAK,EAIL,OAAO,EACP,YAAY,EAEb,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,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iBAAiB,CAanB"}
@@ -16,11 +16,21 @@ export type SystemReminder = {
16
16
  export declare const PROGRESS_REMINDER: SystemReminder;
17
17
  /** 构造一条新的提醒消息。 */
18
18
  export declare function systemReminderMessage(reminder: SystemReminder): UserMessage;
19
- /** 按配置返回应注入的提醒:omEnabled 时为进度提醒。 */
20
- export declare function activeSystemReminders(config: Pick<PluginConfig, 'omEnabled'>): SystemReminder[];
19
+ /** 按配置返回应注入的提醒:omEnabled 与 progressReminderEnabled 同时开启时为进度提醒。 */
20
+ export declare function activeSystemReminders(config: Pick<PluginConfig, 'omEnabled' | 'progressReminderEnabled'>): SystemReminder[];
21
+ /** 活动重发判定:开关、静默窗口内已结束 step 数下限、工具调用数须超过的值。 */
22
+ export type ProgressIdleOptions = {
23
+ readonly enabled: boolean;
24
+ readonly steps: number;
25
+ readonly toolCalls: number;
26
+ };
27
+ /** 默认活动重发判定,与配置默认值一致。 */
28
+ export declare const DEFAULT_PROGRESS_IDLE: ProgressIdleOptions;
29
+ /** 由配置取出活动重发判定。 */
30
+ export declare function progressIdleOptions(config: Pick<PluginConfig, 'progressReminderIdleEnabled' | 'progressReminderIdleSteps' | 'progressReminderIdleToolCalls'>): ProgressIdleOptions;
21
31
  /**
22
32
  * 按表层与待输入消息补发提醒,追加到末尾且不修改入参。
23
- * 进度提醒按 kind 去重并检测活动窗口,活动达标时追加立刻记录要求。
33
+ * 进度提醒按 kind 去重并按 idle 检测活动窗口(缺省沿用默认阈值),活动达标时追加立刻记录要求。
24
34
  */
25
- export declare function ensureSystemReminders(session: Session, messages: readonly UserMessage[], reminders: readonly SystemReminder[]): UserMessage[];
35
+ export declare function ensureSystemReminders(session: Session, messages: readonly UserMessage[], reminders: readonly SystemReminder[], idle?: ProgressIdleOptions): UserMessage[];
26
36
  //# sourceMappingURL=system-reminder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"system-reminder.d.ts","sourceRoot":"","sources":["../src/system-reminder.ts"],"names":[],"mappings":"AAQA,OAAO,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A6B,CAAC;IACpD,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;CAC/B,CAAC;AAEF,kDAAkD;AAClD,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,IAAI,EAAE,OAAO,6BAA6B,CAAC;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAOF,YAAY;AACZ,eAAO,MAAM,iBAAiB,EAAE,cAS/B,CAAC;AAEF,kBAAkB;AAClB,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,cAAc,GAAG,WAAW,CAK3E;AAED,kEAAkE;AAClE,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,WAAW,GAAG,yBAAyB,CAAC,GAClE,cAAc,EAAE,CAElB;AAED,8CAA8C;AAC9C,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,yBAAyB;AACzB,eAAO,MAAM,qBAAqB,EAAE,mBAIlC,CAAC;AAEH,mBAAmB;AACnB,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,IAAI,CACV,YAAY,EACZ,6BAA6B,GAAG,2BAA2B,GAAG,+BAA+B,CAC9F,GACA,mBAAmB,CAMrB;AAkDD;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,SAAS,WAAW,EAAE,EAChC,SAAS,EAAE,SAAS,cAAc,EAAE,EACpC,IAAI,GAAE,mBAA2C,GAChD,WAAW,EAAE,CAwBf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-om",
3
- "version": "0.0.52",
3
+ "version": "0.0.53",
4
4
  "type": "module",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.mjs",