dsh-agent-team-presets 0.3.1 → 0.3.2
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/NOTICE +6 -4
- package/README.md +18 -11
- package/README.zh.md +17 -10
- package/assets/card-patches/catalog.json +25 -0
- package/assets/card-patches/dsh-better-sidebar-0.32.1.client.js.gz +0 -0
- package/assets/card-patches/dsh-context-0.84.1.client.js.gz +0 -0
- package/lib/client.js +62 -11
- package/lib/index.js +224 -19
- package/lib/typert.host.js +16 -3
- package/lib/typert.remote-client.d.ts.map +1 -1
- package/lib/typert.remote-client.js +16 -3
- package/lib/types/builtin-skill.js +1 -1
- package/lib/types/builtin-teams.d.ts +14 -0
- package/lib/types/builtin-teams.js +18 -0
- package/lib/types/card-patches.d.ts +71 -4
- package/lib/types/card-patches.js +222 -6
- package/lib/types/client/CardPatchView.js +14 -2
- package/lib/types/client/TeamListView.d.ts +5 -0
- package/lib/types/client/TeamListView.js +1 -1
- package/lib/types/client/TeamPresetsSection.js +7 -1
- package/lib/types/client/card-patches-controller.js +16 -5
- package/lib/types/client/locales.d.ts +1 -1
- package/lib/types/client/locales.js +2 -0
- package/lib/types/settings-reconcile.js +9 -1
- package/lib/types/tool-catalog.js +12 -10
- package/lib/types/types.d.ts +5 -1
- package/package.json +56 -51
|
@@ -28,13 +28,15 @@ import { dirname, join } from 'node:path';
|
|
|
28
28
|
import { fileURLToPath } from 'node:url';
|
|
29
29
|
import { gunzipSync } from 'node:zlib';
|
|
30
30
|
/**
|
|
31
|
-
* The
|
|
31
|
+
* The versions compiled into this build.
|
|
32
32
|
*
|
|
33
|
-
* Each entry is
|
|
34
|
-
*
|
|
35
|
-
*
|
|
33
|
+
* Each entry is a finished artifact: the replacement is a whole-bundle build, so
|
|
34
|
+
* a different version's bundle would silently change behaviour that was never
|
|
35
|
+
* reviewed here. Newer versions are added by `tools/card-patches.mjs`, which
|
|
36
|
+
* verifies the rebuild first and then writes them to the shipped catalog
|
|
37
|
+
* overlay; nothing here needs to change for that.
|
|
36
38
|
*/
|
|
37
|
-
|
|
39
|
+
const COMPILED_TARGETS = [
|
|
38
40
|
{
|
|
39
41
|
id: 'dsh-context',
|
|
40
42
|
packageName: 'dsh-context',
|
|
@@ -56,6 +58,141 @@ export const CARD_PATCH_TARGETS = [
|
|
|
56
58
|
patchedSha256: 'd0a9f0257e80fb3fdf6eb06a587b5b5aa985e1cfbaaf7a187ee381da0a8ac7ba',
|
|
57
59
|
},
|
|
58
60
|
];
|
|
61
|
+
/** Version of the shipped catalog overlay document; a different one is ignored. */
|
|
62
|
+
export const CARD_PATCH_CATALOG_VERSION = 1;
|
|
63
|
+
/** The shipped overlay: entries a build produced for versions this code predates. */
|
|
64
|
+
function shippedCatalogFile() {
|
|
65
|
+
return join(shippedAssets(), 'catalog.json');
|
|
66
|
+
}
|
|
67
|
+
/** One validated overlay entry, or a message naming what is wrong with it. */
|
|
68
|
+
function catalogString(row, field, pattern, hint) {
|
|
69
|
+
const value = row[field];
|
|
70
|
+
if (typeof value !== 'string' || !pattern.test(value)) {
|
|
71
|
+
throw new Error(`${field} ${hint}: ${JSON.stringify(value)}`);
|
|
72
|
+
}
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Validate one overlay entry.
|
|
77
|
+
*
|
|
78
|
+
* The overlay is data, not code, so it may be edited by hand or written by an
|
|
79
|
+
* older tool; every field is checked against the same shape the compiled
|
|
80
|
+
* entries use. An entry that fails is a reason to ignore the whole document,
|
|
81
|
+
* because acting on part of it would make "what does this build support"
|
|
82
|
+
* depend on JSON key order.
|
|
83
|
+
* @param candidate - one parsed entry.
|
|
84
|
+
* @returns the normalized target.
|
|
85
|
+
* @throws when any field is unusable.
|
|
86
|
+
*/
|
|
87
|
+
export function normalizeCatalogTarget(candidate) {
|
|
88
|
+
if (candidate === null || typeof candidate !== 'object' || Array.isArray(candidate)) {
|
|
89
|
+
throw new Error('the entry is not an object');
|
|
90
|
+
}
|
|
91
|
+
const row = candidate;
|
|
92
|
+
const pristineSha256 = catalogString(row, 'pristineSha256', /^[0-9a-f]{64}$/, 'must be 64 lowercase hex characters');
|
|
93
|
+
const patchedSha256 = catalogString(row, 'patchedSha256', /^[0-9a-f]{64}$/, 'must be 64 lowercase hex characters');
|
|
94
|
+
if (pristineSha256 === patchedSha256) {
|
|
95
|
+
throw new Error('pristineSha256 and patchedSha256 must differ, or the replacement would be the published build');
|
|
96
|
+
}
|
|
97
|
+
const source = row['source'];
|
|
98
|
+
if (typeof source !== 'string' || source.trim() === '' || /\s/.test(source)) {
|
|
99
|
+
throw new Error(`source must be one non-empty token: ${JSON.stringify(source)}`);
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
id: catalogString(row, 'id', /^[a-z0-9]+(?:-[a-z0-9]+)*$/, 'must be lowercase words joined by hyphens'),
|
|
103
|
+
packageName: catalogString(row, 'packageName', /^[a-z0-9][a-z0-9._-]*$/, 'must be a bare package name'),
|
|
104
|
+
version: catalogString(row, 'version', /^\d+\.\d+\.\d+(?:-[0-9A-Za-z]+(?:\.[0-9A-Za-z]+)*)?$/, 'must be a semver version'),
|
|
105
|
+
source,
|
|
106
|
+
asset: catalogString(row, 'asset', /^[a-z0-9][a-z0-9._-]*\.client\.js\.gz$/, 'must be a bare `<name>.client.js.gz` file name'),
|
|
107
|
+
service: catalogString(row, 'service', /^[A-Za-z_$][A-Za-z0-9_$]*$/, 'must be a JavaScript identifier'),
|
|
108
|
+
pristineSha256,
|
|
109
|
+
patchedSha256,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Parse a shipped catalog overlay document.
|
|
114
|
+
* @param text - the document text.
|
|
115
|
+
* @returns every entry it declares.
|
|
116
|
+
* @throws when the document or any entry is unusable.
|
|
117
|
+
*/
|
|
118
|
+
export function parseCardPatchCatalog(text) {
|
|
119
|
+
const document = JSON.parse(text);
|
|
120
|
+
if (document === null || typeof document !== 'object' || Array.isArray(document)) {
|
|
121
|
+
throw new Error('the catalog is not an object');
|
|
122
|
+
}
|
|
123
|
+
const version = document.version;
|
|
124
|
+
if (version !== CARD_PATCH_CATALOG_VERSION) {
|
|
125
|
+
throw new Error(`the catalog version is ${JSON.stringify(version)}, not ${CARD_PATCH_CATALOG_VERSION}`);
|
|
126
|
+
}
|
|
127
|
+
const targets = document.targets;
|
|
128
|
+
if (!Array.isArray(targets))
|
|
129
|
+
throw new Error('the catalog has no targets array');
|
|
130
|
+
return targets.map(normalizeCatalogTarget);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Combine the compiled baseline with the shipped overlay.
|
|
134
|
+
*
|
|
135
|
+
* Entries are keyed by identity *and* version, not by identity alone: keeping
|
|
136
|
+
* the already-supported versions is the whole point of shipping a replacement
|
|
137
|
+
* per version, so rebuilding 0.84.1 must not drop 0.84.0 for the installations
|
|
138
|
+
* still on it. Only the exact pair is replaced when the same version is rebuilt.
|
|
139
|
+
* Compiled order is kept, because that is the order the settings page lists.
|
|
140
|
+
* @param baseline - entries compiled into this build.
|
|
141
|
+
* @param overlay - entries read from the shipped catalog.
|
|
142
|
+
* @returns the merged catalog.
|
|
143
|
+
*/
|
|
144
|
+
export function mergeCatalogTargets(baseline, overlay) {
|
|
145
|
+
const key = (entry) => `${entry.id}@${entry.version}`;
|
|
146
|
+
const byKey = new Map(overlay.map(entry => [key(entry), entry]));
|
|
147
|
+
const merged = baseline.map(entry => byKey.get(key(entry)) ?? entry);
|
|
148
|
+
// Numeric collation, so appending 0.9.0 after 0.10.0 is impossible: "newest
|
|
149
|
+
// last" is what the settings row and the resolver rely on.
|
|
150
|
+
const order = { numeric: true };
|
|
151
|
+
for (const [entryKey, entry] of [...byKey].sort(([left], [right]) => left.localeCompare(right, 'en', order))) {
|
|
152
|
+
if (!baseline.some(current => key(current) === entryKey))
|
|
153
|
+
merged.push(entry);
|
|
154
|
+
}
|
|
155
|
+
return merged;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The distinct target identities, in catalog order.
|
|
159
|
+
* @param targets - the catalog to read.
|
|
160
|
+
* @returns one identity per target, first occurrence order.
|
|
161
|
+
*/
|
|
162
|
+
export function catalogIdentities(targets = CARD_PATCH_TARGETS) {
|
|
163
|
+
return [...new Set(targets.map(target => target.id))];
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Every catalog entry for one identity.
|
|
167
|
+
* @param id - the target identity.
|
|
168
|
+
* @param targets - the catalog to read.
|
|
169
|
+
* @returns its entries, oldest build first.
|
|
170
|
+
*/
|
|
171
|
+
export function catalogTargetsFor(id, targets = CARD_PATCH_TARGETS) {
|
|
172
|
+
return targets.filter(target => target.id === id);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Read the shipped overlay, or nothing when it is absent or unusable.
|
|
176
|
+
*
|
|
177
|
+
* A broken overlay must not take the whole settings page down: it is optional
|
|
178
|
+
* data, so a refusal here falls back to the versions compiled into this build
|
|
179
|
+
* and says so in the log.
|
|
180
|
+
* @returns the overlay entries.
|
|
181
|
+
*/
|
|
182
|
+
function readShippedCatalog() {
|
|
183
|
+
const file = shippedCatalogFile();
|
|
184
|
+
if (!existsSync(file))
|
|
185
|
+
return [];
|
|
186
|
+
try {
|
|
187
|
+
return parseCardPatchCatalog(readFileSync(file, 'utf8'));
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
console.warn(`[team-presets] ignoring the shipped card-patch catalog: ${error instanceof Error ? error.message : String(error)}`);
|
|
191
|
+
return [];
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/** Every version this build can patch: the compiled baseline plus the overlay. */
|
|
195
|
+
export const CARD_PATCH_TARGETS = mergeCatalogTargets(COMPILED_TARGETS, readShippedCatalog());
|
|
59
196
|
/** Directory holding the prebuilt replacements shipped with this package. */
|
|
60
197
|
function shippedAssets() {
|
|
61
198
|
// Built output lives in `lib/`, one level below the package root.
|
|
@@ -133,7 +270,9 @@ export function targetState(target, env = realCardPatchEnvironment) {
|
|
|
133
270
|
id: target.id,
|
|
134
271
|
packageName: target.packageName,
|
|
135
272
|
source: target.source,
|
|
273
|
+
service: target.service,
|
|
136
274
|
supportedVersion: target.version,
|
|
275
|
+
supportedVersions: [target.version],
|
|
137
276
|
};
|
|
138
277
|
const directory = env.resolvePackage(target.packageName);
|
|
139
278
|
if (directory === undefined) {
|
|
@@ -271,5 +410,82 @@ export function uninstallCardPatch(target, env = realCardPatchEnvironment) {
|
|
|
271
410
|
* @returns the entry, or undefined for an id this build does not ship.
|
|
272
411
|
*/
|
|
273
412
|
export function findCardPatchTarget(id) {
|
|
274
|
-
|
|
413
|
+
// The catalog appends in build order, so the last entry for an identity is the
|
|
414
|
+
// newest version this build can patch.
|
|
415
|
+
return catalogTargetsFor(id).at(-1);
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Classify one identity by the version that is actually installed.
|
|
419
|
+
*
|
|
420
|
+
* Several catalog entries may exist for the same target, one per supported
|
|
421
|
+
* upstream version; which one is relevant depends entirely on the installed
|
|
422
|
+
* package, so the choice belongs here rather than at each call site. A version
|
|
423
|
+
* this build has no replacement for reports `unsupported` and names the
|
|
424
|
+
* versions it does ship, which is what tells an operator whether to update the
|
|
425
|
+
* target plugin or this one.
|
|
426
|
+
* @param entries - every catalog entry for one identity, oldest first.
|
|
427
|
+
* @param env - the file-system facts to read through.
|
|
428
|
+
* @returns the row the settings page renders.
|
|
429
|
+
*/
|
|
430
|
+
export function resolveTargetView(entries, env = realCardPatchEnvironment) {
|
|
431
|
+
const newest = entries.at(-1);
|
|
432
|
+
if (newest === undefined)
|
|
433
|
+
throw new Error('a card-patch target needs at least one catalog entry');
|
|
434
|
+
const supportedVersions = entries.map(entry => entry.version);
|
|
435
|
+
const base = {
|
|
436
|
+
id: newest.id,
|
|
437
|
+
packageName: newest.packageName,
|
|
438
|
+
source: newest.source,
|
|
439
|
+
service: newest.service,
|
|
440
|
+
supportedVersion: newest.version,
|
|
441
|
+
supportedVersions,
|
|
442
|
+
};
|
|
443
|
+
const directory = env.resolvePackage(newest.packageName);
|
|
444
|
+
if (directory === undefined) {
|
|
445
|
+
return { ...base, state: 'absent', detail: 'this plugin is not installed in the running profile' };
|
|
446
|
+
}
|
|
447
|
+
const installed = installedVersion(directory);
|
|
448
|
+
if (installed === undefined) {
|
|
449
|
+
return { ...base, state: 'absent', detail: 'its package.json could not be read' };
|
|
450
|
+
}
|
|
451
|
+
const target = entries.find(entry => entry.version === installed);
|
|
452
|
+
if (target === undefined) {
|
|
453
|
+
return {
|
|
454
|
+
...base,
|
|
455
|
+
installedVersion: installed,
|
|
456
|
+
state: 'unsupported',
|
|
457
|
+
detail: `this build ships a replacement for ${supportedVersions.join(', ')}, not ${installed}`,
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
return { ...targetState(target, env), supportedVersions };
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Resolve the catalog entry that matches the installed version of one target.
|
|
464
|
+
* @param id - the target identity.
|
|
465
|
+
* @param env - the file-system facts to read through.
|
|
466
|
+
* @param targets - the catalog to read.
|
|
467
|
+
* @returns the entry to patch, when this build has one for that exact version.
|
|
468
|
+
*/
|
|
469
|
+
export function resolveInstalledTarget(id, env = realCardPatchEnvironment, targets = CARD_PATCH_TARGETS) {
|
|
470
|
+
const entries = catalogTargetsFor(id, targets);
|
|
471
|
+
if (entries.length === 0) {
|
|
472
|
+
const absent = {
|
|
473
|
+
id,
|
|
474
|
+
packageName: id,
|
|
475
|
+
source: 'unknown',
|
|
476
|
+
service: id,
|
|
477
|
+
supportedVersion: '',
|
|
478
|
+
supportedVersions: [],
|
|
479
|
+
state: 'absent',
|
|
480
|
+
detail: `this build ships no card patch for "${id}"`,
|
|
481
|
+
};
|
|
482
|
+
return { view: absent };
|
|
483
|
+
}
|
|
484
|
+
const view = resolveTargetView(entries, env);
|
|
485
|
+
if (view.state === 'absent' || view.state === 'unsupported')
|
|
486
|
+
return { view };
|
|
487
|
+
const target = entries.find(entry => entry.version === view.supportedVersion);
|
|
488
|
+
// `exactOptionalPropertyTypes` forbids assigning `undefined` to an optional
|
|
489
|
+
// property, so the "no matching entry" case is its own return.
|
|
490
|
+
return target === undefined ? { view } : { target, view };
|
|
275
491
|
}
|
|
@@ -54,6 +54,18 @@ function ResultLine({ result, t }) {
|
|
|
54
54
|
: t('patchRefused');
|
|
55
55
|
return (_jsxs("p", { className: result.ok ? css.result : css.resultFailed, role: "status", children: [text, result.detail === undefined ? null : _jsxs("span", { className: css.detail, children: [" \u2014 ", result.detail] })] }));
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* The versions a row can patch, as text.
|
|
59
|
+
*
|
|
60
|
+
* A Host that predates the multi-version catalog sends no `supportedVersions`,
|
|
61
|
+
* and the page must still render the single version it does report: the client
|
|
62
|
+
* bundle reloads on its own while the Host only changes on restart.
|
|
63
|
+
* @param target - the row.
|
|
64
|
+
* @returns the versions, comma separated.
|
|
65
|
+
*/
|
|
66
|
+
function versionsOf(target) {
|
|
67
|
+
return (target.supportedVersions ?? [target.supportedVersion]).join(', ');
|
|
68
|
+
}
|
|
57
69
|
/**
|
|
58
70
|
* Render one target with its state and the action that state allows.
|
|
59
71
|
* @param props - the row facts and the action callback.
|
|
@@ -68,7 +80,7 @@ function Row({ target, live, busy, phase, t, onAct }) {
|
|
|
68
80
|
// A patched bundle that has not been served yet is the one case where the row
|
|
69
81
|
// must say "restart", because nothing is wrong with the file itself.
|
|
70
82
|
const waiting = target.state === 'patched' && !live;
|
|
71
|
-
return (_jsxs("li", { className: css.row, children: [_jsxs("div", { className: css.rowHead, children: [_jsx("code", { className: css.packageName, children: target.packageName }), _jsx("span", { className: css.badge, "data-state": target.state, children: t(STATE_KEYS[target.state]) }), target.state === 'patched' && live ? _jsx("span", { className: css.live, children: t('patchActive') }) : null] }), _jsxs("dl", { className: css.meta, children: [_jsx("dt", { children: t('patchSupported') }), _jsx("dd", { children: target
|
|
83
|
+
return (_jsxs("li", { className: css.row, children: [_jsxs("div", { className: css.rowHead, children: [_jsx("code", { className: css.packageName, children: target.packageName }), _jsx("span", { className: css.badge, "data-state": target.state, children: t(STATE_KEYS[target.state]) }), target.state === 'patched' && live ? _jsx("span", { className: css.live, children: t('patchActive') }) : null] }), _jsxs("dl", { className: css.meta, children: [_jsx("dt", { children: t('patchSupported') }), _jsx("dd", { children: versionsOf(target) }), _jsx("dt", { children: t('patchInstalledVersion') }), _jsx("dd", { children: target.installedVersion ?? '—' }), _jsx("dt", { children: t('patchSource') }), _jsx("dd", { className: css.source, children: target.source })] }), target.detail === undefined ? null : _jsx("p", { className: css.detail, children: target.detail }), busy && phase !== undefined ? (_jsxs("p", { className: css.progress, role: "status", children: [_jsx(StateDot, { state: "ongoing", size: 13 }), phase === 'applying' ? t('patchApplying') : t('patchWaiting')] })) : null, waiting ? _jsx("p", { className: css.hint, children: t('patchPendingHint') }) : null, action === undefined ? null : (_jsx("div", { className: css.actions, children: _jsx(Button, { variant: action === 'install' ? 'primary' : 'outline', disabled: busy, onClick: () => { onAct(action); }, children: busy ? t('patchWorking') : t(action === 'install' ? 'patchInstall' : 'patchUninstall') }) }))] }));
|
|
72
84
|
}
|
|
73
85
|
/**
|
|
74
86
|
* Ask before touching another plugin's installed files.
|
|
@@ -76,5 +88,5 @@ function Row({ target, live, busy, phase, t, onAct }) {
|
|
|
76
88
|
* @returns the dialog.
|
|
77
89
|
*/
|
|
78
90
|
function ConfirmDialog({ target, action, t, onCancel, onConfirm }) {
|
|
79
|
-
return (_jsxs(Modal, { open: true, onClose: onCancel, title: t(action === 'install' ? 'patchInstallTitle' : 'patchUninstallTitle'), closeLabel: t('close'), footer: (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", onClick: onCancel, children: t('cancel') }), _jsx(Button, { variant: "primary", onClick: onConfirm, children: t(action === 'install' ? 'patchInstall' : 'patchUninstall') })] })), children: [_jsx("p", { children: t(action === 'install' ? 'patchInstallBody' : 'patchUninstallBody') }), _jsxs("dl", { className: css.meta, children: [_jsx("dt", { children: t('patchPackage') }), _jsx("dd", { children: _jsx("code", { children: target.packageName }) }), _jsx("dt", { children: t('patchFile') }), _jsx("dd", { children: _jsx("code", { children: `${target.packageName}/lib/client.js` }) }), _jsx("dt", { children: t('patchSupported') }), _jsx("dd", { children: target
|
|
91
|
+
return (_jsxs(Modal, { open: true, onClose: onCancel, title: t(action === 'install' ? 'patchInstallTitle' : 'patchUninstallTitle'), closeLabel: t('close'), footer: (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", onClick: onCancel, children: t('cancel') }), _jsx(Button, { variant: "primary", onClick: onConfirm, children: t(action === 'install' ? 'patchInstall' : 'patchUninstall') })] })), children: [_jsx("p", { children: t(action === 'install' ? 'patchInstallBody' : 'patchUninstallBody') }), _jsxs("dl", { className: css.meta, children: [_jsx("dt", { children: t('patchPackage') }), _jsx("dd", { children: _jsx("code", { children: target.packageName }) }), _jsx("dt", { children: t('patchFile') }), _jsx("dd", { children: _jsx("code", { children: `${target.packageName}/lib/client.js` }) }), _jsx("dt", { children: t('patchSupported') }), _jsx("dd", { children: versionsOf(target) })] })] }));
|
|
80
92
|
}
|
|
@@ -37,6 +37,11 @@ export interface TeamListViewProps {
|
|
|
37
37
|
}[];
|
|
38
38
|
/** Opens the page that manages the Team preset categories. */
|
|
39
39
|
readonly onManageCategories?: () => void;
|
|
40
|
+
/**
|
|
41
|
+
* How many shipped presets this deployment was offered but no longer holds,
|
|
42
|
+
* when none of them are in the list. Zero or undefined renders no hint.
|
|
43
|
+
*/
|
|
44
|
+
readonly missingBuiltins?: number | undefined;
|
|
40
45
|
}
|
|
41
46
|
/**
|
|
42
47
|
* Render the Team list.
|
|
@@ -33,7 +33,7 @@ export function TeamListView(props) {
|
|
|
33
33
|
const matchesQuery = tokens.length === 0 || matchTeam(team, tokens) !== undefined;
|
|
34
34
|
return matchesSource && matchesSeries && matchesCategory && matchesQuery;
|
|
35
35
|
}), [props.teams, props.teamCategories, source, series, category, tokens]);
|
|
36
|
-
return (_jsxs(_Fragment, { children: [_jsxs("header", { className: css.pageHead, children: [_jsx("h2", { className: css.title, children: t('title') }), _jsx("p", { className: css.intro, children: t('description') })] }), _jsxs("div", { className: css.toolbar, children: [_jsxs("div", { className: css.toolbarGroup, children: [_jsx(Button, { size: "sm", variant: "primary", disabled: disabled, onClick: props.onCreate, children: t('newTeam') }), _jsx(Button, { size: "sm", variant: "outline", disabled: disabled, title: t('importNote'), onClick: () => { fileInput.current?.click(); }, children: t('importPreset') })] }), _jsxs("div", { className: css.toolbarGroup, children: [props.onManageCategories === undefined ? null : (_jsx(Button, { size: "sm", variant: "outline", onClick: props.onManageCategories, children: t('categoryManagePage') })), _jsx(Button, { size: "sm", variant: "ghost", disabled: disabled, onClick: () => { setConfirmRestore(true); }, children: t('restoreDefaults') })] }), _jsx("input", { ref: fileInput, className: css.fileInput, type: "file", accept: "application/json,.json", disabled: disabled, onChange: (event) => {
|
|
36
|
+
return (_jsxs(_Fragment, { children: [_jsxs("header", { className: css.pageHead, children: [_jsx("h2", { className: css.title, children: t('title') }), _jsx("p", { className: css.intro, children: t('description') })] }), (props.missingBuiltins ?? 0) === 0 ? null : (_jsxs("div", { className: css.restoreHint, role: "status", children: [_jsx("span", { children: t('restoreMissingHint').replace('{count}', String(props.missingBuiltins)) }), _jsx(Button, { size: "sm", variant: "outline", disabled: disabled, onClick: () => { setConfirmRestore(true); }, children: t('restoreDefaults') })] })), _jsxs("div", { className: css.toolbar, children: [_jsxs("div", { className: css.toolbarGroup, children: [_jsx(Button, { size: "sm", variant: "primary", disabled: disabled, onClick: props.onCreate, children: t('newTeam') }), _jsx(Button, { size: "sm", variant: "outline", disabled: disabled, title: t('importNote'), onClick: () => { fileInput.current?.click(); }, children: t('importPreset') })] }), _jsxs("div", { className: css.toolbarGroup, children: [props.onManageCategories === undefined ? null : (_jsx(Button, { size: "sm", variant: "outline", onClick: props.onManageCategories, children: t('categoryManagePage') })), _jsx(Button, { size: "sm", variant: "ghost", disabled: disabled, onClick: () => { setConfirmRestore(true); }, children: t('restoreDefaults') })] }), _jsx("input", { ref: fileInput, className: css.fileInput, type: "file", accept: "application/json,.json", disabled: disabled, onChange: (event) => {
|
|
37
37
|
const file = event.target.files?.[0];
|
|
38
38
|
// Clearing the value lets the same document be chosen twice in a row.
|
|
39
39
|
event.target.value = '';
|
|
@@ -12,6 +12,7 @@ import { TeamImportDialog } from "./TeamImportDialog.js";
|
|
|
12
12
|
import { TeamListView } from "./TeamListView.js";
|
|
13
13
|
import { TeamSkillsView } from "./TeamSkillsView.js";
|
|
14
14
|
import { CardPatchView } from "./CardPatchView.js";
|
|
15
|
+
import { BUILTIN_TEAM_IDS } from "../builtin-teams.js";
|
|
15
16
|
import { defaultImportResolution, executionStateOf, unnamedTeamsOf } from "./team-presets-controller.js";
|
|
16
17
|
import { downloadPresetText, presetFileName, readPresetFile } from "./preset-file.js";
|
|
17
18
|
import { DEFAULTS_NOTICE_KEYS, DISCLOSURE_NOTICE_KEYS, EXECUTION_NOTICE_KEYS, FORM_ISSUE_KEYS, IMPORT_FAILURE_KEYS, selectionFailureText } from "./locales.js";
|
|
@@ -145,6 +146,11 @@ export function TeamPresetsSection(props) {
|
|
|
145
146
|
// silent failure.
|
|
146
147
|
const disabled = !state.writable || state.formIssue !== undefined;
|
|
147
148
|
const teamList = state.teams;
|
|
149
|
+
// The install pass never re-adds a preset it once offered, so an empty shipped
|
|
150
|
+
// set is a state this page must explain rather than hide. Counting only the
|
|
151
|
+
// complete case keeps the hint off the page for a reader who deleted one Team.
|
|
152
|
+
const heldIds = new Set(teamList.map(entry => entry.id));
|
|
153
|
+
const missingBuiltins = BUILTIN_TEAM_IDS.every(id => !heldIds.has(id)) ? BUILTIN_TEAM_IDS.length : 0;
|
|
148
154
|
// Only the team and agent views address a Team; the categories page stands alone.
|
|
149
155
|
const addressed = view.kind === 'team' || view.kind === 'agent' ? view.teamId : undefined;
|
|
150
156
|
const found = addressed === undefined ? undefined : teamList.find(entry => entry.id === addressed);
|
|
@@ -211,7 +217,7 @@ export function TeamPresetsSection(props) {
|
|
|
211
217
|
const agent = team === undefined || active.kind !== 'agent'
|
|
212
218
|
? undefined
|
|
213
219
|
: active.slot === 'captain' ? team.captain : team.members[active.slot];
|
|
214
|
-
return (_jsxs("div", { className: css.section, children: [_jsxs("div", { role: "tablist", className: css.tabs, children: [_jsx(TabButton, { active: tab === 'teams', onClick: () => { setTab('teams'); }, children: t('tabTeams') }), props.skills === undefined ? null : _jsx(TabButton, { active: tab === 'skills', onClick: () => { setTab('skills'); }, children: t('tabSkills') }), props.cardPatches === undefined ? null : _jsx(TabButton, { active: tab === 'links', onClick: () => { setTab('links'); }, children: t('tabLinks') })] }), _jsxs("div", { className: css.page, children: [active.kind === 'categories' && (_jsx(TeamCategoryManager, { categories: state.categories, teamCategories: state.teamCategories, disabled: disabled, t: t, onBack: () => { setView({ kind: 'list' }); }, onAdd: (name) => { void props.addCategory(name); }, onRename: (id, name) => { void props.renameCategory(id, name); }, onMove: (id, delta) => { void props.moveCategory(id, delta); }, onRemove: (id) => { void props.removeCategory(id); } })), active.kind === 'list' && (_jsx(TeamListView, { teams: teamList, t: t, disabled: disabled, importError: importError, categories: categoriesForList, onManageCategories: () => { setView({ kind: 'categories' }); }, teamCategories: state.teamCategories, onOpen: openTeam, onCreate: () => { openTeam(props.createTeam()); }, onImport: (file) => { void importDocument(file); }, onExport: exportDocument, onRestoreDefaults: () => {
|
|
220
|
+
return (_jsxs("div", { className: css.section, children: [_jsxs("div", { role: "tablist", className: css.tabs, children: [_jsx(TabButton, { active: tab === 'teams', onClick: () => { setTab('teams'); }, children: t('tabTeams') }), props.skills === undefined ? null : _jsx(TabButton, { active: tab === 'skills', onClick: () => { setTab('skills'); }, children: t('tabSkills') }), props.cardPatches === undefined ? null : _jsx(TabButton, { active: tab === 'links', onClick: () => { setTab('links'); }, children: t('tabLinks') })] }), _jsxs("div", { className: css.page, children: [active.kind === 'categories' && (_jsx(TeamCategoryManager, { categories: state.categories, teamCategories: state.teamCategories, disabled: disabled, t: t, onBack: () => { setView({ kind: 'list' }); }, onAdd: (name) => { void props.addCategory(name); }, onRename: (id, name) => { void props.renameCategory(id, name); }, onMove: (id, delta) => { void props.moveCategory(id, delta); }, onRemove: (id) => { void props.removeCategory(id); } })), active.kind === 'list' && (_jsx(TeamListView, { teams: teamList, t: t, disabled: disabled, importError: importError, categories: categoriesForList, onManageCategories: () => { setView({ kind: 'categories' }); }, missingBuiltins: missingBuiltins, teamCategories: state.teamCategories, onOpen: openTeam, onCreate: () => { openTeam(props.createTeam()); }, onImport: (file) => { void importDocument(file); }, onExport: exportDocument, onRestoreDefaults: () => {
|
|
215
221
|
props.restoreDefaults();
|
|
216
222
|
void props.skills?.restoreBuiltinBindings();
|
|
217
223
|
}, onDuplicate: (teamId) => {
|
|
@@ -17,7 +17,13 @@
|
|
|
17
17
|
const SETTLE_TIMEOUT_MS = 6000;
|
|
18
18
|
/** How often that wait re-reads the registered services. */
|
|
19
19
|
const SETTLE_POLL_MS = 250;
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Fallback services, used only before the Host's rows have arrived.
|
|
22
|
+
*
|
|
23
|
+
* Once a row exists its own `service` field is authoritative: the Host derives
|
|
24
|
+
* it from the catalog entry that matches the installed version, so a target
|
|
25
|
+
* added by a shipped catalog never needs a code change here.
|
|
26
|
+
*/
|
|
21
27
|
const SERVICES = {
|
|
22
28
|
'dsh-context': 'contextAgentCardBadges',
|
|
23
29
|
'dsh-better-sidebar': 'betterSidebarAgentCardBadges',
|
|
@@ -97,9 +103,14 @@ export class CardPatchesController {
|
|
|
97
103
|
* alone changes nothing until the server restarts and the page reloads.
|
|
98
104
|
* @returns the live target identities, in catalog order.
|
|
99
105
|
*/
|
|
100
|
-
liveTargets() {
|
|
101
|
-
|
|
102
|
-
|
|
106
|
+
liveTargets(targets = this.state.targets) {
|
|
107
|
+
// `target.service` is authoritative once the Host sends it; a Host from
|
|
108
|
+
// before the multi-version catalog sends none, so the fallback still applies.
|
|
109
|
+
const pairs = targets.length > 0
|
|
110
|
+
? targets.map(target => [target.id, target.service ?? SERVICES[target.id]])
|
|
111
|
+
: Object.entries(SERVICES);
|
|
112
|
+
return pairs
|
|
113
|
+
.filter(([, service]) => service !== undefined && this.ctx.get(service) !== undefined)
|
|
103
114
|
.map(([id]) => id);
|
|
104
115
|
}
|
|
105
116
|
/**
|
|
@@ -115,7 +126,7 @@ export class CardPatchesController {
|
|
|
115
126
|
}
|
|
116
127
|
try {
|
|
117
128
|
const targets = unwrap(await remote.cardPatches());
|
|
118
|
-
this.state = { ...this.state, status: 'ready', targets, live: this.liveTargets() };
|
|
129
|
+
this.state = { ...this.state, status: 'ready', targets, live: this.liveTargets(targets) };
|
|
119
130
|
}
|
|
120
131
|
catch (error) {
|
|
121
132
|
this.state = { ...this.state, status: 'unavailable', live: this.liveTargets() };
|
|
@@ -3,7 +3,7 @@ import type { TeamPresetImportFailure } from '../preset-transfer.ts';
|
|
|
3
3
|
import type { TeamExecutionState } from '../types.ts';
|
|
4
4
|
import type { DefaultsRestore, TeamPresetsFormIssue, TeamSelectionFailure } from './team-presets-controller.ts';
|
|
5
5
|
/** Locale keys this plugin renders. */
|
|
6
|
-
export type TeamPresetsLocaleKey = 'nav' | 'title' | 'description' | 'newTeam' | 'duplicate' | 'remove' | 'removeMember' | 'teamList' | 'emptyTeams' | 'emptySelection' | 'memberCount' | 'teamName' | 'teamNamePlaceholder' | 'teamDescription' | 'captain' | 'captainHint' | 'members' | 'addMember' | 'membersHint' | 'agentName' | 'agentNamePlaceholder' | 'agentColor' | 'agentDescription' | 'route' | 'routeInherit' | 'provider' | 'model' | 'effort' | 'effortDefault' | 'captainModelHint' | 'captainFollowsSession' | 'modelsPartial' | 'modelsFailed' | 'tools' | 'toolsHint' | 'toolMode' | 'toolsDefault' | 'toolsCustom' | 'toolsAllHint' | 'toolsEmpty' | 'toolsScoped' | 'toolsSelectAll' | 'toolsClear' | 'toolsRemove' | 'toolsUnavailable' | 'toolsLoading' | 'toolsFailed' | 'toolsNoCatalog' | 'toolsCaptainOnly' | 'toolsGroupPresets' | 'toolsGroupMcp' | 'toolsGroupOther' | 'toolsInvert' | 'composerMissing' | 'composerMissingHint' | 'systemPrompt' | 'systemPromptPlaceholder' | 'systemPromptHint' | 'promptWarnBraces' | 'save' | 'saving' | 'saveFailed' | 'discard' | 'unsaved' | 'readOnly' | 'unavailable' | 'sectionLoading' | 'formIssueSettingsUnavailable' | 'formIssueNamespaceMissing' | 'formIssueSchemaRejected' | 'selectionUnavailable' | 'selectionRefused' | 'selectionFailed' | 'teamNameRequired' | 'externalUpdateOne' | 'externalUpdateMany' | 'externalUpdateOverriddenOne' | 'externalUpdateOverriddenMany' | 'executionBusy' | 'executionBusyShared' | 'executionIdle' | 'executionUnknown' | 'executionPtcOverridden' | 'externalAddedOne' | 'externalAddedMany' | 'externalRemovedOne' | 'externalRemovedMany' | 'externalRemovedEditedOne' | 'externalRemovedEditedMany' | 'back' | 'backToList' | 'editCaptain' | 'editMember' | 'teamSections' | 'agentSections' | 'modelSection' | 'promptSection' | 'toolsSection' | 'identitySection' | 'emptyMembers' | 'inheritSession' | 'deleteAgent' | 'roleCaptain' | 'roleMember' | 'composerTitle' | 'composerNone' | 'composerHint' | 'trigger' | 'loading' | 'unavailable' | 'roster' | 'model' | 'open' | 'current' | 'memberStatus.running' | 'memberStatus.inactive' | 'presetMemberBadge' | 'presetMemberBadgeHint' | 'tasks' | 'empty' | 'owner' | 'unowned' | 'blockedBy' | 'writeScopes' | 'ready' | 'blocked' | 'task.expand' | 'task.collapse' | 'status.pending' | 'status.in_progress' | 'status.completed' | 'importPreset' | 'exportPreset' | 'importNote' | 'importConfirm' | 'cancel' | 'close' | 'restoreDefaults' | 'restoreDefaultsHint' | 'defaultsRestored' | 'defaultsUnchanged' | 'importConflictTitle' | 'importTeamConflict' | 'importTeamReplace' | 'importTeamRename' | 'importNewTeamName' | 'importCaptainConflict' | 'importCaptainReplace' | 'importCaptainRename' | 'importMemberConflict' | 'importMemberReplace' | 'importMemberRename' | 'importInvalidJson' | 'importInvalidFormat' | 'importUnsupportedVersion' | 'importUnsupportedFields' | 'importDuplicateMembers' | 'importTooManyMembers' | 'importTooLarge' | 'importInvalidMetadata' | 'skillsEmpty' | 'skillsImport' | 'skillsNew' | 'skillsSave' | 'skillsDelete' | 'skillsAssign' | 'skillsUnassign' | 'skillsBuiltinList' | 'skillsFiles' | 'skillsBindings' | 'skillsNamePlaceholder' | 'skillsDescriptionPlaceholder' | 'skillsRoot' | 'skillsRefresh' | 'tabLinks' | 'patchIntro' | 'patchUnavailable' | 'patchStateAbsent' | 'patchStateUnsupported' | 'patchStatePristine' | 'patchStatePatched' | 'patchStateForeign' | 'patchActive' | 'patchSupported' | 'patchInstalledVersion' | 'patchSource' | 'patchPendingHint' | 'patchApplying' | 'patchWaiting' | 'patchInstall' | 'patchUninstall' | 'patchWorking' | 'patchInstallTitle' | 'patchUninstallTitle' | 'patchInstallBody' | 'patchUninstallBody' | 'patchPackage' | 'patchFile' | 'patchInstalledOk' | 'patchRemovedOk' | 'patchRefused' | 'skillsScan' | 'skillsScanHint' | 'skillsScanSummary' | 'skillsScanEmpty' | 'skillsScanImported' | 'skillsScanExisting' | 'skillsScanInvalid' | 'skillsScanMissingSkill' | 'skillsScanInvalidFrontmatter' | 'skillsScanInvalidName' | 'skillsScanMissingDescription' | 'skillsScanTooLarge' | 'skillsScanSymlink' | 'skillsScanNotDirectory' | 'skillsScanUnreadable' | 'skillsScanDuplicate' | 'skillsScanInstallRefused' | 'skillsOpenScanFolder' | 'skillsCopyScanFolder' | 'skillsScanFolderOpened' | 'skillsScanFolderCopied' | 'skillsScanFolderCopyFailed' | 'skillsOverride' | 'skillsReset' | 'skillsBody' | 'tabTeams' | 'tabSkills' | 'skillsHint' | 'skillsAssignTitle' | 'skillsAssignHint' | 'skillsAssignEmpty' | 'skillsNameClash' | 'skillsNameClashBody' | 'skillsBlockedAssign' | 'skillsMcpUnverified' | 'skillsDeclared' | 'skillsFound' | 'skillsMissing' | 'categoryRename' | 'categoryUp' | 'categoryDown' | 'categoryManagePage' | 'categoryTitle' | 'categorySub' | 'categoryTeams' | 'categorySave' | 'categoryRemove' | 'categoryNote' | 'categoryManage' | 'categoryFold' | 'categoryName' | 'categoryAdd' | 'categoryEmpty' | 'categoryOf' | 'categoryNone' | 'metadataTitle' | 'metadataOnlyDisplay' | 'metadataNote' | 'metadataFold' | 'metadataUnfold' | 'metadataSummary' | 'metadataTags' | 'metadataTagsHint' | 'metadataUseCases' | 'metadataQuickPrompts' | 'metadataNotes' | 'filterSource' | 'filterCategory' | 'filterNoCategory' | 'listSearch' | 'listAll' | 'listBuiltin' | 'listCustom' | 'seriesDevelopment' | 'seriesWorkModes' | 'listMatched' | 'listNoInject' | 'listNoMatch' | 'listResultCount' | 'restoreConfirmTitle' | 'restoreConfirmBody' | 'restoreConfirmAction' | 'composeTitle' | 'composeClose' | 'composeSearch' | 'composeAll' | 'composeFilterCategory' | 'composeCategoryAll' | 'composeUncategorized' | 'composeNoneSub' | 'composeSeriesDev' | 'composeSeriesModes' | 'composeEmpty' | 'composePanelTitle' | 'composePanelCaptain' | 'composePanelMembers' | 'composePanelSessionModel' | 'composePanelCaptainHint' | 'composePanelSoloHint' | 'composePanelEmptyMembers' | 'composePanelNoId' | 'composerMissingMember' | 'originBuiltin' | 'originCustom' | 'originOverride' | 'skillsTitle' | 'skillsSub' | 'skillsNote' | 'skillsOpenFolder' | 'skillsOpenAssetFolder' | 'skillsSearch' | 'skillsAll' | 'skillsBuiltin' | 'skillsCustom' | 'skillsBound' | 'skillsResources' | 'skillsSaveFile' | 'skillsEditable' | 'skillsReadonly' | 'skillsMakeCopy' | 'skillsResetCopy' | 'skillsNoBinding' | 'skillsUnbind' | 'skillsDeps' | 'skillsNoDeps' | 'skillsDeleteTitle' | 'skillsDeleteBody' | 'skillsDeleteBlocked' | 'skillsDeleteBoundWarning' | 'skillsDeleteBuiltinWarning' | 'skillsCancel' | 'skillsConfirm' | 'skillsName' | 'skillsDesc' | 'skillsNewTitle' | 'skillsVersion' | 'skillsOverrideOn';
|
|
6
|
+
export type TeamPresetsLocaleKey = 'nav' | 'title' | 'description' | 'newTeam' | 'duplicate' | 'remove' | 'removeMember' | 'teamList' | 'emptyTeams' | 'emptySelection' | 'memberCount' | 'teamName' | 'teamNamePlaceholder' | 'teamDescription' | 'captain' | 'captainHint' | 'members' | 'addMember' | 'membersHint' | 'agentName' | 'agentNamePlaceholder' | 'agentColor' | 'agentDescription' | 'route' | 'routeInherit' | 'provider' | 'model' | 'effort' | 'effortDefault' | 'captainModelHint' | 'captainFollowsSession' | 'modelsPartial' | 'modelsFailed' | 'tools' | 'toolsHint' | 'toolMode' | 'toolsDefault' | 'toolsCustom' | 'toolsAllHint' | 'toolsEmpty' | 'toolsScoped' | 'toolsSelectAll' | 'toolsClear' | 'toolsRemove' | 'toolsUnavailable' | 'toolsLoading' | 'toolsFailed' | 'toolsNoCatalog' | 'toolsCaptainOnly' | 'toolsGroupPresets' | 'toolsGroupMcp' | 'toolsGroupOther' | 'toolsInvert' | 'composerMissing' | 'composerMissingHint' | 'systemPrompt' | 'systemPromptPlaceholder' | 'systemPromptHint' | 'promptWarnBraces' | 'save' | 'saving' | 'saveFailed' | 'discard' | 'unsaved' | 'readOnly' | 'unavailable' | 'sectionLoading' | 'formIssueSettingsUnavailable' | 'formIssueNamespaceMissing' | 'formIssueSchemaRejected' | 'selectionUnavailable' | 'selectionRefused' | 'selectionFailed' | 'teamNameRequired' | 'externalUpdateOne' | 'externalUpdateMany' | 'externalUpdateOverriddenOne' | 'externalUpdateOverriddenMany' | 'executionBusy' | 'executionBusyShared' | 'executionIdle' | 'executionUnknown' | 'executionPtcOverridden' | 'externalAddedOne' | 'externalAddedMany' | 'externalRemovedOne' | 'externalRemovedMany' | 'externalRemovedEditedOne' | 'externalRemovedEditedMany' | 'back' | 'backToList' | 'editCaptain' | 'editMember' | 'teamSections' | 'agentSections' | 'modelSection' | 'promptSection' | 'toolsSection' | 'identitySection' | 'emptyMembers' | 'inheritSession' | 'deleteAgent' | 'roleCaptain' | 'roleMember' | 'composerTitle' | 'composerNone' | 'composerHint' | 'trigger' | 'loading' | 'unavailable' | 'roster' | 'model' | 'open' | 'current' | 'memberStatus.running' | 'memberStatus.inactive' | 'presetMemberBadge' | 'presetMemberBadgeHint' | 'tasks' | 'empty' | 'owner' | 'unowned' | 'blockedBy' | 'writeScopes' | 'ready' | 'blocked' | 'task.expand' | 'task.collapse' | 'status.pending' | 'status.in_progress' | 'status.completed' | 'importPreset' | 'exportPreset' | 'importNote' | 'importConfirm' | 'cancel' | 'close' | 'restoreDefaults' | 'restoreDefaultsHint' | 'defaultsRestored' | 'defaultsUnchanged' | 'restoreMissingHint' | 'importConflictTitle' | 'importTeamConflict' | 'importTeamReplace' | 'importTeamRename' | 'importNewTeamName' | 'importCaptainConflict' | 'importCaptainReplace' | 'importCaptainRename' | 'importMemberConflict' | 'importMemberReplace' | 'importMemberRename' | 'importInvalidJson' | 'importInvalidFormat' | 'importUnsupportedVersion' | 'importUnsupportedFields' | 'importDuplicateMembers' | 'importTooManyMembers' | 'importTooLarge' | 'importInvalidMetadata' | 'skillsEmpty' | 'skillsImport' | 'skillsNew' | 'skillsSave' | 'skillsDelete' | 'skillsAssign' | 'skillsUnassign' | 'skillsBuiltinList' | 'skillsFiles' | 'skillsBindings' | 'skillsNamePlaceholder' | 'skillsDescriptionPlaceholder' | 'skillsRoot' | 'skillsRefresh' | 'tabLinks' | 'patchIntro' | 'patchUnavailable' | 'patchStateAbsent' | 'patchStateUnsupported' | 'patchStatePristine' | 'patchStatePatched' | 'patchStateForeign' | 'patchActive' | 'patchSupported' | 'patchInstalledVersion' | 'patchSource' | 'patchPendingHint' | 'patchApplying' | 'patchWaiting' | 'patchInstall' | 'patchUninstall' | 'patchWorking' | 'patchInstallTitle' | 'patchUninstallTitle' | 'patchInstallBody' | 'patchUninstallBody' | 'patchPackage' | 'patchFile' | 'patchInstalledOk' | 'patchRemovedOk' | 'patchRefused' | 'skillsScan' | 'skillsScanHint' | 'skillsScanSummary' | 'skillsScanEmpty' | 'skillsScanImported' | 'skillsScanExisting' | 'skillsScanInvalid' | 'skillsScanMissingSkill' | 'skillsScanInvalidFrontmatter' | 'skillsScanInvalidName' | 'skillsScanMissingDescription' | 'skillsScanTooLarge' | 'skillsScanSymlink' | 'skillsScanNotDirectory' | 'skillsScanUnreadable' | 'skillsScanDuplicate' | 'skillsScanInstallRefused' | 'skillsOpenScanFolder' | 'skillsCopyScanFolder' | 'skillsScanFolderOpened' | 'skillsScanFolderCopied' | 'skillsScanFolderCopyFailed' | 'skillsOverride' | 'skillsReset' | 'skillsBody' | 'tabTeams' | 'tabSkills' | 'skillsHint' | 'skillsAssignTitle' | 'skillsAssignHint' | 'skillsAssignEmpty' | 'skillsNameClash' | 'skillsNameClashBody' | 'skillsBlockedAssign' | 'skillsMcpUnverified' | 'skillsDeclared' | 'skillsFound' | 'skillsMissing' | 'categoryRename' | 'categoryUp' | 'categoryDown' | 'categoryManagePage' | 'categoryTitle' | 'categorySub' | 'categoryTeams' | 'categorySave' | 'categoryRemove' | 'categoryNote' | 'categoryManage' | 'categoryFold' | 'categoryName' | 'categoryAdd' | 'categoryEmpty' | 'categoryOf' | 'categoryNone' | 'metadataTitle' | 'metadataOnlyDisplay' | 'metadataNote' | 'metadataFold' | 'metadataUnfold' | 'metadataSummary' | 'metadataTags' | 'metadataTagsHint' | 'metadataUseCases' | 'metadataQuickPrompts' | 'metadataNotes' | 'filterSource' | 'filterCategory' | 'filterNoCategory' | 'listSearch' | 'listAll' | 'listBuiltin' | 'listCustom' | 'seriesDevelopment' | 'seriesWorkModes' | 'listMatched' | 'listNoInject' | 'listNoMatch' | 'listResultCount' | 'restoreConfirmTitle' | 'restoreConfirmBody' | 'restoreConfirmAction' | 'composeTitle' | 'composeClose' | 'composeSearch' | 'composeAll' | 'composeFilterCategory' | 'composeCategoryAll' | 'composeUncategorized' | 'composeNoneSub' | 'composeSeriesDev' | 'composeSeriesModes' | 'composeEmpty' | 'composePanelTitle' | 'composePanelCaptain' | 'composePanelMembers' | 'composePanelSessionModel' | 'composePanelCaptainHint' | 'composePanelSoloHint' | 'composePanelEmptyMembers' | 'composePanelNoId' | 'composerMissingMember' | 'originBuiltin' | 'originCustom' | 'originOverride' | 'skillsTitle' | 'skillsSub' | 'skillsNote' | 'skillsOpenFolder' | 'skillsOpenAssetFolder' | 'skillsSearch' | 'skillsAll' | 'skillsBuiltin' | 'skillsCustom' | 'skillsBound' | 'skillsResources' | 'skillsSaveFile' | 'skillsEditable' | 'skillsReadonly' | 'skillsMakeCopy' | 'skillsResetCopy' | 'skillsNoBinding' | 'skillsUnbind' | 'skillsDeps' | 'skillsNoDeps' | 'skillsDeleteTitle' | 'skillsDeleteBody' | 'skillsDeleteBlocked' | 'skillsDeleteBoundWarning' | 'skillsDeleteBuiltinWarning' | 'skillsCancel' | 'skillsConfirm' | 'skillsName' | 'skillsDesc' | 'skillsNewTitle' | 'skillsVersion' | 'skillsOverrideOn';
|
|
7
7
|
/** Locale namespace owned by this plugin. */
|
|
8
8
|
export declare const NS = "settings.agentTeamPresets";
|
|
9
9
|
/** English copy. */
|
|
@@ -139,6 +139,7 @@ export const en = {
|
|
|
139
139
|
restoreDefaultsHint: 'Puts every preset this plugin ships back to its shipped name, description, prompts, colors, and roster. The model routes and tool permissions you configured stay as they are, and teams you created yourself are not touched.',
|
|
140
140
|
defaultsRestored: 'Default presets restored in this draft. Save to apply them.',
|
|
141
141
|
defaultsUnchanged: 'The default presets already match what this plugin ships; nothing was staged.',
|
|
142
|
+
restoreMissingHint: 'This deployment was offered the {count} built-in Team presets, but none of them are in the list. Unless you deleted them yourself, click "Restore built-in presets" to bring them back, then save.',
|
|
142
143
|
importConfirm: 'Import',
|
|
143
144
|
cancel: 'Cancel',
|
|
144
145
|
close: 'Close',
|
|
@@ -478,6 +479,7 @@ export const zh = {
|
|
|
478
479
|
restoreDefaultsHint: '把插件自带的预设全部恢复到出厂的名称、说明、提示词、颜色和成员名单;你为它们配置的模型路由与工具权限保持不变,你自己创建的团队完全不受影响。',
|
|
479
480
|
defaultsRestored: '默认预设已恢复到草稿,保存后生效。',
|
|
480
481
|
defaultsUnchanged: '默认预设与插件出厂状态一致,无需恢复。',
|
|
482
|
+
restoreMissingHint: '这个部署曾经拿到过插件自带的 {count} 个团队预设,但它们现在都不在列表里。如果不是你主动删除的,点「恢复内置预设」可以把它们找回来,然后记得保存。',
|
|
481
483
|
importConfirm: '导入',
|
|
482
484
|
cancel: '取消',
|
|
483
485
|
close: '关闭',
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* @module dsh-agent-team-presets/settings-reconcile
|
|
18
18
|
*/
|
|
19
19
|
import { randomUUID } from 'node:crypto';
|
|
20
|
-
import { cloneMetadata, seedBuiltinTeams } from "./builtin-teams.js";
|
|
20
|
+
import { cloneMetadata, missingSeededBuiltinTeams, seedBuiltinTeams } from "./builtin-teams.js";
|
|
21
21
|
import { builtinEntry } from "./team-catalog.js";
|
|
22
22
|
import { withoutCaptainRoutes } from "./config.js";
|
|
23
23
|
import { reconciledAssignments } from "./team-search.js";
|
|
@@ -78,6 +78,14 @@ export function teamSettingsReconcile(ctx, config, namespace) {
|
|
|
78
78
|
// user edited keeps every edit, and one the user deleted stays deleted
|
|
79
79
|
// because its identity was marked when it was first offered.
|
|
80
80
|
const installed = seedBuiltinTeams(cleaned, seeded);
|
|
81
|
+
// The marker keeps a deleted preset deleted, so a Team list that lost
|
|
82
|
+
// its shipped presets some other way (a hand edit, a restored settings
|
|
83
|
+
// file, a rollback) stays empty until the reader restores them. Say so
|
|
84
|
+
// once per startup instead of leaving an unexplained empty page.
|
|
85
|
+
const missingShipped = missingSeededBuiltinTeams(installed.teams, installed.seeded);
|
|
86
|
+
if (missingShipped.length > 0) {
|
|
87
|
+
ctx.logger.warn('agent-team-presets: %d shipped Team preset(s) are marked as offered but missing from the Team list (%s); open Settings → Agent Team presets and click "Restore built-in presets", then save', missingShipped.length, missingShipped.join(', '));
|
|
88
|
+
}
|
|
81
89
|
// Grouping rows naming a deleted category or a deleted custom Team are
|
|
82
90
|
// dead: drop them here so the page never has to explain a row it
|
|
83
91
|
// cannot resolve. A row naming a shipped identity survives, because a
|
|
@@ -44,7 +44,7 @@ import { RUN_CODE_NAME } from '@deepseek-ai/dsh-tools';
|
|
|
44
44
|
import { GET_TEAM_PRESET_DESCRIPTION, SPAWN_TEAM_MEMBER_DESCRIPTION, UPDATE_TEAM_PRESET_DESCRIPTION } from "./tool-descriptions.js";
|
|
45
45
|
import { IMPLICIT_TOOLS } from "./presets.js";
|
|
46
46
|
import { Remote, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
47
|
-
import {
|
|
47
|
+
import { catalogIdentities, catalogTargetsFor, installCardPatch, resolveInstalledTarget, resolveTargetView, uninstallCardPatch } from "./card-patches.js";
|
|
48
48
|
/**
|
|
49
49
|
* One frame for a composition that holds no execution state.
|
|
50
50
|
*
|
|
@@ -279,7 +279,9 @@ let TeamPresetsToolCatalog = (() => {
|
|
|
279
279
|
* @returns one row per supported target, in catalog order.
|
|
280
280
|
*/
|
|
281
281
|
async cardPatches() {
|
|
282
|
-
|
|
282
|
+
// One row per identity: the catalog may hold several versions of a target,
|
|
283
|
+
// and which one is relevant depends on what is installed right now.
|
|
284
|
+
return catalogIdentities().map(id => resolveTargetView(catalogTargetsFor(id), this.cardPatchEnvironment));
|
|
283
285
|
}
|
|
284
286
|
/**
|
|
285
287
|
* Replace one target's browser bundle with this build's prebuilt replacement.
|
|
@@ -287,10 +289,9 @@ let TeamPresetsToolCatalog = (() => {
|
|
|
287
289
|
* @returns the outcome, or a refusal naming why nothing changed.
|
|
288
290
|
*/
|
|
289
291
|
async installCardPatch(id) {
|
|
290
|
-
const target =
|
|
291
|
-
if (target === undefined)
|
|
292
|
-
return { ok: false, id, state:
|
|
293
|
-
}
|
|
292
|
+
const { target, view } = resolveInstalledTarget(id, this.cardPatchEnvironment);
|
|
293
|
+
if (target === undefined)
|
|
294
|
+
return { ok: false, id, state: view.state, ...view.detail === undefined ? {} : { detail: view.detail } };
|
|
294
295
|
const result = installCardPatch(target, this.cardPatchEnvironment);
|
|
295
296
|
if (result.ok)
|
|
296
297
|
this.publishClientBundle(target.packageName);
|
|
@@ -302,10 +303,11 @@ let TeamPresetsToolCatalog = (() => {
|
|
|
302
303
|
* @returns the outcome, or a refusal naming why nothing changed.
|
|
303
304
|
*/
|
|
304
305
|
async uninstallCardPatch(id) {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
306
|
+
// Restore must resolve the same entry the row was classified against: a
|
|
307
|
+
// different version's pristine hash could never match the backup.
|
|
308
|
+
const { target, view } = resolveInstalledTarget(id, this.cardPatchEnvironment);
|
|
309
|
+
if (target === undefined)
|
|
310
|
+
return { ok: false, id, state: view.state, ...view.detail === undefined ? {} : { detail: view.detail } };
|
|
309
311
|
const result = uninstallCardPatch(target, this.cardPatchEnvironment);
|
|
310
312
|
if (result.ok)
|
|
311
313
|
this.publishClientBundle(target.packageName);
|
package/lib/types/types.d.ts
CHANGED
|
@@ -602,8 +602,12 @@ export interface CardPatchTargetView {
|
|
|
602
602
|
readonly packageName: string;
|
|
603
603
|
/** Upstream revision the prebuilt replacement came from. */
|
|
604
604
|
readonly source: string;
|
|
605
|
-
/**
|
|
605
|
+
/** Service a patched target registers; the page reads it to tell "active" from "installed". */
|
|
606
|
+
readonly service: string;
|
|
607
|
+
/** The version whose replacement applies to this row (the newest supported one when none matches). */
|
|
606
608
|
readonly supportedVersion: string;
|
|
609
|
+
/** Every upstream version this build ships a replacement for. */
|
|
610
|
+
readonly supportedVersions: readonly string[];
|
|
607
611
|
/** Installed version, when the package is present. */
|
|
608
612
|
readonly installedVersion?: string;
|
|
609
613
|
/** Installed bundle state. */
|