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.
Files changed (44) hide show
  1. package/README.md +17 -5
  2. package/dist/client/OmCompactionCard.d.ts +4 -1
  3. package/dist/client/OmCompactionCard.d.ts.map +1 -1
  4. package/dist/client/OmRecompressMenu.d.ts +13 -0
  5. package/dist/client/OmRecompressMenu.d.ts.map +1 -0
  6. package/dist/client/definition.d.ts +10 -0
  7. package/dist/client/definition.d.ts.map +1 -1
  8. package/dist/client/index.d.ts.map +1 -1
  9. package/dist/client/locales.d.ts +23 -2
  10. package/dist/client/locales.d.ts.map +1 -1
  11. package/dist/client/om-config-controller.d.ts +13 -1
  12. package/dist/client/om-config-controller.d.ts.map +1 -1
  13. package/dist/client/recompress-inject.d.ts +9 -0
  14. package/dist/client/recompress-inject.d.ts.map +1 -0
  15. package/dist/client/recompress-run.d.ts +73 -0
  16. package/dist/client/recompress-run.d.ts.map +1 -0
  17. package/dist/client.js +472 -54
  18. package/dist/client.js.map +1 -1
  19. package/dist/compaction-log.d.ts +28 -4
  20. package/dist/compaction-log.d.ts.map +1 -1
  21. package/dist/compress-loop.d.ts +6 -0
  22. package/dist/compress-loop.d.ts.map +1 -1
  23. package/dist/compress.d.ts +7 -3
  24. package/dist/compress.d.ts.map +1 -1
  25. package/dist/config.d.ts +16 -0
  26. package/dist/config.d.ts.map +1 -1
  27. package/dist/constants.d.ts +1 -1
  28. package/dist/constants.d.ts.map +1 -1
  29. package/dist/format.d.ts +8 -0
  30. package/dist/format.d.ts.map +1 -0
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.mjs +325 -65
  33. package/dist/recall.d.ts.map +1 -1
  34. package/dist/recompress.d.ts +66 -0
  35. package/dist/recompress.d.ts.map +1 -0
  36. package/dist/system-reminder.d.ts +15 -14
  37. package/dist/system-reminder.d.ts.map +1 -1
  38. package/dist/types.d.ts +1 -3
  39. package/dist/types.d.ts.map +1 -1
  40. package/dist/utils.d.ts +3 -1
  41. package/dist/utils.d.ts.map +1 -1
  42. package/package.json +4 -1
  43. package/dist/client/format.d.ts +0 -6
  44. package/dist/client/format.d.ts.map +0 -1
