dsh-plugin-om 0.0.63 → 0.0.64

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/client.js CHANGED
@@ -8,7 +8,6 @@ window.__ModuleLoader__.load({
8
8
  let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
9
9
  let react = require("react");
10
10
  let react_jsx_runtime = require("react/jsx-runtime");
11
- let react_dom = require("react-dom");
12
11
  //#region src/eval-session-text.ts
13
12
  /**
14
13
  * /om-compaction-eval 的文本契约:命令名与描述、新会话首条消息、成功文本及其反解。
@@ -492,21 +491,13 @@ window.__ModuleLoader__.load({
492
491
  "compaction.failed.reflect": "上下文压缩失败(反思)",
493
492
  "card.inspect": "诊断日志",
494
493
  "card.trajectory": "轨迹",
495
- "recompress.action": "尝试其他模型",
496
- "recompress.running": "重压缩中:{model}…",
497
- "recompress.started": "压缩开始,完成后会添加至“子智能体”",
498
- "recompress.search": "搜索模型",
499
- "recompress.loading": "正在加载模型…",
500
- "recompress.empty": "没有可用模型",
501
- "recompress.loadFailed": "模型列表加载失败",
502
- "recompress.retry": "重试",
503
- "recompress.effort.title": "思考等级",
504
- "recompress.effort.default": "模型默认",
505
- "recompress.start": "开始({count})",
506
- "recompress.done": "重压缩完成,会话记录已写入日志",
507
- "recompress.failed": "重压缩失败:{error}",
508
494
  "eval.search": "搜索模型",
495
+ "eval.loading": "正在加载模型…",
509
496
  "eval.empty": "没有可用模型",
497
+ "eval.loadFailed": "模型列表加载失败",
498
+ "eval.retry": "重试",
499
+ "eval.effort": "思考等级",
500
+ "eval.effortDefault": "模型默认",
510
501
  "eval.noResults": "没有匹配的模型",
511
502
  "eval.loadError": "加载失败:{message}",
512
503
  "eval.pickModel": "先在左侧选择模型",
@@ -541,8 +532,6 @@ window.__ModuleLoader__.load({
541
532
  "config.compressReasoningEffort.hint": "压缩请求的思考等级;留空使用模型默认值。",
542
533
  "config.compressSkipReasoning": "忽略思考内容",
543
534
  "config.compressSkipReasoning.hint": "压缩时不将历史 reasoning 纳入参考。",
544
- "config.recompressConcurrency": "重压缩并发数",
545
- "config.recompressConcurrency.hint": "换模型重压缩同时运行的上限,至少为 1;超出的排队等待。",
546
535
  "config.rateLimitWaitMs": "限流等待毫秒数",
547
536
  "config.rateLimitWaitMs.hint": "429 限流后的冷却时间;0 表示不等待。",
548
537
  "config.modelDir": "嵌入模型目录",
@@ -577,21 +566,13 @@ window.__ModuleLoader__.load({
577
566
  "compaction.failed.reflect": "Context compaction failed (reflection)",
578
567
  "card.inspect": "Diagnostic log",
579
568
  "card.trajectory": "Trajectory",
580
- "recompress.action": "Try another model",
581
- "recompress.running": "Recompressing: {model}…",
582
- "recompress.started": "Compression started; it will be added to “Subagents” when done",
583
- "recompress.search": "Search models",
584
- "recompress.loading": "Loading models…",
585
- "recompress.empty": "No models available",
586
- "recompress.loadFailed": "Failed to load models",
587
- "recompress.retry": "Retry",
588
- "recompress.effort.title": "Reasoning effort",
589
- "recompress.effort.default": "Model default",
590
- "recompress.start": "Start ({count})",
591
- "recompress.done": "Recompression finished; the session record is in the log",
592
- "recompress.failed": "Recompression failed: {error}",
593
569
  "eval.search": "Search models",
570
+ "eval.loading": "Loading models…",
594
571
  "eval.empty": "No models available",
572
+ "eval.loadFailed": "Failed to load models",
573
+ "eval.retry": "Retry",
574
+ "eval.effort": "Reasoning effort",
575
+ "eval.effortDefault": "Model default",
595
576
  "eval.noResults": "No matching models",
596
577
  "eval.loadError": "Failed to load: {message}",
597
578
  "eval.pickModel": "Pick a model on the left first",
@@ -626,8 +607,6 @@ window.__ModuleLoader__.load({
626
607
  "config.compressReasoningEffort.hint": "Reasoning effort for compression; blank uses the model default.",
627
608
  "config.compressSkipReasoning": "Skip reasoning",
628
609
  "config.compressSkipReasoning.hint": "Exclude historical reasoning from compression references.",
629
- "config.recompressConcurrency": "Recompression concurrency",
630
- "config.recompressConcurrency.hint": "Maximum concurrent model-switch recompressions, at least one; extra runs wait in a queue.",
631
610
  "config.rateLimitWaitMs": "Rate-limit wait in milliseconds",
632
611
  "config.rateLimitWaitMs.hint": "Cooldown after a 429 response; zero skips the wait.",
633
612
  "config.modelDir": "Embedding model directory",
@@ -653,7 +632,7 @@ window.__ModuleLoader__.load({
653
632
  * 提交失败的原因显示在面板内;点面板外或按 Esc 关闭。
654
633
  * 数据来自会话共享的模型目录(与 /model 同一份)。导出 OmEvalModelPanel。
655
634
  */
656
- const css$2 = {
635
+ const css$1 = {
657
636
  panel: "om-eval-panel",
658
637
  columns: "om-eval-columns",
659
638
  left: "om-eval-left",
@@ -669,22 +648,22 @@ window.__ModuleLoader__.load({
669
648
  error: "om-eval-error"
670
649
  };
671
650
  const panelCss = `
672
- .${css$2.panel}{position:fixed;z-index:1000;left:50%;top:50%;transform:translate(-50%,-50%);box-sizing:border-box;width:min(560px,calc(100vw - 24px));max-height:min(420px,calc(100vh - 24px));display:flex;flex-direction:column;overflow:hidden}
673
- .${css$2.columns}{min-height:0;flex:1;display:flex}
674
- .${css$2.left}{flex:1 1 60%;min-width:0;display:flex;flex-direction:column;border-right:1px solid var(--dsw-alias-label-caption)}
675
- .${css$2.right}{flex:1 1 40%;min-width:0;overflow-y:auto;padding:4px}
676
- .${css$2.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}
677
- .${css$2.list}{min-height:0;overflow-y:auto;padding:4px}
678
- .${css$2.row}{box-sizing:border-box;width:100%;display:flex;align-items:center;gap:6px;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}
679
- .${css$2.row}:hover,.${css$2.row}:focus-visible,.${css$2.row}[aria-checked=true]{background:var(--dsw-alias-interactive-bg-hover-solid);outline:none}
680
- .${css$2.row}:disabled{cursor:default;opacity:.55}
681
- .${css$2.mark}{flex:none;color:var(--dsw-alias-label-secondary)}
682
- .${css$2.section}{padding:6px 8px 2px;font-size:11px;color:var(--dsw-alias-label-tertiary)}
683
- .${css$2.footer}{flex:none;display:flex;padding:8px;border-top:1px solid var(--dsw-alias-label-caption)}
684
- .${css$2.start}{flex:1;box-sizing:border-box;font:inherit;font-size:13px;line-height:20px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover-solid);border:none;border-radius:6px;padding:4px 8px;cursor:pointer}
685
- .${css$2.start}:disabled{opacity:.45;cursor:default}
686
- .${css$2.note}{padding:8px 12px;font-size:13px;color:var(--dsw-alias-label-tertiary)}
687
- .${css$2.error}{flex:none;padding:6px 12px;font-size:12px;color:var(--dsw-alias-state-error-primary)}
651
+ .${css$1.panel}{position:fixed;z-index:1000;left:50%;top:50%;transform:translate(-50%,-50%);box-sizing:border-box;width:min(560px,calc(100vw - 24px));max-height:min(420px,calc(100vh - 24px));display:flex;flex-direction:column;overflow:hidden}
652
+ .${css$1.columns}{min-height:0;flex:1;display:flex}
653
+ .${css$1.left}{flex:1 1 60%;min-width:0;display:flex;flex-direction:column;border-right:1px solid var(--dsw-alias-label-caption)}
654
+ .${css$1.right}{flex:1 1 40%;min-width:0;overflow-y:auto;padding:4px}
655
+ .${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}
656
+ .${css$1.list}{min-height:0;overflow-y:auto;padding:4px}
657
+ .${css$1.row}{box-sizing:border-box;width:100%;display:flex;align-items:center;gap:6px;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}
658
+ .${css$1.row}:hover,.${css$1.row}:focus-visible,.${css$1.row}[aria-checked=true]{background:var(--dsw-alias-interactive-bg-hover-solid);outline:none}
659
+ .${css$1.row}:disabled{cursor:default;opacity:.55}
660
+ .${css$1.mark}{flex:none;color:var(--dsw-alias-label-secondary)}
661
+ .${css$1.section}{padding:6px 8px 2px;font-size:11px;color:var(--dsw-alias-label-tertiary)}
662
+ .${css$1.footer}{flex:none;display:flex;padding:8px;border-top:1px solid var(--dsw-alias-label-caption)}
663
+ .${css$1.start}{flex:1;box-sizing:border-box;font:inherit;font-size:13px;line-height:20px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover-solid);border:none;border-radius:6px;padding:4px 8px;cursor:pointer}
664
+ .${css$1.start}:disabled{opacity:.45;cursor:default}
665
+ .${css$1.note}{padding:8px 12px;font-size:13px;color:var(--dsw-alias-label-tertiary)}
666
+ .${css$1.error}{flex:none;padding:6px 12px;font-size:12px;color:var(--dsw-alias-state-error-primary)}
688
667
  `;
689
668
  /** 注册面板样式(无 document 的环境如 node 测试直接跳过)。 */
690
669
  if (typeof document !== "undefined" && document.querySelector("style[data-dsh-plugin-om-eval]") === null) {
@@ -755,48 +734,48 @@ window.__ModuleLoader__.load({
755
734
  }
756
735
  };
757
736
  const mark = (checked) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
758
- className: css$2.mark,
737
+ className: css$1.mark,
759
738
  "aria-hidden": "true",
760
739
  children: checked ? "◉" : "○"
761
740
  });
762
741
  let left;
763
742
  if (state.status === "error" && groups.length === 0) left = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
764
- className: css$2.note,
743
+ className: css$1.note,
765
744
  children: [
766
- state.error ?? t("recompress.loadFailed"),
745
+ state.error ?? t("eval.loadFailed"),
767
746
  " ",
768
747
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
769
748
  type: "button",
770
- className: css$2.row,
749
+ className: css$1.row,
771
750
  "data-om-eval-retry": true,
772
751
  onClick: () => load(),
773
- children: t("recompress.retry")
752
+ children: t("eval.retry")
774
753
  })
775
754
  ]
776
755
  });
