dsh-subagent-library 0.2.8 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +88 -0
- package/MIGRATION.md +192 -0
- package/README.en.md +66 -19
- package/README.md +63 -19
- package/lib/client.js +506 -302
- package/lib/index.js +710 -717
- package/package.json +7 -4
package/lib/client.js
CHANGED
|
@@ -29,6 +29,31 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
29
29
|
react_jsx_runtime = __toESM(react_jsx_runtime);
|
|
30
30
|
|
|
31
31
|
//#region src/client/LibrarySettings.tsx
|
|
32
|
+
/** Content-adaptive textarea: grows with its text (clamped) so long personas
|
|
33
|
+
* are readable without dragging while short ones stay compact. Re-measures
|
|
34
|
+
* after every render (value changes re-render) and on input. */
|
|
35
|
+
function AutoTextarea(props) {
|
|
36
|
+
const { style,...rest } = props;
|
|
37
|
+
const ref = (0, react.useRef)(null);
|
|
38
|
+
const resize = () => {
|
|
39
|
+
const el = ref.current;
|
|
40
|
+
if (el === null) return;
|
|
41
|
+
el.style.height = "auto";
|
|
42
|
+
el.style.height = `${Math.min(Math.max(el.scrollHeight, 110), 440)}px`;
|
|
43
|
+
};
|
|
44
|
+
(0, react.useEffect)(() => {
|
|
45
|
+
resize();
|
|
46
|
+
});
|
|
47
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
48
|
+
...rest,
|
|
49
|
+
ref,
|
|
50
|
+
onInput: resize,
|
|
51
|
+
style: {
|
|
52
|
+
...style,
|
|
53
|
+
overflow: "auto"
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
32
57
|
function LibrarySettings(props) {
|
|
33
58
|
const { readView: readView$1, writeView: writeView$1, subscribeRefresh } = props;
|
|
34
59
|
const [view, setView] = (0, react.useState)(null);
|
|
@@ -48,24 +73,16 @@ function LibrarySettings(props) {
|
|
|
48
73
|
(0, react.useEffect)(() => () => {
|
|
49
74
|
alive.current = false;
|
|
50
75
|
}, []);
|
|
51
|
-
/** Revision of the last committed server state (successful write or load).
|
|
52
|
-
* document-updated pushes at or below it are our own write's echo and are
|
|
53
|
-
* skipped — applyWrite already merged the touched row, and a full reload
|
|
54
|
-
* here would wipe unsaved drafts in other rows. External pushes (higher
|
|
55
|
-
* revisions) still reload. */
|
|
56
|
-
const lastCommitted = (0, react.useRef)(null);
|
|
57
76
|
/** True while a write request is in flight: the push and the HTTP response
|
|
58
77
|
* travel on independent channels, so a push may arrive before the response
|
|
59
|
-
* commits our state.
|
|
60
|
-
* skipped revision is re-checked after the response. */
|
|
78
|
+
* commits our state. Pushes in this window are skipped and re-run after. */
|
|
61
79
|
const pendingSelfWrite = (0, react.useRef)(false);
|
|
62
|
-
const skippedWhilePending = (0, react.useRef)(
|
|
80
|
+
const skippedWhilePending = (0, react.useRef)(false);
|
|
63
81
|
const load = () => {
|
|
64
82
|
(async () => {
|
|
65
83
|
try {
|
|
66
84
|
const next = await readView$1();
|
|
67
85
|
if (!alive.current) return;
|
|
68
|
-
lastCommitted.current = next.revision;
|
|
69
86
|
setView(next);
|
|
70
87
|
setEntries(structuredClone(next.entries));
|
|
71
88
|
} catch (error) {
|
|
@@ -78,12 +95,11 @@ function LibrarySettings(props) {
|
|
|
78
95
|
};
|
|
79
96
|
(0, react.useEffect)(() => {
|
|
80
97
|
load();
|
|
81
|
-
return subscribeRefresh((
|
|
98
|
+
return subscribeRefresh(() => {
|
|
82
99
|
if (pendingSelfWrite.current) {
|
|
83
|
-
|
|
100
|
+
skippedWhilePending.current = true;
|
|
84
101
|
return;
|
|
85
102
|
}
|
|
86
|
-
if (revision !== void 0 && lastCommitted.current !== null && revision <= lastCommitted.current) return;
|
|
87
103
|
load();
|
|
88
104
|
});
|
|
89
105
|
}, [subscribeRefresh]);
|
|
@@ -98,9 +114,8 @@ function LibrarySettings(props) {
|
|
|
98
114
|
if (!alive.current) return false;
|
|
99
115
|
pendingSelfWrite.current = false;
|
|
100
116
|
const skipped = skippedWhilePending.current;
|
|
101
|
-
skippedWhilePending.current =
|
|
117
|
+
skippedWhilePending.current = false;
|
|
102
118
|
if (result.ok) {
|
|
103
|
-
lastCommitted.current = result.view.revision;
|
|
104
119
|
setView(result.view);
|
|
105
120
|
setEntries((current) => {
|
|
106
121
|
const next = { ...current };
|
|
@@ -113,18 +128,19 @@ function LibrarySettings(props) {
|
|
|
113
128
|
kind: "ok",
|
|
114
129
|
text: "已保存"
|
|
115
130
|
});
|
|
116
|
-
if (skipped
|
|
131
|
+
if (skipped) load();
|
|
117
132
|
return true;
|
|
118
133
|
}
|
|
119
|
-
skippedWhilePending.current =
|
|
134
|
+
skippedWhilePending.current = false;
|
|
120
135
|
if (result.conflict) {
|
|
136
|
+
if (result.view !== void 0) setView(result.view);
|
|
137
|
+
else load();
|
|
121
138
|
setStatus({
|
|
122
139
|
kind: "error",
|
|
123
|
-
text: "
|
|
140
|
+
text: "名册已被其他窗口或外部修改(已切换到最新基线)。你的未保存修改已保留;再次保存将以你的版本覆盖。"
|
|
124
141
|
});
|
|
125
|
-
load();
|
|
126
142
|
} else {
|
|
127
|
-
if (skipped
|
|
143
|
+
if (skipped) load();
|
|
128
144
|
setStatus({
|
|
129
145
|
kind: "error",
|
|
130
146
|
text: result.message ?? "保存失败"
|
|
@@ -144,9 +160,12 @@ function LibrarySettings(props) {
|
|
|
144
160
|
* only shows deny. */
|
|
145
161
|
const cleanEntry = (entry) => {
|
|
146
162
|
const clean = { ...entry };
|
|
163
|
+
delete clean.source;
|
|
164
|
+
if (clean.enabled === void 0 || clean.enabled) delete clean.enabled;
|
|
147
165
|
if (clean.provider === "") delete clean.provider;
|
|
148
166
|
if (clean.model === "") delete clean.model;
|
|
149
167
|
if (clean.subagentProvider === "") delete clean.subagentProvider;
|
|
168
|
+
if (clean.reasoningEffort === "") delete clean.reasoningEffort;
|
|
150
169
|
if (clean.persona === "") delete clean.persona;
|
|
151
170
|
if (clean.description === "") delete clean.description;
|
|
152
171
|
if (clean.maxDepth === void 0) delete clean.maxDepth;
|
|
@@ -183,15 +202,15 @@ function LibrarySettings(props) {
|
|
|
183
202
|
...view?.entries ?? {},
|
|
184
203
|
[id]: cleanEntry(entry)
|
|
185
204
|
},
|
|
186
|
-
|
|
205
|
+
expectedHash: view?.hash
|
|
187
206
|
}, id);
|
|
188
207
|
};
|
|
189
208
|
const removeEntry = (id) => {
|
|
190
|
-
if (!window.confirm(`确认删除子代理 "${id}"
|
|
209
|
+
if (!window.confirm(`确认删除子代理 "${id}"?该操作立即删除其名册文件。`)) return;
|
|
191
210
|
applyWrite({
|
|
192
211
|
op: "delete",
|
|
193
212
|
id,
|
|
194
|
-
|
|
213
|
+
expectedHash: view?.hash
|
|
195
214
|
}, id);
|
|
196
215
|
};
|
|
197
216
|
const addEntry = () => {
|
|
@@ -231,7 +250,7 @@ function LibrarySettings(props) {
|
|
|
231
250
|
...serverEntries,
|
|
232
251
|
[id]: cleanEntry(newEntry)
|
|
233
252
|
},
|
|
234
|
-
|
|
253
|
+
expectedHash: view?.hash
|
|
235
254
|
}, id).then((ok) => {
|
|
236
255
|
if (alive.current && ok) {
|
|
237
256
|
setNewId("");
|
|
@@ -244,156 +263,254 @@ function LibrarySettings(props) {
|
|
|
244
263
|
}
|
|
245
264
|
});
|
|
246
265
|
};
|
|
266
|
+
const rootStyle = {
|
|
267
|
+
display: "flex",
|
|
268
|
+
flexDirection: "column",
|
|
269
|
+
gap: 14,
|
|
270
|
+
maxWidth: 860,
|
|
271
|
+
padding: "12px 4px"
|
|
272
|
+
};
|
|
273
|
+
const headingStyle = {
|
|
274
|
+
fontSize: 15,
|
|
275
|
+
fontWeight: 600,
|
|
276
|
+
margin: 0
|
|
277
|
+
};
|
|
278
|
+
const subStyle = {
|
|
279
|
+
fontSize: 12.5,
|
|
280
|
+
opacity: .7,
|
|
281
|
+
margin: 0
|
|
282
|
+
};
|
|
247
283
|
const rowStyle = {
|
|
248
284
|
display: "flex",
|
|
249
285
|
alignItems: "center",
|
|
250
|
-
gap:
|
|
286
|
+
gap: 8,
|
|
287
|
+
flexWrap: "wrap"
|
|
251
288
|
};
|
|
252
289
|
/** Shrinkable multi-column row: min-width 0 lets inputs shrink below their
|
|
253
290
|
* intrinsic width instead of overflowing the settings card (form controls
|
|
254
291
|
* otherwise keep their default width as a flex minimum). */
|
|
255
292
|
const colStyle = {
|
|
256
|
-
|
|
293
|
+
display: "flex",
|
|
294
|
+
alignItems: "center",
|
|
295
|
+
gap: 8,
|
|
257
296
|
flex: 1,
|
|
258
297
|
minWidth: 0
|
|
259
298
|
};
|
|
299
|
+
/** Content-width column for FIXED-width controls (number input, select):
|
|
300
|
+
* flex-basis-0 columns ignore their children when distributing width, and
|
|
301
|
+
* an overflowing visible-box child paints over the neighbor. */
|
|
302
|
+
const fixedColStyle = {
|
|
303
|
+
display: "flex",
|
|
304
|
+
alignItems: "center",
|
|
305
|
+
gap: 8
|
|
306
|
+
};
|
|
260
307
|
const labelStyle = {
|
|
261
|
-
fontSize:
|
|
262
|
-
opacity: .
|
|
308
|
+
fontSize: 13,
|
|
309
|
+
opacity: .75,
|
|
263
310
|
minWidth: "72px"
|
|
264
311
|
};
|
|
265
312
|
const inputStyle = {
|
|
266
313
|
flex: 1,
|
|
267
314
|
minWidth: 0,
|
|
268
|
-
fontSize:
|
|
269
|
-
fontFamily: "monospace",
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
315
|
+
fontSize: 13,
|
|
316
|
+
fontFamily: "Consolas, Menlo, monospace",
|
|
317
|
+
lineHeight: 1.5,
|
|
318
|
+
padding: "5px 8px",
|
|
319
|
+
border: "1px solid rgba(128,128,128,0.4)",
|
|
320
|
+
borderRadius: 6,
|
|
273
321
|
background: "transparent",
|
|
274
322
|
color: "inherit"
|
|
275
323
|
};
|
|
324
|
+
/** Prose fields (description, persona) use the UI font at a readable size —
|
|
325
|
+
* long Chinese text in small monospace was the readability complaint. */
|
|
326
|
+
const proseStyle = {
|
|
327
|
+
...inputStyle,
|
|
328
|
+
fontFamily: "inherit",
|
|
329
|
+
fontSize: 13.5,
|
|
330
|
+
lineHeight: 1.6
|
|
331
|
+
};
|
|
332
|
+
/** Persona editor: adaptive height comes from AutoTextarea (110–440px by
|
|
333
|
+
* content); the style only carries font/border. */
|
|
334
|
+
const textareaStyle = {
|
|
335
|
+
...proseStyle,
|
|
336
|
+
resize: "vertical",
|
|
337
|
+
whiteSpace: "pre-wrap",
|
|
338
|
+
overflowWrap: "anywhere"
|
|
339
|
+
};
|
|
276
340
|
const buttonStyle = {
|
|
277
|
-
padding: "
|
|
278
|
-
fontSize:
|
|
341
|
+
padding: "4px 12px",
|
|
342
|
+
fontSize: 12.5,
|
|
343
|
+
borderRadius: 6,
|
|
344
|
+
border: "1px solid rgba(128,128,128,0.4)",
|
|
345
|
+
background: "transparent",
|
|
346
|
+
color: "inherit",
|
|
279
347
|
cursor: "pointer",
|
|
280
348
|
opacity: busy ? .55 : 1
|
|
281
349
|
};
|
|
350
|
+
const primaryStyle = {
|
|
351
|
+
...buttonStyle,
|
|
352
|
+
border: "1px solid transparent",
|
|
353
|
+
background: "rgba(59,130,246,0.9)",
|
|
354
|
+
color: "#fff"
|
|
355
|
+
};
|
|
356
|
+
const dangerStyle = {
|
|
357
|
+
...buttonStyle,
|
|
358
|
+
border: "1px solid rgba(220,38,38,0.55)"
|
|
359
|
+
};
|
|
360
|
+
const chipStyle = {
|
|
361
|
+
display: "inline-flex",
|
|
362
|
+
alignItems: "center",
|
|
363
|
+
padding: "1px 8px",
|
|
364
|
+
fontSize: 11,
|
|
365
|
+
borderRadius: 999,
|
|
366
|
+
border: "1px solid rgba(128,128,128,0.45)",
|
|
367
|
+
opacity: .8
|
|
368
|
+
};
|
|
282
369
|
const cardStyle = {
|
|
283
370
|
display: "flex",
|
|
284
371
|
flexDirection: "column",
|
|
285
|
-
gap:
|
|
286
|
-
padding:
|
|
287
|
-
border: "1px solid
|
|
288
|
-
borderRadius:
|
|
372
|
+
gap: 8,
|
|
373
|
+
padding: 12,
|
|
374
|
+
border: "1px solid rgba(128,128,128,0.35)",
|
|
375
|
+
borderRadius: 8
|
|
289
376
|
};
|
|
290
377
|
const hintStyle = {
|
|
291
|
-
fontSize:
|
|
378
|
+
fontSize: 11.5,
|
|
292
379
|
opacity: .6,
|
|
293
|
-
|
|
380
|
+
margin: 0
|
|
381
|
+
};
|
|
382
|
+
const bannerStyle = {
|
|
383
|
+
fontSize: 12,
|
|
384
|
+
padding: "6px 10px",
|
|
385
|
+
borderRadius: 6,
|
|
386
|
+
display: "flex",
|
|
387
|
+
flexDirection: "column",
|
|
388
|
+
gap: 2
|
|
389
|
+
};
|
|
390
|
+
const okBannerStyle = {
|
|
391
|
+
...bannerStyle,
|
|
392
|
+
background: "rgba(22,163,74,0.12)",
|
|
393
|
+
border: "1px solid rgba(22,163,74,0.4)"
|
|
394
|
+
};
|
|
395
|
+
const errorBannerStyle = {
|
|
396
|
+
...bannerStyle,
|
|
397
|
+
background: "rgba(220,38,38,0.12)",
|
|
398
|
+
border: "1px solid rgba(220,38,38,0.45)",
|
|
399
|
+
color: "inherit"
|
|
400
|
+
};
|
|
401
|
+
const warnBannerStyle = {
|
|
402
|
+
...bannerStyle,
|
|
403
|
+
background: "rgba(217,119,6,0.14)",
|
|
404
|
+
border: "1px solid rgba(217,119,6,0.45)"
|
|
405
|
+
};
|
|
406
|
+
const infoBannerStyle = {
|
|
407
|
+
...bannerStyle,
|
|
408
|
+
background: "rgba(128,128,128,0.12)",
|
|
409
|
+
border: "1px solid rgba(128,128,128,0.35)"
|
|
294
410
|
};
|
|
295
411
|
if (view === null) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
296
|
-
style:
|
|
297
|
-
display: "flex",
|
|
298
|
-
flexDirection: "column",
|
|
299
|
-
gap: "8px",
|
|
300
|
-
padding: "12px 4px"
|
|
301
|
-
},
|
|
412
|
+
style: rootStyle,
|
|
302
413
|
children: [
|
|
303
414
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
304
415
|
style: {
|
|
305
416
|
display: "flex",
|
|
306
417
|
alignItems: "center",
|
|
307
|
-
gap:
|
|
418
|
+
gap: 10
|
|
308
419
|
},
|
|
309
420
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
310
|
-
style:
|
|
311
|
-
fontSize: "15px",
|
|
312
|
-
fontWeight: 600
|
|
313
|
-
},
|
|
421
|
+
style: headingStyle,
|
|
314
422
|
children: "子代理库"
|
|
315
423
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
316
424
|
type: "button",
|
|
317
425
|
onClick: load,
|
|
318
|
-
style:
|
|
319
|
-
...buttonStyle,
|
|
320
|
-
opacity: .7
|
|
321
|
-
},
|
|
426
|
+
style: buttonStyle,
|
|
322
427
|
children: "重试"
|
|
323
428
|
})]
|
|
324
429
|
}),
|
|
325
430
|
status !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
326
|
-
style:
|
|
327
|
-
fontSize: "12px",
|
|
328
|
-
color: status.kind === "ok" ? "var(--dsh-color-success, #30a46c)" : "var(--dsh-color-danger, #e5484d)",
|
|
329
|
-
whiteSpace: "pre-wrap"
|
|
330
|
-
},
|
|
431
|
+
style: status.kind === "ok" ? okBannerStyle : errorBannerStyle,
|
|
331
432
|
children: status.text
|
|
332
433
|
}),
|
|
333
434
|
status === null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
334
|
-
style:
|
|
335
|
-
fontSize: "13px",
|
|
336
|
-
opacity: .8
|
|
337
|
-
},
|
|
435
|
+
style: subStyle,
|
|
338
436
|
children: "正在加载…(若长时间无响应,请重试或检查插件是否加载)"
|
|
339
437
|
})
|
|
340
438
|
]
|
|
341
439
|
});
|
|
342
440
|
const ids = Object.keys(entries);
|
|
343
441
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
344
|
-
style:
|
|
345
|
-
display: "flex",
|
|
346
|
-
flexDirection: "column",
|
|
347
|
-
gap: "10px",
|
|
348
|
-
padding: "12px 4px",
|
|
349
|
-
maxWidth: "720px"
|
|
350
|
-
},
|
|
442
|
+
style: rootStyle,
|
|
351
443
|
children: [
|
|
352
444
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
353
445
|
style: {
|
|
354
446
|
display: "flex",
|
|
355
447
|
flexDirection: "column",
|
|
356
|
-
gap:
|
|
448
|
+
gap: 2
|
|
357
449
|
},
|
|
358
450
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
359
451
|
style: {
|
|
360
452
|
display: "flex",
|
|
361
453
|
alignItems: "center",
|
|
362
|
-
gap:
|
|
454
|
+
gap: 10
|
|
363
455
|
},
|
|
364
456
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
365
|
-
style:
|
|
366
|
-
fontSize: "15px",
|
|
367
|
-
fontWeight: 600
|
|
368
|
-
},
|
|
457
|
+
style: headingStyle,
|
|
369
458
|
children: "子代理库"
|
|
370
459
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
371
460
|
type: "button",
|
|
372
461
|
onClick: load,
|
|
373
|
-
style:
|
|
374
|
-
...buttonStyle,
|
|
375
|
-
opacity: .7
|
|
376
|
-
},
|
|
462
|
+
style: buttonStyle,
|
|
377
463
|
children: "刷新"
|
|
378
464
|
})]
|
|
379
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.
|
|
380
|
-
style:
|
|
381
|
-
children:
|
|
465
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
466
|
+
style: subStyle,
|
|
467
|
+
children: [
|
|
468
|
+
"管理具名角色子代理(每条目一个 YAML 文件,保存即热生效)。让 agent 修改条目前,建议先把原文件复制到名册目录的 ",
|
|
469
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: "_backups/" }),
|
|
470
|
+
" 里。"
|
|
471
|
+
]
|
|
382
472
|
})]
|
|
383
473
|
}),
|
|
384
|
-
|
|
385
|
-
style:
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
474
|
+
(view.diagnostics?.length ?? 0) > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
475
|
+
style: warnBannerStyle,
|
|
476
|
+
children: view.diagnostics.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
477
|
+
style: {
|
|
478
|
+
fontWeight: item.severity === "error" ? 600 : 400,
|
|
479
|
+
opacity: item.severity === "info" ? .75 : 1
|
|
480
|
+
},
|
|
481
|
+
children: [
|
|
482
|
+
item.severity === "error" ? "错误" : item.severity === "warning" ? "警告" : "提示",
|
|
483
|
+
item.id !== void 0 ? ` [${item.id}]` : "",
|
|
484
|
+
":",
|
|
485
|
+
item.message
|
|
486
|
+
]
|
|
487
|
+
}, index))
|
|
488
|
+
}),
|
|
489
|
+
(view.legacyCount ?? 0) > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
490
|
+
style: infoBannerStyle,
|
|
491
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
492
|
+
"0.2→0.3 迁移:",
|
|
493
|
+
view.legacyCount,
|
|
494
|
+
" 个旧条目已导出为名册文件并优先生效,settings.yaml 中的旧副本仍在(仅作回滚兜底)。确认名册正常后可一键清除。"
|
|
495
|
+
] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
496
|
+
type: "button",
|
|
497
|
+
disabled: busy,
|
|
498
|
+
onClick: () => {
|
|
499
|
+
if (window.confirm("确认清除 settings.yaml 中已迁移的旧条目副本?(名册文件不受影响)")) applyWrite({
|
|
500
|
+
op: "clear-legacy",
|
|
501
|
+
expectedHash: view?.hash
|
|
502
|
+
}, "");
|
|
503
|
+
},
|
|
504
|
+
style: {
|
|
505
|
+
...buttonStyle,
|
|
506
|
+
alignSelf: "flex-start"
|
|
507
|
+
},
|
|
508
|
+
children: "清除旧条目"
|
|
509
|
+
})]
|
|
390
510
|
}),
|
|
391
511
|
ids.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
392
|
-
style:
|
|
393
|
-
|
|
394
|
-
opacity: .8
|
|
395
|
-
},
|
|
396
|
-
children: "库为空。添加第一个条目开始使用。"
|
|
512
|
+
style: subStyle,
|
|
513
|
+
children: "库为空。添加第一个条目开始使用,或在名册目录放一个 <id>.yaml。"
|
|
397
514
|
}),
|
|
398
515
|
ids.map((id) => {
|
|
399
516
|
const entry = entries[id];
|
|
@@ -404,20 +521,30 @@ function LibrarySettings(props) {
|
|
|
404
521
|
style: {
|
|
405
522
|
display: "flex",
|
|
406
523
|
alignItems: "center",
|
|
407
|
-
gap:
|
|
524
|
+
gap: 10,
|
|
525
|
+
flexWrap: "wrap"
|
|
408
526
|
},
|
|
409
527
|
children: [
|
|
410
528
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
411
529
|
style: {
|
|
412
|
-
fontSize:
|
|
530
|
+
fontSize: 13,
|
|
413
531
|
fontWeight: 600,
|
|
414
|
-
fontFamily: "monospace"
|
|
532
|
+
fontFamily: "Consolas, Menlo, monospace",
|
|
533
|
+
opacity: entry.enabled === false ? .5 : 1
|
|
415
534
|
},
|
|
416
535
|
children: id
|
|
417
536
|
}),
|
|
537
|
+
entry.source === "legacy" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
538
|
+
style: chipStyle,
|
|
539
|
+
children: "legacy"
|
|
540
|
+
}),
|
|
541
|
+
entry.enabled === false && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
542
|
+
style: chipStyle,
|
|
543
|
+
children: "已停用"
|
|
544
|
+
}),
|
|
418
545
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
419
546
|
style: {
|
|
420
|
-
fontSize:
|
|
547
|
+
fontSize: 11.5,
|
|
421
548
|
opacity: .7
|
|
422
549
|
},
|
|
423
550
|
children: [
|
|
@@ -430,18 +557,38 @@ function LibrarySettings(props) {
|
|
|
430
557
|
]
|
|
431
558
|
}),
|
|
432
559
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { style: { flex: 1 } }),
|
|
560
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
561
|
+
style: {
|
|
562
|
+
fontSize: 12.5,
|
|
563
|
+
display: "flex",
|
|
564
|
+
alignItems: "center",
|
|
565
|
+
gap: 4,
|
|
566
|
+
cursor: "pointer"
|
|
567
|
+
},
|
|
568
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
569
|
+
type: "checkbox",
|
|
570
|
+
checked: entry.enabled !== false,
|
|
571
|
+
onChange: (event) => setEntries({
|
|
572
|
+
...entries,
|
|
573
|
+
[id]: {
|
|
574
|
+
...entry,
|
|
575
|
+
enabled: event.target.checked ? void 0 : false
|
|
576
|
+
}
|
|
577
|
+
})
|
|
578
|
+
}), "启用"]
|
|
579
|
+
}),
|
|
433
580
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
434
581
|
type: "button",
|
|
435
|
-
disabled: busy
|
|
582
|
+
disabled: busy,
|
|
436
583
|
onClick: () => removeEntry(id),
|
|
437
|
-
style:
|
|
584
|
+
style: dangerStyle,
|
|
438
585
|
children: "删除"
|
|
439
586
|
}),
|
|
440
587
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
441
588
|
type: "button",
|
|
442
|
-
disabled: busy
|
|
589
|
+
disabled: busy,
|
|
443
590
|
onClick: () => updateEntry(id, entry),
|
|
444
|
-
style:
|
|
591
|
+
style: primaryStyle,
|
|
445
592
|
children: "保存"
|
|
446
593
|
})
|
|
447
594
|
]
|
|
@@ -451,7 +598,7 @@ function LibrarySettings(props) {
|
|
|
451
598
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
452
599
|
style: labelStyle,
|
|
453
600
|
children: "描述"
|
|
454
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
601
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
455
602
|
value: entry.description ?? "",
|
|
456
603
|
onChange: (event) => setEntries({
|
|
457
604
|
...entries,
|
|
@@ -460,8 +607,15 @@ function LibrarySettings(props) {
|
|
|
460
607
|
description: event.target.value
|
|
461
608
|
}
|
|
462
609
|
}),
|
|
463
|
-
placeholder: "
|
|
464
|
-
|
|
610
|
+
placeholder: "角色描述(模型可见,可拖右下角展开)",
|
|
611
|
+
rows: 1,
|
|
612
|
+
style: {
|
|
613
|
+
...proseStyle,
|
|
614
|
+
resize: "vertical",
|
|
615
|
+
whiteSpace: "pre-wrap",
|
|
616
|
+
overflowWrap: "anywhere",
|
|
617
|
+
overflow: "auto"
|
|
618
|
+
}
|
|
465
619
|
})]
|
|
466
620
|
}),
|
|
467
621
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -530,7 +684,7 @@ function LibrarySettings(props) {
|
|
|
530
684
|
style: inputStyle
|
|
531
685
|
})]
|
|
532
686
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
533
|
-
style:
|
|
687
|
+
style: fixedColStyle,
|
|
534
688
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
535
689
|
style: labelStyle,
|
|
536
690
|
children: "输出上限"
|
|
@@ -548,7 +702,8 @@ function LibrarySettings(props) {
|
|
|
548
702
|
placeholder: "tokens",
|
|
549
703
|
style: {
|
|
550
704
|
...inputStyle,
|
|
551
|
-
|
|
705
|
+
flex: "none",
|
|
706
|
+
width: 116
|
|
552
707
|
}
|
|
553
708
|
})]
|
|
554
709
|
})]
|
|
@@ -559,92 +714,118 @@ function LibrarySettings(props) {
|
|
|
559
714
|
flexWrap: "wrap",
|
|
560
715
|
gap: "8px"
|
|
561
716
|
},
|
|
562
|
-
children: [
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
maxDepth: event.target.value === "" ? void 0 : Number(event.target.value)
|
|
577
|
-
}
|
|
578
|
-
}),
|
|
579
|
-
style: {
|
|
580
|
-
...inputStyle,
|
|
581
|
-
maxWidth: "80px"
|
|
717
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
718
|
+
style: fixedColStyle,
|
|
719
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
720
|
+
style: labelStyle,
|
|
721
|
+
children: "深度上限"
|
|
722
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
723
|
+
type: "number",
|
|
724
|
+
min: 1,
|
|
725
|
+
value: entry.maxDepth ?? "",
|
|
726
|
+
onChange: (event) => setEntries({
|
|
727
|
+
...entries,
|
|
728
|
+
[id]: {
|
|
729
|
+
...entry,
|
|
730
|
+
maxDepth: event.target.value === "" ? void 0 : Number(event.target.value)
|
|
582
731
|
}
|
|
583
|
-
})
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
732
|
+
}),
|
|
733
|
+
style: {
|
|
734
|
+
...inputStyle,
|
|
735
|
+
flex: "none",
|
|
736
|
+
width: 84
|
|
737
|
+
}
|
|
738
|
+
})]
|
|
739
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
740
|
+
style: {
|
|
741
|
+
...colStyle,
|
|
742
|
+
flex: 1
|
|
743
|
+
},
|
|
744
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
745
|
+
style: labelStyle,
|
|
746
|
+
children: "禁用工具"
|
|
747
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
748
|
+
value: (entry.toolFilter?.deny ?? []).join(", "),
|
|
749
|
+
onChange: (event) => {
|
|
750
|
+
const deny = event.target.value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
751
|
+
const allow = entry.toolFilter?.allow;
|
|
752
|
+
setEntries({
|
|
593
753
|
...entries,
|
|
594
754
|
[id]: {
|
|
595
755
|
...entry,
|
|
596
|
-
|
|
756
|
+
toolFilter: allow !== void 0 && allow.length > 0 || deny.length > 0 ? {
|
|
757
|
+
...allow !== void 0 && allow.length > 0 ? { allow } : {},
|
|
758
|
+
...deny.length > 0 ? { deny } : {}
|
|
759
|
+
} : void 0
|
|
597
760
|
}
|
|
598
|
-
})
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
761
|
+
});
|
|
762
|
+
},
|
|
763
|
+
placeholder: "write, edit, todo_write, …",
|
|
764
|
+
style: inputStyle
|
|
765
|
+
})]
|
|
766
|
+
})]
|
|
767
|
+
}),
|
|
768
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
769
|
+
style: {
|
|
770
|
+
display: "flex",
|
|
771
|
+
flexWrap: "wrap",
|
|
772
|
+
gap: "8px"
|
|
773
|
+
},
|
|
774
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
775
|
+
style: {
|
|
776
|
+
...colStyle,
|
|
777
|
+
flex: 1
|
|
778
|
+
},
|
|
779
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
780
|
+
style: labelStyle,
|
|
781
|
+
children: "思考强度"
|
|
782
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
783
|
+
value: entry.reasoningEffort ?? "",
|
|
784
|
+
onChange: (event) => setEntries({
|
|
785
|
+
...entries,
|
|
786
|
+
[id]: {
|
|
787
|
+
...entry,
|
|
788
|
+
reasoningEffort: event.target.value === "" ? void 0 : event.target.value.trim()
|
|
789
|
+
}
|
|
790
|
+
}),
|
|
791
|
+
placeholder: "如 max / high / medium / low(留空随父会话默认)",
|
|
792
|
+
style: inputStyle
|
|
793
|
+
})]
|
|
794
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
795
|
+
style: fixedColStyle,
|
|
796
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
797
|
+
style: labelStyle,
|
|
798
|
+
children: "后台模式"
|
|
799
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
800
|
+
value: entry.backgroundMode ?? "one-shot",
|
|
801
|
+
onChange: (event) => setEntries({
|
|
802
|
+
...entries,
|
|
803
|
+
[id]: {
|
|
804
|
+
...entry,
|
|
805
|
+
backgroundMode: event.target.value
|
|
806
|
+
}
|
|
807
|
+
}),
|
|
613
808
|
style: {
|
|
614
|
-
...
|
|
615
|
-
flex:
|
|
809
|
+
...inputStyle,
|
|
810
|
+
flex: "none",
|
|
811
|
+
width: 132
|
|
616
812
|
},
|
|
617
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
618
|
-
|
|
619
|
-
children: "
|
|
620
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
621
|
-
value:
|
|
622
|
-
|
|
623
|
-
const deny = event.target.value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
624
|
-
const allow = entry.toolFilter?.allow;
|
|
625
|
-
setEntries({
|
|
626
|
-
...entries,
|
|
627
|
-
[id]: {
|
|
628
|
-
...entry,
|
|
629
|
-
toolFilter: allow !== void 0 && allow.length > 0 || deny.length > 0 ? {
|
|
630
|
-
...allow !== void 0 && allow.length > 0 ? { allow } : {},
|
|
631
|
-
...deny.length > 0 ? { deny } : {}
|
|
632
|
-
} : void 0
|
|
633
|
-
}
|
|
634
|
-
});
|
|
635
|
-
},
|
|
636
|
-
placeholder: "write, edit, todo_write, …",
|
|
637
|
-
style: inputStyle
|
|
813
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
814
|
+
value: "one-shot",
|
|
815
|
+
children: "one-shot"
|
|
816
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
817
|
+
value: "continuable",
|
|
818
|
+
children: "continuable"
|
|
638
819
|
})]
|
|
639
|
-
})
|
|
640
|
-
]
|
|
820
|
+
})]
|
|
821
|
+
})]
|
|
641
822
|
}),
|
|
642
823
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
643
824
|
style: rowStyle,
|
|
644
825
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
645
826
|
style: labelStyle,
|
|
646
827
|
children: "角色提示词"
|
|
647
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
828
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AutoTextarea, {
|
|
648
829
|
value: entry.persona ?? "",
|
|
649
830
|
onChange: (event) => setEntries({
|
|
650
831
|
...entries,
|
|
@@ -654,12 +835,7 @@ function LibrarySettings(props) {
|
|
|
654
835
|
}
|
|
655
836
|
}),
|
|
656
837
|
placeholder: "子代理的系统提示词(可选)",
|
|
657
|
-
|
|
658
|
-
style: {
|
|
659
|
-
...inputStyle,
|
|
660
|
-
resize: "vertical",
|
|
661
|
-
fontFamily: "inherit"
|
|
662
|
-
}
|
|
838
|
+
style: textareaStyle
|
|
663
839
|
})]
|
|
664
840
|
})
|
|
665
841
|
]
|
|
@@ -677,7 +853,7 @@ function LibrarySettings(props) {
|
|
|
677
853
|
children: [
|
|
678
854
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
679
855
|
style: {
|
|
680
|
-
fontSize:
|
|
856
|
+
fontSize: 13,
|
|
681
857
|
fontWeight: 600
|
|
682
858
|
},
|
|
683
859
|
children: "新增子代理"
|
|
@@ -685,9 +861,9 @@ function LibrarySettings(props) {
|
|
|
685
861
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { style: { flex: 1 } }),
|
|
686
862
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
687
863
|
type: "button",
|
|
688
|
-
disabled: busy
|
|
864
|
+
disabled: busy,
|
|
689
865
|
onClick: addEntry,
|
|
690
|
-
style:
|
|
866
|
+
style: primaryStyle,
|
|
691
867
|
children: "添加"
|
|
692
868
|
})
|
|
693
869
|
]
|
|
@@ -712,14 +888,21 @@ function LibrarySettings(props) {
|
|
|
712
888
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
713
889
|
style: labelStyle,
|
|
714
890
|
children: "描述"
|
|
715
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
891
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
716
892
|
value: newEntry.description ?? "",
|
|
717
893
|
onChange: (event) => setNewEntry({
|
|
718
894
|
...newEntry,
|
|
719
895
|
description: event.target.value
|
|
720
896
|
}),
|
|
721
|
-
placeholder: "
|
|
722
|
-
|
|
897
|
+
placeholder: "角色描述(模型可见,可拖右下角展开)",
|
|
898
|
+
rows: 1,
|
|
899
|
+
style: {
|
|
900
|
+
...proseStyle,
|
|
901
|
+
resize: "vertical",
|
|
902
|
+
whiteSpace: "pre-wrap",
|
|
903
|
+
overflowWrap: "anywhere",
|
|
904
|
+
overflow: "auto"
|
|
905
|
+
}
|
|
723
906
|
})]
|
|
724
907
|
}),
|
|
725
908
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -779,7 +962,7 @@ function LibrarySettings(props) {
|
|
|
779
962
|
style: inputStyle
|
|
780
963
|
})]
|
|
781
964
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
782
|
-
style:
|
|
965
|
+
style: fixedColStyle,
|
|
783
966
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
784
967
|
style: labelStyle,
|
|
785
968
|
children: "输出上限"
|
|
@@ -794,7 +977,8 @@ function LibrarySettings(props) {
|
|
|
794
977
|
placeholder: "tokens(可选)",
|
|
795
978
|
style: {
|
|
796
979
|
...inputStyle,
|
|
797
|
-
|
|
980
|
+
flex: "none",
|
|
981
|
+
width: 116
|
|
798
982
|
}
|
|
799
983
|
})]
|
|
800
984
|
})]
|
|
@@ -805,113 +989,132 @@ function LibrarySettings(props) {
|
|
|
805
989
|
flexWrap: "wrap",
|
|
806
990
|
gap: "8px"
|
|
807
991
|
},
|
|
808
|
-
children: [
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
992
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
993
|
+
style: fixedColStyle,
|
|
994
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
995
|
+
style: labelStyle,
|
|
996
|
+
children: "深度上限"
|
|
997
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
998
|
+
type: "number",
|
|
999
|
+
min: 1,
|
|
1000
|
+
value: newEntry.maxDepth ?? "",
|
|
1001
|
+
onChange: (event) => setNewEntry({
|
|
1002
|
+
...newEntry,
|
|
1003
|
+
maxDepth: event.target.value === "" ? void 0 : Number(event.target.value)
|
|
1004
|
+
}),
|
|
1005
|
+
style: {
|
|
1006
|
+
...inputStyle,
|
|
1007
|
+
flex: "none",
|
|
1008
|
+
width: 84
|
|
1009
|
+
}
|
|
1010
|
+
})]
|
|
1011
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1012
|
+
style: {
|
|
1013
|
+
...colStyle,
|
|
1014
|
+
flex: 1
|
|
1015
|
+
},
|
|
1016
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1017
|
+
style: labelStyle,
|
|
1018
|
+
children: "禁用工具"
|
|
1019
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1020
|
+
value: (newEntry.toolFilter?.deny ?? []).join(", "),
|
|
1021
|
+
onChange: (event) => {
|
|
1022
|
+
const deny = event.target.value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
1023
|
+
const allow = newEntry.toolFilter?.allow;
|
|
1024
|
+
setNewEntry({
|
|
836
1025
|
...newEntry,
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
1026
|
+
toolFilter: allow !== void 0 && allow.length > 0 || deny.length > 0 ? {
|
|
1027
|
+
...allow !== void 0 && allow.length > 0 ? { allow } : {},
|
|
1028
|
+
...deny.length > 0 ? { deny } : {}
|
|
1029
|
+
} : void 0
|
|
1030
|
+
});
|
|
1031
|
+
},
|
|
1032
|
+
placeholder: "write, edit, todo_write, …",
|
|
1033
|
+
style: inputStyle
|
|
1034
|
+
})]
|
|
1035
|
+
})]
|
|
1036
|
+
}),
|
|
1037
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1038
|
+
style: {
|
|
1039
|
+
display: "flex",
|
|
1040
|
+
flexWrap: "wrap",
|
|
1041
|
+
gap: "8px"
|
|
1042
|
+
},
|
|
1043
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1044
|
+
style: {
|
|
1045
|
+
...colStyle,
|
|
1046
|
+
flex: 1
|
|
1047
|
+
},
|
|
1048
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1049
|
+
style: labelStyle,
|
|
1050
|
+
children: "思考强度"
|
|
1051
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1052
|
+
value: newEntry.reasoningEffort ?? "",
|
|
1053
|
+
onChange: (event) => setNewEntry({
|
|
1054
|
+
...newEntry,
|
|
1055
|
+
reasoningEffort: event.target.value === "" ? void 0 : event.target.value.trim()
|
|
1056
|
+
}),
|
|
1057
|
+
placeholder: "如 max / high / medium / low(留空随父会话默认)",
|
|
1058
|
+
style: inputStyle
|
|
1059
|
+
})]
|
|
1060
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1061
|
+
style: fixedColStyle,
|
|
1062
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1063
|
+
style: labelStyle,
|
|
1064
|
+
children: "后台模式"
|
|
1065
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
1066
|
+
value: newEntry.backgroundMode ?? "one-shot",
|
|
1067
|
+
onChange: (event) => setNewEntry({
|
|
1068
|
+
...newEntry,
|
|
1069
|
+
backgroundMode: event.target.value
|
|
1070
|
+
}),
|
|
853
1071
|
style: {
|
|
854
|
-
...
|
|
855
|
-
flex:
|
|
1072
|
+
...inputStyle,
|
|
1073
|
+
flex: "none",
|
|
1074
|
+
width: 132
|
|
856
1075
|
},
|
|
857
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
858
|
-
|
|
859
|
-
children: "
|
|
860
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
861
|
-
value:
|
|
862
|
-
|
|
863
|
-
const deny = event.target.value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
864
|
-
const allow = newEntry.toolFilter?.allow;
|
|
865
|
-
setNewEntry({
|
|
866
|
-
...newEntry,
|
|
867
|
-
toolFilter: allow !== void 0 && allow.length > 0 || deny.length > 0 ? {
|
|
868
|
-
...allow !== void 0 && allow.length > 0 ? { allow } : {},
|
|
869
|
-
...deny.length > 0 ? { deny } : {}
|
|
870
|
-
} : void 0
|
|
871
|
-
});
|
|
872
|
-
},
|
|
873
|
-
placeholder: "write, edit, todo_write, …",
|
|
874
|
-
style: inputStyle
|
|
1076
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
1077
|
+
value: "one-shot",
|
|
1078
|
+
children: "one-shot"
|
|
1079
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
1080
|
+
value: "continuable",
|
|
1081
|
+
children: "continuable"
|
|
875
1082
|
})]
|
|
876
|
-
})
|
|
877
|
-
]
|
|
1083
|
+
})]
|
|
1084
|
+
})]
|
|
878
1085
|
}),
|
|
879
1086
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
880
1087
|
style: rowStyle,
|
|
881
1088
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
882
1089
|
style: labelStyle,
|
|
883
1090
|
children: "角色提示词"
|
|
884
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1091
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AutoTextarea, {
|
|
885
1092
|
value: newEntry.persona ?? "",
|
|
886
1093
|
onChange: (event) => setNewEntry({
|
|
887
1094
|
...newEntry,
|
|
888
1095
|
persona: event.target.value
|
|
889
1096
|
}),
|
|
890
1097
|
placeholder: "子代理的系统提示词(可选)",
|
|
891
|
-
|
|
892
|
-
style: {
|
|
893
|
-
...inputStyle,
|
|
894
|
-
resize: "vertical",
|
|
895
|
-
fontFamily: "inherit"
|
|
896
|
-
}
|
|
1098
|
+
style: textareaStyle
|
|
897
1099
|
})]
|
|
898
1100
|
})
|
|
899
1101
|
]
|
|
900
1102
|
}),
|
|
901
1103
|
status !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
902
|
-
style:
|
|
903
|
-
fontSize: "12px",
|
|
904
|
-
color: status.kind === "ok" ? "var(--dsh-color-success, #30a46c)" : "var(--dsh-color-danger, #e5484d)"
|
|
905
|
-
},
|
|
1104
|
+
style: status.kind === "ok" ? okBannerStyle : errorBannerStyle,
|
|
906
1105
|
children: status.text
|
|
907
1106
|
}),
|
|
908
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
909
|
-
style:
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
1107
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1108
|
+
style: hintStyle,
|
|
1109
|
+
children: [
|
|
1110
|
+
"配置存储于名册目录 ",
|
|
1111
|
+
view.dir || "~/.dsh/subagents",
|
|
1112
|
+
"(每具名子代理一个 <id>.yaml,可手编、热生效;",
|
|
1113
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: "_" }),
|
|
1114
|
+
" 前缀的文件/目录为非名册内容,如 ",
|
|
1115
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: "_backups/" }),
|
|
1116
|
+
" 备份区)。 settings.yaml 中的旧 entries 仅作迁移兜底读取,文件优先生效。"
|
|
1117
|
+
]
|
|
915
1118
|
})
|
|
916
1119
|
]
|
|
917
1120
|
});
|
|
@@ -1011,15 +1214,27 @@ const API_PATH = "/subagent-library/api";
|
|
|
1011
1214
|
/** Host error codes that carry no `message`; map them to user-facing text. */
|
|
1012
1215
|
const ERROR_TEXT = {
|
|
1013
1216
|
"not-ready": "设置服务尚未就绪,请稍后重试。",
|
|
1014
|
-
"readonly": "
|
|
1217
|
+
"readonly": "设置服务只读,无法完成该操作。",
|
|
1015
1218
|
"content-type-json-required": "请求被拒绝:写入只接受 JSON。",
|
|
1016
1219
|
"cross-origin-forbidden": "请求被拒绝:跨源写入。",
|
|
1017
1220
|
"body-too-large": "请求体超过 1 MiB 上限。",
|
|
1018
1221
|
"bad-json": "请求体不是合法 JSON。",
|
|
1019
1222
|
"entries-object-required": "缺少 entries 对象。",
|
|
1020
1223
|
"invalid-id": "条目 ID 非法。",
|
|
1021
|
-
"unknown-op": "未知操作。"
|
|
1224
|
+
"unknown-op": "未知操作。",
|
|
1225
|
+
"roster-unreadable": "名册目录读取失败。",
|
|
1226
|
+
"write-failed": "名册文件写入失败。"
|
|
1022
1227
|
};
|
|
1228
|
+
/** Map a wire view onto the UI model. Exported for the wire-contract tests —
|
|
1229
|
+
* a dropped field here silently kills UI features (k3 review: legacyCount). */
|
|
1230
|
+
const parseView = (value) => ({
|
|
1231
|
+
writable: value.writable ?? true,
|
|
1232
|
+
dir: value.dir ?? "",
|
|
1233
|
+
hash: value.hash ?? "",
|
|
1234
|
+
entries: value.entries ?? {},
|
|
1235
|
+
diagnostics: value.diagnostics ?? [],
|
|
1236
|
+
legacyCount: value.legacyCount ?? 0
|
|
1237
|
+
});
|
|
1023
1238
|
async function readView() {
|
|
1024
1239
|
const response = await fetch(API_PATH, { cache: "no-store" });
|
|
1025
1240
|
const body = await response.json();
|
|
@@ -1028,12 +1243,7 @@ async function readView() {
|
|
|
1028
1243
|
const message = body?.message;
|
|
1029
1244
|
throw new Error(message ?? (error !== void 0 ? ERROR_TEXT[error] : void 0) ?? "子代理库接口不可用(插件未加载?)");
|
|
1030
1245
|
}
|
|
1031
|
-
|
|
1032
|
-
return {
|
|
1033
|
-
writable: value.writable,
|
|
1034
|
-
revision: value.revision,
|
|
1035
|
-
entries: value.entries ?? {}
|
|
1036
|
-
};
|
|
1246
|
+
return parseView(body);
|
|
1037
1247
|
}
|
|
1038
1248
|
async function writeView(write) {
|
|
1039
1249
|
try {
|
|
@@ -1044,26 +1254,19 @@ async function writeView(write) {
|
|
|
1044
1254
|
cache: "no-store"
|
|
1045
1255
|
});
|
|
1046
1256
|
const body = await response.json();
|
|
1257
|
+
const wire = typeof body === "object" && body !== null ? body : {};
|
|
1047
1258
|
if (response.status === 409) return {
|
|
1048
1259
|
ok: false,
|
|
1049
|
-
conflict: true
|
|
1260
|
+
conflict: true,
|
|
1261
|
+
view: wire.view !== void 0 ? parseView(wire.view) : void 0
|
|
1262
|
+
};
|
|
1263
|
+
if (!response.ok || wire.ok !== true) return {
|
|
1264
|
+
ok: false,
|
|
1265
|
+
message: wire.message ?? (wire.error !== void 0 ? ERROR_TEXT[wire.error] : void 0) ?? "保存失败"
|
|
1050
1266
|
};
|
|
1051
|
-
if (!response.ok || typeof body !== "object" || body === null || body.ok !== true) {
|
|
1052
|
-
const message = body?.message;
|
|
1053
|
-
const error = body?.error;
|
|
1054
|
-
return {
|
|
1055
|
-
ok: false,
|
|
1056
|
-
message: message ?? (error !== void 0 ? ERROR_TEXT[error] : void 0) ?? "保存失败"
|
|
1057
|
-
};
|
|
1058
|
-
}
|
|
1059
|
-
const value = body;
|
|
1060
1267
|
return {
|
|
1061
1268
|
ok: true,
|
|
1062
|
-
view:
|
|
1063
|
-
writable: value.writable,
|
|
1064
|
-
revision: value.revision,
|
|
1065
|
-
entries: value.entries ?? {}
|
|
1066
|
-
}
|
|
1269
|
+
view: parseView(wire)
|
|
1067
1270
|
};
|
|
1068
1271
|
} catch (error) {
|
|
1069
1272
|
return {
|
|
@@ -1114,5 +1317,6 @@ function apply(ctx) {
|
|
|
1114
1317
|
//#endregion
|
|
1115
1318
|
exports.apply = apply;
|
|
1116
1319
|
exports.inject = inject;
|
|
1320
|
+
exports.parseView = parseView;
|
|
1117
1321
|
return module.exports; } });
|
|
1118
1322
|
//# sourceMappingURL=client.js.map
|