dsh-tool-manager 1.4.2 → 1.5.2
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/CHANGELOG.md +57 -0
- package/DESIGN.md +32 -3
- package/README.md +55 -10
- package/dist/client.js +551 -31
- package/dist/config.d.ts +10 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +20 -0
- package/dist/config.js.map +1 -1
- package/dist/dsh.d.ts +36 -0
- package/dist/dsh.d.ts.map +1 -1
- package/dist/dsh.js.map +1 -1
- package/dist/exposure-history.d.ts.map +1 -1
- package/dist/exposure-history.js +22 -19
- package/dist/exposure-history.js.map +1 -1
- package/dist/index.d.ts +15 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +186 -10
- package/dist/index.js.map +1 -1
- package/dist/mcp-mode.d.ts +82 -0
- package/dist/mcp-mode.d.ts.map +1 -0
- package/dist/mcp-mode.js +238 -0
- package/dist/mcp-mode.js.map +1 -0
- package/dist/policy.d.ts +34 -1
- package/dist/policy.d.ts.map +1 -1
- package/dist/policy.js +107 -3
- package/dist/policy.js.map +1 -1
- package/dist/runtime.d.ts +39 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +327 -19
- package/dist/runtime.js.map +1 -1
- package/dist/snapshot.d.ts.map +1 -1
- package/dist/snapshot.js +4 -2
- package/dist/snapshot.js.map +1 -1
- package/dist/suggest.d.ts +50 -1
- package/dist/suggest.d.ts.map +1 -1
- package/dist/suggest.js +113 -2
- package/dist/suggest.js.map +1 -1
- package/dist/types.d.ts +67 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -1
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +2 -2
package/dist/client.js
CHANGED
|
@@ -14,6 +14,7 @@ window.__ModuleLoader__.load({
|
|
|
14
14
|
".tm_head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}",
|
|
15
15
|
".tm_head h2{font-size:18px;margin:0 0 5px}.tm_muted{color:var(--dsw-alias-label-secondary,#9097a4);font-size:12px;line-height:1.5}",
|
|
16
16
|
".tm_preset_picker{display:flex;align-items:center;gap:9px;flex-wrap:wrap}.tm_preset_picker label{font-size:12px;color:var(--dsw-alias-label-secondary,#9097a4)}.tm_select_wrap{position:relative;display:inline-flex;max-width:100%}.tm_select_wrap:after{content:'';position:absolute;right:12px;top:50%;width:7px;height:7px;border-right:2px solid currentColor;border-bottom:2px solid currentColor;transform:translateY(-70%) rotate(45deg);pointer-events:none;opacity:.9}.tm_preset_select,.tm_btn{appearance:none;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.28));border-radius:8px;background:var(--dsw-alias-bg-layer-1,rgba(128,128,128,.08));color:inherit;padding:7px 10px;font:inherit;font-size:12px}.tm_preset_select{min-width:min(360px,100%);cursor:pointer;padding-right:34px}.tm_preset_select option{background:var(--dsw-alias-bg-base,#17191d);color:inherit}.tm_btn{cursor:pointer}.tm_btn.primary{background:#5367e8;border-color:#5367e8;color:#fff}.tm_btn:disabled{opacity:.5;cursor:not-allowed}",
|
|
17
|
+
".tm_model_block{display:flex;flex-direction:column;gap:6px;min-width:0}.tm_model_row{display:flex;align-items:center;gap:8px;flex-wrap:wrap;min-width:0}.tm_model_row .tm_model_label{flex:0 0 auto;font-size:12px;color:var(--dsw-alias-label-secondary,#9097a4);cursor:help;white-space:nowrap}.tm_model_row .tm_select_wrap{min-width:0}.tm_model_row .tm_model_pick{flex:1 1 auto}.tm_model_row .tm_preset_select{min-width:0;width:100%}.tm_model_row .tm_effort_pick{flex:0 0 auto}.tm_model_row .tm_effort_pick .tm_preset_select{width:auto;min-width:96px}.tm_model_hints{display:flex;align-items:center;gap:8px;flex-wrap:wrap}",
|
|
17
18
|
".tm_panel{border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.24));border-radius:12px;background:var(--dsw-alias-bg-layer-1,rgba(128,128,128,.06));overflow:hidden}",
|
|
18
19
|
".tm_panel_head{padding:13px 14px;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.2));display:flex;justify-content:space-between;gap:12px;align-items:center;flex-wrap:wrap;position:relative}.tm_panel_head b{font-size:14px}",
|
|
19
20
|
".tm_tools{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:0}.tm_tool{display:flex;gap:10px;align-items:flex-start;padding:11px 14px;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.13))}.tm_tool_name{font:600 12px ui-monospace,SFMono-Regular,Consolas,monospace}.tm_tool_desc{font-size:11px;color:var(--dsw-alias-label-secondary,#9097a4);line-height:1.4;margin-top:3px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}",
|
|
@@ -21,7 +22,7 @@ window.__ModuleLoader__.load({
|
|
|
21
22
|
".tm_filters{display:flex;gap:6px;flex-wrap:wrap;align-items:center}.tm_chip{appearance:none;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.28));border-radius:999px;background:transparent;color:inherit;padding:4px 9px;cursor:pointer;font:inherit;font-size:11px}.tm_chip.active{border-color:#7c8cff;background:color-mix(in srgb,#7c8cff 16%,transparent)}",
|
|
22
23
|
".tm_stats{display:flex;flex-wrap:nowrap;gap:6px;padding:8px 12px;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.13))}.tm_stat{flex:1 1 0;min-width:0;padding:6px 7px;border-radius:7px;background:var(--dsw-alias-bg-layer-1,rgba(128,128,128,.07));border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.15))}.tm_stat_value{font-size:15px;font-weight:700;line-height:1.15;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tm_stat_label{margin-top:2px;font-size:10px;line-height:1.3;color:var(--dsw-alias-label-secondary,#9097a4);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@media(max-width:560px){.tm_stats{flex-wrap:wrap}.tm_stat{flex:1 1 30%}}",
|
|
23
24
|
".tm_token{display:inline-flex;align-items:center;margin-left:6px;padding:1px 6px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.22));border-radius:999px;background:var(--dsw-alias-bg-layer-1,rgba(128,128,128,.09));font:600 10px/1.45 ui-monospace,SFMono-Regular,Consolas,monospace;color:var(--dsw-alias-label-secondary,#9097a4);white-space:nowrap;vertical-align:middle}.tm_tool>.tm_token{margin-left:auto;flex:0 0 auto}.tm_stat_extra{margin-top:1px;font-size:9.5px;line-height:1.3;color:var(--dsw-alias-label-secondary,#9097a4);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}",
|
|
24
|
-
".tm_help{display:inline-flex;align-items:center;justify-content:center;width:15px;height:15px;margin-left:6px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.28));border-radius:50%;background:var(--dsw-alias-bg-layer-1,rgba(128,128,128,.08));color:var(--dsw-alias-label-secondary,#9097a4);font:700 10px/1 ui-sans-serif,system-ui,sans-serif;cursor:help;vertical-align:middle;outline:none}.tm_help:hover,.tm_help:focus-visible{border-color:#7c8cff;color:#9da8ff}.tm_help::after{content:attr(data-tip);position:absolute;left:0;top:calc(100% + 6px);width:min(520px,calc(100vw - 48px));max-width:
|
|
25
|
+
".tm_help{display:inline-flex;align-items:center;justify-content:center;width:15px;height:15px;margin-left:6px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.28));border-radius:50%;background:var(--dsw-alias-bg-layer-1,rgba(128,128,128,.08));color:var(--dsw-alias-label-secondary,#9097a4);font:700 10px/1 ui-sans-serif,system-ui,sans-serif;cursor:help;vertical-align:middle;outline:none}.tm_help:hover,.tm_help:focus-visible{border-color:#7c8cff;color:#9da8ff}.tm_help::after{content:attr(data-tip);position:absolute;left:0;top:calc(100% + 6px);width:min(520px,calc(100vw - 48px));max-width:none;padding:10px 12px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.28));border-radius:9px;background:var(--dsw-alias-bg-base,#17191d);box-shadow:0 14px 40px rgba(0,0,0,.35);color:var(--dsw-alias-label-primary,#e7e9ed);font:400 12px/1.65 ui-sans-serif,system-ui,sans-serif;white-space:pre-line;text-align:left;opacity:0;visibility:hidden;pointer-events:none;z-index:30;transition:opacity .12s ease}.tm_help:hover::after,.tm_help:focus-visible::after{opacity:1;visibility:visible}",
|
|
25
26
|
".tm_badge{display:inline-block;margin-left:6px;padding:2px 7px;border:1px solid transparent;border-radius:999px;font-size:10px;font-weight:700;line-height:1.35;letter-spacing:.02em;vertical-align:middle;color:#fff}.tm_badge.off{background:#b42318;border-color:#d92d20;color:#fff}.tm_badge.cold{background:#4338ca;border-color:#6366f1;color:#fff}.tm_badge.live{background:#15803d;border-color:#22c55e;color:#fff}.tm_badge.ptc{background:#6d28d9;border-color:#a78bfa;color:#fff}.tm_badge.native{background:#334155;border-color:#64748b;color:#fff}",
|
|
26
27
|
".tm_group{border-bottom:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.13))}.tm_group:last-child{border-bottom:0}",
|
|
27
28
|
".tm_group_bar{display:flex;align-items:center;gap:8px;padding:11px 14px}",
|
|
@@ -86,7 +87,7 @@ window.__ModuleLoader__.load({
|
|
|
86
87
|
return next;
|
|
87
88
|
}
|
|
88
89
|
function policyPayload(policy) {
|
|
89
|
-
|
|
90
|
+
const payload = {
|
|
90
91
|
disabled: [...(policy.disabled || [])],
|
|
91
92
|
groups: (policy.groups || []).map((group) => ({
|
|
92
93
|
name: group.name,
|
|
@@ -94,9 +95,11 @@ window.__ModuleLoader__.load({
|
|
|
94
95
|
patterns: [...(group.patterns || [])],
|
|
95
96
|
})),
|
|
96
97
|
};
|
|
98
|
+
if (policy.mode === "mcp") payload.mode = "mcp";
|
|
99
|
+
return payload;
|
|
97
100
|
}
|
|
98
101
|
/**
|
|
99
|
-
*
|
|
102
|
+
* Copy one Preset's on-demand groups and disabled names onto another.
|
|
100
103
|
*
|
|
101
104
|
* The target is meant to be overwritten, so its current groups and
|
|
102
105
|
* disabled names are ignored. Copy only what the target can actually
|
|
@@ -104,6 +107,12 @@ window.__ModuleLoader__.load({
|
|
|
104
107
|
* Presets, and a group whose members all disappear is skipped instead
|
|
105
108
|
* of becoming an invalid empty group. Old wildcard patterns are
|
|
106
109
|
* expanded to exact names, matching what the group editor shows.
|
|
110
|
+
*
|
|
111
|
+
* Loading mode is not part of the copy: it says how a Preset reads the
|
|
112
|
+
* groups it owns (tool_list in default mode, tool_find in mcp mode), so
|
|
113
|
+
* it belongs to the target. Rebuilding the policy used to omit `mode`,
|
|
114
|
+
* which silently turned an MCP 按需 target back into default mode after
|
|
115
|
+
* a copy.
|
|
107
116
|
*/
|
|
108
117
|
function copyPresetPolicy(sourcePreset, targetPreset) {
|
|
109
118
|
const sourceTools = sourcePreset.tools || [];
|
|
@@ -132,16 +141,175 @@ window.__ModuleLoader__.load({
|
|
|
132
141
|
patterns: members,
|
|
133
142
|
});
|
|
134
143
|
}
|
|
135
|
-
|
|
144
|
+
const mode = targetPreset.policy && targetPreset.policy.mode === "mcp" ? "mcp" : undefined;
|
|
145
|
+
return { disabled, groups, ...(mode ? { mode } : {}), skippedGroups };
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The empty policy a Preset resets to.
|
|
149
|
+
*
|
|
150
|
+
* Loading mode survives a reset for the same reason it survives a copy:
|
|
151
|
+
* it is a Preset-level choice, not one of the groups being cleared.
|
|
152
|
+
* Dropping it flipped an MCP 按需 Preset back to default mode and
|
|
153
|
+
* re-registered the discovery tool the Preset had switched away from.
|
|
154
|
+
*/
|
|
155
|
+
function resetPresetPolicy(policy) {
|
|
156
|
+
const mode = policy && policy.mode === "mcp" ? "mcp" : undefined;
|
|
157
|
+
return { disabled: [], groups: [], ...(mode ? { mode } : {}) };
|
|
136
158
|
}
|
|
137
159
|
function settingsPayload(value) {
|
|
138
160
|
const settings = { presets: {} };
|
|
139
161
|
for (const item of value && value.presets || []) settings.presets[item.id] = policyPayload(item.policy);
|
|
162
|
+
// `null` is an explicit "follow the default model again". A MISSING key
|
|
163
|
+
// is what a page loaded before this setting existed sends, and the Host
|
|
164
|
+
// reads that as "leave the stored choice alone".
|
|
165
|
+
settings.generation = generationPayload(value);
|
|
140
166
|
return settings;
|
|
141
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* The shared AI generation model, normalized for persistence.
|
|
170
|
+
*
|
|
171
|
+
* Auto-naming and auto-grouping only classify tools and print JSON, so both
|
|
172
|
+
* may run a fast model instead of a slow default one. A pinned route is
|
|
173
|
+
* stored as `{provider, model}`; an effort chosen while still running the
|
|
174
|
+
* default model is stored on its own, so the plugin keeps picking whatever
|
|
175
|
+
* the deployment default is and only overrides its reasoning effort.
|
|
176
|
+
*/
|
|
177
|
+
function generationPayload(value) {
|
|
178
|
+
const choice = value && value.generation;
|
|
179
|
+
if (!choice || typeof choice !== "object") return null;
|
|
180
|
+
const provider = typeof choice.provider === "string" ? choice.provider.trim() : "";
|
|
181
|
+
const model = typeof choice.model === "string" ? choice.model.trim() : "";
|
|
182
|
+
const reasoningEffort = typeof choice.reasoningEffort === "string" ? choice.reasoningEffort.trim() : "";
|
|
183
|
+
if (provider && model) return { provider, model, ...(reasoningEffort ? { reasoningEffort } : {}) };
|
|
184
|
+
if (reasoningEffort) return { reasoningEffort };
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* The selection a generation request will run.
|
|
189
|
+
*
|
|
190
|
+
* A stored choice either pins a route or only overrides the effort of the
|
|
191
|
+
* default model; both end up here as one concrete provider/model/effort,
|
|
192
|
+
* which is what the picker shows and what the dialogs name.
|
|
193
|
+
*/
|
|
194
|
+
function effectiveGenerationModel(choice, fallback) {
|
|
195
|
+
const pinned = choice && choice.provider && choice.model ? choice : null;
|
|
196
|
+
const base = pinned || fallback;
|
|
197
|
+
if (!base || !base.provider || !base.model) return null;
|
|
198
|
+
const effort = pinned
|
|
199
|
+
? (choice.reasoningEffort || "")
|
|
200
|
+
: ((choice && choice.reasoningEffort) || (fallback && fallback.reasoningEffort) || "");
|
|
201
|
+
return { provider: base.provider, model: base.model, ...(effort ? { reasoningEffort: effort } : {}) };
|
|
202
|
+
}
|
|
203
|
+
/** Whether a selection is exactly the deployment default route. */
|
|
204
|
+
function isDefaultSelection(selection, fallback) {
|
|
205
|
+
return !!(selection && fallback && selection.provider === fallback.provider && selection.model === fallback.model);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* The level a switched-to model should run, given the one in use before.
|
|
209
|
+
*
|
|
210
|
+
* Dropping the level whenever the new model does not declare it is what made
|
|
211
|
+
* switching models silently fall back to the deployment default's own level
|
|
212
|
+
* (Max here), which is the slowest possible outcome for a run the reader had
|
|
213
|
+
* just set to Off. The declared levels are ordered least to greatest, so the
|
|
214
|
+
* same relative position is carried over: Off on a four-step model lands on
|
|
215
|
+
* the cheapest step of a three-step one, Max still lands on Max.
|
|
216
|
+
*/
|
|
217
|
+
function carryReasoningEffort(previous, previousEfforts, nextEfforts, nextDefault) {
|
|
218
|
+
if (!previous) return "";
|
|
219
|
+
const ids = (list) => (list || []).map((effort) => effort.id);
|
|
220
|
+
const next = ids(nextEfforts);
|
|
221
|
+
if (next.length === 0) return "";
|
|
222
|
+
if (next.includes(previous)) return previous;
|
|
223
|
+
if (nextDefault && next.includes(nextDefault)) return nextDefault;
|
|
224
|
+
const from = ids(previousEfforts);
|
|
225
|
+
const index = from.indexOf(previous);
|
|
226
|
+
if (index < 0 || from.length < 2) return next[0];
|
|
227
|
+
const position = Math.round((index / (from.length - 1)) * (next.length - 1));
|
|
228
|
+
return next[Math.min(Math.max(position, 0), next.length - 1)];
|
|
229
|
+
}
|
|
230
|
+
/** One model picker value: JSON so provider/model ids may contain anything. */
|
|
231
|
+
function generationModelValue(choice) {
|
|
232
|
+
if (!choice || !choice.provider || !choice.model) return "";
|
|
233
|
+
return JSON.stringify([choice.provider, choice.model]);
|
|
234
|
+
}
|
|
235
|
+
/** Read a model picker value back; `""` means "follow the default model". */
|
|
236
|
+
function parseGenerationModelValue(value) {
|
|
237
|
+
if (typeof value !== "string" || !value) return null;
|
|
238
|
+
let parsed;
|
|
239
|
+
try {
|
|
240
|
+
parsed = JSON.parse(value);
|
|
241
|
+
} catch {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
if (!Array.isArray(parsed) || parsed.length !== 2) return null;
|
|
245
|
+
const [provider, model] = parsed;
|
|
246
|
+
if (typeof provider !== "string" || typeof model !== "string" || !provider || !model) return null;
|
|
247
|
+
return { provider, model };
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Which model a generation request will run, named for the reader.
|
|
251
|
+
*
|
|
252
|
+
* The dialogs used to say "当前默认模型" unconditionally, which became wrong
|
|
253
|
+
* as soon as the generation model could be set separately. The name and the
|
|
254
|
+
* level come from the catalog when it lists them, so the sentence and the
|
|
255
|
+
* picker read the same: the sentence prints a level exactly when the picker
|
|
256
|
+
* has one selected.
|
|
257
|
+
*/
|
|
258
|
+
function generationTargetLabel(choice, fallback, catalog) {
|
|
259
|
+
const effective = effectiveGenerationModel(choice, fallback);
|
|
260
|
+
if (!effective) return "未配置的模型";
|
|
261
|
+
const entry = findModelEntry(catalog, effective);
|
|
262
|
+
const name = entry && entry.name ? entry.name : effective.provider + "/" + effective.model;
|
|
263
|
+
const chosen = effective.reasoningEffort || "";
|
|
264
|
+
const effort = chosen
|
|
265
|
+
? ((entry && entry.reasoning ? (entry.reasoning.efforts || []).find((item) => item.id === chosen) : null) || { name: chosen })
|
|
266
|
+
: null;
|
|
267
|
+
return "「" + name + (effort ? " · 推理 " + effort.name : "") + "」";
|
|
268
|
+
}
|
|
269
|
+
/** The catalog entry for a choice, or null when the catalog does not list it. */
|
|
270
|
+
function findModelEntry(catalog, choice) {
|
|
271
|
+
if (!catalog || !choice) return null;
|
|
272
|
+
for (const group of catalog.groups || []) {
|
|
273
|
+
if (group.id !== choice.provider) continue;
|
|
274
|
+
return (group.models || []).find((model) => model.id === choice.model) || null;
|
|
275
|
+
}
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
142
278
|
function settingsSignature(value) {
|
|
143
279
|
return JSON.stringify(settingsPayload(value));
|
|
144
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* Why the save button cannot run, or null when it can.
|
|
283
|
+
*
|
|
284
|
+
* The button is disabled in four different situations and used to look
|
|
285
|
+
* identical in all of them, so a click that did nothing was
|
|
286
|
+
* indistinguishable from a click that saved. Order matters: the
|
|
287
|
+
* read-only config comes first because waiting never fixes it, while
|
|
288
|
+
* the other two clear themselves.
|
|
289
|
+
*/
|
|
290
|
+
function saveBlockReason(state) {
|
|
291
|
+
if (!state || state.writable !== true) return "当前配置文件不可写,不能保存。";
|
|
292
|
+
if (state.busy) return "正在处理上一个请求,请稍后再保存。";
|
|
293
|
+
if (state.autoGrouping) return "自动分组正在进行,请等它结束后再保存。";
|
|
294
|
+
if (!state.dirty) return "没有需要保存的修改。";
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* The Preset a save error blames, or null when it blames none.
|
|
299
|
+
*
|
|
300
|
+
* Both validation paths quote the id inside curly quotes: the page uses
|
|
301
|
+
* “id” and the server uses "id". Only a quoted run that is exactly one of
|
|
302
|
+
* the known ids counts, so a quoted group or tool name is not mistaken
|
|
303
|
+
* for a Preset.
|
|
304
|
+
*/
|
|
305
|
+
function errorPresetId(message, presetIds) {
|
|
306
|
+
if (typeof message !== "string" || message === "") return null;
|
|
307
|
+
const known = new Set(presetIds || []);
|
|
308
|
+
for (const match of message.matchAll(/[\u201c"]([^\u201d"]+)[\u201d"]/g)) {
|
|
309
|
+
if (known.has(match[1])) return match[1];
|
|
310
|
+
}
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
145
313
|
function matchesPattern(value, pattern) {
|
|
146
314
|
if (!pattern.includes("*")) return value === pattern;
|
|
147
315
|
const escaped = pattern.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".*");
|
|
@@ -416,6 +584,46 @@ window.__ModuleLoader__.load({
|
|
|
416
584
|
"tool_list 只在当前 Preset 有有效按需组时才出现(保存后从下一个模型步骤生效),没有有效按需组时模型看不到它;它由插件自动管理,不出现在本页工具目录中,也不能在这里开关或分组。",
|
|
417
585
|
].join("\n");
|
|
418
586
|
|
|
587
|
+
// MCP mode replaces the group opener with tool_find, so the same two
|
|
588
|
+
// paragraphs have to name the other tool. The header keeps one help
|
|
589
|
+
// entry point and picks the wording from the preset loading mode.
|
|
590
|
+
const TOOL_CATALOG_HELP_MCP = [
|
|
591
|
+
"关掉后立刻对模型隐藏。按需组只声明组名与描述,组内工具不单独声明;模型用 tool_find 读取整组用法后可直接按名调用,不需要开组。",
|
|
592
|
+
"",
|
|
593
|
+
"tool_find 由插件自动注册,不出现在本页目录中,也不能在这里开关或分组;它只在当前 Preset 有有效按需组时出现。",
|
|
594
|
+
"",
|
|
595
|
+
"注意:部分供应商会限制工具调用名,此时 MCP 按需模式无法正常调用组内工具,请改用「默认」加载模式。",
|
|
596
|
+
].join("\n");
|
|
597
|
+
|
|
598
|
+
function toolCatalogHelp(mcpMode) {
|
|
599
|
+
return mcpMode ? TOOL_CATALOG_HELP_MCP : TOOL_CATALOG_HELP;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// One help entry next to the mode label. Both mode explanations live
|
|
603
|
+
// there instead of on the chips, so the warning below covers the whole
|
|
604
|
+
// choice instead of looking like a property of one hovered button.
|
|
605
|
+
const LOADING_MODE_HELP = [
|
|
606
|
+
"默认:组内工具平时不声明;模型用 tool_list({ group }) 打开一组后,这组工具才进入工具表。",
|
|
607
|
+
"",
|
|
608
|
+
"MCP 按需:组内工具始终不进工具表;模型用 tool_find({ group }) 看整组参数,随时能按名字直接调用。",
|
|
609
|
+
"",
|
|
610
|
+
"注意:MCP 按需依赖模型能够直接发出未声明的工具名。部分供应商会限制工具调用名(例如 OpenCode Go),模型只能反复调用 tool_find,无法真正调用组内工具;遇到这种情况请改用「默认」加载模式。",
|
|
611
|
+
].join("\n");
|
|
612
|
+
|
|
613
|
+
// The generation model is a global choice, not a Preset one: auto-naming
|
|
614
|
+
// and auto-grouping classify tools and print JSON, so a fast model is
|
|
615
|
+
// usually enough even when the conversation runs a slow reasoning one.
|
|
616
|
+
// It is offered inside both dialogs that spend a request — 「自动分组」
|
|
617
|
+
// and the group editor's 「自动生成名称和描述」.
|
|
618
|
+
const GENERATION_MODEL_HELP = [
|
|
619
|
+
"「自动分组」和「手动分组」里生成名称、描述时共用的模型,对所有 Preset 生效。",
|
|
620
|
+
"",
|
|
621
|
+
"默认就是 DSH 当前的默认模型及其推理强度;也可以换成任意已注册的 Provider + 模型,并单独选推理强度,「模型默认」表示不额外指定。",
|
|
622
|
+
"",
|
|
623
|
+
"所选模型已不可用(被删除或未配置)时,生成会回退到默认模型并明确提示,不会静默失败。",
|
|
624
|
+
"改动立即写入配置文件,不需要再点「保存」。",
|
|
625
|
+
].join("\n");
|
|
626
|
+
|
|
419
627
|
function ToolManagerSection() {
|
|
420
628
|
const [snapshot, setSnapshot] = react.useState(null);
|
|
421
629
|
const [draft, setDraft] = react.useState(null);
|
|
@@ -434,6 +642,10 @@ window.__ModuleLoader__.load({
|
|
|
434
642
|
const [aiConfirm, setAiConfirm] = react.useState(null);
|
|
435
643
|
const [suggestionTimeoutSeconds, setSuggestionTimeoutSeconds] = react.useState("60");
|
|
436
644
|
const [autoGroupTimeoutSeconds, setAutoGroupTimeoutSeconds] = react.useState("120");
|
|
645
|
+
const [models, setModels] = react.useState(null);
|
|
646
|
+
const [modelsError, setModelsError] = react.useState("");
|
|
647
|
+
const [generationSaveError, setGenerationSaveError] = react.useState("");
|
|
648
|
+
const [aiNotice, setAiNotice] = react.useState("");
|
|
437
649
|
|
|
438
650
|
const load = react.useCallback((attempt) => {
|
|
439
651
|
const tries = attempt || 0;
|
|
@@ -454,6 +666,15 @@ window.__ModuleLoader__.load({
|
|
|
454
666
|
}).finally(() => setBusy(false));
|
|
455
667
|
}, []);
|
|
456
668
|
react.useEffect(() => { load(); }, [load]);
|
|
669
|
+
// The picker is the only consumer of the model catalog, so a failure
|
|
670
|
+
// here leaves "跟随默认模型" usable instead of blocking the whole page.
|
|
671
|
+
react.useEffect(() => {
|
|
672
|
+
let live = true;
|
|
673
|
+
api("/models")
|
|
674
|
+
.then((value) => { if (live) { setModels(value); setModelsError(""); } })
|
|
675
|
+
.catch((e) => { if (live) setModelsError(String(e.message || e)); });
|
|
676
|
+
return () => { live = false; };
|
|
677
|
+
}, []);
|
|
457
678
|
const dirty = !!(snapshot && draft && settingsSignature(snapshot) !== settingsSignature(draft));
|
|
458
679
|
react.useEffect(() => {
|
|
459
680
|
if (!dirty) return undefined;
|
|
@@ -500,6 +721,113 @@ window.__ModuleLoader__.load({
|
|
|
500
721
|
});
|
|
501
722
|
}
|
|
502
723
|
|
|
724
|
+
function setMode(mode) {
|
|
725
|
+
mutatePreset((target) => {
|
|
726
|
+
if (mode === "mcp") {
|
|
727
|
+
target.policy.mode = "mcp";
|
|
728
|
+
} else {
|
|
729
|
+
delete target.policy.mode;
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Choose the shared generation model, or `null` to let the plugin pick.
|
|
736
|
+
*
|
|
737
|
+
* The choice is persisted right away — this setting belongs to no
|
|
738
|
+
* Preset, so waiting for 「保存」 would only ask the reader to save a page
|
|
739
|
+
* they did not change. The draft still moves first, so the picker and the
|
|
740
|
+
* next request see the choice even while the write is in flight.
|
|
741
|
+
*/
|
|
742
|
+
function setGenerationChoice(choice) {
|
|
743
|
+
setDraft((current) => {
|
|
744
|
+
if (!current) return current;
|
|
745
|
+
const next = clone(current);
|
|
746
|
+
if (choice) next.generation = { ...choice };
|
|
747
|
+
else delete next.generation;
|
|
748
|
+
return next;
|
|
749
|
+
});
|
|
750
|
+
setMessage("");
|
|
751
|
+
setAiNotice("");
|
|
752
|
+
persistGeneration(choice);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Write the generation model to the config file.
|
|
757
|
+
*
|
|
758
|
+
* It goes through its own route instead of the page save so it needs no
|
|
759
|
+
* page revision: the Preset policies a page may be drafting are untouched,
|
|
760
|
+
* and the store serializes this write with the next 「保存」.
|
|
761
|
+
*/
|
|
762
|
+
function persistGeneration(choice) {
|
|
763
|
+
setGenerationSaveError("");
|
|
764
|
+
api("/generation", {
|
|
765
|
+
method: "POST",
|
|
766
|
+
body: JSON.stringify({ generation: generationPayload({ generation: choice }) }),
|
|
767
|
+
}).then((result) => {
|
|
768
|
+
if (!result) return;
|
|
769
|
+
// The Host answered with the revision it ended up at. Adopt it so the
|
|
770
|
+
// next 「保存」 sends a revision the store still accepts; take the
|
|
771
|
+
// larger one when two writes of ours raced.
|
|
772
|
+
setSnapshot((current) => {
|
|
773
|
+
if (!current) return current;
|
|
774
|
+
const next = { ...current, revision: Math.max(current.revision || 0, result.revision || 0) };
|
|
775
|
+
if (result.generation) next.generation = { ...result.generation };
|
|
776
|
+
else delete next.generation;
|
|
777
|
+
return next;
|
|
778
|
+
});
|
|
779
|
+
setGenerationSaveError("");
|
|
780
|
+
}).catch((error) => {
|
|
781
|
+
setGenerationSaveError(String(error.message || error));
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* Pick a model for both generation tasks.
|
|
787
|
+
*
|
|
788
|
+
* The chosen level travels with the switch whenever the new model can
|
|
789
|
+
* express it, because it describes how hard the classification should
|
|
790
|
+
* think, not which route runs it. Choosing the deployment default route
|
|
791
|
+
* stores no route at all: that keeps the plugin on whatever the default
|
|
792
|
+
* model becomes. Any other route is persisted.
|
|
793
|
+
*/
|
|
794
|
+
function chooseGenerationModel(value) {
|
|
795
|
+
const picked = parseGenerationModelValue(value);
|
|
796
|
+
if (!picked) return;
|
|
797
|
+
const entry = findModelEntry(models, picked);
|
|
798
|
+
const targetEfforts = entry && entry.reasoning ? entry.reasoning.efforts || [] : [];
|
|
799
|
+
const keep = carryReasoningEffort(
|
|
800
|
+
generationEffortValue,
|
|
801
|
+
generationEntry && generationEntry.reasoning ? generationEntry.reasoning.efforts || [] : [],
|
|
802
|
+
targetEfforts,
|
|
803
|
+
entry && entry.reasoning ? entry.reasoning.defaultEffort : undefined,
|
|
804
|
+
);
|
|
805
|
+
setGenerationChoice(isDefaultSelection(picked, defaultSelection)
|
|
806
|
+
? (keep ? { reasoningEffort: keep } : null)
|
|
807
|
+
: { provider: picked.provider, model: picked.model, ...(keep ? { reasoningEffort: keep } : {}) });
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* Pick the reasoning level of whichever model the picker currently shows.
|
|
812
|
+
*
|
|
813
|
+
* The level is stored even while the model stays the default one, so the
|
|
814
|
+
* picker never has to be locked just because the route was not pinned.
|
|
815
|
+
* "默认" stores nothing, which keeps following whatever level the model
|
|
816
|
+
* or the deployment default already uses.
|
|
817
|
+
*/
|
|
818
|
+
function chooseGenerationEffort(reasoningEffort) {
|
|
819
|
+
if (!generationModel) return;
|
|
820
|
+
if (!isDefaultSelection(generationModel, defaultSelection)) {
|
|
821
|
+
setGenerationChoice({
|
|
822
|
+
provider: generationModel.provider,
|
|
823
|
+
model: generationModel.model,
|
|
824
|
+
...(reasoningEffort ? { reasoningEffort } : {}),
|
|
825
|
+
});
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
setGenerationChoice(reasoningEffort ? { reasoningEffort } : null);
|
|
829
|
+
}
|
|
830
|
+
|
|
503
831
|
function openCreate() {
|
|
504
832
|
setModal({
|
|
505
833
|
mode: "create",
|
|
@@ -515,9 +843,9 @@ window.__ModuleLoader__.load({
|
|
|
515
843
|
|
|
516
844
|
function resetPresetConfig() {
|
|
517
845
|
if (!hasPresetConfig) return;
|
|
518
|
-
if (!window.confirm("确定重置当前 Preset
|
|
846
|
+
if (!window.confirm("确定重置当前 Preset 的配置吗?这会清空它的全部按需组和已关闭工具,加载模式保持不变;只修改页面草稿,保存后生效。")) return;
|
|
519
847
|
mutatePreset((target) => {
|
|
520
|
-
target.policy =
|
|
848
|
+
target.policy = resetPresetPolicy(target.policy);
|
|
521
849
|
});
|
|
522
850
|
setQuery("");
|
|
523
851
|
setFilter("all");
|
|
@@ -557,7 +885,7 @@ window.__ModuleLoader__.load({
|
|
|
557
885
|
if (target.id === source.id || !selected.has(target.id) || target.broken) continue;
|
|
558
886
|
const copied = copyPresetPolicy(source, target);
|
|
559
887
|
const before = JSON.stringify(policyPayload(target.policy));
|
|
560
|
-
const after = JSON.stringify(policyPayload(
|
|
888
|
+
const after = JSON.stringify(policyPayload(copied));
|
|
561
889
|
plans.push({ targetId: target.id, label: target.name || target.id, copied, changed: before !== after });
|
|
562
890
|
}
|
|
563
891
|
if (!plans.length) { setCopyDialog(null); return; }
|
|
@@ -569,6 +897,7 @@ window.__ModuleLoader__.load({
|
|
|
569
897
|
target.policy = {
|
|
570
898
|
disabled: [...plan.copied.disabled],
|
|
571
899
|
groups: plan.copied.groups.map((group) => ({ ...group, _key: newKey() })),
|
|
900
|
+
...(plan.copied.mode ? { mode: plan.copied.mode } : {}),
|
|
572
901
|
};
|
|
573
902
|
}
|
|
574
903
|
return next;
|
|
@@ -638,7 +967,6 @@ window.__ModuleLoader__.load({
|
|
|
638
967
|
setAiConfirm({
|
|
639
968
|
kind: "suggest",
|
|
640
969
|
title: "确认自动生成名称和描述",
|
|
641
|
-
message: "将所选工具的名称和描述发送给当前默认模型,并产生一次模型请求。",
|
|
642
970
|
timeoutSeconds: suggestionTimeoutSeconds,
|
|
643
971
|
prompt: initialPrompt,
|
|
644
972
|
promptCustom: false,
|
|
@@ -646,13 +974,16 @@ window.__ModuleLoader__.load({
|
|
|
646
974
|
error: "",
|
|
647
975
|
run: (timeoutMs, _tools, prompt) => {
|
|
648
976
|
setSuggestionTimeoutSeconds(String(timeoutMs / 1000));
|
|
649
|
-
|
|
977
|
+
setAiNotice("");
|
|
978
|
+
patchModal({ generating: true, generateError: "", generateNotice: "" });
|
|
650
979
|
api("/suggest-group", {
|
|
651
980
|
method: "POST",
|
|
652
|
-
body: JSON.stringify({ presetId: preset.id, toolNames, otherGroupNames, timeoutMs, prompt }),
|
|
981
|
+
body: JSON.stringify({ presetId: preset.id, toolNames, otherGroupNames, timeoutMs, prompt, generation: generationPayload(draft) }),
|
|
653
982
|
}).then((suggestion) => {
|
|
983
|
+
const notice = suggestion.modelNotice ? String(suggestion.modelNotice) : "";
|
|
984
|
+
if (notice) setAiNotice(notice);
|
|
654
985
|
setModal((current) => current && current.key === key
|
|
655
|
-
? { ...current, name: suggestion.name || current.name, description: suggestion.description || current.description, generating: false, generateError: "" }
|
|
986
|
+
? { ...current, name: suggestion.name || current.name, description: suggestion.description || current.description, generating: false, generateError: "", generateNotice: notice }
|
|
656
987
|
: current);
|
|
657
988
|
}).catch((e) => {
|
|
658
989
|
setModal((current) => current && current.key === key
|
|
@@ -709,7 +1040,6 @@ window.__ModuleLoader__.load({
|
|
|
709
1040
|
setAiConfirm({
|
|
710
1041
|
kind: "auto-group",
|
|
711
1042
|
title: "确认自动分组",
|
|
712
|
-
message: "筛选并勾选需要分组的工具,发送给当前默认模型进行聚类。",
|
|
713
1043
|
timeoutSeconds: autoGroupTimeoutSeconds,
|
|
714
1044
|
query: "",
|
|
715
1045
|
selected: allCandidateNames,
|
|
@@ -719,13 +1049,15 @@ window.__ModuleLoader__.load({
|
|
|
719
1049
|
error: "",
|
|
720
1050
|
run: (timeoutMs, selectedToolNames, prompt) => {
|
|
721
1051
|
setAutoGroupTimeoutSeconds(String(timeoutMs / 1000));
|
|
722
|
-
setAutoGrouping(true); setAutoGroupError(""); setAutoPreview(null);
|
|
1052
|
+
setAutoGrouping(true); setAutoGroupError(""); setAutoPreview(null); setAiNotice("");
|
|
723
1053
|
const signature = autoGroupSignature(selectedToolNames, otherGroupNames);
|
|
724
1054
|
api("/auto-group", {
|
|
725
1055
|
method: "POST",
|
|
726
|
-
body: JSON.stringify({ presetId: preset.id, toolNames: selectedToolNames, otherGroupNames, timeoutMs, prompt }),
|
|
1056
|
+
body: JSON.stringify({ presetId: preset.id, toolNames: selectedToolNames, otherGroupNames, timeoutMs, prompt, generation: generationPayload(draft) }),
|
|
727
1057
|
}).then((result) => {
|
|
728
|
-
|
|
1058
|
+
const notice = result.modelNotice ? String(result.modelNotice) : "";
|
|
1059
|
+
if (notice) setAiNotice(notice);
|
|
1060
|
+
setAutoPreview({ presetId: preset.id, signature, selectedTools: selectedToolNames, groups: result.groups || [], ungrouped: result.ungrouped || [], notice });
|
|
729
1061
|
}).catch((e) => setAutoGroupError(String(e.message || e))).finally(() => setAutoGrouping(false));
|
|
730
1062
|
},
|
|
731
1063
|
});
|
|
@@ -792,6 +1124,9 @@ window.__ModuleLoader__.load({
|
|
|
792
1124
|
function save() {
|
|
793
1125
|
for (const item of draft.presets || []) {
|
|
794
1126
|
if (item.broken) continue;
|
|
1127
|
+
// Groups are inert in mcp mode, so a stale/empty group must not
|
|
1128
|
+
// block saving the mode switch.
|
|
1129
|
+
if (item.policy.mode === "mcp") continue;
|
|
795
1130
|
const issues = groupDraftIssues(item);
|
|
796
1131
|
if (issues.disabledMembers.length) {
|
|
797
1132
|
const issue = issues.disabledMembers[0];
|
|
@@ -816,7 +1151,7 @@ window.__ModuleLoader__.load({
|
|
|
816
1151
|
api("/save", { method: "POST", body: JSON.stringify({ expectedRevision: snapshot.revision, settings }) })
|
|
817
1152
|
.then((value) => {
|
|
818
1153
|
const next = withGroupKeys(value);
|
|
819
|
-
setSnapshot(value); setDraft(next); setModal(null); setCopyDialog(null);
|
|
1154
|
+
setSnapshot(value); setDraft(next); setModal(null); setCopyDialog(null); setAiNotice("");
|
|
820
1155
|
setMessage("已保存;运行中 Agent 将从下一个模型步骤应用新策略。");
|
|
821
1156
|
})
|
|
822
1157
|
.catch((e) => setError(String(e.message || e)))
|
|
@@ -825,6 +1160,31 @@ window.__ModuleLoader__.load({
|
|
|
825
1160
|
|
|
826
1161
|
const disabled = new Set(preset.policy.disabled || []);
|
|
827
1162
|
const grouped = groupedNames(preset);
|
|
1163
|
+
const mcpMode = preset.policy.mode === "mcp";
|
|
1164
|
+
const generationChoice = draft.generation || null;
|
|
1165
|
+
const defaultSelection = draft.defaultSelection || null;
|
|
1166
|
+
// What the next request will actually run: a pinned model, else the
|
|
1167
|
+
// deployment default one. The picker always shows a concrete model, so
|
|
1168
|
+
// there is no "follow the default" row to read.
|
|
1169
|
+
const generationModel = effectiveGenerationModel(generationChoice, defaultSelection);
|
|
1170
|
+
const generationEntry = findModelEntry(models, generationModel);
|
|
1171
|
+
// A provider whose own catalog failed tells us nothing about its models,
|
|
1172
|
+
// so only a readable catalog that simply lacks the model is proof.
|
|
1173
|
+
const generationCatalogFailed = !!(models && generationModel
|
|
1174
|
+
&& (models.failures || []).some((item) => item.id === generationModel.provider));
|
|
1175
|
+
const generationUnavailable = !!(generationModel && models && !generationEntry && !generationCatalogFailed);
|
|
1176
|
+
const generationEfforts = generationEntry && generationEntry.reasoning
|
|
1177
|
+
? generationEntry.reasoning.efforts || []
|
|
1178
|
+
: [];
|
|
1179
|
+
// The dropdown shows the level in effect, so "默认" is only shown while no
|
|
1180
|
+
// level is in effect at all. Following the deployment default model means
|
|
1181
|
+
// running ITS level, so the select reads Max there rather than "默认".
|
|
1182
|
+
const generationEffortValue = generationModel && generationModel.reasoningEffort
|
|
1183
|
+
? generationModel.reasoningEffort
|
|
1184
|
+
: "";
|
|
1185
|
+
const generationLabel = generationTargetLabel(generationChoice, defaultSelection, models);
|
|
1186
|
+
const saveBlocked = saveBlockReason({ busy, autoGrouping, writable: draft.writable, dirty });
|
|
1187
|
+
const errorPreset = errorPresetId(error, (draft.presets || []).map((item) => item.id));
|
|
828
1188
|
const autoGroupCandidates = (preset.tools || []).filter((tool) => !disabled.has(tool.name) && !grouped.has(tool.name));
|
|
829
1189
|
const stats = catalogStats(preset);
|
|
830
1190
|
const tokenStats = presetTokenStats(preset);
|
|
@@ -848,8 +1208,8 @@ window.__ModuleLoader__.load({
|
|
|
848
1208
|
});
|
|
849
1209
|
const showGroups = filter === "all" || filter === "cold";
|
|
850
1210
|
const visibleTools = (preset.tools || []).filter((tool) => {
|
|
851
|
-
if (filter === "cold") return false;
|
|
852
1211
|
if (!matchesQuery(tool, needle)) return false;
|
|
1212
|
+
if (filter === "cold") return false;
|
|
853
1213
|
if (filter === "disabled") return disabled.has(tool.name);
|
|
854
1214
|
if (filter === "live") return !disabled.has(tool.name) && !grouped.has(tool.name);
|
|
855
1215
|
return !grouped.has(tool.name);
|
|
@@ -943,12 +1303,129 @@ window.__ModuleLoader__.load({
|
|
|
943
1303
|
);
|
|
944
1304
|
}
|
|
945
1305
|
|
|
1306
|
+
/**
|
|
1307
|
+
* The confirm text, derived at render time so it follows the picker.
|
|
1308
|
+
*
|
|
1309
|
+
* It used to be frozen when the dialog opened, which made the headline
|
|
1310
|
+
* lie as soon as the model was changed in the dialog it describes.
|
|
1311
|
+
*/
|
|
1312
|
+
function aiConfirmMessage() {
|
|
1313
|
+
if (!aiConfirm) return "";
|
|
1314
|
+
return aiConfirm.kind === "auto-group"
|
|
1315
|
+
? "筛选并勾选需要分组的工具,发送给" + generationLabel + "进行聚类。"
|
|
1316
|
+
: "将所选工具的名称和描述发送给" + generationLabel + ",并产生一次模型请求。";
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
/**
|
|
1320
|
+
* The shared generation model control, rendered inside a dialog.
|
|
1321
|
+
*
|
|
1322
|
+
* It belongs to whichever dialog is about to spend a model request —
|
|
1323
|
+
* 「自动分组」 and 「手动分组」 — so the reader can shrink the model right
|
|
1324
|
+
* where the cost is about to happen. Both dialogs edit one value. The
|
|
1325
|
+
* model and its reasoning effort share one line: the effort only matters
|
|
1326
|
+
* for the model next to it.
|
|
1327
|
+
*/
|
|
1328
|
+
function renderGenerationPicker() {
|
|
1329
|
+
const pinned = !!(generationChoice && generationChoice.provider && generationChoice.model);
|
|
1330
|
+
const listed = !!generationEntry;
|
|
1331
|
+
// A reader recognises the provider's own display name, not a route, so
|
|
1332
|
+
// the option text is just that name. The provider is appended only when
|
|
1333
|
+
// two routes would read identically; the route itself is the tooltip.
|
|
1334
|
+
const catalogGroups = models ? models.groups || [] : [];
|
|
1335
|
+
const displayName = (model) => (model.name && model.name !== model.id ? model.name : model.id);
|
|
1336
|
+
const nameCounts = new Map();
|
|
1337
|
+
for (const group of catalogGroups) {
|
|
1338
|
+
for (const model of group.models || []) {
|
|
1339
|
+
const name = displayName(model);
|
|
1340
|
+
nameCounts.set(name, (nameCounts.get(name) || 0) + 1);
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
const modelOptions = catalogGroups.map((group) => h("optgroup", {
|
|
1344
|
+
key: group.id,
|
|
1345
|
+
label: group.name || group.id,
|
|
1346
|
+
}, (group.models || []).map((model) => {
|
|
1347
|
+
const name = displayName(model);
|
|
1348
|
+
const unique = nameCounts.get(name) === 1;
|
|
1349
|
+
return h("option", {
|
|
1350
|
+
key: model.id,
|
|
1351
|
+
value: generationModelValue({ provider: group.id, model: model.id }),
|
|
1352
|
+
title: group.id + "/" + model.id,
|
|
1353
|
+
}, unique || !group.name ? name : name + " · " + group.name);
|
|
1354
|
+
})));
|
|
1355
|
+
// The effective model may not be in the catalog: the default route can
|
|
1356
|
+
// be unlisted, a saved route can be gone, and the catalog can still be
|
|
1357
|
+
// loading. Keep it selectable so the row never shows a wrong model.
|
|
1358
|
+
const unlistedLabel = generationModel
|
|
1359
|
+
? generationModel.provider + "/" + generationModel.model + (pinned ? "(当前不可用)" : "")
|
|
1360
|
+
: "";
|
|
1361
|
+
// An effort the catalog does not list for this route still has to be
|
|
1362
|
+
// readable, otherwise the closed select would show a different level.
|
|
1363
|
+
const undeclaredLevel = listed && generationEffortValue
|
|
1364
|
+
&& !generationEfforts.some((effort) => effort.id === generationEffortValue)
|
|
1365
|
+
? generationEffortValue
|
|
1366
|
+
: "";
|
|
1367
|
+
return h("div", { className: "tm_model_block", key: "generation" },
|
|
1368
|
+
h("div", { className: "tm_model_row" },
|
|
1369
|
+
h("span", { className: "tm_model_label", title: GENERATION_MODEL_HELP, key: "modelLabel" }, "生成模型"),
|
|
1370
|
+
h("span", { className: "tm_select_wrap tm_model_pick", key: "modelPick" },
|
|
1371
|
+
h("select", {
|
|
1372
|
+
className: "tm_preset_select",
|
|
1373
|
+
value: generationModelValue(generationModel),
|
|
1374
|
+
disabled: busy || !generationModel,
|
|
1375
|
+
title: "自动命名与自动分组共用的模型,默认是 DSH 当前的默认模型。选一个快速模型可以明显缩短生成时间。",
|
|
1376
|
+
onChange: (event) => chooseGenerationModel(event.target.value),
|
|
1377
|
+
},
|
|
1378
|
+
!generationModel ? h("option", { value: "" }, "没有可用的默认模型") : null,
|
|
1379
|
+
modelOptions,
|
|
1380
|
+
generationModel && !listed ? h("option", { value: generationModelValue(generationModel) }, unlistedLabel) : null,
|
|
1381
|
+
),
|
|
1382
|
+
),
|
|
1383
|
+
listed
|
|
1384
|
+
? [
|
|
1385
|
+
h("span", {
|
|
1386
|
+
className: "tm_model_label",
|
|
1387
|
+
key: "effortLabel",
|
|
1388
|
+
title: "该模型的推理强度,这里显示的就是本次请求会发送的档位。",
|
|
1389
|
+
}, "推理强度"),
|
|
1390
|
+
h("span", { className: "tm_select_wrap tm_effort_pick", key: "effortPick" },
|
|
1391
|
+
h("select", {
|
|
1392
|
+
className: "tm_preset_select",
|
|
1393
|
+
value: generationEffortValue,
|
|
1394
|
+
disabled: busy || !generationModel,
|
|
1395
|
+
title: "该模型的推理强度。「默认」表示不额外指定,用模型(或 DSH 默认模型)本来的档位。",
|
|
1396
|
+
onChange: (event) => chooseGenerationEffort(event.target.value),
|
|
1397
|
+
},
|
|
1398
|
+
h("option", { value: "" }, "默认"),
|
|
1399
|
+
generationEfforts.map((effort) => h("option", { key: effort.id, value: effort.id }, effort.name)),
|
|
1400
|
+
undeclaredLevel ? h("option", { value: undeclaredLevel }, undeclaredLevel) : null,
|
|
1401
|
+
),
|
|
1402
|
+
),
|
|
1403
|
+
]
|
|
1404
|
+
: h("span", { className: "tm_muted", key: "effortMissing", title: "读不到这个模型的推理强度列表,暂时不能指定。" }, "读不到该模型的推理强度"),
|
|
1405
|
+
),
|
|
1406
|
+
generationSaveError ? h("div", { className: "tm_error" }, "保存失败:" + generationSaveError) : null,
|
|
1407
|
+
generationUnavailable
|
|
1408
|
+
? h("div", { className: "tm_model_hints" },
|
|
1409
|
+
h("span", { className: "tm_badge off", title: "生成时会自动回退到默认模型,并提示原因" }, "该模型当前不可用"),
|
|
1410
|
+
h("span", { className: "tm_muted" }, "生成时会改用默认模型,并提示原因。"),
|
|
1411
|
+
)
|
|
1412
|
+
: null,
|
|
1413
|
+
modelsError
|
|
1414
|
+
? h("div", { className: "tm_muted" }, "模型列表读取失败:" + modelsError)
|
|
1415
|
+
: (models && (models.failures || []).length
|
|
1416
|
+
? h("div", {
|
|
1417
|
+
className: "tm_muted",
|
|
1418
|
+
title: models.failures.map((item) => item.name + ":" + item.message).join("\n"),
|
|
1419
|
+
}, "有 " + models.failures.length + " 个 Provider 的模型列表读取失败,未列出其模型。")
|
|
1420
|
+
: null),
|
|
1421
|
+
);
|
|
1422
|
+
}
|
|
946
1423
|
const aiConfirmDialog = aiConfirm && typeof document !== "undefined" ? reactDom.createPortal(
|
|
947
1424
|
h("div", { className: "tm_modal", role: "dialog", "aria-modal": "true", "aria-label": aiConfirm.title },
|
|
948
1425
|
h("div", { className: "tm_modal_mask", onMouseDown: () => setAiConfirm(null) }),
|
|
949
1426
|
h("div", { className: "tm_modal_card" },
|
|
950
1427
|
h("div", { className: "tm_modal_head" },
|
|
951
|
-
h("div", null, h("h3", null, aiConfirm.title), h("div", { className: "tm_muted" },
|
|
1428
|
+
h("div", null, h("h3", null, aiConfirm.title), h("div", { className: "tm_muted" }, aiConfirmMessage())),
|
|
952
1429
|
h("button", { className: "tm_btn", onClick: () => setAiConfirm(null) }, "关闭"),
|
|
953
1430
|
),
|
|
954
1431
|
h("div", { className: "tm_modal_body" },
|
|
@@ -973,7 +1450,7 @@ window.__ModuleLoader__.load({
|
|
|
973
1450
|
),
|
|
974
1451
|
aiSelected.size === 0
|
|
975
1452
|
? h("div", { className: "tm_error", key: "status" }, "请至少勾选一个工具进行分组。")
|
|
976
|
-
: h("div", { className: "tm_muted", key: "status" }, "已勾选 " + aiSelected.size + " / " + aiCandidates.length + "
|
|
1453
|
+
: h("div", { className: "tm_muted", key: "status" }, "已勾选 " + aiSelected.size + " / " + aiCandidates.length + " 个候选工具。自动分组会调用" + generationLabel + ",结果仍可手动修改。"),
|
|
977
1454
|
aiVisibleCandidates.length
|
|
978
1455
|
? h("div", { className: "tm_picker", key: "picker" }, aiVisibleCandidates.map((tool) => h("label", { className: "tm_pick", key: tool.name },
|
|
979
1456
|
h("input", {
|
|
@@ -991,6 +1468,7 @@ window.__ModuleLoader__.load({
|
|
|
991
1468
|
),
|
|
992
1469
|
)))
|
|
993
1470
|
: h("div", { className: "tm_muted", key: "empty", style: { padding: "12px" } }, aiCandidates.length ? "没有符合筛选的工具。" : "当前没有可分组的工具。"),
|
|
1471
|
+
renderGenerationPicker(),
|
|
994
1472
|
] : null,
|
|
995
1473
|
h("div", {
|
|
996
1474
|
style: {
|
|
@@ -1116,7 +1594,9 @@ window.__ModuleLoader__.load({
|
|
|
1116
1594
|
h("input", { className: "tm_input", value: modal.name, placeholder: "名称(模型用这个打开)", onChange: (e) => patchModal({ name: e.target.value, generateError: "" }) }),
|
|
1117
1595
|
h("button", { className: "tm_btn", disabled: modal.generating || modalMatchedTools.length === 0 || modalInvalidSelected.length > 0, onClick: generateGroupDetails }, modal.generating ? "生成中…" : "自动生成名称和描述"),
|
|
1118
1596
|
),
|
|
1597
|
+
renderGenerationPicker(),
|
|
1119
1598
|
modal.generateError ? h("div", { className: "tm_error" }, modal.generateError) : null,
|
|
1599
|
+
modal.generateNotice ? h("div", { className: "tm_notice" }, modal.generateNotice) : null,
|
|
1120
1600
|
h("textarea", { className: "tm_input", style: { width: "100%", minHeight: "72px", resize: "vertical" }, value: modal.description, placeholder: "描述(可选)", onChange: (e) => patchModal({ description: e.target.value, generateError: "" }) }),
|
|
1121
1601
|
h("div", { className: "tm_row" },
|
|
1122
1602
|
h("input", { className: "tm_input", value: modal.query, placeholder: "筛选工具名或描述", onChange: (e) => patchModal({ query: e.target.value }) }),
|
|
@@ -1126,7 +1606,7 @@ window.__ModuleLoader__.load({
|
|
|
1126
1606
|
modalInvalidSelected.length
|
|
1127
1607
|
? h("div", { className: "tm_error" }, "以下工具已关闭或属于其他分组,不能加入当前组:" + modalInvalidSelected.join(", ") + "。请取消选择。")
|
|
1128
1608
|
: h("div", { className: modalMatchedTools.length ? "tm_muted" : "tm_error" }, modalMatchedTools.length
|
|
1129
|
-
? "已选 " + modalMatchedTools.length + "
|
|
1609
|
+
? "已选 " + modalMatchedTools.length + " 个工具。自动生成会调用" + generationLabel + ",结果仍可手动修改。"
|
|
1130
1610
|
: "每个按需组至少需要一个未关闭且未被其他组占用的工具。"),
|
|
1131
1611
|
pickerTools.length
|
|
1132
1612
|
? h("div", { className: "tm_picker" }, pickerTools.map((tool) => h("label", { className: "tm_pick", key: tool.name },
|
|
@@ -1171,6 +1651,7 @@ window.__ModuleLoader__.load({
|
|
|
1171
1651
|
h("div", { className: "tm_panel_head" }, h("div", { className: "tm_preview_meta" }, h("b", null, group.name), h("div", { className: "tm_preview_desc" }, group.description)), h("span", { className: "tm_group_count" }, group.tools.length + " 个工具")),
|
|
1172
1652
|
h("div", { style: { padding: "10px 14px" } }, group.tools.map((name) => h("div", { className: "tm_member tm_tool_name", key: name }, name))),
|
|
1173
1653
|
)),
|
|
1654
|
+
autoPreview.notice ? h("div", { className: "tm_notice" }, autoPreview.notice) : null,
|
|
1174
1655
|
autoPreview.ungrouped.length ? h("div", { className: "tm_notice" }, "保持常开、未归组:", h("span", { className: "tm_code" }, autoPreview.ungrouped.join(", "))) : null,
|
|
1175
1656
|
),
|
|
1176
1657
|
h("div", { className: "tm_modal_foot" },
|
|
@@ -1189,16 +1670,17 @@ window.__ModuleLoader__.load({
|
|
|
1189
1670
|
h("div", { className: "tm_modal_head" },
|
|
1190
1671
|
h("div", null,
|
|
1191
1672
|
h("h3", null, "复制当前 Preset 配置"),
|
|
1192
|
-
h("div", { className: "tm_muted" }, "将当前 Preset 的全部按需组和已关闭工具复制到勾选的 Preset
|
|
1673
|
+
h("div", { className: "tm_muted" }, "将当前 Preset 的全部按需组和已关闭工具复制到勾选的 Preset;加载模式不跟随复制,各 Preset 保持自己的「默认 / MCP 按需」设置;只改页面草稿,保存后生效。"),
|
|
1193
1674
|
),
|
|
1194
1675
|
h("button", { className: "tm_btn", onClick: () => setCopyDialog(null) }, "关闭"),
|
|
1195
1676
|
),
|
|
1196
1677
|
h("div", { className: "tm_modal_body" },
|
|
1197
1678
|
h("div", { className: "tm_notice" },
|
|
1198
|
-
"源 Preset「" + (copySource.name || copySource.id) + "
|
|
1679
|
+
"源 Preset「" + (copySource.name || copySource.id) + "」(加载模式:"
|
|
1680
|
+
+ (copySource.policy.mode === "mcp" ? "MCP 按需" : "默认") + "):"
|
|
1199
1681
|
+ (copySource.policy.groups || []).length + " 个按需组、"
|
|
1200
1682
|
+ (copySource.policy.disabled || []).length + " 个已关闭工具。"
|
|
1201
|
-
+ "勾选的目标 Preset
|
|
1683
|
+
+ "勾选的目标 Preset 现有分组和关闭项将被整份覆盖,加载模式不变。",
|
|
1202
1684
|
),
|
|
1203
1685
|
h("div", { className: "tm_row" },
|
|
1204
1686
|
h("button", {
|
|
@@ -1213,6 +1695,7 @@ window.__ModuleLoader__.load({
|
|
|
1213
1695
|
? h("div", { className: "tm_picker" }, copyPreviewRows.map(({ target, preview }) => {
|
|
1214
1696
|
const currentGroups = (target.policy.groups || []).length;
|
|
1215
1697
|
const currentDisabled = (target.policy.disabled || []).length;
|
|
1698
|
+
const targetMode = target.policy.mode === "mcp" ? "MCP 按需" : "默认";
|
|
1216
1699
|
const meta = target.broken
|
|
1217
1700
|
? "工具目录读取失败,暂不能复制"
|
|
1218
1701
|
: "现有 " + currentGroups + " 个组 / " + currentDisabled + " 个关闭项 → 将复制 "
|
|
@@ -1220,6 +1703,7 @@ window.__ModuleLoader__.load({
|
|
|
1220
1703
|
+ (preview.skippedGroups.length
|
|
1221
1704
|
? ";跳过 " + preview.skippedGroups.length + " 个组:" + preview.skippedGroups.join("、")
|
|
1222
1705
|
: "")
|
|
1706
|
+
+ ";加载模式保持「" + targetMode + "」"
|
|
1223
1707
|
+ ((target.tools || []).length === 0 ? ";目标没有可见工具,复制后配置为空" : "");
|
|
1224
1708
|
return h("label", { className: "tm_pick", key: target.id },
|
|
1225
1709
|
h("input", {
|
|
@@ -1260,12 +1744,24 @@ window.__ModuleLoader__.load({
|
|
|
1260
1744
|
h("div", null, h("h2", null, "Agent 工具管理"), h("div", { className: "tm_muted" }, "按每个 Agent 预设开关工具。点「手动分组」把不常用的收进按需组:平时模型看不到,需要时先查目录再打开。")),
|
|
1261
1745
|
h("div", { className: "tm_row" },
|
|
1262
1746
|
h("button", { className: "tm_btn", onClick: reload, disabled: busy || autoGrouping }, "刷新"),
|
|
1263
|
-
h("button", {
|
|
1747
|
+
h("button", {
|
|
1748
|
+
className: "tm_btn primary",
|
|
1749
|
+
onClick: save,
|
|
1750
|
+
disabled: saveBlocked !== null,
|
|
1751
|
+
title: saveBlocked || "把当前草稿写入配置文件",
|
|
1752
|
+
}, busy ? "处理中…" : "保存"),
|
|
1264
1753
|
),
|
|
1265
1754
|
),
|
|
1266
1755
|
dirty ? h("div", { className: "tm_notice", role: "status" }, "有未保存的修改。请点击保存;刷新或离开页面前系统会提醒你。") : null,
|
|
1267
1756
|
!draft.writable ? h("div", { className: "tm_notice" }, "当前配置文件不可写,不能保存。") : null,
|
|
1268
|
-
error ? h("div", { className: "tm_error" },
|
|
1757
|
+
error ? h("div", { className: "tm_error" },
|
|
1758
|
+
errorPreset && errorPreset !== preset.id
|
|
1759
|
+
? h("div", { className: "tm_row" },
|
|
1760
|
+
h("span", null, "这条错误来自 Preset “", errorPreset, "”,不是当前显示的 “", preset.id, "”。"),
|
|
1761
|
+
h("button", { className: "tm_btn", onClick: () => { setActive(errorPreset); setQuery(""); setFilter("all"); } }, "切换到它"),
|
|
1762
|
+
)
|
|
1763
|
+
: error,
|
|
1764
|
+
) : null,
|
|
1269
1765
|
message ? h("div", { className: "tm_notice" }, message) : null,
|
|
1270
1766
|
draft.configPath ? h("div", { className: "tm_muted" }, "配置文件:", h("span", { className: "tm_code" }, draft.configPath)) : null,
|
|
1271
1767
|
h("div", { className: "tm_preset_picker" },
|
|
@@ -1276,30 +1772,36 @@ window.__ModuleLoader__.load({
|
|
|
1276
1772
|
className: "tm_preset_select",
|
|
1277
1773
|
value: preset.id,
|
|
1278
1774
|
disabled: autoGrouping,
|
|
1279
|
-
onChange: (event) => { setActive(event.target.value); setQuery(""); setFilter("all"); setModal(null); setAutoPreview(null); setCopyDialog(null); setAutoGroupError(""); setExpanded({}); },
|
|
1280
|
-
}, draft.presets.map((item) => h("option", { key: item.id, value: item.id }, (item.name || item.id) + " · " + (item.tools || []).length + " 个工具" + (item.isDefault ? " · 默认" : "") + (item.trust === "user" ? " · 用户" : "")))),
|
|
1775
|
+
onChange: (event) => { setActive(event.target.value); setQuery(""); setFilter("all"); setModal(null); setAutoPreview(null); setCopyDialog(null); setAutoGroupError(""); setAiNotice(""); setExpanded({}); },
|
|
1776
|
+
}, draft.presets.map((item) => h("option", { key: item.id, value: item.id }, (item.name || item.id) + " · " + (item.tools || []).length + " 个工具" + (item.isDefault ? " · 默认" : "") + (item.trust === "user" ? " · 用户" : "") + (item.id === errorPreset ? " · 保存失败" : "")))),
|
|
1281
1777
|
),
|
|
1282
1778
|
preset.broken ? null
|
|
1283
1779
|
: isPtc
|
|
1284
1780
|
? h("span", { className: "tm_badge ptc", title: "本 Preset 走 PTC:工具以一份生成的 TypeScript SDK 注入系统提示词,token 按该文本 ÷4 估算(含 run_code 调用声明、PTC 指令段与 SDK 脚手架)" }, "PTC")
|
|
1285
1781
|
: h("span", { className: "tm_badge native", title: "本 Preset 走原生 tool-calling:工具以 JSON schema 随请求发送,token 按 JSON ÷4 估算" }, "原生"),
|
|
1286
1782
|
),
|
|
1783
|
+
h("div", { className: "tm_row", style: { padding: "0 14px 10px" } },
|
|
1784
|
+
h("span", { className: "tm_muted", style: { position: "relative" } }, "加载模式", h("span", { className: "tm_help", tabIndex: 0, "aria-label": "加载模式说明", "data-tip": LOADING_MODE_HELP }, "?")),
|
|
1785
|
+
h("button", { className: "tm_chip" + (mcpMode ? "" : " active"), onClick: () => setMode("groups") }, "默认"),
|
|
1786
|
+
h("button", { className: "tm_chip" + (mcpMode ? " active" : ""), onClick: () => setMode("mcp") }, "MCP 按需"),
|
|
1787
|
+
),
|
|
1287
1788
|
preset.broken ? h("div", { className: "tm_error" }, preset.broken) : null,
|
|
1288
1789
|
autoGroupError ? h("div", { className: "tm_error" }, autoGroupError) : null,
|
|
1790
|
+
aiNotice ? h("div", { className: "tm_notice" }, aiNotice) : null,
|
|
1289
1791
|
h("section", { className: "tm_panel" },
|
|
1290
1792
|
h("div", { className: "tm_panel_head" },
|
|
1291
1793
|
h("div", null,
|
|
1292
|
-
h("b", null, "工具目录", h("span", { className: "tm_help", tabIndex: 0, "aria-label": "工具目录说明", "data-tip":
|
|
1794
|
+
h("b", null, "工具目录", h("span", { className: "tm_help", tabIndex: 0, "aria-label": "工具目录说明", "data-tip": toolCatalogHelp(mcpMode) }, "?")),
|
|
1293
1795
|
),
|
|
1294
1796
|
h("div", { className: "tm_row" },
|
|
1295
|
-
h("button", { className: "tm_btn", onClick: startAutoGroup, disabled: autoGrouping || autoGroupCandidates.length === 0, title: autoGroupCandidates.length ? "
|
|
1797
|
+
h("button", { className: "tm_btn", onClick: startAutoGroup, disabled: autoGrouping || autoGroupCandidates.length === 0, title: autoGroupCandidates.length ? "用" + generationLabel + "对未分组且未关闭的工具进行聚类" : "没有可自动分组的工具" }, autoGrouping ? "自动分组中…" : "自动分组"),
|
|
1296
1798
|
h("button", { className: "tm_btn", onClick: openCreate, disabled: autoGrouping }, "手动分组"),
|
|
1297
1799
|
h("button", {
|
|
1298
1800
|
className: "tm_btn",
|
|
1299
1801
|
onClick: resetPresetConfig,
|
|
1300
1802
|
disabled: autoGrouping || busy || !draft.writable || !hasPresetConfig,
|
|
1301
1803
|
title: hasPresetConfig
|
|
1302
|
-
? "清空当前 Preset
|
|
1804
|
+
? "清空当前 Preset 的全部按需组和已关闭工具(加载模式保持不变)"
|
|
1303
1805
|
: "当前 Preset 没有可重置的配置",
|
|
1304
1806
|
}, "重置配置"),
|
|
1305
1807
|
h("button", {
|
|
@@ -1307,7 +1809,7 @@ window.__ModuleLoader__.load({
|
|
|
1307
1809
|
onClick: openCopyDialog,
|
|
1308
1810
|
disabled: autoGrouping || busy || !draft.writable || !hasPresetConfig || copyTargetCount === 0,
|
|
1309
1811
|
title: hasPresetConfig
|
|
1310
|
-
? "把当前 Preset 的分组和已关闭工具复制到其他 Preset"
|
|
1812
|
+
? "把当前 Preset 的分组和已关闭工具复制到其他 Preset(加载模式不复制)"
|
|
1311
1813
|
: "当前 Preset 没有可复制的分组或已关闭工具",
|
|
1312
1814
|
}, "复制配置"),
|
|
1313
1815
|
),
|
|
@@ -1372,6 +1874,24 @@ window.__ModuleLoader__.load({
|
|
|
1372
1874
|
// Pure policy projection, exported for unit tests. DSH only consumes
|
|
1373
1875
|
// apply/inject, so this does not widen the client plugin contract.
|
|
1374
1876
|
exports.copyPresetPolicy = copyPresetPolicy;
|
|
1877
|
+
exports.resetPresetPolicy = resetPresetPolicy;
|
|
1878
|
+
// Generation-model projections, exported for unit tests: the persisted
|
|
1879
|
+
// payload, the picker's value codec, the effective selection the picker
|
|
1880
|
+
// shows, and the label the dialogs print.
|
|
1881
|
+
exports.settingsPayload = settingsPayload;
|
|
1882
|
+
exports.generationPayload = generationPayload;
|
|
1883
|
+
exports.effectiveGenerationModel = effectiveGenerationModel;
|
|
1884
|
+
exports.isDefaultSelection = isDefaultSelection;
|
|
1885
|
+
exports.carryReasoningEffort = carryReasoningEffort;
|
|
1886
|
+
exports.generationModelValue = generationModelValue;
|
|
1887
|
+
exports.parseGenerationModelValue = parseGenerationModelValue;
|
|
1888
|
+
exports.generationTargetLabel = generationTargetLabel;
|
|
1889
|
+
exports.findModelEntry = findModelEntry;
|
|
1890
|
+
// Save-guard projections, exported for unit tests. The button's disabled
|
|
1891
|
+
// state and the error banner both used to hide which Preset or which
|
|
1892
|
+
// condition was involved; these make that answerable without a DOM.
|
|
1893
|
+
exports.saveBlockReason = saveBlockReason;
|
|
1894
|
+
exports.errorPresetId = errorPresetId;
|
|
1375
1895
|
exports.estimateToolTokens = estimateToolTokens;
|
|
1376
1896
|
exports.estimateToolsTokens = estimateToolsTokens;
|
|
1377
1897
|
exports.estimateGroupTokens = estimateGroupTokens;
|