dsh-plugin-om 0.0.43 → 0.0.44

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
@@ -267,7 +267,7 @@ window.__ModuleLoader__.load({
267
267
  //#endregion
268
268
  //#region src/client/locales.ts
269
269
  /**
270
- * `om-compaction` namespace 字典:插件压缩卡片的界面文案(zh/en)。
270
+ * `om-compaction` namespace 字典:压缩卡片、降级警告与插件行配置页的中英文文案。
271
271
  * 导出 NS / zh / en;zh 为键集事实源,en 键集与 zh 一致。
272
272
  */
273
273
  /** Dictionary namespace owned by this plugin. */
@@ -285,7 +285,48 @@ window.__ModuleLoader__.load({
285
285
  "compaction.failed": "上下文压缩失败",
286
286
  "compaction.failed.observe": "上下文压缩失败(观察)",
287
287
  "compaction.failed.reflect": "上下文压缩失败(反思)",
288
- warning: "上下文压缩功能降级"
288
+ warning: "上下文压缩功能降级",
289
+ "config.description": "配置上下文压缩与原文召回。",
290
+ "config.loading": "正在加载配置…",
291
+ "config.unavailable": "插件当前不可用,无法配置。",
292
+ "config.readOnly": "本部署的配置只读。",
293
+ "config.saveFailed": "保存失败,修改已保留,请检查配置或重试。",
294
+ "config.versionConflict": "配置已被其他页面修改,请重新加载后再保存。",
295
+ "config.save": "保存修改",
296
+ "config.discard": "撤销修改",
297
+ "config.saving": "保存中…",
298
+ "config.overridden": "已覆盖",
299
+ "config.inherited": "继承默认",
300
+ "config.reset": "恢复默认",
301
+ "config.invalidInteger": "请输入整数;留空使用默认值。",
302
+ "config.observeThresholdTokens": "观察阈值",
303
+ "config.observeThresholdTokens.hint": "上下文压力达到此 token 数时触发观察压缩。",
304
+ "config.reflectThresholdTokens": "摘要合并阈值",
305
+ "config.reflectThresholdTokens.hint": "摘要累计达到此 token 数时触发反思合并。",
306
+ "config.tailMessageCount": "保留消息数",
307
+ "config.tailMessageCount.hint": "触发观察后保留的完整消息条数。",
308
+ "config.compressMaxTokens": "单次生成上限",
309
+ "config.compressMaxTokens.hint": "压缩请求的最大生成 token 数;留空使用模型默认值。",
310
+ "config.compressProvider": "压缩 Provider",
311
+ "config.compressProvider.hint": "与压缩模型同时设置;留空使用会话路由。",
312
+ "config.compressModel": "压缩模型",
313
+ "config.compressModel.hint": "与压缩 Provider 同时设置;留空使用会话路由。",
314
+ "config.compressReasoningEffort": "思考等级",
315
+ "config.compressReasoningEffort.hint": "压缩请求的思考等级;留空使用模型默认值。",
316
+ "config.compressSkipReasoning": "忽略思考内容",
317
+ "config.compressSkipReasoning.hint": "压缩时不将历史 reasoning 纳入参考。",
318
+ "config.rateLimitWaitMs": "限流等待毫秒数",
319
+ "config.rateLimitWaitMs.hint": "429 限流后的冷却时间;0 表示不等待。",
320
+ "config.modelDir": "嵌入模型目录",
321
+ "config.modelDir.hint": "本地语义召回使用的嵌入模型目录。",
322
+ "config.omEnabled": "自动压缩",
323
+ "config.omEnabled.hint": "启用观察压缩和摘要反思合并。",
324
+ "config.recallEnabled": "原文召回",
325
+ "config.recallEnabled.hint": "注册按消息序号召回原文的工具。",
326
+ "config.semanticRecallEnabled": "语义召回",
327
+ "config.semanticRecallEnabled.hint": "注册本地语义检索工具。",
328
+ "config.debug": "步骤日志",
329
+ "config.debug.hint": "启用步骤级日志;缺省值由 NODE_ENV 决定。"
289
330
  };
290
331
  /** English dictionary(键集与 zh 一致)。 */
291
332
  const en = {
@@ -300,7 +341,48 @@ window.__ModuleLoader__.load({
300
341
  "compaction.failed": "Context compaction failed",
301
342
  "compaction.failed.observe": "Context compaction failed (observation)",
302
343
  "compaction.failed.reflect": "Context compaction failed (reflection)",
303
- warning: "Context compaction degraded"
344
+ warning: "Context compaction degraded",
345
+ "config.description": "Configure context compaction and original-text recall.",
346
+ "config.loading": "Loading configuration…",
347
+ "config.unavailable": "This plugin is unavailable and cannot be configured.",
348
+ "config.readOnly": "This deployment stores configuration read-only.",
349
+ "config.saveFailed": "Save failed. Your changes are retained; check the values or retry.",
350
+ "config.versionConflict": "Configuration changed elsewhere. Reload before saving again.",
351
+ "config.save": "Save changes",
352
+ "config.discard": "Discard changes",
353
+ "config.saving": "Saving…",
354
+ "config.overridden": "Overridden",
355
+ "config.inherited": "Inherited default",
356
+ "config.reset": "Reset to default",
357
+ "config.invalidInteger": "Enter an integer; leave blank to use the default.",
358
+ "config.observeThresholdTokens": "Observation threshold",
359
+ "config.observeThresholdTokens.hint": "Context pressure in tokens that triggers observation.",
360
+ "config.reflectThresholdTokens": "Reflection threshold",
361
+ "config.reflectThresholdTokens.hint": "Total summary tokens that trigger reflection.",
362
+ "config.tailMessageCount": "Retained message count",
363
+ "config.tailMessageCount.hint": "Full messages retained after observation is triggered.",
364
+ "config.compressMaxTokens": "Generation limit",
365
+ "config.compressMaxTokens.hint": "Maximum generated tokens per compression request; blank uses the model default.",
366
+ "config.compressProvider": "Compression provider",
367
+ "config.compressProvider.hint": "Set with the compression model; blank uses session routing.",
368
+ "config.compressModel": "Compression model",
369
+ "config.compressModel.hint": "Set with the compression provider; blank uses session routing.",
370
+ "config.compressReasoningEffort": "Reasoning effort",
371
+ "config.compressReasoningEffort.hint": "Reasoning effort for compression; blank uses the model default.",
372
+ "config.compressSkipReasoning": "Skip reasoning",
373
+ "config.compressSkipReasoning.hint": "Exclude historical reasoning from compression references.",
374
+ "config.rateLimitWaitMs": "Rate-limit wait in milliseconds",
375
+ "config.rateLimitWaitMs.hint": "Cooldown after a 429 response; zero skips the wait.",
376
+ "config.modelDir": "Embedding model directory",
377
+ "config.modelDir.hint": "Directory containing the local semantic-recall embedding model.",
378
+ "config.omEnabled": "Automatic compaction",
379
+ "config.omEnabled.hint": "Enable observation and reflection of summaries.",
380
+ "config.recallEnabled": "Original-text recall",
381
+ "config.recallEnabled.hint": "Register the message-index recall tool.",
382
+ "config.semanticRecallEnabled": "Semantic recall",
383
+ "config.semanticRecallEnabled.hint": "Register the local semantic-search tool.",
384
+ "config.debug": "Step logs",
385
+ "config.debug.hint": "Log processing steps; the default follows NODE_ENV."
304
386
  };
305
387
  //#endregion
306
388
  //#region src/client/format.ts
@@ -442,6 +524,210 @@ window.__ModuleLoader__.load({
442
524
  body: { whiteSpace: "pre-wrap" }
443
525
  };
444
526
  //#endregion
527
+ //#region src/client/om-config-controller.ts
528
+ /** 由宿主提供的插件条目配置命名空间。 */
529
+ const CONFIG_NS = "dsh-plugin-om";
530
+ /** 完整表单字段及控件类别。 */
531
+ const OM_CONFIG_FIELDS = [
532
+ {
533
+ name: "observeThresholdTokens",
534
+ kind: "integer"
535
+ },
536
+ {
537
+ name: "reflectThresholdTokens",
538
+ kind: "integer"
539
+ },
540
+ {
541
+ name: "tailMessageCount",
542
+ kind: "integer"
543
+ },
544
+ {
545
+ name: "compressMaxTokens",
546
+ kind: "integer"
547
+ },
548
+ {
549
+ name: "compressProvider",
550
+ kind: "text"
551
+ },
552
+ {
553
+ name: "compressModel",
554
+ kind: "text"
555
+ },
556
+ {
557
+ name: "compressReasoningEffort",
558
+ kind: "text"
559
+ },
560
+ {
561
+ name: "compressSkipReasoning",
562
+ kind: "boolean"
563
+ },
564
+ {
565
+ name: "rateLimitWaitMs",
566
+ kind: "integer"
567
+ },
568
+ {
569
+ name: "modelDir",
570
+ kind: "text"
571
+ },
572
+ {
573
+ name: "omEnabled",
574
+ kind: "boolean"
575
+ },
576
+ {
577
+ name: "recallEnabled",
578
+ kind: "boolean"
579
+ },
580
+ {
581
+ name: "semanticRecallEnabled",
582
+ kind: "boolean"
583
+ },
584
+ {
585
+ name: "debug",
586
+ kind: "boolean"
587
+ }
588
+ ];
589
+ /** 数字草稿只接受十进制整数,空白表示清除覆盖。 */
590
+ function integerField(field) {
591
+ return {
592
+ field,
593
+ format: (value) => typeof value === "number" ? String(value) : "",
594
+ parse: (text) => {
595
+ const trimmed = text.trim();
596
+ if (trimmed === "") return { kind: "clear" };
597
+ if (!/^[+-]?\d+$/.test(trimmed)) return void 0;
598
+ const value = Number(trimmed);
599
+ return Number.isInteger(value) ? {
600
+ kind: "set",
601
+ value
602
+ } : void 0;
603
+ }
604
+ };
605
+ }
606
+ /** 布尔草稿只允许 true 和 false,缺省值始终来自宿主快照。 */
607
+ function booleanField(field) {
608
+ return {
609
+ field,
610
+ format: (value) => typeof value === "boolean" ? String(value) : "",
611
+ parse: (text) => text === "true" || text === "false" ? {
612
+ kind: "set",
613
+ value: text === "true"
614
+ } : void 0
615
+ };
616
+ }
617
+ /** 将声明的控件类别映射为表单解析规格。 */
618
+ const specs = OM_CONFIG_FIELDS.map(({ name, kind }) => kind === "integer" ? integerField(name) : kind === "boolean" ? booleanField(name) : (0, _deepseek_ai_dsh_client_ui_primitives.settingsTextField)(name));
619
+ /** 在插件客户端生命周期内托管表单订阅。 */
620
+ var OmConfigController = class {
621
+ scope;
622
+ form;
623
+ store;
624
+ conflict = false;
625
+ constructor(scope) {
626
+ this.scope = scope;
627
+ const guarded = {
628
+ getSnapshot: () => scope.getSnapshot(),
629
+ subscribe: (listener) => scope.subscribe(listener),
630
+ mutate: async (ops, revision) => {
631
+ this.conflict = false;
632
+ const accepted = await scope.mutate(ops, revision);
633
+ this.conflict = !accepted && revision !== void 0 && scope.getSnapshot().revision !== revision;
634
+ return accepted;
635
+ }
636
+ };
637
+ this.form = new _deepseek_ai_dsh_client_ui_primitives.SettingsFormModel(guarded, specs);
638
+ this.store = this.form.bind(() => this.projection());
639
+ }
640
+ /** 从模型投影唯一一份字段及加载状态。 */
641
+ projection() {
642
+ return {
643
+ ...this.form.shell(),
644
+ status: this.scope.getSnapshot().status,
645
+ conflict: this.form.shell().failed && this.conflict,
646
+ fields: Object.fromEntries(OM_CONFIG_FIELDS.map(({ name }) => [name, this.form.field(name)]))
647
+ };
648
+ }
649
+ /** 供行槽注册器向 React 注入表单操作。 */
650
+ inject() {
651
+ return {
652
+ hooks: { omConfigCard: this.store },
653
+ ...this.form.actions()
654
+ };
655
+ }
656
+ /** 释放宿主快照订阅。 */
657
+ dispose() {
658
+ this.form.dispose();
659
+ }
660
+ };
661
+ //#endregion
662
+ //#region src/client/OmConfigCard.tsx
663
+ /** 配置行内容:说明、草稿值及继承/覆盖标记。 */
664
+ function OmConfigCard(props) {
665
+ const { t } = props;
666
+ const state = props.useOmConfigCard((snapshot) => snapshot);
667
+ if (props.view === "summary") return t("config.description");
668
+ if (state.status === "loading") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
669
+ role: "status",
670
+ children: t("config.loading")
671
+ });
672
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.SettingsForm, {
673
+ labels: {
674
+ unavailable: t("config.unavailable"),
675
+ readOnly: t("config.readOnly"),
676
+ saveFailed: state.conflict ? t("config.versionConflict") : t("config.saveFailed"),
677
+ save: t("config.save"),
678
+ saving: t("config.saving")
679
+ },
680
+ state: state.writable ? state : {
681
+ ...state,
682
+ dirty: false
683
+ },
684
+ onSave: props.save,
685
+ onDiscard: props.discard,
686
+ children: [state.dirty ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
687
+ type: "button",
688
+ disabled: !state.writable || state.saving,
689
+ onClick: props.discard,
690
+ children: t("config.discard")
691
+ }) : null, OM_CONFIG_FIELDS.map(({ name, kind }) => {
692
+ const field = state.fields[name];
693
+ const label = t(`config.${name}`);
694
+ const hint = t(`config.${name}.hint`);
695
+ const disabled = !state.writable || state.saving;
696
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
697
+ "data-om-field": name,
698
+ children: kind === "boolean" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
699
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
700
+ label,
701
+ checked: field.text === "true",
702
+ disabled,
703
+ onChange: (value) => props.edit(name, String(value))
704
+ }),
705
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: hint }),
706
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: field.overridden ? t("config.overridden") : t("config.inherited") }),
707
+ field.overridden ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
708
+ type: "button",
709
+ disabled,
710
+ onClick: () => props.resetField(name),
711
+ children: t("config.reset")
712
+ }) : null
713
+ ] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.SettingsValueField, {
714
+ id: `plugin-config-om-${name}`,
715
+ label,
716
+ hint,
717
+ overriddenLabel: t("config.overridden"),
718
+ resetLabel: t("config.reset"),
719
+ invalidLabel: t("config.invalidInteger"),
720
+ numeric: kind === "integer",
721
+ disabled,
722
+ ...field,
723
+ onEdit: (text) => props.edit(name, text),
724
+ onReset: () => props.resetField(name)
725
+ }), !field.overridden ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("config.inherited") }) : null] })
726
+ }, name);
727
+ })]
728
+ });
729
+ }
730
+ //#endregion
445
731
  //#region src/client/OmWarningCard.tsx
