@kangyishuai/dsh-advisor 0.6.2 → 0.6.3
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 +94 -73
- package/README.zh-CN.md +106 -79
- package/lib/adoption.js +12 -3
- package/lib/budget.js +36 -33
- package/lib/call.js +39 -18
- package/lib/client.js +381 -80
- package/lib/command-text.js +125 -0
- package/lib/day.js +44 -0
- package/lib/deadline.js +94 -0
- package/lib/decisions.js +162 -75
- package/lib/fs-atomic.js +106 -0
- package/lib/guard.js +14 -5
- package/lib/ledger.js +65 -77
- package/lib/messages.js +108 -0
- package/lib/redact.js +15 -2
- package/lib/service.js +197 -139
- package/lib/settings.js +2 -2
- package/lib/tool-result.js +46 -0
- package/lib/tool-schema.js +4 -2
- package/lib/transcript.js +1 -1
- package/locale/en.json +17 -1
- package/locale/zh.json +24 -8
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -24,6 +24,13 @@ window.__ModuleLoader__.load({
|
|
|
24
24
|
let NS = "advisor";
|
|
25
25
|
/** 插件标识:样式标签的归属,桌面端只读回归靠 style[data-plugin] 判断 client 半已加载。 */
|
|
26
26
|
let PLUGIN_ID = "@kangyishuai/dsh-advisor";
|
|
27
|
+
/** 命令名:与 host 半 `commands.register()` 的 name 一致(commandview 的 entryKey)。 */
|
|
28
|
+
let COMMAND_NAME = "advisor";
|
|
29
|
+
/**
|
|
30
|
+
* 最近一条命令回执(只给 `__test` 断言用;不参与渲染,也不跨会话累积)。
|
|
31
|
+
* @type {{ tone: "ok" | "error", text: string } | null}
|
|
32
|
+
*/
|
|
33
|
+
let lastCommandReceipt = null;
|
|
27
34
|
/** 轻量提示停留时间;到点后把自己清掉。 */
|
|
28
35
|
let TOAST_MS = 4000;
|
|
29
36
|
/**
|
|
@@ -57,14 +64,13 @@ window.__ModuleLoader__.load({
|
|
|
57
64
|
"search.empty": "还没有可选的顾问模型",
|
|
58
65
|
"search.noResults": "没有匹配的模型",
|
|
59
66
|
"effort.auto": "自动",
|
|
60
|
-
"toast.applied": "顾问已设为 {route}(思考档 {effort}
|
|
67
|
+
"toast.applied": "顾问已设为 {route}(思考档 {effort}),下一次征询生效",
|
|
61
68
|
"toast.off": "顾问已关闭,随时可用 /advisor 重新开启",
|
|
62
69
|
"toast.stale": "这项选择已过期,请重新打开 /advisor",
|
|
63
70
|
"error.failed": "设置失败,请重试",
|
|
64
71
|
"error.unreachable": "连不上宿主,稍后重试或运行 /advisor doctor",
|
|
65
72
|
"error.malformed": "宿主返回了无法识别的结果,运行 /advisor doctor 查看诊断",
|
|
66
73
|
"settings.title": "顾问",
|
|
67
|
-
"settings.desc": "设置顾问模式、路由、预算与隐私;保存后的改动对下一次徵询生效。",
|
|
68
74
|
"settings.aria": "顾问设置",
|
|
69
75
|
"settings.loading": "正在读取宿主设置…",
|
|
70
76
|
"settings.retry": "重试",
|
|
@@ -73,10 +79,7 @@ window.__ModuleLoader__.load({
|
|
|
73
79
|
"settings.saving": "保存中…",
|
|
74
80
|
"settings.saved": "已保存",
|
|
75
81
|
"settings.noChanges": "没有改动",
|
|
76
|
-
"settings.group.basic": "基础",
|
|
77
|
-
"settings.group.budget": "预算",
|
|
78
82
|
"settings.group.privacy": "隐私",
|
|
79
|
-
"settings.group.advanced": "高级与状态",
|
|
80
83
|
"settings.group.more": "更多设置",
|
|
81
84
|
"settings.nav": "顾问",
|
|
82
85
|
"settings.summary.mode": "模式",
|
|
@@ -85,20 +88,11 @@ window.__ModuleLoader__.load({
|
|
|
85
88
|
"settings.route.unset": "还没选",
|
|
86
89
|
"settings.budget.unlimited": "不限",
|
|
87
90
|
"settings.mode": "模式",
|
|
88
|
-
"settings.mode.
|
|
89
|
-
"settings.mode.offHint": "不发起任何徵询,也不产生费用。",
|
|
90
|
-
"settings.mode.shadow": "影子(shadow)",
|
|
91
|
-
"settings.mode.shadowHint":
|
|
92
|
-
"只记账,不回灌模型:仍会调用顾问并记录结果,但建议不会进入模型上下文。",
|
|
93
|
-
"settings.mode.advisory": "顾问(advisory)",
|
|
94
|
-
"settings.mode.advisoryHint":
|
|
95
|
-
"正常徵询:顾问建议以工具卡回到模型上下文,模型可以采纳或忽略。",
|
|
96
|
-
"settings.provider": "provider",
|
|
91
|
+
"settings.mode.offHint": "不发起任何征询,也不产生费用。",
|
|
97
92
|
"settings.provider.empty": "(未选择)",
|
|
98
93
|
"settings.provider.declared": "自定义",
|
|
99
94
|
"settings.provider.none": "宿主没有返回任何路由(llm 服务不可用?)",
|
|
100
95
|
"settings.provider.stale": "(当前值不在路由清单)",
|
|
101
|
-
"settings.model": "model",
|
|
102
96
|
"settings.model.empty": "(未选择)",
|
|
103
97
|
"settings.model.manual": "手填 model id",
|
|
104
98
|
"settings.model.manualHint": "列表里没有时可直接手填;手填不校验是否在目录中。",
|
|
@@ -112,31 +106,12 @@ window.__ModuleLoader__.load({
|
|
|
112
106
|
"settings.effort.pickModel": "先选 model",
|
|
113
107
|
"settings.effort.count": "模型声明了 {count} 个思考档",
|
|
114
108
|
"settings.effort.stale": "(当前值不在模型声明里)",
|
|
115
|
-
"settings.budget.maxCallsPerTurn": "每回合最多调用",
|
|
116
|
-
"settings.budget.maxCallsPerSession": "每会话最多调用",
|
|
117
|
-
"settings.budget.maxCallsPerHour": "每小时最多调用",
|
|
118
|
-
"settings.budget.priceInputPerMTok": "输入单价(USD / 百万 token)",
|
|
119
|
-
"settings.budget.priceOutputPerMTok": "输出单价(USD / 百万 token)",
|
|
120
109
|
"settings.budget.range": "默认 {default} · 范围 {min}–{max}",
|
|
121
110
|
"settings.budget.rangeUnlimited": "默认 {default} · 范围 {min}–{max}(0 = 不限)",
|
|
122
111
|
"settings.budget.priceHint": "0 = 不算钱,只统计 token",
|
|
123
112
|
"settings.scope": "发送范围",
|
|
124
|
-
"settings.scope.off": "off",
|
|
125
113
|
"settings.scope.offHint": "不发送任何会话内容。",
|
|
126
|
-
"settings.scope.summary": "summary",
|
|
127
|
-
"settings.scope.summaryHint": "只发 300 字符的宿主注入上下文(不含文件全文)。",
|
|
128
|
-
"settings.scope.full": "full",
|
|
129
|
-
"settings.scope.fullHint": "发送完整上下文,按 maxInputChars 截断。",
|
|
130
|
-
"settings.privacy.redact": "启发式脱敏",
|
|
131
|
-
"settings.privacy.redactHint": "尽力而为的模式替换,不是密钥扫描器,仍可能漏检。",
|
|
132
|
-
"settings.privacy.dedupe": "影子路径去重",
|
|
133
|
-
"settings.privacy.dedupeHint": "只影响 shadow 路径:相同结论不重复记账。",
|
|
134
|
-
"settings.advanced.maxTokens": "输出上限 maxTokens",
|
|
135
|
-
"settings.advanced.temperature": "temperature",
|
|
136
|
-
"settings.advanced.temperatureHint": "留空 = 不传,由 adapter 决定 · 范围 0–2",
|
|
137
114
|
"settings.advanced.temperatureEmpty": "不传",
|
|
138
|
-
"settings.advanced.maxInputChars": "输入上限 maxInputChars(字符)",
|
|
139
|
-
"settings.advanced.sessionCap": "单会话投递上限 sessionCap",
|
|
140
115
|
"settings.status.title": "状态摘要",
|
|
141
116
|
"settings.status.calls": "累计调用 {count} 次",
|
|
142
117
|
"settings.status.tokens": "in {input} / out {output} token",
|
|
@@ -167,7 +142,7 @@ window.__ModuleLoader__.load({
|
|
|
167
142
|
"tail.anchors": "证据锚点未对上({checked} 条)",
|
|
168
143
|
"tail.downgraded": "严重度已降级",
|
|
169
144
|
"tail.aria": "顾问建议(点击展开或收起)",
|
|
170
|
-
"tail.trace.label": "
|
|
145
|
+
"tail.trace.label": "本次征询",
|
|
171
146
|
"tail.trace.sep": ":",
|
|
172
147
|
"tail.trace.chars": "{chars} 字符",
|
|
173
148
|
"tail.trigger.tool": "模型发起",
|
|
@@ -207,8 +182,6 @@ window.__ModuleLoader__.load({
|
|
|
207
182
|
"error.unreachable": "Cannot reach the host — try again later or run /advisor doctor",
|
|
208
183
|
"error.malformed": "The host returned an unrecognized result — run /advisor doctor",
|
|
209
184
|
"settings.title": "Advisor",
|
|
210
|
-
"settings.desc":
|
|
211
|
-
"Set the advisor mode, route, budgets and privacy. Saved changes apply to the next consultation.",
|
|
212
185
|
"settings.aria": "Advisor settings",
|
|
213
186
|
"settings.loading": "Reading host settings…",
|
|
214
187
|
"settings.retry": "Retry",
|
|
@@ -217,10 +190,7 @@ window.__ModuleLoader__.load({
|
|
|
217
190
|
"settings.saving": "Saving…",
|
|
218
191
|
"settings.saved": "Saved",
|
|
219
192
|
"settings.noChanges": "No changes",
|
|
220
|
-
"settings.group.basic": "Basics",
|
|
221
|
-
"settings.group.budget": "Budgets",
|
|
222
193
|
"settings.group.privacy": "Privacy",
|
|
223
|
-
"settings.group.advanced": "Advanced & status",
|
|
224
194
|
"settings.group.more": "More settings",
|
|
225
195
|
"settings.nav": "Advisor",
|
|
226
196
|
"settings.summary.mode": "Mode",
|
|
@@ -229,20 +199,11 @@ window.__ModuleLoader__.load({
|
|
|
229
199
|
"settings.route.unset": "not chosen",
|
|
230
200
|
"settings.budget.unlimited": "Unlimited",
|
|
231
201
|
"settings.mode": "Mode",
|
|
232
|
-
"settings.mode.off": "Off",
|
|
233
202
|
"settings.mode.offHint": "Never consult the advisor and never spend.",
|
|
234
|
-
"settings.mode.shadow": "Shadow",
|
|
235
|
-
"settings.mode.shadowHint":
|
|
236
|
-
"Record only, never feed back to the model: the advisor is still called and logged, but its advice never enters the model context.",
|
|
237
|
-
"settings.mode.advisory": "Advisory",
|
|
238
|
-
"settings.mode.advisoryHint":
|
|
239
|
-
"Normal consultation: advice returns to the model context as a tool card the model may follow or ignore.",
|
|
240
|
-
"settings.provider": "Provider",
|
|
241
203
|
"settings.provider.empty": "(none)",
|
|
242
204
|
"settings.provider.declared": "custom",
|
|
243
205
|
"settings.provider.none": "The host returned no routes (llm service unavailable?)",
|
|
244
206
|
"settings.provider.stale": "(current value is not in the route list)",
|
|
245
|
-
"settings.model": "Model",
|
|
246
207
|
"settings.model.empty": "(none)",
|
|
247
208
|
"settings.model.manual": "Type a model id",
|
|
248
209
|
"settings.model.manualHint":
|
|
@@ -257,34 +218,12 @@ window.__ModuleLoader__.load({
|
|
|
257
218
|
"settings.effort.pickModel": "Pick a model first",
|
|
258
219
|
"settings.effort.count": "The model declares {count} reasoning efforts",
|
|
259
220
|
"settings.effort.stale": "(current value is not declared by the model)",
|
|
260
|
-
"settings.budget.maxCallsPerTurn": "Max calls per turn",
|
|
261
|
-
"settings.budget.maxCallsPerSession": "Max calls per session",
|
|
262
|
-
"settings.budget.maxCallsPerHour": "Max calls per hour",
|
|
263
|
-
"settings.budget.priceInputPerMTok": "Input price (USD / 1M tokens)",
|
|
264
|
-
"settings.budget.priceOutputPerMTok": "Output price (USD / 1M tokens)",
|
|
265
221
|
"settings.budget.range": "default {default} · range {min}–{max}",
|
|
266
222
|
"settings.budget.rangeUnlimited": "default {default} · range {min}–{max} (0 = unlimited)",
|
|
267
223
|
"settings.budget.priceHint": "0 = do not price tokens",
|
|
268
224
|
"settings.scope": "Send scope",
|
|
269
|
-
"settings.scope.off": "off",
|
|
270
225
|
"settings.scope.offHint": "Send no conversation content.",
|
|
271
|
-
"settings.scope.summary": "summary",
|
|
272
|
-
"settings.scope.summaryHint":
|
|
273
|
-
"Send only the host-injected 300-character context (no file bodies).",
|
|
274
|
-
"settings.scope.full": "full",
|
|
275
|
-
"settings.scope.fullHint": "Send the full context, truncated to maxInputChars.",
|
|
276
|
-
"settings.privacy.redact": "Heuristic redaction",
|
|
277
|
-
"settings.privacy.redactHint":
|
|
278
|
-
"Best-effort pattern replacement, not a secret scanner; leaks are still possible.",
|
|
279
|
-
"settings.privacy.dedupe": "Shadow-path dedupe",
|
|
280
|
-
"settings.privacy.dedupeHint":
|
|
281
|
-
"Affects the shadow path only: identical advice is not recorded twice.",
|
|
282
|
-
"settings.advanced.maxTokens": "Output cap maxTokens",
|
|
283
|
-
"settings.advanced.temperature": "temperature",
|
|
284
|
-
"settings.advanced.temperatureHint": "Empty = not sent, decided by the adapter · range 0–2",
|
|
285
226
|
"settings.advanced.temperatureEmpty": "not sent",
|
|
286
|
-
"settings.advanced.maxInputChars": "Input cap maxInputChars (chars)",
|
|
287
|
-
"settings.advanced.sessionCap": "Session delivery cap sessionCap",
|
|
288
227
|
"settings.status.title": "Status",
|
|
289
228
|
"settings.status.calls": "{count} calls so far",
|
|
290
229
|
"settings.status.tokens": "in {input} / out {output} tokens",
|
|
@@ -330,6 +269,11 @@ window.__ModuleLoader__.load({
|
|
|
330
269
|
".dsh-advisor-toast{position:fixed;right:24px;bottom:24px;z-index:2147000000;display:flex;align-items:flex-start;gap:10px;max-width:min(440px,86vw);padding:10px 14px;border-radius:10px;background:var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-base,Canvas));color:var(--dsw-alias-label-primary,CanvasText);border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.35));box-shadow:0 10px 30px rgba(0,0,0,.28);font-size:13px;line-height:1.5;cursor:pointer;transition:opacity .18s ease,transform .18s ease;}",
|
|
331
270
|
".dsh-advisor-toast-mark{font-weight:600;line-height:1.4;}",
|
|
332
271
|
".dsh-advisor-toast-text{flex:1;min-width:0;word-break:break-word;white-space:pre-wrap;}",
|
|
272
|
+
".dsh-advisor-receipt{display:flex;flex-direction:column;gap:6px;max-width:min(520px,90vw);}",
|
|
273
|
+
".dsh-advisor-receipt-head{display:flex;align-items:center;gap:8px;}",
|
|
274
|
+
".dsh-advisor-receipt-title{flex:1 1 auto;min-width:0;font-weight:600;}",
|
|
275
|
+
".dsh-advisor-receipt-close{flex:none;border:none;background:transparent;color:var(--dsw-alias-label-secondary,#a4a4a4);font-size:13px;line-height:18px;cursor:pointer;padding:2px 4px;border-radius:4px;}",
|
|
276
|
+
".dsh-advisor-receipt-body{margin:0;max-height:42vh;overflow:auto;white-space:pre-wrap;word-break:break-word;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;line-height:1.6;}",
|
|
333
277
|
".dsh-advisor-settings{display:flex;flex-direction:column;gap:12px;font-size:13px;line-height:1.5;color:var(--dsw-alias-label-primary,CanvasText);}",
|
|
334
278
|
// 设置分节的首屏摘要:三行只读信息 + 一个紧凑的模式下拉。
|
|
335
279
|
".dsh-advisor-summary{display:flex;flex-direction:column;gap:0;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.22));border-radius:8px;overflow:hidden;}",
|
|
@@ -337,6 +281,17 @@ window.__ModuleLoader__.load({
|
|
|
337
281
|
".dsh-advisor-summary-row+.dsh-advisor-summary-row{border-top:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.16));}",
|
|
338
282
|
".dsh-advisor-summary-label{flex:none;width:4.5em;color:var(--dsw-alias-label-secondary,#a4a4a4);}",
|
|
339
283
|
".dsh-advisor-summary-value{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}",
|
|
284
|
+
".dsh-advisor-summary-mode{display:flex;align-items:center;gap:8px;flex:1 1 auto;min-width:0;flex-wrap:wrap;}",
|
|
285
|
+
".dsh-advisor-effective{flex:0 0 auto;max-width:100%;font-size:12px;line-height:18px;padding:1px 7px;border-radius:999px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.35));color:var(--dsw-alias-label-secondary,#a4a4a4);word-break:break-word;}",
|
|
286
|
+
".dsh-advisor-effective[data-advisor-effective=on]{color:var(--dsw-alias-state-success-primary,#2f9e63);border-color:var(--dsw-alias-state-success-primary,#2f9e63);}",
|
|
287
|
+
".dsh-advisor-effective[data-advisor-effective=off]{color:var(--dsw-alias-state-warn-label,#b8860b);border-color:var(--dsw-alias-state-warn-label,#b8860b);}",
|
|
288
|
+
".dsh-advisor-command{display:flex;flex-direction:column;gap:6px;padding:8px 10px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.22));background:var(--dsw-alias-bg-layer-2,transparent);}",
|
|
289
|
+
".dsh-advisor-command[data-state=error]{border-color:var(--dsw-alias-state-error-primary,#d9534f);}",
|
|
290
|
+
".dsh-advisor-command-head{display:flex;align-items:center;gap:8px;min-width:0;}",
|
|
291
|
+
".dsh-advisor-command-icon{flex:none;color:var(--dsw-alias-label-secondary,#a4a4a4);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;}",
|
|
292
|
+
".dsh-advisor-command-line{flex:1 1 auto;min-width:0;font-weight:600;word-break:break-word;}",
|
|
293
|
+
".dsh-advisor-command-state{flex:none;color:var(--dsw-alias-label-secondary,#a4a4a4);}",
|
|
294
|
+
".dsh-advisor-command-body{margin:0;max-height:40vh;overflow:auto;white-space:pre-wrap;word-break:break-word;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;line-height:1.6;color:var(--dsw-alias-label-primary,CanvasText);}",
|
|
340
295
|
".dsh-advisor-select-compact{max-width:min(320px,100%);}",
|
|
341
296
|
".dsh-advisor-head{display:flex;flex-direction:column;gap:2px;}",
|
|
342
297
|
".dsh-advisor-title{font-size:14px;font-weight:600;}",
|
|
@@ -713,7 +668,7 @@ window.__ModuleLoader__.load({
|
|
|
713
668
|
let SETTINGS_MODES = ["off", "shadow", "advisory"];
|
|
714
669
|
let SETTINGS_SCOPES = ["off", "summary", "full"];
|
|
715
670
|
|
|
716
|
-
/**
|
|
671
|
+
/** 回合结束后的自动征询方式,与 settings.js 一致。 */
|
|
717
672
|
let SETTINGS_POST_ANSWER = ["off", "card"];
|
|
718
673
|
|
|
719
674
|
/** 「记录发送内容」的取值,与 settings.js 一致。 */
|
|
@@ -829,6 +784,91 @@ window.__ModuleLoader__.load({
|
|
|
829
784
|
return out;
|
|
830
785
|
}
|
|
831
786
|
|
|
787
|
+
/**
|
|
788
|
+
* 保存态 → 真实生效态(与 host 半 `lib/command-text.js` 的 `effectiveStateOf` 同语义)。
|
|
789
|
+
* 设置页摘要必须显示这个,而不是只显示保存的 mode(审计 USIM-U2-08)。
|
|
790
|
+
* @param {any} settings
|
|
791
|
+
* @returns {{ effective: "on" | "shadow" | "off", reason: "mode" | "unconfigured" | null, key: string }}
|
|
792
|
+
*/
|
|
793
|
+
function effectiveState(settings) {
|
|
794
|
+
let mode =
|
|
795
|
+
settings?.mode === "advisory" || settings?.mode === "shadow" ? settings.mode : "off";
|
|
796
|
+
let provider = asString(settings?.provider).trim();
|
|
797
|
+
let model = asString(settings?.model).trim();
|
|
798
|
+
let configured = provider !== "" && model !== "";
|
|
799
|
+
if (mode === "off") {
|
|
800
|
+
return { effective: "off", reason: "mode", key: "settings.effective.off.mode" };
|
|
801
|
+
}
|
|
802
|
+
if (!configured) {
|
|
803
|
+
return {
|
|
804
|
+
effective: "off",
|
|
805
|
+
reason: "unconfigured",
|
|
806
|
+
key: "settings.effective.off.unconfigured",
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
if (mode === "shadow") {
|
|
810
|
+
return { effective: "shadow", reason: null, key: "settings.effective.shadow" };
|
|
811
|
+
}
|
|
812
|
+
return { effective: "on", reason: null, key: "settings.effective.on" };
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
/**
|
|
816
|
+
* 宿主的命令节点 → 原始命令行(`/advisor status`)。
|
|
817
|
+
* `node.args` 是宿主 `command/run.args` 原文(含分隔空白,管理员默认记录)。
|
|
818
|
+
* @param {any} node
|
|
819
|
+
* @returns {string}
|
|
820
|
+
*/
|
|
821
|
+
function commandLineOf(node) {
|
|
822
|
+
if (node === null || node === undefined) return "";
|
|
823
|
+
let name = asString(node.name);
|
|
824
|
+
let args = typeof node.args === "string" ? node.args.trim() : "";
|
|
825
|
+
return args === "" ? `/${name}` : `/${name} ${args}`;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* 宿主的命令节点 → 插件命令卡片的展示数据。
|
|
830
|
+
*
|
|
831
|
+
* 宿主通用命令卡片只显示 `node.name`、单行 summary 被省略号截断、多行正文要点开第二层
|
|
832
|
+
* 折叠(`GenericCommandCard.tsx`)。所以插件自己的卡片把「命令行 + 完整多行正文」一次
|
|
833
|
+
* 给全(审计 USIM-U2-07):正文不再省略、也不再要求用户猜到可以点开。
|
|
834
|
+
* @param {any} node
|
|
835
|
+
* @returns {{ line: string, state: "running" | "ok" | "error", body: string, hasEcho: boolean }}
|
|
836
|
+
*/
|
|
837
|
+
function commandCardView(node) {
|
|
838
|
+
let line = commandLineOf(node);
|
|
839
|
+
let name = asString(node?.name);
|
|
840
|
+
let outcome = node?.outcome;
|
|
841
|
+
if (outcome === null || typeof outcome !== "object") {
|
|
842
|
+
return { line: line, state: "running", body: "", hasEcho: false };
|
|
843
|
+
}
|
|
844
|
+
/** @type {"error" | "ok"} */
|
|
845
|
+
let state = outcome.kind === "error" ? "error" : "ok";
|
|
846
|
+
let text = asString(outcome.text).trim();
|
|
847
|
+
if (text === "") return { line: line, state: state, body: "", hasEcho: false };
|
|
848
|
+
let lines = text.split("\n");
|
|
849
|
+
let first = lines[0].trim();
|
|
850
|
+
// host 半的命令回执第一行就是原始命令行;卡片标头已经有同一行,正文去掉它。
|
|
851
|
+
let hasEcho = name !== "" && first.startsWith(`/${name}`);
|
|
852
|
+
let body = hasEcho ? lines.slice(1).join("\n").trim() : text;
|
|
853
|
+
return { line: line, state: state, body: body, hasEcho: hasEcho };
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* 本地命令执行回执(宿主 client 事件 `command/executed`):只处理 advisor。
|
|
858
|
+
* 事件只在本浏览器本地提交时触发(换 tab / 另一客户端不会收到),所以不会把
|
|
859
|
+
* 别人的历史命令弹出来。
|
|
860
|
+
* @param {unknown} name
|
|
861
|
+
* @param {any} result
|
|
862
|
+
* @returns {{ tone: "ok" | "error", text: string } | null}
|
|
863
|
+
*/
|
|
864
|
+
function receiptOf(name, result) {
|
|
865
|
+
if (name !== "advisor") return null;
|
|
866
|
+
/** @type {"ok" | "error"} */
|
|
867
|
+
let tone = result?.kind === "error" ? "error" : "ok";
|
|
868
|
+
let text = asString(result?.text).trim();
|
|
869
|
+
return text === "" ? null : { tone: tone, text: text };
|
|
870
|
+
}
|
|
871
|
+
|
|
832
872
|
/**
|
|
833
873
|
* 只保留卡片关心的字段,并把畸形值夹回默认区间。
|
|
834
874
|
* @param {any} raw
|
|
@@ -1373,7 +1413,7 @@ window.__ModuleLoader__.load({
|
|
|
1373
1413
|
}
|
|
1374
1414
|
|
|
1375
1415
|
/**
|
|
1376
|
-
*
|
|
1416
|
+
* 顾问线展开后的「本次征询」摘要:触发方式 · 时间 · 模型 · 字符数 · 用量/成本。
|
|
1377
1417
|
* @param {any} record
|
|
1378
1418
|
* @param {(key: string) => string} t
|
|
1379
1419
|
* @returns {string}
|
|
@@ -1422,10 +1462,27 @@ window.__ModuleLoader__.load({
|
|
|
1422
1462
|
// toast 组件(属于 shell.overlay;没有提示时返回 null)
|
|
1423
1463
|
// ------------------------------------------------------------------
|
|
1424
1464
|
|
|
1425
|
-
/**
|
|
1465
|
+
/**
|
|
1466
|
+
* shell.overlay 里的轻提示 + 命令回执面板。
|
|
1467
|
+
*
|
|
1468
|
+
* - 普通 toast(选中模型、设置成功等):一行、4 秒后自动消失(旧的反馈路径不动)。
|
|
1469
|
+
* - **命令回执**(`mode: "receipt"`):`/advisor status|doctor` 这类多行输出一次给全,
|
|
1470
|
+
* 不自动消失(长文本 4 秒读不完),保留到用户关闭或下一条回执替换它。
|
|
1471
|
+
* 这是审计 USIM-U2-07 允许的「宿主的命令回执/toast」通道:命令节点在宿主 Chat 里
|
|
1472
|
+
* 被折叠进 process 分组,插件无法展开分组,所以输出必须另有一条立即可见的通路。
|
|
1473
|
+
* @param {any} props slot props:`store` + locale 的 `t`
|
|
1474
|
+
* @returns {any}
|
|
1475
|
+
*/
|
|
1426
1476
|
function AdvisorToast(props) {
|
|
1477
|
+
let t =
|
|
1478
|
+
typeof props.t === "function"
|
|
1479
|
+
? props.t
|
|
1480
|
+
: function passthroughKey(/** @type {string} */ key) {
|
|
1481
|
+
return key;
|
|
1482
|
+
};
|
|
1427
1483
|
let toast = React.useSyncExternalStore(props.store.subscribe, props.store.getSnapshot);
|
|
1428
1484
|
let entryId = toast ? toast.id : null;
|
|
1485
|
+
let receipt = toast !== null && toast.mode === "receipt";
|
|
1429
1486
|
let shownState = React.useState(false);
|
|
1430
1487
|
let shown = shownState[0];
|
|
1431
1488
|
let setShown = shownState[1];
|
|
@@ -1438,6 +1495,12 @@ window.__ModuleLoader__.load({
|
|
|
1438
1495
|
let raise = setTimeout(() => {
|
|
1439
1496
|
setShown(true);
|
|
1440
1497
|
}, 10);
|
|
1498
|
+
if (receipt) {
|
|
1499
|
+
// 回执不自动消失(多行输出要留到用户读完/复制完);只清理淡入定时器。
|
|
1500
|
+
return () => {
|
|
1501
|
+
clearTimeout(raise);
|
|
1502
|
+
};
|
|
1503
|
+
}
|
|
1441
1504
|
let timer = setTimeout(() => {
|
|
1442
1505
|
props.store.set(null);
|
|
1443
1506
|
}, TOAST_MS);
|
|
@@ -1445,7 +1508,7 @@ window.__ModuleLoader__.load({
|
|
|
1445
1508
|
clearTimeout(raise);
|
|
1446
1509
|
clearTimeout(timer);
|
|
1447
1510
|
};
|
|
1448
|
-
}, [entryId, props.store]);
|
|
1511
|
+
}, [entryId, props.store, receipt]);
|
|
1449
1512
|
|
|
1450
1513
|
if (!toast) return null;
|
|
1451
1514
|
let tone = toast.tone === "error" ? "error" : toast.tone === "ok" ? "ok" : "info";
|
|
@@ -1455,6 +1518,48 @@ window.__ModuleLoader__.load({
|
|
|
1455
1518
|
: tone === "ok"
|
|
1456
1519
|
? "var(--dsw-alias-state-success-primary,#2f9e63)"
|
|
1457
1520
|
: "var(--dsw-alias-label-secondary,GrayText)";
|
|
1521
|
+
|
|
1522
|
+
if (receipt) {
|
|
1523
|
+
return h(
|
|
1524
|
+
"section",
|
|
1525
|
+
{
|
|
1526
|
+
className: "dsh-advisor-toast dsh-advisor-receipt",
|
|
1527
|
+
role: "status",
|
|
1528
|
+
"aria-label": t("receipt.title"),
|
|
1529
|
+
"data-advisor-receipt": "",
|
|
1530
|
+
"data-tone": tone,
|
|
1531
|
+
style: {
|
|
1532
|
+
borderLeft: `3px solid ${color}`,
|
|
1533
|
+
opacity: shown ? 1 : 0,
|
|
1534
|
+
transform: shown ? "translateY(0)" : "translateY(8px)",
|
|
1535
|
+
},
|
|
1536
|
+
},
|
|
1537
|
+
h(
|
|
1538
|
+
"div",
|
|
1539
|
+
{ className: "dsh-advisor-receipt-head", key: "head" },
|
|
1540
|
+
h("span", { className: "dsh-advisor-receipt-title", key: "title" }, t("receipt.title")),
|
|
1541
|
+
h(
|
|
1542
|
+
"button",
|
|
1543
|
+
{
|
|
1544
|
+
className: "dsh-advisor-receipt-close",
|
|
1545
|
+
"aria-label": t("receipt.close"),
|
|
1546
|
+
key: "close",
|
|
1547
|
+
onClick: () => {
|
|
1548
|
+
props.store.set(null);
|
|
1549
|
+
},
|
|
1550
|
+
type: "button",
|
|
1551
|
+
},
|
|
1552
|
+
"✕",
|
|
1553
|
+
),
|
|
1554
|
+
),
|
|
1555
|
+
h(
|
|
1556
|
+
"pre",
|
|
1557
|
+
{ className: "dsh-advisor-receipt-body", key: "body", "data-advisor-receipt-body": "" },
|
|
1558
|
+
asString(toast.message),
|
|
1559
|
+
),
|
|
1560
|
+
);
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1458
1563
|
return h(
|
|
1459
1564
|
"div",
|
|
1460
1565
|
{
|
|
@@ -1480,6 +1585,75 @@ window.__ModuleLoader__.load({
|
|
|
1480
1585
|
);
|
|
1481
1586
|
}
|
|
1482
1587
|
|
|
1588
|
+
// ------------------------------------------------------------------
|
|
1589
|
+
// 命令卡片(conversation.chat.commandview,key = advisor)
|
|
1590
|
+
// ------------------------------------------------------------------
|
|
1591
|
+
|
|
1592
|
+
/**
|
|
1593
|
+
* `/advisor` 命令卡片:原始命令行 + 完整多行输出。
|
|
1594
|
+
*
|
|
1595
|
+
* 宿主 `CommandNodeView` 把 command 节点渲染成 `GenericCommandCard`:只显示
|
|
1596
|
+
* `node.name`(看不到用户敲了 status 还是 doctor)、单行 summary 被省略号截断、
|
|
1597
|
+
* 多行正文要点开第二层折叠。宿主的 `conversation.chat.commandview` 是 keyed 子 slot
|
|
1598
|
+
* (按命令名分发),插件在这里一次把这两件事做好(审计 USIM-U2-07)。
|
|
1599
|
+
*
|
|
1600
|
+
* 注意:命令节点仍会被宿主 Chat 折叠进 process 分组(「已完成分析」标题),插件没有
|
|
1601
|
+
* 能力改变分组;所以立刻可见的输出另走 shell.overlay 的命令回执。
|
|
1602
|
+
* @param {any} props slot props:owner `{ node }` + locale 的 `t`
|
|
1603
|
+
* @returns {any}
|
|
1604
|
+
*/
|
|
1605
|
+
function AdvisorCommandCard(props) {
|
|
1606
|
+
let t =
|
|
1607
|
+
typeof props.t === "function"
|
|
1608
|
+
? props.t
|
|
1609
|
+
: function passthroughKey(/** @type {string} */ key) {
|
|
1610
|
+
return key;
|
|
1611
|
+
};
|
|
1612
|
+
let view = commandCardView(props?.node);
|
|
1613
|
+
let running = view.state === "running";
|
|
1614
|
+
let body = running ? "" : view.body;
|
|
1615
|
+
let children = [
|
|
1616
|
+
h(
|
|
1617
|
+
"div",
|
|
1618
|
+
{ className: "dsh-advisor-command-head", key: "head" },
|
|
1619
|
+
h("span", { className: "dsh-advisor-command-icon", key: "icon" }, ">_"),
|
|
1620
|
+
h("span", { className: "dsh-advisor-command-line", key: "line" }, view.line),
|
|
1621
|
+
running
|
|
1622
|
+
? h(
|
|
1623
|
+
"span",
|
|
1624
|
+
{ className: "dsh-advisor-command-state", key: "state" },
|
|
1625
|
+
t("command.running"),
|
|
1626
|
+
)
|
|
1627
|
+
: null,
|
|
1628
|
+
),
|
|
1629
|
+
];
|
|
1630
|
+
if (body !== "") {
|
|
1631
|
+
children.push(
|
|
1632
|
+
h(
|
|
1633
|
+
"pre",
|
|
1634
|
+
{
|
|
1635
|
+
className: "dsh-advisor-command-body",
|
|
1636
|
+
key: "body",
|
|
1637
|
+
"data-advisor-command-body": "",
|
|
1638
|
+
},
|
|
1639
|
+
body,
|
|
1640
|
+
),
|
|
1641
|
+
);
|
|
1642
|
+
}
|
|
1643
|
+
return h(
|
|
1644
|
+
"div",
|
|
1645
|
+
{
|
|
1646
|
+
className: "dsh-advisor-command",
|
|
1647
|
+
role: "group",
|
|
1648
|
+
"aria-label": t("command.card.aria"),
|
|
1649
|
+
"data-advisor-command-card": "",
|
|
1650
|
+
"data-command-line": view.line,
|
|
1651
|
+
"data-state": view.state,
|
|
1652
|
+
},
|
|
1653
|
+
children,
|
|
1654
|
+
);
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1483
1657
|
// ------------------------------------------------------------------
|
|
1484
1658
|
// 顾问线(conversation.chat.turnTail)
|
|
1485
1659
|
// ------------------------------------------------------------------
|
|
@@ -3690,8 +3864,34 @@ window.__ModuleLoader__.load({
|
|
|
3690
3864
|
h("option", { key: value, value: value }, t(`settings.mode.${value}`)),
|
|
3691
3865
|
),
|
|
3692
3866
|
);
|
|
3867
|
+
// 生效状态徽标:保存的 mode 只是偏好(advisory + 没选模型时宿主会直接跳过),
|
|
3868
|
+
// 摘要必须显示**真实生效状态与停用原因**(审计 USIM-U2-08)。
|
|
3869
|
+
// 用 `snap.settings`(宿主回来的保存值)而不是 `draft`:草稿里的改动尚未生效。
|
|
3870
|
+
let savedState = effectiveState(snap.settings);
|
|
3871
|
+
let effectiveChip = h(
|
|
3872
|
+
"span",
|
|
3873
|
+
{
|
|
3874
|
+
className: "dsh-advisor-effective",
|
|
3875
|
+
"data-advisor-effective": savedState.effective,
|
|
3876
|
+
"data-advisor-effective-reason": savedState.reason === null ? "" : savedState.reason,
|
|
3877
|
+
key: "effective",
|
|
3878
|
+
title: t("settings.effective.note"),
|
|
3879
|
+
},
|
|
3880
|
+
t(savedState.key),
|
|
3881
|
+
);
|
|
3882
|
+
let modeSummaryRow = h("div", { className: "dsh-advisor-summary-row", key: "mode" }, [
|
|
3883
|
+
h(
|
|
3884
|
+
"span",
|
|
3885
|
+
{ className: "dsh-advisor-summary-label", key: "label" },
|
|
3886
|
+
t("settings.summary.mode"),
|
|
3887
|
+
),
|
|
3888
|
+
h("span", { className: "dsh-advisor-summary-mode", key: "value" }, [
|
|
3889
|
+
modeSelect,
|
|
3890
|
+
effectiveChip,
|
|
3891
|
+
]),
|
|
3892
|
+
]);
|
|
3693
3893
|
let summary = h("div", { className: "dsh-advisor-summary", "data-advisor-summary": "" }, [
|
|
3694
|
-
|
|
3894
|
+
modeSummaryRow,
|
|
3695
3895
|
summaryRow(t("settings.summary.route"), routeText),
|
|
3696
3896
|
summaryRow(t("settings.summary.budget"), budgetText),
|
|
3697
3897
|
]);
|
|
@@ -3798,8 +3998,20 @@ window.__ModuleLoader__.load({
|
|
|
3798
3998
|
"settings.confirm": "跨 provider 发送",
|
|
3799
3999
|
"settings.confirm.run": "确认跨 provider 发送",
|
|
3800
4000
|
"settings.confirm.running": "确认中…",
|
|
3801
|
-
"settings.confirm.hint": "把当前 provider 加进确认名单;跨 provider
|
|
4001
|
+
"settings.confirm.hint": "把当前 provider 加进确认名单;跨 provider 征询不再中断。",
|
|
3802
4002
|
"settings.confirm.done": "已确认 {provider}",
|
|
4003
|
+
"settings.effective.aria": "生效状态",
|
|
4004
|
+
"settings.effective.on": "已生效",
|
|
4005
|
+
"settings.effective.shadow": "影子:只记账",
|
|
4006
|
+
"settings.effective.off": "已关闭",
|
|
4007
|
+
"settings.effective.off.unconfigured": "已关闭:未选择顾问模型",
|
|
4008
|
+
"settings.effective.off.mode": "已关闭:模式为 off",
|
|
4009
|
+
"settings.effective.note": "设置里保存的是偏好;这里显示的是真实生效状态。",
|
|
4010
|
+
"command.running": "正在运行…",
|
|
4011
|
+
"command.failed": "执行失败",
|
|
4012
|
+
"command.card.aria": "顾问命令输出",
|
|
4013
|
+
"receipt.title": "顾问命令回执",
|
|
4014
|
+
"receipt.close": "关闭回执",
|
|
3803
4015
|
"settings.error.preview": "预览失败,稍后重试",
|
|
3804
4016
|
"settings.error.confirm": "确认失败,稍后重试",
|
|
3805
4017
|
"settings.tracePrompt": "记录发送内容",
|
|
@@ -3837,7 +4049,7 @@ window.__ModuleLoader__.load({
|
|
|
3837
4049
|
"tail.trace.previewFull": "实际发送(脱敏后,共 {chars} 字符)",
|
|
3838
4050
|
"tail.trace.previewNone":
|
|
3839
4051
|
"这条记录没有保存发送内容(可能是旧记录,或已在高级设置里关闭记录)。",
|
|
3840
|
-
"settings.desc": "
|
|
4052
|
+
"settings.desc": "基础设置开箱即用;高级项默认折叠。保存后的改动对下一次征询生效。",
|
|
3841
4053
|
"settings.group.basic": "基础设置",
|
|
3842
4054
|
"settings.group.budget": "预算与限额",
|
|
3843
4055
|
"settings.group.advanced": "高级设置",
|
|
@@ -3845,7 +4057,7 @@ window.__ModuleLoader__.load({
|
|
|
3845
4057
|
"settings.mode.shadow": "影子",
|
|
3846
4058
|
"settings.mode.advisory": "顾问",
|
|
3847
4059
|
"settings.mode.shadowHint": "会调用顾问并记账,但不会把建议放进对话;适合先观察。",
|
|
3848
|
-
"settings.mode.advisoryHint": "
|
|
4060
|
+
"settings.mode.advisoryHint": "会征询顾问,并把建议交给模型;模型可以采纳或忽略。",
|
|
3849
4061
|
"settings.provider": "服务商",
|
|
3850
4062
|
"settings.model": "模型",
|
|
3851
4063
|
"settings.budget.maxCallsPerTurn": "每回合调用上限",
|
|
@@ -3904,7 +4116,7 @@ window.__ModuleLoader__.load({
|
|
|
3904
4116
|
"settings.advanced.maxInputCharsHint":
|
|
3905
4117
|
"一次最多发送多少字符的会话内容;超出会保留首尾、省略中间。",
|
|
3906
4118
|
"settings.advanced.sessionCapHint": "一个会话最多展示几条建议;到顶后只保留 blocker 级。",
|
|
3907
|
-
"settings.help.calls": "
|
|
4119
|
+
"settings.help.calls": "超过上限就跳过本次征询;0 = 不限。",
|
|
3908
4120
|
"settings.help.tech": "技术名:{key}",
|
|
3909
4121
|
"settings.help.open": "查看 {field} 的说明",
|
|
3910
4122
|
"settings.help.defaultOn": "默认:开",
|
|
@@ -3953,6 +4165,19 @@ window.__ModuleLoader__.load({
|
|
|
3953
4165
|
"settings.confirm.hint":
|
|
3954
4166
|
"Add the current provider to the confirmed list so cross-provider consultations stop being interrupted.",
|
|
3955
4167
|
"settings.confirm.done": "Confirmed {provider}",
|
|
4168
|
+
"settings.effective.aria": "Effective status",
|
|
4169
|
+
"settings.effective.on": "In effect",
|
|
4170
|
+
"settings.effective.shadow": "Shadow: log only",
|
|
4171
|
+
"settings.effective.off": "Off",
|
|
4172
|
+
"settings.effective.off.unconfigured": "Off: no advisor model selected",
|
|
4173
|
+
"settings.effective.off.mode": "Off: mode is off",
|
|
4174
|
+
"settings.effective.note":
|
|
4175
|
+
"Settings save a preference; this shows what actually takes effect.",
|
|
4176
|
+
"command.running": "Running…",
|
|
4177
|
+
"command.failed": "Failed",
|
|
4178
|
+
"command.card.aria": "Advisor command output",
|
|
4179
|
+
"receipt.title": "Advisor command receipt",
|
|
4180
|
+
"receipt.close": "Dismiss receipt",
|
|
3956
4181
|
"settings.error.preview": "Preview failed — try again later",
|
|
3957
4182
|
"settings.error.confirm": "Confirmation failed — try again later",
|
|
3958
4183
|
"settings.tracePrompt": "Keep sent content",
|
|
@@ -4138,6 +4363,44 @@ window.__ModuleLoader__.load({
|
|
|
4138
4363
|
});
|
|
4139
4364
|
}
|
|
4140
4365
|
|
|
4366
|
+
/**
|
|
4367
|
+
* 命令回执(多行、常驻到关闭)。与 toast 共用同一个 overlay 槽:
|
|
4368
|
+
* 后一条替换前一条,避免右下角堆叠。
|
|
4369
|
+
* @param {string} message
|
|
4370
|
+
* @param {"ok" | "error" | "info"} [tone]
|
|
4371
|
+
*/
|
|
4372
|
+
function showReceipt(message, tone) {
|
|
4373
|
+
let text = asString(message).trim();
|
|
4374
|
+
if (text === "") return;
|
|
4375
|
+
toastSeq += 1;
|
|
4376
|
+
toastStore.set({
|
|
4377
|
+
id: toastSeq,
|
|
4378
|
+
message: text,
|
|
4379
|
+
mode: "receipt",
|
|
4380
|
+
tone: tone === "error" || tone === "ok" ? tone : "info",
|
|
4381
|
+
});
|
|
4382
|
+
}
|
|
4383
|
+
|
|
4384
|
+
/**
|
|
4385
|
+
* 宿主的本地命令回执事件(`command/executed`,见
|
|
4386
|
+
* `dsh-client-ui-commands/src/client/service.ts` 的 `notifyExecuted`)。
|
|
4387
|
+
*
|
|
4388
|
+
* **参数顺序必须是宿主声明 `(sessionId, name, result)`**:监听器是被
|
|
4389
|
+
* `listener(sessionId, name, result)` 直接调用的;写成 `(name, result)` 会把
|
|
4390
|
+
* sessionId 当命令名,结果永远收不到回执(审计 USIM-U2-07 修复里最隐蔽的一处)。
|
|
4391
|
+
* 只有本浏览器实际提交成功才触发,因此不会把历史/别的客户端的命令弹出来。
|
|
4392
|
+
* @param {any} _sessionId
|
|
4393
|
+
* @param {any} name
|
|
4394
|
+
* @param {any} result
|
|
4395
|
+
*/
|
|
4396
|
+
function onCommandExecuted(_sessionId, name, result) {
|
|
4397
|
+
let receipt = receiptOf(name, result);
|
|
4398
|
+
if (receipt === null) return;
|
|
4399
|
+
// 测试观测点(`__test.lastCommandReceipt` 读取);生产路径没有额外副作用。
|
|
4400
|
+
lastCommandReceipt = receipt;
|
|
4401
|
+
showReceipt(receipt.text, receipt.tone);
|
|
4402
|
+
}
|
|
4403
|
+
|
|
4141
4404
|
/**
|
|
4142
4405
|
* 取宿主服务(可能缺席,绝不抛)。
|
|
4143
4406
|
* @param {string} name
|
|
@@ -4572,6 +4835,39 @@ window.__ModuleLoader__.load({
|
|
|
4572
4835
|
"advisor: turn line",
|
|
4573
4836
|
);
|
|
4574
4837
|
|
|
4838
|
+
/**
|
|
4839
|
+
* `/advisor` 命令卡片:宿主 command 节点的 keyed 子 slot(`CommandNodeView` 用
|
|
4840
|
+
* `entryKey: node.name` 分发)。key 必须是命令名,否则永远落到宿主的通用卡片上。
|
|
4841
|
+
* 槽不存在时宿主自己的 fallback 仍然生效(只是回到单行省略号),不影响插件激活。
|
|
4842
|
+
*/
|
|
4843
|
+
ctx.effect(
|
|
4844
|
+
() =>
|
|
4845
|
+
ctx.slots.inject("conversation.chat.commandview", () =>
|
|
4846
|
+
ctx.slots.register(
|
|
4847
|
+
{
|
|
4848
|
+
name: "conversation.chat.commandview",
|
|
4849
|
+
id: "advisor-command",
|
|
4850
|
+
key: COMMAND_NAME,
|
|
4851
|
+
locale: NS,
|
|
4852
|
+
},
|
|
4853
|
+
AdvisorCommandCard,
|
|
4854
|
+
),
|
|
4855
|
+
),
|
|
4856
|
+
"advisor: command card",
|
|
4857
|
+
);
|
|
4858
|
+
|
|
4859
|
+
// 命令回执:宿主的本地执行确认事件(缺失时静默降级)。
|
|
4860
|
+
try {
|
|
4861
|
+
if (typeof ctx.on === "function") {
|
|
4862
|
+
ctx.effect(
|
|
4863
|
+
() => ctx.on("command/executed", onCommandExecuted),
|
|
4864
|
+
"advisor: command receipt",
|
|
4865
|
+
);
|
|
4866
|
+
}
|
|
4867
|
+
} catch (_error) {
|
|
4868
|
+
/* 旧宿主没有这个事件:卡片仍可读,只是少了即时回执 */
|
|
4869
|
+
}
|
|
4870
|
+
|
|
4575
4871
|
/**
|
|
4576
4872
|
* 装饰 `/advisor`:宿主 popupSelect 打开模型选择器。
|
|
4577
4873
|
* 必须等 commandUi 服务就绪(它不一定在 apply 时已挂载),否则装饰会被静默跳过。
|
|
@@ -4637,6 +4933,11 @@ window.__ModuleLoader__.load({
|
|
|
4637
4933
|
formatMoneyInput: formatMoneyInput,
|
|
4638
4934
|
convertCurrency: convertCurrency,
|
|
4639
4935
|
normalizeSettingsView: normalizeSettingsView,
|
|
4936
|
+
effectiveState: effectiveState,
|
|
4937
|
+
commandLineOf: commandLineOf,
|
|
4938
|
+
commandCardView: commandCardView,
|
|
4939
|
+
receiptOf: receiptOf,
|
|
4940
|
+
lastCommandReceipt: () => lastCommandReceipt,
|
|
4640
4941
|
normalizeOptions: normalizeOptions,
|
|
4641
4942
|
normalizeModels: normalizeModels,
|
|
4642
4943
|
normalizeModelInfo: normalizeModelInfo,
|