package/dist/client.js CHANGED
@@ -6,6 +6,7 @@ window.__ModuleLoader__.load({
6
6
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
7
  let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
8
8
  let react = require("react");
9
+ let react_dom = require("react-dom");
9
10
  let react_jsx_runtime = require("react/jsx-runtime");
10
11
  /**
11
12
  * 解码一条会话事件为 om 私有事件:仅识别 feedback/record 中带 om 信封前缀的
@@ -90,12 +91,20 @@ window.__ModuleLoader__.load({
90
91
  }
91
92
  return null;
92
93
  }
94
+ /** 非空字符串原样返回,其余为 null。 */
95
+ function nonEmptyString(value) {
96
+ return typeof value === "string" && value !== "" ? value : null;
97
+ }
93
98
  /** 从 compaction/summary 载荷提取摘要文本与遮蔽统计(载荷非法时各字段回落 null)。 */
94
- function compactSummaryData(summaryMatch, endMatch) {
99
+ function compactSummaryData(compactionId, summaryMatch, endMatch) {
95
100
  let summary = null;
96
101
  let shadowedItemCount = null;
97
102
  let shadowedTokenCount = null;
98
103
  let shadowedCharCount = null;
104
+ let provider = null;
105
+ let model = null;
106
+ let reasoningEffort = null;
107
+ let durationMs = null;
99
108
  if (summaryMatch?.event.type === "compaction/summary") {
100
109
  const data = summaryMatch.event.data;
101
110
  if (Array.isArray(data.summary)) {
@@ -105,8 +114,13 @@ window.__ModuleLoader__.load({
105
114
  shadowedItemCount = Array.isArray(data.shadowedSeqs) && data.shadowedSeqs.every((seq) => Number.isSafeInteger(seq) && seq >= 0) ? data.shadowedSeqs.length : null;
106
115
  shadowedTokenCount = Number.isSafeInteger(data.shadowedTokenCount) && data.shadowedTokenCount >= 0 ? data.shadowedTokenCount : null;
107
116
  shadowedCharCount = data.shadowedCharCount !== void 0 && Number.isSafeInteger(data.shadowedCharCount) && data.shadowedCharCount >= 0 ? data.shadowedCharCount : null;
117
+ provider = nonEmptyString(data.provider);
118
+ model = nonEmptyString(data.model);
119
+ reasoningEffort = nonEmptyString(data.reasoningEffort);
120
+ durationMs = typeof data.durationMs === "number" && Number.isFinite(data.durationMs) && data.durationMs >= 0 ? data.durationMs : null;
108
121
  }
109
122
  return {
123
+ compactionId,
110
124
  running: false,
111
125
  phase: null,
112
126
  error: null,
@@ -117,6 +131,10 @@ window.__ModuleLoader__.load({
117
131
  shadowedCharCount,
118
132
  summaryCharCount: summary === null ? null : summary.length,
119
133
  summaryTokenCount: summary === null ? null : Math.ceil(summary.length / 4),
134
+ provider,
135
+ model,
136
+ reasoningEffort,
137
+ durationMs,
120
138
  diagnosticSessionId: diagnosticSessionIdOf(summaryMatch, endMatch)
121
139
  };
122
140
  }
@@ -126,8 +144,9 @@ window.__ModuleLoader__.load({
126
144
  return data?.phase === "observe" || data?.phase === "reflect" ? data.phase : null;
127
145
  }
128
146
  /** 压缩进行中提示行的载荷(统计未就绪,全部为 null)。 */
129
- function runningData(start) {
147
+ function runningData(compactionId, start) {
130
148
  return {
149
+ compactionId,
131
150
  running: true,
132
151
  phase: startPhase(start),
133
152
  error: null,
@@ -138,6 +157,10 @@ window.__ModuleLoader__.load({
138
157
  shadowedCharCount: null,
139
158
  summaryCharCount: null,
140
159
  summaryTokenCount: null,
160
+ provider: null,
161
+ model: null,
162
+ reasoningEffort: null,
163
+ durationMs: null,
141
164
  diagnosticSessionId: null
142
165
  };
143
166
  }
@@ -146,9 +169,10 @@ window.__ModuleLoader__.load({
146
169
  * error 取 compaction/end 载荷中的实际报错文案(非字符串或为空时回落 null);
147
170
  * 摘要与统计字段全部为 null。
148
171
  */
149
- function failureData(start, end) {
172
+ function failureData(compactionId, start, end) {
150
173
  const data = end.event.data;
151
174
  return {
175
+ compactionId,
152
176
  running: false,
153
177
  phase: startPhase(start),
154
178
  error: typeof data?.error === "string" && data.error !== "" ? data.error : null,
@@ -159,6 +183,10 @@ window.__ModuleLoader__.load({
159
183
  shadowedCharCount: null,
160
184
  summaryCharCount: null,
161
185
  summaryTokenCount: null,
186
+ provider: null,
187
+ model: null,
188
+ reasoningEffort: null,
189
+ durationMs: null,
162
190
  diagnosticSessionId: diagnosticSessionIdOf(end)
163
191
  };
164
192
  }
@@ -231,16 +259,16 @@ window.__ModuleLoader__.load({
231
259
  buildViewNode: (context) => {
232
260
  const state = context.state ?? fallbackState(context);
233
261
  if (state.checkpoint !== void 0) {
234
- const data = compactSummaryData(state.summary, state.end);
262
+ const data = compactSummaryData(context.id, state.summary, state.end);
235
263
  return chatNode(context, COMPACTION_CARD_KIND, state.checkpoint.event.seq, data);
236
264
  }
237
265
  if (state.end !== void 0) {
238
266
  const anchorSeq = context.start?.event.seq ?? state.end.event.seq;
239
267
  const endData = state.end.event.data;
240
- if (typeof endData?.error === "string" && endData.error !== "" && !endData.error.startsWith("压缩已中止(signal aborted)")) return chatNode(context, COMPACTION_CARD_KIND, anchorSeq, failureData(context.start, state.end));
241
- return chatNode(context, COMPACTION_CARD_KIND, anchorSeq, runningData(context.start), "hidden");
268
+ if (typeof endData?.error === "string" && endData.error !== "" && !endData.error.startsWith("压缩已中止(signal aborted)")) return chatNode(context, COMPACTION_CARD_KIND, anchorSeq, failureData(context.id, context.start, state.end));
269
+ return chatNode(context, COMPACTION_CARD_KIND, anchorSeq, runningData(context.id, context.start), "hidden");
242
270
  }
243
- if (context.start !== void 0) return chatNode(context, COMPACTION_CARD_KIND, context.start.event.seq, runningData(context.start));
271
+ if (context.start !== void 0) return chatNode(context, COMPACTION_CARD_KIND, context.start.event.seq, runningData(context.id, context.start));
244
272
  return null;
245
273
  }
246
274
  };
@@ -287,7 +315,9 @@ window.__ModuleLoader__.load({
287
315
  const zh = {
288
316
  compaction: "上下文已压缩",
289
317
  "compaction.completed": "已压缩 {items} 条历史记录(约 {tokens} tokens)",
290
- "compaction.stats": "{items} 条 · {beforeChars} 字符({beforeTokens} tokens)→ {afterChars} 字符({afterTokens} tokens)",
318
+ "compaction.stats": "字符 {beforeChars} → {afterChars}",
319
+ "compaction.stats.sep": ",",
320
+ "compaction.stats.effortDefault": "默认",
291
321
  "compaction.expand": "点击查看压缩摘要",
292
322
  "compaction.unavailable": "压缩摘要不可用",
293
323
  "compaction.running": "正在压缩上下文…",
@@ -298,6 +328,17 @@ window.__ModuleLoader__.load({
298
328
  "compaction.failed.reflect": "上下文压缩失败(反思)",
299
329
  "card.inspect": "诊断日志",
300
330
  "card.trajectory": "轨迹",
331
+ "recompress.action": "尝试其他模型",
332
+ "recompress.running": "重压缩中…",
333
+ "recompress.started": "压缩开始,完成后会添加至“子智能体”",
334
+ "recompress.search": "搜索模型",
335
+ "recompress.loading": "正在加载模型…",
336
+ "recompress.empty": "没有可用模型",
337
+ "recompress.loadFailed": "模型列表加载失败",
338
+ "recompress.retry": "重试",
339
+ "recompress.effort.default": "模型默认",
340
+ "recompress.done": "重压缩完成,会话记录已写入日志",
341
+ "recompress.failed": "重压缩失败:{error}",
301
342
  warning: "上下文压缩功能降级",
302
343
  "config.description": "配置上下文压缩与原文召回。",
303
344
  "config.loading": "正在加载配置…",
@@ -332,7 +373,15 @@ window.__ModuleLoader__.load({
332
373
  "config.modelDir": "嵌入模型目录",
333
374
  "config.modelDir.hint": "本地语义增强使用的嵌入模型目录。",
334
375
  "config.omEnabled": "自动压缩",
335
- "config.omEnabled.hint": "启用观察压缩和摘要反思合并。",
376
+ "config.omEnabled.hint": "启用观察压缩和摘要反思合并;关闭后进度提醒也不再注入。",
377
+ "config.progressReminderEnabled": "进度提醒",
378
+ "config.progressReminderEnabled.hint": "向主会话注入进度提醒,要求模型持续输出记录;需同时开启自动压缩。",
379
+ "config.progressReminderIdleEnabled": "长期无记录时重发",
380
+ "config.progressReminderIdleEnabled.hint": "模型长期只调用工具不输出记录时重发提醒;关闭后仅在提醒缺失时补发。",
381
+ "config.progressReminderIdleSteps": "重发步数",
382
+ "config.progressReminderIdleSteps.hint": "无记录的已结束步骤数达到此值才重发,至少为 1。",
383
+ "config.progressReminderIdleToolCalls": "重发工具调用数",
384
+ "config.progressReminderIdleToolCalls.hint": "无记录期间工具调用数超过此值才重发,至少为 0。",
336
385
  "config.recallEnabled": "原文召回",
337
386
  "config.recallEnabled.hint": "注册召回工具,按消息序号回看原文。",
338
387
  "config.semanticRecallEnabled": "语义增强",
@@ -344,7 +393,9 @@ window.__ModuleLoader__.load({
344
393
  const en = {
345
394
  compaction: "Context compacted",
346
395
  "compaction.completed": "Compacted {items} messages (~{tokens} tokens)",
347
- "compaction.stats": "{items} msgs · {beforeChars} chars ({beforeTokens} tokens) → {afterChars} chars ({afterTokens} tokens)",
396
+ "compaction.stats": "chars {beforeChars} → {afterChars}",
397
+ "compaction.stats.sep": ", ",
398
+ "compaction.stats.effortDefault": "default",
348
399
  "compaction.expand": "Click to view summary",
349
400
  "compaction.unavailable": "Summary unavailable",
350
401
  "compaction.running": "Compressing context…",
@@ -355,6 +406,17 @@ window.__ModuleLoader__.load({
355
406
  "compaction.failed.reflect": "Context compaction failed (reflection)",
356
407
  "card.inspect": "Diagnostic log",
357
408
  "card.trajectory": "Trajectory",
409
+ "recompress.action": "Try another model",
410
+ "recompress.running": "Recompressing…",
411
+ "recompress.started": "Compression started; it will be added to “Subagents” when done",
412
+ "recompress.search": "Search models",
413
+ "recompress.loading": "Loading models…",
414
+ "recompress.empty": "No models available",
415
+ "recompress.loadFailed": "Failed to load models",
416
+ "recompress.retry": "Retry",
417
+ "recompress.effort.default": "Model default",
418
+ "recompress.done": "Recompression finished; the session record is in the log",
419
+ "recompress.failed": "Recompression failed: {error}",
358
420
  warning: "Context compaction degraded",
359
421
  "config.description": "Configure context compaction and original-text recall.",
360
422
  "config.loading": "Loading configuration…",
@@ -389,7 +451,15 @@ window.__ModuleLoader__.load({
389
451
  "config.modelDir": "Embedding model directory",
390
452
  "config.modelDir.hint": "Directory containing the local semantic-enhancement embedding model.",
391
453
  "config.omEnabled": "Automatic compaction",
392
- "config.omEnabled.hint": "Enable observation and reflection of summaries.",
454
+ "config.omEnabled.hint": "Enable observation and reflection of summaries. Turning it off also stops progress reminders.",
455
+ "config.progressReminderEnabled": "Progress reminder",
456
+ "config.progressReminderEnabled.hint": "Inject a progress reminder asking the model to keep writing notes. Requires automatic compaction.",
457
+ "config.progressReminderIdleEnabled": "Resend when silent",
458
+ "config.progressReminderIdleEnabled.hint": "Resend the reminder when the model only calls tools without notes; off resends only when it is missing.",
459
+ "config.progressReminderIdleSteps": "Resend step count",
460
+ "config.progressReminderIdleSteps.hint": "Resend once this many finished steps have passed without notes; at least 1.",
461
+ "config.progressReminderIdleToolCalls": "Resend tool-call count",
462
+ "config.progressReminderIdleToolCalls.hint": "Resend only when tool calls without notes exceed this value; at least 0.",
393
463
  "config.recallEnabled": "Original-text recall",
394
464
  "config.recallEnabled.hint": "Register the recall tool to review original messages by index.",
395
465
  "config.semanticRecallEnabled": "Semantic enhancement",
@@ -398,9 +468,9 @@ window.__ModuleLoader__.load({
398
468
  "config.debug.hint": "Log processing steps; the default follows NODE_ENV."
399
469
  };
400
470
  //#endregion
401
- //#region src/client/format.ts
471
+ //#region src/format.ts
402
472
  /**
403
- * 压缩卡片统计行的紧凑数字格式化。导出 formatCompactCount。
473
+ * 紧凑数字格式化(压缩卡片、重压缩记录与压缩日志共用)。零依赖,服务端与浏览器均可引用。导出 formatCompactCount / formatSeconds。
404
474
  * <1k 原样;≥1k 用 k;≥1w(万)用 w;≥1M 用 M;保留 1 位小数并去掉末尾 .0。
405
475
  */
406
476
  function formatCompactCount(value) {
@@ -413,6 +483,241 @@ window.__ModuleLoader__.load({
413
483
  if (value >= 1e3) return `${trim(value / 1e3)}k`;
414
484
  return String(value);
415
485
  }
486
+ /** 毫秒耗时格式化为一位小数的秒数,如 63.1s。 */
487
+ function formatSeconds(durationMs) {
488
+ return `${(durationMs / 1e3).toFixed(1)}s`;
489
+ }
490
+ //#endregion
491
+ //#region src/client/OmRecompressMenu.tsx
492
+ /**
493
+ * 换模型重压缩的模型选择菜单:触发按钮 + 浮层。
494
+ * 数据来自宿主会话共享的模型目录(与 /model 弹窗同一份:按供应商分组、模型的思考等级
495
+ * 元数据),搜索排序复用宿主 rankByName,浮层材质复用 MenuSurface / MenuGroup。
496
+ * 选中模型后若该模型带思考等级则进入等级列表(含「模型默认」),再提交;
497
+ * 选择只触发 onPick,不改变会话自身所选模型。
498
+ * 导出 OmRecompressMenu。
499
+ */
500
+ /** 超过该模型数才显示搜索框。 */
501
+ const SEARCH_MIN_MODELS = 5;
502
+ const css$1 = {
503
+ button: "om-recompress-button",
504
+ panel: "om-recompress-panel",
505
+ search: "om-recompress-search",
506
+ list: "om-recompress-list",
507
+ row: "om-recompress-row",
508
+ note: "om-recompress-note"
509
+ };
510
+ const menuCss = `
511
+ .${css$1.button}{border:.5px solid var(--dsw-alias-border-l4);background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-secondary);font:inherit;font-size:11px;line-height:16px;cursor:pointer;white-space:nowrap;border-radius:999px;flex:none;align-items:center;gap:4px;margin:0;padding:2px 8px;display:inline-flex}
512
+ .${css$1.button}:is(:hover,:focus-visible):not(:disabled){background:var(--dsw-alias-interactive-bg-hover-solid);color:var(--dsw-alias-label-primary)}
513
+ .${css$1.button}:disabled{cursor:default;opacity:.6}
514
+ .${css$1.panel}{position:fixed;z-index:1000;box-sizing:border-box;width:260px;max-height:320px;display:flex;flex-direction:column;overflow:hidden}
515
+ .${css$1.search}{box-sizing:border-box;width:100%;margin:0;padding:8px 12px;font:inherit;font-size:13px;color:inherit;background:none;border:none;border-bottom:1px solid var(--dsw-alias-label-caption);outline:none}
516
+ .${css$1.list}{min-height:0;overflow-y:auto;padding:4px}
517
+ .${css$1.row}{box-sizing:border-box;width:100%;display:block;text-align:left;font:inherit;font-size:13px;line-height:20px;color:inherit;background:none;border:none;border-radius:6px;padding:4px 8px;cursor:pointer}
518
+ .${css$1.row}:hover,.${css$1.row}:focus-visible{background:var(--dsw-alias-bg-hover,transparent);outline:none}
519
+ .${css$1.note}{padding:8px 12px;font-size:13px;color:var(--dsw-alias-label-tertiary)}
520
+ `;
521
+ /** 注册菜单样式(无 document 的环境如 node 测试直接跳过)。 */
522
+ if (typeof document !== "undefined" && document.querySelector("style[data-dsh-plugin-om-recompress]") === null) {
523
+ const tag = document.createElement("style");
524
+ tag.dataset.dshPluginOmRecompress = "true";
525
+ tag.textContent = menuCss;
526
+ document.head.appendChild(tag);
527
+ }
528
+ /** 触发按钮与模型选择浮层。 */
529
+ function OmRecompressMenu({ source, t, disabled, onPick }) {
530
+ const state = (0, react.useSyncExternalStore)((listener) => source.directory.subscribe(listener), () => source.directory.getSnapshot());
531
+ const [open, setOpen] = (0, react.useState)(false);
532
+ const [query, setQuery] = (0, react.useState)("");
533
+ const [picked, setPicked] = (0, react.useState)(null);
534
+ const [position, setPosition] = (0, react.useState)(null);
535
+ const triggerRef = (0, react.useRef)(null);
536
+ const panelRef = (0, react.useRef)(null);
537
+ const showSearch = state.groups.reduce((sum, group) => sum + group.models.length, 0) >= SEARCH_MIN_MODELS;
538
+ const groups = (0, react.useMemo)(() => {
539
+ const text = showSearch ? query.trim() : "";
540
+ return state.groups.map((group) => ({
541
+ ...group,
542
+ models: (0, _deepseek_ai_dsh_client_ui_primitives.rankByName)(group.models, text)
543
+ })).filter((group) => group.models.length > 0);
544
+ }, [
545
+ state.groups,
546
+ query,
547
+ showSearch
548
+ ]);
549
+ const close = (0, react.useCallback)(() => {
550
+ setOpen(false);
551
+ setPicked(null);
552
+ setQuery("");
553
+ }, []);
554
+ (0, react.useEffect)(() => {
555
+ if (!open) return;
556
+ const outside = (event) => {
557
+ const target = event.target;
558
+ if (triggerRef.current?.contains(target) === true) return;
559
+ if (panelRef.current?.contains(target) === true) return;
560
+ close();
561
+ };
562
+ const onKey = (event) => {
563
+ if (event.key === "Escape") close();
564
+ };
565
+ document.addEventListener("mousedown", outside);
566
+ document.addEventListener("keydown", onKey);
567
+ return () => {
568
+ document.removeEventListener("mousedown", outside);
569
+ document.removeEventListener("keydown", onKey);
570
+ };
571
+ }, [open, close]);
572
+ (0, react.useLayoutEffect)(() => {
573
+ if (!open) {
574
+ setPosition(null);
575
+ return;
576
+ }
577
+ const place = () => {
578
+ const rect = triggerRef.current?.getBoundingClientRect();
579
+ if (rect === void 0) return;
580
+ const margin = 12;
581
+ const width = panelRef.current?.offsetWidth ?? 260;
582
+ const height = panelRef.current?.offsetHeight ?? 0;
583
+ const left = Math.min(Math.max(rect.right - width, margin), window.innerWidth - width - margin);
584
+ const below = rect.bottom + 4;
585
+ const top = below + height <= window.innerHeight - margin ? below : Math.max(margin, rect.top - 4 - height);
586
+ setPosition({
587
+ left,
588
+ top
589
+ });
590
+ };
591
+ place();
592
+ window.addEventListener("scroll", place, true);
593
+ window.addEventListener("resize", place);
594
+ return () => {
595
+ window.removeEventListener("scroll", place, true);
596
+ window.removeEventListener("resize", place);
597
+ };
598
+ }, [
599
+ open,
600
+ state,
601
+ query,
602
+ picked
603
+ ]);
604
+ const choose = (provider, model) => {
605
+ if (model.reasoning === void 0 || model.reasoning.efforts.length === 0) {
606
+ close();
607
+ onPick({
608
+ provider,
609
+ model: model.id
610
+ });
611
+ return;
612
+ }
613
+ setPicked({
614
+ provider,
615
+ model
616
+ });
617
+ };
618
+ const finish = (effort) => {
619
+ if (picked === null) return;
620
+ const choice = {
621
+ provider: picked.provider,
622
+ model: picked.model.id,
623
+ ...effort === void 0 ? {} : { reasoningEffort: effort }
624
+ };
625
+ close();
626
+ onPick(choice);
627
+ };
628
+ let body;
629
+ if (picked !== null) body = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
630
+ className: css$1.list,
631
+ children: [
632
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
633
+ type: "button",
634
+ className: css$1.row,
635
+ "data-om-recompress-back": true,
636
+ onClick: () => setPicked(null),
637
+ children: ["← ", picked.model.name]
638
+ }),
639
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
640
+ type: "button",
641
+ className: css$1.row,
642
+ "data-om-recompress-effort": "",
643
+ onClick: () => finish(void 0),
644
+ children: t("recompress.effort.default")
645
+ }),
646
+ picked.model.reasoning?.efforts.map((effort) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
647
+ type: "button",
648
+ className: css$1.row,
649
+ "data-om-recompress-effort": effort.id,
650
+ onClick: () => finish(effort.id),
651
+ children: effort.name
652
+ }, effort.id))
653
+ ]
654
+ });
655
+ else if (state.status === "error" && state.groups.length === 0) body = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
656
+ className: css$1.note,
657
+ children: [
658
+ state.error ?? t("recompress.loadFailed"),
659
+ " ",
660
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
661
+ type: "button",
662
+ className: css$1.row,
663
+ "data-om-recompress-retry": true,
664
+ onClick: () => source.load(),
665
+ children: t("recompress.retry")
666
+ })
667
+ ]
668
+ });
669
+ else if (state.groups.length === 0) body = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
670
+ className: css$1.note,
671
+ children: state.status === "ready" ? t("recompress.empty") : t("recompress.loading")
672
+ });
673
+ else body = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [showSearch && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
674
+ className: css$1.search,
675
+ "data-om-recompress-search": true,
676
+ value: query,
677
+ placeholder: t("recompress.search"),
678
+ onChange: (event) => setQuery(event.target.value),
679
+ autoFocus: true
680
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
681
+ className: css$1.list,
682
+ children: groups.map((group) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.MenuGroup, {
683
+ label: group.name,
684
+ children: group.models.map((model) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
685
+ type: "button",
686
+ className: css$1.row,
687
+ "data-om-recompress-model": `${group.id}/${model.id}`,
688
+ onClick: () => choose(group.id, model),
689
+ children: model.name
690
+ }, model.id))
691
+ }, group.id))
692
+ })] });
693
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
694
+ ref: triggerRef,
695
+ type: "button",
696
+ className: css$1.button,
697
+ "data-om-recompress": true,
698
+ disabled,
699
+ onClick: (event) => {
700
+ event.stopPropagation();
701
+ if (open) {
702
+ close();
703
+ return;
704
+ }
705
+ source.load();
706
+ setOpen(true);
707
+ },
708
+ children: disabled ? t("recompress.running") : t("recompress.action")
709
+ }), open && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.MenuSurface, {
710
+ ref: panelRef,
711
+ className: css$1.panel,
712
+ role: "menu",
713
+ style: position ?? {
714
+ visibility: "hidden",
715
+ left: 0,
716
+ top: 0
717
+ },
718
+ children: body
719
+ }), document.body)] });
720
+ }
416
721
  //#endregion
417
722
  //#region src/client/OmCompactionCard.tsx
418
723
  /** 卡片样式类名(与宿主 ContextInjectionRow.module.css 同款规则,增加水平滚动支持)。 */
@@ -425,6 +730,7 @@ window.__ModuleLoader__.load({
425
730
  body: "om-compaction-body",
426
731
  actions: "om-compaction-actions",
427
732
  inspect: "om-compaction-inspect",
733
+ result: "om-compaction-recompress-result",
428
734
  trajectory: "om-compaction-trajectory"
429
735
  };
430
736
  /** 卡片样式规则:保留宿主外观,对折叠摘要与展开体增加水平滚动适配。 */
@@ -440,6 +746,7 @@ window.__ModuleLoader__.load({
440
746
  .${css.inspect}{border:.5px solid var(--dsw-alias-border-l4);background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-secondary);font:inherit;font-size:11px;line-height:16px;cursor:pointer;white-space:nowrap;border-radius:999px;flex:none;align-items:center;gap:4px;margin:0;padding:2px 8px;display:inline-flex}
441
747
  .${css.inspect}:is(:hover,:focus-visible){background:var(--dsw-alias-interactive-bg-hover-solid);color:var(--dsw-alias-label-primary)}
442
748
  .${css.trajectory}{display:none}
749
+ .${css.result}{padding:2px 0 0 22px;font-size:12px;line-height:20px;color:var(--dsw-alias-label-tertiary);max-height:60px;overflow-y:auto;overflow-wrap:anywhere;overscroll-behavior:contain;scrollbar-width:thin}
443
750
  .${css.body}{box-sizing:border-box;background:var(--dsw-alias-markdown-code-block);width:calc(100% - 22px);max-height:141px;color:var(--dsw-alias-label-tertiary);font:400 11px/16px var(--ds-font-family-code);border:none;border-radius:8px;margin:4px 0 0 22px;padding:10px 16px 12px 12px;overflow-x:auto;overflow-y:auto;overscroll-behavior-x:contain;-webkit-overflow-scrolling:touch;scrollbar-width:thin}
444
751
  `;
445
752
  /** 注册卡片样式(无 document 的环境如 node 测试直接跳过)。 */
@@ -450,8 +757,10 @@ window.__ModuleLoader__.load({
450
757
  document.head.appendChild(tag);
451
758
  }
452
759
  /** 折叠式压缩卡片(统计标题行 + 代码块样式 summary 展开)。 */
453
- const OmCompactionCard = (0, react.memo)(function OmCompactionCard({ node, t, sessionId, openSession, inspectCall }) {
760
+ const OmCompactionCard = (0, react.memo)(function OmCompactionCard({ node, t, sessionId, openSession, recompress, inspectCall }) {
454
761
  const [expanded, setExpanded] = (0, react.useState)(false);
762
+ const [recompressState, setRecompressState] = (0, react.useState)({ status: "idle" });
763
+ const [startedToast, setStartedToast] = (0, react.useState)(0);
455
764
  const { data } = node;
456
765
  const diagnosticSessionId = data.diagnosticSessionId;
457
766
  const inspect = diagnosticSessionId !== null && sessionId !== void 0 && openSession !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
@@ -468,6 +777,31 @@ window.__ModuleLoader__.load({
468
777
  },
469
778
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconInspectOutlineRegular, { size: 12 }), t("card.inspect")]
470
779
  }) : null;
780
+ const pickRecompress = (choice) => {
781
+ if (recompress === void 0) return;
782
+ setRecompressState({ status: "running" });
783
+ setStartedToast((seq) => seq + 1);
784
+ recompress.run(data.compactionId, choice).then((outcome) => {
785
+ setRecompressState(outcome.ok ? {
786
+ status: "done",
787
+ text: outcome.text || t("recompress.done")
788
+ } : {
789
+ status: "failed",
790
+ text: t("recompress.failed", { error: outcome.text })
791
+ });
792
+ });
793
+ };
794
+ const recompressButton = recompress === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OmRecompressMenu, {
795
+ source: recompress,
796
+ t,
797
+ disabled: recompressState.status === "running",
798
+ onPick: pickRecompress
799
+ });
800
+ const recompressResult = recompressState.status === "done" || recompressState.status === "failed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
801
+ className: css.result,
802
+ "data-om-recompress-result": true,
803
+ children: recompressState.text
804
+ }) : null;
471
805
  const trajectory = inspectCall === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
472
806
  type: "button",
473
807
  className: `${css.inspect} ${css.trajectory}`,
@@ -478,11 +812,17 @@ window.__ModuleLoader__.load({
478
812
  },
479
813
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconInspectOutlineRegular, { size: 12 }), t("card.trajectory")]
480
814
  });
481
- const actions = inspect === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
815
+ const actionBar = (extra) => inspect === null && extra === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
482
816
  className: css.actions,
483
817
  "data-om-compaction-actions": true,
484
- children: [trajectory, inspect]
818
+ children: [
819
+ trajectory,
820
+ inspect,
821
+ extra
822
+ ]
485
823
  });
824
+ const failureActions = actionBar(null);
825
+ const actions = actionBar(recompressButton);
486
826
  if (data.running) {
487
827
  const runningLabel = data.phase === "observe" ? t("compaction.running.observe") : data.phase === "reflect" ? t("compaction.running.reflect") : t("compaction.running");
488
828
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -525,50 +865,62 @@ window.__ModuleLoader__.load({
525
865
  className: css.body,
526
866
  style: styles$1.body,
527
867
  children: data.error
528
- }), actions]
868
+ }), failureActions]
529
869
  })
530
870
  });
531
871
  }
532
872
  const expandable = data.summary !== null || actions !== null;
533
873
  const open = expandable && expanded;
534
- const stats = data.shadowedItemCount !== null && data.shadowedCharCount !== null && data.shadowedTokenCount !== null && data.summaryCharCount !== null && data.summaryTokenCount !== null ? t("compaction.stats", {
535
- items: formatCompactCount(data.shadowedItemCount),
536
- beforeChars: formatCompactCount(data.shadowedCharCount),
537
- beforeTokens: formatCompactCount(data.shadowedTokenCount),
538
- afterChars: formatCompactCount(data.summaryCharCount),
539
- afterTokens: formatCompactCount(data.summaryTokenCount)
540
- }) : data.shadowedItemCount !== null && data.shadowedTokenCount !== null ? t("compaction.completed", {
874
+ const stats = data.shadowedCharCount !== null && data.summaryCharCount !== null ? [
875
+ t("compaction.stats", {
876
+ beforeChars: formatCompactCount(data.shadowedCharCount),
877
+ afterChars: formatCompactCount(data.summaryCharCount)
878
+ }),
879
+ ...data.durationMs === null ? [] : [formatSeconds(data.durationMs)],
880
+ ...data.model === null ? [] : [`${data.provider === null ? "" : `${data.provider}/`}${data.model}(${data.reasoningEffort ?? t("compaction.stats.effortDefault")})`]
881
+ ].join(t("compaction.stats.sep")) : data.shadowedItemCount !== null && data.shadowedTokenCount !== null ? t("compaction.completed", {
541
882
  items: formatCompactCount(data.shadowedItemCount),
542
883
  tokens: formatCompactCount(data.shadowedTokenCount)
543
884
  }) : data.summary !== null ? t("compaction.expand") : t("compaction.unavailable");
544
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
885
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
545
886
  style: styles$1.row,
546
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.DisclosureRow, {
547
- className: css.root,
548
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconBrowseOutlineRegular, { size: 14 }),
549
- chevronClassName: css.chevron,
550
- title: t("compaction"),
551
- collapsedContent: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
552
- className: css.sep,
553
- "aria-hidden": true
554
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
555
- className: `${css.summary} ${css.scrollable}`,
556
- "data-om-compaction-summary": true,
557
- children: stats
558
- })] }),
559
- keepContentWhenOpen: true,
560
- expandable,
561
- expandOnRowClick: true,
562
- open,
563
- onToggle: () => {
564
- setExpanded((value) => !value);
565
- },
566
- children: [data.summary !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
567
- className: css.body,
568
- style: styles$1.body,
569
- children: data.summary
570
- }), actions]
571
- })
887
+ children: [
888
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.DisclosureRow, {
889
+ className: css.root,
890
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconBrowseOutlineRegular, { size: 14 }),
891
+ chevronClassName: css.chevron,
892
+ title: t("compaction"),
893
+ collapsedContent: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
894
+ className: css.sep,
895
+ "aria-hidden": true
896
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
897
+ className: `${css.summary} ${css.scrollable}`,
898
+ "data-om-compaction-summary": true,
899
+ children: stats
900
+ })] }),
901
+ keepContentWhenOpen: true,
902
+ expandable,
903
+ expandOnRowClick: true,
904
+ open,
905
+ onToggle: () => {
906
+ setExpanded((value) => !value);
907
+ },
908
+ children: [data.summary !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
909
+ className: css.body,
910
+ style: styles$1.body,
911
+ children: data.summary
912
+ }), actions]
913
+ }),
914
+ recompressResult,
915
+ startedToast > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Toast, {
916
+ tone: "success",
917
+ text: t("recompress.started"),
918
+ holdMs: 4e3,
919
+ onDone: () => {
920
+ setStartedToast(0);
921
+ }
922
+ }, startedToast)
923
+ ]
572
924
  });
573
925
  });
574
926
  const styles$1 = {
@@ -626,6 +978,22 @@ window.__ModuleLoader__.load({
626
978
  name: "omEnabled",
627
979
  kind: "boolean"
628
980
  },
981
+ {
982
+ name: "progressReminderEnabled",
983
+ kind: "boolean"
984
+ },
985
+ {
986
+ name: "progressReminderIdleEnabled",
987
+ kind: "boolean"
988
+ },
989
+ {
990
+ name: "progressReminderIdleSteps",
991
+ kind: "integer"
992
+ },
993
+ {
994
+ name: "progressReminderIdleToolCalls",
995
+ kind: "integer"
996
+ },
629
997
  {
630
998
  name: "recallEnabled",
631
999
  kind: "boolean"
@@ -891,6 +1259,50 @@ window.__ModuleLoader__.load({
891
1259
  });
892
1260
  const bodyStyle = { whiteSpace: "pre-wrap" };
893
1261
  //#endregion
1262
+ //#region src/client/recompress-run.ts
1263
+ /** 拼出命令行:/om-recompress <compactionId> <provider> <model> [effort]。 */
1264
+ function recompressLine(compactionId, choice) {
1265
+ const effort = choice.reasoningEffort === void 0 ? "" : ` ${choice.reasoningEffort}`;
1266
+ return `/om-recompress ${compactionId} ${choice.provider} ${choice.model}${effort}`;
1267
+ }
1268
+ /** 经命令通道提交一次重压缩;远程拒绝或抛错都归一为失败结果。 */
1269
+ async function submitRecompress(execute, sessionId, compactionId, choice) {
1270
+ try {
1271
+ const result = await execute(sessionId, recompressLine(compactionId, choice));
1272
+ if (!result.ok) return {
1273
+ ok: false,
1274
+ text: result.error.message
1275
+ };
1276
+ const { kind, text } = result.value.result;
1277
+ return {
1278
+ ok: kind === "success",
1279
+ text: text ?? ""
1280
+ };
1281
+ } catch (error) {
1282
+ return {
1283
+ ok: false,
1284
+ text: error instanceof Error ? error.message : String(error)
1285
+ };
1286
+ }
1287
+ }
1288
+ //#endregion
1289
+ //#region src/client/recompress-inject.ts
1290
+ /** 构造某会话的重压缩能力:目录与 /model 弹窗共用,提交走 command.execute。 */
1291
+ function recompressFor(ctx, directories, sessionId) {
1292
+ const directory = directories.directoryFor(sessionId);
1293
+ return {
1294
+ directory: directory.store,
1295
+ load: () => {
1296
+ directory.load();
1297
+ },
1298
+ run: (compactionId, choice) => submitRecompress(async (id, line) => {
1299
+ const commands = ctx.get("remote.commands");
1300
+ if (commands === void 0) throw new Error("remote.commands unavailable");
1301
+ return commands.execute(id, line, []);
1302
+ }, sessionId, compactionId, choice)
1303
+ };
1304
+ }
1305
+ //#endregion
894
1306
  //#region src/client/index.ts
895
1307
  /** 必需服务:聊天节点槽、会话定义、双语 locale、宿主配置表单与会话跳转。 */
896
1308
  const inject = [
@@ -912,9 +1324,15 @@ window.__ModuleLoader__.load({
912
1324
  name: "conversation.chat.node",
913
1325
  key: "om-compaction",
914
1326
  locale: NS,
915
- inject: () => ({ openSession: (target) => {
916
- ctx.uiWorkspace.openSession(target);
917
- } })
1327
+ inject: (sessionId) => {
1328
+ const directories = ctx.get("modelDirectories");
1329
+ return {
1330
+ openSession: (target) => {
1331
+ ctx.uiWorkspace.openSession(target);
1332
+ },
1333
+ ...directories === void 0 ? {} : { recompress: recompressFor(ctx, directories, sessionId) }
1334
+ };
1335
+ }
918
1336
  }, OmCompactionCard));
919
1337
  ctx.slots.inject("conversation.chat.node", () => ctx.slots.register({
920
1338
  name: "conversation.chat.node",