777
756
  else if (groups.length === 0) left = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
778
- className: css$2.note,
779
- children: state.status === "ready" ? t("eval.empty") : t("recompress.loading")
757
+ className: css$1.note,
758
+ children: state.status === "ready" ? t("eval.empty") : t("eval.loading")
780
759
  });
781
760
  else left = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
782
- className: css$2.search,
761
+ className: css$1.search,
783
762
  "data-om-eval-search": true,
784
763
  value: query,
785
764
  placeholder: t("eval.search"),
786
765
  onChange: (event) => setQuery(event.target.value),
787
766
  autoFocus: true
788
767
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
789
- className: css$2.list,
768
+ className: css$1.list,
790
769
  children: [
791
770
  filtered.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
792
- className: css$2.note,
771
+ className: css$1.note,
793
772
  children: t("eval.noResults")
794
773
  }),
795
774
  filtered.map((group) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.MenuGroup, {
796
775
  label: group.name,
797
776
  children: group.models.map((model) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
798
777
  type: "button",
799
- className: css$2.row,
778
+ className: css$1.row,
800
779
  role: "menuitemradio",
801
780
  "aria-checked": picked?.provider === group.id && picked.model.id === model.id,
802
781
  "data-om-eval-model": `${group.id}/${model.id}`,
@@ -806,7 +785,7 @@ window.__ModuleLoader__.load({
806
785
  }, group.id)),
807
786
  state.failures.map((failure) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
808
787
  type: "button",
809
- className: css$2.row,
788
+ className: css$1.row,
810
789
  disabled: true,
811
790
  title: t("eval.loadError", { message: failure.message }),
812
791
  children: failure.name
@@ -816,30 +795,30 @@ window.__ModuleLoader__.load({
816
795
  const efforts = picked?.model.reasoning?.efforts ?? [];
817
796
  let right;
818
797
  if (picked === null) right = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
819
- className: css$2.note,
798
+ className: css$1.note,
820
799
  children: t("eval.pickModel")
821
800
  });
822
801
  else if (efforts.length === 0) right = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
823
- className: css$2.note,
802
+ className: css$1.note,
824
803
  children: t("eval.noEffort")
825
804
  });
826
805
  else right = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
827
806
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
828
- className: css$2.section,
829
- children: t("recompress.effort.title")
807
+ className: css$1.section,
808
+ children: t("eval.effort")
830
809
  }),
