@dsh-plus/subagent-model 0.1.10 → 0.2.1
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/lib/index.d.ts +1 -4
- package/lib/index.js +51 -193
- package/package.json +8 -31
- package/src/config.ts +33 -42
- package/src/delegation.ts +23 -54
- package/src/index.ts +5 -4
- package/src/ns.ts +3 -6
- package/src/service.ts +20 -29
- package/lib/client.js +0 -850
- package/src/catalog.ts +0 -127
- package/src/client/api.ts +0 -45
- package/src/client/card.tsx +0 -340
- package/src/client/client.ts +0 -78
- package/src/client/draft.ts +0 -69
- package/src/client/i18n.ts +0 -65
- package/src/client/styles.ts +0 -30
- package/src/config-api.ts +0 -53
package/lib/client.js
DELETED
|
@@ -1,850 +0,0 @@
|
|
|
1
|
-
window.__ModuleLoader__.load({
|
|
2
|
-
id: "@dsh-plus/subagent-model",
|
|
3
|
-
factory: (require) => {
|
|
4
|
-
var module = { exports: {} };
|
|
5
|
-
var exports = module.exports;
|
|
6
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
-
let react = require("react");
|
|
9
|
-
//#region ../shared/src/client/icons.tsx
|
|
10
|
-
/** 官方 IconChevronDownOutline14 的同构实现(path 数据逐字一致)。 */
|
|
11
|
-
function ChevronDownIcon(props) {
|
|
12
|
-
const size = props.size ?? 14;
|
|
13
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
14
|
-
width: size,
|
|
15
|
-
height: size,
|
|
16
|
-
className: props.className,
|
|
17
|
-
viewBox: "0 0 14 14",
|
|
18
|
-
fill: "none",
|
|
19
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
20
|
-
"aria-hidden": "true",
|
|
21
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
22
|
-
d: "M11.8486 5.5L11.4238 5.92383L8.69727 8.65137C8.44157 8.90706 8.21562 9.13382 8.01172 9.29785C7.79912 9.46883 7.55595 9.61756 7.25 9.66602C7.08435 9.69222 6.91565 9.69222 6.75 9.66602C6.44405 9.61756 6.20088 9.46883 5.98828 9.29785C5.78438 9.13382 5.55843 8.90706 5.30273 8.65137L2.57617 5.92383L2.15137 5.5L3 4.65137L3.42383 5.07617L6.15137 7.80273C6.42595 8.07732 6.59876 8.24849 6.74023 8.3623C6.87291 8.46904 6.92272 8.47813 6.9375 8.48047C6.97895 8.48703 7.02105 8.48703 7.0625 8.48047C7.07728 8.47813 7.12709 8.46904 7.25977 8.3623C7.40124 8.24849 7.57405 8.07732 7.84863 7.80273L10.5762 5.07617L11 4.65137L11.8486 5.5Z",
|
|
23
|
-
fill: "currentColor"
|
|
24
|
-
})
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region ../shared/src/client/card.tsx
|
|
29
|
-
const IDLE_STATUS = {
|
|
30
|
-
kind: "idle",
|
|
31
|
-
text: ""
|
|
32
|
-
};
|
|
33
|
-
function CardChrome(props) {
|
|
34
|
-
const p = props.prefix;
|
|
35
|
-
const badge = props.statusBadge;
|
|
36
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
37
|
-
className: `${p}-card${props.open ? ` ${p}-cardOpen` : ""}`,
|
|
38
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
39
|
-
type: "button",
|
|
40
|
-
className: `${p}-header`,
|
|
41
|
-
"aria-expanded": props.open,
|
|
42
|
-
"aria-label": props.title,
|
|
43
|
-
onClick: () => props.onToggle(!props.open),
|
|
44
|
-
children: [
|
|
45
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
46
|
-
className: `${p}-headText`,
|
|
47
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
48
|
-
className: `${p}-name`,
|
|
49
|
-
children: props.title
|
|
50
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
51
|
-
className: `${p}-description`,
|
|
52
|
-
children: props.description
|
|
53
|
-
})]
|
|
54
|
-
}),
|
|
55
|
-
badge !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
56
|
-
className: `${p}-statusBadge ${badge.on ? `${p}-statusOn` : `${p}-statusOff`}`,
|
|
57
|
-
children: badge.text
|
|
58
|
-
}) : null,
|
|
59
|
-
props.dirty ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
60
|
-
className: `${p}-pending`,
|
|
61
|
-
children: props.dirtyLabel
|
|
62
|
-
}) : null,
|
|
63
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChevronDownIcon, { className: `${p}-chevron${props.open ? ` ${p}-chevronOpen` : ""}` })
|
|
64
|
-
]
|
|
65
|
-
}), props.open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
66
|
-
className: `${p}-body`,
|
|
67
|
-
children: [
|
|
68
|
-
props.readOnlyNotice !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
69
|
-
className: `${p}-readOnly`,
|
|
70
|
-
role: "status",
|
|
71
|
-
children: props.readOnlyNotice
|
|
72
|
-
}) : null,
|
|
73
|
-
props.children,
|
|
74
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
75
|
-
className: `${p}-footer`,
|
|
76
|
-
children: [props.status !== void 0 && props.status.kind !== "idle" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
77
|
-
className: `${p}-status${props.status.kind === "error" ? ` ${p}-statusError` : ""}`,
|
|
78
|
-
role: "status",
|
|
79
|
-
children: props.status.text
|
|
80
|
-
}) : null, props.actions.map((action) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
81
|
-
type: "button",
|
|
82
|
-
className: `${p}-btn ${action.variant === "primary" ? `${p}-btnPrimary` : `${p}-btnGhost`}`,
|
|
83
|
-
disabled: action.disabled === true,
|
|
84
|
-
onClick: action.onClick,
|
|
85
|
-
children: action.label
|
|
86
|
-
}, action.key))]
|
|
87
|
-
})
|
|
88
|
-
]
|
|
89
|
-
}) : null]
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
//#endregion
|
|
93
|
-
//#region ../shared/src/client/fields.tsx
|
|
94
|
-
/**
|
|
95
|
-
* 勾选行:自绘圆角扁平开关(switch),对齐官方 WebUI 无原生 checkbox 的
|
|
96
|
-
* 设计语言(官方选择类控件全走胶囊/菜单,见 cardCss 的 -switch 规则)。
|
|
97
|
-
* 语义保持 checkbox(无障碍树与表单语义不变),视觉自绘。
|
|
98
|
-
*/
|
|
99
|
-
function CheckRow(props) {
|
|
100
|
-
const p = props.prefix ?? "dshp";
|
|
101
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
102
|
-
className: `${p}-checkRow`,
|
|
103
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
104
|
-
id: props.id,
|
|
105
|
-
type: "checkbox",
|
|
106
|
-
role: "switch",
|
|
107
|
-
"aria-checked": props.checked,
|
|
108
|
-
checked: props.checked,
|
|
109
|
-
disabled: props.disabled === true,
|
|
110
|
-
onChange: (event) => props.onEdit(event.target.checked)
|
|
111
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
112
|
-
htmlFor: props.id,
|
|
113
|
-
children: props.label
|
|
114
|
-
})]
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
function SelectField(props) {
|
|
118
|
-
const p = props.prefix ?? "dshp";
|
|
119
|
-
const invalid = props.invalid === true;
|
|
120
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
121
|
-
className: `${p}-field`,
|
|
122
|
-
children: [
|
|
123
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
124
|
-
className: `${p}-head`,
|
|
125
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
126
|
-
className: `${p}-label`,
|
|
127
|
-
htmlFor: props.id,
|
|
128
|
-
children: props.label
|
|
129
|
-
})
|
|
130
|
-
}),
|
|
131
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
|
|
132
|
-
id: props.id,
|
|
133
|
-
className: `${p}-select${invalid ? ` ${p}-inputInvalid` : ""}`,
|
|
134
|
-
"aria-invalid": invalid || void 0,
|
|
135
|
-
value: props.value,
|
|
136
|
-
disabled: props.disabled === true,
|
|
137
|
-
onChange: (event) => props.onEdit(event.target.value),
|
|
138
|
-
children: props.options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
139
|
-
value: option.value,
|
|
140
|
-
children: option.label
|
|
141
|
-
}, option.value))
|
|
142
|
-
}),
|
|
143
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
144
|
-
className: invalid ? `${p}-invalid` : `${p}-hint`,
|
|
145
|
-
children: invalid ? props.invalidLabel ?? "" : props.hint ?? ""
|
|
146
|
-
})
|
|
147
|
-
]
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
//#endregion
|
|
151
|
-
//#region ../shared/src/client/i18n.ts
|
|
152
|
-
/** 卡片通用文案(save/discard/unsaved/loading 等四插件共有键)。 */
|
|
153
|
-
const commonZh = {
|
|
154
|
-
save: "保存",
|
|
155
|
-
saving: "保存中…",
|
|
156
|
-
discard: "放弃",
|
|
157
|
-
unsaved: "未保存",
|
|
158
|
-
loading: "加载中…",
|
|
159
|
-
unavailable: "配置服务不可用。",
|
|
160
|
-
readOnly: "当前部署无 settings provider,配置为只读;请编辑 settings.yaml。",
|
|
161
|
-
invalidNumber: "请输入正整数。",
|
|
162
|
-
collapse: "收起",
|
|
163
|
-
expand: "展开",
|
|
164
|
-
enabledOn: "已启用",
|
|
165
|
-
enabledOff: "未启用",
|
|
166
|
-
saveFailed: "保存失败,请检查填写内容。",
|
|
167
|
-
confirm: "确认",
|
|
168
|
-
cancel: "取消"
|
|
169
|
-
};
|
|
170
|
-
const commonEn = {
|
|
171
|
-
save: "Save",
|
|
172
|
-
saving: "Saving…",
|
|
173
|
-
discard: "Discard",
|
|
174
|
-
unsaved: "Unsaved",
|
|
175
|
-
loading: "Loading…",
|
|
176
|
-
unavailable: "Settings service unavailable.",
|
|
177
|
-
readOnly: "No settings provider in this deployment; config is read-only. Edit settings.yaml.",
|
|
178
|
-
invalidNumber: "Enter a positive integer.",
|
|
179
|
-
collapse: "Collapse",
|
|
180
|
-
expand: "Expand",
|
|
181
|
-
enabledOn: "On",
|
|
182
|
-
enabledOff: "Off",
|
|
183
|
-
saveFailed: "Save failed; check the fields.",
|
|
184
|
-
confirm: "Confirm",
|
|
185
|
-
cancel: "Cancel"
|
|
186
|
-
};
|
|
187
|
-
/** own 覆盖同键合并(返回新对象,入参不可变)。 */
|
|
188
|
-
function mergeDict(base, own) {
|
|
189
|
-
return {
|
|
190
|
-
...base,
|
|
191
|
-
...own
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
//#endregion
|
|
195
|
-
//#region ../shared/src/client/scope.ts
|
|
196
|
-
/**
|
|
197
|
-
* api 直连实现的命名空间 scope(官方配置页 tab 同款模式)。
|
|
198
|
-
* 读:describe 取命名空间视图(脱敏 value/revision + 顶层 writable);
|
|
199
|
-
* 刷新:remote `settings/document-updated`(按命名空间过滤)与
|
|
200
|
-
* `connection/reset`;generation 防旧读覆盖新发布。任何页面 origin
|
|
201
|
-
* (loopback 或 tailnet 信任域名)下行为一致。
|
|
202
|
-
* effect 归属调用方 fiber(label 需含插件名以便诊断)。
|
|
203
|
-
*/
|
|
204
|
-
function createApiScope(api, ns, c, label) {
|
|
205
|
-
let state = {
|
|
206
|
-
status: "loading",
|
|
207
|
-
value: void 0,
|
|
208
|
-
revision: void 0,
|
|
209
|
-
writable: false
|
|
210
|
-
};
|
|
211
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
212
|
-
let generation = 0;
|
|
213
|
-
const publish = (next) => {
|
|
214
|
-
state = next;
|
|
215
|
-
for (const listener of [...listeners]) listener();
|
|
216
|
-
};
|
|
217
|
-
const load = async () => {
|
|
218
|
-
const gen = ++generation;
|
|
219
|
-
let response;
|
|
220
|
-
try {
|
|
221
|
-
response = await api.describe({});
|
|
222
|
-
} catch {
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
if (gen !== generation || !response.result.ok) return;
|
|
226
|
-
const writable = response.result.value?.writable ?? false;
|
|
227
|
-
const view = response.result.value?.namespaces.find((candidate) => candidate.ns === ns);
|
|
228
|
-
if (view === void 0) {
|
|
229
|
-
publish({
|
|
230
|
-
status: "unavailable",
|
|
231
|
-
value: void 0,
|
|
232
|
-
revision: void 0,
|
|
233
|
-
writable
|
|
234
|
-
});
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
publish({
|
|
238
|
-
status: "ready",
|
|
239
|
-
value: view.value,
|
|
240
|
-
revision: view.revision,
|
|
241
|
-
writable
|
|
242
|
-
});
|
|
243
|
-
};
|
|
244
|
-
const refresh = (namespace) => {
|
|
245
|
-
if (namespace !== void 0 && namespace !== ns) return;
|
|
246
|
-
load();
|
|
247
|
-
};
|
|
248
|
-
const disposers = [c.get("remote").$on("settings/document-updated", refresh), c.on("connection/reset", () => {
|
|
249
|
-
load();
|
|
250
|
-
})];
|
|
251
|
-
c.effect(() => () => {
|
|
252
|
-
for (const dispose of disposers) dispose();
|
|
253
|
-
}, label);
|
|
254
|
-
load();
|
|
255
|
-
return {
|
|
256
|
-
getSnapshot: () => state,
|
|
257
|
-
subscribe: (listener) => {
|
|
258
|
-
listeners.add(listener);
|
|
259
|
-
return () => {
|
|
260
|
-
listeners.delete(listener);
|
|
261
|
-
};
|
|
262
|
-
},
|
|
263
|
-
load
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
//#endregion
|
|
267
|
-
//#region ../shared/src/client/styles.ts
|
|
268
|
-
/**
|
|
269
|
-
* 配置卡片样式工厂(各插件 client 的公共收编版)。
|
|
270
|
-
* 视觉规则与迁移前逐字一致(类名前缀换为各插件自身,DOM 类名不变),
|
|
271
|
-
* 另补移动端与可达性增强(767px 断点 + pointer:coarse,对齐 ui-mobile-fit 约定):
|
|
272
|
-
* - 窄屏 input/textarea 16px(防 iOS 聚焦缩放)、可点目标 ≥44px;
|
|
273
|
-
* - footer 按钮等宽换行、状态文字独占一行;
|
|
274
|
-
* - 展开态 body 底部 sticky 保存栏(长表单滚动中始终可达)。
|
|
275
|
-
* 沿用官方 data-plugin / data-plugin-css 约定(HMR 据此卸载),不覆盖上游选择器。
|
|
276
|
-
* @module @dsh-plus/shared/client/styles
|
|
277
|
-
*/
|
|
278
|
-
/** 生成全套卡片 CSS;prefix 为插件类名前缀(如 'dne'),extra 为插件特有规则。 */
|
|
279
|
-
function cardCss(prefix, extra = "") {
|
|
280
|
-
return `
|
|
281
|
-
.${prefix}-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}
|
|
282
|
-
.${prefix}-card:hover{border-color:var(--dsw-alias-label-dimmed)}
|
|
283
|
-
.${prefix}-cardOpen{background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-label-dimmed)}
|
|
284
|
-
.${prefix}-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}
|
|
285
|
-
.${prefix}-header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px}
|
|
286
|
-
.${prefix}-headText{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}
|
|
287
|
-
.${prefix}-name{color:var(--dsw-alias-label-primary);font-size:15px;font-weight:600;line-height:1.4}
|
|
288
|
-
.${prefix}-description{color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:1.5}
|
|
289
|
-
.${prefix}-chevron{color:var(--dsw-alias-label-tertiary);flex:none;transition:transform .16s;display:inline-flex}
|
|
290
|
-
.${prefix}-chevronOpen{transform:rotate(180deg)}
|
|
291
|
-
.${prefix}-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}
|
|
292
|
-
.${prefix}-statusBadge{white-space:nowrap;border-radius:999px;flex:none;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px}
|
|
293
|
-
.${prefix}-statusOn{background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-secondary)}
|
|
294
|
-
.${prefix}-statusOff{color:var(--dsw-alias-label-tertiary)}
|
|
295
|
-
.${prefix}-body{border-top:1px solid var(--dsw-alias-border-l2);margin:0 16px;padding-bottom:8px}
|
|
296
|
-
.${prefix}-field{flex-direction:column;gap:6px;padding:12px 0;display:flex}
|
|
297
|
-
.${prefix}-field+.${prefix}-field{border-top:1px solid var(--dsw-alias-border-l2)}
|
|
298
|
-
.${prefix}-head{align-items:center;gap:8px;display:flex}
|
|
299
|
-
.${prefix}-label{min-width:0;color:var(--dsw-alias-label-primary);flex:1;font-size:13px;font-weight:500;line-height:1.5}
|
|
300
|
-
.${prefix}-badge{white-space:nowrap;border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px}
|
|
301
|
-
.${prefix}-badgeSet{background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-secondary)}
|
|
302
|
-
.${prefix}-badgeUnset{color:var(--dsw-alias-label-tertiary)}
|
|
303
|
-
.${prefix}-input{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);height:34px;font:inherit;color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 12px;font-size:13px;transition:border-color .18s,background .18s}
|
|
304
|
-
.${prefix}-input:hover:not(:disabled):not(:focus-visible){border-color:var(--dsw-alias-label-dimmed)}
|
|
305
|
-
.${prefix}-input:focus-visible{border-color:var(--dsw-alias-brand-primary);outline:none}
|
|
306
|
-
.${prefix}-input:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}
|
|
307
|
-
.${prefix}-inputInvalid{border-color:var(--dsw-alias-label-error)}
|
|
308
|
-
.${prefix}-select{appearance:none;background:var(--dsw-alias-bg-module-platform);border:none;cursor:pointer;background-image:linear-gradient(45deg,transparent 50%,var(--dsw-alias-label-secondary) 50%),linear-gradient(135deg,var(--dsw-alias-label-secondary) 50%,transparent 50%);background-position:calc(100% - 16px) 50%,calc(100% - 11px) 50%;background-size:5px 5px;background-repeat:no-repeat;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;height:34px;box-sizing:border-box;border-radius:8px;padding:0 30px 0 12px;transition:background-color .18s}
|
|
309
|
-
.${prefix}-select:hover:not(:disabled){background-color:var(--dsw-alias-interactive-bg-hover)}
|
|
310
|
-
.${prefix}-hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:1.5}
|
|
311
|
-
.${prefix}-invalid{color:var(--dsw-alias-label-error);margin:0;font-size:12px;line-height:1.5}
|
|
312
|
-
.${prefix}-checkRow{align-items:center;gap:10px;display:flex;padding:6px 0}
|
|
313
|
-
.${prefix}-checkRow label{color:var(--dsw-alias-label-primary);font-size:13px;line-height:1.5;cursor:pointer;flex:1;min-width:0}
|
|
314
|
-
/* 自绘圆角扁平开关(官方 UI 无可见原生 checkbox,选择类全走胶囊/菜单) */
|
|
315
|
-
.${prefix}-checkRow input{appearance:none;-webkit-appearance:none;position:relative;box-sizing:border-box;background:var(--dsw-alias-bg-module-platform);border:none;border-radius:999px;width:34px;height:20px;flex:none;cursor:pointer;transition:background .18s;margin:0}
|
|
316
|
-
.${prefix}-checkRow input::after{content:"";position:absolute;top:2px;left:2px;background:var(--dsw-alias-label-primary);border-radius:999px;width:16px;height:16px;transition:left .18s cubic-bezier(.4,0,.2,1)}
|
|
317
|
-
.${prefix}-checkRow input:checked{background:var(--dsw-alias-brand-primary)}
|
|
318
|
-
.${prefix}-checkRow input:checked::after{left:16px;background:var(--dsw-alias-bg-base)}
|
|
319
|
-
.${prefix}-checkRow input:disabled{opacity:.4;cursor:default}
|
|
320
|
-
.${prefix}-checkRow input:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}
|
|
321
|
-
.${prefix}-groupLabel{color:var(--dsw-alias-label-secondary);font-size:12px;font-weight:600;padding:12px 0 2px;margin:0}
|
|
322
|
-
.${prefix}-readOnly{color:var(--dsw-alias-label-tertiary);margin:12px 0 0;font-size:12px;line-height:1.5}
|
|
323
|
-
.${prefix}-warn{color:var(--dsw-alias-label-error);margin:12px 0 0;font-size:12px;line-height:1.5}
|
|
324
|
-
.${prefix}-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}
|
|
325
|
-
.${prefix}-status{min-width:0;color:var(--dsw-alias-label-secondary);flex:1;margin:0;font-size:12px;line-height:1.5}
|
|
326
|
-
.${prefix}-statusError{color:var(--dsw-alias-label-error)}
|
|
327
|
-
.${prefix}-btn{appearance:none;font:inherit;cursor:pointer;border:1px solid #0000;border-radius:8px;padding:5px 14px;font-size:13px;line-height:1.5}
|
|
328
|
-
.${prefix}-btnGhost{border-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);background:0 0}
|
|
329
|
-
.${prefix}-btnGhost:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed)}
|
|
330
|
-
.${prefix}-btnPrimary{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}
|
|
331
|
-
.${prefix}-btn:disabled{opacity:.4;cursor:default}
|
|
332
|
-
.${prefix}-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}
|
|
333
|
-
@media (max-width:767px){
|
|
334
|
-
.${prefix}-body{margin:0 10px}
|
|
335
|
-
.${prefix}-header{padding:12px 12px}
|
|
336
|
-
.${prefix}-input,.${prefix}-select{font-size:16px;height:40px}
|
|
337
|
-
.${prefix}-checkRow{min-height:44px;padding:8px 0}
|
|
338
|
-
.${prefix}-footer{position:sticky;bottom:0;background:var(--dsw-alias-bg-layer-2);margin:0 -10px;padding:10px 10px 6px;border-top:1px solid var(--dsw-alias-border-l2);border-bottom-left-radius:12px;border-bottom-right-radius:12px}
|
|
339
|
-
.${prefix}-status{flex-basis:100%;flex:none}
|
|
340
|
-
.${prefix}-btn{min-height:44px;flex:1;min-width:96px}
|
|
341
|
-
.${prefix}-statusBadge{display:none}
|
|
342
|
-
}
|
|
343
|
-
@media (pointer:coarse){
|
|
344
|
-
.${prefix}-btn{min-height:44px}
|
|
345
|
-
.${prefix}-checkRow{min-height:44px}
|
|
346
|
-
.${prefix}-input,.${prefix}-select{height:40px}
|
|
347
|
-
}
|
|
348
|
-
${extra}
|
|
349
|
-
`;
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* 幂等注入样式标签(官方 data-plugin-css 约定);返回新标签,
|
|
353
|
-
* 已存在或环境无 document 时返回 null(调用方 effect 卸载用)。
|
|
354
|
-
*/
|
|
355
|
-
function injectCardStyle(pluginId, css) {
|
|
356
|
-
if (typeof document === "undefined") return null;
|
|
357
|
-
const tagId = `${pluginId}/card.css`;
|
|
358
|
-
if (document.querySelector(`style[data-plugin-css=${JSON.stringify(tagId)}]`) !== null) return null;
|
|
359
|
-
const tag = document.createElement("style");
|
|
360
|
-
tag.dataset.plugin = pluginId;
|
|
361
|
-
tag.dataset.pluginCss = tagId;
|
|
362
|
-
tag.textContent = css;
|
|
363
|
-
document.head.appendChild(tag);
|
|
364
|
-
return tag;
|
|
365
|
-
}
|
|
366
|
-
//#endregion
|
|
367
|
-
//#region src/ns.ts
|
|
368
|
-
/**
|
|
369
|
-
* settings 命名空间字面量(纯常量,零依赖,浏览器半可安全引入)。
|
|
370
|
-
* 服务端经 settingsNamespace() 品牌化后使用(config.ts),浏览器半将其作为
|
|
371
|
-
* settings.plugin.item keyed 槽位的 key —— 同一字面量两处共用,防止漂移。
|
|
372
|
-
* 契约:dsh rc7 起该槽位按「卡片编辑的 settings 命名空间」作 key 分发,
|
|
373
|
-
* 官方配置页只渲染 key 命中 Host 已注册命名空间的卡片。
|
|
374
|
-
* @module subagent-model/ns
|
|
375
|
-
*/
|
|
376
|
-
const SETTINGS_NS = "dsh-plus-subagent-model";
|
|
377
|
-
//#endregion
|
|
378
|
-
//#region src/client/api.ts
|
|
379
|
-
const ROUTE_CATALOG = "/dsh-plus/subagent-model/catalog";
|
|
380
|
-
async function parse(res) {
|
|
381
|
-
const body = await res.json();
|
|
382
|
-
if (!res.ok) throw new Error(body.error ?? `HTTP ${res.status}`);
|
|
383
|
-
return body;
|
|
384
|
-
}
|
|
385
|
-
async function fetchCatalog() {
|
|
386
|
-
return parse(await fetch(ROUTE_CATALOG, { credentials: "same-origin" }));
|
|
387
|
-
}
|
|
388
|
-
//#endregion
|
|
389
|
-
//#region src/client/draft.ts
|
|
390
|
-
const EMPTY_ROW = {
|
|
391
|
-
enabled: false,
|
|
392
|
-
provider: "",
|
|
393
|
-
model: "",
|
|
394
|
-
reasoningEffort: "inherit"
|
|
395
|
-
};
|
|
396
|
-
/** 行集 = 目录 subagentProviders ∪ 已配置条目;目录行缺省为空行。 */
|
|
397
|
-
function draftFrom(value, catalog) {
|
|
398
|
-
const rows = {};
|
|
399
|
-
const names = /* @__PURE__ */ new Set();
|
|
400
|
-
for (const name of catalog?.subagentProviders ?? []) names.add(name);
|
|
401
|
-
for (const name of Object.keys(value.entries).sort()) names.add(name);
|
|
402
|
-
for (const name of names) {
|
|
403
|
-
const entry = value.entries[name];
|
|
404
|
-
rows[name] = entry === void 0 ? { ...EMPTY_ROW } : {
|
|
405
|
-
enabled: entry.enabled,
|
|
406
|
-
provider: entry.provider,
|
|
407
|
-
model: entry.model,
|
|
408
|
-
reasoningEffort: entry.reasoningEffort
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
return {
|
|
412
|
-
enabled: value.enabled,
|
|
413
|
-
rows
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
function toPatch(draft) {
|
|
417
|
-
const entries = {};
|
|
418
|
-
for (const name of Object.keys(draft.rows).sort()) entries[name] = draft.rows[name];
|
|
419
|
-
return {
|
|
420
|
-
enabled: draft.enabled,
|
|
421
|
-
entries
|
|
422
|
-
};
|
|
423
|
-
}
|
|
424
|
-
//#endregion
|
|
425
|
-
//#region src/client/card.tsx
|
|
426
|
-
/**
|
|
427
|
-
* 「子代理模型配置」配置卡片:注册进 settings.plugin.item 插槽(官方插件配置页)。
|
|
428
|
-
* 外壳与基础控件走 @dsh-plus/shared/client 套件(CardChrome/CheckRow/SelectField)。
|
|
429
|
-
* 配置读写走官方 settingsScope 传输:value 为 schema 解析后的命名空间值
|
|
430
|
-
* (enabled + entries),行集合 = 目录返回的已注册子代理 provider
|
|
431
|
-
* ∪ 已配置条目,保存时全量写回 entries(未配置的新 provider 行以默认空值
|
|
432
|
-
* 落盘,自文档化);「模型目录」为唯一保留的自定义端点。
|
|
433
|
-
* @module subagent-model/client/card
|
|
434
|
-
*/
|
|
435
|
-
const EFFORT_INHERIT = "inherit";
|
|
436
|
-
const EFFORT_DEFAULT = "default";
|
|
437
|
-
function unknownOption(value, label) {
|
|
438
|
-
return {
|
|
439
|
-
value,
|
|
440
|
-
label: `${value}(${label})`
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
function providerOptions(catalog, row, t) {
|
|
444
|
-
const options = [{
|
|
445
|
-
value: "",
|
|
446
|
-
label: t("inheritProvider")
|
|
447
|
-
}];
|
|
448
|
-
for (const provider of catalog?.providers ?? []) options.push({
|
|
449
|
-
value: provider.id,
|
|
450
|
-
label: provider.name
|
|
451
|
-
});
|
|
452
|
-
if (row.provider.length > 0 && !options.some((o) => o.value === row.provider)) options.push(unknownOption(row.provider, t("unknownValue")));
|
|
453
|
-
return options;
|
|
454
|
-
}
|
|
455
|
-
function modelOptions(catalog, row, t) {
|
|
456
|
-
const options = [{
|
|
457
|
-
value: "",
|
|
458
|
-
label: t("inheritModel")
|
|
459
|
-
}];
|
|
460
|
-
const provider = catalog?.providers.find((p) => p.id === row.provider);
|
|
461
|
-
for (const model of provider?.models ?? []) options.push({
|
|
462
|
-
value: model.id,
|
|
463
|
-
label: model.name
|
|
464
|
-
});
|
|
465
|
-
if (row.model.length > 0 && !options.some((o) => o.value === row.model)) options.push(unknownOption(row.model, t("unknownValue")));
|
|
466
|
-
return options;
|
|
467
|
-
}
|
|
468
|
-
function effortOptions(catalog, row, t) {
|
|
469
|
-
const options = [{
|
|
470
|
-
value: EFFORT_INHERIT,
|
|
471
|
-
label: t("effortInherit")
|
|
472
|
-
}, {
|
|
473
|
-
value: EFFORT_DEFAULT,
|
|
474
|
-
label: t("effortDefault")
|
|
475
|
-
}];
|
|
476
|
-
const model = (catalog?.providers.find((p) => p.id === row.provider))?.models.find((m) => m.id === row.model);
|
|
477
|
-
for (const effort of model?.reasoning?.efforts ?? []) options.push({
|
|
478
|
-
value: effort.id,
|
|
479
|
-
label: effort.name
|
|
480
|
-
});
|
|
481
|
-
if (row.reasoningEffort.length > 0 && !options.some((o) => o.value === row.reasoningEffort)) options.push(unknownOption(row.reasoningEffort, t("unknownValue")));
|
|
482
|
-
return options;
|
|
483
|
-
}
|
|
484
|
-
function RowBlock(props) {
|
|
485
|
-
const { name, row, catalog, disabled, t, onEdit } = props;
|
|
486
|
-
const invalidModel = row.model.length > 0 && row.provider.length === 0;
|
|
487
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
488
|
-
className: "dsm-row",
|
|
489
|
-
children: [
|
|
490
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
491
|
-
className: "dsm-rowHead",
|
|
492
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
493
|
-
className: "dsm-rowName",
|
|
494
|
-
children: name
|
|
495
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckRow, {
|
|
496
|
-
prefix: "dsm",
|
|
497
|
-
id: `dsm-row-${name}`,
|
|
498
|
-
label: t("rowEnabled"),
|
|
499
|
-
checked: row.enabled,
|
|
500
|
-
disabled,
|
|
501
|
-
onEdit: (v) => onEdit({
|
|
502
|
-
...row,
|
|
503
|
-
enabled: v
|
|
504
|
-
})
|
|
505
|
-
})]
|
|
506
|
-
}),
|
|
507
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
508
|
-
className: "dsm-rowHint",
|
|
509
|
-
children: t("rowHint")
|
|
510
|
-
}),
|
|
511
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectField, {
|
|
512
|
-
prefix: "dsm",
|
|
513
|
-
id: `dsm-provider-${name}`,
|
|
514
|
-
label: t("provider"),
|
|
515
|
-
hint: t("providerHint"),
|
|
516
|
-
value: row.provider,
|
|
517
|
-
options: providerOptions(catalog, row, t),
|
|
518
|
-
disabled,
|
|
519
|
-
onEdit: (v) => onEdit({
|
|
520
|
-
...row,
|
|
521
|
-
provider: v
|
|
522
|
-
})
|
|
523
|
-
}),
|
|
524
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectField, {
|
|
525
|
-
prefix: "dsm",
|
|
526
|
-
id: `dsm-model-${name}`,
|
|
527
|
-
label: t("model"),
|
|
528
|
-
hint: t("modelHint"),
|
|
529
|
-
value: row.model,
|
|
530
|
-
options: modelOptions(catalog, row, t),
|
|
531
|
-
disabled: disabled || row.provider.length === 0,
|
|
532
|
-
invalid: invalidModel,
|
|
533
|
-
invalidLabel: t("invalidModel"),
|
|
534
|
-
onEdit: (v) => onEdit({
|
|
535
|
-
...row,
|
|
536
|
-
model: v
|
|
537
|
-
})
|
|
538
|
-
}),
|
|
539
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectField, {
|
|
540
|
-
prefix: "dsm",
|
|
541
|
-
id: `dsm-effort-${name}`,
|
|
542
|
-
label: t("effort"),
|
|
543
|
-
hint: t("effortHint"),
|
|
544
|
-
value: row.reasoningEffort,
|
|
545
|
-
options: effortOptions(catalog, row, t),
|
|
546
|
-
disabled,
|
|
547
|
-
onEdit: (v) => onEdit({
|
|
548
|
-
...row,
|
|
549
|
-
reasoningEffort: v
|
|
550
|
-
})
|
|
551
|
-
})
|
|
552
|
-
]
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
function SubagentModelCard(props) {
|
|
556
|
-
const { t, scope, api } = props;
|
|
557
|
-
const snapshot = (0, react.useSyncExternalStore)((listener) => scope.subscribe(listener), () => scope.getSnapshot());
|
|
558
|
-
const value = snapshot.value;
|
|
559
|
-
const [open, setOpen] = (0, react.useState)(false);
|
|
560
|
-
const [draft, setDraft] = (0, react.useState)(null);
|
|
561
|
-
const [catalog, setCatalog] = (0, react.useState)(null);
|
|
562
|
-
const [catalogFailed, setCatalogFailed] = (0, react.useState)(false);
|
|
563
|
-
const [saving, setSaving] = (0, react.useState)(false);
|
|
564
|
-
const [status, setStatus] = (0, react.useState)(IDLE_STATUS);
|
|
565
|
-
(0, react.useEffect)(() => {
|
|
566
|
-
if (value === void 0) return;
|
|
567
|
-
setDraft((current) => {
|
|
568
|
-
if (current === null) return draftFrom(value, catalog);
|
|
569
|
-
if (catalog === null) return current;
|
|
570
|
-
const rows = { ...current.rows };
|
|
571
|
-
let changed = false;
|
|
572
|
-
for (const name of catalog.subagentProviders) {
|
|
573
|
-
if (name in rows) continue;
|
|
574
|
-
rows[name] = { ...EMPTY_ROW };
|
|
575
|
-
changed = true;
|
|
576
|
-
}
|
|
577
|
-
return changed ? {
|
|
578
|
-
...current,
|
|
579
|
-
rows
|
|
580
|
-
} : current;
|
|
581
|
-
});
|
|
582
|
-
}, [value, catalog]);
|
|
583
|
-
(0, react.useEffect)(() => {
|
|
584
|
-
if (!open || catalog !== null) return;
|
|
585
|
-
let alive = true;
|
|
586
|
-
fetchCatalog().then((loaded) => {
|
|
587
|
-
if (!alive) return;
|
|
588
|
-
setCatalog(loaded);
|
|
589
|
-
setCatalogFailed(false);
|
|
590
|
-
}).catch(() => {
|
|
591
|
-
if (alive) setCatalogFailed(true);
|
|
592
|
-
});
|
|
593
|
-
return () => {
|
|
594
|
-
alive = false;
|
|
595
|
-
};
|
|
596
|
-
}, [open, catalog]);
|
|
597
|
-
const dirty = (0, react.useMemo)(() => value !== void 0 && draft !== null && JSON.stringify(toPatch(draft)) !== JSON.stringify(toPatch(draftFrom(value, catalog))), [
|
|
598
|
-
value,
|
|
599
|
-
draft,
|
|
600
|
-
catalog
|
|
601
|
-
]);
|
|
602
|
-
const invalid = (0, react.useMemo)(() => draft !== null && Object.values(draft.rows).some((row) => row.model.length > 0 && row.provider.length === 0), [draft]);
|
|
603
|
-
if (value === void 0 || draft === null) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
|
|
604
|
-
className: "dsm-card",
|
|
605
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
606
|
-
className: "dsm-empty",
|
|
607
|
-
children: t("loading")
|
|
608
|
-
})
|
|
609
|
-
});
|
|
610
|
-
const edit = (key, editValue) => {
|
|
611
|
-
setDraft({
|
|
612
|
-
...draft,
|
|
613
|
-
[key]: editValue
|
|
614
|
-
});
|
|
615
|
-
setStatus(IDLE_STATUS);
|
|
616
|
-
};
|
|
617
|
-
const editRow = (name, row) => {
|
|
618
|
-
setDraft({
|
|
619
|
-
...draft,
|
|
620
|
-
rows: {
|
|
621
|
-
...draft.rows,
|
|
622
|
-
[name]: row
|
|
623
|
-
}
|
|
624
|
-
});
|
|
625
|
-
setStatus(IDLE_STATUS);
|
|
626
|
-
};
|
|
627
|
-
const onSave = () => {
|
|
628
|
-
setSaving(true);
|
|
629
|
-
const revision = scope.getSnapshot().revision;
|
|
630
|
-
api.update({
|
|
631
|
-
ns: SETTINGS_NS,
|
|
632
|
-
patch: toPatch(draft),
|
|
633
|
-
...revision !== void 0 ? { expectedRevision: revision } : {}
|
|
634
|
-
}).then(async (response) => {
|
|
635
|
-
if (!response.result.ok) throw new Error(response.result.error?.message ?? t("saveFailed"));
|
|
636
|
-
await scope.load();
|
|
637
|
-
const next = scope.getSnapshot().value;
|
|
638
|
-
if (next !== void 0) setDraft(draftFrom(next, catalog));
|
|
639
|
-
setStatus(IDLE_STATUS);
|
|
640
|
-
}).catch((error) => {
|
|
641
|
-
setStatus({
|
|
642
|
-
kind: "error",
|
|
643
|
-
text: `${t("saveFailed")}${error instanceof Error ? error.message : ""}`
|
|
644
|
-
});
|
|
645
|
-
}).finally(() => setSaving(false));
|
|
646
|
-
};
|
|
647
|
-
const onRetryCatalog = () => {
|
|
648
|
-
setCatalog(null);
|
|
649
|
-
setCatalogFailed(false);
|
|
650
|
-
};
|
|
651
|
-
const disabled = !snapshot.writable;
|
|
652
|
-
const rowNames = Object.keys(draft.rows).sort();
|
|
653
|
-
const providerCount = (catalog?.providers ?? []).length;
|
|
654
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(CardChrome, {
|
|
655
|
-
prefix: "dsm",
|
|
656
|
-
title: t("title"),
|
|
657
|
-
description: t("description"),
|
|
658
|
-
open,
|
|
659
|
-
onToggle: setOpen,
|
|
660
|
-
statusBadge: {
|
|
661
|
-
text: t(draft.enabled ? "enabledOn" : "enabledOff"),
|
|
662
|
-
on: draft.enabled
|
|
663
|
-
},
|
|
664
|
-
dirty,
|
|
665
|
-
dirtyLabel: t("unsaved"),
|
|
666
|
-
readOnlyNotice: disabled ? t("readOnly") : void 0,
|
|
667
|
-
status,
|
|
668
|
-
actions: [{
|
|
669
|
-
key: "discard",
|
|
670
|
-
label: t("discard"),
|
|
671
|
-
disabled: !dirty || saving,
|
|
672
|
-
onClick: () => {
|
|
673
|
-
setDraft(draftFrom(value, catalog));
|
|
674
|
-
setStatus(IDLE_STATUS);
|
|
675
|
-
}
|
|
676
|
-
}, {
|
|
677
|
-
key: "save",
|
|
678
|
-
label: t(saving ? "saving" : "save"),
|
|
679
|
-
variant: "primary",
|
|
680
|
-
disabled: !dirty || invalid || saving || disabled,
|
|
681
|
-
onClick: onSave
|
|
682
|
-
}],
|
|
683
|
-
children: [
|
|
684
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckRow, {
|
|
685
|
-
prefix: "dsm",
|
|
686
|
-
id: "dsm-enabled",
|
|
687
|
-
label: t("enabled"),
|
|
688
|
-
checked: draft.enabled,
|
|
689
|
-
disabled,
|
|
690
|
-
onEdit: (v) => edit("enabled", v)
|
|
691
|
-
}),
|
|
692
|
-
catalogFailed ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
693
|
-
className: "dsm-banner",
|
|
694
|
-
role: "status",
|
|
695
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("catalogError") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
696
|
-
type: "button",
|
|
697
|
-
className: "dsm-bannerRetry",
|
|
698
|
-
onClick: onRetryCatalog,
|
|
699
|
-
children: t("catalogRetry")
|
|
700
|
-
})]
|
|
701
|
-
}) : null,
|
|
702
|
-
catalog === null && !catalogFailed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
703
|
-
className: "dsm-empty",
|
|
704
|
-
role: "status",
|
|
705
|
-
children: t("catalogLoading")
|
|
706
|
-
}) : null,
|
|
707
|
-
rowNames.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
708
|
-
className: "dsm-empty",
|
|
709
|
-
role: "status",
|
|
710
|
-
children: t("noRows")
|
|
711
|
-
}) : null,
|
|
712
|
-
rowNames.map((name) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RowBlock, {
|
|
713
|
-
name,
|
|
714
|
-
row: draft.rows[name] ?? { ...EMPTY_ROW },
|
|
715
|
-
catalog,
|
|
716
|
-
disabled,
|
|
717
|
-
t,
|
|
718
|
-
onEdit: (row) => editRow(name, row)
|
|
719
|
-
}, name)),
|
|
720
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
721
|
-
className: "dsm-hint dsm-rowHint",
|
|
722
|
-
children: providerCount > 0 ? t("rowDesc") : ""
|
|
723
|
-
})
|
|
724
|
-
]
|
|
725
|
-
});
|
|
726
|
-
}
|
|
727
|
-
//#endregion
|
|
728
|
-
//#region src/client/i18n.ts
|
|
729
|
-
/**
|
|
730
|
-
* 配置卡片文案(zh/en)。经 ctx.locale.register 注册、bind 取用,与官方卡片同机制。
|
|
731
|
-
* 公共键(save/discard/unsaved 等)来自 shared 的 common 字典,本文件只维护业务键。
|
|
732
|
-
* @module subagent-model/client/i18n
|
|
733
|
-
*/
|
|
734
|
-
const NS = "dsh-plus-subagent-model";
|
|
735
|
-
const ownZh = {
|
|
736
|
-
title: "子代理模型配置",
|
|
737
|
-
description: "为 subagent / subagent_fork 等子代理单独指定提供商、模型与思考程度,或继承主代理。",
|
|
738
|
-
enabled: "启用插件",
|
|
739
|
-
rowEnabled: "启用该行",
|
|
740
|
-
provider: "提供商",
|
|
741
|
-
model: "模型",
|
|
742
|
-
effort: "思考程度",
|
|
743
|
-
inheritProvider: "继承主代理",
|
|
744
|
-
inheritModel: "继承主代理",
|
|
745
|
-
effortInherit: "继承主代理",
|
|
746
|
-
effortDefault: "跟随模型默认",
|
|
747
|
-
providerHint: "留空 = 子代理沿用主代理的提供商与模型。",
|
|
748
|
-
modelHint: "留空 = 沿用主代理的模型(需与所选提供商匹配)。",
|
|
749
|
-
effortHint: "inherit = 不干预(fork 会随会话继承);default = 显式使用模型默认档位。",
|
|
750
|
-
rowHint: "按子代理 provider 名匹配;standard preset 中 spawn ↔ subagent 工具、fork ↔ subagent_fork 工具。",
|
|
751
|
-
rowDesc: "未注册的 provider 行不生效,可保留待用。",
|
|
752
|
-
noRows: "当前未发现子代理 provider;配置将在 provider 注册后生效。",
|
|
753
|
-
catalogError: "提供商目录加载失败:",
|
|
754
|
-
catalogRetry: "重试",
|
|
755
|
-
catalogLoading: "目录加载中…",
|
|
756
|
-
unknownValue: "目录外",
|
|
757
|
-
invalidModel: "模型不能脱离提供商单独配置。"
|
|
758
|
-
};
|
|
759
|
-
const ownEn = {
|
|
760
|
-
title: "Subagent model config",
|
|
761
|
-
description: "Pick a provider, model, and thinking effort for subagent / subagent_fork children, or inherit from the main agent.",
|
|
762
|
-
enabled: "Enable plugin",
|
|
763
|
-
rowEnabled: "Enable row",
|
|
764
|
-
provider: "Provider",
|
|
765
|
-
model: "Model",
|
|
766
|
-
effort: "Effort",
|
|
767
|
-
inheritProvider: "Inherit from main agent",
|
|
768
|
-
inheritModel: "Inherit from main agent",
|
|
769
|
-
effortInherit: "Inherit from main agent",
|
|
770
|
-
effortDefault: "Follow model default",
|
|
771
|
-
providerHint: "Empty = the child follows the main agent’s provider and model.",
|
|
772
|
-
modelHint: "Empty = follow the main agent’s model (must match the chosen provider).",
|
|
773
|
-
effortHint: "inherit = do not touch (forks inherit via session seed); default = explicitly use the model’s default level.",
|
|
774
|
-
rowHint: "Matched by subagent provider name; in the standard preset spawn ↔ subagent tool, fork ↔ subagent_fork tool.",
|
|
775
|
-
rowDesc: "Rows for unregistered providers are inert; keep them for later.",
|
|
776
|
-
noRows: "No subagent provider registered yet; config takes effect once one appears.",
|
|
777
|
-
catalogError: "Failed to load provider catalog: ",
|
|
778
|
-
catalogRetry: "Retry",
|
|
779
|
-
catalogLoading: "Loading catalog…",
|
|
780
|
-
unknownValue: "outside catalog",
|
|
781
|
-
invalidModel: "Model cannot be set without a provider."
|
|
782
|
-
};
|
|
783
|
-
const zh = mergeDict(commonZh, ownZh);
|
|
784
|
-
const en = mergeDict(commonEn, ownEn);
|
|
785
|
-
//#endregion
|
|
786
|
-
//#region src/client/styles.ts
|
|
787
|
-
/**
|
|
788
|
-
* 配置卡片样式:基础规则走 @dsh-plus/shared/client 的 cardCss('dsm'),
|
|
789
|
-
* 本文件只补插件特有规则(provider 行块 / banner / 目录空态)。
|
|
790
|
-
* 沿用官方 data-plugin / data-plugin-css 约定(HMR 据此卸载)。
|
|
791
|
-
* @module subagent-model/client/styles
|
|
792
|
-
*/
|
|
793
|
-
const PLUGIN_ID = "@dsh-plus/subagent-model";
|
|
794
|
-
const cardCssAll = cardCss("dsm", `
|
|
795
|
-
.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}
|
|
796
|
-
.dsm-rowHead{align-items:center;gap:8px;padding:8px 0 2px;display:flex}
|
|
797
|
-
.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}
|
|
798
|
-
.dsm-rowHint{color:var(--dsw-alias-label-tertiary);margin:0 0 4px;font-size:12px;line-height:1.5}
|
|
799
|
-
.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}
|
|
800
|
-
.dsm-bannerRetry{color:inherit;font:inherit;cursor:pointer;background:0 0;border:none;flex:none;padding:0;font-weight:600}
|
|
801
|
-
.dsm-empty{color:var(--dsw-alias-label-tertiary);margin:12px 0 0;font-size:12px;line-height:1.5}
|
|
802
|
-
@media (max-width:767px){
|
|
803
|
-
.dsm-row{padding:2px 8px 8px}
|
|
804
|
-
.dsm-rowHead{flex-wrap:wrap}
|
|
805
|
-
}
|
|
806
|
-
`);
|
|
807
|
-
/** 幂等注入样式标签;返回标签(已存在或环境无 document 时为 null)。 */
|
|
808
|
-
function injectStyle() {
|
|
809
|
-
return injectCardStyle(PLUGIN_ID, cardCssAll);
|
|
810
|
-
}
|
|
811
|
-
//#endregion
|
|
812
|
-
//#region src/client/client.ts
|
|
813
|
-
const name = "dsh-plus-subagent-model";
|
|
814
|
-
/** 浏览器半需要的 cordis 服务 key(loader 据此注入;package.json 的 dsh.client.inject 管包加载顺序)。 */
|
|
815
|
-
const inject = [
|
|
816
|
-
"slots",
|
|
817
|
-
"locale",
|
|
818
|
-
"connection",
|
|
819
|
-
"remote"
|
|
820
|
-
];
|
|
821
|
-
function apply(ctx) {
|
|
822
|
-
const c = ctx;
|
|
823
|
-
const tag = injectStyle();
|
|
824
|
-
c.effect(() => () => {
|
|
825
|
-
tag?.remove();
|
|
826
|
-
}, "subagent-model: style");
|
|
827
|
-
c.effect(() => c.locale.register(NS, {
|
|
828
|
-
zh,
|
|
829
|
-
en
|
|
830
|
-
}), "subagent-model: locale");
|
|
831
|
-
const api = c.get("connection").api.settings;
|
|
832
|
-
const scope = createApiScope(api, SETTINGS_NS, c, "subagent-model: settings scope");
|
|
833
|
-
c.slots.inject("settings.plugin.item", () => c.slots.register({
|
|
834
|
-
name: "settings.plugin.item",
|
|
835
|
-
key: SETTINGS_NS,
|
|
836
|
-
locale: NS,
|
|
837
|
-
inject: () => ({
|
|
838
|
-
t: c.locale.bind(NS),
|
|
839
|
-
scope,
|
|
840
|
-
api
|
|
841
|
-
})
|
|
842
|
-
}, SubagentModelCard));
|
|
843
|
-
}
|
|
844
|
-
//#endregion
|
|
845
|
-
exports.apply = apply;
|
|
846
|
-
exports.inject = inject;
|
|
847
|
-
exports.name = name;
|
|
848
|
-
return module.exports;
|
|
849
|
-
}
|
|
850
|
-
});
|