@darkbear9494/dsh-model-manager 0.1.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +314 -80
- package/client.js +277 -23
- package/cordis.patch.yml +15 -0
- package/lib/index.js +759 -37
- package/package.json +6 -4
package/client.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* Contributes a configuration page for this plugin's own row on the Plugins
|
|
5
5
|
* page. The row gains a configure control that opens a card with one model
|
|
6
6
|
* picker per role (main / planning / execution / vision) fed by the host's live
|
|
7
|
-
* model catalog, plus the
|
|
7
|
+
* model catalog, plus the shared selection strategy, the distribution mode and
|
|
8
|
+
* a per-role reasoning effort.
|
|
8
9
|
*
|
|
9
10
|
* Design constraints (from the harness's own plugin practices):
|
|
10
11
|
* - No Harness Client package is `require`d as a module. React comes from the
|
|
@@ -55,6 +56,22 @@ window.__ModuleLoader__.load({
|
|
|
55
56
|
const USAGE_PROJECTION_KEY = 'modelManagerUsage';
|
|
56
57
|
const ROLES = ['main', 'planning', 'execution', 'vision'];
|
|
57
58
|
const MODES = ['hybrid', 'managed', 'advisory'];
|
|
59
|
+
const DELEGATION_LEVELS = ['off', 'balanced', 'eager'];
|
|
60
|
+
/**
|
|
61
|
+
* This package's version, pinned for the browser half. The host reads the
|
|
62
|
+
* real manifest; the client cannot (no fs), so this constant is the
|
|
63
|
+
* fallback AND the primary source for the update banner —
|
|
64
|
+
* test/packaging.test.mjs pins it equal to package.json, so a release that
|
|
65
|
+
* forgets to bump both fails the suite instead of shipping a wrong banner.
|
|
66
|
+
*/
|
|
67
|
+
const VERSION = '0.4.0';
|
|
68
|
+
/**
|
|
69
|
+
* Registry path of this package. The scoped name is percent-encoded the
|
|
70
|
+
* way npm serves scoped packuments.
|
|
71
|
+
*/
|
|
72
|
+
const UPDATE_PACKAGE_PATH = '@darkbear9494%2fdsh-model-manager';
|
|
73
|
+
const UPDATE_REGISTRY_DEFAULT = 'https://registry.npmjs.org';
|
|
74
|
+
const UPDATE_FETCH_TIMEOUT_MS = 10_000;
|
|
58
75
|
/**
|
|
59
76
|
* How long to wait for the session-scoped catalog before relying on the
|
|
60
77
|
* global `remote.llm` directory alone. It is a bonus source (it carries
|
|
@@ -99,6 +116,21 @@ window.__ModuleLoader__.load({
|
|
|
99
116
|
pick: 'Selection',
|
|
100
117
|
pickFirst: 'first — use the top model, fall back down the list',
|
|
101
118
|
pickRoundRobin: 'round-robin — rotate across the list',
|
|
119
|
+
pickHint: 'One strategy for every role. "first" keeps each list as a failover chain; "round-robin" rotates across it.',
|
|
120
|
+
delegation: 'Auto delegation',
|
|
121
|
+
delegationOff: 'off — no delegation policy is added',
|
|
122
|
+
delegationBalanced: 'balanced — delegate multi-step and independent work',
|
|
123
|
+
delegationEager: 'eager — orchestrate: delegate nearly all substantive work',
|
|
124
|
+
delegationHint: 'Adds a system-prompt policy telling the top-level agent to plan and dispatch subagents instead of doing everything itself. Delegated children are never encouraged to delegate further; the policy only renders when the agent actually has the delegation tools.',
|
|
125
|
+
updateTitle: 'Update available',
|
|
126
|
+
updateBanner: 'Update available: {latest} (installed {current}).',
|
|
127
|
+
updateCommand: 'Upgrade: dsh plugin --profile <profile> add @darkbear9494/dsh-model-manager@latest, then restart the harness.',
|
|
128
|
+
updateChip: 'Update: {latest}',
|
|
129
|
+
updateChipHint: 'A newer @darkbear9494/dsh-model-manager is published. Click for the upgrade command.',
|
|
130
|
+
updateRecheck: 'Re-check',
|
|
131
|
+
updateChecking: 'Checking for updates…',
|
|
132
|
+
updateUpToDate: 'Up to date ({version}).',
|
|
133
|
+
updateFailed: 'Update check failed: {reason}',
|
|
102
134
|
orderHint: 'Order is the fallback order: the top model is tried first.',
|
|
103
135
|
usageTitle: 'Model usage',
|
|
104
136
|
usageModel: 'Provider / model',
|
|
@@ -148,6 +180,21 @@ window.__ModuleLoader__.load({
|
|
|
148
180
|
pick: '选择方式',
|
|
149
181
|
pickFirst: 'first — 优先用第一个,失败时按顺序向下回退',
|
|
150
182
|
pickRoundRobin: 'round-robin — 在列表内轮流使用',
|
|
183
|
+
pickHint: '所有角色共用这一个选择方式。"first" 把每个角色的列表当作回退链;"round-robin" 在列表内轮流使用。',
|
|
184
|
+
delegation: '自动委派',
|
|
185
|
+
delegationOff: 'off — 不注入任何委派策略',
|
|
186
|
+
delegationBalanced: 'balanced — 多步骤与可并行的任务交给子智能体',
|
|
187
|
+
delegationEager: 'eager — 全程编排:几乎所有实质工作都委派出去',
|
|
188
|
+
delegationHint: '向顶层智能体的系统提示注入委派策略,让它先规划再派发子智能体,而不是事事亲力亲为。被委派的子智能体不会被鼓励继续往下委派;策略只在智能体确实持有委派工具时生效。',
|
|
189
|
+
updateTitle: '有可用更新',
|
|
190
|
+
updateBanner: '有可用更新:{latest}(当前 {current})。',
|
|
191
|
+
updateCommand: '升级命令:dsh plugin --profile <profile> add @darkbear9494/dsh-model-manager@latest,执行后重启。',
|
|
192
|
+
updateChip: '更新:{latest}',
|
|
193
|
+
updateChipHint: '已发布更新的 @darkbear9494/dsh-model-manager。点击查看升级命令。',
|
|
194
|
+
updateRecheck: '重新检查',
|
|
195
|
+
updateChecking: '正在检查更新…',
|
|
196
|
+
updateUpToDate: '已是最新({version})。',
|
|
197
|
+
updateFailed: '更新检查失败:{reason}',
|
|
151
198
|
orderHint: '列表顺序即回退顺序:排在最前的模型优先使用。',
|
|
152
199
|
usageTitle: '模型用量',
|
|
153
200
|
usageModel: '提供方 / 模型',
|
|
@@ -231,7 +278,6 @@ window.__ModuleLoader__.load({
|
|
|
231
278
|
color: 'var(--dsw-alias-label-secondary)',
|
|
232
279
|
},
|
|
233
280
|
cellSpan: { gridColumn: '2 / -1' },
|
|
234
|
-
pickLabel: { fontSize: '0.76rem', color: 'var(--dsw-alias-label-secondary)' },
|
|
235
281
|
usage: { position: 'relative', display: 'inline-flex' },
|
|
236
282
|
usageButton: {
|
|
237
283
|
display: 'inline-flex',
|
|
@@ -305,6 +351,31 @@ window.__ModuleLoader__.load({
|
|
|
305
351
|
error: { fontSize: '0.76rem', color: 'var(--dsw-alias-state-error-primary)' },
|
|
306
352
|
ok: { fontSize: '0.76rem', color: 'var(--dsw-alias-state-success-primary)' },
|
|
307
353
|
summary: { fontSize: '0.8rem', color: 'var(--dsw-alias-label-secondary)' },
|
|
354
|
+
// The update banner: a warn-toned block with the upgrade command and a
|
|
355
|
+
// re-check action, so an available release is actionable, not just stated.
|
|
356
|
+
updateBanner: {
|
|
357
|
+
display: 'flex',
|
|
358
|
+
flexDirection: 'column',
|
|
359
|
+
gap: '0.3rem',
|
|
360
|
+
padding: '0.5rem 0.6rem',
|
|
361
|
+
borderRadius: 8,
|
|
362
|
+
border: '1px solid var(--dsw-alias-state-warn-primary)',
|
|
363
|
+
background: 'var(--dsw-alias-bg-layer-2)',
|
|
364
|
+
color: 'var(--dsw-alias-state-warn-primary)',
|
|
365
|
+
fontSize: '0.78rem',
|
|
366
|
+
},
|
|
367
|
+
updateBannerHead: { display: 'flex', alignItems: 'baseline', gap: '0.5rem', fontWeight: 600 },
|
|
368
|
+
updateBannerText: { color: 'var(--dsw-alias-label-primary)', fontFamily: 'ui-monospace, monospace', overflowWrap: 'anywhere' },
|
|
369
|
+
updateRecheck: {
|
|
370
|
+
alignSelf: 'flex-start',
|
|
371
|
+
padding: '0.15rem 0.5rem',
|
|
372
|
+
borderRadius: 6,
|
|
373
|
+
border: '1px solid var(--dsw-alias-border-l1)',
|
|
374
|
+
background: 'var(--dsw-alias-bg-layer-1)',
|
|
375
|
+
color: 'var(--dsw-alias-label-secondary)',
|
|
376
|
+
fontSize: '0.74rem',
|
|
377
|
+
cursor: 'pointer',
|
|
378
|
+
},
|
|
308
379
|
};
|
|
309
380
|
|
|
310
381
|
const routeKey = (provider, model) => `${provider}\u0000${model}`;
|
|
@@ -500,6 +571,107 @@ window.__ModuleLoader__.load({
|
|
|
500
571
|
safely('adapter updates', () => use(() => ctx.remote.$on('llm/adapters-updated', () => void loadCatalog()), 'model-manager: adapter updates'));
|
|
501
572
|
safely('settings updates', () => use(() => ctx.remote.$on('settings/document-updated', () => void loadCatalog()), 'model-manager: settings updates'));
|
|
502
573
|
|
|
574
|
+
// -- update check --------------------------------------------------------
|
|
575
|
+
// The host half checks on its own schedule (log line + model_manager tool
|
|
576
|
+
// action "update"); the browser cannot read that state, so this half runs
|
|
577
|
+
// the same comparison itself: one packument fetch per page load, plus one
|
|
578
|
+
// per settings save (the registry URL is row config) and per manual
|
|
579
|
+
// re-check. Offline or CORS-blocked deployments simply see no banner —
|
|
580
|
+
// the host log and the tool action still report the update.
|
|
581
|
+
const updateListeners = new Set();
|
|
582
|
+
const updateStore = { status: 'idle' };
|
|
583
|
+
const publishUpdate = (patch) => {
|
|
584
|
+
Object.assign(updateStore, patch, { at: Date.now() });
|
|
585
|
+
for (const listener of [...updateListeners]) {
|
|
586
|
+
try {
|
|
587
|
+
listener();
|
|
588
|
+
} catch {
|
|
589
|
+
/* a broken subscriber must not break the others */
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
const subscribeUpdate = (listener) => {
|
|
594
|
+
updateListeners.add(listener);
|
|
595
|
+
return () => updateListeners.delete(listener);
|
|
596
|
+
};
|
|
597
|
+
const getUpdateSnapshot = () => updateStore;
|
|
598
|
+
|
|
599
|
+
/** The registry URL from the row config, when the form is bound. */
|
|
600
|
+
const registryFromForm = () => {
|
|
601
|
+
try {
|
|
602
|
+
const snapshot = settingsGetSnapshot();
|
|
603
|
+
const registry = snapshot?.value?.update?.registry;
|
|
604
|
+
return typeof registry === 'string' && registry.trim() !== ''
|
|
605
|
+
? registry.trim().replace(/\/+$/, '') : undefined;
|
|
606
|
+
} catch {
|
|
607
|
+
return undefined;
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
/** Semver-shaped comparison, mirroring the host half's rules. */
|
|
612
|
+
const compareClientVersions = (a, b) => {
|
|
613
|
+
const parse = (input) => {
|
|
614
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(String(input ?? '').trim());
|
|
615
|
+
return match === null ? undefined : [Number(match[1]), Number(match[2]), Number(match[3]), match[4] ?? ''];
|
|
616
|
+
};
|
|
617
|
+
const left = parse(a);
|
|
618
|
+
const right = parse(b);
|
|
619
|
+
if (left === undefined || right === undefined) return undefined;
|
|
620
|
+
for (let index = 0; index < 3; index += 1) {
|
|
621
|
+
if (left[index] !== right[index]) return left[index] < right[index] ? -1 : 1;
|
|
622
|
+
}
|
|
623
|
+
// A release sorts above any prerelease; prerelease identifiers compare
|
|
624
|
+
// numerically when both are numeric, else in ASCII order.
|
|
625
|
+
const lp = left[3] === '' ? [] : left[3].split('.');
|
|
626
|
+
const rp = right[3] === '' ? [] : right[3].split('.');
|
|
627
|
+
if (lp.length === 0 && rp.length === 0) return 0;
|
|
628
|
+
if (lp.length === 0) return 1;
|
|
629
|
+
if (rp.length === 0) return -1;
|
|
630
|
+
for (let index = 0; index < lp.length || index < rp.length; index += 1) {
|
|
631
|
+
const x = lp[index];
|
|
632
|
+
const y = rp[index];
|
|
633
|
+
if (x === undefined) return -1;
|
|
634
|
+
if (y === undefined) return 1;
|
|
635
|
+
const xn = /^\d+$/.test(x);
|
|
636
|
+
const yn = /^\d+$/.test(y);
|
|
637
|
+
if (xn && yn) {
|
|
638
|
+
if (Number(x) !== Number(y)) return Number(x) < Number(y) ? -1 : 1;
|
|
639
|
+
} else if (xn) return -1;
|
|
640
|
+
else if (yn) return 1;
|
|
641
|
+
else if (x !== y) return x < y ? -1 : 1;
|
|
642
|
+
}
|
|
643
|
+
return 0;
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
const checkUpdates = async () => {
|
|
647
|
+
// Browser-only on purpose: a module test (or any non-page host) has no
|
|
648
|
+
// window.location, and firing a real registry fetch from a test would
|
|
649
|
+
// make the suite depend on the network.
|
|
650
|
+
if (typeof window === 'undefined' || window.location === undefined) return;
|
|
651
|
+
if (typeof fetch !== 'function') return;
|
|
652
|
+
publishUpdate({ status: 'checking' });
|
|
653
|
+
try {
|
|
654
|
+
const registry = registryFromForm() ?? UPDATE_REGISTRY_DEFAULT;
|
|
655
|
+
const signal = typeof AbortSignal?.timeout === 'function'
|
|
656
|
+
? AbortSignal.timeout(UPDATE_FETCH_TIMEOUT_MS) : undefined;
|
|
657
|
+
const response = await fetch(`${registry}/${UPDATE_PACKAGE_PATH}`, {
|
|
658
|
+
headers: { accept: 'application/vnd.npm.install-v1+json' },
|
|
659
|
+
...(signal === undefined ? {} : { signal }),
|
|
660
|
+
});
|
|
661
|
+
if (response?.ok !== true) throw new Error(`HTTP ${response?.status ?? '(no status)'}`);
|
|
662
|
+
const packument = await response.json();
|
|
663
|
+
const latest = packument?.['dist-tags']?.latest;
|
|
664
|
+
if (typeof latest !== 'string' || latest === '') throw new Error('no dist-tags.latest');
|
|
665
|
+
const order = compareClientVersions(latest, VERSION);
|
|
666
|
+
if (order === undefined) throw new Error(`unparseable version pair "${latest}" / "${VERSION}"`);
|
|
667
|
+
if (order > 0) publishUpdate({ status: 'available', latest, current: VERSION, registry });
|
|
668
|
+
else publishUpdate({ status: 'ok', latest, current: VERSION, registry });
|
|
669
|
+
} catch (error) {
|
|
670
|
+
publishUpdate({ status: 'error', reason: error?.message ?? String(error) });
|
|
671
|
+
}
|
|
672
|
+
};
|
|
673
|
+
safely('settings updates (update re-check)', () => use(() => ctx.remote.$on('settings/document-updated', () => void checkUpdates()), 'model-manager: settings update re-check'));
|
|
674
|
+
|
|
503
675
|
// -- lookups ------------------------------------------------------------
|
|
504
676
|
const modelIn = (provider, model) => {
|
|
505
677
|
for (const group of catalog.groups) {
|
|
@@ -533,6 +705,7 @@ window.__ModuleLoader__.load({
|
|
|
533
705
|
function Card(props) {
|
|
534
706
|
const state = React.useSyncExternalStore(subscribe, getSnapshot);
|
|
535
707
|
const shared = React.useSyncExternalStore(settingsSubscribe, settingsGetSnapshot);
|
|
708
|
+
const update = React.useSyncExternalStore(subscribeUpdate, getUpdateSnapshot, getUpdateSnapshot);
|
|
536
709
|
const [status, setStatus] = React.useState(null);
|
|
537
710
|
const view = props?.view;
|
|
538
711
|
const form = props?.form ?? settingsForm;
|
|
@@ -540,6 +713,9 @@ window.__ModuleLoader__.load({
|
|
|
540
713
|
const value = isObject(snapshot?.value) ? snapshot.value : {};
|
|
541
714
|
const roles = isObject(value.roles) ? value.roles : {};
|
|
542
715
|
const mode = isObject(value.strategy) && typeof value.strategy.mode === 'string' ? value.strategy.mode : 'hybrid';
|
|
716
|
+
const pick = value.pick === 'round-robin' ? 'round-robin' : 'first';
|
|
717
|
+
const autoDelegate = isObject(value.strategy) && DELEGATION_LEVELS.includes(value.strategy.autoDelegate)
|
|
718
|
+
? value.strategy.autoDelegate : 'balanced';
|
|
543
719
|
|
|
544
720
|
const summary = () => {
|
|
545
721
|
const parts = ROLES
|
|
@@ -710,26 +886,6 @@ window.__ModuleLoader__.load({
|
|
|
710
886
|
h('option', { key: '', value: '' }, t('addModel')),
|
|
711
887
|
...modelOptions(used)));
|
|
712
888
|
|
|
713
|
-
if (models.length > 1) {
|
|
714
|
-
const holder = roles[role];
|
|
715
|
-
const pick = holder !== null && typeof holder === 'object' && holder.pick === 'round-robin'
|
|
716
|
-
? 'round-robin' : 'first';
|
|
717
|
-
cells.push(h('span', {
|
|
718
|
-
key: 'pick',
|
|
719
|
-
style: { ...S.cellSpan, display: 'inline-flex', alignItems: 'center', gap: '0.45rem' },
|
|
720
|
-
},
|
|
721
|
-
h('span', { style: S.pickLabel }, t('pick')),
|
|
722
|
-
h('select', {
|
|
723
|
-
style: { ...S.selectGrid, ...S.selectEffortGrid },
|
|
724
|
-
value: pick,
|
|
725
|
-
disabled: !ready,
|
|
726
|
-
'aria-label': `${t(roleKeyFor(role))} — ${t('pick')}`,
|
|
727
|
-
onChange: (event) => write([{ op: 'set', path: ['roles', role, 'pick'], value: event.target.value }]),
|
|
728
|
-
},
|
|
729
|
-
h('option', { key: 'first', value: 'first' }, t('pickFirst')),
|
|
730
|
-
h('option', { key: 'rr', value: 'round-robin' }, t('pickRoundRobin')))));
|
|
731
|
-
}
|
|
732
|
-
|
|
733
889
|
return h('div', { key: role, style: S.row },
|
|
734
890
|
h('label', { style: S.label }, t(roleKeyFor(role))),
|
|
735
891
|
h('span', { style: S.hint }, t(hintKeyFor(role))),
|
|
@@ -748,6 +904,62 @@ window.__ModuleLoader__.load({
|
|
|
748
904
|
onChange: (event) => write([{ op: 'set', path: ['strategy', 'mode'], value: event.target.value }]),
|
|
749
905
|
}, ...MODES.map((name) => h('option', { key: name, value: name }, t(modeKeyFor(name)))))));
|
|
750
906
|
|
|
907
|
+
// One selection strategy for every role (since 0.2.0): the value is
|
|
908
|
+
// top-level, and the per-role controls are gone by design.
|
|
909
|
+
const pickControl = h('div', { style: S.row },
|
|
910
|
+
h('label', { style: S.label }, t('pick')),
|
|
911
|
+
h('div', { style: S.controls },
|
|
912
|
+
h('select', {
|
|
913
|
+
style: S.select,
|
|
914
|
+
value: pick,
|
|
915
|
+
disabled: !ready,
|
|
916
|
+
'aria-label': t('pick'),
|
|
917
|
+
onChange: (event) => write([{ op: 'set', path: ['pick'], value: event.target.value }]),
|
|
918
|
+
},
|
|
919
|
+
h('option', { key: 'first', value: 'first' }, t('pickFirst')),
|
|
920
|
+
h('option', { key: 'rr', value: 'round-robin' }, t('pickRoundRobin')))),
|
|
921
|
+
h('span', { style: S.hint }, t('pickHint')));
|
|
922
|
+
|
|
923
|
+
// Auto-delegation level: the system-prompt policy that tells the
|
|
924
|
+
// top-level agent to plan and dispatch subagents. Written the same way
|
|
925
|
+
// as pick/mode, so a save applies live through the volatile namespace.
|
|
926
|
+
const delegationControl = h('div', { style: S.row },
|
|
927
|
+
h('label', { style: S.label }, t('delegation')),
|
|
928
|
+
h('div', { style: S.controls },
|
|
929
|
+
h('select', {
|
|
930
|
+
style: S.select,
|
|
931
|
+
value: DELEGATION_LEVELS.includes(autoDelegate) ? autoDelegate : 'balanced',
|
|
932
|
+
disabled: !ready,
|
|
933
|
+
'aria-label': t('delegation'),
|
|
934
|
+
onChange: (event) => write([{ op: 'set', path: ['strategy', 'autoDelegate'], value: event.target.value }]),
|
|
935
|
+
},
|
|
936
|
+
h('option', { key: 'off', value: 'off' }, t('delegationOff')),
|
|
937
|
+
h('option', { key: 'balanced', value: 'balanced' }, t('delegationBalanced')),
|
|
938
|
+
h('option', { key: 'eager', value: 'eager' }, t('delegationEager')))),
|
|
939
|
+
h('span', { style: S.hint }, t('delegationHint')));
|
|
940
|
+
|
|
941
|
+
// The update banner renders from the client-side update store (one
|
|
942
|
+
// packument fetch per page load), not from the form: the host runs its
|
|
943
|
+
// own check, and the two agree because both compare against the same
|
|
944
|
+
// registry packument.
|
|
945
|
+
let updateBanner = null;
|
|
946
|
+
if (update.status === 'available') {
|
|
947
|
+
updateBanner = h('div', { key: 'update', style: S.updateBanner },
|
|
948
|
+
h('div', { style: S.updateBannerHead }, t('updateTitle')),
|
|
949
|
+
h('div', { style: S.updateBannerText }, t('updateBanner', { latest: update.latest, current: update.current })),
|
|
950
|
+
h('div', { style: S.updateBannerText }, t('updateCommand')),
|
|
951
|
+
h('button', {
|
|
952
|
+
type: 'button',
|
|
953
|
+
style: S.updateRecheck,
|
|
954
|
+
onClick: () => void checkUpdates(),
|
|
955
|
+
}, t('updateRecheck')));
|
|
956
|
+
} else if (update.status === 'checking') {
|
|
957
|
+
updateBanner = h('div', { key: 'update-checking', style: S.notice }, t('updateChecking'));
|
|
958
|
+
} else if (update.status === 'error' && update.reason !== undefined) {
|
|
959
|
+
updateBanner = h('div', { key: 'update-error', style: S.notice },
|
|
960
|
+
t('updateFailed', { reason: update.reason }));
|
|
961
|
+
}
|
|
962
|
+
|
|
751
963
|
const notices = [];
|
|
752
964
|
if (!ready && snapshot.status === 'ready') notices.push(h('div', { key: 'ro', style: S.notice }, t('readOnly')));
|
|
753
965
|
if (state.status === 'loading') notices.push(h('div', { key: 'load', style: S.notice }, t('loading')));
|
|
@@ -784,9 +996,12 @@ window.__ModuleLoader__.load({
|
|
|
784
996
|
h('span', { style: S.hint }, t('enableHint')));
|
|
785
997
|
|
|
786
998
|
return h('div', { style: S.root },
|
|
999
|
+
updateBanner,
|
|
787
1000
|
h('p', { style: S.help }, t('help')),
|
|
788
1001
|
enableToggle,
|
|
789
1002
|
...ROLES.map((role) => row(role)),
|
|
1003
|
+
pickControl,
|
|
1004
|
+
delegationControl,
|
|
790
1005
|
modeControl,
|
|
791
1006
|
...notices);
|
|
792
1007
|
}
|
|
@@ -880,6 +1095,40 @@ window.__ModuleLoader__.load({
|
|
|
880
1095
|
}, UsageView));
|
|
881
1096
|
}));
|
|
882
1097
|
|
|
1098
|
+
// -- update-available chip, rendered in the session header ----------------
|
|
1099
|
+
// A persistent, visible prompt while an update is outstanding: the chip
|
|
1100
|
+
// sits next to the usage button and disappears the moment the banner's
|
|
1101
|
+
// store says "up to date". It reads the same client-side update store as
|
|
1102
|
+
// the settings banner, so the two never disagree.
|
|
1103
|
+
function UpdateChip() {
|
|
1104
|
+
const update = React.useSyncExternalStore(subscribeUpdate, getUpdateSnapshot, getUpdateSnapshot);
|
|
1105
|
+
const [open, setOpen] = React.useState(false);
|
|
1106
|
+
if (update?.status !== 'available') return null;
|
|
1107
|
+
return h('span', { style: S.usage }, [
|
|
1108
|
+
h('button', {
|
|
1109
|
+
type: 'button',
|
|
1110
|
+
style: S.usageButton,
|
|
1111
|
+
'aria-haspopup': 'dialog',
|
|
1112
|
+
'aria-expanded': open,
|
|
1113
|
+
title: t('updateChipHint'),
|
|
1114
|
+
onClick: () => setOpen((current) => !current),
|
|
1115
|
+
}, t('updateChip', { latest: update.latest })),
|
|
1116
|
+
...(open ? [h('div', { style: S.usagePanel, role: 'dialog', 'aria-label': t('updateTitle') }, [
|
|
1117
|
+
h('div', { style: S.usageHead }, [h('span', null, t('updateTitle'))]),
|
|
1118
|
+
h('div', { key: 'line', style: S.usageEmpty },
|
|
1119
|
+
t('updateBanner', { latest: update.latest, current: update.current })),
|
|
1120
|
+
h('div', { key: 'cmd', style: S.usageEmpty }, t('updateCommand')),
|
|
1121
|
+
])] : []),
|
|
1122
|
+
]);
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
safely('session update surface', () => ctx.slots.inject('conversation.session.header.utilities', () => ctx.slots.register({
|
|
1126
|
+
name: 'conversation.session.header.utilities',
|
|
1127
|
+
id: 'model-manager-update',
|
|
1128
|
+
order: 70,
|
|
1129
|
+
locale: LOCALE_NS,
|
|
1130
|
+
}, UpdateChip)));
|
|
1131
|
+
|
|
883
1132
|
safely('settings page', () => use(() => ctx.slots.inject('settings.section', () => {
|
|
884
1133
|
const disposer = ctx.slots.register({
|
|
885
1134
|
name: 'settings.section',
|
|
@@ -909,11 +1158,16 @@ window.__ModuleLoader__.load({
|
|
|
909
1158
|
}
|
|
910
1159
|
}));
|
|
911
1160
|
|
|
1161
|
+
// The initial update check runs after the form binds, so a custom
|
|
1162
|
+
// `update.registry` in the row config is honoured on the very first fetch.
|
|
1163
|
+
safely('initial update check', () => void checkUpdates());
|
|
1164
|
+
|
|
912
1165
|
// One success line, so the browser console distinguishes "never applied"
|
|
913
1166
|
// from "applied but a step failed" (each failed step logs its own
|
|
914
1167
|
// `[model-manager] <step>: <error>` warning immediately above this).
|
|
915
1168
|
try {
|
|
916
|
-
console.log('[model-manager] client half applied; locale registered,
|
|
1169
|
+
console.log('[model-manager] client half applied; locale registered, 3 registrations across 2 '
|
|
1170
|
+
+ 'surfaces (settings section; session header utilities: usage + update chip)');
|
|
917
1171
|
} catch {
|
|
918
1172
|
/* logging is best-effort */
|
|
919
1173
|
}
|
package/cordis.patch.yml
CHANGED
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
- id: model-manager
|
|
16
16
|
name: '@darkbear9494/dsh-model-manager'
|
|
17
17
|
config:
|
|
18
|
+
# One selection strategy for every role (0.2.0): first | round-robin.
|
|
19
|
+
# `first` treats each role's ordered list as a failover chain;
|
|
20
|
+
# `round-robin` rotates across each role's list.
|
|
21
|
+
pick: first
|
|
18
22
|
roles:
|
|
19
23
|
# Main agent outside plan mode. Empty = leave the composer choice alone.
|
|
20
24
|
main:
|
|
@@ -34,3 +38,14 @@
|
|
|
34
38
|
models: []
|
|
35
39
|
strategy:
|
|
36
40
|
mode: hybrid
|
|
41
|
+
# Auto-delegation policy (0.3.0): off | balanced | eager.
|
|
42
|
+
# Adds a system-prompt section telling the top-level agent to plan
|
|
43
|
+
# and dispatch subagents instead of doing everything itself.
|
|
44
|
+
autoDelegate: balanced
|
|
45
|
+
# Automatic update check (0.3.0): boot + every intervalHours against
|
|
46
|
+
# the registry; a newer release is logged and surfaced by the
|
|
47
|
+
# model_manager tool and the Web card. intervalHours: 0 = boot only.
|
|
48
|
+
update:
|
|
49
|
+
enabled: true
|
|
50
|
+
registry: https://registry.npmjs.org
|
|
51
|
+
intervalHours: 24
|