831
810
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
832
811
  type: "button",
833
- className: css$2.row,
812
+ className: css$1.row,
834
813
  role: "menuitemradio",
835
814
  "aria-checked": effort === void 0,
836
815
  "data-om-eval-effort": "",
837
816
  onClick: () => setEffort(void 0),
838
- children: [mark(effort === void 0), t("recompress.effort.default")]
817
+ children: [mark(effort === void 0), t("eval.effortDefault")]
839
818
  }),
840
819
  efforts.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
841
820
  type: "button",
842
- className: css$2.row,
821
+ className: css$1.row,
843
822
  role: "menuitemradio",
844
823
  "aria-checked": effort === item.id,
845
824
  "data-om-eval-effort": item.id,
@@ -849,29 +828,29 @@ window.__ModuleLoader__.load({
849
828
  ] });
850
829
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.MenuSurface, {
851
830
  ref: panelRef,
852
- className: css$2.panel,
831
+ className: css$1.panel,
853
832
  role: "menu",
854
833
  children: [
855
834
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
856
- className: css$2.columns,
835
+ className: css$1.columns,
857
836
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
858
- className: css$2.left,
837
+ className: css$1.left,
859
838
  children: left
860
839
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
861
- className: css$2.right,
840
+ className: css$1.right,
862
841
  children: right
863
842
  })]
864
843
  }),
865
844
  error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
866
- className: css$2.error,
845
+ className: css$1.error,
867
846
  "data-om-eval-error": true,
868
847
  children: error
869
848
  }),
870
849
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
871
- className: css$2.footer,
850
+ className: css$1.footer,
872
851
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
873
852
  type: "button",
874
- className: css$2.start,
853
+ className: css$1.start,
875
854
  "data-om-eval-start": true,
876
855
  disabled: picked === null || submitting,
