@dsh-plus/subagent-model 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 agguy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/lib/client.js ADDED
@@ -0,0 +1,626 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "@dsh-plus/subagent-model",
3
+ factory: (require) => {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
6
+
7
+ //#region rolldown:runtime
8
+ var __create = Object.create;
9
+ var __defProp = Object.defineProperty;
10
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
+ var __getOwnPropNames = Object.getOwnPropertyNames;
12
+ var __getProtoOf = Object.getPrototypeOf;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
16
+ key = keys[i];
17
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
+ get: ((k) => from[k]).bind(null, key),
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
25
+ value: mod,
26
+ enumerable: true
27
+ }) : target, mod));
28
+
29
+ //#endregion
30
+ let react = require("react");
31
+ react = __toESM(react);
32
+ let react_jsx_runtime = require("react/jsx-runtime");
33
+ react_jsx_runtime = __toESM(react_jsx_runtime);
34
+
35
+ //#region src/client/api.ts
36
+ const ROUTE_CONFIG = "/dsh-plus/subagent-model/config";
37
+ const ROUTE_CATALOG = "/dsh-plus/subagent-model/catalog";
38
+ async function parse(res) {
39
+ const body = await res.json();
40
+ if (!res.ok) throw new Error(body.error ?? `HTTP ${res.status}`);
41
+ return body;
42
+ }
43
+ async function fetchConfig() {
44
+ return parse(await fetch(ROUTE_CONFIG, { credentials: "same-origin" }));
45
+ }
46
+ async function saveConfig(patch) {
47
+ return parse(await fetch(ROUTE_CONFIG, {
48
+ method: "PUT",
49
+ credentials: "same-origin",
50
+ headers: { "content-type": "application/json" },
51
+ body: JSON.stringify(patch)
52
+ }));
53
+ }
54
+ async function fetchCatalog() {
55
+ return parse(await fetch(ROUTE_CATALOG, { credentials: "same-origin" }));
56
+ }
57
+
58
+ //#endregion
59
+ //#region src/client/fields.tsx
60
+ function CheckRow(props) {
61
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
62
+ className: "dsm-checkRow",
63
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
64
+ id: props.id,
65
+ type: "checkbox",
66
+ checked: props.checked,
67
+ disabled: props.disabled === true,
68
+ onChange: (event) => props.onEdit(event.target.checked)
69
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
70
+ htmlFor: props.id,
71
+ children: props.label
72
+ })]
73
+ });
74
+ }
75
+ function SelectField(props) {
76
+ const invalid = props.invalid === true;
77
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
78
+ className: "dsm-field",
79
+ children: [
80
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
81
+ className: "dsm-head",
82
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
83
+ className: "dsm-label",
84
+ htmlFor: props.id,
85
+ children: props.label
86
+ })
87
+ }),
88
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
89
+ id: props.id,
90
+ className: "dsm-select",
91
+ "aria-invalid": invalid || void 0,
92
+ value: props.value,
93
+ disabled: props.disabled === true,
94
+ onChange: (event) => props.onEdit(event.target.value),
95
+ children: props.options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
96
+ value: option.value,
97
+ children: option.label
98
+ }, option.value))
99
+ }),
100
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
101
+ className: invalid ? "dsm-invalid" : "dsm-hint",
102
+ children: invalid ? props.invalidLabel ?? "" : props.hint ?? ""
103
+ })
104
+ ]
105
+ });
106
+ }
107
+
108
+ //#endregion
109
+ //#region src/client/card.tsx
110
+ const IDLE_STATUS = {
111
+ kind: "idle",
112
+ text: ""
113
+ };
114
+ const EMPTY_ROW = {
115
+ enabled: false,
116
+ provider: "",
117
+ model: "",
118
+ reasoningEffort: "inherit"
119
+ };
120
+ const EFFORT_INHERIT = "inherit";
121
+ const EFFORT_DEFAULT = "default";
122
+ function draftFromWire(wire) {
123
+ const rows = {};
124
+ const names = [...wire.subagentProviders, ...Object.keys(wire.entries).sort()];
125
+ for (const name$1 of names) {
126
+ const entry = wire.entries[name$1];
127
+ rows[name$1] = entry === void 0 ? { ...EMPTY_ROW } : {
128
+ enabled: entry.enabled,
129
+ provider: entry.provider,
130
+ model: entry.model,
131
+ reasoningEffort: entry.reasoningEffort
132
+ };
133
+ }
134
+ return {
135
+ enabled: wire.enabled,
136
+ rows
137
+ };
138
+ }
139
+ function toPatch(draft) {
140
+ return {
141
+ enabled: draft.enabled,
142
+ entries: draft.rows
143
+ };
144
+ }
145
+ function rowNamesOf(wire, draft) {
146
+ const names = /* @__PURE__ */ new Set();
147
+ for (const name$1 of wire.subagentProviders) names.add(name$1);
148
+ for (const name$1 of Object.keys(draft.rows).sort()) names.add(name$1);
149
+ return [...names];
150
+ }
151
+ function unknownOption(value, label) {
152
+ return {
153
+ value,
154
+ label: `${value}(${label})`
155
+ };
156
+ }
157
+ function providerOptions(catalog, row, t) {
158
+ const options = [{
159
+ value: "",
160
+ label: t("inheritProvider")
161
+ }];
162
+ for (const provider of catalog?.providers ?? []) options.push({
163
+ value: provider.id,
164
+ label: provider.name
165
+ });
166
+ if (row.provider.length > 0 && !options.some((o) => o.value === row.provider)) options.push(unknownOption(row.provider, t("unknownValue")));
167
+ return options;
168
+ }
169
+ function modelOptions(catalog, row, t) {
170
+ const options = [{
171
+ value: "",
172
+ label: t("inheritModel")
173
+ }];
174
+ const provider = catalog?.providers.find((p) => p.id === row.provider);
175
+ for (const model of provider?.models ?? []) options.push({
176
+ value: model.id,
177
+ label: model.name
178
+ });
179
+ if (row.model.length > 0 && !options.some((o) => o.value === row.model)) options.push(unknownOption(row.model, t("unknownValue")));
180
+ return options;
181
+ }
182
+ function effortOptions(catalog, row, t) {
183
+ const options = [{
184
+ value: EFFORT_INHERIT,
185
+ label: t("effortInherit")
186
+ }, {
187
+ value: EFFORT_DEFAULT,
188
+ label: t("effortDefault")
189
+ }];
190
+ const model = (catalog?.providers.find((p) => p.id === row.provider))?.models.find((m) => m.id === row.model);
191
+ for (const effort of model?.reasoning?.efforts ?? []) options.push({
192
+ value: effort.id,
193
+ label: effort.name
194
+ });
195
+ if (row.reasoningEffort.length > 0 && !options.some((o) => o.value === row.reasoningEffort)) options.push(unknownOption(row.reasoningEffort, t("unknownValue")));
196
+ return options;
197
+ }
198
+ function RowBlock(props) {
199
+ const { name: name$1, row, catalog, disabled, t, onEdit } = props;
200
+ const invalidModel = row.model.length > 0 && row.provider.length === 0;
201
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
202
+ className: "dsm-row",
203
+ children: [
204
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
205
+ className: "dsm-rowHead",
206
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
207
+ className: "dsm-rowName",
208
+ children: name$1
209
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckRow, {
210
+ id: `dsm-row-${name$1}`,
211
+ label: t("rowEnabled"),
212
+ checked: row.enabled,
213
+ disabled,
214
+ onEdit: (v) => onEdit({
215
+ ...row,
216
+ enabled: v
217
+ })
218
+ })]
219
+ }),
220
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
221
+ className: "dsm-rowHint",
222
+ children: t("rowHint")
223
+ }),
224
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectField, {
225
+ id: `dsm-provider-${name$1}`,
226
+ label: t("provider"),
227
+ hint: t("providerHint"),
228
+ value: row.provider,
229
+ options: providerOptions(catalog, row, t),
230
+ disabled,
231
+ onEdit: (v) => onEdit({
232
+ ...row,
233
+ provider: v
234
+ })
235
+ }),
236
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectField, {
237
+ id: `dsm-model-${name$1}`,
238
+ label: t("model"),
239
+ hint: t("modelHint"),
240
+ value: row.model,
241
+ options: modelOptions(catalog, row, t),
242
+ disabled: disabled || row.provider.length === 0,
243
+ invalid: invalidModel,
244
+ invalidLabel: t("invalidModel"),
245
+ onEdit: (v) => onEdit({
246
+ ...row,
247
+ model: v
248
+ })
249
+ }),
250
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectField, {
251
+ id: `dsm-effort-${name$1}`,
252
+ label: t("effort"),
253
+ hint: t("effortHint"),
254
+ value: row.reasoningEffort,
255
+ options: effortOptions(catalog, row, t),
256
+ disabled,
257
+ onEdit: (v) => onEdit({
258
+ ...row,
259
+ reasoningEffort: v
260
+ })
261
+ })
262
+ ]
263
+ });
264
+ }
265
+ function SubagentModelCard(props) {
266
+ const { t } = props;
267
+ const [open, setOpen] = (0, react.useState)(false);
268
+ const [wire, setWire] = (0, react.useState)(null);
269
+ const [draft, setDraft] = (0, react.useState)(null);
270
+ const [catalog, setCatalog] = (0, react.useState)(null);
271
+ const [catalogFailed, setCatalogFailed] = (0, react.useState)(false);
272
+ const [loadFailed, setLoadFailed] = (0, react.useState)(false);
273
+ const [saving, setSaving] = (0, react.useState)(false);
274
+ const [status, setStatus] = (0, react.useState)(IDLE_STATUS);
275
+ (0, react.useEffect)(() => {
276
+ let alive = true;
277
+ fetchConfig().then((loaded) => {
278
+ if (!alive) return;
279
+ setWire(loaded);
280
+ setDraft(draftFromWire(loaded));
281
+ }).catch(() => {
282
+ if (alive) setLoadFailed(true);
283
+ });
284
+ return () => {
285
+ alive = false;
286
+ };
287
+ }, []);
288
+ (0, react.useEffect)(() => {
289
+ if (!open || catalog !== null) return;
290
+ let alive = true;
291
+ fetchCatalog().then((loaded) => {
292
+ if (!alive) return;
293
+ setCatalog(loaded);
294
+ setCatalogFailed(false);
295
+ }).catch(() => {
296
+ if (alive) setCatalogFailed(true);
297
+ });
298
+ return () => {
299
+ alive = false;
300
+ };
301
+ }, [open, catalog]);
302
+ const dirty = (0, react.useMemo)(() => wire !== null && draft !== null && JSON.stringify(toPatch(draft)) !== JSON.stringify(toPatch(draftFromWire(wire))), [wire, draft]);
303
+ const invalid = (0, react.useMemo)(() => draft !== null && Object.values(draft.rows).some((row) => row.model.length > 0 && row.provider.length === 0), [draft]);
304
+ if (loadFailed) return null;
305
+ if (wire === null || draft === null) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
306
+ className: "dsm-card",
307
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
308
+ className: "dsm-empty",
309
+ children: t("loading")
310
+ })
311
+ });
312
+ const edit = (key, value) => {
313
+ setDraft({
314
+ ...draft,
315
+ [key]: value
316
+ });
317
+ setStatus(IDLE_STATUS);
318
+ };
319
+ const editRow = (name$1, row) => {
320
+ setDraft({
321
+ ...draft,
322
+ rows: {
323
+ ...draft.rows,
324
+ [name$1]: row
325
+ }
326
+ });
327
+ setStatus(IDLE_STATUS);
328
+ };
329
+ const onSave = () => {
330
+ setSaving(true);
331
+ saveConfig(toPatch(draft)).then((saved) => {
332
+ setWire(saved);
333
+ setDraft(draftFromWire(saved));
334
+ setStatus(IDLE_STATUS);
335
+ }).catch((error) => {
336
+ setStatus({
337
+ kind: "error",
338
+ text: `${t("saveFailed")}${error instanceof Error ? error.message : ""}`
339
+ });
340
+ }).finally(() => setSaving(false));
341
+ };
342
+ const onRetryCatalog = () => {
343
+ setCatalog(null);
344
+ setCatalogFailed(false);
345
+ };
346
+ const disabled = !wire.writable;
347
+ const rowNames = rowNamesOf(wire, draft);
348
+ const providerCount = (catalog?.providers ?? []).length;
349
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
350
+ className: `dsm-card${open ? " dsm-cardOpen" : ""}`,
351
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
352
+ type: "button",
353
+ className: "dsm-header",
354
+ "aria-expanded": open,
355
+ "aria-label": `${t(open ? "collapse" : "expand")}: ${t("title")}`,
356
+ onClick: () => setOpen(!open),
357
+ children: [
358
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
359
+ className: "dsm-headText",
360
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
361
+ className: "dsm-name",
362
+ children: t("title")
363
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
364
+ className: "dsm-description",
365
+ children: t("description")
366
+ })]
367
+ }),
368
+ dirty ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
369
+ className: "dsm-pending",
370
+ children: t("unsaved")
371
+ }) : null,
372
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
373
+ className: `dsm-chevron${open ? " dsm-chevronOpen" : ""}`,
374
+ children: "▾"
375
+ })
376
+ ]
377
+ }), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
378
+ className: "dsm-body",
379
+ children: [
380
+ disabled ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
381
+ className: "dsm-empty",
382
+ role: "status",
383
+ children: t("readOnly")
384
+ }) : null,
385
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckRow, {
386
+ id: "dsm-enabled",
387
+ label: t("enabled"),
388
+ checked: draft.enabled,
389
+ disabled,
390
+ onEdit: (v) => edit("enabled", v)
391
+ }),
392
+ catalogFailed ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
393
+ className: "dsm-banner",
394
+ role: "status",
395
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("catalogError") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
396
+ type: "button",
397
+ className: "dsm-bannerRetry",
398
+ onClick: onRetryCatalog,
399
+ children: t("catalogRetry")
400
+ })]
401
+ }) : null,
402
+ catalog === null && !catalogFailed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
403
+ className: "dsm-empty",
404
+ role: "status",
405
+ children: t("catalogLoading")
406
+ }) : null,
407
+ rowNames.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
408
+ className: "dsm-empty",
409
+ role: "status",
410
+ children: t("noRows")
411
+ }) : null,
412
+ rowNames.map((name$1) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RowBlock, {
413
+ name: name$1,
414
+ row: draft.rows[name$1] ?? { ...EMPTY_ROW },
415
+ catalog,
416
+ disabled,
417
+ t,
418
+ onEdit: (row) => editRow(name$1, row)
419
+ }, name$1)),
420
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
421
+ className: "dsm-hint dsm-rowHint",
422
+ children: providerCount > 0 ? t("rowDesc") : ""
423
+ }),
424
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
425
+ className: "dsm-footer",
426
+ children: [
427
+ status.kind !== "idle" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
428
+ className: `dsm-status${status.kind === "error" ? " dsm-statusError" : ""}`,
429
+ role: "status",
430
+ children: status.text
431
+ }) : null,
432
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
433
+ type: "button",
434
+ className: "dsm-btn dsm-btnGhost",
435
+ disabled: !dirty || saving,
436
+ onClick: () => {
437
+ setDraft(draftFromWire(wire));
438
+ setStatus(IDLE_STATUS);
439
+ },
440
+ children: t("discard")
441
+ }),
442
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
443
+ type: "button",
444
+ className: "dsm-btn dsm-btnPrimary",
445
+ disabled: !dirty || invalid || saving || disabled,
446
+ onClick: onSave,
447
+ children: t(saving ? "saving" : "save")
448
+ })
449
+ ]
450
+ })
451
+ ]
452
+ }) : null]
453
+ });
454
+ }
455
+
456
+ //#endregion
457
+ //#region src/client/i18n.ts
458
+ /**
459
+ * 配置卡片文案(zh/en)。经 ctx.locale.register 注册、bind 取用,与官方卡片同机制。
460
+ * @module subagent-model/client/i18n
461
+ */
462
+ const NS = "dsh-plus-subagent-model";
463
+ const zh = {
464
+ title: "子代理模型配置",
465
+ description: "为 subagent / subagent_fork 等子代理单独指定提供商、模型与思考程度,或继承主代理。",
466
+ enabled: "启用插件",
467
+ rowEnabled: "启用该行",
468
+ provider: "提供商",
469
+ model: "模型",
470
+ effort: "思考程度",
471
+ inheritProvider: "继承主代理",
472
+ inheritModel: "继承主代理",
473
+ effortInherit: "继承主代理",
474
+ effortDefault: "跟随模型默认",
475
+ providerHint: "留空 = 子代理沿用主代理的提供商与模型。",
476
+ modelHint: "留空 = 沿用主代理的模型(需与所选提供商匹配)。",
477
+ effortHint: "inherit = 不干预(fork 会随会话继承);default = 显式使用模型默认档位。",
478
+ rowHint: "按子代理 provider 名匹配;standard preset 中 spawn ↔ subagent 工具、fork ↔ subagent_fork 工具。",
479
+ rowDesc: "未注册的 provider 行不生效,可保留待用。",
480
+ noRows: "当前未发现子代理 provider;配置将在 provider 注册后生效。",
481
+ catalogError: "提供商目录加载失败:",
482
+ catalogRetry: "重试",
483
+ catalogLoading: "目录加载中…",
484
+ unknownValue: "目录外",
485
+ save: "保存",
486
+ saving: "保存中…",
487
+ discard: "放弃",
488
+ unsaved: "未保存",
489
+ saveFailed: "保存失败:",
490
+ loading: "加载中…",
491
+ unavailable: "配置服务不可用。",
492
+ readOnly: "当前部署无 settings provider,配置为只读;请编辑 settings.yaml。",
493
+ expand: "展开",
494
+ collapse: "收起",
495
+ invalidModel: "模型不能脱离提供商单独配置。"
496
+ };
497
+ const en = {
498
+ title: "Subagent model config",
499
+ description: "Pick a provider, model, and thinking effort for subagent / subagent_fork children, or inherit from the main agent.",
500
+ enabled: "Enable plugin",
501
+ rowEnabled: "Enable row",
502
+ provider: "Provider",
503
+ model: "Model",
504
+ effort: "Effort",
505
+ inheritProvider: "Inherit from main agent",
506
+ inheritModel: "Inherit from main agent",
507
+ effortInherit: "Inherit from main agent",
508
+ effortDefault: "Follow model default",
509
+ providerHint: "Empty = the child follows the main agent’s provider and model.",
510
+ modelHint: "Empty = follow the main agent’s model (must match the chosen provider).",
511
+ effortHint: "inherit = do not touch (forks inherit via session seed); default = explicitly use the model’s default level.",
512
+ rowHint: "Matched by subagent provider name; in the standard preset spawn ↔ subagent tool, fork ↔ subagent_fork tool.",
513
+ rowDesc: "Rows for unregistered providers are inert; keep them for later.",
514
+ noRows: "No subagent provider registered yet; config takes effect once one appears.",
515
+ catalogError: "Failed to load provider catalog: ",
516
+ catalogRetry: "Retry",
517
+ catalogLoading: "Loading catalog…",
518
+ unknownValue: "outside catalog",
519
+ save: "Save",
520
+ saving: "Saving…",
521
+ discard: "Discard",
522
+ unsaved: "Unsaved",
523
+ saveFailed: "Save failed: ",
524
+ loading: "Loading…",
525
+ unavailable: "Configuration service unavailable.",
526
+ readOnly: "No settings provider in this deployment; edit settings.yaml instead.",
527
+ expand: "Expand",
528
+ collapse: "Collapse",
529
+ invalidModel: "Model cannot be set without a provider."
530
+ };
531
+
532
+ //#endregion
533
+ //#region src/client/styles.ts
534
+ /**
535
+ * 配置卡片样式:沿用官方 data-plugin / data-plugin-css 约定(HMR 据此卸载),
536
+ * 视觉对齐官方卡片(--dsw-alias-* 变量),不覆盖上游任何选择器。
537
+ * @module subagent-model/client/styles
538
+ */
539
+ const PLUGIN_ID = "@dsh-plus/subagent-model";
540
+ const STYLE_TAG_ID = `${PLUGIN_ID}/card.css`;
541
+ const cardCss = `
542
+ .dsm-card{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:12px;list-style:none;transition:border-color .16s,background .16s}
543
+ .dsm-card:hover{border-color:var(--dsw-alias-label-dimmed)}
544
+ .dsm-cardOpen{background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-label-dimmed)}
545
+ .dsm-header{appearance:none;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:0 0;border:0;border-radius:12px;align-items:center;gap:12px;padding:14px 16px;display:flex}
546
+ .dsm-header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px}
547
+ .dsm-headText{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}
548
+ .dsm-name{color:var(--dsw-alias-label-primary);font-size:15px;font-weight:600;line-height:1.4}
549
+ .dsm-description{color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:1.5}
550
+ .dsm-chevron{color:var(--dsw-alias-label-tertiary);flex:none;transition:transform .16s;font-size:12px}
551
+ .dsm-chevronOpen{transform:rotate(180deg)}
552
+ .dsm-pending{white-space:nowrap;background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-secondary);border-radius:999px;flex:none;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px}
553
+ .dsm-body{border-top:1px solid var(--dsw-alias-border-l2);margin:0 16px;padding-bottom:8px}
554
+ .dsm-field{flex-direction:column;gap:6px;padding:12px 0;display:flex}
555
+ .dsm-field+.dsm-field{border-top:1px solid var(--dsw-alias-border-l2)}
556
+ .dsm-head{align-items:center;gap:8px;display:flex}
557
+ .dsm-label{min-width:0;color:var(--dsw-alias-label-primary);flex:1;font-size:13px;font-weight:500;line-height:1.5}
558
+ .dsm-select{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);height:34px;min-width:0;font:inherit;color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 8px;font-size:13px}
559
+ .dsm-select:focus-visible{border-color:var(--dsw-alias-brand-primary);outline:none}
560
+ .dsm-select:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}
561
+ .dsm-hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:1.5}
562
+ .dsm-invalid{color:var(--dsw-alias-label-error);margin:0;font-size:12px;line-height:1.5}
563
+ .dsm-checkRow{align-items:center;gap:8px;display:flex;padding:6px 0}
564
+ .dsm-checkRow input{accent-color:var(--dsw-alias-brand-primary)}
565
+ .dsm-checkRow label{color:var(--dsw-alias-label-primary);font-size:13px;line-height:1.5;cursor:pointer}
566
+ .dsm-row{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);border-radius:10px;margin:12px 0 0;padding:4px 12px 10px}
567
+ .dsm-rowHead{align-items:center;gap:8px;padding:8px 0 2px;display:flex}
568
+ .dsm-rowName{min-width:0;color:var(--dsw-alias-label-primary);flex:1;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:13px;font-weight:600;line-height:1.5}
569
+ .dsm-rowHint{color:var(--dsw-alias-label-tertiary);margin:0 0 4px;font-size:12px;line-height:1.5}
570
+ .dsm-groupLabel{color:var(--dsw-alias-label-secondary);font-size:12px;font-weight:600;padding:12px 0 2px;margin:0}
571
+ .dsm-status{min-width:0;color:var(--dsw-alias-label-secondary);flex:1;margin:0;font-size:12px;line-height:1.5}
572
+ .dsm-statusError{color:var(--dsw-alias-label-error)}
573
+ .dsm-banner{background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary);justify-content:space-between;align-items:center;gap:8px;border-radius:8px;margin-top:12px;padding:7px 8px;font-size:12px;line-height:18px;display:flex}
574
+ .dsm-bannerRetry{color:inherit;font:inherit;cursor:pointer;background:0 0;border:none;flex:none;padding:0;font-weight:600}
575
+ .dsm-empty{color:var(--dsw-alias-label-tertiary);margin:12px 0 0;font-size:12px;line-height:1.5}
576
+ .dsm-footer{border-top:1px solid var(--dsw-alias-border-l2);justify-content:flex-end;align-items:center;gap:8px;padding:12px 0 4px;display:flex;flex-wrap:wrap}
577
+ .dsm-btn{appearance:none;font:inherit;cursor:pointer;border:1px solid #0000;border-radius:8px;padding:5px 14px;font-size:13px;line-height:1.5}
578
+ .dsm-btnGhost{border-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);background:0 0}
579
+ .dsm-btnGhost:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed)}
580
+ .dsm-btnPrimary{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}
581
+ .dsm-btn:disabled{opacity:.4;cursor:default}
582
+ .dsm-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}
583
+ `;
584
+ /** 幂等注入样式标签;返回标签(已存在或环境无 document 时为 null)。 */
585
+ function injectStyle() {
586
+ if (typeof document === "undefined") return null;
587
+ if (document.querySelector(`style[data-plugin-css=${JSON.stringify(STYLE_TAG_ID)}]`) !== null) return null;
588
+ const tag = document.createElement("style");
589
+ tag.dataset.plugin = PLUGIN_ID;
590
+ tag.dataset.pluginCss = STYLE_TAG_ID;
591
+ tag.textContent = cardCss;
592
+ document.head.appendChild(tag);
593
+ return tag;
594
+ }
595
+
596
+ //#endregion
597
+ //#region src/client/client.ts
598
+ const name = "dsh-plus-subagent-model";
599
+ /** 浏览器半需要的 cordis 服务 key(loader 据此注入;package.json 的 dsh.client.inject 管包加载顺序)。 */
600
+ const inject = ["slots", "locale"];
601
+ function apply(ctx) {
602
+ const c = ctx;
603
+ const tag = injectStyle();
604
+ c.effect(() => () => {
605
+ tag?.remove();
606
+ }, "subagent-model: style");
607
+ c.effect(() => c.locale.register(NS, {
608
+ zh,
609
+ en
610
+ }), "subagent-model: locale");
611
+ c.slots.inject("settings.plugin.item", () => c.slots.register({
612
+ name: "settings.plugin.item",
613
+ id: "subagent-model",
614
+ order: 100,
615
+ locale: NS,
616
+ inject: () => ({ t: c.locale.bind(NS) })
617
+ }, SubagentModelCard));
618
+ }
619
+
620
+ //#endregion
621
+ exports.apply = apply;
622
+ exports.inject = inject;
623
+ exports.name = name;
624
+ return module.exports;
625
+ }
626
+ });