@dsh-plus/subagent-model 0.1.8 → 0.1.9
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/client.js +423 -300
- package/package.json +4 -2
- package/src/client/card.tsx +86 -102
- package/src/client/client.ts +5 -84
- package/src/client/i18n.ts +7 -22
- package/src/client/styles.ts +12 -48
- package/src/client/fields.tsx +0 -75
- package/src/client/scope.ts +0 -59
package/lib/client.js
CHANGED
|
@@ -4,8 +4,336 @@ window.__ModuleLoader__.load({
|
|
|
4
4
|
var module = { exports: {} };
|
|
5
5
|
var exports = module.exports;
|
|
6
6
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
-
let react = require("react");
|
|
8
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
let react = require("react");
|
|
9
|
+
//#region ../shared/src/client/card.tsx
|
|
10
|
+
const IDLE_STATUS = {
|
|
11
|
+
kind: "idle",
|
|
12
|
+
text: ""
|
|
13
|
+
};
|
|
14
|
+
function CardChrome(props) {
|
|
15
|
+
const p = props.prefix;
|
|
16
|
+
const badge = props.statusBadge;
|
|
17
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
18
|
+
className: `${p}-card${props.open ? ` ${p}-cardOpen` : ""}`,
|
|
19
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
20
|
+
type: "button",
|
|
21
|
+
className: `${p}-header`,
|
|
22
|
+
"aria-expanded": props.open,
|
|
23
|
+
"aria-label": props.title,
|
|
24
|
+
onClick: () => props.onToggle(!props.open),
|
|
25
|
+
children: [
|
|
26
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
27
|
+
className: `${p}-headText`,
|
|
28
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
29
|
+
className: `${p}-name`,
|
|
30
|
+
children: props.title
|
|
31
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
32
|
+
className: `${p}-description`,
|
|
33
|
+
children: props.description
|
|
34
|
+
})]
|
|
35
|
+
}),
|
|
36
|
+
badge !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
37
|
+
className: `${p}-statusBadge ${badge.on ? `${p}-statusOn` : `${p}-statusOff`}`,
|
|
38
|
+
children: badge.text
|
|
39
|
+
}) : null,
|
|
40
|
+
props.dirty ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
41
|
+
className: `${p}-pending`,
|
|
42
|
+
children: props.dirtyLabel
|
|
43
|
+
}) : null,
|
|
44
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
45
|
+
className: `${p}-chevron${props.open ? ` ${p}-chevronOpen` : ""}`,
|
|
46
|
+
children: "▾"
|
|
47
|
+
})
|
|
48
|
+
]
|
|
49
|
+
}), props.open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
50
|
+
className: `${p}-body`,
|
|
51
|
+
children: [
|
|
52
|
+
props.readOnlyNotice !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
53
|
+
className: `${p}-readOnly`,
|
|
54
|
+
role: "status",
|
|
55
|
+
children: props.readOnlyNotice
|
|
56
|
+
}) : null,
|
|
57
|
+
props.children,
|
|
58
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
59
|
+
className: `${p}-footer`,
|
|
60
|
+
children: [props.status !== void 0 && props.status.kind !== "idle" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
61
|
+
className: `${p}-status${props.status.kind === "error" ? ` ${p}-statusError` : ""}`,
|
|
62
|
+
role: "status",
|
|
63
|
+
children: props.status.text
|
|
64
|
+
}) : null, props.actions.map((action) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
65
|
+
type: "button",
|
|
66
|
+
className: `${p}-btn ${action.variant === "primary" ? `${p}-btnPrimary` : `${p}-btnGhost`}`,
|
|
67
|
+
disabled: action.disabled === true,
|
|
68
|
+
onClick: action.onClick,
|
|
69
|
+
children: action.label
|
|
70
|
+
}, action.key))]
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
}) : null]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region ../shared/src/client/fields.tsx
|
|
78
|
+
function CheckRow(props) {
|
|
79
|
+
const p = props.prefix ?? "dshp";
|
|
80
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
81
|
+
className: `${p}-checkRow`,
|
|
82
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
83
|
+
id: props.id,
|
|
84
|
+
type: "checkbox",
|
|
85
|
+
checked: props.checked,
|
|
86
|
+
disabled: props.disabled === true,
|
|
87
|
+
onChange: (event) => props.onEdit(event.target.checked)
|
|
88
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
89
|
+
htmlFor: props.id,
|
|
90
|
+
children: props.label
|
|
91
|
+
})]
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function SelectField(props) {
|
|
95
|
+
const p = props.prefix ?? "dshp";
|
|
96
|
+
const invalid = props.invalid === true;
|
|
97
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
98
|
+
className: `${p}-field`,
|
|
99
|
+
children: [
|
|
100
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
101
|
+
className: `${p}-head`,
|
|
102
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
103
|
+
className: `${p}-label`,
|
|
104
|
+
htmlFor: props.id,
|
|
105
|
+
children: props.label
|
|
106
|
+
})
|
|
107
|
+
}),
|
|
108
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
|
|
109
|
+
id: props.id,
|
|
110
|
+
className: `${p}-select${invalid ? ` ${p}-inputInvalid` : ""}`,
|
|
111
|
+
"aria-invalid": invalid || void 0,
|
|
112
|
+
value: props.value,
|
|
113
|
+
disabled: props.disabled === true,
|
|
114
|
+
onChange: (event) => props.onEdit(event.target.value),
|
|
115
|
+
children: props.options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
116
|
+
value: option.value,
|
|
117
|
+
children: option.label
|
|
118
|
+
}, option.value))
|
|
119
|
+
}),
|
|
120
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
121
|
+
className: invalid ? `${p}-invalid` : `${p}-hint`,
|
|
122
|
+
children: invalid ? props.invalidLabel ?? "" : props.hint ?? ""
|
|
123
|
+
})
|
|
124
|
+
]
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region ../shared/src/client/i18n.ts
|
|
129
|
+
/** 卡片通用文案(save/discard/unsaved/loading 等四插件共有键)。 */
|
|
130
|
+
const commonZh = {
|
|
131
|
+
save: "保存",
|
|
132
|
+
saving: "保存中…",
|
|
133
|
+
discard: "放弃",
|
|
134
|
+
unsaved: "未保存",
|
|
135
|
+
loading: "加载中…",
|
|
136
|
+
unavailable: "配置服务不可用。",
|
|
137
|
+
readOnly: "当前部署无 settings provider,配置为只读;请编辑 settings.yaml。",
|
|
138
|
+
invalidNumber: "请输入正整数。",
|
|
139
|
+
collapse: "收起",
|
|
140
|
+
expand: "展开",
|
|
141
|
+
enabledOn: "已启用",
|
|
142
|
+
enabledOff: "未启用",
|
|
143
|
+
saveFailed: "保存失败,请检查填写内容。",
|
|
144
|
+
confirm: "确认",
|
|
145
|
+
cancel: "取消"
|
|
146
|
+
};
|
|
147
|
+
const commonEn = {
|
|
148
|
+
save: "Save",
|
|
149
|
+
saving: "Saving…",
|
|
150
|
+
discard: "Discard",
|
|
151
|
+
unsaved: "Unsaved",
|
|
152
|
+
loading: "Loading…",
|
|
153
|
+
unavailable: "Settings service unavailable.",
|
|
154
|
+
readOnly: "No settings provider in this deployment; config is read-only. Edit settings.yaml.",
|
|
155
|
+
invalidNumber: "Enter a positive integer.",
|
|
156
|
+
collapse: "Collapse",
|
|
157
|
+
expand: "Expand",
|
|
158
|
+
enabledOn: "On",
|
|
159
|
+
enabledOff: "Off",
|
|
160
|
+
saveFailed: "Save failed; check the fields.",
|
|
161
|
+
confirm: "Confirm",
|
|
162
|
+
cancel: "Cancel"
|
|
163
|
+
};
|
|
164
|
+
/** own 覆盖同键合并(返回新对象,入参不可变)。 */
|
|
165
|
+
function mergeDict(base, own) {
|
|
166
|
+
return {
|
|
167
|
+
...base,
|
|
168
|
+
...own
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region ../shared/src/client/scope.ts
|
|
173
|
+
/**
|
|
174
|
+
* api 直连实现的命名空间 scope(官方配置页 tab 同款模式)。
|
|
175
|
+
* 读:describe 取命名空间视图(脱敏 value/revision + 顶层 writable);
|
|
176
|
+
* 刷新:remote `settings/document-updated`(按命名空间过滤)与
|
|
177
|
+
* `connection/reset`;generation 防旧读覆盖新发布。任何页面 origin
|
|
178
|
+
* (loopback 或 tailnet 信任域名)下行为一致。
|
|
179
|
+
* effect 归属调用方 fiber(label 需含插件名以便诊断)。
|
|
180
|
+
*/
|
|
181
|
+
function createApiScope(api, ns, c, label) {
|
|
182
|
+
let state = {
|
|
183
|
+
status: "loading",
|
|
184
|
+
value: void 0,
|
|
185
|
+
revision: void 0,
|
|
186
|
+
writable: false
|
|
187
|
+
};
|
|
188
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
189
|
+
let generation = 0;
|
|
190
|
+
const publish = (next) => {
|
|
191
|
+
state = next;
|
|
192
|
+
for (const listener of [...listeners]) listener();
|
|
193
|
+
};
|
|
194
|
+
const load = async () => {
|
|
195
|
+
const gen = ++generation;
|
|
196
|
+
let response;
|
|
197
|
+
try {
|
|
198
|
+
response = await api.describe({});
|
|
199
|
+
} catch {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (gen !== generation || !response.result.ok) return;
|
|
203
|
+
const writable = response.result.value?.writable ?? false;
|
|
204
|
+
const view = response.result.value?.namespaces.find((candidate) => candidate.ns === ns);
|
|
205
|
+
if (view === void 0) {
|
|
206
|
+
publish({
|
|
207
|
+
status: "unavailable",
|
|
208
|
+
value: void 0,
|
|
209
|
+
revision: void 0,
|
|
210
|
+
writable
|
|
211
|
+
});
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
publish({
|
|
215
|
+
status: "ready",
|
|
216
|
+
value: view.value,
|
|
217
|
+
revision: view.revision,
|
|
218
|
+
writable
|
|
219
|
+
});
|
|
220
|
+
};
|
|
221
|
+
const refresh = (namespace) => {
|
|
222
|
+
if (namespace !== void 0 && namespace !== ns) return;
|
|
223
|
+
load();
|
|
224
|
+
};
|
|
225
|
+
const disposers = [c.get("remote").$on("settings/document-updated", refresh), c.on("connection/reset", () => {
|
|
226
|
+
load();
|
|
227
|
+
})];
|
|
228
|
+
c.effect(() => () => {
|
|
229
|
+
for (const dispose of disposers) dispose();
|
|
230
|
+
}, label);
|
|
231
|
+
load();
|
|
232
|
+
return {
|
|
233
|
+
getSnapshot: () => state,
|
|
234
|
+
subscribe: (listener) => {
|
|
235
|
+
listeners.add(listener);
|
|
236
|
+
return () => {
|
|
237
|
+
listeners.delete(listener);
|
|
238
|
+
};
|
|
239
|
+
},
|
|
240
|
+
load
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region ../shared/src/client/styles.ts
|
|
245
|
+
/**
|
|
246
|
+
* 配置卡片样式工厂(各插件 client 的公共收编版)。
|
|
247
|
+
* 视觉规则与迁移前逐字一致(类名前缀换为各插件自身,DOM 类名不变),
|
|
248
|
+
* 另补移动端与可达性增强(767px 断点 + pointer:coarse,对齐 ui-mobile-fit 约定):
|
|
249
|
+
* - 窄屏 input/textarea 16px(防 iOS 聚焦缩放)、可点目标 ≥44px;
|
|
250
|
+
* - footer 按钮等宽换行、状态文字独占一行;
|
|
251
|
+
* - 展开态 body 底部 sticky 保存栏(长表单滚动中始终可达)。
|
|
252
|
+
* 沿用官方 data-plugin / data-plugin-css 约定(HMR 据此卸载),不覆盖上游选择器。
|
|
253
|
+
* @module @dsh-plus/shared/client/styles
|
|
254
|
+
*/
|
|
255
|
+
/** 生成全套卡片 CSS;prefix 为插件类名前缀(如 'dne'),extra 为插件特有规则。 */
|
|
256
|
+
function cardCss(prefix, extra = "") {
|
|
257
|
+
return `
|
|
258
|
+
.${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}
|
|
259
|
+
.${prefix}-card:hover{border-color:var(--dsw-alias-label-dimmed)}
|
|
260
|
+
.${prefix}-cardOpen{background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-label-dimmed)}
|
|
261
|
+
.${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}
|
|
262
|
+
.${prefix}-header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px}
|
|
263
|
+
.${prefix}-headText{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}
|
|
264
|
+
.${prefix}-name{color:var(--dsw-alias-label-primary);font-size:15px;font-weight:600;line-height:1.4}
|
|
265
|
+
.${prefix}-description{color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:1.5}
|
|
266
|
+
.${prefix}-chevron{color:var(--dsw-alias-label-tertiary);flex:none;transition:transform .16s;font-size:12px}
|
|
267
|
+
.${prefix}-chevronOpen{transform:rotate(180deg)}
|
|
268
|
+
.${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}
|
|
269
|
+
.${prefix}-statusBadge{white-space:nowrap;border-radius:999px;flex:none;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px}
|
|
270
|
+
.${prefix}-statusOn{background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-secondary)}
|
|
271
|
+
.${prefix}-statusOff{color:var(--dsw-alias-label-tertiary)}
|
|
272
|
+
.${prefix}-body{border-top:1px solid var(--dsw-alias-border-l2);margin:0 16px;padding-bottom:8px}
|
|
273
|
+
.${prefix}-field{flex-direction:column;gap:6px;padding:12px 0;display:flex}
|
|
274
|
+
.${prefix}-field+.${prefix}-field{border-top:1px solid var(--dsw-alias-border-l2)}
|
|
275
|
+
.${prefix}-head{align-items:center;gap:8px;display:flex}
|
|
276
|
+
.${prefix}-label{min-width:0;color:var(--dsw-alias-label-primary);flex:1;font-size:13px;font-weight:500;line-height:1.5}
|
|
277
|
+
.${prefix}-badge{white-space:nowrap;border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px}
|
|
278
|
+
.${prefix}-badgeSet{background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-secondary)}
|
|
279
|
+
.${prefix}-badgeUnset{color:var(--dsw-alias-label-tertiary)}
|
|
280
|
+
.${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}
|
|
281
|
+
.${prefix}-input:focus-visible{border-color:var(--dsw-alias-brand-primary);outline:none}
|
|
282
|
+
.${prefix}-input:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}
|
|
283
|
+
.${prefix}-inputInvalid{border-color:var(--dsw-alias-label-error)}
|
|
284
|
+
.${prefix}-select{appearance:none;background-image:linear-gradient(45deg,transparent 50%,var(--dsw-alias-label-tertiary) 50%),linear-gradient(135deg,var(--dsw-alias-label-tertiary) 50%,transparent 50%);background-position:calc(100% - 16px) 50%,calc(100% - 11px) 50%;background-size:5px 5px;background-repeat:no-repeat;padding-right:28px}
|
|
285
|
+
.${prefix}-hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:1.5}
|
|
286
|
+
.${prefix}-invalid{color:var(--dsw-alias-label-error);margin:0;font-size:12px;line-height:1.5}
|
|
287
|
+
.${prefix}-checkRow{align-items:center;gap:8px;display:flex;padding:6px 0}
|
|
288
|
+
.${prefix}-checkRow input{accent-color:var(--dsw-alias-brand-primary)}
|
|
289
|
+
.${prefix}-checkRow label{color:var(--dsw-alias-label-primary);font-size:13px;line-height:1.5;cursor:pointer}
|
|
290
|
+
.${prefix}-groupLabel{color:var(--dsw-alias-label-secondary);font-size:12px;font-weight:600;padding:12px 0 2px;margin:0}
|
|
291
|
+
.${prefix}-readOnly{color:var(--dsw-alias-label-tertiary);margin:12px 0 0;font-size:12px;line-height:1.5}
|
|
292
|
+
.${prefix}-warn{color:var(--dsw-alias-label-error);margin:12px 0 0;font-size:12px;line-height:1.5}
|
|
293
|
+
.${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}
|
|
294
|
+
.${prefix}-status{min-width:0;color:var(--dsw-alias-label-secondary);flex:1;margin:0;font-size:12px;line-height:1.5}
|
|
295
|
+
.${prefix}-statusError{color:var(--dsw-alias-label-error)}
|
|
296
|
+
.${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}
|
|
297
|
+
.${prefix}-btnGhost{border-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);background:0 0}
|
|
298
|
+
.${prefix}-btnGhost:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed)}
|
|
299
|
+
.${prefix}-btnPrimary{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}
|
|
300
|
+
.${prefix}-btn:disabled{opacity:.4;cursor:default}
|
|
301
|
+
.${prefix}-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}
|
|
302
|
+
@media (max-width:767px){
|
|
303
|
+
.${prefix}-body{margin:0 10px}
|
|
304
|
+
.${prefix}-header{padding:12px 12px}
|
|
305
|
+
.${prefix}-input,.${prefix}-select{font-size:16px;height:40px}
|
|
306
|
+
.${prefix}-checkRow{min-height:44px;padding:8px 0}
|
|
307
|
+
.${prefix}-checkRow input{width:18px;height:18px;flex:none}
|
|
308
|
+
.${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}
|
|
309
|
+
.${prefix}-status{flex-basis:100%;flex:none}
|
|
310
|
+
.${prefix}-btn{min-height:44px;flex:1;min-width:96px}
|
|
311
|
+
.${prefix}-statusBadge{display:none}
|
|
312
|
+
}
|
|
313
|
+
@media (pointer:coarse){
|
|
314
|
+
.${prefix}-btn{min-height:44px}
|
|
315
|
+
.${prefix}-checkRow{min-height:44px}
|
|
316
|
+
.${prefix}-input,.${prefix}-select{height:40px}
|
|
317
|
+
}
|
|
318
|
+
${extra}
|
|
319
|
+
`;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* 幂等注入样式标签(官方 data-plugin-css 约定);返回新标签,
|
|
323
|
+
* 已存在或环境无 document 时返回 null(调用方 effect 卸载用)。
|
|
324
|
+
*/
|
|
325
|
+
function injectCardStyle(pluginId, css) {
|
|
326
|
+
if (typeof document === "undefined") return null;
|
|
327
|
+
const tagId = `${pluginId}/card.css`;
|
|
328
|
+
if (document.querySelector(`style[data-plugin-css=${JSON.stringify(tagId)}]`) !== null) return null;
|
|
329
|
+
const tag = document.createElement("style");
|
|
330
|
+
tag.dataset.plugin = pluginId;
|
|
331
|
+
tag.dataset.pluginCss = tagId;
|
|
332
|
+
tag.textContent = css;
|
|
333
|
+
document.head.appendChild(tag);
|
|
334
|
+
return tag;
|
|
335
|
+
}
|
|
336
|
+
//#endregion
|
|
9
337
|
//#region src/ns.ts
|
|
10
338
|
/**
|
|
11
339
|
* settings 命名空间字面量(纯常量,零依赖,浏览器半可安全引入)。
|
|
@@ -64,69 +392,16 @@ window.__ModuleLoader__.load({
|
|
|
64
392
|
};
|
|
65
393
|
}
|
|
66
394
|
//#endregion
|
|
67
|
-
//#region src/client/fields.tsx
|
|
68
|
-
function CheckRow(props) {
|
|
69
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
70
|
-
className: "dsm-checkRow",
|
|
71
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
72
|
-
id: props.id,
|
|
73
|
-
type: "checkbox",
|
|
74
|
-
checked: props.checked,
|
|
75
|
-
disabled: props.disabled === true,
|
|
76
|
-
onChange: (event) => props.onEdit(event.target.checked)
|
|
77
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
78
|
-
htmlFor: props.id,
|
|
79
|
-
children: props.label
|
|
80
|
-
})]
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
function SelectField(props) {
|
|
84
|
-
const invalid = props.invalid === true;
|
|
85
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
86
|
-
className: "dsm-field",
|
|
87
|
-
children: [
|
|
88
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
89
|
-
className: "dsm-head",
|
|
90
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
91
|
-
className: "dsm-label",
|
|
92
|
-
htmlFor: props.id,
|
|
93
|
-
children: props.label
|
|
94
|
-
})
|
|
95
|
-
}),
|
|
96
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
|
|
97
|
-
id: props.id,
|
|
98
|
-
className: "dsm-select",
|
|
99
|
-
"aria-invalid": invalid || void 0,
|
|
100
|
-
value: props.value,
|
|
101
|
-
disabled: props.disabled === true,
|
|
102
|
-
onChange: (event) => props.onEdit(event.target.value),
|
|
103
|
-
children: props.options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
104
|
-
value: option.value,
|
|
105
|
-
children: option.label
|
|
106
|
-
}, option.value))
|
|
107
|
-
}),
|
|
108
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
109
|
-
className: invalid ? "dsm-invalid" : "dsm-hint",
|
|
110
|
-
children: invalid ? props.invalidLabel ?? "" : props.hint ?? ""
|
|
111
|
-
})
|
|
112
|
-
]
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
//#endregion
|
|
116
395
|
//#region src/client/card.tsx
|
|
117
396
|
/**
|
|
118
397
|
* 「子代理模型配置」配置卡片:注册进 settings.plugin.item 插槽(官方插件配置页)。
|
|
119
|
-
*
|
|
120
|
-
* 配置读写走官方 settingsScope
|
|
121
|
-
*
|
|
398
|
+
* 外壳与基础控件走 @dsh-plus/shared/client 套件(CardChrome/CheckRow/SelectField)。
|
|
399
|
+
* 配置读写走官方 settingsScope 传输:value 为 schema 解析后的命名空间值
|
|
400
|
+
* (enabled + entries),行集合 = 目录返回的已注册子代理 provider
|
|
122
401
|
* ∪ 已配置条目,保存时全量写回 entries(未配置的新 provider 行以默认空值
|
|
123
402
|
* 落盘,自文档化);「模型目录」为唯一保留的自定义端点。
|
|
124
403
|
* @module subagent-model/client/card
|
|
125
404
|
*/
|
|
126
|
-
const IDLE_STATUS = {
|
|
127
|
-
kind: "idle",
|
|
128
|
-
text: ""
|
|
129
|
-
};
|
|
130
405
|
const EFFORT_INHERIT = "inherit";
|
|
131
406
|
const EFFORT_DEFAULT = "default";
|
|
132
407
|
function unknownOption(value, label) {
|
|
@@ -188,6 +463,7 @@ window.__ModuleLoader__.load({
|
|
|
188
463
|
className: "dsm-rowName",
|
|
189
464
|
children: name
|
|
190
465
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckRow, {
|
|
466
|
+
prefix: "dsm",
|
|
191
467
|
id: `dsm-row-${name}`,
|
|
192
468
|
label: t("rowEnabled"),
|
|
193
469
|
checked: row.enabled,
|
|
@@ -203,6 +479,7 @@ window.__ModuleLoader__.load({
|
|
|
203
479
|
children: t("rowHint")
|
|
204
480
|
}),
|
|
205
481
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectField, {
|
|
482
|
+
prefix: "dsm",
|
|
206
483
|
id: `dsm-provider-${name}`,
|
|
207
484
|
label: t("provider"),
|
|
208
485
|
hint: t("providerHint"),
|
|
@@ -215,6 +492,7 @@ window.__ModuleLoader__.load({
|
|
|
215
492
|
})
|
|
216
493
|
}),
|
|
217
494
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectField, {
|
|
495
|
+
prefix: "dsm",
|
|
218
496
|
id: `dsm-model-${name}`,
|
|
219
497
|
label: t("model"),
|
|
220
498
|
hint: t("modelHint"),
|
|
@@ -229,6 +507,7 @@ window.__ModuleLoader__.load({
|
|
|
229
507
|
})
|
|
230
508
|
}),
|
|
231
509
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectField, {
|
|
510
|
+
prefix: "dsm",
|
|
232
511
|
id: `dsm-effort-${name}`,
|
|
233
512
|
label: t("effort"),
|
|
234
513
|
hint: t("effortHint"),
|
|
@@ -342,120 +621,88 @@ window.__ModuleLoader__.load({
|
|
|
342
621
|
const disabled = !snapshot.writable;
|
|
343
622
|
const rowNames = Object.keys(draft.rows).sort();
|
|
344
623
|
const providerCount = (catalog?.providers ?? []).length;
|
|
345
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
417
|
-
className: "dsm-hint dsm-rowHint",
|
|
418
|
-
children: providerCount > 0 ? t("rowDesc") : ""
|
|
419
|
-
}),
|
|
420
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
421
|
-
className: "dsm-footer",
|
|
422
|
-
children: [
|
|
423
|
-
status.kind !== "idle" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
424
|
-
className: `dsm-status${status.kind === "error" ? " dsm-statusError" : ""}`,
|
|
425
|
-
role: "status",
|
|
426
|
-
children: status.text
|
|
427
|
-
}) : null,
|
|
428
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
429
|
-
type: "button",
|
|
430
|
-
className: "dsm-btn dsm-btnGhost",
|
|
431
|
-
disabled: !dirty || saving,
|
|
432
|
-
onClick: () => {
|
|
433
|
-
setDraft(draftFrom(value, catalog));
|
|
434
|
-
setStatus(IDLE_STATUS);
|
|
435
|
-
},
|
|
436
|
-
children: t("discard")
|
|
437
|
-
}),
|
|
438
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
439
|
-
type: "button",
|
|
440
|
-
className: "dsm-btn dsm-btnPrimary",
|
|
441
|
-
disabled: !dirty || invalid || saving || disabled,
|
|
442
|
-
onClick: onSave,
|
|
443
|
-
children: t(saving ? "saving" : "save")
|
|
444
|
-
})
|
|
445
|
-
]
|
|
446
|
-
})
|
|
447
|
-
]
|
|
448
|
-
}) : null]
|
|
624
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(CardChrome, {
|
|
625
|
+
prefix: "dsm",
|
|
626
|
+
title: t("title"),
|
|
627
|
+
description: t("description"),
|
|
628
|
+
open,
|
|
629
|
+
onToggle: setOpen,
|
|
630
|
+
statusBadge: {
|
|
631
|
+
text: t(draft.enabled ? "enabledOn" : "enabledOff"),
|
|
632
|
+
on: draft.enabled
|
|
633
|
+
},
|
|
634
|
+
dirty,
|
|
635
|
+
dirtyLabel: t("unsaved"),
|
|
636
|
+
readOnlyNotice: disabled ? t("readOnly") : void 0,
|
|
637
|
+
status,
|
|
638
|
+
actions: [{
|
|
639
|
+
key: "discard",
|
|
640
|
+
label: t("discard"),
|
|
641
|
+
disabled: !dirty || saving,
|
|
642
|
+
onClick: () => {
|
|
643
|
+
setDraft(draftFrom(value, catalog));
|
|
644
|
+
setStatus(IDLE_STATUS);
|
|
645
|
+
}
|
|
646
|
+
}, {
|
|
647
|
+
key: "save",
|
|
648
|
+
label: t(saving ? "saving" : "save"),
|
|
649
|
+
variant: "primary",
|
|
650
|
+
disabled: !dirty || invalid || saving || disabled,
|
|
651
|
+
onClick: onSave
|
|
652
|
+
}],
|
|
653
|
+
children: [
|
|
654
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckRow, {
|
|
655
|
+
prefix: "dsm",
|
|
656
|
+
id: "dsm-enabled",
|
|
657
|
+
label: t("enabled"),
|
|
658
|
+
checked: draft.enabled,
|
|
659
|
+
disabled,
|
|
660
|
+
onEdit: (v) => edit("enabled", v)
|
|
661
|
+
}),
|
|
662
|
+
catalogFailed ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
663
|
+
className: "dsm-banner",
|
|
664
|
+
role: "status",
|
|
665
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("catalogError") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
666
|
+
type: "button",
|
|
667
|
+
className: "dsm-bannerRetry",
|
|
668
|
+
onClick: onRetryCatalog,
|
|
669
|
+
children: t("catalogRetry")
|
|
670
|
+
})]
|
|
671
|
+
}) : null,
|
|
672
|
+
catalog === null && !catalogFailed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
673
|
+
className: "dsm-empty",
|
|
674
|
+
role: "status",
|
|
675
|
+
children: t("catalogLoading")
|
|
676
|
+
}) : null,
|
|
677
|
+
rowNames.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
678
|
+
className: "dsm-empty",
|
|
679
|
+
role: "status",
|
|
680
|
+
children: t("noRows")
|
|
681
|
+
}) : null,
|
|
682
|
+
rowNames.map((name) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RowBlock, {
|
|
683
|
+
name,
|
|
684
|
+
row: draft.rows[name] ?? { ...EMPTY_ROW },
|
|
685
|
+
catalog,
|
|
686
|
+
disabled,
|
|
687
|
+
t,
|
|
688
|
+
onEdit: (row) => editRow(name, row)
|
|
689
|
+
}, name)),
|
|
690
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
691
|
+
className: "dsm-hint dsm-rowHint",
|
|
692
|
+
children: providerCount > 0 ? t("rowDesc") : ""
|
|
693
|
+
})
|
|
694
|
+
]
|
|
449
695
|
});
|
|
450
696
|
}
|
|
451
697
|
//#endregion
|
|
452
698
|
//#region src/client/i18n.ts
|
|
453
699
|
/**
|
|
454
700
|
* 配置卡片文案(zh/en)。经 ctx.locale.register 注册、bind 取用,与官方卡片同机制。
|
|
701
|
+
* 公共键(save/discard/unsaved 等)来自 shared 的 common 字典,本文件只维护业务键。
|
|
455
702
|
* @module subagent-model/client/i18n
|
|
456
703
|
*/
|
|
457
704
|
const NS = "dsh-plus-subagent-model";
|
|
458
|
-
const
|
|
705
|
+
const ownZh = {
|
|
459
706
|
title: "子代理模型配置",
|
|
460
707
|
description: "为 subagent / subagent_fork 等子代理单独指定提供商、模型与思考程度,或继承主代理。",
|
|
461
708
|
enabled: "启用插件",
|
|
@@ -477,19 +724,9 @@ window.__ModuleLoader__.load({
|
|
|
477
724
|
catalogRetry: "重试",
|
|
478
725
|
catalogLoading: "目录加载中…",
|
|
479
726
|
unknownValue: "目录外",
|
|
480
|
-
save: "保存",
|
|
481
|
-
saving: "保存中…",
|
|
482
|
-
discard: "放弃",
|
|
483
|
-
unsaved: "未保存",
|
|
484
|
-
saveFailed: "保存失败:",
|
|
485
|
-
loading: "加载中…",
|
|
486
|
-
unavailable: "配置服务不可用。",
|
|
487
|
-
readOnly: "当前部署无 settings provider,配置为只读;请编辑 settings.yaml。",
|
|
488
|
-
expand: "展开",
|
|
489
|
-
collapse: "收起",
|
|
490
727
|
invalidModel: "模型不能脱离提供商单独配置。"
|
|
491
728
|
};
|
|
492
|
-
const
|
|
729
|
+
const ownEn = {
|
|
493
730
|
title: "Subagent model config",
|
|
494
731
|
description: "Pick a provider, model, and thinking effort for subagent / subagent_fork children, or inherit from the main agent.",
|
|
495
732
|
enabled: "Enable plugin",
|
|
@@ -511,80 +748,35 @@ window.__ModuleLoader__.load({
|
|
|
511
748
|
catalogRetry: "Retry",
|
|
512
749
|
catalogLoading: "Loading catalog…",
|
|
513
750
|
unknownValue: "outside catalog",
|
|
514
|
-
save: "Save",
|
|
515
|
-
saving: "Saving…",
|
|
516
|
-
discard: "Discard",
|
|
517
|
-
unsaved: "Unsaved",
|
|
518
|
-
saveFailed: "Save failed: ",
|
|
519
|
-
loading: "Loading…",
|
|
520
|
-
unavailable: "Configuration service unavailable.",
|
|
521
|
-
readOnly: "No settings provider in this deployment; edit settings.yaml instead.",
|
|
522
|
-
expand: "Expand",
|
|
523
|
-
collapse: "Collapse",
|
|
524
751
|
invalidModel: "Model cannot be set without a provider."
|
|
525
752
|
};
|
|
753
|
+
const zh = mergeDict(commonZh, ownZh);
|
|
754
|
+
const en = mergeDict(commonEn, ownEn);
|
|
526
755
|
//#endregion
|
|
527
756
|
//#region src/client/styles.ts
|
|
528
757
|
/**
|
|
529
|
-
*
|
|
530
|
-
*
|
|
758
|
+
* 配置卡片样式:基础规则走 @dsh-plus/shared/client 的 cardCss('dsm'),
|
|
759
|
+
* 本文件只补插件特有规则(provider 行块 / banner / 目录空态)。
|
|
760
|
+
* 沿用官方 data-plugin / data-plugin-css 约定(HMR 据此卸载)。
|
|
531
761
|
* @module subagent-model/client/styles
|
|
532
762
|
*/
|
|
533
763
|
const PLUGIN_ID = "@dsh-plus/subagent-model";
|
|
534
|
-
const
|
|
535
|
-
const cardCss = `
|
|
536
|
-
.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}
|
|
537
|
-
.dsm-card:hover{border-color:var(--dsw-alias-label-dimmed)}
|
|
538
|
-
.dsm-cardOpen{background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-label-dimmed)}
|
|
539
|
-
.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}
|
|
540
|
-
.dsm-header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px}
|
|
541
|
-
.dsm-headText{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}
|
|
542
|
-
.dsm-name{color:var(--dsw-alias-label-primary);font-size:15px;font-weight:600;line-height:1.4}
|
|
543
|
-
.dsm-description{color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:1.5}
|
|
544
|
-
.dsm-chevron{color:var(--dsw-alias-label-tertiary);flex:none;transition:transform .16s;font-size:12px}
|
|
545
|
-
.dsm-chevronOpen{transform:rotate(180deg)}
|
|
546
|
-
.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}
|
|
547
|
-
.dsm-body{border-top:1px solid var(--dsw-alias-border-l2);margin:0 16px;padding-bottom:8px}
|
|
548
|
-
.dsm-field{flex-direction:column;gap:6px;padding:12px 0;display:flex}
|
|
549
|
-
.dsm-field+.dsm-field{border-top:1px solid var(--dsw-alias-border-l2)}
|
|
550
|
-
.dsm-head{align-items:center;gap:8px;display:flex}
|
|
551
|
-
.dsm-label{min-width:0;color:var(--dsw-alias-label-primary);flex:1;font-size:13px;font-weight:500;line-height:1.5}
|
|
552
|
-
.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}
|
|
553
|
-
.dsm-select:focus-visible{border-color:var(--dsw-alias-brand-primary);outline:none}
|
|
554
|
-
.dsm-select:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}
|
|
555
|
-
.dsm-hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:1.5}
|
|
556
|
-
.dsm-invalid{color:var(--dsw-alias-label-error);margin:0;font-size:12px;line-height:1.5}
|
|
557
|
-
.dsm-checkRow{align-items:center;gap:8px;display:flex;padding:6px 0}
|
|
558
|
-
.dsm-checkRow input{accent-color:var(--dsw-alias-brand-primary)}
|
|
559
|
-
.dsm-checkRow label{color:var(--dsw-alias-label-primary);font-size:13px;line-height:1.5;cursor:pointer}
|
|
764
|
+
const cardCssAll = cardCss("dsm", `
|
|
560
765
|
.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}
|
|
561
766
|
.dsm-rowHead{align-items:center;gap:8px;padding:8px 0 2px;display:flex}
|
|
562
767
|
.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}
|
|
563
768
|
.dsm-rowHint{color:var(--dsw-alias-label-tertiary);margin:0 0 4px;font-size:12px;line-height:1.5}
|
|
564
|
-
.dsm-groupLabel{color:var(--dsw-alias-label-secondary);font-size:12px;font-weight:600;padding:12px 0 2px;margin:0}
|
|
565
|
-
.dsm-status{min-width:0;color:var(--dsw-alias-label-secondary);flex:1;margin:0;font-size:12px;line-height:1.5}
|
|
566
|
-
.dsm-statusError{color:var(--dsw-alias-label-error)}
|
|
567
769
|
.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}
|
|
568
770
|
.dsm-bannerRetry{color:inherit;font:inherit;cursor:pointer;background:0 0;border:none;flex:none;padding:0;font-weight:600}
|
|
569
771
|
.dsm-empty{color:var(--dsw-alias-label-tertiary);margin:12px 0 0;font-size:12px;line-height:1.5}
|
|
570
|
-
|
|
571
|
-
.dsm-
|
|
572
|
-
.dsm-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
.dsm-btn:disabled{opacity:.4;cursor:default}
|
|
576
|
-
.dsm-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}
|
|
577
|
-
`;
|
|
772
|
+
@media (max-width:767px){
|
|
773
|
+
.dsm-row{padding:2px 8px 8px}
|
|
774
|
+
.dsm-rowHead{flex-wrap:wrap}
|
|
775
|
+
}
|
|
776
|
+
`);
|
|
578
777
|
/** 幂等注入样式标签;返回标签(已存在或环境无 document 时为 null)。 */
|
|
579
778
|
function injectStyle() {
|
|
580
|
-
|
|
581
|
-
if (document.querySelector(`style[data-plugin-css=${JSON.stringify(STYLE_TAG_ID)}]`) !== null) return null;
|
|
582
|
-
const tag = document.createElement("style");
|
|
583
|
-
tag.dataset.plugin = PLUGIN_ID;
|
|
584
|
-
tag.dataset.pluginCss = STYLE_TAG_ID;
|
|
585
|
-
tag.textContent = cardCss;
|
|
586
|
-
document.head.appendChild(tag);
|
|
587
|
-
return tag;
|
|
779
|
+
return injectCardStyle(PLUGIN_ID, cardCssAll);
|
|
588
780
|
}
|
|
589
781
|
//#endregion
|
|
590
782
|
//#region src/client/client.ts
|
|
@@ -596,75 +788,6 @@ window.__ModuleLoader__.load({
|
|
|
596
788
|
"connection",
|
|
597
789
|
"remote"
|
|
598
790
|
];
|
|
599
|
-
/**
|
|
600
|
-
* api 直连实现的命名空间 scope(官方配置页 tab 同款模式)。
|
|
601
|
-
* 读:describe 取命名空间视图(脱敏 value/revision + 顶层 writable);
|
|
602
|
-
* 刷新:remote `settings/document-updated`(按命名空间过滤)与
|
|
603
|
-
* `connection/reset`;generation 防旧读覆盖新发布。任何页面 origin
|
|
604
|
-
* (loopback 或 tailnet 信任域名)下行为一致。
|
|
605
|
-
*/
|
|
606
|
-
function createApiScope(api, ns, c) {
|
|
607
|
-
let state = {
|
|
608
|
-
status: "loading",
|
|
609
|
-
value: void 0,
|
|
610
|
-
revision: void 0,
|
|
611
|
-
writable: false
|
|
612
|
-
};
|
|
613
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
614
|
-
let generation = 0;
|
|
615
|
-
const publish = (next) => {
|
|
616
|
-
state = next;
|
|
617
|
-
for (const listener of [...listeners]) listener();
|
|
618
|
-
};
|
|
619
|
-
const load = async () => {
|
|
620
|
-
const gen = ++generation;
|
|
621
|
-
let response;
|
|
622
|
-
try {
|
|
623
|
-
response = await api.describe({});
|
|
624
|
-
} catch {
|
|
625
|
-
return;
|
|
626
|
-
}
|
|
627
|
-
if (gen !== generation || !response.result.ok) return;
|
|
628
|
-
const writable = response.result.value?.writable ?? false;
|
|
629
|
-
const view = response.result.value?.namespaces.find((candidate) => candidate.ns === ns);
|
|
630
|
-
if (view === void 0) {
|
|
631
|
-
publish({
|
|
632
|
-
status: "unavailable",
|
|
633
|
-
value: void 0,
|
|
634
|
-
revision: void 0,
|
|
635
|
-
writable
|
|
636
|
-
});
|
|
637
|
-
return;
|
|
638
|
-
}
|
|
639
|
-
publish({
|
|
640
|
-
status: "ready",
|
|
641
|
-
value: view.value,
|
|
642
|
-
revision: view.revision,
|
|
643
|
-
writable
|
|
644
|
-
});
|
|
645
|
-
};
|
|
646
|
-
const refresh = (namespace) => {
|
|
647
|
-
if (namespace !== void 0 && namespace !== ns) return;
|
|
648
|
-
load();
|
|
649
|
-
};
|
|
650
|
-
const disposers = [c.get("remote").$on("settings/document-updated", refresh), c.on("connection/reset", () => {
|
|
651
|
-
load();
|
|
652
|
-
})];
|
|
653
|
-
c.effect(() => () => {
|
|
654
|
-
for (const dispose of disposers) dispose();
|
|
655
|
-
}, "subagent-model: settings scope");
|
|
656
|
-
load();
|
|
657
|
-
return {
|
|
658
|
-
getSnapshot: () => state,
|
|
659
|
-
subscribe: (listener) => {
|
|
660
|
-
listeners.add(listener);
|
|
661
|
-
return () => {
|
|
662
|
-
listeners.delete(listener);
|
|
663
|
-
};
|
|
664
|
-
},
|
|
665
|
-
load
|
|
666
|
-
};
|
|
667
|
-
}
|
|
668
791
|
function apply(ctx) {
|
|
669
792
|
const c = ctx;
|
|
670
793
|
const tag = injectStyle();
|
|
@@ -676,7 +799,7 @@ window.__ModuleLoader__.load({
|
|
|
676
799
|
en
|
|
677
800
|
}), "subagent-model: locale");
|
|
678
801
|
const api = c.get("connection").api.settings;
|
|
679
|
-
const scope = createApiScope(api, SETTINGS_NS, c);
|
|
802
|
+
const scope = createApiScope(api, SETTINGS_NS, c, "subagent-model: settings scope");
|
|
680
803
|
c.slots.inject("settings.plugin.item", () => c.slots.register({
|
|
681
804
|
name: "settings.plugin.item",
|
|
682
805
|
key: SETTINGS_NS,
|