877
856
  onClick: () => void submit(),
@@ -958,341 +937,6 @@ window.__ModuleLoader__.load({
958
937
  return `${(durationMs / 1e3).toFixed(1)}s`;
959
938
  }
960
939
  //#endregion
961
- //#region src/client/recompress-run.ts
962
- /** 所选模型的思考等级并集:按 id 去重并保持首次出现顺序。 */
963
- function effortUnion(selected) {
964
- const union = /* @__PURE__ */ new Map();
965
- for (const { model } of selected) for (const effort of model.reasoning?.efforts ?? []) if (!union.has(effort.id)) union.set(effort.id, {
966
- id: effort.id,
967
- name: effort.name
968
- });
969
- return [...union.values()];
970
- }
971
- /**
972
- * 把勾选展开为待运行的组合列表:带等级模型在勾默认时先出默认组合,再按模型等级顺序
973
- * 为每个被勾且被支持的等级出一组,不支持的跳过;无等级模型固定只出一个默认组合;
974
- * 顺序按模型选择顺序再按等级顺序。
975
- */
976
- function expandRecompressChoices(selected, picks) {
977
- const choices = [];
978
- for (const { provider, model } of selected) {
979
- const efforts = model.reasoning?.efforts ?? [];
980
- if (efforts.length === 0) {
981
- choices.push({
982
- provider,
983
- model: model.id
984
- });
985
- continue;
986
- }
987
- if (picks.useDefault) choices.push({
988
- provider,
989
- model: model.id
990
- });
991
- for (const effort of efforts) if (picks.effortIds.has(effort.id)) choices.push({
992
- provider,
993
- model: model.id,
994
- reasoningEffort: effort.id
995
- });
996
- }
997
- return choices;
998
- }
999
- /** 拼出命令行:/om-recompress <compactionId> <provider> <model> [effort]。 */
1000
- function recompressLine(compactionId, choice) {
1001
- const effort = choice.reasoningEffort === void 0 ? "" : ` ${choice.reasoningEffort}`;
1002
- return `/om-recompress ${compactionId} ${choice.provider} ${choice.model}${effort}`;
1003
- }
1004
- /** 经命令通道提交一次重压缩;远程拒绝或抛错都归一为失败结果。 */
1005
- async function submitRecompress(execute, sessionId, compactionId, choice) {
1006
- try {
1007
- const result = await execute(sessionId, recompressLine(compactionId, choice));
1008
- if (!result.ok) return {
1009
- ok: false,
1010
- text: result.error.message
1011
- };
1012
- const { kind, text } = result.value.result;
1013
- return {
1014
- ok: kind === "success",
1015
- text: text ?? ""
1016
- };
1017
- } catch (error) {
1018
- return {
1019
- ok: false,
1020
- text: error instanceof Error ? error.message : String(error)
1021
- };
1022
- }
1023
- }
1024
- //#endregion
1025
- //#region src/client/OmRecompressMenu.tsx
1026
- /**
1027
- * 换模型重压缩的模型选择菜单:触发按钮 + 浮层,支持多选批量提交。
1028
- * 数据来自宿主会话共享的模型目录(与 /model 弹窗同一份:按供应商分组、模型的思考等级
1029
- * 元数据),搜索排序复用宿主 rankByName,浮层材质复用 MenuSurface / MenuGroup。
1030
- * 模型为复选框多选;勾选后出现全局思考等级区(「模型默认」+ 所选模型等级并集);
1031
- * 底部「开始(N)」一次性展开为模型×等级组合并提交 onPick,N 为 0 时禁用;
1032
- * 点浮层外或 Esc 关闭不提交。选择只触发 onPick,不改变会话自身所选模型。
1033
- * 导出 OmRecompressMenu。
1034
- */
1035
- /** 超过该模型数才显示搜索框。 */
1036
- const SEARCH_MIN_MODELS = 5;
1037
- const css$1 = {
1038
- button: "om-recompress-button",
1039
- panel: "om-recompress-panel",
1040
- search: "om-recompress-search",
1041
- list: "om-recompress-list",
1042
- row: "om-recompress-row",
1043
- mark: "om-recompress-mark",
1044
- section: "om-recompress-section",
1045
- footer: "om-recompress-footer",
1046
- start: "om-recompress-start",
1047
- note: "om-recompress-note"
1048
- };
1049
- const menuCss = `
1050
- .${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}
1051
- .${css$1.button}:is(:hover,:focus-visible):not(:disabled){background:var(--dsw-alias-interactive-bg-hover-solid);color:var(--dsw-alias-label-primary)}
1052
- .${css$1.panel}{position:fixed;z-index:1000;box-sizing:border-box;width:260px;max-height:320px;display:flex;flex-direction:column;overflow:hidden}
1053
- .${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}
1054
- .${css$1.list}{min-height:0;overflow-y:auto;padding:4px}
1055
- .${css$1.row}{box-sizing:border-box;width:100%;display:flex;align-items:center;gap:6px;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}
1056
- .${css$1.row}:hover,.${css$1.row}:focus-visible{background:var(--dsw-alias-bg-hover,transparent);outline:none}
1057
- .${css$1.mark}{flex:none;color:var(--dsw-alias-label-secondary)}
1058
- .${css$1.section}{padding:6px 8px 2px;font-size:11px;color:var(--dsw-alias-label-tertiary)}
1059
- .${css$1.footer}{flex:none;display:flex;padding:8px;border-top:1px solid var(--dsw-alias-label-caption)}
1060
- .${css$1.start}{flex:1;box-sizing:border-box;font:inherit;font-size:13px;line-height:20px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover-solid);border:none;border-radius:6px;padding:4px 8px;cursor:pointer}
1061
- .${css$1.start}:disabled{opacity:.45;cursor:default}
1062
- .${css$1.note}{padding:8px 12px;font-size:13px;color:var(--dsw-alias-label-tertiary)}
1063
- `;
1064
- /** 注册菜单样式(无 document 的环境如 node 测试直接跳过)。 */
1065
- if (typeof document !== "undefined" && document.querySelector("style[data-dsh-plugin-om-recompress]") === null) {
1066
- const tag = document.createElement("style");
1067
- tag.dataset.dshPluginOmRecompress = "true";
1068
- tag.textContent = menuCss;
1069
- document.head.appendChild(tag);
1070
- }
1071
- /** 触发按钮与模型多选浮层。 */
1072
- function OmRecompressMenu({ source, t, onPick }) {
1073
- const state = (0, react.useSyncExternalStore)((listener) => source.directory.subscribe(listener), () => source.directory.getSnapshot());
1074
- const [open, setOpen] = (0, react.useState)(false);
1075
- const [query, setQuery] = (0, react.useState)("");
1076
- const [selected, setSelected] = (0, react.useState)([]);
1077
- const [useDefault, setUseDefault] = (0, react.useState)(true);
1078
- const [effortIds, setEffortIds] = (0, react.useState)(() => /* @__PURE__ */ new Set());
1079
- const [position, setPosition] = (0, react.useState)(null);
1080
- const triggerRef = (0, react.useRef)(null);
1081
- const panelRef = (0, react.useRef)(null);
1082
- const showSearch = state.groups.reduce((sum, group) => sum + group.models.length, 0) >= SEARCH_MIN_MODELS;
1083
- const groups = (0, react.useMemo)(() => {
1084
- const text = showSearch ? query.trim() : "";
1085
- return state.groups.map((group) => ({
1086
- ...group,
1087
- models: (0, _deepseek_ai_dsh_client_ui_primitives.rankByName)(group.models, text)
1088
- })).filter((group) => group.models.length > 0);
1089
- }, [
1090
- state.groups,
1091
- query,
1092
- showSearch
1093
- ]);
1094
- const efforts = (0, react.useMemo)(() => effortUnion(selected), [selected]);
1095
- const picks = (0, react.useMemo)(() => ({
1096
- useDefault,
1097
- effortIds
1098
- }), [useDefault, effortIds]);
1099
- const choices = (0, react.useMemo)(() => expandRecompressChoices(selected, picks), [selected, picks]);
1100
- const close = (0, react.useCallback)(() => {
1101
- setOpen(false);
1102
- setQuery("");
1103
- setSelected([]);
1104
- setUseDefault(true);
1105
- setEffortIds(/* @__PURE__ */ new Set());
1106
- }, []);
1107
- (0, react.useEffect)(() => {
1108
- if (!open) return;
1109
- const outside = (event) => {
1110
- const target = event.target;
1111
- if (triggerRef.current?.contains(target) === true) return;
1112
- if (panelRef.current?.contains(target) === true) return;
1113
- close();
1114
- };
1115
- const onKey = (event) => {
1116
- if (event.key === "Escape") close();
1117
- };
1118
- document.addEventListener("mousedown", outside);
1119
- document.addEventListener("keydown", onKey);
1120
- return () => {
1121
- document.removeEventListener("mousedown", outside);
1122
- document.removeEventListener("keydown", onKey);
1123
- };
1124
- }, [open, close]);
1125
- (0, react.useLayoutEffect)(() => {
1126
- if (!open) {
1127
- setPosition(null);
1128
- return;
1129
- }
1130
- const place = () => {
1131
- const rect = triggerRef.current?.getBoundingClientRect();
1132
- if (rect === void 0) return;
1133
- const margin = 12;
1134
- const width = panelRef.current?.offsetWidth ?? 260;
1135
- const height = panelRef.current?.offsetHeight ?? 0;
1136
- const left = Math.min(Math.max(rect.right - width, margin), window.innerWidth - width - margin);
1137
- const below = rect.bottom + 4;
1138
- const top = below + height <= window.innerHeight - margin ? below : Math.max(margin, rect.top - 4 - height);
1139
- setPosition({
1140
- left,
1141
- top
1142
- });
1143
- };
1144
- place();
1145
- window.addEventListener("scroll", place, true);
1146
- window.addEventListener("resize", place);
1147
- return () => {
1148
- window.removeEventListener("scroll", place, true);
1149
- window.removeEventListener("resize", place);
1150
- };
1151
- }, [
1152
- open,
1153
- state,
1154
- query,
1155
- selected,
1156
- useDefault,
1157
- effortIds
1158
- ]);
1159
- const isSelected = (provider, model) => selected.some((entry) => entry.provider === provider && entry.model.id === model.id);
1160
- const toggleModel = (provider, model) => {
1161
- setSelected((prev) => prev.some((entry) => entry.provider === provider && entry.model.id === model.id) ? prev.filter((entry) => !(entry.provider === provider && entry.model.id === model.id)) : [...prev, {
1162
- provider,
1163
- model
1164
- }]);
1165
- };
1166
- const toggleEffort = (id) => {
1167
- setEffortIds((prev) => {
1168
- const next = new Set(prev);
1169
- if (next.has(id)) next.delete(id);
1170
- else next.add(id);
1171
- return next;
1172
- });
1173
- };
1174
- const submit = () => {
1175
- const batch = choices;
1176
- close();
1177
- onPick(batch);
1178
- };
1179
- const mark = (checked) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1180
- className: css$1.mark,
1181
- "aria-hidden": "true",
1182
- children: checked ? "☑" : "☐"
1183
- });
1184
- let body;
1185
- if (state.status === "error" && state.groups.length === 0) body = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1186
- className: css$1.note,
1187
- children: [
1188
- state.error ?? t("recompress.loadFailed"),
1189
- " ",
1190
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1191
- type: "button",
1192
- className: css$1.row,
1193
- "data-om-recompress-retry": true,
1194
- onClick: () => source.load(),
1195
- children: t("recompress.retry")
1196
- })
1197
- ]
1198
- });
1199
- else if (state.groups.length === 0) body = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1200
- className: css$1.note,
1201
- children: state.status === "ready" ? t("recompress.empty") : t("recompress.loading")
1202
- });
1203
- else body = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1204
- showSearch && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1205
- className: css$1.search,
1206
- "data-om-recompress-search": true,
1207
- value: query,
1208
- placeholder: t("recompress.search"),
1209
- onChange: (event) => setQuery(event.target.value),
1210
- autoFocus: true
1211
- }),
1212
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1213
- className: css$1.list,
1214
- children: [groups.map((group) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.MenuGroup, {
1215
- label: group.name,
1216
- children: group.models.map((model) => {
1217
- const checked = isSelected(group.id, model);
1218
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1219
- type: "button",
1220
- className: css$1.row,
1221
- role: "menuitemcheckbox",
1222
- "aria-checked": checked,
1223
- "data-om-recompress-model": `${group.id}/${model.id}`,
1224
- onClick: () => toggleModel(group.id, model),
1225
- children: [mark(checked), model.name]
1226
- }, model.id);
1227
- })
1228
- }, group.id)), efforts.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1229
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1230
- className: css$1.section,
1231
- children: t("recompress.effort.title")
1232
- }),
1233
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1234
- type: "button",
1235
- className: css$1.row,
1236
- role: "menuitemcheckbox",
1237
- "aria-checked": useDefault,
1238
- "data-om-recompress-effort": "",
1239
- onClick: () => setUseDefault((prev) => !prev),
1240
- children: [mark(useDefault), t("recompress.effort.default")]
1241
- }),
1242
- efforts.map((effort) => {
1243
- const checked = effortIds.has(effort.id);
1244
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1245
- type: "button",
1246
- className: css$1.row,
1247
- role: "menuitemcheckbox",
1248
- "aria-checked": checked,
1249
- "data-om-recompress-effort": effort.id,
1250
- onClick: () => toggleEffort(effort.id),
1251
- children: [mark(checked), effort.name]
1252
- }, effort.id);
1253
- })
1254
- ] })]
1255
- }),
1256
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1257
- className: css$1.footer,
1258
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1259
- type: "button",
1260
- className: css$1.start,
1261
- "data-om-recompress-start": true,
1262
- disabled: choices.length === 0,
1263
- onClick: submit,
1264
- children: t("recompress.start", { count: choices.length })
1265
- })
1266
- })
1267
- ] });
1268
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1269
- ref: triggerRef,
1270
- type: "button",
1271
- className: css$1.button,
1272
- "data-om-recompress": true,
1273
- onClick: (event) => {
1274
- event.stopPropagation();
1275
- if (open) {
1276
- close();
1277
- return;
1278
- }
1279
- source.load();
1280
- setOpen(true);
1281
- },
1282
- children: t("recompress.action")
1283
- }), open && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.MenuSurface, {
1284
- ref: panelRef,
1285
- className: css$1.panel,
1286
- role: "menu",
1287
- style: position ?? {
1288
- visibility: "hidden",
1289
- left: 0,
1290
- top: 0
1291
- },
1292
- children: body
1293
- }), document.body)] });
1294
- }
1295
- //#endregion
1296
940
  //#region src/client/OmCompactionCard.tsx
