@kangyishuai/dsh-advisor 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -25
- package/README.zh-CN.md +49 -27
- package/lib/client.js +1355 -448
- package/lib/service.js +23 -1
- package/lib/settings.js +46 -11
- package/lib/trace.js +31 -0
- package/locale/en.json +101 -34
- package/locale/zh.json +107 -40
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -161,6 +161,14 @@ window.__ModuleLoader__.load({
|
|
|
161
161
|
"tail.anchors": "证据锚点未对上({checked} 条)",
|
|
162
162
|
"tail.downgraded": "严重度已降级",
|
|
163
163
|
"tail.aria": "顾问建议(点击展开或收起)",
|
|
164
|
+
"tail.trace.label": "本次徵询",
|
|
165
|
+
"tail.trace.sep": ":",
|
|
166
|
+
"tail.trace.chars": "{chars} 字符",
|
|
167
|
+
"tail.trigger.tool": "模型发起",
|
|
168
|
+
"tail.trigger.shadow": "影子",
|
|
169
|
+
"tail.trigger.manual": "手动",
|
|
170
|
+
"tail.trigger.postAnswer": "答后复查",
|
|
171
|
+
"tail.trigger.other": "其他",
|
|
164
172
|
};
|
|
165
173
|
|
|
166
174
|
/** 英文字典(键集必须与 zh 完全一致,locale/*.json 同步)。 */
|
|
@@ -295,6 +303,14 @@ window.__ModuleLoader__.load({
|
|
|
295
303
|
"tail.anchors": "Evidence anchors did not match ({checked} checked)",
|
|
296
304
|
"tail.downgraded": "Severity downgraded",
|
|
297
305
|
"tail.aria": "Advisor advice (click to expand or collapse)",
|
|
306
|
+
"tail.trace.label": "Consultation",
|
|
307
|
+
"tail.trace.sep": ": ",
|
|
308
|
+
"tail.trace.chars": "{chars} chars",
|
|
309
|
+
"tail.trigger.tool": "model",
|
|
310
|
+
"tail.trigger.shadow": "shadow",
|
|
311
|
+
"tail.trigger.manual": "manual",
|
|
312
|
+
"tail.trigger.postAnswer": "post-answer",
|
|
313
|
+
"tail.trigger.other": "other",
|
|
298
314
|
};
|
|
299
315
|
|
|
300
316
|
/** 提示条样式:只用宿主 CSS 变量,深浅色自动跟随;同时充当「client 半已加载」的标记。 */
|
|
@@ -306,16 +322,43 @@ window.__ModuleLoader__.load({
|
|
|
306
322
|
".dsh-advisor-head{display:flex;flex-direction:column;gap:2px;}",
|
|
307
323
|
".dsh-advisor-title{font-size:14px;font-weight:600;}",
|
|
308
324
|
".dsh-advisor-desc{font-size:12px;color:var(--dsw-alias-label-secondary,GrayText);}",
|
|
309
|
-
".dsh-advisor-group{display:flex;flex-direction:column;gap:8px;
|
|
325
|
+
".dsh-advisor-group{display:flex;flex-direction:column;gap:8px;}",
|
|
326
|
+
".dsh-advisor-group + .dsh-advisor-group{margin-top:2px;padding-top:10px;border-top:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.28));}",
|
|
310
327
|
".dsh-advisor-group-title{font-size:12px;font-weight:600;letter-spacing:.04em;color:var(--dsw-alias-label-secondary,GrayText);}",
|
|
328
|
+
".dsh-advisor-subgroup{display:flex;flex-direction:column;gap:6px;}",
|
|
329
|
+
".dsh-advisor-subgroup-title{font-size:11.5px;font-weight:600;color:var(--dsw-alias-label-secondary,GrayText);}",
|
|
311
330
|
".dsh-advisor-row{display:flex;flex-wrap:wrap;align-items:center;gap:6px 10px;}",
|
|
312
331
|
".dsh-advisor-row--stack{flex-direction:column;align-items:flex-start;gap:4px;}",
|
|
332
|
+
".dsh-advisor-field{display:flex;flex-direction:column;gap:2px;}",
|
|
333
|
+
".dsh-advisor-label-wrap{display:flex;align-items:center;gap:6px;flex:0 0 auto;}",
|
|
313
334
|
".dsh-advisor-label{flex:0 0 auto;min-width:120px;color:var(--dsw-alias-label-primary,CanvasText);}",
|
|
335
|
+
".dsh-advisor-help-btn{flex:0 0 auto;width:16px;height:16px;padding:0;border-radius:50%;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.45));background:transparent;color:var(--dsw-alias-label-secondary,GrayText);font-size:11px;line-height:14px;text-align:center;cursor:pointer;}",
|
|
336
|
+
".dsh-advisor-help-btn:hover{background:var(--dsw-alias-bg-layer-2,rgba(128,128,128,.12));color:var(--dsw-alias-label-primary,CanvasText);}",
|
|
337
|
+
".dsh-advisor-help-btn:focus-visible{outline:2px solid var(--dsw-alias-label-primary,CanvasText);outline-offset:1px;}",
|
|
338
|
+
".dsh-advisor-help-body{padding:6px 10px;border-left:2px solid var(--dsw-alias-border-l2,rgba(128,128,128,.35));font-size:11.5px;line-height:1.55;color:var(--dsw-alias-label-secondary,GrayText);}",
|
|
339
|
+
".dsh-advisor-help-body p{margin:0;}",
|
|
340
|
+
".dsh-advisor-help-body .dsh-advisor-help-meta{margin-top:2px;color:var(--dsw-alias-label-secondary,GrayText);}",
|
|
341
|
+
".dsh-advisor-help-body .dsh-advisor-help-tech{margin-top:2px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10.5px;opacity:.85;}",
|
|
314
342
|
".dsh-advisor-controls{display:flex;flex:1 1 220px;flex-wrap:wrap;gap:6px;min-width:0;}",
|
|
315
343
|
".dsh-advisor-input,.dsh-advisor-select{flex:1 1 140px;min-width:0;padding:4px 8px;border-radius:6px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.4));background:var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-base,Canvas));color:inherit;font:inherit;}",
|
|
316
344
|
".dsh-advisor-input[type=number]{flex:0 0 120px;}",
|
|
317
345
|
".dsh-advisor-input[type=checkbox]{flex:0 0 auto;width:16px;height:16px;}",
|
|
318
346
|
".dsh-advisor-hint{flex:1 1 100%;font-size:11.5px;color:var(--dsw-alias-label-secondary,GrayText);word-break:break-word;}",
|
|
347
|
+
".dsh-advisor-unit{flex:0 0 auto;font-size:11.5px;color:var(--dsw-alias-label-secondary,GrayText);white-space:nowrap;}",
|
|
348
|
+
".dsh-advisor-off{display:flex;flex-direction:column;gap:4px;padding:8px 10px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.28));border-radius:8px;background:var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-base,Canvas));}",
|
|
349
|
+
".dsh-advisor-off-title{font-weight:600;}",
|
|
350
|
+
".dsh-advisor-dirty{font-size:12px;color:var(--dsw-alias-state-warning-primary,#b7791f);}",
|
|
351
|
+
".dsh-advisor-disclosure{display:flex;flex-direction:column;gap:4px;}",
|
|
352
|
+
".dsh-advisor-disclosure-toggle{display:flex;align-items:center;gap:6px;width:100%;padding:4px 0;border:0;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer;}",
|
|
353
|
+
".dsh-advisor-disclosure-toggle:hover{color:var(--dsw-alias-label-primary,CanvasText);}",
|
|
354
|
+
".dsh-advisor-caret{flex:0 0 auto;width:12px;font-size:11px;color:var(--dsw-alias-label-secondary,GrayText);}",
|
|
355
|
+
".dsh-advisor-disclosure-title{font-size:12px;font-weight:600;letter-spacing:.04em;color:var(--dsw-alias-label-secondary,GrayText);}",
|
|
356
|
+
".dsh-advisor-badge{flex:0 0 auto;padding:0 6px;border-radius:999px;background:var(--dsw-alias-bg-layer-2,rgba(128,128,128,.14));color:var(--dsw-alias-label-secondary,GrayText);font-size:10.5px;line-height:16px;font-weight:400;}",
|
|
357
|
+
".dsh-advisor-disclosure-body{display:flex;flex-direction:column;gap:10px;padding:4px 0 2px 16px;border-left:2px solid var(--dsw-alias-border-l2,rgba(128,128,128,.22));}",
|
|
358
|
+
".dsh-advisor-paths{display:flex;flex-direction:column;gap:2px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10.5px;color:var(--dsw-alias-label-secondary,GrayText);word-break:break-all;}",
|
|
359
|
+
".dsh-advisor-more{display:flex;flex-direction:column;gap:4px;font-size:11.5px;color:var(--dsw-alias-label-secondary,GrayText);}",
|
|
360
|
+
".dsh-advisor-more p{margin:0;}",
|
|
361
|
+
".dsh-advisor-path{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10.5px;word-break:break-all;}",
|
|
319
362
|
".dsh-advisor-choices{display:flex;flex:1 1 100%;flex-direction:column;gap:6px;}",
|
|
320
363
|
".dsh-advisor-choice{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 8px;cursor:pointer;}",
|
|
321
364
|
".dsh-advisor-choice-label{font-weight:500;}",
|
|
@@ -341,9 +384,13 @@ window.__ModuleLoader__.load({
|
|
|
341
384
|
".dsh-advisor-turn-head:hover{background:var(--dsw-alias-bg-layer-2,rgba(128,128,128,.12));}",
|
|
342
385
|
".dsh-advisor-turn-sev{flex:0 0 auto;font-weight:600;color:var(--dsw-alias-label-primary,CanvasText);}",
|
|
343
386
|
".dsh-advisor-turn-sum{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}",
|
|
387
|
+
".dsh-advisor-turn-time{flex:0 0 auto;font-size:11px;color:var(--dsw-alias-label-secondary,GrayText);opacity:.75;}",
|
|
344
388
|
".dsh-advisor-turn-body{display:flex;flex-direction:column;gap:3px;padding:4px 8px;border-left:2px solid var(--dsw-alias-border-l2,rgba(128,128,128,.35));}",
|
|
345
389
|
".dsh-advisor-turn-advice{white-space:pre-wrap;word-break:break-word;color:var(--dsw-alias-label-primary,CanvasText);}",
|
|
346
390
|
".dsh-advisor-turn-meta{font-size:11.5px;color:var(--dsw-alias-label-secondary,GrayText);word-break:break-word;}",
|
|
391
|
+
".dsh-advisor-turn-preview{display:flex;flex-direction:column;gap:4px;}",
|
|
392
|
+
".dsh-advisor-turn-preview-row{display:flex;flex-wrap:wrap;align-items:center;gap:6px 10px;}",
|
|
393
|
+
".dsh-advisor-turn-pre{margin:0;padding:8px 10px;max-height:260px;overflow:auto;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.28));border-radius:6px;background:var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-base,Canvas));font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;line-height:1.5;white-space:pre-wrap;word-break:break-word;}",
|
|
347
394
|
".dsh-advisor-turn-warn{font-size:11.5px;color:var(--dsw-alias-state-warning-primary,#b7791f);word-break:break-word;}",
|
|
348
395
|
].join("\n");
|
|
349
396
|
|
|
@@ -545,22 +592,34 @@ window.__ModuleLoader__.load({
|
|
|
545
592
|
// 真正的校验仍在宿主(不复制宿主写入逻辑)。
|
|
546
593
|
// ------------------------------------------------------------------
|
|
547
594
|
|
|
548
|
-
/** @type {Record<string,
|
|
595
|
+
/** 与 host 的 DEFAULT_SETTINGS 对齐;数值字段缺失时用它回落。 @type {Record<string, any>} */
|
|
549
596
|
let SETTINGS_DEFAULTS = {
|
|
597
|
+
mode: "off",
|
|
598
|
+
provider: "",
|
|
599
|
+
model: "",
|
|
600
|
+
reasoningEffort: "",
|
|
550
601
|
maxTokens: 4096,
|
|
602
|
+
temperature: null,
|
|
551
603
|
maxCallsPerTurn: 1,
|
|
552
604
|
maxCallsPerSession: 32,
|
|
553
605
|
maxCallsPerHour: 12,
|
|
554
606
|
maxCostPerDayUsd: 0,
|
|
555
607
|
priceInputPerMTok: 0,
|
|
556
608
|
priceOutputPerMTok: 0,
|
|
609
|
+
privacyScope: "summary",
|
|
610
|
+
redact: true,
|
|
611
|
+
dedupe: true,
|
|
612
|
+
sessionCap: 24,
|
|
613
|
+
allowedModels: [],
|
|
557
614
|
workspaceMaxCallsPerDay: 200,
|
|
558
615
|
workspaceMaxCostPerDayUsd: 0,
|
|
559
|
-
|
|
616
|
+
postAnswer: "off",
|
|
617
|
+
advisorTools: false,
|
|
618
|
+
tracePrompt: "preview",
|
|
560
619
|
maxInputChars: 60000,
|
|
561
620
|
};
|
|
562
621
|
|
|
563
|
-
/** 与 settings.js 的
|
|
622
|
+
/** 与 settings.js 的 INT_LIMITS / MONEY_LIMITS 逐项一致;越界在前端先夹一次。 @type {Record<string, number[]>} */
|
|
564
623
|
let SETTINGS_LIMITS = {
|
|
565
624
|
maxTokens: [256, 32000],
|
|
566
625
|
maxCallsPerTurn: [0, 8],
|
|
@@ -575,8 +634,38 @@ window.__ModuleLoader__.load({
|
|
|
575
634
|
maxInputChars: [4000, 400000],
|
|
576
635
|
};
|
|
577
636
|
|
|
637
|
+
/** 金额字段的小数位;与 settings.js 的 MONEY_LIMITS 一致。 @type {Record<string, number>} */
|
|
638
|
+
let SETTINGS_MONEY_FIELDS = {
|
|
639
|
+
maxCostPerDayUsd: 2,
|
|
640
|
+
workspaceMaxCostPerDayUsd: 2,
|
|
641
|
+
priceInputPerMTok: 4,
|
|
642
|
+
priceOutputPerMTok: 4,
|
|
643
|
+
};
|
|
644
|
+
|
|
578
645
|
/** 所有整数输入字段(temperature 单独处理:可为空、可小数)。 */
|
|
579
|
-
let SETTINGS_INT_FIELDS = Object.keys(SETTINGS_LIMITS)
|
|
646
|
+
let SETTINGS_INT_FIELDS = Object.keys(SETTINGS_LIMITS).filter(function isIntField(key) {
|
|
647
|
+
return Object.hasOwn(SETTINGS_MONEY_FIELDS, key) === false;
|
|
648
|
+
});
|
|
649
|
+
|
|
650
|
+
/** 高级区字段:用于「N 项已修改」徽标与「恢复默认」。 */
|
|
651
|
+
let SETTINGS_ADVANCED_FIELDS = [
|
|
652
|
+
"maxCallsPerTurn",
|
|
653
|
+
"maxCallsPerSession",
|
|
654
|
+
"maxCallsPerHour",
|
|
655
|
+
"workspaceMaxCallsPerDay",
|
|
656
|
+
"workspaceMaxCostPerDayUsd",
|
|
657
|
+
"priceInputPerMTok",
|
|
658
|
+
"priceOutputPerMTok",
|
|
659
|
+
"maxTokens",
|
|
660
|
+
"temperature",
|
|
661
|
+
"maxInputChars",
|
|
662
|
+
"sessionCap",
|
|
663
|
+
"allowedModels",
|
|
664
|
+
"postAnswer",
|
|
665
|
+
"advisorTools",
|
|
666
|
+
"tracePrompt",
|
|
667
|
+
"dedupe",
|
|
668
|
+
];
|
|
580
669
|
|
|
581
670
|
/** 0 表示「不限」的预算字段;只影响提示文案。 */
|
|
582
671
|
let SETTINGS_UNLIMITED_FIELDS = [
|
|
@@ -595,6 +684,9 @@ window.__ModuleLoader__.load({
|
|
|
595
684
|
/** 回合结束后的自动徵询方式,与 settings.js 一致。 */
|
|
596
685
|
let SETTINGS_POST_ANSWER = ["off", "card"];
|
|
597
686
|
|
|
687
|
+
/** 「记录发送内容」的取值,与 settings.js 一致。 */
|
|
688
|
+
let SETTINGS_TRACE_PROMPT = ["preview", "off"];
|
|
689
|
+
|
|
598
690
|
/** 卡片读写的字段:保存时只 diff 这些键,绝不把整个设置对象发回去。 */
|
|
599
691
|
let SETTINGS_EDITABLE_FIELDS = [
|
|
600
692
|
"mode",
|
|
@@ -618,11 +710,12 @@ window.__ModuleLoader__.load({
|
|
|
618
710
|
"maxInputChars",
|
|
619
711
|
"postAnswer",
|
|
620
712
|
"advisorTools",
|
|
713
|
+
"tracePrompt",
|
|
621
714
|
"allowedModels",
|
|
622
715
|
];
|
|
623
716
|
|
|
624
717
|
/**
|
|
625
|
-
* 整数夹紧:与 settings.js 的
|
|
718
|
+
* 整数夹紧:与 settings.js 的 clampInt 同语义(取整、非有限值回落)。
|
|
626
719
|
* @param {any} value
|
|
627
720
|
* @param {number} fallback
|
|
628
721
|
* @param {number} min
|
|
@@ -635,6 +728,23 @@ window.__ModuleLoader__.load({
|
|
|
635
728
|
return Math.min(max, Math.max(min, Math.round(n)));
|
|
636
729
|
}
|
|
637
730
|
|
|
731
|
+
/**
|
|
732
|
+
* 金额夹紧:与 settings.js 的 clampMoney 同语义(按固定小数位收口)。
|
|
733
|
+
* @param {any} value
|
|
734
|
+
* @param {number} fallback
|
|
735
|
+
* @param {number} min
|
|
736
|
+
* @param {number} max
|
|
737
|
+
* @param {number} digits
|
|
738
|
+
* @returns {number}
|
|
739
|
+
*/
|
|
740
|
+
function clampMoney(value, fallback, min, max, digits) {
|
|
741
|
+
let n = typeof value === "number" ? value : Number(value);
|
|
742
|
+
if (!Number.isFinite(n)) return fallback;
|
|
743
|
+
let bounded = Math.min(max, Math.max(min, n));
|
|
744
|
+
let factor = 10 ** digits;
|
|
745
|
+
return Math.round(bounded * factor) / factor;
|
|
746
|
+
}
|
|
747
|
+
|
|
638
748
|
/**
|
|
639
749
|
* 可空小数夹紧(temperature):空 / 非数字 → null。
|
|
640
750
|
* @param {any} value
|
|
@@ -650,6 +760,20 @@ window.__ModuleLoader__.load({
|
|
|
650
760
|
return Math.min(max, Math.max(min, n));
|
|
651
761
|
}
|
|
652
762
|
|
|
763
|
+
/**
|
|
764
|
+
* 金额输入框的规范文本:去掉多余的尾零,0 显示成 "0"。
|
|
765
|
+
* @param {any} value
|
|
766
|
+
* @param {number} digits
|
|
767
|
+
* @returns {string}
|
|
768
|
+
*/
|
|
769
|
+
function formatMoneyInput(value, digits) {
|
|
770
|
+
let n = Number(value);
|
|
771
|
+
if (!Number.isFinite(n)) return "0";
|
|
772
|
+
let text = n.toFixed(digits);
|
|
773
|
+
if (text.indexOf(".") >= 0) text = text.replace(/0+$/, "").replace(/\.$/, "");
|
|
774
|
+
return text === "" || text === "-0" ? "0" : text;
|
|
775
|
+
}
|
|
776
|
+
|
|
653
777
|
/**
|
|
654
778
|
* 规整字符串数组(allowedModels / confirmedHosts):去空、去重、截断条数。
|
|
655
779
|
* 与 settings.js 的 normalizeStringList 同语义,前端只用它来显示。
|
|
@@ -689,6 +813,7 @@ window.__ModuleLoader__.load({
|
|
|
689
813
|
temperature: null,
|
|
690
814
|
postAnswer: input.postAnswer === "card" ? "card" : "off",
|
|
691
815
|
advisorTools: input.advisorTools === true,
|
|
816
|
+
tracePrompt: input.tracePrompt === "off" ? "off" : "preview",
|
|
692
817
|
allowedModels: normalizeStringList(input.allowedModels),
|
|
693
818
|
confirmedHosts: normalizeStringList(input.confirmedHosts),
|
|
694
819
|
};
|
|
@@ -701,6 +826,15 @@ window.__ModuleLoader__.load({
|
|
|
701
826
|
SETTINGS_LIMITS[key][1],
|
|
702
827
|
);
|
|
703
828
|
}
|
|
829
|
+
for (let key of Object.keys(SETTINGS_MONEY_FIELDS)) {
|
|
830
|
+
out[key] = clampMoney(
|
|
831
|
+
input[key],
|
|
832
|
+
SETTINGS_DEFAULTS[key],
|
|
833
|
+
SETTINGS_LIMITS[key][0],
|
|
834
|
+
SETTINGS_LIMITS[key][1],
|
|
835
|
+
SETTINGS_MONEY_FIELDS[key],
|
|
836
|
+
);
|
|
837
|
+
}
|
|
704
838
|
out.temperature =
|
|
705
839
|
input.temperature === null || input.temperature === undefined || input.temperature === ""
|
|
706
840
|
? null
|
|
@@ -804,6 +938,7 @@ window.__ModuleLoader__.load({
|
|
|
804
938
|
: null,
|
|
805
939
|
lastSkip: asString(raw.lastSkip).trim(),
|
|
806
940
|
ledgerPath: asString(raw.ledgerPath).trim(),
|
|
941
|
+
settingsPath: asString(raw.settingsPath).trim(),
|
|
807
942
|
};
|
|
808
943
|
}
|
|
809
944
|
|
|
@@ -1043,6 +1178,11 @@ window.__ModuleLoader__.load({
|
|
|
1043
1178
|
summary: asString(item.summary),
|
|
1044
1179
|
model: asString(item.model).trim(),
|
|
1045
1180
|
usage: asString(item.usage).trim(),
|
|
1181
|
+
at: countOf(item.at),
|
|
1182
|
+
trigger: asString(item.trigger).trim(),
|
|
1183
|
+
requestChars: countOf(item.requestChars),
|
|
1184
|
+
requestPreview: asString(item.requestPreview),
|
|
1185
|
+
requestPreviewTruncated: item.requestPreviewTruncated === true,
|
|
1046
1186
|
anchors:
|
|
1047
1187
|
anchorsRaw === null
|
|
1048
1188
|
? null
|
|
@@ -1074,6 +1214,60 @@ window.__ModuleLoader__.load({
|
|
|
1074
1214
|
return String(Math.round(n)).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
1075
1215
|
}
|
|
1076
1216
|
|
|
1217
|
+
/** 触发方式白名单;未知值归到 other。 */
|
|
1218
|
+
let ADVICE_TRIGGERS = ["tool", "shadow", "manual", "post-answer"];
|
|
1219
|
+
|
|
1220
|
+
/**
|
|
1221
|
+
* 触发方式的本地化标签。
|
|
1222
|
+
* @param {(key: string) => string} t
|
|
1223
|
+
* @param {string} trigger
|
|
1224
|
+
* @returns {string}
|
|
1225
|
+
*/
|
|
1226
|
+
function triggerLabel(t, trigger) {
|
|
1227
|
+
let key =
|
|
1228
|
+
trigger === "post-answer"
|
|
1229
|
+
? "postAnswer"
|
|
1230
|
+
: ADVICE_TRIGGERS.indexOf(trigger) >= 0
|
|
1231
|
+
? trigger
|
|
1232
|
+
: "other";
|
|
1233
|
+
return t(`tail.trigger.${key}`);
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
/**
|
|
1237
|
+
* 本地时间 HH:mm;无效/缺失返回空串。
|
|
1238
|
+
* @param {any} epochMs
|
|
1239
|
+
* @returns {string}
|
|
1240
|
+
*/
|
|
1241
|
+
function formatClock(epochMs) {
|
|
1242
|
+
let n = Number(epochMs);
|
|
1243
|
+
if (!Number.isFinite(n) || n <= 0) return "";
|
|
1244
|
+
let date = new Date(n);
|
|
1245
|
+
let hours = String(date.getHours()).padStart(2, "0");
|
|
1246
|
+
let minutes = String(date.getMinutes()).padStart(2, "0");
|
|
1247
|
+
return `${hours}:${minutes}`;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
/**
|
|
1251
|
+
* 顾问线展开后的「本次徵询」摘要:触发方式 · 时间 · 模型 · 字符数 · 用量/成本。
|
|
1252
|
+
* @param {any} record
|
|
1253
|
+
* @param {(key: string) => string} t
|
|
1254
|
+
* @returns {string}
|
|
1255
|
+
*/
|
|
1256
|
+
function traceTextOf(record, t) {
|
|
1257
|
+
let parts = [];
|
|
1258
|
+
let trigger = asString(record.trigger).trim();
|
|
1259
|
+
if (trigger !== "") parts.push(triggerLabel(t, trigger));
|
|
1260
|
+
let clock = formatClock(record.at);
|
|
1261
|
+
if (clock !== "") parts.push(clock);
|
|
1262
|
+
let model = asString(record.model).trim();
|
|
1263
|
+
if (model !== "") parts.push(model);
|
|
1264
|
+
let chars = countOf(record.requestChars);
|
|
1265
|
+
if (chars > 0) parts.push(t("tail.trace.chars").replace("{chars}", formatCount(chars)));
|
|
1266
|
+
let usage = asString(record.usage).trim();
|
|
1267
|
+
if (usage !== "") parts.push(usage);
|
|
1268
|
+
return parts.join(" · ");
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1077
1271
|
/**
|
|
1078
1272
|
* 极简 store:组件用 useSyncExternalStore 订阅,写入方直接 set。
|
|
1079
1273
|
* @param {any} initial
|
|
@@ -1200,6 +1394,9 @@ window.__ModuleLoader__.load({
|
|
|
1200
1394
|
let expandedState = React.useState(false);
|
|
1201
1395
|
let expanded = expandedState[0];
|
|
1202
1396
|
let setExpanded = expandedState[1];
|
|
1397
|
+
let previewState = React.useState(false);
|
|
1398
|
+
let previewOpen = previewState[0];
|
|
1399
|
+
let setPreviewOpen = previewState[1];
|
|
1203
1400
|
|
|
1204
1401
|
// 一次拉全量并按 sessionId 缓存;props.turn 变化不重拉。失败静默(不 toast、不弹错)。
|
|
1205
1402
|
React.useEffect(
|
|
@@ -1286,6 +1483,7 @@ window.__ModuleLoader__.load({
|
|
|
1286
1483
|
60,
|
|
1287
1484
|
);
|
|
1288
1485
|
let severityLabel = t(`tail.severity.${severity}`);
|
|
1486
|
+
let clock = formatClock(record.at);
|
|
1289
1487
|
|
|
1290
1488
|
/** @type {any[]} */
|
|
1291
1489
|
let headChildren = [];
|
|
@@ -1307,6 +1505,19 @@ window.__ModuleLoader__.load({
|
|
|
1307
1505
|
);
|
|
1308
1506
|
}
|
|
1309
1507
|
}
|
|
1508
|
+
if (clock !== "") {
|
|
1509
|
+
headChildren.push(
|
|
1510
|
+
h(
|
|
1511
|
+
"span",
|
|
1512
|
+
{
|
|
1513
|
+
className: "dsh-advisor-turn-time",
|
|
1514
|
+
key: "time",
|
|
1515
|
+
title: new Date(record.at).toLocaleString(),
|
|
1516
|
+
},
|
|
1517
|
+
clock,
|
|
1518
|
+
),
|
|
1519
|
+
);
|
|
1520
|
+
}
|
|
1310
1521
|
|
|
1311
1522
|
/** @type {any[]} */
|
|
1312
1523
|
let bodyChildren = [
|
|
@@ -1316,11 +1527,60 @@ window.__ModuleLoader__.load({
|
|
|
1316
1527
|
asString(record.advice) === "" ? t("tail.empty") : record.advice,
|
|
1317
1528
|
),
|
|
1318
1529
|
];
|
|
1319
|
-
let
|
|
1320
|
-
|
|
1321
|
-
.
|
|
1322
|
-
|
|
1323
|
-
|
|
1530
|
+
let traceText = traceTextOf(record, t);
|
|
1531
|
+
if (traceText !== "") {
|
|
1532
|
+
bodyChildren.push(
|
|
1533
|
+
h(
|
|
1534
|
+
"div",
|
|
1535
|
+
{ className: "dsh-advisor-turn-meta", "data-advisor-trace": "", key: "trace" },
|
|
1536
|
+
`${t("tail.trace.label")}${t("tail.trace.sep")}${traceText}`,
|
|
1537
|
+
),
|
|
1538
|
+
);
|
|
1539
|
+
}
|
|
1540
|
+
let requestPreview = asString(record.requestPreview);
|
|
1541
|
+
if (requestPreview !== "") {
|
|
1542
|
+
let previewChars = countOf(record.requestChars);
|
|
1543
|
+
let previewNote =
|
|
1544
|
+
record.requestPreviewTruncated === true
|
|
1545
|
+
? t("tail.trace.previewTruncated").replace("{chars}", formatCount(previewChars))
|
|
1546
|
+
: t("tail.trace.previewFull").replace("{chars}", formatCount(previewChars));
|
|
1547
|
+
bodyChildren.push(
|
|
1548
|
+
h("div", { className: "dsh-advisor-turn-preview", key: "preview" }, [
|
|
1549
|
+
h("div", { className: "dsh-advisor-turn-preview-row", key: "row" }, [
|
|
1550
|
+
h("span", { className: "dsh-advisor-turn-meta", key: "note" }, previewNote),
|
|
1551
|
+
h(
|
|
1552
|
+
"button",
|
|
1553
|
+
{
|
|
1554
|
+
className: "dsh-advisor-btn",
|
|
1555
|
+
"data-advisor-preview-toggle": "",
|
|
1556
|
+
key: "toggle",
|
|
1557
|
+
onClick: function togglePreview() {
|
|
1558
|
+
setPreviewOpen(function flip(/** @type {boolean} */ prev) {
|
|
1559
|
+
return !prev;
|
|
1560
|
+
});
|
|
1561
|
+
},
|
|
1562
|
+
type: "button",
|
|
1563
|
+
},
|
|
1564
|
+
previewOpen ? t("tail.trace.previewHide") : t("tail.trace.preview"),
|
|
1565
|
+
),
|
|
1566
|
+
]),
|
|
1567
|
+
previewOpen
|
|
1568
|
+
? h(
|
|
1569
|
+
"pre",
|
|
1570
|
+
{ className: "dsh-advisor-turn-pre", "data-advisor-preview": "", key: "pre" },
|
|
1571
|
+
requestPreview,
|
|
1572
|
+
)
|
|
1573
|
+
: null,
|
|
1574
|
+
]),
|
|
1575
|
+
);
|
|
1576
|
+
} else if (countOf(record.requestChars) > 0) {
|
|
1577
|
+
bodyChildren.push(
|
|
1578
|
+
h(
|
|
1579
|
+
"div",
|
|
1580
|
+
{ className: "dsh-advisor-turn-meta", key: "previewNone" },
|
|
1581
|
+
t("tail.trace.previewNone"),
|
|
1582
|
+
),
|
|
1583
|
+
);
|
|
1324
1584
|
}
|
|
1325
1585
|
let anchors = record.anchors;
|
|
1326
1586
|
if (anchors && typeof anchors === "object") {
|
|
@@ -1350,6 +1610,7 @@ window.__ModuleLoader__.load({
|
|
|
1350
1610
|
className: "dsh-advisor-turn",
|
|
1351
1611
|
"data-advisor-turn": String(turnNumber),
|
|
1352
1612
|
"data-advisor-status": declined ? "declined" : "reviewed",
|
|
1613
|
+
"data-advisor-trigger": asString(record.trigger).trim(),
|
|
1353
1614
|
},
|
|
1354
1615
|
[
|
|
1355
1616
|
h(
|
|
@@ -1389,6 +1650,13 @@ window.__ModuleLoader__.load({
|
|
|
1389
1650
|
// 设置页卡片(settings.general.item)
|
|
1390
1651
|
// ------------------------------------------------------------------
|
|
1391
1652
|
|
|
1653
|
+
/**
|
|
1654
|
+
* 设置卡折叠/帮助的 UI 状态。放在组件外:宿主重渲染设置槽位时组件可能重挂,
|
|
1655
|
+
* 但用户已经展开的高级区不应该被悄悄收起;页面刷新才复位。
|
|
1656
|
+
*/
|
|
1657
|
+
/** @type {Record<string, any>} */
|
|
1658
|
+
let settingsUiState = { advanced: false, status: false, off: false, help: "" };
|
|
1659
|
+
|
|
1392
1660
|
/**
|
|
1393
1661
|
* 设置页 → 通用 的「顾问」卡片。`settings.general.item` 是无 owner props 的 list 槽,
|
|
1394
1662
|
* sessionId 拿不到时传空串(宿主只跳过按会话的字段);数据全部经 props.api 现取。
|
|
@@ -1451,6 +1719,46 @@ window.__ModuleLoader__.load({
|
|
|
1451
1719
|
let previewOpenState = React.useState(false);
|
|
1452
1720
|
let previewOpen = previewOpenState[0];
|
|
1453
1721
|
let setPreviewOpen = previewOpenState[1];
|
|
1722
|
+
/** 高级设置默认折叠;状态与诊断再单独一层。 */
|
|
1723
|
+
/**
|
|
1724
|
+
* 折叠/帮助状态用模块级缓存做初值,组件重挂载时不会把已展开的高级区收起。
|
|
1725
|
+
* @param {string} key
|
|
1726
|
+
* @param {any} initial
|
|
1727
|
+
* @returns {[any, (next: any) => void]}
|
|
1728
|
+
*/
|
|
1729
|
+
function useUiState(key, initial) {
|
|
1730
|
+
let state = React.useState(
|
|
1731
|
+
settingsUiState[key] === undefined ? initial : settingsUiState[key],
|
|
1732
|
+
);
|
|
1733
|
+
let value = state[0];
|
|
1734
|
+
let setValue = state[1];
|
|
1735
|
+
let set = React.useCallback(
|
|
1736
|
+
function update(/** @type {any} */ next) {
|
|
1737
|
+
setValue(function apply(/** @type {any} */ prev) {
|
|
1738
|
+
let resolved = typeof next === "function" ? next(prev) : next;
|
|
1739
|
+
settingsUiState[key] = resolved;
|
|
1740
|
+
return resolved;
|
|
1741
|
+
});
|
|
1742
|
+
},
|
|
1743
|
+
[key],
|
|
1744
|
+
);
|
|
1745
|
+
return [value, set];
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
let advancedState = useUiState("advanced", false);
|
|
1749
|
+
let advancedOpen = advancedState[0];
|
|
1750
|
+
let setAdvancedOpen = advancedState[1];
|
|
1751
|
+
let statusState = useUiState("status", false);
|
|
1752
|
+
let statusOpen = statusState[0];
|
|
1753
|
+
let setStatusOpen = statusState[1];
|
|
1754
|
+
/** off 时也可以显式展开配置;默认收起。 */
|
|
1755
|
+
let offExpandState = useUiState("off", false);
|
|
1756
|
+
let offExpanded = offExpandState[0];
|
|
1757
|
+
let setOffExpanded = offExpandState[1];
|
|
1758
|
+
/** 同一时间只展开一个字段的说明。 */
|
|
1759
|
+
let helpState = useUiState("help", "");
|
|
1760
|
+
let openHelp = helpState[0];
|
|
1761
|
+
let setOpenHelp = helpState[1];
|
|
1454
1762
|
/** provider/model 切换可能并发:只接受最后一次请求的返回。 */
|
|
1455
1763
|
let modelsSeq = React.useRef(0);
|
|
1456
1764
|
let infoSeq = React.useRef(0);
|
|
@@ -1492,6 +1800,9 @@ window.__ModuleLoader__.load({
|
|
|
1492
1800
|
let key = SETTINGS_INT_FIELDS[index];
|
|
1493
1801
|
out[key] = String(settings[key]);
|
|
1494
1802
|
}
|
|
1803
|
+
for (let key of Object.keys(SETTINGS_MONEY_FIELDS)) {
|
|
1804
|
+
out[key] = formatMoneyInput(settings[key], SETTINGS_MONEY_FIELDS[key]);
|
|
1805
|
+
}
|
|
1495
1806
|
out.temperature = settings.temperature === null ? "" : String(settings.temperature);
|
|
1496
1807
|
out.allowedModels = normalizeStringList(settings.allowedModels).join(", ");
|
|
1497
1808
|
return out;
|
|
@@ -1670,6 +1981,19 @@ window.__ModuleLoader__.load({
|
|
|
1670
1981
|
if (text === "") continue;
|
|
1671
1982
|
next[key] = clampInt(text, next[key], SETTINGS_LIMITS[key][0], SETTINGS_LIMITS[key][1]);
|
|
1672
1983
|
}
|
|
1984
|
+
for (let key of Object.keys(SETTINGS_MONEY_FIELDS)) {
|
|
1985
|
+
let raw = texts[key];
|
|
1986
|
+
if (typeof raw !== "string") continue;
|
|
1987
|
+
let text = raw.trim();
|
|
1988
|
+
if (text === "") continue;
|
|
1989
|
+
next[key] = clampMoney(
|
|
1990
|
+
text,
|
|
1991
|
+
next[key],
|
|
1992
|
+
SETTINGS_LIMITS[key][0],
|
|
1993
|
+
SETTINGS_LIMITS[key][1],
|
|
1994
|
+
SETTINGS_MONEY_FIELDS[key],
|
|
1995
|
+
);
|
|
1996
|
+
}
|
|
1673
1997
|
if (typeof texts.temperature === "string") {
|
|
1674
1998
|
let tempText = texts.temperature.trim();
|
|
1675
1999
|
next.temperature = tempText === "" ? null : clampFloat(tempText, null, 0, 2);
|
|
@@ -1696,14 +2020,24 @@ window.__ModuleLoader__.load({
|
|
|
1696
2020
|
);
|
|
1697
2021
|
return;
|
|
1698
2022
|
}
|
|
2023
|
+
let limit = SETTINGS_LIMITS[key];
|
|
2024
|
+
let digits = SETTINGS_MONEY_FIELDS[key];
|
|
1699
2025
|
if (text === "") {
|
|
1700
|
-
|
|
2026
|
+
let restored =
|
|
2027
|
+
digits === undefined ? String(draft[key]) : formatMoneyInput(draft[key], digits);
|
|
2028
|
+
setTexts(Object.assign({}, texts, { [key]: restored }));
|
|
1701
2029
|
return;
|
|
1702
2030
|
}
|
|
1703
|
-
let
|
|
1704
|
-
|
|
2031
|
+
let value =
|
|
2032
|
+
digits === undefined
|
|
2033
|
+
? clampInt(text, draft[key], limit[0], limit[1])
|
|
2034
|
+
: clampMoney(text, draft[key], limit[0], limit[1], digits);
|
|
1705
2035
|
setDraft(Object.assign({}, draft, { [key]: value }));
|
|
1706
|
-
setTexts(
|
|
2036
|
+
setTexts(
|
|
2037
|
+
Object.assign({}, texts, {
|
|
2038
|
+
[key]: digits === undefined ? String(value) : formatMoneyInput(value, digits),
|
|
2039
|
+
}),
|
|
2040
|
+
);
|
|
1707
2041
|
}
|
|
1708
2042
|
|
|
1709
2043
|
/** 保存:只发改过的字段,成功后用返回值刷新本地状态。 */
|
|
@@ -1956,6 +2290,8 @@ window.__ModuleLoader__.load({
|
|
|
1956
2290
|
function chooseMode(mode) {
|
|
1957
2291
|
if (!draft) return;
|
|
1958
2292
|
setDraft(Object.assign({}, draft, { mode: mode }));
|
|
2293
|
+
// 切回 off 时回到紧凑态;切到其它模式时保持/展开基础设置。
|
|
2294
|
+
if (mode === "off") setOffExpanded(false);
|
|
1959
2295
|
}
|
|
1960
2296
|
|
|
1961
2297
|
/** @param {string} scope */
|
|
@@ -1974,6 +2310,16 @@ window.__ModuleLoader__.load({
|
|
|
1974
2310
|
);
|
|
1975
2311
|
}
|
|
1976
2312
|
|
|
2313
|
+
/** @param {string} value */
|
|
2314
|
+
function chooseTracePrompt(value) {
|
|
2315
|
+
if (!draft) return;
|
|
2316
|
+
setDraft(
|
|
2317
|
+
Object.assign({}, draft, {
|
|
2318
|
+
tracePrompt: SETTINGS_TRACE_PROMPT.indexOf(value) >= 0 ? value : "preview",
|
|
2319
|
+
}),
|
|
2320
|
+
);
|
|
2321
|
+
}
|
|
2322
|
+
|
|
1977
2323
|
/**
|
|
1978
2324
|
* @param {string} key
|
|
1979
2325
|
* @param {boolean} on
|
|
@@ -2024,214 +2370,267 @@ window.__ModuleLoader__.load({
|
|
|
2024
2370
|
}
|
|
2025
2371
|
|
|
2026
2372
|
/**
|
|
2027
|
-
*
|
|
2028
|
-
* @param {string}
|
|
2029
|
-
* @param {
|
|
2030
|
-
* @param {string[]} values
|
|
2031
|
-
* @param {string} prefix
|
|
2032
|
-
* @param {string} current
|
|
2033
|
-
* @param {(value: string) => void} onPick
|
|
2373
|
+
* 高级区里的小分组标题。
|
|
2374
|
+
* @param {string} titleKey
|
|
2375
|
+
* @param {any[]} children
|
|
2034
2376
|
* @param {string} key
|
|
2035
2377
|
* @returns {any}
|
|
2036
2378
|
*/
|
|
2037
|
-
function
|
|
2038
|
-
let choices = values.map(function renderChoice(/** @type {string} */ value) {
|
|
2039
|
-
return h("label", { className: "dsh-advisor-choice", key: value }, [
|
|
2040
|
-
h("input", {
|
|
2041
|
-
checked: current === value,
|
|
2042
|
-
key: "input",
|
|
2043
|
-
name: `advisor-${name}`,
|
|
2044
|
-
onChange: function onChoice() {
|
|
2045
|
-
onPick(value);
|
|
2046
|
-
},
|
|
2047
|
-
type: "radio",
|
|
2048
|
-
value: value,
|
|
2049
|
-
}),
|
|
2050
|
-
h("span", { className: "dsh-advisor-choice-label", key: "label" }, t(prefix + value)),
|
|
2051
|
-
h(
|
|
2052
|
-
"span",
|
|
2053
|
-
{ className: "dsh-advisor-choice-hint", key: "hint" },
|
|
2054
|
-
t(`${prefix}${value}Hint`),
|
|
2055
|
-
),
|
|
2056
|
-
]);
|
|
2057
|
-
});
|
|
2379
|
+
function subgroup(titleKey, children, key) {
|
|
2058
2380
|
return h(
|
|
2059
2381
|
"div",
|
|
2060
|
-
{
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2382
|
+
{ className: "dsh-advisor-subgroup", key: key },
|
|
2383
|
+
[h("div", { className: "dsh-advisor-subgroup-title", key: "title" }, t(titleKey))].concat(
|
|
2384
|
+
children,
|
|
2385
|
+
),
|
|
2386
|
+
);
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2389
|
+
/**
|
|
2390
|
+
* 字段外壳:label + 可选「?」帮助按钮 + 控件 + 可选内联提示。
|
|
2391
|
+
* 帮助说明只在点开时渲染,避免每个字段常驻两三行说明把页面撑长。
|
|
2392
|
+
* @param {string} key
|
|
2393
|
+
* @param {string} labelKey
|
|
2394
|
+
* @param {any[]} controlNodes
|
|
2395
|
+
* @param {{ controlId?: string, hint?: string, helpText?: string, metaText?: string }} [options]
|
|
2396
|
+
* @returns {any}
|
|
2397
|
+
*/
|
|
2398
|
+
function fieldShell(key, labelKey, controlNodes, options) {
|
|
2399
|
+
let opts = options === undefined ? {} : options;
|
|
2400
|
+
let controlId = typeof opts.controlId === "string" ? opts.controlId : `dsh-advisor-${key}`;
|
|
2401
|
+
let helpText = typeof opts.helpText === "string" ? opts.helpText : "";
|
|
2402
|
+
let metaText = typeof opts.metaText === "string" ? opts.metaText : "";
|
|
2403
|
+
let hint = typeof opts.hint === "string" ? opts.hint : "";
|
|
2404
|
+
let helpId = `dsh-advisor-help-${key}`;
|
|
2405
|
+
let isHelpOpen = openHelp === key;
|
|
2406
|
+
let labelChildren = [
|
|
2407
|
+
h(
|
|
2408
|
+
"label",
|
|
2409
|
+
{ className: "dsh-advisor-label", htmlFor: controlId, key: "label" },
|
|
2410
|
+
t(labelKey),
|
|
2411
|
+
),
|
|
2412
|
+
];
|
|
2413
|
+
if (helpText !== "") {
|
|
2414
|
+
labelChildren.push(
|
|
2067
2415
|
h(
|
|
2068
|
-
"
|
|
2416
|
+
"button",
|
|
2069
2417
|
{
|
|
2070
|
-
"aria-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2418
|
+
"aria-controls": isHelpOpen ? helpId : undefined,
|
|
2419
|
+
"aria-expanded": isHelpOpen ? "true" : "false",
|
|
2420
|
+
"aria-label": t("settings.help.open").replace("{field}", t(labelKey)),
|
|
2421
|
+
className: "dsh-advisor-help-btn",
|
|
2422
|
+
key: "help",
|
|
2423
|
+
onClick: function toggleHelp() {
|
|
2424
|
+
setOpenHelp(isHelpOpen ? "" : key);
|
|
2425
|
+
},
|
|
2426
|
+
onKeyDown: function closeHelp(/** @type {any} */ event) {
|
|
2427
|
+
if (event && event.key === "Escape") setOpenHelp("");
|
|
2428
|
+
},
|
|
2429
|
+
title: t("settings.help.open").replace("{field}", t(labelKey)),
|
|
2430
|
+
type: "button",
|
|
2074
2431
|
},
|
|
2075
|
-
|
|
2432
|
+
"?",
|
|
2076
2433
|
),
|
|
2077
|
-
|
|
2434
|
+
);
|
|
2435
|
+
}
|
|
2436
|
+
let rowChildren = [
|
|
2437
|
+
h("div", { className: "dsh-advisor-label-wrap", key: "labelWrap" }, labelChildren),
|
|
2438
|
+
].concat(controlNodes);
|
|
2439
|
+
if (hint !== "") {
|
|
2440
|
+
rowChildren.push(h("span", { className: "dsh-advisor-hint", key: "hint" }, hint));
|
|
2441
|
+
}
|
|
2442
|
+
let children = [
|
|
2443
|
+
h(
|
|
2444
|
+
"div",
|
|
2445
|
+
{ className: "dsh-advisor-row", "data-advisor-row": key, key: "row" },
|
|
2446
|
+
rowChildren,
|
|
2447
|
+
),
|
|
2448
|
+
];
|
|
2449
|
+
if (helpText !== "" && isHelpOpen) {
|
|
2450
|
+
let helpChildren = [h("p", { key: "text" }, helpText)];
|
|
2451
|
+
if (metaText !== "") {
|
|
2452
|
+
helpChildren.push(
|
|
2453
|
+
h("p", { className: "dsh-advisor-help-meta", key: "meta" }, metaText),
|
|
2454
|
+
);
|
|
2455
|
+
}
|
|
2456
|
+
helpChildren.push(
|
|
2457
|
+
h(
|
|
2458
|
+
"p",
|
|
2459
|
+
{ className: "dsh-advisor-help-tech", key: "tech" },
|
|
2460
|
+
t("settings.help.tech").replace("{key}", key),
|
|
2461
|
+
),
|
|
2462
|
+
);
|
|
2463
|
+
children.push(
|
|
2464
|
+
h(
|
|
2465
|
+
"div",
|
|
2466
|
+
{ className: "dsh-advisor-help-body", id: helpId, key: "helpBody", role: "note" },
|
|
2467
|
+
helpChildren,
|
|
2468
|
+
),
|
|
2469
|
+
);
|
|
2470
|
+
}
|
|
2471
|
+
return h(
|
|
2472
|
+
"div",
|
|
2473
|
+
{ className: "dsh-advisor-field", "data-advisor-field": key, key: key },
|
|
2474
|
+
children,
|
|
2078
2475
|
);
|
|
2079
2476
|
}
|
|
2080
2477
|
|
|
2081
2478
|
/**
|
|
2082
|
-
*
|
|
2479
|
+
* 默认值 + 范围提示;数值字段共用。
|
|
2083
2480
|
* @param {string} key
|
|
2084
|
-
* @
|
|
2085
|
-
* @param {string} extraHint 已翻译的前缀说明,可为空串
|
|
2086
|
-
* @returns {any}
|
|
2481
|
+
* @returns {string}
|
|
2087
2482
|
*/
|
|
2088
|
-
function
|
|
2483
|
+
function rangeText(key) {
|
|
2089
2484
|
let limit = SETTINGS_LIMITS[key];
|
|
2090
2485
|
let rangeKey =
|
|
2091
2486
|
SETTINGS_UNLIMITED_FIELDS.indexOf(key) >= 0
|
|
2092
2487
|
? "settings.budget.rangeUnlimited"
|
|
2093
2488
|
: "settings.budget.range";
|
|
2094
|
-
|
|
2489
|
+
return t(rangeKey)
|
|
2095
2490
|
.replace("{default}", String(SETTINGS_DEFAULTS[key]))
|
|
2096
2491
|
.replace("{min}", String(limit[0]))
|
|
2097
2492
|
.replace("{max}", String(limit[1]));
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
})
|
|
2125
|
-
|
|
2126
|
-
|
|
2493
|
+
}
|
|
2494
|
+
|
|
2495
|
+
/**
|
|
2496
|
+
* 数字输入 + 可选单位 + 可选帮助说明。
|
|
2497
|
+
* @param {string} key
|
|
2498
|
+
* @param {string} labelKey
|
|
2499
|
+
* @param {{ hint?: string, help?: string, unit?: string }} [options]
|
|
2500
|
+
* @returns {any}
|
|
2501
|
+
*/
|
|
2502
|
+
function numberField(key, labelKey, options) {
|
|
2503
|
+
let opts = options === undefined ? {} : options;
|
|
2504
|
+
let limit = SETTINGS_LIMITS[key];
|
|
2505
|
+
let digits = SETTINGS_MONEY_FIELDS[key];
|
|
2506
|
+
let step = digits === 2 ? "0.01" : digits === 4 ? "0.001" : "1";
|
|
2507
|
+
let helpText = typeof opts.help === "string" ? opts.help : "";
|
|
2508
|
+
let hint = typeof opts.hint === "string" ? opts.hint : "";
|
|
2509
|
+
if (helpText === "" && hint === "") hint = rangeText(key);
|
|
2510
|
+
let control = h("input", {
|
|
2511
|
+
className: "dsh-advisor-input",
|
|
2512
|
+
id: `dsh-advisor-${key}`,
|
|
2513
|
+
key: "input",
|
|
2514
|
+
max: String(limit[1]),
|
|
2515
|
+
min: String(limit[0]),
|
|
2516
|
+
onBlur: function onNumberBlur() {
|
|
2517
|
+
commitOne(key);
|
|
2518
|
+
},
|
|
2519
|
+
onChange: function onNumberChange(/** @type {any} */ event) {
|
|
2520
|
+
let value = String(event.target.value);
|
|
2521
|
+
setTexts(function mergeNumber(/** @type {any} */ prev) {
|
|
2522
|
+
return Object.assign({}, prev, { [key]: value });
|
|
2523
|
+
});
|
|
2524
|
+
},
|
|
2525
|
+
inputMode: digits === undefined ? "numeric" : "decimal",
|
|
2526
|
+
step: step,
|
|
2527
|
+
type: "number",
|
|
2528
|
+
value: typeof texts[key] === "string" ? texts[key] : "",
|
|
2529
|
+
});
|
|
2530
|
+
let controls = [control];
|
|
2531
|
+
if (typeof opts.unit === "string" && opts.unit !== "") {
|
|
2532
|
+
controls.push(h("span", { className: "dsh-advisor-unit", key: "unit" }, opts.unit));
|
|
2533
|
+
}
|
|
2534
|
+
return fieldShell(key, labelKey, controls, {
|
|
2535
|
+
controlId: `dsh-advisor-${key}`,
|
|
2536
|
+
helpText: helpText,
|
|
2537
|
+
hint: hint,
|
|
2538
|
+
metaText: helpText === "" ? "" : rangeText(key),
|
|
2539
|
+
});
|
|
2127
2540
|
}
|
|
2128
2541
|
|
|
2129
2542
|
/** temperature:留空表示不传,可为小数。 @returns {any} */
|
|
2130
2543
|
function temperatureField() {
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
)
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
},
|
|
2157
|
-
placeholder: t("settings.advanced.temperatureEmpty"),
|
|
2158
|
-
step: "0.1",
|
|
2159
|
-
type: "number",
|
|
2160
|
-
value: typeof texts.temperature === "string" ? texts.temperature : "",
|
|
2161
|
-
}),
|
|
2162
|
-
h(
|
|
2163
|
-
"span",
|
|
2164
|
-
{ className: "dsh-advisor-hint", key: "hint" },
|
|
2165
|
-
t("settings.advanced.temperatureHint"),
|
|
2166
|
-
),
|
|
2167
|
-
]);
|
|
2544
|
+
let control = h("input", {
|
|
2545
|
+
className: "dsh-advisor-input",
|
|
2546
|
+
id: "dsh-advisor-temperature",
|
|
2547
|
+
key: "input",
|
|
2548
|
+
max: "2",
|
|
2549
|
+
min: "0",
|
|
2550
|
+
onBlur: function onTemperatureBlur() {
|
|
2551
|
+
commitOne("temperature");
|
|
2552
|
+
},
|
|
2553
|
+
onChange: function onTemperatureChange(/** @type {any} */ event) {
|
|
2554
|
+
let value = String(event.target.value);
|
|
2555
|
+
setTexts(function mergeTemperature(/** @type {any} */ prev) {
|
|
2556
|
+
return Object.assign({}, prev, { temperature: value });
|
|
2557
|
+
});
|
|
2558
|
+
},
|
|
2559
|
+
placeholder: t("settings.advanced.temperatureEmpty"),
|
|
2560
|
+
step: "0.1",
|
|
2561
|
+
type: "number",
|
|
2562
|
+
value: typeof texts.temperature === "string" ? texts.temperature : "",
|
|
2563
|
+
});
|
|
2564
|
+
return fieldShell("temperature", "settings.advanced.temperature", [control], {
|
|
2565
|
+
controlId: "dsh-advisor-temperature",
|
|
2566
|
+
helpText: t("settings.advanced.temperatureHint"),
|
|
2567
|
+
metaText: t("settings.help.defaultNotSent"),
|
|
2568
|
+
});
|
|
2168
2569
|
}
|
|
2169
2570
|
|
|
2170
2571
|
/**
|
|
2171
2572
|
* 开关一行。
|
|
2172
2573
|
* @param {string} key
|
|
2173
2574
|
* @param {string} labelKey
|
|
2174
|
-
* @param {string}
|
|
2575
|
+
* @param {{ hint?: string, help?: string, meta?: string }} [options]
|
|
2175
2576
|
* @returns {any}
|
|
2176
2577
|
*/
|
|
2177
|
-
function switchField(key, labelKey,
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
checked
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
]);
|
|
2578
|
+
function switchField(key, labelKey, options) {
|
|
2579
|
+
let opts = options === undefined ? {} : options;
|
|
2580
|
+
let control = h("input", {
|
|
2581
|
+
checked: draft[key] === true,
|
|
2582
|
+
"data-advisor-switch": key,
|
|
2583
|
+
id: `dsh-advisor-${key}`,
|
|
2584
|
+
key: "input",
|
|
2585
|
+
onChange: function onSwitch(/** @type {any} */ event) {
|
|
2586
|
+
toggleFlag(key, event.target.checked === true);
|
|
2587
|
+
},
|
|
2588
|
+
type: "checkbox",
|
|
2589
|
+
});
|
|
2590
|
+
return fieldShell(key, labelKey, [control], {
|
|
2591
|
+
controlId: `dsh-advisor-${key}`,
|
|
2592
|
+
helpText: typeof opts.help === "string" ? opts.help : "",
|
|
2593
|
+
hint: typeof opts.hint === "string" ? opts.hint : "",
|
|
2594
|
+
metaText: typeof opts.meta === "string" ? opts.meta : "",
|
|
2595
|
+
});
|
|
2196
2596
|
}
|
|
2197
2597
|
|
|
2198
2598
|
/**
|
|
2199
|
-
* 下拉一行(枚举字段,如 postAnswer)。
|
|
2599
|
+
* 下拉一行(枚举字段,如 mode / scope / postAnswer)。
|
|
2200
2600
|
* @param {string} key
|
|
2201
2601
|
* @param {string} labelKey
|
|
2202
2602
|
* @param {string[]} values 合法取值;选项文案拼成 `${prefix}${value}`
|
|
2203
2603
|
* @param {string} prefix
|
|
2204
2604
|
* @param {string} current
|
|
2205
2605
|
* @param {(value: string) => void} onPick
|
|
2206
|
-
* @param {string}
|
|
2606
|
+
* @param {{ hint?: string, help?: string, meta?: string }} [options]
|
|
2207
2607
|
* @returns {any}
|
|
2208
2608
|
*/
|
|
2209
|
-
function selectField(key, labelKey, values, prefix, current, onPick,
|
|
2210
|
-
let
|
|
2609
|
+
function selectField(key, labelKey, values, prefix, current, onPick, options) {
|
|
2610
|
+
let opts = options === undefined ? {} : options;
|
|
2611
|
+
let optionNodes = values.map(function renderOption(/** @type {string} */ value) {
|
|
2211
2612
|
return h("option", { key: value, value: value }, t(prefix + value));
|
|
2212
2613
|
});
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
className: "dsh-advisor-select",
|
|
2223
|
-
"data-advisor-select": key,
|
|
2224
|
-
id: `dsh-advisor-${key}`,
|
|
2225
|
-
key: "select",
|
|
2226
|
-
onChange: function onSelectChange(/** @type {any} */ event) {
|
|
2227
|
-
onPick(String(event.target.value));
|
|
2228
|
-
},
|
|
2229
|
-
value: current,
|
|
2614
|
+
let control = h(
|
|
2615
|
+
"select",
|
|
2616
|
+
{
|
|
2617
|
+
className: "dsh-advisor-select",
|
|
2618
|
+
"data-advisor-select": key,
|
|
2619
|
+
id: `dsh-advisor-${key}`,
|
|
2620
|
+
key: "select",
|
|
2621
|
+
onChange: function onSelectChange(/** @type {any} */ event) {
|
|
2622
|
+
onPick(String(event.target.value));
|
|
2230
2623
|
},
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2624
|
+
value: current,
|
|
2625
|
+
},
|
|
2626
|
+
optionNodes,
|
|
2627
|
+
);
|
|
2628
|
+
return fieldShell(key, labelKey, [control], {
|
|
2629
|
+
controlId: `dsh-advisor-${key}`,
|
|
2630
|
+
helpText: typeof opts.help === "string" ? opts.help : "",
|
|
2631
|
+
hint: typeof opts.hint === "string" ? opts.hint : "",
|
|
2632
|
+
metaText: typeof opts.meta === "string" ? opts.meta : "",
|
|
2633
|
+
});
|
|
2235
2634
|
}
|
|
2236
2635
|
|
|
2237
2636
|
/**
|
|
@@ -2239,38 +2638,26 @@ window.__ModuleLoader__.load({
|
|
|
2239
2638
|
* @returns {any}
|
|
2240
2639
|
*/
|
|
2241
2640
|
function allowedModelsField() {
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
}
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
});
|
|
2263
|
-
},
|
|
2264
|
-
placeholder: t("settings.advanced.allowedModelsPlaceholder"),
|
|
2265
|
-
type: "text",
|
|
2266
|
-
value: typeof texts.allowedModels === "string" ? texts.allowedModels : "",
|
|
2267
|
-
}),
|
|
2268
|
-
h(
|
|
2269
|
-
"span",
|
|
2270
|
-
{ className: "dsh-advisor-hint", key: "hint" },
|
|
2271
|
-
t("settings.advanced.allowedModelsHint"),
|
|
2272
|
-
),
|
|
2273
|
-
]);
|
|
2641
|
+
let control = h("input", {
|
|
2642
|
+
className: "dsh-advisor-input",
|
|
2643
|
+
id: "dsh-advisor-allowedModels",
|
|
2644
|
+
key: "input",
|
|
2645
|
+
onBlur: commitAllowedModels,
|
|
2646
|
+
onChange: function onAllowedModelsChange(/** @type {any} */ event) {
|
|
2647
|
+
let value = String(event.target.value);
|
|
2648
|
+
setTexts(function mergeAllowed(/** @type {any} */ prev) {
|
|
2649
|
+
return Object.assign({}, prev, { allowedModels: value });
|
|
2650
|
+
});
|
|
2651
|
+
},
|
|
2652
|
+
placeholder: t("settings.advanced.allowedModelsPlaceholder"),
|
|
2653
|
+
type: "text",
|
|
2654
|
+
value: typeof texts.allowedModels === "string" ? texts.allowedModels : "",
|
|
2655
|
+
});
|
|
2656
|
+
return fieldShell("allowedModels", "settings.advanced.allowedModels", [control], {
|
|
2657
|
+
controlId: "dsh-advisor-allowedModels",
|
|
2658
|
+
helpText: t("settings.advanced.allowedModelsHint"),
|
|
2659
|
+
metaText: t("settings.help.defaultEmpty"),
|
|
2660
|
+
});
|
|
2274
2661
|
}
|
|
2275
2662
|
|
|
2276
2663
|
/** provider 下拉:来自 options.routes,declared 标「自定义」。 @returns {any} */
|
|
@@ -2296,30 +2683,24 @@ window.__ModuleLoader__.load({
|
|
|
2296
2683
|
),
|
|
2297
2684
|
);
|
|
2298
2685
|
}
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
className: "dsh-advisor-select",
|
|
2309
|
-
"data-advisor-provider": "",
|
|
2310
|
-
id: "dsh-advisor-provider",
|
|
2311
|
-
key: "select",
|
|
2312
|
-
onChange: function onProviderChange(/** @type {any} */ event) {
|
|
2313
|
-
chooseProvider(String(event.target.value));
|
|
2314
|
-
},
|
|
2315
|
-
value: draft.provider,
|
|
2686
|
+
let control = h(
|
|
2687
|
+
"select",
|
|
2688
|
+
{
|
|
2689
|
+
className: "dsh-advisor-select",
|
|
2690
|
+
"data-advisor-provider": "",
|
|
2691
|
+
id: "dsh-advisor-provider",
|
|
2692
|
+
key: "select",
|
|
2693
|
+
onChange: function onProviderChange(/** @type {any} */ event) {
|
|
2694
|
+
chooseProvider(String(event.target.value));
|
|
2316
2695
|
},
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2696
|
+
value: draft.provider,
|
|
2697
|
+
},
|
|
2698
|
+
options,
|
|
2699
|
+
);
|
|
2700
|
+
return fieldShell("provider", "settings.provider", [control], {
|
|
2701
|
+
controlId: "dsh-advisor-provider",
|
|
2702
|
+
hint: routes.length === 0 ? t("settings.provider.none") : "",
|
|
2703
|
+
});
|
|
2323
2704
|
}
|
|
2324
2705
|
|
|
2325
2706
|
/** 模型下拉 + 手填输入。 @returns {any} */
|
|
@@ -2349,52 +2730,44 @@ window.__ModuleLoader__.load({
|
|
|
2349
2730
|
else if (list === null) hint = t("settings.model.loading");
|
|
2350
2731
|
else if (list.length === 0) hint = t("settings.model.none");
|
|
2351
2732
|
if (hint !== "") hint = `${hint} · ${t("settings.model.manualHint")}`;
|
|
2352
|
-
|
|
2733
|
+
let controls = h("div", { className: "dsh-advisor-controls", key: "controls" }, [
|
|
2353
2734
|
h(
|
|
2354
|
-
"
|
|
2355
|
-
{
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
"select",
|
|
2361
|
-
{
|
|
2362
|
-
|
|
2363
|
-
"data-advisor-model": "",
|
|
2364
|
-
disabled: list === null,
|
|
2365
|
-
id: "dsh-advisor-model",
|
|
2366
|
-
key: "select",
|
|
2367
|
-
onChange: function onModelChange(/** @type {any} */ event) {
|
|
2368
|
-
chooseModel(String(event.target.value));
|
|
2369
|
-
},
|
|
2370
|
-
value: draft.model,
|
|
2371
|
-
},
|
|
2372
|
-
options,
|
|
2373
|
-
),
|
|
2374
|
-
h("input", {
|
|
2375
|
-
"aria-label": t("settings.model.manual"),
|
|
2376
|
-
className: "dsh-advisor-input",
|
|
2377
|
-
"data-advisor-model-text": "",
|
|
2378
|
-
key: "manual",
|
|
2379
|
-
onBlur: function onModelTextBlur() {
|
|
2380
|
-
if (draft.model !== "" && draft.provider !== "") {
|
|
2381
|
-
loadInfoFor(draft.provider, draft.model);
|
|
2382
|
-
}
|
|
2383
|
-
},
|
|
2384
|
-
onChange: function onModelTextChange(/** @type {any} */ event) {
|
|
2385
|
-
onModelText(String(event.target.value));
|
|
2735
|
+
"select",
|
|
2736
|
+
{
|
|
2737
|
+
className: "dsh-advisor-select",
|
|
2738
|
+
"data-advisor-model": "",
|
|
2739
|
+
disabled: list === null,
|
|
2740
|
+
id: "dsh-advisor-model",
|
|
2741
|
+
key: "select",
|
|
2742
|
+
onChange: function onModelChange(/** @type {any} */ event) {
|
|
2743
|
+
chooseModel(String(event.target.value));
|
|
2386
2744
|
},
|
|
2387
|
-
placeholder: t("settings.model.manual"),
|
|
2388
|
-
type: "text",
|
|
2389
2745
|
value: draft.model,
|
|
2390
|
-
}
|
|
2391
|
-
|
|
2392
|
-
h(
|
|
2393
|
-
"span",
|
|
2394
|
-
{ className: "dsh-advisor-hint", key: "hint" },
|
|
2395
|
-
hint === "" ? t("settings.model.manualHint") : hint,
|
|
2746
|
+
},
|
|
2747
|
+
options,
|
|
2396
2748
|
),
|
|
2749
|
+
h("input", {
|
|
2750
|
+
"aria-label": t("settings.model.manual"),
|
|
2751
|
+
className: "dsh-advisor-input",
|
|
2752
|
+
"data-advisor-model-text": "",
|
|
2753
|
+
key: "manual",
|
|
2754
|
+
onBlur: function onModelTextBlur() {
|
|
2755
|
+
if (draft.model !== "" && draft.provider !== "") {
|
|
2756
|
+
loadInfoFor(draft.provider, draft.model);
|
|
2757
|
+
}
|
|
2758
|
+
},
|
|
2759
|
+
onChange: function onModelTextChange(/** @type {any} */ event) {
|
|
2760
|
+
onModelText(String(event.target.value));
|
|
2761
|
+
},
|
|
2762
|
+
placeholder: t("settings.model.manual"),
|
|
2763
|
+
type: "text",
|
|
2764
|
+
value: draft.model,
|
|
2765
|
+
}),
|
|
2397
2766
|
]);
|
|
2767
|
+
return fieldShell("model", "settings.model", [controls], {
|
|
2768
|
+
controlId: "dsh-advisor-model",
|
|
2769
|
+
hint: hint === "" ? t("settings.model.manualHint") : hint,
|
|
2770
|
+
});
|
|
2398
2771
|
}
|
|
2399
2772
|
|
|
2400
2773
|
/** 思考档下拉:auto + modelInfo.efforts;拿不到只留 auto。 @returns {any} */
|
|
@@ -2427,29 +2800,25 @@ window.__ModuleLoader__.load({
|
|
|
2427
2800
|
else if (info.state === "error") hint = t("settings.error.modelInfo");
|
|
2428
2801
|
else if (info.state === "empty" || efforts.length === 0) hint = t("settings.effort.none");
|
|
2429
2802
|
else hint = t("settings.effort.count").replace("{count}", String(efforts.length));
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
"select",
|
|
2438
|
-
{
|
|
2439
|
-
|
|
2440
|
-
"data-advisor-effort": "",
|
|
2441
|
-
disabled: draft.model === "" || info.state === "loading",
|
|
2442
|
-
id: "dsh-advisor-effort",
|
|
2443
|
-
key: "select",
|
|
2444
|
-
onChange: function onEffortChange(/** @type {any} */ event) {
|
|
2445
|
-
chooseEffort(String(event.target.value));
|
|
2446
|
-
},
|
|
2447
|
-
value: draft.reasoningEffort,
|
|
2803
|
+
let control = h(
|
|
2804
|
+
"select",
|
|
2805
|
+
{
|
|
2806
|
+
className: "dsh-advisor-select",
|
|
2807
|
+
"data-advisor-effort": "",
|
|
2808
|
+
disabled: draft.model === "" || info.state === "loading",
|
|
2809
|
+
id: "dsh-advisor-effort",
|
|
2810
|
+
key: "select",
|
|
2811
|
+
onChange: function onEffortChange(/** @type {any} */ event) {
|
|
2812
|
+
chooseEffort(String(event.target.value));
|
|
2448
2813
|
},
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2814
|
+
value: draft.reasoningEffort,
|
|
2815
|
+
},
|
|
2816
|
+
options,
|
|
2817
|
+
);
|
|
2818
|
+
return fieldShell("effort", "settings.effort", [control], {
|
|
2819
|
+
controlId: "dsh-advisor-effort",
|
|
2820
|
+
hint: hint,
|
|
2821
|
+
});
|
|
2453
2822
|
}
|
|
2454
2823
|
|
|
2455
2824
|
// 初次加载 / 重载:还没有可用快照时只渲染标题与加载态,避免半张卡片。
|
|
@@ -2476,6 +2845,198 @@ window.__ModuleLoader__.load({
|
|
|
2476
2845
|
);
|
|
2477
2846
|
}
|
|
2478
2847
|
|
|
2848
|
+
/**
|
|
2849
|
+
* 当前草稿是否有未保存改动。
|
|
2850
|
+
* @returns {boolean}
|
|
2851
|
+
*/
|
|
2852
|
+
function isDirty() {
|
|
2853
|
+
if (snap === null || draft === null) return false;
|
|
2854
|
+
return Object.keys(diffSettings(snap.settings, draft)).length > 0;
|
|
2855
|
+
}
|
|
2856
|
+
|
|
2857
|
+
/**
|
|
2858
|
+
* 数组按内容比较、浮点按 epsilon 比较;其余用严格相等。
|
|
2859
|
+
* @param {any} a
|
|
2860
|
+
* @param {any} b
|
|
2861
|
+
* @returns {boolean}
|
|
2862
|
+
*/
|
|
2863
|
+
function valuesEqual(a, b) {
|
|
2864
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
2865
|
+
return normalizeStringList(a).join("\u0000") === normalizeStringList(b).join("\u0000");
|
|
2866
|
+
}
|
|
2867
|
+
if (a === null || a === undefined) return b === null || b === undefined;
|
|
2868
|
+
if (typeof a === "number" && typeof b === "number") return Math.abs(a - b) < 1e-9;
|
|
2869
|
+
return a === b;
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2872
|
+
/** 高级区里与默认值不同的项数;用于折叠标题徽标。 @returns {number} */
|
|
2873
|
+
function advancedChangedCount() {
|
|
2874
|
+
if (draft === null) return 0;
|
|
2875
|
+
let count = 0;
|
|
2876
|
+
for (let index = 0; index < SETTINGS_ADVANCED_FIELDS.length; index += 1) {
|
|
2877
|
+
let key = SETTINGS_ADVANCED_FIELDS[index];
|
|
2878
|
+
if (valuesEqual(draft[key], SETTINGS_DEFAULTS[key]) === false) count += 1;
|
|
2879
|
+
}
|
|
2880
|
+
return count;
|
|
2881
|
+
}
|
|
2882
|
+
|
|
2883
|
+
/** 恢复高级字段默认值;不动模式、路由、隐私这些基础字段。 */
|
|
2884
|
+
function resetAdvanced() {
|
|
2885
|
+
if (draft === null) return;
|
|
2886
|
+
let next = Object.assign({}, draft);
|
|
2887
|
+
for (let index = 0; index < SETTINGS_ADVANCED_FIELDS.length; index += 1) {
|
|
2888
|
+
let key = SETTINGS_ADVANCED_FIELDS[index];
|
|
2889
|
+
let fallback = SETTINGS_DEFAULTS[key];
|
|
2890
|
+
next[key] = Array.isArray(fallback) ? fallback.slice() : fallback;
|
|
2891
|
+
}
|
|
2892
|
+
setDraft(next);
|
|
2893
|
+
setTexts(textsOf(next));
|
|
2894
|
+
setError(null);
|
|
2895
|
+
setNotice(t("settings.advanced.resetDone"));
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2898
|
+
/** 复制设置文件路径;剪贴板不可用时只提示手动复制。 */
|
|
2899
|
+
function copySettingsPath() {
|
|
2900
|
+
let path = snap !== null && typeof snap.settingsPath === "string" ? snap.settingsPath : "";
|
|
2901
|
+
if (path === "") {
|
|
2902
|
+
setNotice(t("settings.advanced.pathUnknown"));
|
|
2903
|
+
return;
|
|
2904
|
+
}
|
|
2905
|
+
try {
|
|
2906
|
+
if (
|
|
2907
|
+
typeof navigator !== "undefined" &&
|
|
2908
|
+
navigator.clipboard &&
|
|
2909
|
+
typeof navigator.clipboard.writeText === "function"
|
|
2910
|
+
) {
|
|
2911
|
+
navigator.clipboard.writeText(path).then(
|
|
2912
|
+
function onCopied() {
|
|
2913
|
+
setNotice(t("settings.advanced.copied"));
|
|
2914
|
+
},
|
|
2915
|
+
function onCopyFailed() {
|
|
2916
|
+
setNotice(t("settings.advanced.copyFailed"));
|
|
2917
|
+
},
|
|
2918
|
+
);
|
|
2919
|
+
return;
|
|
2920
|
+
}
|
|
2921
|
+
} catch (_error) {
|
|
2922
|
+
/* 落回手动复制提示 */
|
|
2923
|
+
}
|
|
2924
|
+
setNotice(t("settings.advanced.copyFailed"));
|
|
2925
|
+
}
|
|
2926
|
+
|
|
2927
|
+
/**
|
|
2928
|
+
* 一个可折叠区块:高级设置、状态与诊断共用。
|
|
2929
|
+
* @param {string} key
|
|
2930
|
+
* @param {string} title
|
|
2931
|
+
* @param {string} badge
|
|
2932
|
+
* @param {any[]} children
|
|
2933
|
+
* @param {boolean} isOpen
|
|
2934
|
+
* @param {() => void} onToggle
|
|
2935
|
+
* @returns {any}
|
|
2936
|
+
*/
|
|
2937
|
+
function disclosure(key, title, badge, children, isOpen, onToggle) {
|
|
2938
|
+
return h(
|
|
2939
|
+
"section",
|
|
2940
|
+
{ className: "dsh-advisor-disclosure", "data-advisor-disclosure": key, key: key },
|
|
2941
|
+
[
|
|
2942
|
+
h(
|
|
2943
|
+
"button",
|
|
2944
|
+
{
|
|
2945
|
+
"aria-expanded": isOpen ? "true" : "false",
|
|
2946
|
+
className: "dsh-advisor-disclosure-toggle",
|
|
2947
|
+
"data-advisor-disclosure-toggle": key,
|
|
2948
|
+
key: "toggle",
|
|
2949
|
+
onClick: onToggle,
|
|
2950
|
+
type: "button",
|
|
2951
|
+
},
|
|
2952
|
+
[
|
|
2953
|
+
h("span", { className: "dsh-advisor-caret", key: "caret" }, isOpen ? "▾" : "▸"),
|
|
2954
|
+
h("span", { className: "dsh-advisor-disclosure-title", key: "title" }, title),
|
|
2955
|
+
badge === ""
|
|
2956
|
+
? null
|
|
2957
|
+
: h("span", { className: "dsh-advisor-badge", key: "badge" }, badge),
|
|
2958
|
+
],
|
|
2959
|
+
),
|
|
2960
|
+
isOpen
|
|
2961
|
+
? h("div", { className: "dsh-advisor-disclosure-body", key: "body" }, children)
|
|
2962
|
+
: null,
|
|
2963
|
+
],
|
|
2964
|
+
);
|
|
2965
|
+
}
|
|
2966
|
+
|
|
2967
|
+
/** off 时的紧凑卡片:只解释状态、给配置入口,不铺开任何设置。 @returns {any} */
|
|
2968
|
+
function offNotice() {
|
|
2969
|
+
let configured = draft.provider !== "" && draft.model !== "";
|
|
2970
|
+
let dirty = isDirty();
|
|
2971
|
+
return h("div", { className: "dsh-advisor-off", "data-advisor-off": "", key: "off" }, [
|
|
2972
|
+
h("div", { className: "dsh-advisor-off-title", key: "title" }, t("settings.off.title")),
|
|
2973
|
+
h(
|
|
2974
|
+
"div",
|
|
2975
|
+
{ className: "dsh-advisor-note", key: "state" },
|
|
2976
|
+
configured
|
|
2977
|
+
? t("settings.off.configured")
|
|
2978
|
+
.replace("{provider}", draft.provider)
|
|
2979
|
+
.replace("{model}", draft.model)
|
|
2980
|
+
: t("settings.off.unconfigured"),
|
|
2981
|
+
),
|
|
2982
|
+
dirty
|
|
2983
|
+
? h("div", { className: "dsh-advisor-dirty", key: "dirty" }, t("settings.dirty"))
|
|
2984
|
+
: null,
|
|
2985
|
+
h("div", { className: "dsh-advisor-actions", key: "actions" }, [
|
|
2986
|
+
h(
|
|
2987
|
+
"button",
|
|
2988
|
+
{
|
|
2989
|
+
className: "dsh-advisor-btn",
|
|
2990
|
+
"data-advisor-configure": "",
|
|
2991
|
+
key: "configure",
|
|
2992
|
+
onClick: function toggleOffForm() {
|
|
2993
|
+
setOffExpanded(!offExpanded);
|
|
2994
|
+
},
|
|
2995
|
+
type: "button",
|
|
2996
|
+
},
|
|
2997
|
+
offExpanded ? t("settings.off.collapse") : t("settings.off.configure"),
|
|
2998
|
+
),
|
|
2999
|
+
]),
|
|
3000
|
+
]);
|
|
3001
|
+
}
|
|
3002
|
+
|
|
3003
|
+
/** 保存 / 重新加载 / 未保存提示。 @param {boolean} dirty @returns {any} */
|
|
3004
|
+
function actionBar(dirty) {
|
|
3005
|
+
return h("div", { className: "dsh-advisor-actions", key: "actions" }, [
|
|
3006
|
+
h(
|
|
3007
|
+
"button",
|
|
3008
|
+
{
|
|
3009
|
+
className: "dsh-advisor-btn dsh-advisor-btn--primary",
|
|
3010
|
+
"data-advisor-save": "",
|
|
3011
|
+
disabled: busy === "save" || busy === "load",
|
|
3012
|
+
key: "save",
|
|
3013
|
+
onClick: save,
|
|
3014
|
+
type: "button",
|
|
3015
|
+
},
|
|
3016
|
+
busy === "save" ? t("settings.saving") : t("settings.save"),
|
|
3017
|
+
),
|
|
3018
|
+
h(
|
|
3019
|
+
"button",
|
|
3020
|
+
{
|
|
3021
|
+
className: "dsh-advisor-btn",
|
|
3022
|
+
"data-advisor-reload": "",
|
|
3023
|
+
disabled: busy === "load",
|
|
3024
|
+
key: "reload",
|
|
3025
|
+
onClick: reload,
|
|
3026
|
+
type: "button",
|
|
3027
|
+
},
|
|
3028
|
+
t("settings.reload"),
|
|
3029
|
+
),
|
|
3030
|
+
dirty
|
|
3031
|
+
? h(
|
|
3032
|
+
"span",
|
|
3033
|
+
{ className: "dsh-advisor-dirty", "data-advisor-dirty": "", key: "dirty" },
|
|
3034
|
+
t("settings.dirty"),
|
|
3035
|
+
)
|
|
3036
|
+
: null,
|
|
3037
|
+
]);
|
|
3038
|
+
}
|
|
3039
|
+
|
|
2479
3040
|
let sep = t("settings.status.sep");
|
|
2480
3041
|
let totals = snap.totals;
|
|
2481
3042
|
let priced = snap.settings.priceInputPerMTok > 0 || snap.settings.priceOutputPerMTok > 0;
|
|
@@ -2495,9 +3056,6 @@ window.__ModuleLoader__.load({
|
|
|
2495
3056
|
t("settings.status.skip") +
|
|
2496
3057
|
sep +
|
|
2497
3058
|
(snap.lastSkip === "" ? t("settings.status.none") : snap.lastSkip),
|
|
2498
|
-
t("settings.status.ledger") +
|
|
2499
|
-
sep +
|
|
2500
|
-
(snap.ledgerPath === "" ? t("settings.status.none") : snap.ledgerPath),
|
|
2501
3059
|
];
|
|
2502
3060
|
|
|
2503
3061
|
let doctorNode = null;
|
|
@@ -2533,39 +3091,199 @@ window.__ModuleLoader__.load({
|
|
|
2533
3091
|
.replace("{calls}", formatCount(snap.pool.calls))
|
|
2534
3092
|
.replace("{cost}", `$${Number(snap.pool.costUsd).toFixed(4)}`);
|
|
2535
3093
|
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
3094
|
+
// 基础设置:只放开启前必须做的决定,以及每日预算与发送范围。
|
|
3095
|
+
let basicBody = [
|
|
3096
|
+
subgroup("settings.group.model", [providerField(), modelField(), effortField()], "model"),
|
|
3097
|
+
subgroup(
|
|
3098
|
+
"settings.group.spend",
|
|
3099
|
+
[
|
|
3100
|
+
numberField("maxCostPerDayUsd", "settings.budget.maxCostPerDayUsd", {
|
|
3101
|
+
hint: t("settings.basic.budgetHint"),
|
|
3102
|
+
unit: t("settings.unit.usd"),
|
|
3103
|
+
}),
|
|
3104
|
+
],
|
|
3105
|
+
"spend",
|
|
2545
3106
|
),
|
|
2546
|
-
|
|
2547
|
-
"
|
|
2548
|
-
|
|
2549
|
-
|
|
3107
|
+
subgroup(
|
|
3108
|
+
"settings.group.privacy",
|
|
3109
|
+
[
|
|
3110
|
+
selectField(
|
|
3111
|
+
"scope",
|
|
3112
|
+
"settings.scope",
|
|
3113
|
+
SETTINGS_SCOPES,
|
|
3114
|
+
"settings.scope.",
|
|
3115
|
+
draft.privacyScope,
|
|
3116
|
+
chooseScope,
|
|
3117
|
+
{ hint: t(`settings.scope.${draft.privacyScope}Hint`) },
|
|
3118
|
+
),
|
|
3119
|
+
switchField("redact", "settings.privacy.redact", {
|
|
3120
|
+
hint: t("settings.privacy.redactHint"),
|
|
3121
|
+
}),
|
|
3122
|
+
],
|
|
3123
|
+
"privacy",
|
|
2550
3124
|
),
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
3125
|
+
];
|
|
3126
|
+
|
|
3127
|
+
// 高级设置:调用限额、单价、生成参数、投递行为;默认折叠。
|
|
3128
|
+
let advancedBody = [
|
|
3129
|
+
h("div", { className: "dsh-advisor-note", key: "intro" }, t("settings.advanced.intro")),
|
|
3130
|
+
subgroup(
|
|
3131
|
+
"settings.group.limits",
|
|
3132
|
+
[
|
|
3133
|
+
h(
|
|
3134
|
+
"div",
|
|
3135
|
+
{ className: "dsh-advisor-note", key: "dailyBudgetNote" },
|
|
3136
|
+
t("settings.advanced.dailyBudgetNote"),
|
|
3137
|
+
),
|
|
3138
|
+
numberField("maxCallsPerTurn", "settings.budget.maxCallsPerTurn", {
|
|
3139
|
+
help: t("settings.help.calls"),
|
|
3140
|
+
unit: t("settings.unit.calls"),
|
|
3141
|
+
}),
|
|
3142
|
+
numberField("maxCallsPerSession", "settings.budget.maxCallsPerSession", {
|
|
3143
|
+
help: t("settings.help.calls"),
|
|
3144
|
+
unit: t("settings.unit.calls"),
|
|
3145
|
+
}),
|
|
3146
|
+
numberField("maxCallsPerHour", "settings.budget.maxCallsPerHour", {
|
|
3147
|
+
help: t("settings.help.calls"),
|
|
3148
|
+
unit: t("settings.unit.calls"),
|
|
3149
|
+
}),
|
|
3150
|
+
numberField("workspaceMaxCallsPerDay", "settings.budget.workspaceMaxCallsPerDay", {
|
|
3151
|
+
help: t("settings.budget.workspaceHint"),
|
|
3152
|
+
unit: t("settings.unit.calls"),
|
|
3153
|
+
}),
|
|
3154
|
+
numberField("workspaceMaxCostPerDayUsd", "settings.budget.workspaceMaxCostPerDayUsd", {
|
|
3155
|
+
help: t("settings.budget.workspaceHint"),
|
|
3156
|
+
unit: t("settings.unit.usd"),
|
|
3157
|
+
}),
|
|
3158
|
+
h(
|
|
3159
|
+
"div",
|
|
3160
|
+
{ className: "dsh-advisor-readout", "data-advisor-pool": "", key: "pool" },
|
|
3161
|
+
poolLine,
|
|
3162
|
+
),
|
|
3163
|
+
],
|
|
3164
|
+
"limits",
|
|
2559
3165
|
),
|
|
2560
|
-
|
|
2561
|
-
"
|
|
2562
|
-
|
|
2563
|
-
|
|
3166
|
+
subgroup(
|
|
3167
|
+
"settings.group.money",
|
|
3168
|
+
[
|
|
3169
|
+
numberField("priceInputPerMTok", "settings.budget.priceInputPerMTok", {
|
|
3170
|
+
help: t("settings.budget.priceHint"),
|
|
3171
|
+
unit: t("settings.unit.usdPerMTok"),
|
|
3172
|
+
}),
|
|
3173
|
+
numberField("priceOutputPerMTok", "settings.budget.priceOutputPerMTok", {
|
|
3174
|
+
help: t("settings.budget.priceHint"),
|
|
3175
|
+
unit: t("settings.unit.usdPerMTok"),
|
|
3176
|
+
}),
|
|
3177
|
+
h("div", { className: "dsh-advisor-readout", key: "priceSource" }, priceSourceText),
|
|
3178
|
+
],
|
|
3179
|
+
"money",
|
|
2564
3180
|
),
|
|
2565
|
-
|
|
2566
|
-
"
|
|
2567
|
-
|
|
2568
|
-
|
|
3181
|
+
subgroup(
|
|
3182
|
+
"settings.group.generation",
|
|
3183
|
+
[
|
|
3184
|
+
numberField("maxTokens", "settings.advanced.maxTokens", {
|
|
3185
|
+
help: t("settings.advanced.maxTokensHint"),
|
|
3186
|
+
unit: t("settings.unit.tokens"),
|
|
3187
|
+
}),
|
|
3188
|
+
temperatureField(),
|
|
3189
|
+
numberField("maxInputChars", "settings.advanced.maxInputChars", {
|
|
3190
|
+
help: t("settings.advanced.maxInputCharsHint"),
|
|
3191
|
+
unit: t("settings.unit.chars"),
|
|
3192
|
+
}),
|
|
3193
|
+
],
|
|
3194
|
+
"generation",
|
|
3195
|
+
),
|
|
3196
|
+
subgroup(
|
|
3197
|
+
"settings.group.delivery",
|
|
3198
|
+
[
|
|
3199
|
+
numberField("sessionCap", "settings.advanced.sessionCap", {
|
|
3200
|
+
help: t("settings.advanced.sessionCapHint"),
|
|
3201
|
+
unit: t("settings.unit.items"),
|
|
3202
|
+
}),
|
|
3203
|
+
allowedModelsField(),
|
|
3204
|
+
selectField(
|
|
3205
|
+
"postAnswer",
|
|
3206
|
+
"settings.postAnswer",
|
|
3207
|
+
SETTINGS_POST_ANSWER,
|
|
3208
|
+
"settings.postAnswer.",
|
|
3209
|
+
draft.postAnswer,
|
|
3210
|
+
choosePostAnswer,
|
|
3211
|
+
{ help: t("settings.postAnswer.hint"), meta: t("settings.help.defaultOffOption") },
|
|
3212
|
+
),
|
|
3213
|
+
switchField("advisorTools", "settings.advisorTools", {
|
|
3214
|
+
help: t("settings.advisorToolsHint"),
|
|
3215
|
+
meta: t("settings.help.defaultOff"),
|
|
3216
|
+
}),
|
|
3217
|
+
switchField("dedupe", "settings.privacy.dedupe", {
|
|
3218
|
+
help: t("settings.privacy.dedupeHint"),
|
|
3219
|
+
meta: t("settings.help.defaultOn"),
|
|
3220
|
+
}),
|
|
3221
|
+
selectField(
|
|
3222
|
+
"tracePrompt",
|
|
3223
|
+
"settings.tracePrompt",
|
|
3224
|
+
SETTINGS_TRACE_PROMPT,
|
|
3225
|
+
"settings.tracePrompt.",
|
|
3226
|
+
draft.tracePrompt,
|
|
3227
|
+
chooseTracePrompt,
|
|
3228
|
+
{
|
|
3229
|
+
help: t("settings.tracePrompt.hint"),
|
|
3230
|
+
meta: t("settings.help.defaultPreview"),
|
|
3231
|
+
},
|
|
3232
|
+
),
|
|
3233
|
+
],
|
|
3234
|
+
"delivery",
|
|
3235
|
+
),
|
|
3236
|
+
subgroup(
|
|
3237
|
+
"settings.group.more",
|
|
3238
|
+
[
|
|
3239
|
+
h("div", { className: "dsh-advisor-more", key: "more" }, [
|
|
3240
|
+
h(
|
|
3241
|
+
"p",
|
|
3242
|
+
{ key: "text" },
|
|
3243
|
+
t("settings.advanced.more").replace("{fields}", t("settings.advanced.moreFields")),
|
|
3244
|
+
),
|
|
3245
|
+
h(
|
|
3246
|
+
"p",
|
|
3247
|
+
{ className: "dsh-advisor-path", key: "path" },
|
|
3248
|
+
snap.settingsPath === ""
|
|
3249
|
+
? t("settings.advanced.pathUnknown")
|
|
3250
|
+
: t("settings.paths.settings").replace("{path}", snap.settingsPath),
|
|
3251
|
+
),
|
|
3252
|
+
snap.settingsPath === ""
|
|
3253
|
+
? null
|
|
3254
|
+
: h(
|
|
3255
|
+
"button",
|
|
3256
|
+
{
|
|
3257
|
+
className: "dsh-advisor-btn",
|
|
3258
|
+
"data-advisor-copy-path": "",
|
|
3259
|
+
key: "copy",
|
|
3260
|
+
onClick: copySettingsPath,
|
|
3261
|
+
type: "button",
|
|
3262
|
+
},
|
|
3263
|
+
t("settings.advanced.copyPath"),
|
|
3264
|
+
),
|
|
3265
|
+
]),
|
|
3266
|
+
],
|
|
3267
|
+
"more",
|
|
3268
|
+
),
|
|
3269
|
+
h("div", { className: "dsh-advisor-divider", key: "resetDivider" }),
|
|
3270
|
+
h("div", { className: "dsh-advisor-actions", key: "resetActions" }, [
|
|
3271
|
+
h(
|
|
3272
|
+
"button",
|
|
3273
|
+
{
|
|
3274
|
+
className: "dsh-advisor-btn",
|
|
3275
|
+
"data-advisor-reset": "",
|
|
3276
|
+
key: "reset",
|
|
3277
|
+
onClick: resetAdvanced,
|
|
3278
|
+
type: "button",
|
|
3279
|
+
},
|
|
3280
|
+
t("settings.advanced.reset"),
|
|
3281
|
+
),
|
|
3282
|
+
]),
|
|
3283
|
+
h(
|
|
3284
|
+
"div",
|
|
3285
|
+
{ className: "dsh-advisor-note", key: "resetHint" },
|
|
3286
|
+
t("settings.advanced.resetHint"),
|
|
2569
3287
|
),
|
|
2570
3288
|
];
|
|
2571
3289
|
|
|
@@ -2623,12 +3341,20 @@ window.__ModuleLoader__.load({
|
|
|
2623
3341
|
]);
|
|
2624
3342
|
}
|
|
2625
3343
|
|
|
2626
|
-
let
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
3344
|
+
let statusBody = [
|
|
3345
|
+
h(
|
|
3346
|
+
"div",
|
|
3347
|
+
{ className: "dsh-advisor-summary", "data-advisor-summary": "", key: "summary" },
|
|
3348
|
+
summaryLines.map(
|
|
3349
|
+
function renderSummaryLine(/** @type {string} */ line, /** @type {number} */ index) {
|
|
3350
|
+
return h(
|
|
3351
|
+
"div",
|
|
3352
|
+
{ className: "dsh-advisor-summary-line", key: `line-${index}` },
|
|
3353
|
+
line,
|
|
3354
|
+
);
|
|
3355
|
+
},
|
|
3356
|
+
),
|
|
3357
|
+
),
|
|
2632
3358
|
h("div", { className: "dsh-advisor-row", key: "previewRow" }, [
|
|
2633
3359
|
h("span", { className: "dsh-advisor-label", key: "label" }, t("settings.preview")),
|
|
2634
3360
|
h(
|
|
@@ -2646,31 +3372,13 @@ window.__ModuleLoader__.load({
|
|
|
2646
3372
|
]),
|
|
2647
3373
|
previewNode,
|
|
2648
3374
|
confirmRow,
|
|
2649
|
-
h("div", { className: "dsh-advisor-divider", key: "divider" }),
|
|
2650
|
-
h(
|
|
2651
|
-
"div",
|
|
2652
|
-
{ className: "dsh-advisor-subtitle", key: "statusTitle" },
|
|
2653
|
-
t("settings.status.title"),
|
|
2654
|
-
),
|
|
2655
|
-
h(
|
|
2656
|
-
"div",
|
|
2657
|
-
{ className: "dsh-advisor-summary", "data-advisor-summary": "", key: "summary" },
|
|
2658
|
-
summaryLines.map(
|
|
2659
|
-
function renderSummaryLine(/** @type {string} */ line, /** @type {number} */ index) {
|
|
2660
|
-
return h(
|
|
2661
|
-
"div",
|
|
2662
|
-
{ className: "dsh-advisor-summary-line", key: `line-${index}` },
|
|
2663
|
-
line,
|
|
2664
|
-
);
|
|
2665
|
-
},
|
|
2666
|
-
),
|
|
2667
|
-
),
|
|
2668
3375
|
h("div", { className: "dsh-advisor-row", key: "doctorRow" }, [
|
|
2669
3376
|
h("span", { className: "dsh-advisor-label", key: "label" }, t("settings.doctor")),
|
|
2670
3377
|
h(
|
|
2671
3378
|
"button",
|
|
2672
3379
|
{
|
|
2673
3380
|
className: "dsh-advisor-btn",
|
|
3381
|
+
"data-advisor-doctor-run": "",
|
|
2674
3382
|
disabled: busy === "doctor",
|
|
2675
3383
|
key: "run",
|
|
2676
3384
|
onClick: runDoctor,
|
|
@@ -2680,6 +3388,22 @@ window.__ModuleLoader__.load({
|
|
|
2680
3388
|
),
|
|
2681
3389
|
]),
|
|
2682
3390
|
doctorNode,
|
|
3391
|
+
h("div", { className: "dsh-advisor-paths", key: "paths" }, [
|
|
3392
|
+
snap.settingsPath === ""
|
|
3393
|
+
? null
|
|
3394
|
+
: h(
|
|
3395
|
+
"div",
|
|
3396
|
+
{ key: "settingsPath" },
|
|
3397
|
+
t("settings.paths.settings").replace("{path}", snap.settingsPath),
|
|
3398
|
+
),
|
|
3399
|
+
snap.ledgerPath === ""
|
|
3400
|
+
? null
|
|
3401
|
+
: h(
|
|
3402
|
+
"div",
|
|
3403
|
+
{ key: "ledgerPath" },
|
|
3404
|
+
t("settings.paths.ledger").replace("{path}", snap.ledgerPath),
|
|
3405
|
+
),
|
|
3406
|
+
]),
|
|
2683
3407
|
];
|
|
2684
3408
|
|
|
2685
3409
|
let noticeNode =
|
|
@@ -2687,6 +3411,64 @@ window.__ModuleLoader__.load({
|
|
|
2687
3411
|
? null
|
|
2688
3412
|
: h("div", { className: "dsh-advisor-saved", key: "notice", role: "status" }, notice);
|
|
2689
3413
|
|
|
3414
|
+
let advancedChanged = advancedChangedCount();
|
|
3415
|
+
let advancedBadge =
|
|
3416
|
+
advancedChanged === 0
|
|
3417
|
+
? t("settings.advanced.defaults")
|
|
3418
|
+
: t("settings.advanced.changed").replace("{count}", String(advancedChanged));
|
|
3419
|
+
let modeRow = selectField(
|
|
3420
|
+
"mode",
|
|
3421
|
+
"settings.mode",
|
|
3422
|
+
SETTINGS_MODES,
|
|
3423
|
+
"settings.mode.",
|
|
3424
|
+
draft.mode,
|
|
3425
|
+
chooseMode,
|
|
3426
|
+
{ hint: t(`settings.mode.${draft.mode}Hint`) },
|
|
3427
|
+
);
|
|
3428
|
+
let showForm = draft.mode !== "off" || offExpanded;
|
|
3429
|
+
let dirty = isDirty();
|
|
3430
|
+
|
|
3431
|
+
let children = [
|
|
3432
|
+
h("div", { className: "dsh-advisor-head", key: "head" }, [
|
|
3433
|
+
h("div", { className: "dsh-advisor-title", key: "title" }, t("settings.title")),
|
|
3434
|
+
h("div", { className: "dsh-advisor-desc", key: "desc" }, t("settings.desc")),
|
|
3435
|
+
]),
|
|
3436
|
+
errorBanner(),
|
|
3437
|
+
modeRow,
|
|
3438
|
+
];
|
|
3439
|
+
if (!showForm) {
|
|
3440
|
+
children.push(offNotice());
|
|
3441
|
+
} else {
|
|
3442
|
+
if (draft.mode === "off") children.push(offNotice());
|
|
3443
|
+
children.push(group("settings.group.basic", basicBody, "basic"));
|
|
3444
|
+
children.push(
|
|
3445
|
+
disclosure(
|
|
3446
|
+
"advanced",
|
|
3447
|
+
t("settings.group.advanced"),
|
|
3448
|
+
advancedBadge,
|
|
3449
|
+
advancedBody,
|
|
3450
|
+
advancedOpen,
|
|
3451
|
+
function toggleAdvanced() {
|
|
3452
|
+
setAdvancedOpen(!advancedOpen);
|
|
3453
|
+
},
|
|
3454
|
+
),
|
|
3455
|
+
);
|
|
3456
|
+
children.push(
|
|
3457
|
+
disclosure(
|
|
3458
|
+
"status",
|
|
3459
|
+
t("settings.group.status"),
|
|
3460
|
+
t("settings.status.calls").replace("{count}", formatCount(totals.calls)),
|
|
3461
|
+
statusBody,
|
|
3462
|
+
statusOpen,
|
|
3463
|
+
function toggleStatus() {
|
|
3464
|
+
setStatusOpen(!statusOpen);
|
|
3465
|
+
},
|
|
3466
|
+
),
|
|
3467
|
+
);
|
|
3468
|
+
}
|
|
3469
|
+
children.push(noticeNode);
|
|
3470
|
+
children.push(actionBar(dirty));
|
|
3471
|
+
|
|
2690
3472
|
return h(
|
|
2691
3473
|
"div",
|
|
2692
3474
|
{
|
|
@@ -2695,87 +3477,7 @@ window.__ModuleLoader__.load({
|
|
|
2695
3477
|
"data-advisor-settings": "",
|
|
2696
3478
|
role: "group",
|
|
2697
3479
|
},
|
|
2698
|
-
|
|
2699
|
-
h("div", { className: "dsh-advisor-head", key: "head" }, [
|
|
2700
|
-
h("div", { className: "dsh-advisor-title", key: "title" }, t("settings.title")),
|
|
2701
|
-
h("div", { className: "dsh-advisor-desc", key: "desc" }, t("settings.desc")),
|
|
2702
|
-
]),
|
|
2703
|
-
errorBanner(),
|
|
2704
|
-
group(
|
|
2705
|
-
"settings.group.basic",
|
|
2706
|
-
[
|
|
2707
|
-
radioField(
|
|
2708
|
-
"mode",
|
|
2709
|
-
"settings.mode",
|
|
2710
|
-
SETTINGS_MODES,
|
|
2711
|
-
"settings.mode.",
|
|
2712
|
-
draft.mode,
|
|
2713
|
-
chooseMode,
|
|
2714
|
-
"mode",
|
|
2715
|
-
),
|
|
2716
|
-
providerField(),
|
|
2717
|
-
modelField(),
|
|
2718
|
-
effortField(),
|
|
2719
|
-
selectField(
|
|
2720
|
-
"postAnswer",
|
|
2721
|
-
"settings.postAnswer",
|
|
2722
|
-
SETTINGS_POST_ANSWER,
|
|
2723
|
-
"settings.postAnswer.",
|
|
2724
|
-
draft.postAnswer,
|
|
2725
|
-
choosePostAnswer,
|
|
2726
|
-
"settings.postAnswer.hint",
|
|
2727
|
-
),
|
|
2728
|
-
switchField("advisorTools", "settings.advisorTools", "settings.advisorToolsHint"),
|
|
2729
|
-
],
|
|
2730
|
-
"basic",
|
|
2731
|
-
),
|
|
2732
|
-
group("settings.group.budget", budgetGroup, "budget"),
|
|
2733
|
-
group(
|
|
2734
|
-
"settings.group.privacy",
|
|
2735
|
-
[
|
|
2736
|
-
radioField(
|
|
2737
|
-
"scope",
|
|
2738
|
-
"settings.scope",
|
|
2739
|
-
SETTINGS_SCOPES,
|
|
2740
|
-
"settings.scope.",
|
|
2741
|
-
draft.privacyScope,
|
|
2742
|
-
chooseScope,
|
|
2743
|
-
"scope",
|
|
2744
|
-
),
|
|
2745
|
-
switchField("redact", "settings.privacy.redact", "settings.privacy.redactHint"),
|
|
2746
|
-
switchField("dedupe", "settings.privacy.dedupe", "settings.privacy.dedupeHint"),
|
|
2747
|
-
],
|
|
2748
|
-
"privacy",
|
|
2749
|
-
),
|
|
2750
|
-
group("settings.group.advanced", advancedGroup, "advanced"),
|
|
2751
|
-
noticeNode,
|
|
2752
|
-
h("div", { className: "dsh-advisor-actions", key: "actions" }, [
|
|
2753
|
-
h(
|
|
2754
|
-
"button",
|
|
2755
|
-
{
|
|
2756
|
-
className: "dsh-advisor-btn dsh-advisor-btn--primary",
|
|
2757
|
-
"data-advisor-save": "",
|
|
2758
|
-
disabled: busy === "save" || busy === "load",
|
|
2759
|
-
key: "save",
|
|
2760
|
-
onClick: save,
|
|
2761
|
-
type: "button",
|
|
2762
|
-
},
|
|
2763
|
-
busy === "save" ? t("settings.saving") : t("settings.save"),
|
|
2764
|
-
),
|
|
2765
|
-
h(
|
|
2766
|
-
"button",
|
|
2767
|
-
{
|
|
2768
|
-
className: "dsh-advisor-btn",
|
|
2769
|
-
"data-advisor-reload": "",
|
|
2770
|
-
disabled: busy === "load",
|
|
2771
|
-
key: "reload",
|
|
2772
|
-
onClick: reload,
|
|
2773
|
-
type: "button",
|
|
2774
|
-
},
|
|
2775
|
-
t("settings.reload"),
|
|
2776
|
-
),
|
|
2777
|
-
]),
|
|
2778
|
-
],
|
|
3480
|
+
children,
|
|
2779
3481
|
);
|
|
2780
3482
|
}
|
|
2781
3483
|
|
|
@@ -2787,22 +3489,22 @@ window.__ModuleLoader__.load({
|
|
|
2787
3489
|
// 而 slot 的 t() 只认这里注册的字典。两处必须同步(`test/locale-parity.test.js` 会守住)。
|
|
2788
3490
|
const LOCALE_EXTRA = {
|
|
2789
3491
|
zh: {
|
|
2790
|
-
|
|
2791
|
-
"settings.postAnswer": "
|
|
2792
|
-
"settings.postAnswer.
|
|
2793
|
-
"settings.postAnswer.
|
|
2794
|
-
|
|
3492
|
+
"settings.postAnswer": "回合结束后自动复查",
|
|
3493
|
+
"settings.postAnswer.off": "不跑",
|
|
3494
|
+
"settings.postAnswer.card": "只记录一行",
|
|
3495
|
+
"settings.postAnswer.hint":
|
|
3496
|
+
"每轮回答后自动复查一次;只记录建议,不插回对话。会产生额外调用和费用。",
|
|
2795
3497
|
"settings.advisorTools": "允许顾问读文件核实",
|
|
2796
3498
|
"settings.advisorToolsHint":
|
|
2797
|
-
"
|
|
2798
|
-
"settings.budget.workspaceMaxCallsPerDay": "
|
|
2799
|
-
"settings.budget.workspaceMaxCostPerDayUsd": "
|
|
3499
|
+
"允许顾问读取工作目录里的文件来核实结论(最多 5 个、只读);会多一次模型调用。",
|
|
3500
|
+
"settings.budget.workspaceMaxCallsPerDay": "工作区每日调用上限",
|
|
3501
|
+
"settings.budget.workspaceMaxCostPerDayUsd": "工作区每日预算",
|
|
2800
3502
|
"settings.budget.workspaceHint": "工作区级,跨会话累计、按本地日重置",
|
|
2801
3503
|
"settings.budget.poolLine": "工作区今日:{calls} 次 · ≈{cost}",
|
|
2802
3504
|
"settings.budget.priceSource.builtin": "单价来源:内置参考价",
|
|
2803
3505
|
"settings.budget.priceSource.settings": "单价来源:你设置的",
|
|
2804
3506
|
"settings.budget.priceSource.none": "单价来源:未配置(只记 token)",
|
|
2805
|
-
"settings.advanced.allowedModels": "模型白名单
|
|
3507
|
+
"settings.advanced.allowedModels": "模型白名单",
|
|
2806
3508
|
"settings.advanced.allowedModelsHint": "留空=不限制;可写 provider/model 或裸 model id",
|
|
2807
3509
|
"settings.advanced.allowedModelsPlaceholder": "例如 deepseek/deepseek-chat, gpt-4o",
|
|
2808
3510
|
"settings.preview": "发送预览",
|
|
@@ -2818,26 +3520,119 @@ window.__ModuleLoader__.load({
|
|
|
2818
3520
|
"settings.confirm.done": "已确认 {provider}",
|
|
2819
3521
|
"settings.error.preview": "预览失败,稍后重试",
|
|
2820
3522
|
"settings.error.confirm": "确认失败,稍后重试",
|
|
3523
|
+
"settings.tracePrompt": "记录发送内容",
|
|
3524
|
+
"settings.tracePrompt.preview": "首尾预览",
|
|
3525
|
+
"settings.tracePrompt.off": "不记录",
|
|
3526
|
+
"settings.tracePrompt.hint":
|
|
3527
|
+
"在会话记录里保留本次实际发送文本的首尾各 2,000 字符(脱敏后);关掉后只记元数据。发送前脱敏关闭时,预览也会包含原文。",
|
|
3528
|
+
"settings.help.defaultPreview": "默认:首尾预览",
|
|
3529
|
+
"tail.trace.preview": "查看发送内容",
|
|
3530
|
+
"tail.trace.previewHide": "收起发送内容",
|
|
3531
|
+
"tail.trace.previewTruncated": "实际发送(脱敏后,首尾各 2,000 字符;共 {chars} 字符)",
|
|
3532
|
+
"tail.trace.previewFull": "实际发送(脱敏后,共 {chars} 字符)",
|
|
3533
|
+
"tail.trace.previewNone":
|
|
3534
|
+
"这条记录没有保存发送内容(可能是旧记录,或已在高级设置里关闭记录)。",
|
|
3535
|
+
"settings.desc": "基础设置开箱即用;高级项默认折叠。保存后的改动对下一次徵询生效。",
|
|
3536
|
+
"settings.group.basic": "基础设置",
|
|
3537
|
+
"settings.group.budget": "预算与限额",
|
|
3538
|
+
"settings.group.advanced": "高级设置",
|
|
3539
|
+
"settings.mode.off": "关闭",
|
|
3540
|
+
"settings.mode.shadow": "影子",
|
|
3541
|
+
"settings.mode.advisory": "顾问",
|
|
3542
|
+
"settings.mode.shadowHint": "会调用顾问并记账,但不会把建议放进对话;适合先观察。",
|
|
3543
|
+
"settings.mode.advisoryHint": "会徵询顾问,并把建议交给模型;模型可以采纳或忽略。",
|
|
3544
|
+
"settings.provider": "服务商",
|
|
3545
|
+
"settings.model": "模型",
|
|
3546
|
+
"settings.budget.maxCallsPerTurn": "每回合调用上限",
|
|
3547
|
+
"settings.budget.maxCallsPerSession": "每会话调用上限",
|
|
3548
|
+
"settings.budget.maxCallsPerHour": "每小时调用上限",
|
|
3549
|
+
"settings.budget.maxCostPerDayUsd": "每日预算",
|
|
3550
|
+
"settings.budget.priceInputPerMTok": "输入单价",
|
|
3551
|
+
"settings.budget.priceOutputPerMTok": "输出单价",
|
|
3552
|
+
"settings.scope.off": "不发送",
|
|
3553
|
+
"settings.scope.summary": "摘要",
|
|
3554
|
+
"settings.scope.full": "完整",
|
|
3555
|
+
"settings.scope.summaryHint": "只发一段约 300 字的会话摘要,不发文件全文。",
|
|
3556
|
+
"settings.scope.fullHint": "发送完整上下文,按输入上限截断。",
|
|
3557
|
+
"settings.privacy.redact": "发送前脱敏",
|
|
3558
|
+
"settings.privacy.redactHint": "自动遮掉常见的密钥格式;不能保证全部遮住。",
|
|
3559
|
+
"settings.privacy.dedupe": "影子模式去重",
|
|
3560
|
+
"settings.privacy.dedupeHint": "影子模式下,相同的建议只记一次。",
|
|
3561
|
+
"settings.advanced.maxTokens": "输出上限",
|
|
3562
|
+
"settings.advanced.temperature": "随机性",
|
|
3563
|
+
"settings.advanced.temperatureHint": "留空 = 由模型决定;范围 0–2。",
|
|
3564
|
+
"settings.advanced.maxInputChars": "输入上限",
|
|
3565
|
+
"settings.advanced.sessionCap": "建议条数上限",
|
|
3566
|
+
"settings.off.title": "顾问已关闭",
|
|
3567
|
+
"settings.off.desc": "不会调用顾问,也不产生费用。",
|
|
3568
|
+
"settings.off.unconfigured": "还没有选择顾问模型。点「配置顾问」选择服务商和模型。",
|
|
3569
|
+
"settings.off.configured": "已配置:{provider} / {model}。启用后生效。",
|
|
3570
|
+
"settings.off.configure": "配置顾问",
|
|
3571
|
+
"settings.off.collapse": "收起配置",
|
|
3572
|
+
"settings.dirty": "有未保存的改动",
|
|
3573
|
+
"settings.advanced.intro": "以下都有合理默认值,通常不用改;改过的项会显示在标题上。",
|
|
3574
|
+
"settings.advanced.defaults": "默认值",
|
|
3575
|
+
"settings.advanced.changed": "{count} 项已修改",
|
|
3576
|
+
"settings.advanced.reset": "恢复默认",
|
|
3577
|
+
"settings.advanced.resetHint": "只重置高级字段,不影响模式、服务商、模型和隐私。",
|
|
3578
|
+
"settings.advanced.resetDone": "高级设置已恢复默认(尚未保存)。",
|
|
3579
|
+
"settings.advanced.more": "还有 {fields} 等冷门项;需要时可直接编辑设置文件。",
|
|
3580
|
+
"settings.advanced.moreFields": "tiers、pairingEnforcement、timeoutMs、immuneTurns",
|
|
3581
|
+
"settings.advanced.copyPath": "复制路径",
|
|
3582
|
+
"settings.advanced.copied": "已复制",
|
|
3583
|
+
"settings.advanced.copyFailed": "复制失败,请手动复制。",
|
|
3584
|
+
"settings.advanced.pathUnknown": "宿主没有返回设置文件路径。",
|
|
3585
|
+
"settings.advanced.dailyBudgetNote":
|
|
3586
|
+
"每日预算在基础设置里;这里是调用次数和工作区级限额。",
|
|
3587
|
+
"settings.group.model": "顾问模型",
|
|
3588
|
+
"settings.group.spend": "预算",
|
|
3589
|
+
"settings.group.limits": "调用限额",
|
|
3590
|
+
"settings.group.money": "单价",
|
|
3591
|
+
"settings.group.generation": "生成参数",
|
|
3592
|
+
"settings.group.delivery": "投递与行为",
|
|
3593
|
+
"settings.group.more": "更多",
|
|
3594
|
+
"settings.group.status": "状态与诊断",
|
|
3595
|
+
"settings.basic.budgetHint": "0 = 不限;默认 0,范围 0–10000。更细的限额在高级设置里。",
|
|
3596
|
+
"settings.budget.maxCostHint": "每天最多花多少钱;0 = 不限。只有填了单价才会计算金额。",
|
|
3597
|
+
"settings.advanced.maxTokensHint": "单次回答最多生成多少 token;越大越贵。",
|
|
3598
|
+
"settings.advanced.maxInputCharsHint":
|
|
3599
|
+
"一次最多发送多少字符的会话内容;超出会保留首尾、省略中间。",
|
|
3600
|
+
"settings.advanced.sessionCapHint": "一个会话最多展示几条建议;到顶后只保留 blocker 级。",
|
|
3601
|
+
"settings.help.calls": "超过上限就跳过本次徵询;0 = 不限。",
|
|
3602
|
+
"settings.help.tech": "技术名:{key}",
|
|
3603
|
+
"settings.help.open": "查看 {field} 的说明",
|
|
3604
|
+
"settings.help.defaultOn": "默认:开",
|
|
3605
|
+
"settings.help.defaultOff": "默认:关",
|
|
3606
|
+
"settings.help.defaultOffOption": "默认:不跑",
|
|
3607
|
+
"settings.help.defaultEmpty": "默认:不限制",
|
|
3608
|
+
"settings.help.defaultNotSent": "默认:不传(由模型决定)",
|
|
3609
|
+
"settings.unit.usd": "USD",
|
|
3610
|
+
"settings.unit.usdPerMTok": "USD / 百万 token",
|
|
3611
|
+
"settings.unit.tokens": "token",
|
|
3612
|
+
"settings.unit.chars": "字符",
|
|
3613
|
+
"settings.unit.calls": "次",
|
|
3614
|
+
"settings.unit.items": "条",
|
|
3615
|
+
"settings.paths.settings": "设置文件:{path}",
|
|
3616
|
+
"settings.paths.ledger": "账本:{path}",
|
|
2821
3617
|
},
|
|
2822
3618
|
en: {
|
|
2823
|
-
|
|
2824
|
-
"settings.postAnswer": "
|
|
2825
|
-
"settings.postAnswer.
|
|
2826
|
-
"settings.postAnswer.card": "card (record one line)",
|
|
3619
|
+
"settings.postAnswer": "Auto-review after each turn",
|
|
3620
|
+
"settings.postAnswer.off": "Do not run",
|
|
3621
|
+
"settings.postAnswer.card": "Record one line",
|
|
2827
3622
|
"settings.postAnswer.hint":
|
|
2828
|
-
"
|
|
3623
|
+
"Runs the advisor once after each answer; records advice only, never inserts it into the conversation. Costs an extra call.",
|
|
2829
3624
|
"settings.advisorTools": "Let the advisor read files",
|
|
2830
3625
|
"settings.advisorToolsHint":
|
|
2831
|
-
"
|
|
2832
|
-
"settings.budget.workspaceMaxCallsPerDay": "Workspace
|
|
2833
|
-
"settings.budget.workspaceMaxCostPerDayUsd": "Workspace daily budget
|
|
3626
|
+
"Lets the advisor read files in the working directory to verify conclusions (up to 5 files, read-only); costs one extra model call.",
|
|
3627
|
+
"settings.budget.workspaceMaxCallsPerDay": "Workspace calls per day",
|
|
3628
|
+
"settings.budget.workspaceMaxCostPerDayUsd": "Workspace daily budget",
|
|
2834
3629
|
"settings.budget.workspaceHint":
|
|
2835
3630
|
"Workspace-wide: shared across sessions, resets on the local day",
|
|
2836
3631
|
"settings.budget.poolLine": "Workspace today: {calls} calls · ≈{cost}",
|
|
2837
3632
|
"settings.budget.priceSource.builtin": "Price source: built-in reference",
|
|
2838
3633
|
"settings.budget.priceSource.settings": "Price source: yours",
|
|
2839
3634
|
"settings.budget.priceSource.none": "Price source: not set (tokens only)",
|
|
2840
|
-
"settings.advanced.allowedModels": "Model allowlist
|
|
3635
|
+
"settings.advanced.allowedModels": "Model allowlist",
|
|
2841
3636
|
"settings.advanced.allowedModelsHint":
|
|
2842
3637
|
"Empty = no limit; accepts provider/model or a bare model id",
|
|
2843
3638
|
"settings.advanced.allowedModelsPlaceholder": "e.g. deepseek/deepseek-chat, gpt-4o",
|
|
@@ -2855,6 +3650,112 @@ window.__ModuleLoader__.load({
|
|
|
2855
3650
|
"settings.confirm.done": "Confirmed {provider}",
|
|
2856
3651
|
"settings.error.preview": "Preview failed — try again later",
|
|
2857
3652
|
"settings.error.confirm": "Confirmation failed — try again later",
|
|
3653
|
+
"settings.tracePrompt": "Keep sent content",
|
|
3654
|
+
"settings.tracePrompt.preview": "Head/tail preview",
|
|
3655
|
+
"settings.tracePrompt.off": "Do not record",
|
|
3656
|
+
"settings.tracePrompt.hint":
|
|
3657
|
+
"Stores the first and last 2,000 characters of the text actually sent (after redaction) in the session record; off stores metadata only. If redaction is off, the preview contains raw text.",
|
|
3658
|
+
"settings.help.defaultPreview": "Default: head/tail preview",
|
|
3659
|
+
"tail.trace.preview": "View sent content",
|
|
3660
|
+
"tail.trace.previewHide": "Hide sent content",
|
|
3661
|
+
"tail.trace.previewTruncated": "Sent (redacted; first/last 2,000 of {chars} chars)",
|
|
3662
|
+
"tail.trace.previewFull": "Sent (redacted; {chars} chars)",
|
|
3663
|
+
"tail.trace.previewNone":
|
|
3664
|
+
"No sent content saved for this record (older record, or disabled in Advanced).",
|
|
3665
|
+
"settings.desc":
|
|
3666
|
+
"The basics work out of the box; advanced knobs stay folded. Saved changes apply to the next consultation.",
|
|
3667
|
+
"settings.group.basic": "Basics",
|
|
3668
|
+
"settings.group.budget": "Budgets & limits",
|
|
3669
|
+
"settings.group.advanced": "Advanced",
|
|
3670
|
+
"settings.mode.off": "Off",
|
|
3671
|
+
"settings.mode.shadow": "Shadow",
|
|
3672
|
+
"settings.mode.advisory": "Advisory",
|
|
3673
|
+
"settings.mode.shadowHint":
|
|
3674
|
+
"Calls the advisor and records it, but never puts advice into the conversation — useful for observing first.",
|
|
3675
|
+
"settings.mode.advisoryHint":
|
|
3676
|
+
"Calls the advisor and hands the advice to the model; the model may take it or ignore it.",
|
|
3677
|
+
"settings.provider": "Provider",
|
|
3678
|
+
"settings.model": "Model",
|
|
3679
|
+
"settings.budget.maxCallsPerTurn": "Calls per turn",
|
|
3680
|
+
"settings.budget.maxCallsPerSession": "Calls per session",
|
|
3681
|
+
"settings.budget.maxCallsPerHour": "Calls per hour",
|
|
3682
|
+
"settings.budget.maxCostPerDayUsd": "Daily budget",
|
|
3683
|
+
"settings.budget.priceInputPerMTok": "Input price",
|
|
3684
|
+
"settings.budget.priceOutputPerMTok": "Output price",
|
|
3685
|
+
"settings.scope.off": "None",
|
|
3686
|
+
"settings.scope.summary": "Summary",
|
|
3687
|
+
"settings.scope.full": "Full",
|
|
3688
|
+
"settings.scope.summaryHint":
|
|
3689
|
+
"Sends a ~300-character conversation summary; no file contents.",
|
|
3690
|
+
"settings.scope.fullHint": "Sends the full context, truncated to the input limit.",
|
|
3691
|
+
"settings.privacy.redact": "Redact before sending",
|
|
3692
|
+
"settings.privacy.redactHint":
|
|
3693
|
+
"Masks common key formats; it cannot guarantee every secret is caught.",
|
|
3694
|
+
"settings.privacy.dedupe": "Dedupe in shadow mode",
|
|
3695
|
+
"settings.privacy.dedupeHint": "In shadow mode, the same advice is recorded only once.",
|
|
3696
|
+
"settings.advanced.maxTokens": "Output limit",
|
|
3697
|
+
"settings.advanced.temperature": "Randomness",
|
|
3698
|
+
"settings.advanced.temperatureHint": "Empty = let the model decide; range 0–2.",
|
|
3699
|
+
"settings.advanced.maxInputChars": "Input limit",
|
|
3700
|
+
"settings.advanced.sessionCap": "Advice items per session",
|
|
3701
|
+
"settings.off.title": "Advisor is off",
|
|
3702
|
+
"settings.off.desc": "It never calls the advisor and never spends.",
|
|
3703
|
+
"settings.off.unconfigured":
|
|
3704
|
+
"No advisor model selected yet. Choose “Configure advisor” to pick a provider and model.",
|
|
3705
|
+
"settings.off.configured": "Configured: {provider} / {model}. Takes effect when enabled.",
|
|
3706
|
+
"settings.off.configure": "Configure advisor",
|
|
3707
|
+
"settings.off.collapse": "Hide configuration",
|
|
3708
|
+
"settings.dirty": "Unsaved changes",
|
|
3709
|
+
"settings.advanced.intro":
|
|
3710
|
+
"Sensible defaults; you normally do not need to change these. Modified items show on the heading.",
|
|
3711
|
+
"settings.advanced.defaults": "Defaults",
|
|
3712
|
+
"settings.advanced.changed": "{count} changed",
|
|
3713
|
+
"settings.advanced.reset": "Reset to defaults",
|
|
3714
|
+
"settings.advanced.resetHint":
|
|
3715
|
+
"Only resets advanced fields; mode, provider, model and privacy stay.",
|
|
3716
|
+
"settings.advanced.resetDone": "Advanced settings restored to defaults (not saved yet).",
|
|
3717
|
+
"settings.advanced.more":
|
|
3718
|
+
"Rarely changed keys such as {fields} can be edited directly in the settings file.",
|
|
3719
|
+
"settings.advanced.moreFields": "tiers, pairingEnforcement, timeoutMs, immuneTurns",
|
|
3720
|
+
"settings.advanced.copyPath": "Copy path",
|
|
3721
|
+
"settings.advanced.copied": "Copied",
|
|
3722
|
+
"settings.advanced.copyFailed": "Copy failed — copy it manually.",
|
|
3723
|
+
"settings.advanced.pathUnknown": "The host did not return the settings file path.",
|
|
3724
|
+
"settings.advanced.dailyBudgetNote":
|
|
3725
|
+
"The daily budget is under Basics; this section has call and workspace-level limits.",
|
|
3726
|
+
"settings.group.model": "Advisor model",
|
|
3727
|
+
"settings.group.spend": "Budget",
|
|
3728
|
+
"settings.group.limits": "Call limits",
|
|
3729
|
+
"settings.group.money": "Prices",
|
|
3730
|
+
"settings.group.generation": "Generation",
|
|
3731
|
+
"settings.group.delivery": "Delivery & behavior",
|
|
3732
|
+
"settings.group.more": "More",
|
|
3733
|
+
"settings.group.status": "Status & diagnostics",
|
|
3734
|
+
"settings.basic.budgetHint":
|
|
3735
|
+
"0 = unlimited; default 0, range 0–10000. Finer limits are under Advanced.",
|
|
3736
|
+
"settings.budget.maxCostHint":
|
|
3737
|
+
"Maximum spend per day; 0 = unlimited. Only counted when prices are set.",
|
|
3738
|
+
"settings.advanced.maxTokensHint": "Maximum output tokens per answer; higher costs more.",
|
|
3739
|
+
"settings.advanced.maxInputCharsHint":
|
|
3740
|
+
"Maximum characters of conversation sent per call; excess in the middle is elided, head and tail kept.",
|
|
3741
|
+
"settings.advanced.sessionCapHint":
|
|
3742
|
+
"Maximum advice items shown per session; once reached only blocker items get through.",
|
|
3743
|
+
"settings.help.calls": "Above the limit, the consultation is skipped; 0 = unlimited.",
|
|
3744
|
+
"settings.help.tech": "Key: {key}",
|
|
3745
|
+
"settings.help.open": "Show help for {field}",
|
|
3746
|
+
"settings.help.defaultOn": "Default: on",
|
|
3747
|
+
"settings.help.defaultOff": "Default: off",
|
|
3748
|
+
"settings.help.defaultOffOption": "Default: off",
|
|
3749
|
+
"settings.help.defaultEmpty": "Default: no limit",
|
|
3750
|
+
"settings.help.defaultNotSent": "Default: not sent (model default)",
|
|
3751
|
+
"settings.unit.usd": "USD",
|
|
3752
|
+
"settings.unit.usdPerMTok": "USD / 1M tokens",
|
|
3753
|
+
"settings.unit.tokens": "tokens",
|
|
3754
|
+
"settings.unit.chars": "chars",
|
|
3755
|
+
"settings.unit.calls": "calls",
|
|
3756
|
+
"settings.unit.items": "items",
|
|
3757
|
+
"settings.paths.settings": "Settings file: {path}",
|
|
3758
|
+
"settings.paths.ledger": "Ledger: {path}",
|
|
2858
3759
|
},
|
|
2859
3760
|
};
|
|
2860
3761
|
|
|
@@ -3403,6 +4304,9 @@ window.__ModuleLoader__.load({
|
|
|
3403
4304
|
interpretSetModel: interpretSetModel,
|
|
3404
4305
|
clampInt: clampInt,
|
|
3405
4306
|
clampFloat: clampFloat,
|
|
4307
|
+
clampMoney: clampMoney,
|
|
4308
|
+
formatMoneyInput: formatMoneyInput,
|
|
4309
|
+
normalizeSettingsView: normalizeSettingsView,
|
|
3406
4310
|
normalizeOptions: normalizeOptions,
|
|
3407
4311
|
normalizeModels: normalizeModels,
|
|
3408
4312
|
normalizeModelInfo: normalizeModelInfo,
|
|
@@ -3412,6 +4316,9 @@ window.__ModuleLoader__.load({
|
|
|
3412
4316
|
diffSettings: diffSettings,
|
|
3413
4317
|
interpretUpdate: interpretUpdate,
|
|
3414
4318
|
normalizeAdviceItems: normalizeAdviceItems,
|
|
4319
|
+
formatClock: formatClock,
|
|
4320
|
+
traceTextOf: traceTextOf,
|
|
4321
|
+
triggerLabel: triggerLabel,
|
|
3415
4322
|
truncateText: truncateText,
|
|
3416
4323
|
turnNumberOf: turnNumberOf,
|
|
3417
4324
|
slotTurnNumber: slotTurnNumber,
|