dsh-subagent-library 0.4.0 → 0.4.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 +16 -1
- package/README.en.md +58 -26
- package/README.md +59 -27
- package/assets/readme/hero.svg +3 -3
- package/assets/readme/member-model-effort.png +0 -0
- package/assets/readme/screenshot-settings.png +0 -0
- package/lib/client.js +375 -147
- package/lib/index.js +37 -3
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -80,6 +80,26 @@ function emptyMember() {
|
|
|
80
80
|
assignment: ""
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
+
/** Pick an unused valid member code derived from a role ID. */
|
|
84
|
+
function suggestSlot(roleId, otherSlots) {
|
|
85
|
+
const base = roleId.trim();
|
|
86
|
+
if (entryIdIssue(base)) return "";
|
|
87
|
+
const used = new Set(otherSlots.map((slot) => slot.trim()).filter(Boolean));
|
|
88
|
+
if (!used.has(base)) return base;
|
|
89
|
+
for (let n = 2; n < 1e3; n++) {
|
|
90
|
+
const suffix = `-${n}`;
|
|
91
|
+
const candidate = `${base.slice(0, MAX_ID_LENGTH - suffix.length).replace(/-+$/, "") || "m"}${suffix}`;
|
|
92
|
+
if (!used.has(candidate) && !entryIdIssue(candidate)) return candidate;
|
|
93
|
+
}
|
|
94
|
+
return "";
|
|
95
|
+
}
|
|
96
|
+
/** Place enabled items before disabled items while preserving relative order within each group. */
|
|
97
|
+
function sortByEnabled(ids, isEnabled) {
|
|
98
|
+
const enabled = [];
|
|
99
|
+
const disabled = [];
|
|
100
|
+
for (const id of ids) (isEnabled(id) ? enabled : disabled).push(id);
|
|
101
|
+
return [...enabled, ...disabled];
|
|
102
|
+
}
|
|
83
103
|
function roleForm(id, row) {
|
|
84
104
|
return {
|
|
85
105
|
kind: "roles",
|
|
@@ -281,11 +301,12 @@ const button = {
|
|
|
281
301
|
fontFamily: "inherit",
|
|
282
302
|
fontWeight: 500,
|
|
283
303
|
borderRadius: 8,
|
|
284
|
-
border: `1px solid ${TOKEN.
|
|
304
|
+
border: `1px solid ${TOKEN.border}`,
|
|
285
305
|
background: "transparent",
|
|
286
306
|
color: TOKEN.secondary,
|
|
287
307
|
cursor: "pointer",
|
|
288
|
-
whiteSpace: "nowrap"
|
|
308
|
+
whiteSpace: "nowrap",
|
|
309
|
+
transition: "background-color 140ms ease, border-color 140ms ease, color 140ms ease, filter 140ms ease"
|
|
289
310
|
};
|
|
290
311
|
const chip = {
|
|
291
312
|
display: "inline-flex",
|
|
@@ -304,12 +325,12 @@ const S = {
|
|
|
304
325
|
root: {
|
|
305
326
|
display: "flex",
|
|
306
327
|
flexDirection: "column",
|
|
307
|
-
gap:
|
|
328
|
+
gap: 14,
|
|
308
329
|
width: "100%",
|
|
309
330
|
minWidth: 0,
|
|
310
331
|
maxWidth: 880,
|
|
311
332
|
boxSizing: "border-box",
|
|
312
|
-
padding: "
|
|
333
|
+
padding: "6px 4px 14px",
|
|
313
334
|
color: TOKEN.primary,
|
|
314
335
|
containerType: "inline-size",
|
|
315
336
|
containerName: "dsh-library"
|
|
@@ -321,17 +342,17 @@ const S = {
|
|
|
321
342
|
flexWrap: "wrap"
|
|
322
343
|
},
|
|
323
344
|
heading: {
|
|
324
|
-
fontSize:
|
|
325
|
-
lineHeight: 1.
|
|
345
|
+
fontSize: 19,
|
|
346
|
+
lineHeight: 1.35,
|
|
326
347
|
fontWeight: 650,
|
|
327
|
-
letterSpacing: "-0.
|
|
348
|
+
letterSpacing: "-0.02em",
|
|
328
349
|
margin: 0
|
|
329
350
|
},
|
|
330
351
|
banner: {
|
|
331
352
|
fontSize: 12.5,
|
|
332
353
|
lineHeight: 1.65,
|
|
333
354
|
padding: "10px 12px",
|
|
334
|
-
borderRadius:
|
|
355
|
+
borderRadius: 9,
|
|
335
356
|
display: "flex",
|
|
336
357
|
flexDirection: "column",
|
|
337
358
|
gap: 6,
|
|
@@ -351,7 +372,6 @@ const S = {
|
|
|
351
372
|
minWidth: 0,
|
|
352
373
|
minHeight: 34,
|
|
353
374
|
padding: "6px 10px",
|
|
354
|
-
border: `1px solid ${TOKEN.borderStrong}`,
|
|
355
375
|
borderRadius: 8
|
|
356
376
|
},
|
|
357
377
|
searchInput: {
|
|
@@ -370,24 +390,11 @@ const S = {
|
|
|
370
390
|
flexDirection: "column",
|
|
371
391
|
gap: 10
|
|
372
392
|
},
|
|
373
|
-
row: {
|
|
374
|
-
minWidth: 0,
|
|
375
|
-
border: `1px solid ${TOKEN.border}`,
|
|
376
|
-
borderRadius: 12,
|
|
377
|
-
background: TOKEN.surface,
|
|
378
|
-
overflow: "hidden",
|
|
379
|
-
transition: "border-color 140ms ease, box-shadow 140ms ease"
|
|
380
|
-
},
|
|
381
|
-
rowOpen: {
|
|
382
|
-
borderColor: TOKEN.accent,
|
|
383
|
-
boxShadow: `0 0 0 1px ${TOKEN.accentSoft}`
|
|
384
|
-
},
|
|
385
|
-
rowOff: { background: "transparent" },
|
|
386
393
|
head: {
|
|
387
394
|
display: "flex",
|
|
388
395
|
alignItems: "flex-start",
|
|
389
396
|
gap: 12,
|
|
390
|
-
padding: "12px 16px
|
|
397
|
+
padding: "12px 16px 2px 12px"
|
|
391
398
|
},
|
|
392
399
|
disclosure: {
|
|
393
400
|
display: "flex",
|
|
@@ -403,7 +410,8 @@ const S = {
|
|
|
403
410
|
borderRadius: 4,
|
|
404
411
|
color: TOKEN.primary,
|
|
405
412
|
background: "transparent",
|
|
406
|
-
cursor: "pointer"
|
|
413
|
+
cursor: "pointer",
|
|
414
|
+
transition: "color 140ms ease"
|
|
407
415
|
},
|
|
408
416
|
titleRow: {
|
|
409
417
|
display: "flex",
|
|
@@ -421,11 +429,11 @@ const S = {
|
|
|
421
429
|
alignItems: "center",
|
|
422
430
|
justifyContent: "center",
|
|
423
431
|
color: TOKEN.muted,
|
|
424
|
-
transition: "transform 140ms ease"
|
|
432
|
+
transition: "transform 160ms cubic-bezier(0.22, 1, 0.36, 1), color 140ms ease"
|
|
425
433
|
},
|
|
426
434
|
id: {
|
|
427
435
|
fontSize: 14,
|
|
428
|
-
lineHeight: 1.
|
|
436
|
+
lineHeight: 1.55,
|
|
429
437
|
fontWeight: 650,
|
|
430
438
|
fontFamily: MONO,
|
|
431
439
|
overflowWrap: "anywhere",
|
|
@@ -439,13 +447,14 @@ const S = {
|
|
|
439
447
|
minHeight: 28,
|
|
440
448
|
fontSize: 11.5,
|
|
441
449
|
color: TOKEN.muted,
|
|
442
|
-
cursor: "pointer"
|
|
450
|
+
cursor: "pointer",
|
|
451
|
+
userSelect: "none"
|
|
443
452
|
},
|
|
444
453
|
overview: {
|
|
445
454
|
display: "flex",
|
|
446
455
|
flexDirection: "column",
|
|
447
|
-
gap:
|
|
448
|
-
padding: "
|
|
456
|
+
gap: 8,
|
|
457
|
+
padding: "1px 16px 13px 36px",
|
|
449
458
|
minWidth: 0
|
|
450
459
|
},
|
|
451
460
|
excerpt: {
|
|
@@ -463,7 +472,7 @@ const S = {
|
|
|
463
472
|
display: "flex",
|
|
464
473
|
flexWrap: "wrap",
|
|
465
474
|
alignItems: "baseline",
|
|
466
|
-
gap: "
|
|
475
|
+
gap: "3px 8px",
|
|
467
476
|
minWidth: 0
|
|
468
477
|
},
|
|
469
478
|
metaLabel: {
|
|
@@ -485,7 +494,7 @@ const S = {
|
|
|
485
494
|
fontSize: 11.5,
|
|
486
495
|
color: TOKEN.muted,
|
|
487
496
|
paddingLeft: 8,
|
|
488
|
-
borderLeft: `1px solid ${TOKEN.
|
|
497
|
+
borderLeft: `1px solid ${TOKEN.border}`,
|
|
489
498
|
overflowWrap: "anywhere",
|
|
490
499
|
minWidth: 0,
|
|
491
500
|
maxWidth: "100%"
|
|
@@ -493,7 +502,7 @@ const S = {
|
|
|
493
502
|
glyph: chip,
|
|
494
503
|
dirtyChip: {
|
|
495
504
|
...chip,
|
|
496
|
-
fontSize:
|
|
505
|
+
fontSize: 11,
|
|
497
506
|
color: TOKEN.warn,
|
|
498
507
|
background: TOKEN.warnSoft
|
|
499
508
|
},
|
|
@@ -501,11 +510,12 @@ const S = {
|
|
|
501
510
|
display: "flex",
|
|
502
511
|
flexDirection: "column",
|
|
503
512
|
gap: 13,
|
|
504
|
-
padding: "
|
|
513
|
+
padding: "13px 15px 14px",
|
|
505
514
|
borderTop: `1px solid ${TOKEN.divider}`
|
|
506
515
|
},
|
|
507
516
|
fieldLabel: {
|
|
508
517
|
fontSize: 12,
|
|
518
|
+
fontWeight: 500,
|
|
509
519
|
color: TOKEN.secondary,
|
|
510
520
|
marginBottom: 6,
|
|
511
521
|
display: "block"
|
|
@@ -538,7 +548,6 @@ const S = {
|
|
|
538
548
|
fontFamily: MONO,
|
|
539
549
|
lineHeight: 1.5,
|
|
540
550
|
padding: "6px 9px",
|
|
541
|
-
border: `1px solid ${TOKEN.borderStrong}`,
|
|
542
551
|
borderRadius: 7,
|
|
543
552
|
background: "transparent",
|
|
544
553
|
color: "inherit"
|
|
@@ -551,7 +560,6 @@ const S = {
|
|
|
551
560
|
fontFamily: "inherit",
|
|
552
561
|
lineHeight: 1.7,
|
|
553
562
|
padding: "8px 10px",
|
|
554
|
-
border: `1px solid ${TOKEN.borderStrong}`,
|
|
555
563
|
borderRadius: 7,
|
|
556
564
|
background: "transparent",
|
|
557
565
|
color: "inherit",
|
|
@@ -563,18 +571,18 @@ const S = {
|
|
|
563
571
|
primary: {
|
|
564
572
|
...button,
|
|
565
573
|
padding: "5px 13px",
|
|
566
|
-
|
|
574
|
+
border: "1px solid transparent",
|
|
567
575
|
background: TOKEN.accentFill,
|
|
568
576
|
color: "#fff"
|
|
569
577
|
},
|
|
570
578
|
danger: {
|
|
571
579
|
...button,
|
|
572
|
-
|
|
580
|
+
border: `1px solid ${TOKEN.dangerSoft}`,
|
|
573
581
|
color: TOKEN.danger
|
|
574
582
|
},
|
|
575
583
|
ghost: {
|
|
576
584
|
...button,
|
|
577
|
-
|
|
585
|
+
border: "1px solid transparent",
|
|
578
586
|
color: TOKEN.muted
|
|
579
587
|
},
|
|
580
588
|
hint: {
|
|
@@ -594,14 +602,18 @@ const S = {
|
|
|
594
602
|
borderRadius: 10
|
|
595
603
|
},
|
|
596
604
|
footer: {
|
|
597
|
-
padding: "
|
|
605
|
+
padding: "2px 0 4px",
|
|
598
606
|
color: TOKEN.muted,
|
|
607
|
+
minWidth: 0,
|
|
599
608
|
overflowWrap: "anywhere"
|
|
600
609
|
},
|
|
601
|
-
|
|
602
|
-
cursor: "pointer",
|
|
610
|
+
footerNote: {
|
|
603
611
|
fontSize: 11.5,
|
|
604
|
-
|
|
612
|
+
lineHeight: 1.7,
|
|
613
|
+
color: TOKEN.muted,
|
|
614
|
+
margin: "4px 0 0",
|
|
615
|
+
paddingLeft: 18,
|
|
616
|
+
overflowWrap: "anywhere"
|
|
605
617
|
}
|
|
606
618
|
};
|
|
607
619
|
const BANNER = {
|
|
@@ -612,7 +624,8 @@ const BANNER = {
|
|
|
612
624
|
},
|
|
613
625
|
error: {
|
|
614
626
|
...S.banner,
|
|
615
|
-
background: TOKEN.dangerSoft
|
|
627
|
+
background: TOKEN.dangerSoft,
|
|
628
|
+
color: TOKEN.danger
|
|
616
629
|
},
|
|
617
630
|
warn: {
|
|
618
631
|
...S.banner,
|
|
@@ -620,53 +633,145 @@ const BANNER = {
|
|
|
620
633
|
},
|
|
621
634
|
info: {
|
|
622
635
|
...S.banner,
|
|
623
|
-
background: TOKEN.inset
|
|
636
|
+
background: TOKEN.inset,
|
|
637
|
+
border: `1px solid ${TOKEN.divider}`
|
|
624
638
|
}
|
|
625
639
|
};
|
|
626
640
|
/** Scoped styles travel with the client bundle; no extra host CSS loader. */
|
|
627
641
|
const SETTINGS_CSS = `
|
|
642
|
+
:is(:has(> .dsh-library), :has(> * > .dsh-library)) { scrollbar-gutter: stable; }
|
|
628
643
|
.dsh-library *, .dsh-library *::before { box-sizing: border-box; }
|
|
629
|
-
.dsh-library button:disabled { cursor: default !important; opacity: .
|
|
630
|
-
.dsh-library :is(button,
|
|
631
|
-
outline: 2px solid ${TOKEN.accent}; outline-offset:
|
|
644
|
+
.dsh-library button:disabled { cursor: default !important; opacity: .48; }
|
|
645
|
+
.dsh-library :is(button, summary):focus-visible {
|
|
646
|
+
outline: 2px solid ${TOKEN.accent}; outline-offset: 2px;
|
|
632
647
|
}
|
|
633
|
-
.dsh-library .library-
|
|
648
|
+
.dsh-library .dsh-library-switch:focus-visible {
|
|
634
649
|
outline: 2px solid ${TOKEN.accent}; outline-offset: 2px;
|
|
635
650
|
}
|
|
651
|
+
.dsh-library .library-search {
|
|
652
|
+
border: 1px solid ${TOKEN.border};
|
|
653
|
+
background: var(--dsw-alias-bg-base, transparent);
|
|
654
|
+
transition: border-color 140ms ease, box-shadow 140ms ease;
|
|
655
|
+
}
|
|
656
|
+
.dsh-library .library-search svg { color: ${TOKEN.muted}; flex: none; }
|
|
657
|
+
.dsh-library .library-search:focus-within {
|
|
658
|
+
border-color: ${TOKEN.accent};
|
|
659
|
+
box-shadow: 0 0 0 2px ${TOKEN.accentSoft};
|
|
660
|
+
}
|
|
636
661
|
.dsh-library .library-search input:focus-visible { outline: none; }
|
|
637
|
-
.dsh-library .library-panel {
|
|
638
|
-
|
|
662
|
+
.dsh-library .library-panel {
|
|
663
|
+
display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0;
|
|
664
|
+
}
|
|
665
|
+
.dsh-library .library-banner code {
|
|
666
|
+
font-family: ${MONO}; font-size: 0.92em; padding: 1px 5px; border-radius: 4px;
|
|
667
|
+
background: var(--dsw-alias-bg-base, rgba(128,128,128,0.1));
|
|
668
|
+
}
|
|
669
|
+
.dsh-library .library-footer code {
|
|
670
|
+
font-family: ${MONO}; font-size: 0.92em; padding: 1px 5px; border-radius: 4px;
|
|
671
|
+
background: ${TOKEN.inset};
|
|
672
|
+
}
|
|
673
|
+
.dsh-library .library-tabs { display: flex; gap: 18px; border-bottom: 1px solid ${TOKEN.divider}; }
|
|
639
674
|
.dsh-library .library-tabs button {
|
|
640
|
-
|
|
641
|
-
|
|
675
|
+
display: inline-flex; align-items: center; gap: 6px;
|
|
676
|
+
padding: 6px 2px 9px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent;
|
|
677
|
+
background: transparent; color: ${TOKEN.secondary}; font: inherit; font-size: 13px; font-weight: 600;
|
|
678
|
+
cursor: pointer; transition: color 140ms ease, border-color 140ms ease;
|
|
679
|
+
}
|
|
680
|
+
.dsh-library .library-tabs button[aria-selected=true] { color: ${TOKEN.accent}; border-bottom-color: currentColor; }
|
|
681
|
+
.dsh-library .library-tab-count {
|
|
682
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
683
|
+
min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
|
|
684
|
+
font-size: 11px; font-weight: 550; line-height: 1;
|
|
685
|
+
background: ${TOKEN.inset}; color: ${TOKEN.muted};
|
|
686
|
+
transition: background-color 140ms ease, color 140ms ease;
|
|
642
687
|
}
|
|
643
|
-
.dsh-library .library-tabs button[aria-selected=true]
|
|
688
|
+
.dsh-library .library-tabs button[aria-selected=true] .library-tab-count {
|
|
689
|
+
background: ${TOKEN.accentSoft}; color: ${TOKEN.accent};
|
|
690
|
+
}
|
|
691
|
+
.dsh-library .library-tab-dot {
|
|
692
|
+
width: 6px; height: 6px; border-radius: 50%; background: ${TOKEN.warn}; flex: none;
|
|
693
|
+
}
|
|
694
|
+
.dsh-library .dsh-library-card {
|
|
695
|
+
min-width: 0; border: 1px solid ${TOKEN.border}; border-radius: 12px;
|
|
696
|
+
background: ${TOKEN.surface}; overflow: hidden;
|
|
697
|
+
transition: border-color 160ms cubic-bezier(0.22, 1, 0.36, 1),
|
|
698
|
+
box-shadow 160ms cubic-bezier(0.22, 1, 0.36, 1),
|
|
699
|
+
background-color 160ms ease;
|
|
700
|
+
}
|
|
701
|
+
.dsh-library .dsh-library-card[data-disabled] {
|
|
702
|
+
background: transparent; border-color: ${TOKEN.divider};
|
|
703
|
+
}
|
|
704
|
+
.dsh-library .dsh-library-card[data-disabled] .library-card-title,
|
|
705
|
+
.dsh-library .dsh-library-card[data-disabled] .library-card-overview {
|
|
706
|
+
opacity: .68;
|
|
707
|
+
}
|
|
708
|
+
.dsh-library .dsh-library-card[data-open] {
|
|
709
|
+
border-color: ${TOKEN.accent};
|
|
710
|
+
box-shadow: 0 0 0 1px ${TOKEN.accentSoft}, 0 2px 10px rgba(0, 0, 0, 0.04);
|
|
711
|
+
}
|
|
712
|
+
.dsh-library .dsh-library-card[data-open] .library-card-head { padding-bottom: 11px; }
|
|
713
|
+
.dsh-library .dsh-library-card[data-open] .library-card-title { opacity: 1; }
|
|
644
714
|
.dsh-library .library-editor { min-width: 0; border: 0; margin: 0; }
|
|
715
|
+
.dsh-library .library-editor :is(input:not([type=checkbox]), textarea, select) {
|
|
716
|
+
border: 1px solid ${TOKEN.border};
|
|
717
|
+
background: var(--dsw-alias-bg-base, transparent);
|
|
718
|
+
transition: border-color 140ms ease, box-shadow 140ms ease;
|
|
719
|
+
}
|
|
720
|
+
.dsh-library .library-editor :is(input:not([type=checkbox]), textarea, select):focus {
|
|
721
|
+
outline: none;
|
|
722
|
+
border-color: ${TOKEN.accent};
|
|
723
|
+
box-shadow: 0 0 0 2px ${TOKEN.accentSoft};
|
|
724
|
+
}
|
|
645
725
|
.dsh-library h3 { margin: 0; font-size: 13px; font-weight: 650; }
|
|
646
726
|
.dsh-library .library-editor textarea { min-height: 51px !important; }
|
|
647
727
|
.dsh-library .library-editor [data-field=assignment] { min-height: 35px !important; }
|
|
648
|
-
.dsh-library .library-editor
|
|
728
|
+
.dsh-library .library-editor [data-field=instructions] { min-height: 76px !important; }
|
|
729
|
+
.dsh-library .library-editor [data-field=persona] { min-height: 118px !important; }
|
|
730
|
+
.dsh-library .library-editor input:read-only { background: ${TOKEN.inset} !important; color: ${TOKEN.secondary}; }
|
|
731
|
+
.dsh-library .library-advanced {
|
|
732
|
+
border: 1px solid ${TOKEN.divider}; border-radius: 8px;
|
|
733
|
+
padding: 8px 11px; background: var(--dsw-alias-bg-base, transparent);
|
|
734
|
+
}
|
|
735
|
+
.dsh-library .library-advanced > summary,
|
|
736
|
+
.dsh-library .library-footer > summary {
|
|
737
|
+
display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 6px;
|
|
738
|
+
cursor: pointer; list-style: none; user-select: none; border-radius: 4px;
|
|
739
|
+
}
|
|
740
|
+
.dsh-library .library-advanced > summary { font-size: 12px; font-weight: 550; color: ${TOKEN.secondary}; }
|
|
741
|
+
.dsh-library .library-footer > summary { font-size: 11.5px; color: ${TOKEN.muted}; padding: 2px 4px 2px 0; transition: color 140ms ease; }
|
|
742
|
+
.dsh-library .library-advanced > summary::-webkit-details-marker,
|
|
743
|
+
.dsh-library .library-footer > summary::-webkit-details-marker { display: none; }
|
|
744
|
+
.dsh-library .library-advanced > summary::before,
|
|
745
|
+
.dsh-library .library-footer > summary::before {
|
|
746
|
+
content: '❯'; font-size: 9.5px; color: ${TOKEN.muted};
|
|
747
|
+
transition: transform 160ms cubic-bezier(0.22, 1, 0.36, 1); display: inline-block; width: 12px; text-align: center;
|
|
748
|
+
}
|
|
749
|
+
.dsh-library .library-advanced[open] > summary::before,
|
|
750
|
+
.dsh-library .library-footer[open] > summary::before { transform: rotate(90deg); }
|
|
751
|
+
.dsh-library .library-advanced-body { padding-top: 10px; margin-top: 8px; border-top: 1px solid ${TOKEN.divider}; }
|
|
752
|
+
.dsh-library .library-member-chip { font-family: ${MONO}; font-size: 11px; }
|
|
649
753
|
.dsh-library .library-members-head {
|
|
650
754
|
display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
|
|
651
|
-
gap: 5px 10px; padding-top: 8px; border-top: 1px solid ${TOKEN.
|
|
755
|
+
gap: 5px 10px; padding-top: 8px; border-top: 1px solid ${TOKEN.divider};
|
|
652
756
|
}
|
|
653
757
|
.dsh-library .library-members { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
|
|
654
758
|
.dsh-library .library-members li {
|
|
655
|
-
display: grid; gap: 7px; min-width: 0; padding:
|
|
656
|
-
border: 1px solid ${TOKEN.border}; border-radius:
|
|
759
|
+
display: grid; gap: 7px; min-width: 0; padding: 9px 11px 11px;
|
|
760
|
+
border: 1px solid ${TOKEN.border}; border-radius: 9px; background: var(--dsw-alias-bg-base, transparent);
|
|
657
761
|
}
|
|
658
762
|
.dsh-library .library-member-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 12px; }
|
|
659
763
|
.dsh-library .library-member-head button { min-height: 27px !important; padding: 2px 6px !important; }
|
|
660
764
|
.dsh-library .library-link {
|
|
661
765
|
border: 0 !important; padding: 0 !important; min-height: 0 !important; display: inline !important;
|
|
662
766
|
color: ${TOKEN.accent} !important; white-space: normal !important; text-align: left; text-decoration: underline; overflow-wrap: anywhere;
|
|
767
|
+
background: transparent !important;
|
|
663
768
|
}
|
|
664
769
|
.dsh-library .library-field-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 8px; padding-top: 2px; }
|
|
665
770
|
.dsh-library .library-field-actions > button { min-height: 24px !important; }
|
|
666
771
|
.dsh-library .library-field-note { padding-top: 4px; }
|
|
667
772
|
.dsh-library .library-field-error { color: ${TOKEN.danger}; font-size: 11.5px; line-height: 1.65; overflow-wrap: anywhere; }
|
|
668
773
|
.dsh-library .library-field-error:not(:empty) { margin-top: 4px; }
|
|
669
|
-
.dsh-library [data-field=slot][aria-invalid=true] { border-color: ${TOKEN.danger} !important; }
|
|
774
|
+
.dsh-library [data-field=slot][aria-invalid=true] { border-color: ${TOKEN.danger} !important; box-shadow: 0 0 0 2px ${TOKEN.dangerSoft} !important; }
|
|
670
775
|
.dsh-library [data-field=role-id] { user-select: text; }
|
|
671
776
|
.dsh-library .library-refs ul { padding-inline-start: 19px; margin: 4px 0; }
|
|
672
777
|
.dsh-library .library-dialog {
|
|
@@ -685,11 +790,12 @@ const SETTINGS_CSS = `
|
|
|
685
790
|
appearance: none; position: relative; display: inline-block; flex: none;
|
|
686
791
|
width: 30px; height: 18px; margin: 0; border: 1px solid ${TOKEN.borderStrong};
|
|
687
792
|
border-radius: 999px; background: ${TOKEN.hover}; cursor: pointer;
|
|
688
|
-
transition: background
|
|
793
|
+
transition: background-color 160ms ease, border-color 160ms ease;
|
|
689
794
|
}
|
|
690
795
|
.dsh-library-switch::before {
|
|
691
796
|
content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px;
|
|
692
|
-
border-radius: 50%; background: ${TOKEN.muted};
|
|
797
|
+
border-radius: 50%; background: ${TOKEN.muted};
|
|
798
|
+
transition: transform 160ms cubic-bezier(0.22, 1, 0.36, 1), background-color 160ms ease;
|
|
693
799
|
}
|
|
694
800
|
.dsh-library-switch:checked { background: ${TOKEN.accentFill}; border-color: transparent; }
|
|
695
801
|
.dsh-library-switch:checked::before { transform: translateX(12px); background: #fff; }
|
|
@@ -697,9 +803,21 @@ const SETTINGS_CSS = `
|
|
|
697
803
|
.dsh-library .library-grid, .dsh-library .library-compare { grid-template-columns: minmax(0, 1fr) !important; }
|
|
698
804
|
}
|
|
699
805
|
@media (hover: hover) {
|
|
700
|
-
.dsh-library-card:hover { border-color: ${TOKEN.borderStrong}; }
|
|
701
|
-
.dsh-library-disclosure:hover { color: ${TOKEN.accent} !important; }
|
|
702
|
-
.dsh-library
|
|
806
|
+
.dsh-library .dsh-library-card:not([data-open]):hover { border-color: ${TOKEN.borderStrong}; }
|
|
807
|
+
.dsh-library .dsh-library-disclosure:hover { color: ${TOKEN.accent} !important; }
|
|
808
|
+
.dsh-library .dsh-library-disclosure:hover .library-card-chevron { color: ${TOKEN.accent} !important; }
|
|
809
|
+
.dsh-library .library-tabs button:not([aria-selected=true]):hover { color: ${TOKEN.primary}; }
|
|
810
|
+
.dsh-library .library-search:not(:focus-within):hover { border-color: ${TOKEN.borderStrong}; }
|
|
811
|
+
.dsh-library .library-editor :is(input:not([type=checkbox]):not(:read-only), textarea, select):not(:focus):hover {
|
|
812
|
+
border-color: ${TOKEN.borderStrong};
|
|
813
|
+
}
|
|
814
|
+
.dsh-library .library-footer > summary:hover { color: ${TOKEN.secondary}; }
|
|
815
|
+
.dsh-library button[data-tone=button]:not(:disabled):not(.library-link):hover {
|
|
816
|
+
background: ${TOKEN.hover} !important; border-color: ${TOKEN.borderStrong} !important; color: ${TOKEN.primary} !important;
|
|
817
|
+
}
|
|
818
|
+
.dsh-library button[data-tone=primary]:not(:disabled):hover { filter: brightness(.93); }
|
|
819
|
+
.dsh-library button[data-tone=danger]:not(:disabled):hover { background: ${TOKEN.dangerSoft} !important; border-color: ${TOKEN.danger} !important; }
|
|
820
|
+
.dsh-library button[data-tone=ghost]:not(:disabled):hover { background: ${TOKEN.hover} !important; color: ${TOKEN.primary} !important; }
|
|
703
821
|
}
|
|
704
822
|
@media (prefers-reduced-motion: reduce) {
|
|
705
823
|
.dsh-library *, .dsh-library *::before { transition: none !important; }
|
|
@@ -717,6 +835,7 @@ function Action({ action, tone = "button", children,...props }) {
|
|
|
717
835
|
...props,
|
|
718
836
|
type: "button",
|
|
719
837
|
"data-action": action,
|
|
838
|
+
"data-tone": tone,
|
|
720
839
|
style: {
|
|
721
840
|
...S[tone],
|
|
722
841
|
...props.style
|
|
@@ -741,7 +860,7 @@ function Field({ label, name, value, change, multiline, hint, describedBy,...pro
|
|
|
741
860
|
"aria-describedby": description,
|
|
742
861
|
"data-field": name,
|
|
743
862
|
value,
|
|
744
|
-
rows: name === "assignment" ? 1 : 2,
|
|
863
|
+
rows: name === "persona" ? 5 : name === "instructions" ? 3 : name === "assignment" ? 1 : 2,
|
|
745
864
|
placeholder: props.placeholder,
|
|
746
865
|
onChange: (e) => change?.(e.target.value),
|
|
747
866
|
style: S.prose
|
|
@@ -807,12 +926,12 @@ function memberState(view, form, member) {
|
|
|
807
926
|
}
|
|
808
927
|
const notes = {
|
|
809
928
|
"profile": "使用当前 profile 的独立路由。",
|
|
810
|
-
"inherit": "当前 profile
|
|
811
|
-
"foreign-ignored": "共享 Provider 未在此 profile
|
|
812
|
-
"profile-missing": "当前 profile 的 Provider 尚未注册,可更换 Provider
|
|
813
|
-
"overlay-broken": "当前 profile
|
|
929
|
+
"inherit": "当前 profile 已设为跟随主会话模型(派遣时与主会话一致)。",
|
|
930
|
+
"foreign-ignored": "共享 Provider 未在此 profile 注册,当前跟随主会话模型。",
|
|
931
|
+
"profile-missing": "当前 profile 的 Provider 尚未注册,可更换 Provider 或改为跟随主会话模型。",
|
|
932
|
+
"overlay-broken": "当前 profile 的路由无法读取,可重新设置或设为跟随主会话模型。"
|
|
814
933
|
};
|
|
815
|
-
function RoleFields({ form, isNew, change, view, refs, jump }) {
|
|
934
|
+
function RoleFields({ form, isNew, change, view, refs, jump, message }) {
|
|
816
935
|
const patch = (values) => change({
|
|
817
936
|
...form,
|
|
818
937
|
...values
|
|
@@ -829,6 +948,16 @@ function RoleFields({ form, isNew, change, view, refs, jump }) {
|
|
|
829
948
|
form.reasoningEffort,
|
|
830
949
|
form.maxTokens
|
|
831
950
|
].some((value) => value.trim());
|
|
951
|
+
const savedHasRoute = Boolean(saved && [
|
|
952
|
+
saved.provider,
|
|
953
|
+
saved.model,
|
|
954
|
+
saved.reasoningEffort,
|
|
955
|
+
saved.maxTokens
|
|
956
|
+
].some((v) => v !== void 0 && String(v).trim()));
|
|
957
|
+
const needsPin = form.routeNote === "overlay-broken" || form.routeNote === "foreign-ignored";
|
|
958
|
+
const pendingInherit = form.inherit || !hasRoute && savedHasRoute;
|
|
959
|
+
const alreadyInherit = !hasRoute && !savedHasRoute && !needsPin;
|
|
960
|
+
const inheritLabel = pendingInherit ? "保存后跟随主会话模型" : alreadyInherit ? "已跟随主会话模型" : hasRoute ? "改为跟随主会话模型" : "设为跟随主会话模型";
|
|
832
961
|
const clearRoute = (inherit) => patch({
|
|
833
962
|
inherit,
|
|
834
963
|
provider: "",
|
|
@@ -836,6 +965,12 @@ function RoleFields({ form, isNew, change, view, refs, jump }) {
|
|
|
836
965
|
reasoningEffort: "",
|
|
837
966
|
maxTokens: ""
|
|
838
967
|
});
|
|
968
|
+
const advancedSummary = [form.subagentProvider.trim() && `传输层 ${form.subagentProvider.trim()}`, form.maxDepth.trim() && `深度 ${form.maxDepth.trim()}`].filter(Boolean).join(" · ");
|
|
969
|
+
const advancedAlert = Boolean(message?.includes("深度上限") || saved?.reason?.startsWith("maxDepth is 0") || saved?.reason?.startsWith("subagent transport provider") || saved?.reason?.startsWith("Transport "));
|
|
970
|
+
const [advancedOpen, setAdvancedOpen] = (0, react.useState)(advancedAlert);
|
|
971
|
+
(0, react.useEffect)(() => {
|
|
972
|
+
if (advancedAlert) setAdvancedOpen(true);
|
|
973
|
+
}, [advancedAlert]);
|
|
839
974
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
840
975
|
saved?.launchable === false && saved.enabled !== false && !saved.toolFilter && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
841
976
|
style: BANNER.warn,
|
|
@@ -855,12 +990,12 @@ function RoleFields({ form, isNew, change, view, refs, jump }) {
|
|
|
855
990
|
value: form.description,
|
|
856
991
|
change: (description) => patch({ description })
|
|
857
992
|
}),
|
|
858
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h3", { children: [view.profile || routeReadOnly ? "
|
|
993
|
+
/* @__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
994
|
style: S.hint,
|
|
860
995
|
children: [" · ", view.profile]
|
|
861
996
|
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
862
997
|
style: S.hint,
|
|
863
|
-
children: view.routeWriteProblem ?? (view.profile ? form.routeNote ? notes[form.routeNote] : "
|
|
998
|
+
children: view.routeWriteProblem ?? (view.profile ? form.routeNote ? notes[form.routeNote] : "模型与思考档位按当前 profile 保存;派遣时也可按需临时切换其他授权模型。" : "这里编辑角色的共享默认模型。全部留空后保存,共享默认将跟随主会话模型。共享路由变更后,绑定旧默认路由的 profile 需重新设置。")
|
|
864
999
|
})] }),
|
|
865
1000
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
866
1001
|
className: "library-grid",
|
|
@@ -872,7 +1007,7 @@ function RoleFields({ form, isNew, change, view, refs, jump }) {
|
|
|
872
1007
|
value: form.provider,
|
|
873
1008
|
change: (v) => route("provider", v),
|
|
874
1009
|
readOnly: routeReadOnly,
|
|
875
|
-
placeholder: "
|
|
1010
|
+
placeholder: "跟随主会话"
|
|
876
1011
|
}),
|
|
877
1012
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
878
1013
|
name: "model",
|
|
@@ -880,7 +1015,7 @@ function RoleFields({ form, isNew, change, view, refs, jump }) {
|
|
|
880
1015
|
value: form.model,
|
|
881
1016
|
change: (v) => route("model", v),
|
|
882
1017
|
readOnly: routeReadOnly,
|
|
883
|
-
placeholder: "
|
|
1018
|
+
placeholder: "跟随主会话"
|
|
884
1019
|
}),
|
|
885
1020
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
886
1021
|
name: "reasoningEffort",
|
|
@@ -903,40 +1038,53 @@ function RoleFields({ form, isNew, change, view, refs, jump }) {
|
|
|
903
1038
|
}),
|
|
904
1039
|
!routeReadOnly && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: view.profile ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
|
|
905
1040
|
action: "inherit",
|
|
906
|
-
disabled:
|
|
1041
|
+
disabled: pendingInherit || alreadyInherit,
|
|
907
1042
|
onClick: () => clearRoute(true),
|
|
908
|
-
children:
|
|
1043
|
+
children: inheritLabel
|
|
909
1044
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
|
|
910
1045
|
action: "clear-shared-route",
|
|
911
1046
|
disabled: !hasRoute,
|
|
912
1047
|
onClick: () => clearRoute(false),
|
|
913
1048
|
children: "清空共享路由"
|
|
914
1049
|
}) }),
|
|
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
1050
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
935
1051
|
name: "persona",
|
|
936
1052
|
label: "角色人设",
|
|
937
1053
|
multiline: true,
|
|
938
1054
|
value: form.persona,
|
|
939
|
-
change: (persona) => patch({ persona })
|
|
1055
|
+
change: (persona) => patch({ persona }),
|
|
1056
|
+
placeholder: "定义这个角色的工作方式、检查视角或边界约束"
|
|
1057
|
+
}),
|
|
1058
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
1059
|
+
className: "library-advanced",
|
|
1060
|
+
open: advancedOpen,
|
|
1061
|
+
onToggle: (e) => setAdvancedOpen(e.currentTarget.open),
|
|
1062
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "高级选项" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1063
|
+
style: S.hint,
|
|
1064
|
+
children: advancedSummary || "传输层、深度上限"
|
|
1065
|
+
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1066
|
+
className: "library-advanced-body",
|
|
1067
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1068
|
+
className: "library-grid",
|
|
1069
|
+
style: S.grid,
|
|
1070
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1071
|
+
name: "subagentProvider",
|
|
1072
|
+
label: "传输层",
|
|
1073
|
+
value: form.subagentProvider,
|
|
1074
|
+
change: (subagentProvider) => patch({ subagentProvider }),
|
|
1075
|
+
placeholder: "spawn(默认)",
|
|
1076
|
+
hint: "留空使用默认 spawn(独立上下文);填 fork 可继承父会话历史。"
|
|
1077
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
1078
|
+
name: "maxDepth",
|
|
1079
|
+
label: "深度上限",
|
|
1080
|
+
value: form.maxDepth,
|
|
1081
|
+
change: (maxDepth) => patch({ maxDepth }),
|
|
1082
|
+
min: 0,
|
|
1083
|
+
placeholder: "跟随宿主",
|
|
1084
|
+
hint: "留空时跟随宿主。填写后使用宿主与角色上限中较低的值,填 0 禁止派遣。"
|
|
1085
|
+
})]
|
|
1086
|
+
})
|
|
1087
|
+
})]
|
|
940
1088
|
}),
|
|
941
1089
|
form.filter && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
942
1090
|
style: BANNER.warn,
|
|
@@ -1243,7 +1391,14 @@ function GroupFields({ form, isNew, change, view, message }) {
|
|
|
1243
1391
|
style: S.input,
|
|
1244
1392
|
"data-field": "role",
|
|
1245
1393
|
value: member.role,
|
|
1246
|
-
onChange: (e) =>
|
|
1394
|
+
onChange: (e) => {
|
|
1395
|
+
const nextRole = e.target.value;
|
|
1396
|
+
const autoSlot = !member.slot.trim() && nextRole && own(view.entries, nextRole) ? suggestSlot(nextRole, slots.filter((_, index) => index !== i)) : "";
|
|
1397
|
+
patchMember(i, autoSlot ? {
|
|
1398
|
+
role: nextRole,
|
|
1399
|
+
slot: autoSlot
|
|
1400
|
+
} : { role: nextRole });
|
|
1401
|
+
},
|
|
1247
1402
|
children: [
|
|
1248
1403
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
1249
1404
|
value: "",
|
|
@@ -1337,9 +1492,9 @@ function CompareForm({ form }) {
|
|
|
1337
1492
|
form.members.forEach((m) => rows.push([m.slot || "成员", [m.role, m.assignment].filter(Boolean).join(" / ")]));
|
|
1338
1493
|
} else {
|
|
1339
1494
|
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 ? "
|
|
1495
|
+
if (form.inherit || form.routeNote) rows.push(["路由状态", form.inherit ? "保存后跟随主会话模型" : {
|
|
1341
1496
|
profile: "当前 profile 路由",
|
|
1342
|
-
inherit: "
|
|
1497
|
+
inherit: "跟随主会话模型",
|
|
1343
1498
|
"foreign-ignored": "共享 Provider 未注册",
|
|
1344
1499
|
"profile-missing": "当前 Provider 未注册",
|
|
1345
1500
|
"overlay-broken": "路由无法读取"
|
|
@@ -1415,10 +1570,10 @@ function LibrarySettings({ readView: readView$1, writeView: writeView$1, subscri
|
|
|
1415
1570
|
return next;
|
|
1416
1571
|
});
|
|
1417
1572
|
}
|
|
1418
|
-
function reveal(id, slot) {
|
|
1573
|
+
function reveal(id, slot, selector) {
|
|
1419
1574
|
requestAnimationFrame(() => {
|
|
1420
1575
|
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]");
|
|
1576
|
+
const target = slot && card?.querySelector(`[data-slot-key="${CSS.escape(slot)}"] [data-field="slot"]`) || (selector ? card?.querySelector(selector) : null) || card?.querySelector("[data-row-id]");
|
|
1422
1577
|
target?.focus({ preventScroll: true });
|
|
1423
1578
|
target?.scrollIntoView({ block: "nearest" });
|
|
1424
1579
|
});
|
|
@@ -1441,7 +1596,7 @@ function LibrarySettings({ readView: readView$1, writeView: writeView$1, subscri
|
|
|
1441
1596
|
setNotice(void 0);
|
|
1442
1597
|
if (focus) requestAnimationFrame(() => root.current?.querySelector(`[data-tab="${next}"]`)?.focus());
|
|
1443
1598
|
}
|
|
1444
|
-
async function write(operation, row, success = "已保存。") {
|
|
1599
|
+
async function write(operation, row, success = "已保存。", options) {
|
|
1445
1600
|
if (writing.current) return;
|
|
1446
1601
|
writing.current = true;
|
|
1447
1602
|
readNumber.current++;
|
|
@@ -1455,11 +1610,11 @@ function LibrarySettings({ readView: readView$1, writeView: writeView$1, subscri
|
|
|
1455
1610
|
setView(result.view);
|
|
1456
1611
|
if (k && row) {
|
|
1457
1612
|
put(k, void 0);
|
|
1458
|
-
setExpanded((old) => ({
|
|
1613
|
+
if (!options?.keepExpanded) setExpanded((old) => ({
|
|
1459
1614
|
...old,
|
|
1460
1615
|
[k]: false
|
|
1461
1616
|
}));
|
|
1462
|
-
if (operation.op === "save-entry" || operation.op === "save-group") reveal(operation.id);
|
|
1617
|
+
if (operation.op === "save-entry" || operation.op === "save-group") reveal(operation.id, void 0, options?.focusSwitch ? "[data-field=\"enabled\"]" : void 0);
|
|
1463
1618
|
else requestAnimationFrame(() => root.current?.querySelector("[data-action=\"new\"]")?.focus());
|
|
1464
1619
|
}
|
|
1465
1620
|
setNotice({ text: success });
|
|
@@ -1589,7 +1744,10 @@ function LibrarySettings({ readView: readView$1, writeView: writeView$1, subscri
|
|
|
1589
1744
|
});
|
|
1590
1745
|
}
|
|
1591
1746
|
const needle = filters[tab].trim().toLowerCase();
|
|
1592
|
-
const
|
|
1747
|
+
const roleCount = Object.keys(view.entries).length;
|
|
1748
|
+
const groupCount = Object.keys(view.groups).length;
|
|
1749
|
+
const hasDirtyTab = (kind) => Object.entries(drafts).some(([k, d]) => k.startsWith(kind + "/") && (d.conflict || !equal(d.base, d.form)));
|
|
1750
|
+
const serverIds = sortByEnabled(Object.keys(tab === "roles" ? view.entries : view.groups), (id) => (tab === "roles" ? view.entries[id]?.enabled : view.groups[id]?.enabled) !== false);
|
|
1593
1751
|
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
1752
|
if (!needle || id === NEW || drafts[key(id)] && expanded[key(id)]) return true;
|
|
1595
1753
|
const form = drafts[key(id)]?.form ?? serverForm(view, tab, id);
|
|
@@ -1630,7 +1788,7 @@ function LibrarySettings({ readView: readView$1, writeView: writeView$1, subscri
|
|
|
1630
1788
|
className: "library-tabs",
|
|
1631
1789
|
role: "tablist",
|
|
1632
1790
|
"aria-label": "设置分类",
|
|
1633
|
-
children: ["roles", "groups"].map((kind) => /* @__PURE__ */ (0, react_jsx_runtime.
|
|
1791
|
+
children: ["roles", "groups"].map((kind) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1634
1792
|
type: "button",
|
|
1635
1793
|
role: "tab",
|
|
1636
1794
|
"data-tab": kind,
|
|
@@ -1650,7 +1808,18 @@ function LibrarySettings({ readView: readView$1, writeView: writeView$1, subscri
|
|
|
1650
1808
|
changeTab(e.key === "Home" ? "roles" : e.key === "End" ? "groups" : tab === "groups" ? "roles" : "groups", true);
|
|
1651
1809
|
}
|
|
1652
1810
|
},
|
|
1653
|
-
children:
|
|
1811
|
+
children: [
|
|
1812
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: kind === "roles" ? "角色名册" : "编队" }),
|
|
1813
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1814
|
+
className: "library-tab-count",
|
|
1815
|
+
children: kind === "roles" ? roleCount : groupCount
|
|
1816
|
+
}),
|
|
1817
|
+
hasDirtyTab(kind) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1818
|
+
className: "library-tab-dot",
|
|
1819
|
+
"aria-label": "有未保存修改",
|
|
1820
|
+
title: "有未保存修改"
|
|
1821
|
+
})
|
|
1822
|
+
]
|
|
1654
1823
|
}, kind))
|
|
1655
1824
|
}),
|
|
1656
1825
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
@@ -1660,12 +1829,9 @@ function LibrarySettings({ readView: readView$1, writeView: writeView$1, subscri
|
|
|
1660
1829
|
className: "library-panel",
|
|
1661
1830
|
children: [
|
|
1662
1831
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1832
|
+
className: "library-banner",
|
|
1663
1833
|
style: BANNER.info,
|
|
1664
|
-
children: tab === "roles" ? /* @__PURE__ */ (0, react_jsx_runtime.
|
|
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
|
-
] }) : "编队支持逐个派遣,开启或关闭智能体团队均可使用。"
|
|
1834
|
+
children: tab === "roles" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: 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 })] }), "(默认模型按 profile 保存)。同一角色可多次派遣并按需换模型(授权范围见「内置插件 → 子智能体」);角色配置由编队共享。"] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: "角色配置由引用它的编队共享。同一角色可多次派遣并按需换模型(授权范围见「内置插件 → 子智能体」)。" }) }) : "编队支持逐个派遣,开启或关闭智能体团队均可使用。"
|
|
1669
1835
|
}),
|
|
1670
1836
|
view.diagnostics?.length ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
1671
1837
|
style: BANNER.warn,
|
|
@@ -1767,7 +1933,8 @@ function LibrarySettings({ readView: readView$1, writeView: writeView$1, subscri
|
|
|
1767
1933
|
const dirty = !equal(draft.base, form);
|
|
1768
1934
|
const refs = own(view.roleUsages, id) ?? [];
|
|
1769
1935
|
const blocked = form.kind === "groups" ? form.members.filter((m) => memberState(view, form, m)).length : 0;
|
|
1770
|
-
const
|
|
1936
|
+
const savedRole = form.kind === "roles" ? own(view.entries, id) : void 0;
|
|
1937
|
+
const roleState = savedRole && savedRole.enabled !== false ? availability(savedRole) : "";
|
|
1771
1938
|
const contentId = scope + tab + id;
|
|
1772
1939
|
function change(next) {
|
|
1773
1940
|
put(k, equal(draft.base, next) && !stale ? void 0 : {
|
|
@@ -1779,16 +1946,54 @@ function LibrarySettings({ readView: readView$1, writeView: writeView$1, subscri
|
|
|
1779
1946
|
});
|
|
1780
1947
|
setNotice(void 0);
|
|
1781
1948
|
}
|
|
1949
|
+
function toggleEnabled(checked) {
|
|
1950
|
+
const nextForm = {
|
|
1951
|
+
...form,
|
|
1952
|
+
enabled: checked
|
|
1953
|
+
};
|
|
1954
|
+
if (!isNew && !dirty && !stale && current) {
|
|
1955
|
+
const nextDraft = {
|
|
1956
|
+
...draft,
|
|
1957
|
+
form: nextForm,
|
|
1958
|
+
message: void 0,
|
|
1959
|
+
references: void 0
|
|
1960
|
+
};
|
|
1961
|
+
const error = validate(nextForm, currentView, false, draft.base);
|
|
1962
|
+
if (error) {
|
|
1963
|
+
put(k, {
|
|
1964
|
+
...nextDraft,
|
|
1965
|
+
message: error
|
|
1966
|
+
});
|
|
1967
|
+
setExpanded((old) => ({
|
|
1968
|
+
...old,
|
|
1969
|
+
[k]: true
|
|
1970
|
+
}));
|
|
1971
|
+
return;
|
|
1972
|
+
}
|
|
1973
|
+
const impact = form.kind === "roles" && !checked && refs.length ? ` ${refs.length} 名编队成员暂时无法派遣。` : "";
|
|
1974
|
+
write(saveWrite(nextDraft, currentView), {
|
|
1975
|
+
id,
|
|
1976
|
+
draft: nextDraft
|
|
1977
|
+
}, `已${checked ? "启用" : "停用"}${label} ${id}。${impact}`, {
|
|
1978
|
+
keepExpanded: open,
|
|
1979
|
+
focusSwitch: true
|
|
1980
|
+
});
|
|
1981
|
+
return;
|
|
1982
|
+
}
|
|
1983
|
+
change(nextForm);
|
|
1984
|
+
setExpanded((old) => ({
|
|
1985
|
+
...old,
|
|
1986
|
+
[k]: true
|
|
1987
|
+
}));
|
|
1988
|
+
}
|
|
1782
1989
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
|
|
1783
1990
|
className: "dsh-library-card",
|
|
1784
1991
|
"data-card": id,
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
...!form.enabled && S.rowOff,
|
|
1788
|
-
...open && S.rowOpen
|
|
1789
|
-
},
|
|
1992
|
+
"data-open": open ? "" : void 0,
|
|
1993
|
+
"data-disabled": !form.enabled ? "" : void 0,
|
|
1790
1994
|
children: [
|
|
1791
1995
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1996
|
+
className: "library-card-head",
|
|
1792
1997
|
style: S.head,
|
|
1793
1998
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1794
1999
|
type: "button",
|
|
@@ -1804,12 +2009,14 @@ function LibrarySettings({ readView: readView$1, writeView: writeView$1, subscri
|
|
|
1804
2009
|
})),
|
|
1805
2010
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1806
2011
|
"aria-hidden": "true",
|
|
2012
|
+
className: "library-card-chevron",
|
|
1807
2013
|
style: {
|
|
1808
2014
|
...S.chevron,
|
|
1809
2015
|
transform: open ? "rotate(90deg)" : void 0
|
|
1810
2016
|
},
|
|
1811
2017
|
children: "❯"
|
|
1812
2018
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2019
|
+
className: "library-card-title",
|
|
1813
2020
|
style: S.titleRow,
|
|
1814
2021
|
children: [
|
|
1815
2022
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
|
|
@@ -1836,40 +2043,48 @@ function LibrarySettings({ readView: readView$1, writeView: writeView$1, subscri
|
|
|
1836
2043
|
"aria-label": label + "启用状态",
|
|
1837
2044
|
checked: form.enabled,
|
|
1838
2045
|
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
|
-
}
|
|
2046
|
+
onChange: (e) => toggleEnabled(e.target.checked)
|
|
1849
2047
|
}), form.enabled ? "已启用" : "已停用"]
|
|
1850
2048
|
})]
|
|
1851
2049
|
}),
|
|
1852
2050
|
!open && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2051
|
+
className: "library-card-overview",
|
|
1853
2052
|
style: S.overview,
|
|
1854
2053
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1855
2054
|
style: S.excerpt,
|
|
1856
2055
|
children: form.description || "填写" + label + "的用途。"
|
|
1857
2056
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1858
2057
|
style: S.route,
|
|
1859
|
-
children: form.kind === "groups" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
2058
|
+
children: form.kind === "groups" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
2059
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2060
|
+
style: S.metaLabel,
|
|
2061
|
+
children: [form.members.length, " 名成员"]
|
|
2062
|
+
}),
|
|
2063
|
+
form.members.slice(0, 6).map((m, idx) => {
|
|
2064
|
+
const mState = memberState(view, form, m);
|
|
2065
|
+
const chipText = !m.slot || m.slot === m.role ? m.role || m.slot || `成员 ${idx + 1}` : `${m.slot} → ${m.role}`;
|
|
2066
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2067
|
+
className: "library-member-chip",
|
|
2068
|
+
style: mState && form.enabled ? S.dirtyChip : S.glyph,
|
|
2069
|
+
children: chipText
|
|
2070
|
+
}, idx);
|
|
2071
|
+
}),
|
|
2072
|
+
form.members.length > 6 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2073
|
+
style: S.glyph,
|
|
2074
|
+
children: ["+", form.members.length - 6]
|
|
2075
|
+
}),
|
|
2076
|
+
blocked > 0 && form.enabled && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2077
|
+
style: S.dirtyChip,
|
|
2078
|
+
children: [blocked, " 名暂时无法派遣"]
|
|
2079
|
+
})
|
|
2080
|
+
] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1866
2081
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1867
2082
|
style: S.metaLabel,
|
|
1868
2083
|
children: "模型"
|
|
1869
2084
|
}),
|
|
1870
2085
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
1871
2086
|
style: S.model,
|
|
1872
|
-
children: form.model || "
|
|
2087
|
+
children: form.model || "跟随主会话"
|
|
1873
2088
|
}),
|
|
1874
2089
|
form.provider && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
1875
2090
|
style: S.provider,
|
|
@@ -1932,7 +2147,8 @@ function LibrarySettings({ readView: readView$1, writeView: writeView$1, subscri
|
|
|
1932
2147
|
change,
|
|
1933
2148
|
view,
|
|
1934
2149
|
refs,
|
|
1935
|
-
jump
|
|
2150
|
+
jump,
|
|
2151
|
+
message: draft.message
|
|
1936
2152
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GroupFields, {
|
|
1937
2153
|
form,
|
|
1938
2154
|
isNew,
|
|
@@ -1992,12 +2208,13 @@ function LibrarySettings({ readView: readView$1, writeView: writeView$1, subscri
|
|
|
1992
2208
|
})]
|
|
1993
2209
|
}),
|
|
1994
2210
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
2211
|
+
className: "library-footer",
|
|
1995
2212
|
style: S.footer,
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
2000
|
-
style: S.
|
|
2213
|
+
onToggle: (e) => {
|
|
2214
|
+
if (e.currentTarget.open) e.currentTarget.scrollIntoView({ block: "nearest" });
|
|
2215
|
+
},
|
|
2216
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", { children: "存储与备份说明" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
2217
|
+
style: S.footerNote,
|
|
2001
2218
|
children: [
|
|
2002
2219
|
"角色保存在 ",
|
|
2003
2220
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: view.dir || "~/.dsh/subagents/" }),
|
|
@@ -2115,6 +2332,9 @@ const NS = "subagent-library";
|
|
|
2115
2332
|
const API_PATH = "/subagent-library/api";
|
|
2116
2333
|
/** Host error codes that carry no `message`; map them to user-facing text. */
|
|
2117
2334
|
const ERROR_TEXT = {
|
|
2335
|
+
"unauthorized": "请重新登录 DSH,再打开子代理库设置。",
|
|
2336
|
+
"forbidden": "当前身份无权管理子代理库设置。",
|
|
2337
|
+
"host-authentication-unavailable": "DSH 身份验证服务暂不可用,请稍后重试。",
|
|
2118
2338
|
"not-ready": "设置服务尚未就绪,请稍后重试。",
|
|
2119
2339
|
"readonly": "设置服务只读,无法完成该操作。",
|
|
2120
2340
|
"content-type-json-required": "请求被拒绝:写入只接受 JSON。",
|
|
@@ -2146,12 +2366,21 @@ const parseView = (value) => ({
|
|
|
2146
2366
|
...typeof value.profile === "string" && value.profile !== "" ? { profile: value.profile } : {},
|
|
2147
2367
|
...value.routeWriteProblem && { routeWriteProblem: value.routeWriteProblem }
|
|
2148
2368
|
});
|
|
2369
|
+
async function readSettingsBody(response) {
|
|
2370
|
+
if (!response.headers.get("content-type")?.includes("application/json")) {
|
|
2371
|
+
if (response.status === 401) return { error: "unauthorized" };
|
|
2372
|
+
if (response.status === 403) return { error: "forbidden" };
|
|
2373
|
+
if (response.status === 503) return { error: "not-ready" };
|
|
2374
|
+
}
|
|
2375
|
+
const body = await response.json();
|
|
2376
|
+
return typeof body === "object" && body !== null ? body : {};
|
|
2377
|
+
}
|
|
2149
2378
|
async function readView() {
|
|
2150
2379
|
const response = await fetch(API_PATH, { cache: "no-store" });
|
|
2151
|
-
const body = await response
|
|
2152
|
-
if (!response.ok ||
|
|
2153
|
-
const error = body
|
|
2154
|
-
const message = body
|
|
2380
|
+
const body = await readSettingsBody(response);
|
|
2381
|
+
if (!response.ok || body.ok !== true) {
|
|
2382
|
+
const error = body.error;
|
|
2383
|
+
const message = body.message;
|
|
2155
2384
|
throw new Error(message ?? (error !== void 0 ? ERROR_TEXT[error] : void 0) ?? "子代理库接口不可用(插件未加载?)");
|
|
2156
2385
|
}
|
|
2157
2386
|
return parseView(body);
|
|
@@ -2164,8 +2393,7 @@ async function writeView(write) {
|
|
|
2164
2393
|
body: JSON.stringify(write),
|
|
2165
2394
|
cache: "no-store"
|
|
2166
2395
|
});
|
|
2167
|
-
const
|
|
2168
|
-
const wire = typeof body === "object" && body !== null ? body : {};
|
|
2396
|
+
const wire = await readSettingsBody(response);
|
|
2169
2397
|
if (!response.ok || wire.ok !== true) return {
|
|
2170
2398
|
ok: false,
|
|
2171
2399
|
error: wire.error,
|