1297
941
  /** 卡片样式类名(与宿主 ContextInjectionRow.module.css 同款规则,增加水平滚动支持)。 */
1298
942
  const css = {
@@ -1304,7 +948,6 @@ window.__ModuleLoader__.load({
1304
948
  body: "om-compaction-body",
1305
949
  actions: "om-compaction-actions",
1306
950
  inspect: "om-compaction-inspect",
1307
- result: "om-compaction-recompress-result",
1308
951
  trajectory: "om-compaction-trajectory"
1309
952
  };
1310
953
  /** 卡片样式规则:保留宿主外观,对折叠摘要与展开体增加水平滚动适配。 */
@@ -1320,7 +963,6 @@ window.__ModuleLoader__.load({
1320
963
  .${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}
1321
964
  .${css.inspect}:is(:hover,:focus-visible){background:var(--dsw-alias-interactive-bg-hover-solid);color:var(--dsw-alias-label-primary)}
1322
965
  .${css.trajectory}{display:none}
1323
- .${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}
1324
966
  .${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}
1325
967
  `;
1326
968
  /** 注册卡片样式(无 document 的环境如 node 测试直接跳过)。 */
@@ -1331,11 +973,8 @@ window.__ModuleLoader__.load({
1331
973
  document.head.appendChild(tag);
1332
974
  }
1333
975
  /** 折叠式压缩卡片(统计标题行 + 代码块样式 summary 展开)。 */
1334
- const OmCompactionCard = (0, react.memo)(function OmCompactionCard({ node, t, sessionId, openSession, recompress, inspectCall }) {
976
+ const OmCompactionCard = (0, react.memo)(function OmCompactionCard({ node, t, sessionId, openSession, inspectCall }) {
1335
977
  const [expanded, setExpanded] = (0, react.useState)(false);
1336
- const [recompressEntries, setRecompressEntries] = (0, react.useState)([]);
1337
- const nextEntryId = (0, react.useRef)(0);
1338
- const [startedToast, setStartedToast] = (0, react.useState)(0);
1339
978
  const { data } = node;
1340
979
  const diagnosticSessionId = data.diagnosticSessionId;
1341
980
  const inspect = diagnosticSessionId !== null && sessionId !== void 0 && openSession !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
@@ -1352,42 +991,6 @@ window.__ModuleLoader__.load({
1352
991
  },
1353
992
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconInspectOutlineRegular, { size: 12 }), t("card.inspect")]
1354
993
  }) : null;
1355
- const pickRecompress = (choices) => {
1356
- if (recompress === void 0) return;
1357
- const batch = choices.map((choice) => ({
1358
- id: nextEntryId.current++,
1359
- choice,
1360
- model: `${choice.provider}/${choice.model}(${choice.reasoningEffort ?? t("compaction.stats.effortDefault")})`
1361
- }));
1362
- setRecompressEntries((entries) => [...entries.filter((entry) => entry.status === "running"), ...batch.map(({ id, model }) => ({
1363
- id,
1364
- status: "running",
1365
- model
1366
- }))]);
1367
- setStartedToast((seq) => seq + 1);
1368
- for (const { id, choice } of batch) recompress.run(data.compactionId, choice).then((outcome) => {
1369
- const text = outcome.ok ? outcome.text || t("recompress.done") : t("recompress.failed", { error: outcome.text });
1370
- setRecompressEntries((entries) => entries.map((entry) => entry.id === id ? {
1371
- id,
1372
- status: outcome.ok ? "done" : "failed",
1373
- text
1374
- } : entry));
1375
- });
1376
- };
1377
- const recompressButton = recompress === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OmRecompressMenu, {
1378
- source: recompress,
1379
- t,
1380
- onPick: pickRecompress
1381
- });
1382
- const recompressResult = recompressEntries.map((entry) => entry.status === "running" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1383
- className: css.result,
1384
- "data-om-recompress-running": true,
1385
- children: t("recompress.running", { model: entry.model })
1386
- }, entry.id) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1387
- className: css.result,
1388
- "data-om-recompress-result": true,
1389
- children: entry.text
1390
- }, entry.id));
1391
994
  const trajectory = inspectCall === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1392
995
  type: "button",
1393
996
  className: `${css.inspect} ${css.trajectory}`,
@@ -1398,17 +1001,11 @@ window.__ModuleLoader__.load({
1398
1001
  },
1399
1002
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconInspectOutlineRegular, { size: 12 }), t("card.trajectory")]
1400
1003
  });
1401
- const actionBar = (extra) => inspect === null && extra === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1004
+ const actions = inspect === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1402
1005
  className: css.actions,
1403
1006
  "data-om-compaction-actions": true,
1404
- children: [
1405
- trajectory,
1406
- inspect,
1407
- extra
1408
- ]
1007
+ children: [trajectory, inspect]
1409
1008
  });
1410
- const failureActions = actionBar(null);
1411
- const actions = actionBar(recompressButton);
1412
1009
  if (data.running) {
1413
1010
  const runningLabel = data.phase === "observe" ? t("compaction.running.observe") : data.phase === "reflect" ? t("compaction.running.reflect") : t("compaction.running");
1414
1011
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -1451,7 +1048,7 @@ window.__ModuleLoader__.load({
1451
1048
  className: css.body,
1452
1049
  style: styles$1.body,
1453
1050
  children: data.error
1454
- }), failureActions]
1051
+ }), actions]
1455
1052
  })
1456
1053
  });
1457
1054
  }
@@ -1468,45 +1065,34 @@ window.__ModuleLoader__.load({
1468
1065
  items: formatCompactCount(data.shadowedItemCount),
1469
1066
  tokens: formatCompactCount(data.shadowedTokenCount)
1470
1067
  }) : data.summary !== null ? t("compaction.expand") : t("compaction.unavailable");
1471
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1068
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1472
1069
  style: styles$1.row,
1473
- children: [
1474
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.DisclosureRow, {
1475
- className: css.root,
1476
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconBrowseOutlineRegular, { size: 14 }),
1477
- chevronClassName: css.chevron,
1478
- title: t("compaction"),
1479
- collapsedContent: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1480
- className: css.sep,
1481
- "aria-hidden": true
1482
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1483
- className: `${css.summary} ${css.scrollable}`,
1484
- "data-om-compaction-summary": true,
1485
- children: stats
1486
- })] }),
1487
- keepContentWhenOpen: true,
1488
- expandable,
1489
- expandOnRowClick: true,
1490
- open,
1491
- onToggle: () => {
1492
- setExpanded((value) => !value);
1493
- },
1494
- children: [data.summary !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1495
- className: css.body,
1496
- style: styles$1.body,
1497
- children: data.summary
1498
- }), actions]
1499
- }),
1500
- recompressResult,
1501
- startedToast > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Toast, {
1502
- tone: "success",
1503
- text: t("recompress.started"),
1504
- holdMs: 4e3,
1505
- onDone: () => {
1506
- setStartedToast(0);
1507
- }
1508
- }, startedToast)
1509
- ]
1070
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.DisclosureRow, {
1071
+ className: css.root,
1072
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconBrowseOutlineRegular, { size: 14 }),
1073
+ chevronClassName: css.chevron,
1074
+ title: t("compaction"),
1075
+ collapsedContent: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1076
+ className: css.sep,
1077
+ "aria-hidden": true
1078
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1079
+ className: `${css.summary} ${css.scrollable}`,
1080
+ "data-om-compaction-summary": true,
1081
+ children: stats
1082
+ })] }),
1083
+ keepContentWhenOpen: true,
1084
+ expandable,
1085
+ expandOnRowClick: true,
1086
+ open,
1087
+ onToggle: () => {
1088
+ setExpanded((value) => !value);
1089
+ },
1090
+ children: [data.summary !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1091
+ className: css.body,
1092
+ style: styles$1.body,
1093
+ children: data.summary
1094
+ }), actions]
1095
+ })
1510
1096
  });
1511
1097
  });
1512
1098
  const styles$1 = {
@@ -1566,10 +1152,6 @@ window.__ModuleLoader__.load({
1566
1152
  name: "rateLimitWaitMs",
1567
1153
  kind: "integer"
1568
1154
  },
1569
- {
1570
- name: "recompressConcurrency",
1571
- kind: "integer"
1572
- },
1573
1155
  {
1574
1156
  name: "progressReminderEnabled",
1575
1157
  kind: "boolean"
@@ -1849,23 +1431,6 @@ window.__ModuleLoader__.load({
1849
1431
  });
1850
1432
  const bodyStyle = { whiteSpace: "pre-wrap" };
1851
1433
  //#endregion
1852
- //#region src/client/recompress-inject.ts
1853
- /** 构造某会话的重压缩能力:目录与 /model 弹窗共用,提交走 command.execute。 */
1854
- function recompressFor(ctx, directories, sessionId) {
1855
- const directory = directories.directoryFor(sessionId);
1856
- return {
1857
- directory: directory.store,
1858
- load: () => {
1859
- directory.load();
1860
- },
1861
- run: (compactionId, choice) => submitRecompress(async (id, line) => {
1862
- const commands = ctx.get("remote.commands");
1863
- if (commands === void 0) throw new Error("remote.commands unavailable");
1864
- return commands.execute(id, line, []);
1865
- }, sessionId, compactionId, choice)
1866
- };
1867
- }
1868
- //#endregion
1869
1434
  //#region src/client/index.ts
1870
1435
  /** 必需服务:聊天节点槽、会话定义、双语 locale、宿主配置表单与会话跳转。 */
1871
1436
  const inject = [
@@ -1903,15 +1468,9 @@ window.__ModuleLoader__.load({
1903
1468
  name: "conversation.chat.node",
1904
1469
  key: "om-compaction",
1905
1470
  locale: NS,
1906
- inject: (sessionId) => {
1907
- const directories = ctx.get("modelDirectories");
1908
- return {
1909
- openSession: (target) => {
1910
- ctx.uiWorkspace.openSession(target);
1911
- },
1912
- ...directories === void 0 ? {} : { recompress: recompressFor(ctx, directories, sessionId) }
1913
- };
1914
- }
1471
+ inject: () => ({ openSession: (target) => {
1472
+ ctx.uiWorkspace.openSession(target);
1473
+ } })
1915
1474
  }, OmCompactionCard));
1916
1475
  ctx.slots.inject("conversation.chat.node", () => ctx.slots.register({
1917
1476
  name: "conversation.chat.node",