446
732
  /** 折叠式功能降级警告行(降级说明摘要行 + 完整说明展开)。 */
447
733
  const OmWarningCard = (0, react.memo)(function OmWarningCard({ node, t }) {
@@ -479,13 +765,14 @@ window.__ModuleLoader__.load({
479
765
  const bodyStyle = { whiteSpace: "pre-wrap" };
480
766
  //#endregion
481
767
  //#region src/client/index.ts
482
- /** Required services: 聊天节点槽、uiConversation 会话定义注册表与 locale 服务。 */
768
+ /** 必需服务:聊天节点槽、会话定义、双语 locale 与宿主配置表单。 */
483
769
  const inject = [
484
770
  "slots",
485
771
  "uiConversation",
486
- "locale"
772
+ "locale",
773
+ "configForms"
487
774
  ];
488
- /** Client plugin body: 注册压缩卡片的业务定义与 keyed 渲染器(随插件卸载移除)。 */
775
+ /** 挂载压缩卡片、警告行和可配置的插件行。 */
489
776
  function apply(ctx) {
490
777
  ctx.effect(() => ctx.locale.register(NS, {
491
778
  zh,
@@ -503,6 +790,14 @@ window.__ModuleLoader__.load({
503
790
  key: "om-warning",
504
791
  locale: NS
505
792
  }, OmWarningCard));
793
+ const card = new OmConfigController(ctx.configForms.get(CONFIG_NS));
794
+ ctx.effect(() => () => card.dispose(), "dsh-plugin-om: config form subscription");
795
+ ctx.effect(() => ctx.configForms.whileServed([CONFIG_NS], () => ctx.slots.inject("plugins.row.config", () => ctx.slots.register({
796
+ name: "plugins.row.config",
797
+ key: "dsh-plugin-om#dsh-plugin-om",
798
+ locale: NS,
799
+ inject: () => card.inject()
800
+ }, OmConfigCard))), "dsh-plugin-om: row configuration");
506
801
  }
507
802
  //#endregion
508
803
  exports.apply = apply;