dsh-subagent-library 0.3.5 → 0.4.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/CHANGELOG.md +39 -1
- package/LICENSE +201 -19
- package/MIGRATION.md +22 -6
- package/README.en.md +101 -139
- package/README.md +97 -125
- package/THIRD_PARTY_NOTICES.md +18 -45
- package/assets/readme/group-dispatch.png +0 -0
- package/assets/readme/group-settings.png +0 -0
- package/assets/readme/hero.svg +3 -3
- package/lib/client.js +1570 -1366
- package/lib/index.js +1844 -5749
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +3 -3
package/lib/client.js
CHANGED
|
@@ -28,6 +28,225 @@ react = __toESM(react);
|
|
|
28
28
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
29
29
|
react_jsx_runtime = __toESM(react_jsx_runtime);
|
|
30
30
|
|
|
31
|
+
//#region src/entry-id.ts
|
|
32
|
+
/** Entry ids are lowercase DNS-like labels. Also enforced for file names. */
|
|
33
|
+
const ENTRY_ID = /^[a-z0-9][a-z0-9-]*$/;
|
|
34
|
+
/** NTFS single component cap is 255; `<id>.yaml` plus headroom stays far below. */
|
|
35
|
+
const MAX_ID_LENGTH = 64;
|
|
36
|
+
const RESERVED_NAMES = new Set([
|
|
37
|
+
"con",
|
|
38
|
+
"prn",
|
|
39
|
+
"aux",
|
|
40
|
+
"nul",
|
|
41
|
+
...Array.from({ length: 9 }, (_, index) => `com${index + 1}`),
|
|
42
|
+
...Array.from({ length: 9 }, (_, index) => `lpt${index + 1}`)
|
|
43
|
+
]);
|
|
44
|
+
function entryIdIssue(id) {
|
|
45
|
+
if (!id) return "required";
|
|
46
|
+
if (!/^[a-z0-9]/.test(id)) return "start";
|
|
47
|
+
if (!ENTRY_ID.test(id)) return "characters";
|
|
48
|
+
if (id.length > MAX_ID_LENGTH) return "length";
|
|
49
|
+
if (RESERVED_NAMES.has(id)) return "reserved";
|
|
50
|
+
}
|
|
51
|
+
/** Check draft member codes using the same trimming the settings writer applies. */
|
|
52
|
+
function memberCodeErrors(values) {
|
|
53
|
+
const codes = values.map((value) => value.trim());
|
|
54
|
+
const seen = /* @__PURE__ */ new Set();
|
|
55
|
+
const duplicates = /* @__PURE__ */ new Set();
|
|
56
|
+
for (const code of codes) {
|
|
57
|
+
if (seen.has(code)) duplicates.add(code);
|
|
58
|
+
seen.add(code);
|
|
59
|
+
}
|
|
60
|
+
return codes.map((code) => {
|
|
61
|
+
switch (entryIdIssue(code)) {
|
|
62
|
+
case "required": return "请填写成员代号。";
|
|
63
|
+
case "start": return "成员代号须以小写字母或数字开头。";
|
|
64
|
+
case "characters": return "成员代号只能使用小写字母、数字和短横线。";
|
|
65
|
+
case "length": return `成员代号最多 ${MAX_ID_LENGTH} 个字符。`;
|
|
66
|
+
case "reserved": return "这个成员代号是系统保留名称,请换一个。";
|
|
67
|
+
default: return duplicates.has(code) ? "此代号已在编队中使用,请换一个。" : void 0;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/client/editor-state.ts
|
|
74
|
+
const NEW = "@new";
|
|
75
|
+
const own = (rows, id) => Object.hasOwn(rows, id) ? rows[id] : void 0;
|
|
76
|
+
function emptyMember() {
|
|
77
|
+
return {
|
|
78
|
+
slot: "",
|
|
79
|
+
role: "",
|
|
80
|
+
assignment: ""
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function roleForm(id, row) {
|
|
84
|
+
return {
|
|
85
|
+
kind: "roles",
|
|
86
|
+
id,
|
|
87
|
+
enabled: row.enabled !== false,
|
|
88
|
+
description: row.description ?? "",
|
|
89
|
+
provider: row.provider ?? "",
|
|
90
|
+
model: row.model ?? "",
|
|
91
|
+
reasoningEffort: row.reasoningEffort ?? "",
|
|
92
|
+
maxTokens: String(row.maxTokens ?? ""),
|
|
93
|
+
maxDepth: String(row.maxDepth ?? ""),
|
|
94
|
+
subagentProvider: row.subagentProvider ?? "",
|
|
95
|
+
persona: row.persona ?? "",
|
|
96
|
+
filter: row.toolFilter,
|
|
97
|
+
routeNote: row.routeNote,
|
|
98
|
+
inherit: false,
|
|
99
|
+
clearToolFilter: false
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function groupForm(id, group) {
|
|
103
|
+
return {
|
|
104
|
+
kind: "groups",
|
|
105
|
+
id,
|
|
106
|
+
enabled: group.enabled !== false,
|
|
107
|
+
description: group.description,
|
|
108
|
+
name: group.name ?? "",
|
|
109
|
+
instructions: group.instructions ?? "",
|
|
110
|
+
members: group.members.map(({ slot, role, assignment }) => ({
|
|
111
|
+
slot,
|
|
112
|
+
role,
|
|
113
|
+
assignment: assignment ?? ""
|
|
114
|
+
}))
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function serverForm(view, tab, id) {
|
|
118
|
+
if (tab === "groups") {
|
|
119
|
+
const group = own(view.groups, id);
|
|
120
|
+
return group && groupForm(id, group);
|
|
121
|
+
}
|
|
122
|
+
const role = own(view.entries, id);
|
|
123
|
+
if (!role) return void 0;
|
|
124
|
+
return roleForm(id, view.profile ? role : {
|
|
125
|
+
...role,
|
|
126
|
+
...own(view.sharedEntries, id)
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function freshDraft(view, tab, id) {
|
|
130
|
+
const base = serverForm(view, tab, id);
|
|
131
|
+
return {
|
|
132
|
+
form: base ?? (tab === "roles" ? roleForm("", {}) : groupForm("", {
|
|
133
|
+
description: "",
|
|
134
|
+
members: [emptyMember()]
|
|
135
|
+
})),
|
|
136
|
+
base
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
const equal = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
140
|
+
/** Keep edited fields and bring untouched ones forward after an explicit comparison. */
|
|
141
|
+
function rebase(draft, current) {
|
|
142
|
+
if (!current || !draft.base) return {
|
|
143
|
+
form: draft.form,
|
|
144
|
+
base: current
|
|
145
|
+
};
|
|
146
|
+
const base = draft.base;
|
|
147
|
+
const changes = Object.fromEntries(Object.entries(draft.form).filter(([key, value]) => !equal(value, Reflect.get(base, key))));
|
|
148
|
+
const form = {
|
|
149
|
+
...current,
|
|
150
|
+
...changes
|
|
151
|
+
};
|
|
152
|
+
if (form.kind === "roles" && form.inherit) return {
|
|
153
|
+
base: current,
|
|
154
|
+
form: {
|
|
155
|
+
...form,
|
|
156
|
+
provider: "",
|
|
157
|
+
model: "",
|
|
158
|
+
reasoningEffort: "",
|
|
159
|
+
maxTokens: ""
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
return {
|
|
163
|
+
base: current,
|
|
164
|
+
form
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function validate(form, view, isNew, base) {
|
|
168
|
+
const id = form.id.trim();
|
|
169
|
+
const idIssue = entryIdIssue(id);
|
|
170
|
+
if (idIssue === "reserved") return "这个 ID 是系统保留名称,请换一个。";
|
|
171
|
+
if (idIssue && form.kind === "groups") {
|
|
172
|
+
if (idIssue === "required") return "请填写编队 ID。";
|
|
173
|
+
if (/\s/.test(id)) return "编队 ID 中不能有空格,可以用短横线连接单词。";
|
|
174
|
+
return "请按上面的格式修改编队 ID,例如 review-group。";
|
|
175
|
+
}
|
|
176
|
+
if (idIssue) return "ID 可使用小写字母、数字和短横线,以字母或数字开头,最长 64 个字符。";
|
|
177
|
+
if (isNew && serverForm(view, form.kind, id)) return "此 ID 已存在,请换一个。";
|
|
178
|
+
if (!form.description.trim()) return "请填写描述。";
|
|
179
|
+
if (form.kind === "roles") {
|
|
180
|
+
for (const [value, min, label] of [[
|
|
181
|
+
form.maxDepth,
|
|
182
|
+
0,
|
|
183
|
+
"深度上限"
|
|
184
|
+
], [
|
|
185
|
+
form.maxTokens,
|
|
186
|
+
1,
|
|
187
|
+
"输出上限"
|
|
188
|
+
]]) if (value && (!Number.isSafeInteger(Number(value)) || Number(value) < min)) return `${label}需为 ≥${min} 的整数。`;
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (!form.members.length) return "请添加至少一名编队成员。";
|
|
192
|
+
const codeError = memberCodeErrors(form.members.map((m) => m.slot)).find(Boolean);
|
|
193
|
+
if (codeError) return codeError;
|
|
194
|
+
for (const member of form.members) {
|
|
195
|
+
const unchanged = base?.kind === "groups" && base.members.some((m) => m.slot === member.slot.trim() && m.role === member.role);
|
|
196
|
+
if (!member.role || !unchanged && !own(view.entries, member.role)) return "请为每位成员选择名册中的角色。";
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function routeFields(form) {
|
|
200
|
+
return {
|
|
201
|
+
...form.provider.trim() && { provider: form.provider.trim() },
|
|
202
|
+
...form.model.trim() && { model: form.model.trim() },
|
|
203
|
+
...form.reasoningEffort.trim() && { reasoningEffort: form.reasoningEffort.trim() },
|
|
204
|
+
...form.maxTokens && { maxTokens: Number(form.maxTokens) }
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function saveWrite(draft, view) {
|
|
208
|
+
const { form, base } = draft;
|
|
209
|
+
const id = form.id.trim();
|
|
210
|
+
const expectedHash = view.hash;
|
|
211
|
+
const common = {
|
|
212
|
+
description: form.description,
|
|
213
|
+
...!form.enabled && { enabled: false }
|
|
214
|
+
};
|
|
215
|
+
if (form.kind === "groups") return {
|
|
216
|
+
op: "save-group",
|
|
217
|
+
id,
|
|
218
|
+
expectedHash,
|
|
219
|
+
group: {
|
|
220
|
+
...common,
|
|
221
|
+
...form.name.trim() && { name: form.name.trim() },
|
|
222
|
+
...form.instructions && { instructions: form.instructions },
|
|
223
|
+
members: form.members.map((m) => ({
|
|
224
|
+
slot: m.slot.trim(),
|
|
225
|
+
role: m.role,
|
|
226
|
+
...m.assignment && { assignment: m.assignment }
|
|
227
|
+
}))
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
const fields = routeFields(form);
|
|
231
|
+
const previous = base?.kind === "roles" ? routeFields(base) : {};
|
|
232
|
+
const routeChanged = form.inherit || !equal(fields, previous);
|
|
233
|
+
return {
|
|
234
|
+
op: "save-entry",
|
|
235
|
+
id,
|
|
236
|
+
expectedHash,
|
|
237
|
+
entry: {
|
|
238
|
+
...common,
|
|
239
|
+
...form.persona && { persona: form.persona },
|
|
240
|
+
...!base && form.filter && !form.clearToolFilter && { toolFilter: form.filter },
|
|
241
|
+
...form.subagentProvider.trim() && { subagentProvider: form.subagentProvider.trim() },
|
|
242
|
+
...form.maxDepth && { maxDepth: Number(form.maxDepth) }
|
|
243
|
+
},
|
|
244
|
+
...routeChanged && { route: form.inherit || !Object.keys(fields).length ? { inherit: true } : fields },
|
|
245
|
+
...form.clearToolFilter && { clearToolFilter: true }
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
//#endregion
|
|
31
250
|
//#region src/client/settings-theme.ts
|
|
32
251
|
/** Host theme tokens keep the roster at home in both desktop color schemes. */
|
|
33
252
|
const TOKEN = {
|
|
@@ -50,9 +269,6 @@ const TOKEN = {
|
|
|
50
269
|
danger: "var(--dsw-alias-state-error-primary, #dc2626)",
|
|
51
270
|
dangerSoft: "var(--dsw-alias-state-error-secondary, rgba(220,38,38,0.12))"
|
|
52
271
|
};
|
|
53
|
-
const ACCENT = TOKEN.accent;
|
|
54
|
-
const SUCCESS = TOKEN.success;
|
|
55
|
-
const DANGER = TOKEN.danger;
|
|
56
272
|
const MONO = "ui-monospace, SFMono-Regular, Consolas, \"Liberation Mono\", Menlo, monospace";
|
|
57
273
|
const button = {
|
|
58
274
|
display: "inline-flex",
|
|
@@ -98,11 +314,6 @@ const S = {
|
|
|
98
314
|
containerType: "inline-size",
|
|
99
315
|
containerName: "dsh-library"
|
|
100
316
|
},
|
|
101
|
-
pageHeader: {
|
|
102
|
-
display: "flex",
|
|
103
|
-
flexDirection: "column",
|
|
104
|
-
gap: 7
|
|
105
|
-
},
|
|
106
317
|
headingRow: {
|
|
107
318
|
display: "flex",
|
|
108
319
|
alignItems: "center",
|
|
@@ -116,55 +327,6 @@ const S = {
|
|
|
116
327
|
letterSpacing: "-0.025em",
|
|
117
328
|
margin: 0
|
|
118
329
|
},
|
|
119
|
-
sub: {
|
|
120
|
-
fontSize: 12.5,
|
|
121
|
-
lineHeight: 1.65,
|
|
122
|
-
color: TOKEN.muted,
|
|
123
|
-
margin: 0
|
|
124
|
-
},
|
|
125
|
-
band: {
|
|
126
|
-
display: "flex",
|
|
127
|
-
flexDirection: "column",
|
|
128
|
-
gap: 10,
|
|
129
|
-
padding: "13px 16px",
|
|
130
|
-
background: TOKEN.inset,
|
|
131
|
-
borderRadius: 10
|
|
132
|
-
},
|
|
133
|
-
bandStats: {
|
|
134
|
-
display: "flex",
|
|
135
|
-
alignItems: "baseline",
|
|
136
|
-
gap: "8px 24px",
|
|
137
|
-
flexWrap: "wrap"
|
|
138
|
-
},
|
|
139
|
-
bandStat: {
|
|
140
|
-
display: "flex",
|
|
141
|
-
alignItems: "baseline",
|
|
142
|
-
gap: 6
|
|
143
|
-
},
|
|
144
|
-
bandValue: {
|
|
145
|
-
fontSize: 19,
|
|
146
|
-
fontWeight: 600,
|
|
147
|
-
lineHeight: 1.3,
|
|
148
|
-
fontVariantNumeric: "tabular-nums"
|
|
149
|
-
},
|
|
150
|
-
bandLabel: {
|
|
151
|
-
fontSize: 11.5,
|
|
152
|
-
color: TOKEN.muted,
|
|
153
|
-
flexShrink: 0
|
|
154
|
-
},
|
|
155
|
-
bandDir: {
|
|
156
|
-
display: "flex",
|
|
157
|
-
alignItems: "baseline",
|
|
158
|
-
gap: 10,
|
|
159
|
-
minWidth: 0
|
|
160
|
-
},
|
|
161
|
-
bandPath: {
|
|
162
|
-
fontFamily: MONO,
|
|
163
|
-
fontSize: 11.5,
|
|
164
|
-
color: TOKEN.secondary,
|
|
165
|
-
overflowWrap: "anywhere",
|
|
166
|
-
minWidth: 0
|
|
167
|
-
},
|
|
168
330
|
banner: {
|
|
169
331
|
fontSize: 12.5,
|
|
170
332
|
lineHeight: 1.65,
|
|
@@ -203,16 +365,6 @@ const S = {
|
|
|
203
365
|
fontSize: 13,
|
|
204
366
|
fontFamily: "inherit"
|
|
205
367
|
},
|
|
206
|
-
listCaption: {
|
|
207
|
-
display: "flex",
|
|
208
|
-
justifyContent: "space-between",
|
|
209
|
-
gap: "4px 12px",
|
|
210
|
-
flexWrap: "wrap",
|
|
211
|
-
fontSize: 11.5,
|
|
212
|
-
color: TOKEN.muted,
|
|
213
|
-
marginTop: 2,
|
|
214
|
-
marginBottom: -7
|
|
215
|
-
},
|
|
216
368
|
list: {
|
|
217
369
|
display: "flex",
|
|
218
370
|
flexDirection: "column",
|
|
@@ -338,72 +490,20 @@ const S = {
|
|
|
338
490
|
minWidth: 0,
|
|
339
491
|
maxWidth: "100%"
|
|
340
492
|
},
|
|
341
|
-
glyphs: {
|
|
342
|
-
display: "flex",
|
|
343
|
-
alignItems: "center",
|
|
344
|
-
gap: 6,
|
|
345
|
-
flexWrap: "wrap",
|
|
346
|
-
minWidth: 0
|
|
347
|
-
},
|
|
348
493
|
glyph: chip,
|
|
349
|
-
metaValue: {
|
|
350
|
-
fontFamily: MONO,
|
|
351
|
-
fontVariantNumeric: "tabular-nums"
|
|
352
|
-
},
|
|
353
|
-
modeChip: {
|
|
354
|
-
...chip,
|
|
355
|
-
color: TOKEN.accent,
|
|
356
|
-
background: TOKEN.accentSoft
|
|
357
|
-
},
|
|
358
|
-
chip: {
|
|
359
|
-
...chip,
|
|
360
|
-
fontSize: 10.5
|
|
361
|
-
},
|
|
362
494
|
dirtyChip: {
|
|
363
495
|
...chip,
|
|
364
496
|
fontSize: 10.5,
|
|
365
497
|
color: TOKEN.warn,
|
|
366
498
|
background: TOKEN.warnSoft
|
|
367
499
|
},
|
|
368
|
-
draftActions: {
|
|
369
|
-
display: "flex",
|
|
370
|
-
alignItems: "center",
|
|
371
|
-
gap: 8,
|
|
372
|
-
flexWrap: "wrap",
|
|
373
|
-
padding: "9px 16px",
|
|
374
|
-
borderTop: `1px solid ${TOKEN.divider}`
|
|
375
|
-
},
|
|
376
|
-
addHead: {
|
|
377
|
-
display: "flex",
|
|
378
|
-
alignItems: "center",
|
|
379
|
-
flexWrap: "wrap",
|
|
380
|
-
gap: 12,
|
|
381
|
-
padding: "16px"
|
|
382
|
-
},
|
|
383
|
-
addIntro: {
|
|
384
|
-
display: "flex",
|
|
385
|
-
flex: "1 1 220px",
|
|
386
|
-
flexDirection: "column",
|
|
387
|
-
gap: 3,
|
|
388
|
-
minWidth: 0
|
|
389
|
-
},
|
|
390
500
|
body: {
|
|
391
501
|
display: "flex",
|
|
392
502
|
flexDirection: "column",
|
|
393
|
-
gap:
|
|
394
|
-
padding:
|
|
503
|
+
gap: 13,
|
|
504
|
+
padding: "12px 14px",
|
|
395
505
|
borderTop: `1px solid ${TOKEN.divider}`
|
|
396
506
|
},
|
|
397
|
-
group: {
|
|
398
|
-
display: "flex",
|
|
399
|
-
flexDirection: "column",
|
|
400
|
-
gap: 12
|
|
401
|
-
},
|
|
402
|
-
groupTitle: {
|
|
403
|
-
fontSize: 12.5,
|
|
404
|
-
fontWeight: 600,
|
|
405
|
-
color: TOKEN.primary
|
|
406
|
-
},
|
|
407
507
|
fieldLabel: {
|
|
408
508
|
fontSize: 12,
|
|
409
509
|
color: TOKEN.secondary,
|
|
@@ -507,7 +607,8 @@ const S = {
|
|
|
507
607
|
const BANNER = {
|
|
508
608
|
ok: {
|
|
509
609
|
...S.banner,
|
|
510
|
-
background: TOKEN.successSoft
|
|
610
|
+
background: TOKEN.successSoft,
|
|
611
|
+
color: TOKEN.success
|
|
511
612
|
},
|
|
512
613
|
error: {
|
|
513
614
|
...S.banner,
|
|
@@ -529,10 +630,56 @@ const SETTINGS_CSS = `
|
|
|
529
630
|
.dsh-library :is(button, input, textarea, select, summary):focus-visible {
|
|
530
631
|
outline: 2px solid ${TOKEN.accent}; outline-offset: 3px;
|
|
531
632
|
}
|
|
532
|
-
.dsh-library
|
|
633
|
+
.dsh-library .library-search:focus-within {
|
|
533
634
|
outline: 2px solid ${TOKEN.accent}; outline-offset: 2px;
|
|
534
635
|
}
|
|
535
|
-
.dsh-library input
|
|
636
|
+
.dsh-library .library-search input:focus-visible { outline: none; }
|
|
637
|
+
.dsh-library .library-panel { display: grid; gap: 14px; min-width: 0; }
|
|
638
|
+
.dsh-library .library-tabs { display: flex; gap: 18px; border-bottom: 1px solid ${TOKEN.border}; }
|
|
639
|
+
.dsh-library .library-tabs button {
|
|
640
|
+
padding: 6px 3px 8px; border: 0; border-bottom: 2px solid transparent;
|
|
641
|
+
background: transparent; color: ${TOKEN.secondary}; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
|
|
642
|
+
}
|
|
643
|
+
.dsh-library .library-tabs button[aria-selected=true] { color: ${TOKEN.accent}; border-color: currentColor; }
|
|
644
|
+
.dsh-library .library-editor { min-width: 0; border: 0; margin: 0; }
|
|
645
|
+
.dsh-library h3 { margin: 0; font-size: 13px; font-weight: 650; }
|
|
646
|
+
.dsh-library .library-editor textarea { min-height: 51px !important; }
|
|
647
|
+
.dsh-library .library-editor [data-field=assignment] { min-height: 35px !important; }
|
|
648
|
+
.dsh-library .library-editor input:read-only { background: ${TOKEN.inset} !important; }
|
|
649
|
+
.dsh-library .library-members-head {
|
|
650
|
+
display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
|
|
651
|
+
gap: 5px 10px; padding-top: 8px; border-top: 1px solid ${TOKEN.border};
|
|
652
|
+
}
|
|
653
|
+
.dsh-library .library-members { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
|
|
654
|
+
.dsh-library .library-members li {
|
|
655
|
+
display: grid; gap: 7px; min-width: 0; padding: 8px 10px 10px;
|
|
656
|
+
border: 1px solid ${TOKEN.border}; border-radius: 8px; background: var(--dsw-alias-bg-base, transparent);
|
|
657
|
+
}
|
|
658
|
+
.dsh-library .library-member-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 12px; }
|
|
659
|
+
.dsh-library .library-member-head button { min-height: 27px !important; padding: 2px 6px !important; }
|
|
660
|
+
.dsh-library .library-link {
|
|
661
|
+
border: 0 !important; padding: 0 !important; min-height: 0 !important; display: inline !important;
|
|
662
|
+
color: ${TOKEN.accent} !important; white-space: normal !important; text-align: left; text-decoration: underline; overflow-wrap: anywhere;
|
|
663
|
+
}
|
|
664
|
+
.dsh-library .library-field-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 8px; padding-top: 2px; }
|
|
665
|
+
.dsh-library .library-field-actions > button { min-height: 24px !important; }
|
|
666
|
+
.dsh-library .library-field-note { padding-top: 4px; }
|
|
667
|
+
.dsh-library .library-field-error { color: ${TOKEN.danger}; font-size: 11.5px; line-height: 1.65; overflow-wrap: anywhere; }
|
|
668
|
+
.dsh-library .library-field-error:not(:empty) { margin-top: 4px; }
|
|
669
|
+
.dsh-library [data-field=slot][aria-invalid=true] { border-color: ${TOKEN.danger} !important; }
|
|
670
|
+
.dsh-library [data-field=role-id] { user-select: text; }
|
|
671
|
+
.dsh-library .library-refs ul { padding-inline-start: 19px; margin: 4px 0; }
|
|
672
|
+
.dsh-library .library-dialog {
|
|
673
|
+
width: min(540px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 17px;
|
|
674
|
+
border: 1px solid ${TOKEN.borderStrong}; border-radius: 12px; background: var(--dsw-alias-bg-base, Canvas);
|
|
675
|
+
color: var(--dsw-alias-label-primary, CanvasText); box-shadow: 0 8px 30px #13182633; font: inherit; font-size: 13px;
|
|
676
|
+
}
|
|
677
|
+
.dsh-library .library-dialog::backdrop { background: #10152260; }
|
|
678
|
+
.dsh-library .library-compare { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin-top: 10px; }
|
|
679
|
+
.dsh-library .library-compare article { background: ${TOKEN.inset}; padding: 8px; border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
680
|
+
.dsh-library .library-compare dl { margin: 5px 0 0; }
|
|
681
|
+
.dsh-library .library-compare dt, .dsh-library .library-compare dd { display: inline; margin: 0; }
|
|
682
|
+
.dsh-library .library-compare dt { font-weight: 600; margin-inline-end: 5px; }
|
|
536
683
|
.dsh-library select option { background: ${TOKEN.surface}; color: ${TOKEN.primary}; }
|
|
537
684
|
.dsh-library-switch {
|
|
538
685
|
appearance: none; position: relative; display: inline-block; flex: none;
|
|
@@ -546,8 +693,8 @@ const SETTINGS_CSS = `
|
|
|
546
693
|
}
|
|
547
694
|
.dsh-library-switch:checked { background: ${TOKEN.accentFill}; border-color: transparent; }
|
|
548
695
|
.dsh-library-switch:checked::before { transform: translateX(12px); background: #fff; }
|
|
549
|
-
@container dsh-library (max-width:
|
|
550
|
-
.dsh-library-grid { grid-template-columns: minmax(0, 1fr) !important; }
|
|
696
|
+
@container dsh-library (max-width: 285px) {
|
|
697
|
+
.dsh-library .library-grid, .dsh-library .library-compare { grid-template-columns: minmax(0, 1fr) !important; }
|
|
551
698
|
}
|
|
552
699
|
@media (hover: hover) {
|
|
553
700
|
.dsh-library-card:hover { border-color: ${TOKEN.borderStrong}; }
|
|
@@ -564,1351 +711,1402 @@ const SETTINGS_CSS = `
|
|
|
564
711
|
`;
|
|
565
712
|
|
|
566
713
|
//#endregion
|
|
567
|
-
//#region src/client/
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
/** Content-adaptive textarea: grows with its text (clamped) so long personas
|
|
574
|
-
* are readable without dragging while short ones stay compact. Re-measures
|
|
575
|
-
* after every render (value changes re-render) and on input. */
|
|
576
|
-
function AutoTextarea(props) {
|
|
577
|
-
const { style,...rest } = props;
|
|
578
|
-
const ref = (0, react.useRef)(null);
|
|
579
|
-
const resize = () => {
|
|
580
|
-
const el = ref.current;
|
|
581
|
-
if (el === null) return;
|
|
582
|
-
el.style.height = "auto";
|
|
583
|
-
el.style.height = `${Math.min(Math.max(el.scrollHeight, 86), 440)}px`;
|
|
584
|
-
};
|
|
585
|
-
(0, react.useEffect)(() => {
|
|
586
|
-
resize();
|
|
587
|
-
});
|
|
588
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
589
|
-
...rest,
|
|
590
|
-
ref,
|
|
591
|
-
onInput: resize,
|
|
714
|
+
//#region src/client/editor-fields.tsx
|
|
715
|
+
function Action({ action, tone = "button", children,...props }) {
|
|
716
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
717
|
+
...props,
|
|
718
|
+
type: "button",
|
|
719
|
+
"data-action": action,
|
|
592
720
|
style: {
|
|
593
|
-
...
|
|
594
|
-
|
|
595
|
-
}
|
|
721
|
+
...S[tone],
|
|
722
|
+
...props.style
|
|
723
|
+
},
|
|
724
|
+
children
|
|
596
725
|
});
|
|
597
726
|
}
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
const
|
|
602
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
727
|
+
function Field({ label, name, value, change, multiline, hint, describedBy,...props }) {
|
|
728
|
+
const id = (0, react.useId)();
|
|
729
|
+
const hintId = hint ? `${id}-hint` : void 0;
|
|
730
|
+
const description = [describedBy, hintId].filter(Boolean).join(" ") || void 0;
|
|
731
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
603
732
|
style: S.field,
|
|
604
733
|
children: [
|
|
605
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
734
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
735
|
+
htmlFor: id,
|
|
606
736
|
style: S.fieldLabel,
|
|
607
737
|
children: label
|
|
608
738
|
}),
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
739
|
+
multiline ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
740
|
+
id,
|
|
741
|
+
"aria-describedby": description,
|
|
742
|
+
"data-field": name,
|
|
743
|
+
value,
|
|
744
|
+
rows: name === "assignment" ? 1 : 2,
|
|
745
|
+
placeholder: props.placeholder,
|
|
746
|
+
onChange: (e) => change?.(e.target.value),
|
|
747
|
+
style: S.prose
|
|
748
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
749
|
+
...props,
|
|
750
|
+
id,
|
|
751
|
+
"aria-describedby": description,
|
|
752
|
+
"data-field": name,
|
|
753
|
+
type: props.min === void 0 ? "text" : "number",
|
|
754
|
+
value,
|
|
755
|
+
onChange: (e) => change?.(e.target.value),
|
|
756
|
+
style: S.input
|
|
757
|
+
}),
|
|
758
|
+
hint && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
759
|
+
id: hintId,
|
|
760
|
+
className: "library-field-note",
|
|
761
|
+
style: S.hint,
|
|
615
762
|
children: hint
|
|
616
763
|
})
|
|
617
764
|
]
|
|
618
765
|
});
|
|
619
766
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
strokeLinejoin: "round",
|
|
636
|
-
"aria-hidden": "true",
|
|
637
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M4.5 2.5L8 6l-3.5 3.5" })
|
|
638
|
-
})
|
|
767
|
+
function References({ refs, view, jump, title }) {
|
|
768
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
769
|
+
className: "library-refs",
|
|
770
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: title }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", { children: refs.map((ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Action, {
|
|
771
|
+
action: "jump",
|
|
772
|
+
"data-group": ref.groupId,
|
|
773
|
+
"data-slot-id": ref.slot,
|
|
774
|
+
className: "library-link",
|
|
775
|
+
onClick: () => jump(ref),
|
|
776
|
+
children: [
|
|
777
|
+
own(view.groups, ref.groupId)?.name || ref.groupId,
|
|
778
|
+
" / ",
|
|
779
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: ref.slot })
|
|
780
|
+
]
|
|
781
|
+
}) }, ref.groupId + "/" + ref.slot)) })]
|
|
639
782
|
});
|
|
640
783
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
784
|
+
function availability(role) {
|
|
785
|
+
if (!role) return "角色缺失";
|
|
786
|
+
if (role.enabled === false) return "角色已停用";
|
|
787
|
+
if (role.toolFilter) return "旧工具限制";
|
|
788
|
+
if (role.launchable === false) {
|
|
789
|
+
if (role.routeNote === "profile-missing") return "当前 Provider 未注册";
|
|
790
|
+
if (role.routeNote === "overlay-broken") return "当前路由无法读取";
|
|
791
|
+
if (role.maxDepth === 0 || role.reason?.startsWith("maxDepth is 0")) return "深度上限为 0";
|
|
792
|
+
if (role.reason?.includes("native named activations")) return "宿主缺少原生具名派遣支持";
|
|
793
|
+
if (role.reason?.startsWith("subagent transport provider")) return "传输层未注册";
|
|
794
|
+
if (role.reason?.startsWith("Transport ")) return "传输层无法执行当前配置";
|
|
795
|
+
return "暂时无法派遣";
|
|
796
|
+
}
|
|
797
|
+
return "";
|
|
648
798
|
}
|
|
649
|
-
function
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
const
|
|
653
|
-
|
|
654
|
-
const
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
799
|
+
function memberState(view, form, member) {
|
|
800
|
+
if (!form.enabled) return "编队已停用";
|
|
801
|
+
if (!member.role) return "";
|
|
802
|
+
const reason = availability(own(view.entries, member.role));
|
|
803
|
+
if (reason) return reason;
|
|
804
|
+
const saved = own(view.groups, form.id);
|
|
805
|
+
if (saved && saved.enabled !== false && saved.members.some((m) => m.slot === member.slot && m.role === member.role && m.launchable === false)) return "暂时无法派遣";
|
|
806
|
+
return "";
|
|
807
|
+
}
|
|
808
|
+
const notes = {
|
|
809
|
+
"profile": "使用当前 profile 的独立路由。",
|
|
810
|
+
"inherit": "当前 profile 已设置为跟随会话。",
|
|
811
|
+
"foreign-ignored": "共享 Provider 未在此 profile 注册,当前跟随会话。",
|
|
812
|
+
"profile-missing": "当前 profile 的 Provider 尚未注册,可更换 Provider 或使用会话模型。",
|
|
813
|
+
"overlay-broken": "当前 profile 的路由无法读取,可重新设置或使用会话模型。"
|
|
814
|
+
};
|
|
815
|
+
function RoleFields({ form, isNew, change, view, refs, jump }) {
|
|
816
|
+
const patch = (values) => change({
|
|
817
|
+
...form,
|
|
818
|
+
...values
|
|
819
|
+
});
|
|
820
|
+
const route = (field, value) => patch({
|
|
821
|
+
[field]: value,
|
|
822
|
+
inherit: false
|
|
823
|
+
});
|
|
824
|
+
const saved = own(view.entries, form.id);
|
|
825
|
+
const routeReadOnly = !!view.routeWriteProblem;
|
|
826
|
+
const hasRoute = [
|
|
827
|
+
form.provider,
|
|
828
|
+
form.model,
|
|
829
|
+
form.reasoningEffort,
|
|
830
|
+
form.maxTokens
|
|
831
|
+
].some((value) => value.trim());
|
|
832
|
+
const clearRoute = (inherit) => patch({
|
|
833
|
+
inherit,
|
|
659
834
|
provider: "",
|
|
660
835
|
model: "",
|
|
661
|
-
|
|
836
|
+
reasoningEffort: "",
|
|
837
|
+
maxTokens: ""
|
|
838
|
+
});
|
|
839
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
840
|
+
saved?.launchable === false && saved.enabled !== false && !saved.toolFilter && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
841
|
+
style: BANNER.warn,
|
|
842
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: availability(saved) }), saved.reason && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: saved.reason })]
|
|
843
|
+
}),
|
|
844
|
+
isNew && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
845
|
+
name: "id",
|
|
846
|
+
label: "角色 ID",
|
|
847
|
+
value: form.id,
|
|
848
|
+
change: (id) => patch({ id }),
|
|
849
|
+
placeholder: "reviewer"
|
|
850
|
+
}),
|
|
851
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
852
|
+
name: "description",
|
|
853
|
+
label: "角色描述",
|
|
854
|
+
multiline: true,
|
|
855
|
+
value: form.description,
|
|
856
|
+
change: (description) => patch({ description })
|
|
857
|
+
}),
|
|
858
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h3", { children: [view.profile || routeReadOnly ? "模型路由" : "共享模型路由", view.profile && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
859
|
+
style: S.hint,
|
|
860
|
+
children: [" · ", view.profile]
|
|
861
|
+
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
862
|
+
style: S.hint,
|
|
863
|
+
children: view.routeWriteProblem ?? (view.profile ? form.routeNote ? notes[form.routeNote] : "模型与思考档位只应用于当前 profile。" : "这里编辑角色的共享默认路由。全部留空后保存,共享默认将跟随会话。共享路由变更后,绑定旧默认路由的 profile 需重新设置。")
|
|
864
|
+
})] }),
|
|
865
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
866
|
+
className: "library-grid",
|
|
867
|
+
style: S.grid,
|
|
868
|
+
children: [
|
|
869
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
870
|
+
name: "provider",
|
|
871
|
+
label: "Provider",
|
|
872
|
+
value: form.provider,
|
|
873
|
+
change: (v) => route("provider", v),
|
|
874
|
+
readOnly: routeReadOnly,
|
|
875
|
+
placeholder: "跟随会话"
|
|
876
|
+
}),
|
|
877
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
878
|
+
name: "model",
|
|
879
|
+
label: "模型",
|
|
880
|
+
value: form.model,
|
|
881
|
+
change: (v) => route("model", v),
|
|
882
|
+
readOnly: routeReadOnly,
|
|
883
|
+
placeholder: "跟随会话"
|
|
884
|
+
}),
|
|
885
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
886
|
+
name: "reasoningEffort",
|
|
887
|
+
label: "思考档位",
|
|
888
|
+
value: form.reasoningEffort,
|
|
889
|
+
change: (v) => route("reasoningEffort", v),
|
|
890
|
+
readOnly: routeReadOnly,
|
|
891
|
+
placeholder: "例如 high"
|
|
892
|
+
}),
|
|
893
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
894
|
+
name: "maxTokens",
|
|
895
|
+
label: "输出上限",
|
|
896
|
+
value: form.maxTokens,
|
|
897
|
+
change: (v) => route("maxTokens", v),
|
|
898
|
+
readOnly: routeReadOnly,
|
|
899
|
+
min: 1,
|
|
900
|
+
placeholder: "tokens"
|
|
901
|
+
})
|
|
902
|
+
]
|
|
903
|
+
}),
|
|
904
|
+
!routeReadOnly && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: view.profile ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
|
|
905
|
+
action: "inherit",
|
|
906
|
+
disabled: form.inherit || form.routeNote === "inherit" && !hasRoute,
|
|
907
|
+
onClick: () => clearRoute(true),
|
|
908
|
+
children: form.inherit ? "保存后使用会话模型" : "使用会话模型"
|
|
909
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
|
|
910
|
+
action: "clear-shared-route",
|
|
911
|
+
disabled: !hasRoute,
|
|
912
|
+
onClick: () => clearRoute(false),
|
|
913
|
+
children: "清空共享路由"
|
|
914
|
+
}) }),
|
|
915
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
916
|
+
className: "library-grid",
|
|
917
|
+
style: S.grid,
|
|
918
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
919
|
+
name: "subagentProvider",
|
|
920
|
+
label: "传输层",
|
|
921
|
+
value: form.subagentProvider,
|
|
922
|
+
change: (subagentProvider) => patch({ subagentProvider }),
|
|
923
|
+
placeholder: "spawn(默认)"
|
|
924
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
925
|
+
name: "maxDepth",
|
|
926
|
+
label: "深度上限",
|
|
927
|
+
value: form.maxDepth,
|
|
928
|
+
change: (maxDepth) => patch({ maxDepth }),
|
|
929
|
+
min: 0,
|
|
930
|
+
placeholder: "跟随宿主",
|
|
931
|
+
hint: "留空时跟随宿主。填写后使用宿主与角色上限中较低的值,填 0 禁止派遣。"
|
|
932
|
+
})]
|
|
933
|
+
}),
|
|
934
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
935
|
+
name: "persona",
|
|
936
|
+
label: "角色人设",
|
|
937
|
+
multiline: true,
|
|
938
|
+
value: form.persona,
|
|
939
|
+
change: (persona) => patch({ persona })
|
|
940
|
+
}),
|
|
941
|
+
form.filter && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
942
|
+
style: BANNER.warn,
|
|
943
|
+
children: [
|
|
944
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: "旧工具限制" }),
|
|
945
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "这个角色的工具限制无法在当前宿主执行。解除限制后可按宿主的权限派遣。" }),
|
|
946
|
+
form.filter.allow && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: ["允许:", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: form.filter.allow.join(", ") || "空列表" })] }),
|
|
947
|
+
form.filter.deny && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: ["禁用:", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: form.filter.deny.join(", ") || "空列表" })] }),
|
|
948
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
949
|
+
type: "checkbox",
|
|
950
|
+
"data-field": "clearToolFilter",
|
|
951
|
+
checked: form.clearToolFilter,
|
|
952
|
+
onChange: (e) => patch({ clearToolFilter: e.target.checked })
|
|
953
|
+
}), " 保存时解除旧工具限制"] })
|
|
954
|
+
]
|
|
955
|
+
}),
|
|
956
|
+
refs.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
957
|
+
style: form.enabled ? BANNER.info : BANNER.warn,
|
|
958
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(References, {
|
|
959
|
+
refs,
|
|
960
|
+
view,
|
|
961
|
+
jump,
|
|
962
|
+
title: form.enabled ? "使用此角色的编队成员" : "停用角色后,以下成员将无法派遣"
|
|
963
|
+
})
|
|
964
|
+
})
|
|
965
|
+
] });
|
|
966
|
+
}
|
|
967
|
+
function copySelection(id, doc) {
|
|
968
|
+
const focused = doc.activeElement;
|
|
969
|
+
const input = doc.createElement("textarea");
|
|
970
|
+
input.value = id;
|
|
971
|
+
input.readOnly = true;
|
|
972
|
+
Object.assign(input.style, {
|
|
973
|
+
position: "fixed",
|
|
974
|
+
inset: "0 auto auto 0",
|
|
975
|
+
opacity: "0",
|
|
976
|
+
pointerEvents: "none"
|
|
662
977
|
});
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
978
|
+
doc.body.append(input);
|
|
979
|
+
try {
|
|
980
|
+
input.focus({ preventScroll: true });
|
|
981
|
+
input.select();
|
|
982
|
+
return doc.execCommand("copy");
|
|
983
|
+
} catch {
|
|
984
|
+
return false;
|
|
985
|
+
} finally {
|
|
986
|
+
input.remove();
|
|
987
|
+
focused?.focus({ preventScroll: true });
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
function RoleIdCopy({ id }) {
|
|
991
|
+
const [status, setStatus] = (0, react.useState)();
|
|
992
|
+
const manualInput = (0, react.useRef)(null);
|
|
993
|
+
const trigger = (0, react.useRef)();
|
|
994
|
+
const selectId = (0, react.useCallback)((input) => {
|
|
995
|
+
manualInput.current = input;
|
|
996
|
+
if (trigger.current?.matches(":focus")) {
|
|
997
|
+
input?.focus({ preventScroll: true });
|
|
998
|
+
input?.select();
|
|
999
|
+
}
|
|
672
1000
|
}, []);
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
const pendingSelfWrite = (0, react.useRef)(false);
|
|
677
|
-
const skippedWhilePending = (0, react.useRef)(false);
|
|
678
|
-
const load = () => {
|
|
679
|
-
(async () => {
|
|
680
|
-
try {
|
|
681
|
-
const next = await readView$1();
|
|
682
|
-
if (!alive.current) return;
|
|
683
|
-
setView(next);
|
|
684
|
-
setEntries(structuredClone(next.entries));
|
|
685
|
-
} catch (error) {
|
|
686
|
-
if (alive.current) setStatus({
|
|
687
|
-
kind: "error",
|
|
688
|
-
text: String(error)
|
|
689
|
-
});
|
|
690
|
-
}
|
|
691
|
-
})();
|
|
692
|
-
};
|
|
693
|
-
(0, react.useEffect)(() => {
|
|
694
|
-
load();
|
|
695
|
-
return subscribeRefresh(() => {
|
|
696
|
-
if (pendingSelfWrite.current) {
|
|
697
|
-
skippedWhilePending.current = true;
|
|
698
|
-
return;
|
|
699
|
-
}
|
|
700
|
-
load();
|
|
701
|
-
});
|
|
702
|
-
}, [subscribeRefresh]);
|
|
703
|
-
const applyWrite = async (write, touchedId) => {
|
|
704
|
-
if (busyRef.current) return false;
|
|
705
|
-
busyRef.current = true;
|
|
706
|
-
setBusy(true);
|
|
707
|
-
setStatus(null);
|
|
708
|
-
pendingSelfWrite.current = true;
|
|
1001
|
+
async function copy(event) {
|
|
1002
|
+
const button$1 = event.currentTarget;
|
|
1003
|
+
trigger.current = button$1;
|
|
709
1004
|
try {
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
pendingSelfWrite.current = false;
|
|
713
|
-
const skipped = skippedWhilePending.current;
|
|
714
|
-
skippedWhilePending.current = false;
|
|
715
|
-
if (result.ok) {
|
|
716
|
-
setView(result.view);
|
|
717
|
-
setEntries((current) => {
|
|
718
|
-
const next = { ...current };
|
|
719
|
-
const fresh = result.view.entries[touchedId];
|
|
720
|
-
if (fresh !== void 0) next[touchedId] = structuredClone(fresh);
|
|
721
|
-
else delete next[touchedId];
|
|
722
|
-
return next;
|
|
723
|
-
});
|
|
724
|
-
setStatus({
|
|
725
|
-
kind: "ok",
|
|
726
|
-
text: "已保存"
|
|
727
|
-
});
|
|
728
|
-
if (skipped) load();
|
|
729
|
-
return true;
|
|
730
|
-
}
|
|
731
|
-
skippedWhilePending.current = false;
|
|
732
|
-
if (result.conflict) {
|
|
733
|
-
if (result.view !== void 0) setView(result.view);
|
|
734
|
-
else load();
|
|
735
|
-
setStatus({
|
|
736
|
-
kind: "error",
|
|
737
|
-
text: "名册已被其他窗口或外部修改(已切换到最新基线)。你的未保存修改已保留;再次保存将以你的版本覆盖。"
|
|
738
|
-
});
|
|
739
|
-
} else {
|
|
740
|
-
if (skipped) load();
|
|
741
|
-
setStatus({
|
|
742
|
-
kind: "error",
|
|
743
|
-
text: result.message ?? "保存失败"
|
|
744
|
-
});
|
|
745
|
-
}
|
|
746
|
-
return false;
|
|
747
|
-
} finally {
|
|
748
|
-
pendingSelfWrite.current = false;
|
|
749
|
-
busyRef.current = false;
|
|
750
|
-
if (alive.current) setBusy(false);
|
|
751
|
-
}
|
|
752
|
-
};
|
|
753
|
-
/** Normalize one entry for persistence: empty optional fields are dropped
|
|
754
|
-
* (they then fall back to their defaults instead of being stored as '' or
|
|
755
|
-
* stale values), and toolFilter survives only while it still scopes
|
|
756
|
-
* something — an allow list alone must NOT be deleted by an editor that
|
|
757
|
-
* only shows deny. */
|
|
758
|
-
const cleanEntry = (entry) => {
|
|
759
|
-
const clean = { ...entry };
|
|
760
|
-
delete clean.source;
|
|
761
|
-
delete clean.routeNote;
|
|
762
|
-
if (clean.enabled === void 0 || clean.enabled) delete clean.enabled;
|
|
763
|
-
if (clean.provider === "") delete clean.provider;
|
|
764
|
-
if (clean.model === "") delete clean.model;
|
|
765
|
-
if (clean.subagentProvider === "") delete clean.subagentProvider;
|
|
766
|
-
if (clean.reasoningEffort === "") delete clean.reasoningEffort;
|
|
767
|
-
if (clean.persona === "") delete clean.persona;
|
|
768
|
-
if (clean.description === "") delete clean.description;
|
|
769
|
-
if (clean.maxDepth === void 0) delete clean.maxDepth;
|
|
770
|
-
if (clean.maxTokens === void 0) delete clean.maxTokens;
|
|
771
|
-
const filter$1 = clean.toolFilter;
|
|
772
|
-
if (filter$1 !== void 0 && (filter$1.allow === void 0 || filter$1.allow.length === 0) && (filter$1.deny === void 0 || filter$1.deny.length === 0)) delete clean.toolFilter;
|
|
773
|
-
return clean;
|
|
774
|
-
};
|
|
775
|
-
const updateEntry = (id, entry) => {
|
|
776
|
-
if ((entry.description ?? "").trim() === "") {
|
|
777
|
-
setStatus({
|
|
778
|
-
kind: "error",
|
|
779
|
-
text: "描述不能为空。"
|
|
780
|
-
});
|
|
781
|
-
setOpen((current) => ({
|
|
782
|
-
...current,
|
|
783
|
-
[id]: true
|
|
784
|
-
}));
|
|
785
|
-
return;
|
|
786
|
-
}
|
|
787
|
-
if (entry.maxDepth !== void 0 && (!Number.isInteger(entry.maxDepth) || entry.maxDepth < 1)) {
|
|
788
|
-
setStatus({
|
|
789
|
-
kind: "error",
|
|
790
|
-
text: "深度上限需为 ≥1 的整数。"
|
|
791
|
-
});
|
|
792
|
-
setOpen((current) => ({
|
|
793
|
-
...current,
|
|
794
|
-
[id]: true
|
|
795
|
-
}));
|
|
796
|
-
return;
|
|
797
|
-
}
|
|
798
|
-
if (entry.maxTokens !== void 0 && (!Number.isInteger(entry.maxTokens) || entry.maxTokens < 1)) {
|
|
799
|
-
setStatus({
|
|
800
|
-
kind: "error",
|
|
801
|
-
text: "输出上限需为 ≥1 的整数。"
|
|
802
|
-
});
|
|
803
|
-
setOpen((current) => ({
|
|
804
|
-
...current,
|
|
805
|
-
[id]: true
|
|
806
|
-
}));
|
|
807
|
-
return;
|
|
808
|
-
}
|
|
809
|
-
applyWrite({
|
|
810
|
-
op: "save",
|
|
811
|
-
entries: {
|
|
812
|
-
...view?.entries ?? {},
|
|
813
|
-
[id]: cleanEntry(entry)
|
|
814
|
-
},
|
|
815
|
-
expectedHash: view?.hash
|
|
816
|
-
}, id);
|
|
817
|
-
};
|
|
818
|
-
const removeEntry = (id) => {
|
|
819
|
-
if (!window.confirm(`确认删除子代理 "${id}"?该操作立即删除其名册文件。`)) return;
|
|
820
|
-
applyWrite({
|
|
821
|
-
op: "delete",
|
|
822
|
-
id,
|
|
823
|
-
expectedHash: view?.hash
|
|
824
|
-
}, id);
|
|
825
|
-
};
|
|
826
|
-
const addEntry = () => {
|
|
827
|
-
const id = newId.trim();
|
|
828
|
-
if (!/^[a-z0-9][a-z0-9-]*$/.test(id) || (newEntry.description ?? "").trim() === "") {
|
|
829
|
-
setStatus({
|
|
830
|
-
kind: "error",
|
|
831
|
-
text: "ID 需为小写字母/数字/连字符,且必须有描述。"
|
|
832
|
-
});
|
|
1005
|
+
await navigator.clipboard.writeText(id);
|
|
1006
|
+
setStatus("copied");
|
|
833
1007
|
return;
|
|
1008
|
+
} catch {
|
|
1009
|
+
if (!button$1.isConnected) return;
|
|
834
1010
|
}
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
setStatus({
|
|
838
|
-
kind: "error",
|
|
839
|
-
text: `ID "${id}" 已存在。`
|
|
840
|
-
});
|
|
841
|
-
return;
|
|
842
|
-
}
|
|
843
|
-
if (newEntry.maxTokens !== void 0 && (!Number.isInteger(newEntry.maxTokens) || newEntry.maxTokens < 1)) {
|
|
844
|
-
setStatus({
|
|
845
|
-
kind: "error",
|
|
846
|
-
text: "输出上限需为 ≥1 的整数。"
|
|
847
|
-
});
|
|
1011
|
+
if (copySelection(id, button$1.ownerDocument)) {
|
|
1012
|
+
setStatus("copied");
|
|
848
1013
|
return;
|
|
849
1014
|
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
const
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
...changes
|
|
888
|
-
}
|
|
889
|
-
}));
|
|
890
|
-
};
|
|
891
|
-
const revertEntry = (id) => {
|
|
892
|
-
const saved = view?.entries[id];
|
|
893
|
-
if (saved !== void 0) setEntries((current) => ({
|
|
894
|
-
...current,
|
|
895
|
-
[id]: structuredClone(saved)
|
|
896
|
-
}));
|
|
897
|
-
};
|
|
898
|
-
const setDeny = (id, text) => {
|
|
899
|
-
const deny = parseList(text);
|
|
900
|
-
const allow = entries[id]?.toolFilter?.allow;
|
|
901
|
-
const keepAllow = allow !== void 0 && allow.length > 0;
|
|
902
|
-
patch(id, { toolFilter: keepAllow || deny.length > 0 ? {
|
|
903
|
-
...keepAllow ? { allow } : {},
|
|
904
|
-
...deny.length > 0 ? { deny } : {}
|
|
905
|
-
} : void 0 });
|
|
906
|
-
};
|
|
907
|
-
const ids = (0, react.useMemo)(() => Object.keys(entries), [entries]);
|
|
908
|
-
const stats = (0, react.useMemo)(() => {
|
|
909
|
-
let off = 0;
|
|
910
|
-
let legacy = 0;
|
|
911
|
-
for (const id of ids) {
|
|
912
|
-
const entry = entries[id];
|
|
913
|
-
if (entry.enabled === false) off += 1;
|
|
914
|
-
if (entry.source === "legacy") legacy += 1;
|
|
915
|
-
}
|
|
916
|
-
return {
|
|
917
|
-
total: ids.length,
|
|
918
|
-
off,
|
|
919
|
-
legacy
|
|
920
|
-
};
|
|
921
|
-
}, [ids, entries]);
|
|
922
|
-
/** Disabled rows sink to the bottom (they are not what you came to look at),
|
|
923
|
-
* then plain alphabetical. */
|
|
924
|
-
const orderedIds = (0, react.useMemo)(() => [...ids].sort((a, b) => {
|
|
925
|
-
const offA = entries[a].enabled === false ? 1 : 0;
|
|
926
|
-
const offB = entries[b].enabled === false ? 1 : 0;
|
|
927
|
-
if (offA !== offB) return offA - offB;
|
|
928
|
-
return a.localeCompare(b);
|
|
929
|
-
}), [ids, entries]);
|
|
930
|
-
const needle = filter.trim().toLowerCase();
|
|
931
|
-
const visibleIds = (0, react.useMemo)(() => {
|
|
932
|
-
if (needle === "") return orderedIds;
|
|
933
|
-
return orderedIds.filter((id) => {
|
|
934
|
-
const entry = entries[id];
|
|
935
|
-
return [
|
|
936
|
-
id,
|
|
937
|
-
entry.description,
|
|
938
|
-
entry.model,
|
|
939
|
-
entry.provider,
|
|
940
|
-
entry.reasoningEffort,
|
|
941
|
-
entry.persona
|
|
942
|
-
].filter((value) => typeof value === "string").join("\n").toLowerCase().includes(needle);
|
|
943
|
-
});
|
|
944
|
-
}, [
|
|
945
|
-
orderedIds,
|
|
946
|
-
entries,
|
|
947
|
-
needle
|
|
948
|
-
]);
|
|
949
|
-
const dirtyIds = (0, react.useMemo)(() => {
|
|
950
|
-
const set = /* @__PURE__ */ new Set();
|
|
951
|
-
for (const id of ids) if (!sameEntry(entries[id], view?.entries[id])) set.add(id);
|
|
952
|
-
return set;
|
|
953
|
-
}, [
|
|
954
|
-
ids,
|
|
955
|
-
entries,
|
|
956
|
-
view
|
|
957
|
-
]);
|
|
958
|
-
const openCount = visibleIds.filter((id) => open[id] === true).length;
|
|
959
|
-
const allOpen = visibleIds.length > 0 && openCount === visibleIds.length;
|
|
960
|
-
const toggleAll = () => {
|
|
961
|
-
setOpen((current) => {
|
|
962
|
-
const next = { ...current };
|
|
963
|
-
for (const id of visibleIds) next[id] = !allOpen;
|
|
964
|
-
return next;
|
|
965
|
-
});
|
|
966
|
-
};
|
|
967
|
-
if (view === null) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
968
|
-
className: "dsh-library",
|
|
969
|
-
style: S.root,
|
|
970
|
-
children: [
|
|
971
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: SETTINGS_CSS }),
|
|
972
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
973
|
-
style: S.headingRow,
|
|
974
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
975
|
-
style: S.heading,
|
|
976
|
-
children: "子代理库"
|
|
977
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
978
|
-
type: "button",
|
|
979
|
-
onClick: load,
|
|
980
|
-
style: S.button,
|
|
981
|
-
children: "重试"
|
|
982
|
-
})]
|
|
983
|
-
}),
|
|
984
|
-
status !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
985
|
-
style: status.kind === "ok" ? BANNER.ok : BANNER.error,
|
|
986
|
-
children: status.text
|
|
987
|
-
}),
|
|
988
|
-
status === null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
989
|
-
style: S.sub,
|
|
990
|
-
children: "正在加载…(若长时间无响应,请重试或检查插件是否加载)"
|
|
991
|
-
})
|
|
992
|
-
]
|
|
1015
|
+
setStatus("manual");
|
|
1016
|
+
selectId(manualInput.current);
|
|
1017
|
+
}
|
|
1018
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1019
|
+
className: "library-field-actions",
|
|
1020
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
|
|
1021
|
+
action: "copy-role-id",
|
|
1022
|
+
className: "library-link",
|
|
1023
|
+
"aria-label": "复制角色 ID",
|
|
1024
|
+
onClick: copy,
|
|
1025
|
+
children: "复制 ID"
|
|
1026
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1027
|
+
style: S.hint,
|
|
1028
|
+
role: "status",
|
|
1029
|
+
children: status === "copied" ? "已复制" : status === "manual" ? "请手动复制下方 ID" : ""
|
|
1030
|
+
})]
|
|
1031
|
+
}), status === "manual" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1032
|
+
ref: selectId,
|
|
1033
|
+
"data-field": "role-id",
|
|
1034
|
+
"aria-label": "角色 ID",
|
|
1035
|
+
style: S.input,
|
|
1036
|
+
value: id,
|
|
1037
|
+
readOnly: true,
|
|
1038
|
+
onFocus: (event) => event.currentTarget.select()
|
|
1039
|
+
})] });
|
|
1040
|
+
}
|
|
1041
|
+
function GroupFields({ form, isNew, change, view, message }) {
|
|
1042
|
+
const id = (0, react.useId)();
|
|
1043
|
+
const rulesId = `${id}-slot-rules`;
|
|
1044
|
+
const list = (0, react.useRef)(null);
|
|
1045
|
+
const addButton = (0, react.useRef)(null);
|
|
1046
|
+
const slots = form.members.map((member) => member.slot);
|
|
1047
|
+
const slotErrors = memberCodeErrors(slots);
|
|
1048
|
+
const usedSlots = new Set(slots.map((slot) => slot.trim()));
|
|
1049
|
+
const patch = (values) => change({
|
|
1050
|
+
...form,
|
|
1051
|
+
...values
|
|
993
1052
|
});
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
children: "刷新"
|
|
1015
|
-
})
|
|
1016
|
-
]
|
|
1017
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1018
|
-
style: S.sub,
|
|
1019
|
-
children: "集中管理角色、模型与执行方式。展开条目编辑,保存后即刻生效。"
|
|
1020
|
-
})]
|
|
1021
|
-
}),
|
|
1022
|
-
(view.diagnostics?.length ?? 0) > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1023
|
-
style: BANNER.warn,
|
|
1024
|
-
children: view.diagnostics.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1025
|
-
style: {
|
|
1026
|
-
fontWeight: item.severity === "error" ? 600 : 400,
|
|
1027
|
-
opacity: item.severity === "info" ? .78 : 1
|
|
1028
|
-
},
|
|
1029
|
-
children: [
|
|
1030
|
-
item.severity === "error" ? "错误" : item.severity === "warning" ? "警告" : "提示",
|
|
1031
|
-
item.id !== void 0 ? ` [${item.id}]` : "",
|
|
1032
|
-
":",
|
|
1033
|
-
item.message
|
|
1034
|
-
]
|
|
1035
|
-
}, index))
|
|
1036
|
-
}),
|
|
1037
|
-
view.profile !== void 0 && view.profile !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1038
|
-
style: BANNER.info,
|
|
1053
|
+
const patchMember = (i, values) => patch({ members: form.members.map((member, index) => index === i ? {
|
|
1054
|
+
...member,
|
|
1055
|
+
...values
|
|
1056
|
+
} : member) });
|
|
1057
|
+
const focus = (i) => requestAnimationFrame(() => {
|
|
1058
|
+
(list.current?.children[i]?.querySelector("[data-field=\"slot\"]") ?? addButton.current?.querySelector("button"))?.focus();
|
|
1059
|
+
});
|
|
1060
|
+
function move(i, to) {
|
|
1061
|
+
const members = [...form.members];
|
|
1062
|
+
const [member] = members.splice(i, 1);
|
|
1063
|
+
members.splice(to, 0, member);
|
|
1064
|
+
patch({ members });
|
|
1065
|
+
focus(to);
|
|
1066
|
+
}
|
|
1067
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1068
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1069
|
+
style: BANNER.warn,
|
|
1070
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1071
|
+
id: rulesId,
|
|
1072
|
+
"data-slot-rules": true,
|
|
1039
1073
|
children: [
|
|
1040
|
-
"
|
|
1041
|
-
|
|
1042
|
-
|
|
1074
|
+
isNew ? "编队 ID 和成员代号" : "成员代号",
|
|
1075
|
+
"请用小写字母、数字或短横线,最多 ",
|
|
1076
|
+
MAX_ID_LENGTH,
|
|
1077
|
+
" 个字符。中间不能有空格,开头不能用短横线。组内代号不能重复。"
|
|
1043
1078
|
]
|
|
1044
|
-
}),
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
})
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1079
|
+
}), message && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
|
|
1080
|
+
role: "alert",
|
|
1081
|
+
children: message
|
|
1082
|
+
})]
|
|
1083
|
+
}),
|
|
1084
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1085
|
+
className: "library-grid",
|
|
1086
|
+
style: S.grid,
|
|
1087
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1088
|
+
name: "name",
|
|
1089
|
+
label: "编队名称",
|
|
1090
|
+
value: form.name,
|
|
1091
|
+
change: (name) => patch({ name }),
|
|
1092
|
+
placeholder: "留空时使用编队 ID"
|
|
1093
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1094
|
+
name: "id",
|
|
1095
|
+
label: "编队 ID",
|
|
1096
|
+
value: form.id,
|
|
1097
|
+
change: (id$1) => patch({ id: id$1 }),
|
|
1098
|
+
describedBy: isNew ? rulesId : void 0,
|
|
1099
|
+
readOnly: !isNew,
|
|
1100
|
+
placeholder: "change-review"
|
|
1101
|
+
})]
|
|
1102
|
+
}),
|
|
1103
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1104
|
+
name: "description",
|
|
1105
|
+
label: "编队描述",
|
|
1106
|
+
multiline: true,
|
|
1107
|
+
value: form.description,
|
|
1108
|
+
change: (description) => patch({ description })
|
|
1109
|
+
}),
|
|
1110
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1111
|
+
name: "instructions",
|
|
1112
|
+
label: "共享说明",
|
|
1113
|
+
multiline: true,
|
|
1114
|
+
value: form.instructions,
|
|
1115
|
+
change: (instructions) => patch({ instructions })
|
|
1116
|
+
}),
|
|
1117
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1118
|
+
className: "library-members-head",
|
|
1119
|
+
ref: addButton,
|
|
1120
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: "编队成员" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
|
|
1121
|
+
action: "add-slot",
|
|
1122
|
+
onClick: () => {
|
|
1123
|
+
patch({ members: [...form.members, emptyMember()] });
|
|
1124
|
+
focus(form.members.length);
|
|
1125
|
+
},
|
|
1126
|
+
children: "+ 添加成员"
|
|
1127
|
+
})]
|
|
1128
|
+
}),
|
|
1129
|
+
!form.members.length && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1130
|
+
style: S.empty,
|
|
1131
|
+
children: "添加至少一名成员。"
|
|
1132
|
+
}),
|
|
1133
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("ol", {
|
|
1134
|
+
className: "library-members",
|
|
1135
|
+
ref: list,
|
|
1136
|
+
children: form.members.map((member, i) => {
|
|
1137
|
+
const role = own(view.entries, member.role);
|
|
1138
|
+
const state = memberState(view, form, member);
|
|
1139
|
+
const slotId = `${id}-slot-${i}`;
|
|
1140
|
+
const error = (member.slot || member.role) && slotErrors[i];
|
|
1141
|
+
const errorId = `${slotId}-error`;
|
|
1142
|
+
const canUseRoleId = role && !member.slot.trim() && !entryIdIssue(member.role);
|
|
1143
|
+
const roleIdUsed = canUseRoleId && usedSlots.has(member.role);
|
|
1144
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
1145
|
+
"data-slot": i,
|
|
1146
|
+
"data-slot-key": member.slot,
|
|
1071
1147
|
children: [
|
|
1072
1148
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1073
|
-
|
|
1074
|
-
children: [
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1149
|
+
className: "library-member-head",
|
|
1150
|
+
children: [
|
|
1151
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("strong", { children: ["成员 ", i + 1] }),
|
|
1152
|
+
state && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1153
|
+
style: S.dirtyChip,
|
|
1154
|
+
children: state
|
|
1155
|
+
}),
|
|
1156
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { style: S.spacer }),
|
|
1157
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
|
|
1158
|
+
action: "up",
|
|
1159
|
+
"aria-label": `上移成员 ${i + 1}`,
|
|
1160
|
+
title: "上移",
|
|
1161
|
+
disabled: i === 0,
|
|
1162
|
+
onClick: () => move(i, i - 1),
|
|
1163
|
+
children: "↑"
|
|
1164
|
+
}),
|
|
1165
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
|
|
1166
|
+
action: "down",
|
|
1167
|
+
"aria-label": `下移成员 ${i + 1}`,
|
|
1168
|
+
title: "下移",
|
|
1169
|
+
disabled: i + 1 === form.members.length,
|
|
1170
|
+
onClick: () => move(i, i + 1),
|
|
1171
|
+
children: "↓"
|
|
1172
|
+
}),
|
|
1173
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
|
|
1174
|
+
action: "remove",
|
|
1175
|
+
tone: "danger",
|
|
1176
|
+
"aria-label": `移除成员 ${i + 1}`,
|
|
1177
|
+
onClick: () => {
|
|
1178
|
+
patch({ members: form.members.filter((_, n) => n !== i) });
|
|
1179
|
+
focus(Math.min(i, form.members.length - 2));
|
|
1180
|
+
},
|
|
1181
|
+
children: "移除"
|
|
1182
|
+
})
|
|
1183
|
+
]
|
|
1081
1184
|
}),
|
|
1082
1185
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1083
|
-
|
|
1084
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1085
|
-
style: {
|
|
1086
|
-
...S.bandValue,
|
|
1087
|
-
color: SUCCESS
|
|
1088
|
-
},
|
|
1089
|
-
children: stats.total - stats.off
|
|
1090
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1091
|
-
style: S.bandLabel,
|
|
1092
|
-
children: "已启用"
|
|
1093
|
-
})]
|
|
1094
|
-
}),
|
|
1095
|
-
stats.off > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1096
|
-
style: S.bandStat,
|
|
1097
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1098
|
-
style: S.bandValue,
|
|
1099
|
-
children: stats.off
|
|
1100
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1101
|
-
style: S.bandLabel,
|
|
1102
|
-
children: "已停用"
|
|
1103
|
-
})]
|
|
1104
|
-
}),
|
|
1105
|
-
dirtyIds.size > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1106
|
-
style: S.bandStat,
|
|
1107
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1108
|
-
style: {
|
|
1109
|
-
...S.bandValue,
|
|
1110
|
-
color: DANGER
|
|
1111
|
-
},
|
|
1112
|
-
children: dirtyIds.size
|
|
1113
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1114
|
-
style: S.bandLabel,
|
|
1115
|
-
children: "未保存"
|
|
1116
|
-
})]
|
|
1117
|
-
})
|
|
1118
|
-
]
|
|
1119
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1120
|
-
style: S.bandDir,
|
|
1121
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1122
|
-
style: S.bandLabel,
|
|
1123
|
-
children: "名册目录"
|
|
1124
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1125
|
-
style: S.bandPath,
|
|
1126
|
-
title: view.dir || "~/.dsh/subagents",
|
|
1127
|
-
children: view.dir || "~/.dsh/subagents"
|
|
1128
|
-
})]
|
|
1129
|
-
})]
|
|
1130
|
-
}),
|
|
1131
|
-
stats.total > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1132
|
-
style: S.bar,
|
|
1133
|
-
children: [
|
|
1134
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1135
|
-
style: S.search,
|
|
1136
|
-
children: [
|
|
1137
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
1138
|
-
width: "12",
|
|
1139
|
-
height: "12",
|
|
1140
|
-
viewBox: "0 0 12 12",
|
|
1141
|
-
fill: "none",
|
|
1142
|
-
stroke: "currentColor",
|
|
1143
|
-
strokeWidth: "1.5",
|
|
1144
|
-
strokeLinecap: "round",
|
|
1145
|
-
style: {
|
|
1146
|
-
color: "inherit",
|
|
1147
|
-
opacity: .6,
|
|
1148
|
-
flex: "none"
|
|
1149
|
-
},
|
|
1150
|
-
"aria-hidden": "true",
|
|
1151
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
1152
|
-
cx: "5",
|
|
1153
|
-
cy: "5",
|
|
1154
|
-
r: "3.4"
|
|
1155
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M7.6 7.6L10.5 10.5" })]
|
|
1156
|
-
}),
|
|
1157
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1158
|
-
value: filter,
|
|
1159
|
-
onChange: (event) => setFilter(event.target.value),
|
|
1160
|
-
placeholder: "筛选 id、描述、模型…",
|
|
1161
|
-
"aria-label": "筛选子代理",
|
|
1162
|
-
style: S.searchInput
|
|
1163
|
-
}),
|
|
1164
|
-
filter !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1165
|
-
type: "button",
|
|
1166
|
-
onClick: () => setFilter(""),
|
|
1167
|
-
title: "清除筛选",
|
|
1168
|
-
style: {
|
|
1169
|
-
...S.ghost,
|
|
1170
|
-
padding: 0,
|
|
1171
|
-
fontSize: 13,
|
|
1172
|
-
lineHeight: 1
|
|
1173
|
-
},
|
|
1174
|
-
children: "×"
|
|
1175
|
-
})
|
|
1176
|
-
]
|
|
1177
|
-
}),
|
|
1178
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1179
|
-
type: "button",
|
|
1180
|
-
onClick: toggleAll,
|
|
1181
|
-
disabled: visibleIds.length === 0,
|
|
1182
|
-
style: S.button,
|
|
1183
|
-
children: allOpen ? "全部收起" : "全部展开"
|
|
1184
|
-
}),
|
|
1185
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1186
|
-
type: "button",
|
|
1187
|
-
onClick: () => setAdding((current) => !current),
|
|
1188
|
-
style: adding ? S.button : S.primary,
|
|
1189
|
-
children: adding ? "取消新增" : "+ 新增子代理"
|
|
1190
|
-
})
|
|
1191
|
-
]
|
|
1192
|
-
}),
|
|
1193
|
-
(adding || stats.total === 0) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1194
|
-
className: "dsh-library-card",
|
|
1195
|
-
style: {
|
|
1196
|
-
...S.row,
|
|
1197
|
-
...S.rowOpen
|
|
1198
|
-
},
|
|
1199
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1200
|
-
style: S.addHead,
|
|
1201
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1202
|
-
style: S.addIntro,
|
|
1203
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1204
|
-
style: {
|
|
1205
|
-
...S.id,
|
|
1206
|
-
color: ACCENT
|
|
1207
|
-
},
|
|
1208
|
-
children: "新增子代理"
|
|
1209
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1210
|
-
style: S.sub,
|
|
1211
|
-
children: "填写 ID 与角色描述,其余配置可稍后补充。"
|
|
1212
|
-
})]
|
|
1213
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1214
|
-
type: "button",
|
|
1215
|
-
disabled: busy,
|
|
1216
|
-
onClick: addEntry,
|
|
1217
|
-
style: S.primary,
|
|
1218
|
-
children: "创建子代理"
|
|
1219
|
-
})]
|
|
1220
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1221
|
-
style: S.body,
|
|
1222
|
-
children: [
|
|
1223
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1224
|
-
className: "dsh-library-grid",
|
|
1186
|
+
className: "library-grid",
|
|
1225
1187
|
style: S.grid,
|
|
1226
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
style: S.input
|
|
1234
|
-
})
|
|
1235
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1236
|
-
label: "模型",
|
|
1237
|
-
hint: "留空随默认路由",
|
|
1238
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1239
|
-
value: newEntry.model ?? "",
|
|
1240
|
-
onChange: (event) => setNewEntry({
|
|
1241
|
-
...newEntry,
|
|
1242
|
-
model: event.target.value
|
|
1188
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1189
|
+
style: S.field,
|
|
1190
|
+
children: [
|
|
1191
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
1192
|
+
htmlFor: slotId,
|
|
1193
|
+
style: S.fieldLabel,
|
|
1194
|
+
children: "成员代号"
|
|
1243
1195
|
}),
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
})
|
|
1247
|
-
})]
|
|
1248
|
-
}),
|
|
1249
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1250
|
-
label: "描述(模型可见)",
|
|
1251
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
1252
|
-
value: newEntry.description ?? "",
|
|
1253
|
-
onChange: (event) => setNewEntry({
|
|
1254
|
-
...newEntry,
|
|
1255
|
-
description: event.target.value
|
|
1256
|
-
}),
|
|
1257
|
-
placeholder: "一句话说明这个角色做什么——模型靠它选人",
|
|
1258
|
-
rows: 1,
|
|
1259
|
-
style: {
|
|
1260
|
-
...S.prose,
|
|
1261
|
-
overflow: "auto"
|
|
1262
|
-
}
|
|
1263
|
-
})
|
|
1264
|
-
}),
|
|
1265
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1266
|
-
className: "dsh-library-grid",
|
|
1267
|
-
style: S.grid,
|
|
1268
|
-
children: [
|
|
1269
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1270
|
-
label: "Provider",
|
|
1271
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1272
|
-
value: newEntry.provider ?? "",
|
|
1273
|
-
onChange: (event) => setNewEntry({
|
|
1274
|
-
...newEntry,
|
|
1275
|
-
provider: event.target.value
|
|
1276
|
-
}),
|
|
1277
|
-
placeholder: "kimi-coding",
|
|
1278
|
-
style: S.input
|
|
1279
|
-
})
|
|
1280
|
-
}),
|
|
1281
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1282
|
-
label: "传输层",
|
|
1283
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1284
|
-
value: newEntry.subagentProvider ?? "",
|
|
1285
|
-
onChange: (event) => setNewEntry({
|
|
1286
|
-
...newEntry,
|
|
1287
|
-
subagentProvider: event.target.value
|
|
1288
|
-
}),
|
|
1289
|
-
placeholder: "spawn(默认)",
|
|
1290
|
-
style: S.input
|
|
1291
|
-
})
|
|
1292
|
-
}),
|
|
1293
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1294
|
-
label: "后台模式",
|
|
1295
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
1296
|
-
value: newEntry.backgroundMode ?? "one-shot",
|
|
1297
|
-
onChange: (event) => setNewEntry({
|
|
1298
|
-
...newEntry,
|
|
1299
|
-
backgroundMode: event.target.value
|
|
1300
|
-
}),
|
|
1196
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1197
|
+
id: slotId,
|
|
1301
1198
|
style: S.input,
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1199
|
+
"data-field": "slot",
|
|
1200
|
+
value: member.slot,
|
|
1201
|
+
placeholder: "例如 review",
|
|
1202
|
+
autoComplete: "off",
|
|
1203
|
+
autoCapitalize: "none",
|
|
1204
|
+
spellCheck: false,
|
|
1205
|
+
"aria-invalid": !!error || void 0,
|
|
1206
|
+
"aria-describedby": error ? `${rulesId} ${errorId}` : rulesId,
|
|
1207
|
+
onChange: (e) => patchMember(i, { slot: e.target.value })
|
|
1208
|
+
}),
|
|
1209
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1210
|
+
id: errorId,
|
|
1211
|
+
"data-slot-error": true,
|
|
1212
|
+
className: "library-field-error",
|
|
1213
|
+
"aria-live": "polite",
|
|
1214
|
+
children: error
|
|
1215
|
+
}),
|
|
1216
|
+
canUseRoleId && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1217
|
+
className: "library-field-actions",
|
|
1218
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
|
|
1219
|
+
action: "use-role-id",
|
|
1220
|
+
className: "library-link",
|
|
1221
|
+
disabled: roleIdUsed,
|
|
1222
|
+
onClick: () => {
|
|
1223
|
+
patchMember(i, { slot: member.role });
|
|
1224
|
+
focus(i);
|
|
1225
|
+
},
|
|
1226
|
+
children: "用角色 ID"
|
|
1227
|
+
}), roleIdUsed && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1228
|
+
style: S.hint,
|
|
1229
|
+
children: "此代号已使用"
|
|
1308
1230
|
})]
|
|
1309
1231
|
})
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
...newEntry,
|
|
1319
|
-
maxDepth: event.target.value === "" ? void 0 : Number(event.target.value)
|
|
1320
|
-
}),
|
|
1321
|
-
style: S.input
|
|
1322
|
-
})
|
|
1323
|
-
}),
|
|
1324
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1325
|
-
label: "输出上限",
|
|
1326
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1327
|
-
type: "number",
|
|
1328
|
-
min: 1,
|
|
1329
|
-
value: newEntry.maxTokens ?? "",
|
|
1330
|
-
onChange: (event) => setNewEntry({
|
|
1331
|
-
...newEntry,
|
|
1332
|
-
maxTokens: event.target.value === "" ? void 0 : Number(event.target.value)
|
|
1333
|
-
}),
|
|
1334
|
-
placeholder: "tokens",
|
|
1335
|
-
style: S.input
|
|
1336
|
-
})
|
|
1337
|
-
})
|
|
1338
|
-
]
|
|
1339
|
-
}),
|
|
1340
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1341
|
-
className: "dsh-library-grid",
|
|
1342
|
-
style: S.grid,
|
|
1343
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1344
|
-
label: "思考强度",
|
|
1345
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1346
|
-
value: newEntry.reasoningEffort ?? "",
|
|
1347
|
-
onChange: (event) => setNewEntry({
|
|
1348
|
-
...newEntry,
|
|
1349
|
-
reasoningEffort: event.target.value === "" ? void 0 : event.target.value.trim()
|
|
1232
|
+
]
|
|
1233
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1234
|
+
style: S.field,
|
|
1235
|
+
children: [
|
|
1236
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
1237
|
+
htmlFor: `${slotId}-role`,
|
|
1238
|
+
style: S.fieldLabel,
|
|
1239
|
+
children: "角色"
|
|
1350
1240
|
}),
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1241
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
1242
|
+
id: `${slotId}-role`,
|
|
1243
|
+
style: S.input,
|
|
1244
|
+
"data-field": "role",
|
|
1245
|
+
value: member.role,
|
|
1246
|
+
onChange: (e) => patchMember(i, { role: e.target.value }),
|
|
1247
|
+
children: [
|
|
1248
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
1249
|
+
value: "",
|
|
1250
|
+
children: "选择名册中的角色"
|
|
1251
|
+
}),
|
|
1252
|
+
member.role && !role && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("option", {
|
|
1253
|
+
value: member.role,
|
|
1254
|
+
children: [member.role, " · 角色缺失"]
|
|
1255
|
+
}),
|
|
1256
|
+
Object.entries(view.entries).map(([id$1, row]) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("option", {
|
|
1257
|
+
value: id$1,
|
|
1258
|
+
children: [id$1, availability(row) && " · " + availability(row)]
|
|
1259
|
+
}, id$1))
|
|
1260
|
+
]
|
|
1261
|
+
}),
|
|
1262
|
+
member.role && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RoleIdCopy, { id: member.role }, member.role)
|
|
1263
|
+
]
|
|
1374
1264
|
})]
|
|
1375
1265
|
}),
|
|
1376
1266
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
}),
|
|
1384
|
-
placeholder: "子代理的系统提示词",
|
|
1385
|
-
style: S.prose
|
|
1386
|
-
})
|
|
1267
|
+
name: "assignment",
|
|
1268
|
+
label: "默认分工",
|
|
1269
|
+
multiline: true,
|
|
1270
|
+
value: member.assignment,
|
|
1271
|
+
change: (assignment) => patchMember(i, { assignment }),
|
|
1272
|
+
placeholder: "例如:检查这次改动会不会影响已有功能"
|
|
1387
1273
|
})
|
|
1388
1274
|
]
|
|
1389
|
-
})
|
|
1275
|
+
}, i);
|
|
1276
|
+
})
|
|
1277
|
+
})
|
|
1278
|
+
] });
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
//#endregion
|
|
1282
|
+
//#region src/client/LibrarySettings.tsx
|
|
1283
|
+
function Modal({ dialog, close }) {
|
|
1284
|
+
const ref = (0, react.useRef)(null);
|
|
1285
|
+
const id = (0, react.useId)();
|
|
1286
|
+
(0, react.useEffect)(() => {
|
|
1287
|
+
const node = ref.current;
|
|
1288
|
+
node?.showModal();
|
|
1289
|
+
return () => {
|
|
1290
|
+
node?.close();
|
|
1291
|
+
};
|
|
1292
|
+
}, []);
|
|
1293
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("dialog", {
|
|
1294
|
+
className: "library-dialog",
|
|
1295
|
+
ref,
|
|
1296
|
+
"aria-labelledby": id,
|
|
1297
|
+
onCancel: close,
|
|
1298
|
+
children: [
|
|
1299
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
1300
|
+
id,
|
|
1301
|
+
children: dialog.title
|
|
1390
1302
|
}),
|
|
1391
|
-
|
|
1392
|
-
|
|
1303
|
+
dialog.content,
|
|
1304
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1305
|
+
style: S.actions,
|
|
1393
1306
|
children: [
|
|
1394
|
-
|
|
1395
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1307
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { style: S.spacer }),
|
|
1308
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
|
|
1309
|
+
action: "cancel",
|
|
1310
|
+
autoFocus: true,
|
|
1311
|
+
onClick: close,
|
|
1312
|
+
children: "取消"
|
|
1313
|
+
}),
|
|
1314
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
|
|
1315
|
+
action: "confirm",
|
|
1316
|
+
tone: dialog.destructive ? "danger" : "primary",
|
|
1317
|
+
onClick: () => {
|
|
1318
|
+
close();
|
|
1319
|
+
dialog.confirm();
|
|
1320
|
+
},
|
|
1321
|
+
children: dialog.label
|
|
1322
|
+
})
|
|
1399
1323
|
]
|
|
1324
|
+
})
|
|
1325
|
+
]
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1328
|
+
function CompareForm({ form }) {
|
|
1329
|
+
if (!form) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: "条目已删除或尚未创建。" });
|
|
1330
|
+
const rows = [
|
|
1331
|
+
["ID", form.id],
|
|
1332
|
+
["状态", form.enabled ? "已启用" : "已停用"],
|
|
1333
|
+
["描述", form.description]
|
|
1334
|
+
];
|
|
1335
|
+
if (form.kind === "groups") {
|
|
1336
|
+
rows.push(["名称", form.name], ["共享说明", form.instructions]);
|
|
1337
|
+
form.members.forEach((m) => rows.push([m.slot || "成员", [m.role, m.assignment].filter(Boolean).join(" / ")]));
|
|
1338
|
+
} else {
|
|
1339
|
+
rows.push(["Provider", form.provider], ["模型", form.model], ["思考档位", form.reasoningEffort], ["输出上限", form.maxTokens], ["传输层", form.subagentProvider], ["深度上限", form.maxDepth], ["角色人设", form.persona]);
|
|
1340
|
+
if (form.inherit || form.routeNote) rows.push(["路由状态", form.inherit ? "保存后使用会话模型" : {
|
|
1341
|
+
profile: "当前 profile 路由",
|
|
1342
|
+
inherit: "使用会话模型",
|
|
1343
|
+
"foreign-ignored": "共享 Provider 未注册",
|
|
1344
|
+
"profile-missing": "当前 Provider 未注册",
|
|
1345
|
+
"overlay-broken": "路由无法读取"
|
|
1346
|
+
}[form.routeNote]]);
|
|
1347
|
+
if (form.filter) rows.push(["旧工具限制", form.clearToolFilter ? "保存时解除" : JSON.stringify(form.filter)]);
|
|
1348
|
+
}
|
|
1349
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dl", { children: rows.map(([name, value], i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: name }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { children: value || "—" })] }, i)) });
|
|
1350
|
+
}
|
|
1351
|
+
function LibrarySettings({ readView: readView$1, writeView: writeView$1, subscribeRefresh }) {
|
|
1352
|
+
const scope = (0, react.useId)();
|
|
1353
|
+
const root = (0, react.useRef)(null);
|
|
1354
|
+
const [view, setView] = (0, react.useState)(null);
|
|
1355
|
+
const [tab, setTab] = (0, react.useState)("roles");
|
|
1356
|
+
const [filters, setFilters] = (0, react.useState)({
|
|
1357
|
+
roles: "",
|
|
1358
|
+
groups: ""
|
|
1359
|
+
});
|
|
1360
|
+
const [expanded, setExpanded] = (0, react.useState)({});
|
|
1361
|
+
const [drafts, setDrafts] = (0, react.useState)({});
|
|
1362
|
+
const [busy, setBusy] = (0, react.useState)(false);
|
|
1363
|
+
const [notice, setNotice] = (0, react.useState)();
|
|
1364
|
+
const [dialog, setDialog] = (0, react.useState)();
|
|
1365
|
+
const active = (0, react.useRef)(false);
|
|
1366
|
+
const writing = (0, react.useRef)(false);
|
|
1367
|
+
const pendingRefresh = (0, react.useRef)(false);
|
|
1368
|
+
const readNumber = (0, react.useRef)(0);
|
|
1369
|
+
const load = (0, react.useCallback)(async (manual = false) => {
|
|
1370
|
+
if (writing.current) {
|
|
1371
|
+
pendingRefresh.current = true;
|
|
1372
|
+
return;
|
|
1373
|
+
}
|
|
1374
|
+
const request = ++readNumber.current;
|
|
1375
|
+
try {
|
|
1376
|
+
const latest = await readView$1();
|
|
1377
|
+
if (!active.current || request !== readNumber.current) return;
|
|
1378
|
+
setView(latest);
|
|
1379
|
+
setDrafts((rows) => {
|
|
1380
|
+
if (!Object.values(rows).some((row) => row.awaitingCurrent)) return rows;
|
|
1381
|
+
return Object.fromEntries(Object.entries(rows).map(([id, row]) => [id, row.awaitingCurrent ? {
|
|
1382
|
+
...row,
|
|
1383
|
+
awaitingCurrent: false
|
|
1384
|
+
} : row]));
|
|
1385
|
+
});
|
|
1386
|
+
if (manual) setNotice({ text: "已读取当前配置。" });
|
|
1387
|
+
} catch (error) {
|
|
1388
|
+
if (active.current && request === readNumber.current) setNotice({
|
|
1389
|
+
text: String(error),
|
|
1390
|
+
error: true
|
|
1391
|
+
});
|
|
1392
|
+
}
|
|
1393
|
+
}, [readView$1]);
|
|
1394
|
+
(0, react.useEffect)(() => {
|
|
1395
|
+
active.current = true;
|
|
1396
|
+
load();
|
|
1397
|
+
const unsubscribe = subscribeRefresh(() => {
|
|
1398
|
+
load();
|
|
1399
|
+
});
|
|
1400
|
+
return () => {
|
|
1401
|
+
active.current = false;
|
|
1402
|
+
readNumber.current++;
|
|
1403
|
+
unsubscribe();
|
|
1404
|
+
};
|
|
1405
|
+
}, [load, subscribeRefresh]);
|
|
1406
|
+
const keyFor = (kind, id) => kind + "/" + id;
|
|
1407
|
+
const key = (id) => keyFor(tab, id);
|
|
1408
|
+
const label = tab === "roles" ? "角色" : "编队";
|
|
1409
|
+
const readonly = busy || !view?.writable;
|
|
1410
|
+
function put(k, draft) {
|
|
1411
|
+
setDrafts((current) => {
|
|
1412
|
+
const next = { ...current };
|
|
1413
|
+
if (draft) next[k] = draft;
|
|
1414
|
+
else delete next[k];
|
|
1415
|
+
return next;
|
|
1416
|
+
});
|
|
1417
|
+
}
|
|
1418
|
+
function reveal(id, slot) {
|
|
1419
|
+
requestAnimationFrame(() => {
|
|
1420
|
+
const card = root.current?.querySelector(`[data-card="${CSS.escape(id)}"]`);
|
|
1421
|
+
const target = slot && card?.querySelector(`[data-slot-key="${CSS.escape(slot)}"] [data-field="slot"]`) || card?.querySelector("[data-row-id]");
|
|
1422
|
+
target?.focus({ preventScroll: true });
|
|
1423
|
+
target?.scrollIntoView({ block: "nearest" });
|
|
1424
|
+
});
|
|
1425
|
+
}
|
|
1426
|
+
function jump(ref) {
|
|
1427
|
+
setTab("groups");
|
|
1428
|
+
setFilters((old) => ({
|
|
1429
|
+
...old,
|
|
1430
|
+
groups: ""
|
|
1431
|
+
}));
|
|
1432
|
+
setExpanded((old) => ({
|
|
1433
|
+
...old,
|
|
1434
|
+
[keyFor("groups", ref.groupId)]: true
|
|
1435
|
+
}));
|
|
1436
|
+
setNotice(void 0);
|
|
1437
|
+
reveal(ref.groupId, ref.slot);
|
|
1438
|
+
}
|
|
1439
|
+
function changeTab(next, focus) {
|
|
1440
|
+
setTab(next);
|
|
1441
|
+
setNotice(void 0);
|
|
1442
|
+
if (focus) requestAnimationFrame(() => root.current?.querySelector(`[data-tab="${next}"]`)?.focus());
|
|
1443
|
+
}
|
|
1444
|
+
async function write(operation, row, success = "已保存。") {
|
|
1445
|
+
if (writing.current) return;
|
|
1446
|
+
writing.current = true;
|
|
1447
|
+
readNumber.current++;
|
|
1448
|
+
setBusy(true);
|
|
1449
|
+
setNotice(void 0);
|
|
1450
|
+
const k = row && key(row.id);
|
|
1451
|
+
try {
|
|
1452
|
+
const result = await writeView$1(operation);
|
|
1453
|
+
if (!active.current) return;
|
|
1454
|
+
if (result.ok) {
|
|
1455
|
+
setView(result.view);
|
|
1456
|
+
if (k && row) {
|
|
1457
|
+
put(k, void 0);
|
|
1458
|
+
setExpanded((old) => ({
|
|
1459
|
+
...old,
|
|
1460
|
+
[k]: false
|
|
1461
|
+
}));
|
|
1462
|
+
if (operation.op === "save-entry" || operation.op === "save-group") reveal(operation.id);
|
|
1463
|
+
else requestAnimationFrame(() => root.current?.querySelector("[data-action=\"new\"]")?.focus());
|
|
1464
|
+
}
|
|
1465
|
+
setNotice({ text: success });
|
|
1466
|
+
} else {
|
|
1467
|
+
if (result.view) setView(result.view);
|
|
1468
|
+
if (k && row) {
|
|
1469
|
+
put(k, {
|
|
1470
|
+
...row.draft,
|
|
1471
|
+
conflict: result.conflict,
|
|
1472
|
+
message: result.conflict ? void 0 : result.message ?? "保存失败。",
|
|
1473
|
+
references: result.references,
|
|
1474
|
+
awaitingCurrent: result.conflict && !result.view
|
|
1475
|
+
});
|
|
1476
|
+
setExpanded((old) => ({
|
|
1477
|
+
...old,
|
|
1478
|
+
[k]: true
|
|
1479
|
+
}));
|
|
1480
|
+
if (result.conflict && !result.view) pendingRefresh.current = true;
|
|
1481
|
+
if (result.references?.length && !result.view) pendingRefresh.current = true;
|
|
1482
|
+
} else setNotice({
|
|
1483
|
+
text: result.message ?? "配置发生变化,请刷新后重试。",
|
|
1484
|
+
error: true
|
|
1485
|
+
});
|
|
1486
|
+
}
|
|
1487
|
+
} catch (error) {
|
|
1488
|
+
if (active.current) setNotice({
|
|
1489
|
+
text: String(error),
|
|
1490
|
+
error: true
|
|
1491
|
+
});
|
|
1492
|
+
} finally {
|
|
1493
|
+
writing.current = false;
|
|
1494
|
+
if (active.current) {
|
|
1495
|
+
setBusy(false);
|
|
1496
|
+
if (pendingRefresh.current) {
|
|
1497
|
+
pendingRefresh.current = false;
|
|
1498
|
+
load();
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
if (!view) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1504
|
+
className: "dsh-library",
|
|
1505
|
+
style: S.root,
|
|
1506
|
+
children: [
|
|
1507
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: SETTINGS_CSS }),
|
|
1508
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
|
|
1509
|
+
style: S.heading,
|
|
1510
|
+
children: "子代理库"
|
|
1400
1511
|
}),
|
|
1401
|
-
|
|
1402
|
-
|
|
1512
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1513
|
+
role: "status",
|
|
1514
|
+
children: notice?.text ?? "正在加载…"
|
|
1515
|
+
}),
|
|
1516
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
|
|
1517
|
+
action: "refresh",
|
|
1518
|
+
onClick: () => void load(true),
|
|
1519
|
+
children: "重试"
|
|
1520
|
+
}) })
|
|
1521
|
+
]
|
|
1522
|
+
});
|
|
1523
|
+
const currentView = view;
|
|
1524
|
+
function add() {
|
|
1525
|
+
const k = key(NEW);
|
|
1526
|
+
put(k, freshDraft(currentView, tab, NEW));
|
|
1527
|
+
setExpanded((old) => ({
|
|
1528
|
+
...old,
|
|
1529
|
+
[k]: true
|
|
1530
|
+
}));
|
|
1531
|
+
setNotice(void 0);
|
|
1532
|
+
reveal(NEW);
|
|
1533
|
+
}
|
|
1534
|
+
function compare(id, draft) {
|
|
1535
|
+
const current = serverForm(currentView, tab, id === NEW ? draft.form.id.trim() : id);
|
|
1536
|
+
const collision = id === NEW && !!current;
|
|
1537
|
+
const recreate = !current && id !== NEW;
|
|
1538
|
+
const competingMembers = draft.form.kind === "groups" && draft.base?.kind === "groups" && current?.kind === "groups" && !equal(draft.base.members, draft.form.members) && !equal(draft.base.members, current.members) && !equal(current.members, draft.form.members);
|
|
1539
|
+
setDialog({
|
|
1540
|
+
title: "配置版本有冲突",
|
|
1541
|
+
label: collision ? "返回更换 ID" : recreate ? "保留草稿为新条目" : "保留草稿,继续编辑",
|
|
1542
|
+
content: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1543
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1544
|
+
className: "library-compare",
|
|
1545
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: "当前配置" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CompareForm, { form: current })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: "你的草稿" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CompareForm, { form: draft.form })] })]
|
|
1546
|
+
}),
|
|
1547
|
+
competingMembers && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1548
|
+
style: BANNER.warn,
|
|
1549
|
+
children: "双方都修改了编队成员。保留草稿将采用你这份完整的成员名单和分工。"
|
|
1550
|
+
}),
|
|
1551
|
+
collision ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: "这个 ID 已有配置。请为新条目更换 ID 后再创建。" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", { children: ["保留已编辑的字段,其他字段采用当前配置。", recreate ? "再次保存将重新创建这个条目。" : "再次保存才会写入配置。"] })
|
|
1552
|
+
] }),
|
|
1553
|
+
confirm: () => {
|
|
1554
|
+
if (!collision) {
|
|
1555
|
+
put(key(id), rebase(draft, current));
|
|
1556
|
+
return;
|
|
1557
|
+
}
|
|
1558
|
+
requestAnimationFrame(() => root.current?.querySelector("[data-card=\"@new\"] [data-field=\"id\"]")?.focus());
|
|
1559
|
+
}
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
function remove(id, draft) {
|
|
1563
|
+
const refs = tab === "roles" ? own(currentView.roleUsages, id) : void 0;
|
|
1564
|
+
if (refs?.length) {
|
|
1565
|
+
put(key(id), {
|
|
1566
|
+
...draft,
|
|
1567
|
+
references: refs
|
|
1568
|
+
});
|
|
1569
|
+
return;
|
|
1570
|
+
}
|
|
1571
|
+
setDialog({
|
|
1572
|
+
title: "删除" + label,
|
|
1573
|
+
label: "确认删除",
|
|
1574
|
+
destructive: true,
|
|
1575
|
+
content: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", { children: [
|
|
1576
|
+
"确定删除 ",
|
|
1577
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: draft.form.kind === "groups" && draft.form.name || id }),
|
|
1578
|
+
"?",
|
|
1579
|
+
tab === "groups" && "名册中的角色仍可单独使用。"
|
|
1580
|
+
] }),
|
|
1581
|
+
confirm: () => void write({
|
|
1582
|
+
op: tab === "roles" ? "delete" : "delete-group",
|
|
1583
|
+
id,
|
|
1584
|
+
expectedHash: currentView.hash
|
|
1585
|
+
}, {
|
|
1586
|
+
id,
|
|
1587
|
+
draft
|
|
1588
|
+
}, "已删除" + label + " " + id + "。")
|
|
1589
|
+
});
|
|
1590
|
+
}
|
|
1591
|
+
const needle = filters[tab].trim().toLowerCase();
|
|
1592
|
+
const serverIds = Object.keys(tab === "roles" ? view.entries : view.groups);
|
|
1593
|
+
const ids = [...new Set([...Object.keys(drafts).filter((k) => k.startsWith(tab + "/") && !serverIds.includes(k.slice(tab.length + 1))).map((k) => k.slice(tab.length + 1)), ...serverIds])].filter((id) => {
|
|
1594
|
+
if (!needle || id === NEW || drafts[key(id)] && expanded[key(id)]) return true;
|
|
1595
|
+
const form = drafts[key(id)]?.form ?? serverForm(view, tab, id);
|
|
1596
|
+
return form && [
|
|
1597
|
+
id,
|
|
1598
|
+
form.description,
|
|
1599
|
+
...form.kind === "roles" ? [
|
|
1600
|
+
form.model,
|
|
1601
|
+
form.provider,
|
|
1602
|
+
form.persona,
|
|
1603
|
+
form.reasoningEffort
|
|
1604
|
+
] : [form.name]
|
|
1605
|
+
].some((s) => s.toLowerCase().includes(needle));
|
|
1606
|
+
});
|
|
1607
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1608
|
+
ref: root,
|
|
1609
|
+
className: "dsh-library",
|
|
1610
|
+
style: S.root,
|
|
1611
|
+
children: [
|
|
1612
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: SETTINGS_CSS }),
|
|
1613
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
|
|
1614
|
+
style: S.headingRow,
|
|
1403
1615
|
children: [
|
|
1404
|
-
"
|
|
1405
|
-
|
|
1406
|
-
|
|
1616
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
|
|
1617
|
+
style: S.heading,
|
|
1618
|
+
children: "子代理库"
|
|
1619
|
+
}),
|
|
1620
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { style: S.spacer }),
|
|
1621
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
|
|
1622
|
+
action: "refresh",
|
|
1623
|
+
disabled: busy,
|
|
1624
|
+
onClick: () => void load(true),
|
|
1625
|
+
children: "刷新"
|
|
1626
|
+
})
|
|
1407
1627
|
]
|
|
1408
1628
|
}),
|
|
1409
|
-
visibleIds.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1410
|
-
style: S.listCaption,
|
|
1411
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: needle === "" ? "角色名册" : `匹配 ${visibleIds.length} / ${stats.total} 个子代理` }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "点击名称展开配置" })]
|
|
1412
|
-
}),
|
|
1413
1629
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1630
|
+
className: "library-tabs",
|
|
1631
|
+
role: "tablist",
|
|
1632
|
+
"aria-label": "设置分类",
|
|
1633
|
+
children: ["roles", "groups"].map((kind) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1634
|
+
type: "button",
|
|
1635
|
+
role: "tab",
|
|
1636
|
+
"data-tab": kind,
|
|
1637
|
+
id: scope + kind,
|
|
1638
|
+
"aria-controls": scope + "-panel",
|
|
1639
|
+
"aria-selected": tab === kind,
|
|
1640
|
+
tabIndex: tab === kind ? 0 : -1,
|
|
1641
|
+
onClick: () => changeTab(kind, false),
|
|
1642
|
+
onKeyDown: (e) => {
|
|
1643
|
+
if ([
|
|
1644
|
+
"ArrowLeft",
|
|
1645
|
+
"ArrowRight",
|
|
1646
|
+
"Home",
|
|
1647
|
+
"End"
|
|
1648
|
+
].includes(e.key)) {
|
|
1649
|
+
e.preventDefault();
|
|
1650
|
+
changeTab(e.key === "Home" ? "roles" : e.key === "End" ? "groups" : tab === "groups" ? "roles" : "groups", true);
|
|
1651
|
+
}
|
|
1652
|
+
},
|
|
1653
|
+
children: kind === "roles" ? "角色名册" : "编队"
|
|
1654
|
+
}, kind))
|
|
1655
|
+
}),
|
|
1656
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
1657
|
+
role: "tabpanel",
|
|
1658
|
+
id: scope + "-panel",
|
|
1659
|
+
"aria-labelledby": scope + tab,
|
|
1660
|
+
className: "library-panel",
|
|
1661
|
+
children: [
|
|
1662
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1663
|
+
style: BANNER.info,
|
|
1664
|
+
children: tab === "roles" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
1665
|
+
view.profile && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("strong", { children: ["当前 profile:", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: view.profile })] }), "。"] }),
|
|
1666
|
+
"角色配置由引用它的编队共享。",
|
|
1667
|
+
view.profile && "模型路由按 profile 保存。"
|
|
1668
|
+
] }) : "编队支持逐个派遣,开启或关闭智能体团队均可使用。"
|
|
1669
|
+
}),
|
|
1670
|
+
view.diagnostics?.length ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
1671
|
+
style: BANNER.warn,
|
|
1672
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", { children: [
|
|
1673
|
+
"配置诊断(",
|
|
1674
|
+
view.diagnostics.length,
|
|
1675
|
+
")"
|
|
1676
|
+
] }), view.diagnostics.map((item, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
|
|
1677
|
+
item.file ?? item.id,
|
|
1678
|
+
" ",
|
|
1679
|
+
item.message
|
|
1680
|
+
] }, i))]
|
|
1681
|
+
}) : null,
|
|
1682
|
+
tab === "roles" && (view.legacyCount ?? 0) > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1683
|
+
style: BANNER.info,
|
|
1684
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
1685
|
+
"名册已接管 ",
|
|
1686
|
+
view.legacyCount,
|
|
1687
|
+
" 个旧条目。确认迁移后可清除旧配置中的角色副本。"
|
|
1688
|
+
] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
|
|
1689
|
+
action: "clear-legacy",
|
|
1690
|
+
disabled: readonly,
|
|
1691
|
+
onClick: () => setDialog({
|
|
1692
|
+
title: "清除旧副本",
|
|
1693
|
+
label: "确认清除",
|
|
1694
|
+
content: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: "清除旧配置中已迁移的角色副本?名册文件会保留。" }),
|
|
1695
|
+
destructive: true,
|
|
1696
|
+
confirm: () => void write({
|
|
1697
|
+
op: "clear-legacy",
|
|
1698
|
+
expectedHash: view.hash
|
|
1699
|
+
}, void 0, "已清除旧副本。")
|
|
1475
1700
|
}),
|
|
1476
|
-
|
|
1477
|
-
|
|
1701
|
+
children: "清除旧副本"
|
|
1702
|
+
}) })]
|
|
1703
|
+
}),
|
|
1704
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1705
|
+
style: S.bar,
|
|
1706
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1707
|
+
className: "library-search",
|
|
1708
|
+
style: S.search,
|
|
1709
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
1710
|
+
"aria-hidden": "true",
|
|
1711
|
+
width: "15",
|
|
1712
|
+
height: "15",
|
|
1713
|
+
viewBox: "0 0 24 24",
|
|
1714
|
+
fill: "none",
|
|
1715
|
+
stroke: "currentColor",
|
|
1716
|
+
strokeWidth: "2",
|
|
1717
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
1718
|
+
cx: "10.5",
|
|
1719
|
+
cy: "10.5",
|
|
1720
|
+
r: "5.5"
|
|
1721
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "m15 15 5 5" })]
|
|
1722
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1723
|
+
type: "search",
|
|
1724
|
+
"aria-label": "筛选" + label,
|
|
1725
|
+
value: filters[tab],
|
|
1726
|
+
placeholder: tab === "roles" ? "筛选角色 ID、描述、模型" : "筛选编队名称、ID、描述",
|
|
1727
|
+
onChange: (e) => setFilters({
|
|
1728
|
+
...filters,
|
|
1729
|
+
[tab]: e.target.value
|
|
1730
|
+
}),
|
|
1731
|
+
style: S.searchInput
|
|
1732
|
+
})]
|
|
1733
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Action, {
|
|
1734
|
+
action: "new",
|
|
1735
|
+
tone: "primary",
|
|
1736
|
+
disabled: readonly || !!drafts[key(NEW)],
|
|
1737
|
+
onClick: add,
|
|
1738
|
+
children: [
|
|
1739
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1740
|
+
"aria-hidden": "true",
|
|
1741
|
+
children: "+ "
|
|
1742
|
+
}),
|
|
1743
|
+
"新建",
|
|
1744
|
+
label
|
|
1745
|
+
]
|
|
1746
|
+
})]
|
|
1747
|
+
}),
|
|
1748
|
+
notice && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1749
|
+
role: "status",
|
|
1750
|
+
style: notice.error ? BANNER.error : BANNER.ok,
|
|
1751
|
+
children: notice.text
|
|
1752
|
+
}),
|
|
1753
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1754
|
+
style: S.list,
|
|
1755
|
+
children: [!ids.length && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1756
|
+
style: S.empty,
|
|
1757
|
+
children: needle ? "没有匹配的条目。" : "暂无" + label + "。"
|
|
1758
|
+
}), ids.map((id) => {
|
|
1759
|
+
const k = key(id);
|
|
1760
|
+
const draft = drafts[k] ?? freshDraft(view, tab, id);
|
|
1761
|
+
const form = draft.form;
|
|
1762
|
+
const open = Boolean(expanded[k]);
|
|
1763
|
+
const isNew = id === NEW;
|
|
1764
|
+
const current = serverForm(view, tab, isNew ? form.id.trim() : id);
|
|
1765
|
+
const collision = isNew && !!current;
|
|
1766
|
+
const stale = Boolean(draft.conflict || !equal(draft.base, current));
|
|
1767
|
+
const dirty = !equal(draft.base, form);
|
|
1768
|
+
const refs = own(view.roleUsages, id) ?? [];
|
|
1769
|
+
const blocked = form.kind === "groups" ? form.members.filter((m) => memberState(view, form, m)).length : 0;
|
|
1770
|
+
const roleState = form.kind === "roles" && availability(own(view.entries, id));
|
|
1771
|
+
const contentId = scope + tab + id;
|
|
1772
|
+
function change(next) {
|
|
1773
|
+
put(k, equal(draft.base, next) && !stale ? void 0 : {
|
|
1774
|
+
...draft,
|
|
1775
|
+
form: next,
|
|
1776
|
+
message: void 0,
|
|
1777
|
+
references: void 0,
|
|
1778
|
+
conflict: isNew && form.id !== next.id && !draft.awaitingCurrent ? false : draft.conflict
|
|
1779
|
+
});
|
|
1780
|
+
setNotice(void 0);
|
|
1781
|
+
}
|
|
1782
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
|
|
1783
|
+
className: "dsh-library-card",
|
|
1784
|
+
"data-card": id,
|
|
1785
|
+
style: {
|
|
1786
|
+
...S.row,
|
|
1787
|
+
...!form.enabled && S.rowOff,
|
|
1788
|
+
...open && S.rowOpen
|
|
1789
|
+
},
|
|
1478
1790
|
children: [
|
|
1479
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1480
|
-
style: S.excerpt,
|
|
1481
|
-
title: entry.description ?? "",
|
|
1482
|
-
children: entry.description || "暂无角色描述"
|
|
1483
|
-
}),
|
|
1484
1791
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1485
|
-
style: S.
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
1506
|
-
style:
|
|
1507
|
-
children: entry.backgroundMode === "continuable" ? "可续聊" : "单次任务"
|
|
1508
|
-
}),
|
|
1509
|
-
entry.reasoningEffort && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1510
|
-
style: S.glyph,
|
|
1511
|
-
children: ["思考 ", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1512
|
-
style: S.metaValue,
|
|
1513
|
-
children: entry.reasoningEffort
|
|
1514
|
-
})]
|
|
1515
|
-
}),
|
|
1516
|
-
entry.maxDepth !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1517
|
-
style: S.glyph,
|
|
1518
|
-
children: ["深度 ", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1519
|
-
style: S.metaValue,
|
|
1520
|
-
children: entry.maxDepth
|
|
1521
|
-
})]
|
|
1522
|
-
}),
|
|
1523
|
-
entry.maxTokens !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1524
|
-
style: S.glyph,
|
|
1792
|
+
style: S.head,
|
|
1793
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1794
|
+
type: "button",
|
|
1795
|
+
style: S.disclosure,
|
|
1796
|
+
className: "dsh-library-disclosure",
|
|
1797
|
+
"data-row-id": id,
|
|
1798
|
+
"data-action": "toggle",
|
|
1799
|
+
"aria-expanded": open,
|
|
1800
|
+
"aria-controls": contentId,
|
|
1801
|
+
onClick: () => setExpanded((old) => ({
|
|
1802
|
+
...old,
|
|
1803
|
+
[k]: !open
|
|
1804
|
+
})),
|
|
1805
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1806
|
+
"aria-hidden": "true",
|
|
1807
|
+
style: {
|
|
1808
|
+
...S.chevron,
|
|
1809
|
+
transform: open ? "rotate(90deg)" : void 0
|
|
1810
|
+
},
|
|
1811
|
+
children: "❯"
|
|
1812
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1813
|
+
style: S.titleRow,
|
|
1525
1814
|
children: [
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
children: entry.maxTokens.toLocaleString("en-US")
|
|
1815
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
|
|
1816
|
+
style: form.kind === "roles" ? S.id : void 0,
|
|
1817
|
+
children: isNew ? "新建" + label : form.kind === "groups" ? form.name || id : id
|
|
1530
1818
|
}),
|
|
1531
|
-
"
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
style: S.glyph,
|
|
1540
|
-
children: [
|
|
1541
|
-
"禁用 ",
|
|
1542
|
-
entry.toolFilter.deny.length,
|
|
1543
|
-
" 项工具"
|
|
1544
|
-
]
|
|
1545
|
-
}),
|
|
1546
|
-
(entry.toolFilter?.allow?.length ?? 0) > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1547
|
-
style: S.glyph,
|
|
1548
|
-
children: [
|
|
1549
|
-
"允许 ",
|
|
1550
|
-
entry.toolFilter.allow.length,
|
|
1551
|
-
" 项工具"
|
|
1819
|
+
dirty && !isNew && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1820
|
+
style: S.dirtyChip,
|
|
1821
|
+
children: "未保存"
|
|
1822
|
+
}),
|
|
1823
|
+
stale && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1824
|
+
style: S.dirtyChip,
|
|
1825
|
+
children: "版本冲突"
|
|
1826
|
+
})
|
|
1552
1827
|
]
|
|
1553
|
-
})
|
|
1554
|
-
]
|
|
1555
|
-
})
|
|
1556
|
-
]
|
|
1557
|
-
}),
|
|
1558
|
-
dirty && !isOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1559
|
-
style: S.draftActions,
|
|
1560
|
-
children: [
|
|
1561
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1562
|
-
style: S.hint,
|
|
1563
|
-
children: "保存后生效"
|
|
1564
|
-
}),
|
|
1565
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { style: S.spacer }),
|
|
1566
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1567
|
-
type: "button",
|
|
1568
|
-
disabled: busy,
|
|
1569
|
-
onClick: (event) => {
|
|
1570
|
-
focusDisclosure(event);
|
|
1571
|
-
revertEntry(id);
|
|
1572
|
-
},
|
|
1573
|
-
style: S.ghost,
|
|
1574
|
-
children: "还原"
|
|
1575
|
-
}),
|
|
1576
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1577
|
-
type: "button",
|
|
1578
|
-
disabled: busy,
|
|
1579
|
-
onClick: (event) => {
|
|
1580
|
-
focusDisclosure(event);
|
|
1581
|
-
updateEntry(id, entry);
|
|
1582
|
-
},
|
|
1583
|
-
style: S.primary,
|
|
1584
|
-
children: "保存修改"
|
|
1585
|
-
})
|
|
1586
|
-
]
|
|
1587
|
-
}),
|
|
1588
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1589
|
-
id: `${sectionId}-${id}`,
|
|
1590
|
-
hidden: !isOpen,
|
|
1591
|
-
children: isOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1592
|
-
style: S.body,
|
|
1593
|
-
children: [
|
|
1594
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1595
|
-
style: S.group,
|
|
1596
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1597
|
-
style: S.groupTitle,
|
|
1598
|
-
children: "概述"
|
|
1599
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1600
|
-
label: "描述(模型可见)",
|
|
1601
|
-
hint: "模型用 list_subagents 读到的就是这句话,写清角色与适用场景",
|
|
1602
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
1603
|
-
value: entry.description ?? "",
|
|
1604
|
-
onChange: (event) => patch(id, { description: event.target.value }),
|
|
1605
|
-
placeholder: "角色描述",
|
|
1606
|
-
rows: 1,
|
|
1607
|
-
style: {
|
|
1608
|
-
...S.prose,
|
|
1609
|
-
overflow: "auto"
|
|
1610
|
-
}
|
|
1611
|
-
})
|
|
1612
1828
|
})]
|
|
1613
|
-
}),
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1829
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1830
|
+
style: S.headToggle,
|
|
1831
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1832
|
+
className: "dsh-library-switch",
|
|
1833
|
+
type: "checkbox",
|
|
1834
|
+
role: "switch",
|
|
1835
|
+
"data-field": "enabled",
|
|
1836
|
+
"aria-label": label + "启用状态",
|
|
1837
|
+
checked: form.enabled,
|
|
1838
|
+
disabled: readonly,
|
|
1839
|
+
onChange: (e) => {
|
|
1840
|
+
change({
|
|
1841
|
+
...form,
|
|
1842
|
+
enabled: e.target.checked
|
|
1843
|
+
});
|
|
1844
|
+
setExpanded((old) => ({
|
|
1845
|
+
...old,
|
|
1846
|
+
[k]: true
|
|
1847
|
+
}));
|
|
1848
|
+
}
|
|
1849
|
+
}), form.enabled ? "已启用" : "已停用"]
|
|
1850
|
+
})]
|
|
1851
|
+
}),
|
|
1852
|
+
!open && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1853
|
+
style: S.overview,
|
|
1854
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1855
|
+
style: S.excerpt,
|
|
1856
|
+
children: form.description || "填写" + label + "的用途。"
|
|
1857
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1858
|
+
style: S.route,
|
|
1859
|
+
children: form.kind === "groups" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1860
|
+
style: S.metaLabel,
|
|
1861
|
+
children: [form.members.length, " 名成员"]
|
|
1862
|
+
}), blocked > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1863
|
+
style: S.dirtyChip,
|
|
1864
|
+
children: [blocked, " 名暂时无法派遣"]
|
|
1865
|
+
})] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1617
1866
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1618
|
-
style: S.
|
|
1619
|
-
children: "
|
|
1867
|
+
style: S.metaLabel,
|
|
1868
|
+
children: "模型"
|
|
1620
1869
|
}),
|
|
1621
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
children: [
|
|
1625
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1626
|
-
label: "Provider",
|
|
1627
|
-
hint: entry.routeNote === "foreign-ignored" ? "共享名册里的路由当前 profile 没有,调用会改用本会话模型。留空保存不会改掉共享路由。" : entry.routeNote === "profile" ? `只保存在 profile ${view.profile ?? ""}` : entry.routeNote === "inherit" ? "本 profile 固定使用会话模型,不跟随共享名册路由" : entry.routeNote === "profile-missing" ? "这个 profile 保存的 Provider 未注册" : void 0,
|
|
1628
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1629
|
-
value: entry.provider ?? "",
|
|
1630
|
-
onChange: (event) => patch(id, { provider: event.target.value }),
|
|
1631
|
-
placeholder: "deepseek-official / kimi-coding",
|
|
1632
|
-
style: S.input
|
|
1633
|
-
})
|
|
1634
|
-
}),
|
|
1635
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1636
|
-
label: "模型",
|
|
1637
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1638
|
-
value: entry.model ?? "",
|
|
1639
|
-
onChange: (event) => patch(id, { model: event.target.value }),
|
|
1640
|
-
placeholder: "k3-256k",
|
|
1641
|
-
style: S.input
|
|
1642
|
-
})
|
|
1643
|
-
}),
|
|
1644
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1645
|
-
label: "传输层",
|
|
1646
|
-
hint: "留空用 spawn",
|
|
1647
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1648
|
-
value: entry.subagentProvider ?? "",
|
|
1649
|
-
onChange: (event) => patch(id, { subagentProvider: event.target.value }),
|
|
1650
|
-
placeholder: "spawn(默认)",
|
|
1651
|
-
style: S.input
|
|
1652
|
-
})
|
|
1653
|
-
}),
|
|
1654
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1655
|
-
label: "后台模式",
|
|
1656
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
1657
|
-
value: entry.backgroundMode ?? "one-shot",
|
|
1658
|
-
onChange: (event) => patch(id, { backgroundMode: event.target.value }),
|
|
1659
|
-
style: S.input,
|
|
1660
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
1661
|
-
value: "one-shot",
|
|
1662
|
-
children: "one-shot"
|
|
1663
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
1664
|
-
value: "continuable",
|
|
1665
|
-
children: "continuable"
|
|
1666
|
-
})]
|
|
1667
|
-
})
|
|
1668
|
-
})
|
|
1669
|
-
]
|
|
1870
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
1871
|
+
style: S.model,
|
|
1872
|
+
children: form.model || "跟随会话"
|
|
1670
1873
|
}),
|
|
1671
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
children: [
|
|
1675
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1676
|
-
label: "思考强度",
|
|
1677
|
-
hint: "留空随父会话默认",
|
|
1678
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1679
|
-
value: entry.reasoningEffort ?? "",
|
|
1680
|
-
onChange: (event) => patch(id, { reasoningEffort: event.target.value === "" ? void 0 : event.target.value.trim() }),
|
|
1681
|
-
placeholder: "max / high / medium / low",
|
|
1682
|
-
style: S.input
|
|
1683
|
-
})
|
|
1684
|
-
}),
|
|
1685
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1686
|
-
label: "深度上限",
|
|
1687
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1688
|
-
type: "number",
|
|
1689
|
-
min: 1,
|
|
1690
|
-
value: entry.maxDepth ?? "",
|
|
1691
|
-
onChange: (event) => patch(id, { maxDepth: event.target.value === "" ? void 0 : Number(event.target.value) }),
|
|
1692
|
-
style: S.input
|
|
1693
|
-
})
|
|
1694
|
-
}),
|
|
1695
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1696
|
-
label: "输出上限",
|
|
1697
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1698
|
-
type: "number",
|
|
1699
|
-
min: 1,
|
|
1700
|
-
value: entry.maxTokens ?? "",
|
|
1701
|
-
onChange: (event) => patch(id, { maxTokens: event.target.value === "" ? void 0 : Number(event.target.value) }),
|
|
1702
|
-
placeholder: "tokens",
|
|
1703
|
-
style: S.input
|
|
1704
|
-
})
|
|
1705
|
-
})
|
|
1706
|
-
]
|
|
1707
|
-
})
|
|
1708
|
-
]
|
|
1709
|
-
}),
|
|
1710
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1711
|
-
style: S.group,
|
|
1712
|
-
children: [
|
|
1713
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1714
|
-
style: S.groupTitle,
|
|
1715
|
-
children: "工具与提示词"
|
|
1874
|
+
form.provider && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
1875
|
+
style: S.provider,
|
|
1876
|
+
children: form.provider
|
|
1716
1877
|
}),
|
|
1717
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1721
|
-
value: listToText(entry.toolFilter?.deny),
|
|
1722
|
-
onChange: (event) => setDeny(id, event.target.value),
|
|
1723
|
-
placeholder: "write, edit, todo_write, …",
|
|
1724
|
-
style: S.input
|
|
1725
|
-
})
|
|
1878
|
+
form.reasoningEffort && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1879
|
+
style: S.glyph,
|
|
1880
|
+
children: ["思考 ", form.reasoningEffort]
|
|
1726
1881
|
}),
|
|
1727
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
1728
|
-
|
|
1729
|
-
children:
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
})
|
|
1882
|
+
refs.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1883
|
+
style: S.glyph,
|
|
1884
|
+
children: [refs.length, " 名编队成员在用"]
|
|
1885
|
+
}),
|
|
1886
|
+
roleState && !isNew && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1887
|
+
style: S.dirtyChip,
|
|
1888
|
+
children: roleState
|
|
1735
1889
|
})
|
|
1736
|
-
]
|
|
1737
|
-
})
|
|
1738
|
-
|
|
1739
|
-
|
|
1890
|
+
] })
|
|
1891
|
+
})]
|
|
1892
|
+
}),
|
|
1893
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1894
|
+
id: contentId,
|
|
1895
|
+
hidden: !open,
|
|
1896
|
+
children: open && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("fieldset", {
|
|
1897
|
+
disabled: readonly,
|
|
1898
|
+
className: "library-editor",
|
|
1899
|
+
style: S.body,
|
|
1740
1900
|
children: [
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1901
|
+
stale && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1902
|
+
role: "alert",
|
|
1903
|
+
style: BANNER.warn,
|
|
1904
|
+
children: [collision ? "这个 ID 已有配置,请更换 ID 再创建。" : "配置已在别处更新,你的草稿已保留。", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: draft.awaitingCurrent ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
|
|
1905
|
+
action: "refresh",
|
|
1906
|
+
onClick: () => void load(true),
|
|
1907
|
+
children: "重新读取当前版本"
|
|
1908
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
|
|
1909
|
+
action: "compare",
|
|
1910
|
+
className: "library-link",
|
|
1911
|
+
onClick: () => compare(id, draft),
|
|
1912
|
+
children: "查看当前版本"
|
|
1913
|
+
}) })]
|
|
1750
1914
|
}),
|
|
1751
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
},
|
|
1760
|
-
|
|
1761
|
-
|
|
1915
|
+
draft.references?.length ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1916
|
+
role: "alert",
|
|
1917
|
+
style: BANNER.warn,
|
|
1918
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(References, {
|
|
1919
|
+
refs: draft.references,
|
|
1920
|
+
view,
|
|
1921
|
+
jump,
|
|
1922
|
+
title: "无法删除,以下编队成员还在使用这个角色"
|
|
1923
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "请给这些成员更换角色,或将他们移出编队后再删除。" })]
|
|
1924
|
+
}) : form.kind === "roles" && draft.message && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1925
|
+
role: "alert",
|
|
1926
|
+
style: BANNER.warn,
|
|
1927
|
+
children: draft.message
|
|
1762
1928
|
}),
|
|
1763
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1929
|
+
form.kind === "roles" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RoleFields, {
|
|
1930
|
+
form,
|
|
1931
|
+
isNew,
|
|
1932
|
+
change,
|
|
1933
|
+
view,
|
|
1934
|
+
refs,
|
|
1935
|
+
jump
|
|
1936
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GroupFields, {
|
|
1937
|
+
form,
|
|
1938
|
+
isNew,
|
|
1939
|
+
change,
|
|
1940
|
+
view,
|
|
1941
|
+
message: draft.message
|
|
1772
1942
|
}),
|
|
1773
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1943
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1944
|
+
style: S.actions,
|
|
1945
|
+
children: [
|
|
1946
|
+
!isNew && current && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Action, {
|
|
1947
|
+
action: "delete",
|
|
1948
|
+
tone: "danger",
|
|
1949
|
+
disabled: stale,
|
|
1950
|
+
onClick: () => remove(id, draft),
|
|
1951
|
+
children: ["删除", label]
|
|
1952
|
+
}),
|
|
1953
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { style: S.spacer }),
|
|
1954
|
+
(dirty || stale) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
|
|
1955
|
+
action: "revert",
|
|
1956
|
+
tone: "ghost",
|
|
1957
|
+
onClick: () => {
|
|
1958
|
+
put(k, void 0);
|
|
1959
|
+
if (isNew) requestAnimationFrame(() => root.current?.querySelector("[data-action=\"new\"]")?.focus());
|
|
1960
|
+
else reveal(id);
|
|
1961
|
+
},
|
|
1962
|
+
children: isNew ? "取消" : "还原草稿"
|
|
1963
|
+
}),
|
|
1964
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
|
|
1965
|
+
action: "save",
|
|
1966
|
+
tone: "primary",
|
|
1967
|
+
disabled: !dirty || stale,
|
|
1968
|
+
onClick: () => {
|
|
1969
|
+
const error = validate(form, view, isNew, draft.base);
|
|
1970
|
+
if (error) {
|
|
1971
|
+
put(k, {
|
|
1972
|
+
...draft,
|
|
1973
|
+
message: error
|
|
1974
|
+
});
|
|
1975
|
+
return;
|
|
1976
|
+
}
|
|
1977
|
+
const impact = form.kind === "roles" && !form.enabled && draft.base?.enabled && refs.length ? ` ${refs.length} 名编队成员暂时无法派遣。` : "";
|
|
1978
|
+
write(saveWrite(draft, view), {
|
|
1979
|
+
id,
|
|
1980
|
+
draft
|
|
1981
|
+
}, `已保存${label} ${form.id.trim()}。${impact}`);
|
|
1982
|
+
},
|
|
1983
|
+
children: isNew ? "创建" + label : "保存修改"
|
|
1984
|
+
})
|
|
1985
|
+
]
|
|
1782
1986
|
})
|
|
1783
1987
|
]
|
|
1784
1988
|
})
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
})
|
|
1788
|
-
]
|
|
1789
|
-
},
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1989
|
+
})
|
|
1990
|
+
]
|
|
1991
|
+
}, k);
|
|
1992
|
+
})]
|
|
1993
|
+
}),
|
|
1994
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
1995
|
+
style: S.footer,
|
|
1996
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", {
|
|
1997
|
+
style: S.footerSummary,
|
|
1998
|
+
children: "存储与备份说明"
|
|
1999
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
2000
|
+
style: S.hint,
|
|
2001
|
+
children: [
|
|
2002
|
+
"角色保存在 ",
|
|
2003
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: view.dir || "~/.dsh/subagents/" }),
|
|
2004
|
+
",编队位于该目录下的 ",
|
|
2005
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: "_groups/" }),
|
|
2006
|
+
"。 备份时一并保留角色文件、编队和 ",
|
|
2007
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: "_profiles/" }),
|
|
2008
|
+
" 中的模型路由。"
|
|
2009
|
+
]
|
|
2010
|
+
})]
|
|
2011
|
+
})
|
|
2012
|
+
]
|
|
1797
2013
|
}),
|
|
1798
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
style: S.footerSummary,
|
|
1802
|
-
children: "存储与备份说明"
|
|
1803
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1804
|
-
style: S.hint,
|
|
1805
|
-
children: [
|
|
1806
|
-
"配置存储于名册目录 ",
|
|
1807
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
1808
|
-
style: { fontFamily: MONO },
|
|
1809
|
-
children: view.dir || "~/.dsh/subagents"
|
|
1810
|
-
}),
|
|
1811
|
-
"(每具名子代理一个 ",
|
|
1812
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: "<id>.yaml" }),
|
|
1813
|
-
",可手编、热生效;",
|
|
1814
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: "_" }),
|
|
1815
|
-
" 前缀的文件/目录为非名册内容,如 ",
|
|
1816
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: "_backups/" }),
|
|
1817
|
-
" 备份区)。 让 agent 修改条目前,建议先把原文件复制到 ",
|
|
1818
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: "_backups/" }),
|
|
1819
|
-
" 里。 settings.yaml 中的旧 entries 仅作迁移兜底读取,文件优先生效。"
|
|
1820
|
-
]
|
|
1821
|
-
})]
|
|
2014
|
+
dialog && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Modal, {
|
|
2015
|
+
dialog,
|
|
2016
|
+
close: () => setDialog(void 0)
|
|
1822
2017
|
})
|
|
1823
2018
|
]
|
|
1824
2019
|
});
|
|
1825
2020
|
}
|
|
1826
2021
|
|
|
2022
|
+
//#endregion
|
|
2023
|
+
//#region src/client/icon.tsx
|
|
2024
|
+
/** Robot-head glyph for the library's settings row. */
|
|
2025
|
+
function LibraryNavIcon({ size = 16 }) {
|
|
2026
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
2027
|
+
viewBox: "0 0 16 16",
|
|
2028
|
+
width: size,
|
|
2029
|
+
height: size,
|
|
2030
|
+
fill: "none",
|
|
2031
|
+
stroke: "currentColor",
|
|
2032
|
+
strokeWidth: 1.2,
|
|
2033
|
+
strokeLinecap: "round",
|
|
2034
|
+
strokeLinejoin: "round",
|
|
2035
|
+
"aria-hidden": "true",
|
|
2036
|
+
children: [
|
|
2037
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M8 6.5V3.9" }),
|
|
2038
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
2039
|
+
cx: "8",
|
|
2040
|
+
cy: "2.6",
|
|
2041
|
+
r: "0.85"
|
|
2042
|
+
}),
|
|
2043
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
|
|
2044
|
+
x: "3.25",
|
|
2045
|
+
y: "6.5",
|
|
2046
|
+
width: "9.5",
|
|
2047
|
+
height: "6.5",
|
|
2048
|
+
rx: "1.5"
|
|
2049
|
+
}),
|
|
2050
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M5.75 9.25v1.25" }),
|
|
2051
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M10.25 9.25v1.25" }),
|
|
2052
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M1.75 9.25h1.5" }),
|
|
2053
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M12.75 9.25h1.5" })
|
|
2054
|
+
]
|
|
2055
|
+
});
|
|
2056
|
+
}
|
|
2057
|
+
|
|
1827
2058
|
//#endregion
|
|
1828
2059
|
//#region src/client/nav-icon.ts
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
* replaces that fallback <svg> inside OUR nav button (matched by our own
|
|
1835
|
-
* registered label text) with the drawn robot-head icon. A MutationObserver
|
|
1836
|
-
* re-applies the icon when the panel re-renders; gated on the settings
|
|
1837
|
-
* dialog being present so idle chat streams never pay the query cost.
|
|
1838
|
-
*/
|
|
1839
|
-
const NAV_ICON_INNER = "<path d=\"M8 6.5V3.9\"/><circle cx=\"8\" cy=\"2.6\" r=\"0.85\"/><rect x=\"3.25\" y=\"6.5\" width=\"9.5\" height=\"6.5\" rx=\"1.5\"/><path d=\"M5.75 9.25v1.25\"/><path d=\"M10.25 9.25v1.25\"/><path d=\"M1.75 9.25h1.5\"/><path d=\"M12.75 9.25h1.5\"/>";
|
|
1840
|
-
const NAV_LABELS = new Set(["子代理库"]);
|
|
1841
|
-
function decorateSettingsNavIcon(ctx) {
|
|
1842
|
-
ctx.effect(() => {
|
|
1843
|
-
const decorate = () => {
|
|
1844
|
-
if (document.querySelector("[role=\"dialog\"]") === null) return;
|
|
1845
|
-
for (const button$1 of Array.from(document.querySelectorAll("button"))) {
|
|
1846
|
-
const label = button$1.querySelector(":scope > span");
|
|
1847
|
-
if (label === null || !NAV_LABELS.has(label.textContent ?? "")) continue;
|
|
1848
|
-
const existing = button$1.firstElementChild;
|
|
1849
|
-
if (existing instanceof SVGElement) {
|
|
1850
|
-
if (existing.dataset.navIcon === "1") continue;
|
|
1851
|
-
const template = document.createElement("template");
|
|
1852
|
-
template.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-nav-icon="1">${NAV_ICON_INNER}</svg>`;
|
|
1853
|
-
existing.replaceWith(template.content.firstElementChild);
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
};
|
|
1857
|
-
const observer = new MutationObserver(() => decorate());
|
|
1858
|
-
observer.observe(document.body, {
|
|
1859
|
-
childList: true,
|
|
1860
|
-
subtree: true
|
|
1861
|
-
});
|
|
1862
|
-
decorate();
|
|
1863
|
-
return () => observer.disconnect();
|
|
1864
|
-
}, "subagent-library: nav icon decoration");
|
|
2060
|
+
function registerSettingsNavIcon(ctx) {
|
|
2061
|
+
ctx.slots.inject("settings.section.icon", () => ctx.slots.register({
|
|
2062
|
+
name: "settings.section.icon",
|
|
2063
|
+
id: "subagent-library"
|
|
2064
|
+
}, LibraryNavIcon));
|
|
1865
2065
|
}
|
|
1866
2066
|
|
|
1867
2067
|
//#endregion
|
|
1868
2068
|
//#region src/client/locales.ts
|
|
1869
2069
|
const zh = {
|
|
1870
2070
|
"settings.title": "子代理库",
|
|
1871
|
-
"settings.hint": "
|
|
2071
|
+
"settings.hint": "管理名册中的角色和编队,为编队成员指定代号与默认分工。",
|
|
1872
2072
|
"settings.empty": "库为空。添加第一个条目开始使用。",
|
|
1873
2073
|
"settings.missing": "未找到 subagent-library 配置段(插件未加载?)。",
|
|
1874
2074
|
"settings.add": "添加",
|
|
1875
|
-
"settings.addNew": "
|
|
2075
|
+
"settings.addNew": "新建角色",
|
|
1876
2076
|
"settings.delete": "删除",
|
|
1877
2077
|
"settings.save": "保存",
|
|
1878
2078
|
"settings.saved": "已保存",
|
|
1879
|
-
"settings.conflict": "
|
|
2079
|
+
"settings.conflict": "配置已在别处更新,你的草稿已保留。查看当前配置后可继续编辑。",
|
|
1880
2080
|
"settings.error": "保存失败:",
|
|
1881
2081
|
"settings.id": "ID",
|
|
1882
2082
|
"settings.description": "描述",
|
|
1883
2083
|
"settings.model": "模型",
|
|
1884
2084
|
"settings.persona": "角色提示词",
|
|
1885
|
-
"settings.toolFilter": "
|
|
2085
|
+
"settings.toolFilter": "旧工具限制",
|
|
1886
2086
|
"settings.maxDepth": "深度上限",
|
|
1887
|
-
"settings.background": "后台模式",
|
|
1888
2087
|
"settings.provider": "Provider",
|
|
1889
|
-
"settings.sourceHint": "
|
|
2088
|
+
"settings.sourceHint": "角色保存在名册目录,编队位于 _groups/,各 profile 的模型路由位于 _profiles/。"
|
|
1890
2089
|
};
|
|
1891
2090
|
const en = {
|
|
1892
2091
|
"settings.title": "Subagent Library",
|
|
1893
|
-
"settings.hint": "Manage
|
|
2092
|
+
"settings.hint": "Manage roles and groups. Give each group member a code and a default assignment.",
|
|
1894
2093
|
"settings.empty": "Library is empty. Add the first entry to get started.",
|
|
1895
2094
|
"settings.missing": "No subagent-library section found (plugin not loaded?).",
|
|
1896
2095
|
"settings.add": "Add",
|
|
1897
|
-
"settings.addNew": "New
|
|
2096
|
+
"settings.addNew": "New role",
|
|
1898
2097
|
"settings.delete": "Delete",
|
|
1899
2098
|
"settings.save": "Save",
|
|
1900
2099
|
"settings.saved": "Saved",
|
|
1901
|
-
"settings.conflict": "
|
|
2100
|
+
"settings.conflict": "Settings changed elsewhere. Your draft is preserved. Review the current settings to continue editing.",
|
|
1902
2101
|
"settings.error": "Save failed: ",
|
|
1903
2102
|
"settings.id": "ID",
|
|
1904
2103
|
"settings.description": "Description",
|
|
1905
2104
|
"settings.model": "Model",
|
|
1906
2105
|
"settings.persona": "Persona",
|
|
1907
|
-
"settings.toolFilter": "
|
|
2106
|
+
"settings.toolFilter": "Legacy tool restrictions",
|
|
1908
2107
|
"settings.maxDepth": "Max depth",
|
|
1909
|
-
"settings.background": "Background",
|
|
1910
2108
|
"settings.provider": "Provider",
|
|
1911
|
-
"settings.sourceHint": "
|
|
2109
|
+
"settings.sourceHint": "Roles are stored in the roster directory, groups in _groups/, and profile model routes in _profiles/."
|
|
1912
2110
|
};
|
|
1913
2111
|
|
|
1914
2112
|
//#endregion
|
|
@@ -1928,7 +2126,10 @@ const ERROR_TEXT = {
|
|
|
1928
2126
|
"unknown-op": "未知操作。",
|
|
1929
2127
|
"roster-unreadable": "名册目录读取失败。",
|
|
1930
2128
|
"write-failed": "名册文件写入失败。",
|
|
1931
|
-
"profile-path": "当前 profile 名称不能保存独立模型路由。"
|
|
2129
|
+
"profile-path": "当前 profile 名称不能保存独立模型路由。",
|
|
2130
|
+
"role-in-use": "有编队成员还在使用这个角色。",
|
|
2131
|
+
"conflict": "配置已在别处更新,你的草稿已保留。",
|
|
2132
|
+
"roster-busy": "名册正在保存其他修改,请稍后再试。"
|
|
1932
2133
|
};
|
|
1933
2134
|
/** Map a wire view onto the UI model. Exported for the wire-contract tests —
|
|
1934
2135
|
* a dropped field here silently kills UI features (k3 review: legacyCount). */
|
|
@@ -1937,9 +2138,13 @@ const parseView = (value) => ({
|
|
|
1937
2138
|
dir: value.dir ?? "",
|
|
1938
2139
|
hash: value.hash ?? "",
|
|
1939
2140
|
entries: value.entries ?? {},
|
|
2141
|
+
sharedEntries: value.sharedEntries ?? {},
|
|
2142
|
+
groups: value.groups ?? {},
|
|
2143
|
+
roleUsages: value.roleUsages ?? {},
|
|
1940
2144
|
diagnostics: value.diagnostics ?? [],
|
|
1941
2145
|
legacyCount: value.legacyCount ?? 0,
|
|
1942
|
-
...typeof value.profile === "string" && value.profile !== "" ? { profile: value.profile } : {}
|
|
2146
|
+
...typeof value.profile === "string" && value.profile !== "" ? { profile: value.profile } : {},
|
|
2147
|
+
...value.routeWriteProblem && { routeWriteProblem: value.routeWriteProblem }
|
|
1943
2148
|
});
|
|
1944
2149
|
async function readView() {
|
|
1945
2150
|
const response = await fetch(API_PATH, { cache: "no-store" });
|
|
@@ -1961,14 +2166,13 @@ async function writeView(write) {
|
|
|
1961
2166
|
});
|
|
1962
2167
|
const body = await response.json();
|
|
1963
2168
|
const wire = typeof body === "object" && body !== null ? body : {};
|
|
1964
|
-
if (response.status === 409) return {
|
|
1965
|
-
ok: false,
|
|
1966
|
-
conflict: true,
|
|
1967
|
-
view: wire.view !== void 0 ? parseView(wire.view) : void 0
|
|
1968
|
-
};
|
|
1969
2169
|
if (!response.ok || wire.ok !== true) return {
|
|
1970
2170
|
ok: false,
|
|
1971
|
-
|
|
2171
|
+
error: wire.error,
|
|
2172
|
+
conflict: response.status === 409 && wire.error === "conflict",
|
|
2173
|
+
message: wire.message?.replace(/^Error:\s*/, "") ?? (wire.error ? ERROR_TEXT[wire.error] : void 0) ?? "保存失败",
|
|
2174
|
+
view: wire.view && parseView(wire.view),
|
|
2175
|
+
references: wire.references
|
|
1972
2176
|
};
|
|
1973
2177
|
return {
|
|
1974
2178
|
ok: true,
|
|
@@ -2017,7 +2221,7 @@ function apply(ctx) {
|
|
|
2017
2221
|
subscribeRefresh
|
|
2018
2222
|
})
|
|
2019
2223
|
}, LibrarySettings));
|
|
2020
|
-
|
|
2224
|
+
registerSettingsNavIcon(ctx);
|
|
2021
2225
|
}
|
|
2022
2226
|
|
|
2023
2227
|
//#endregion
|