dsh-agent-team-presets 0.3.3 → 0.3.4
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 +4 -3
- package/README.md +2 -2
- package/README.zh.md +2 -2
- package/assets/card-patches/catalog.json +10 -0
- package/assets/card-patches/dsh-context-0.87.0.client.js.gz +0 -0
- package/docs/builtin-team-skills.md +4 -4
- package/docs/builtin-team-skills.zh.md +4 -4
- package/docs/guide/install.md +1 -1
- package/docs/guide/install.zh.md +1 -1
- package/docs/guide/integrations.md +1 -1
- package/docs/guide/integrations.zh.md +1 -1
- package/docs/guide/team-skills.md +21 -9
- package/docs/guide/team-skills.zh.md +21 -9
- package/icon.webp +0 -0
- package/lib/client.js +952 -176
- package/lib/index.js +560 -297
- package/lib/typert.host.js +402 -29
- package/lib/typert.remote-client.d.ts +9 -9
- package/lib/typert.remote-client.d.ts.map +1 -1
- package/lib/typert.remote-client.js +402 -29
- package/lib/types/client/TeamImportDialog.d.ts +4 -15
- package/lib/types/client/TeamImportDialog.js +29 -25
- package/lib/types/client/TeamPresetsSection.js +14 -5
- package/lib/types/client/TeamSkillsView.d.ts +3 -3
- package/lib/types/client/TeamSkillsView.js +56 -12
- package/lib/types/client/locales.d.ts +1 -1
- package/lib/types/client/locales.js +60 -8
- package/lib/types/client/team-presets-controller.d.ts +15 -2
- package/lib/types/client/team-presets-controller.js +86 -30
- package/lib/types/client/team-skills-controller.d.ts +14 -5
- package/lib/types/client/team-skills-controller.js +71 -37
- package/lib/types/index.js +5 -7
- package/lib/types/preset-editor.js +3 -4
- package/lib/types/preset-transfer.d.ts +1 -1
- package/lib/types/presets.d.ts +21 -23
- package/lib/types/presets.js +72 -36
- package/lib/types/team-skills/import.d.ts +17 -7
- package/lib/types/team-skills/import.js +115 -21
- package/lib/types/team-skills/index.d.ts +1 -12
- package/lib/types/team-skills/index.js +3 -26
- package/lib/types/team-skills/manager.d.ts +3 -3
- package/lib/types/team-skills/manager.js +39 -81
- package/lib/types/team-skills/official-bindings.d.ts +29 -0
- package/lib/types/team-skills/official-bindings.js +51 -0
- package/lib/types/team-skills/service.d.ts +7 -12
- package/lib/types/team-skills/service.js +125 -56
- package/lib/types/team-skills/store.d.ts +16 -6
- package/lib/types/team-skills/store.js +119 -14
- package/lib/types/types.d.ts +18 -4
- package/package.json +4 -1
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
import type { Context } from '@deepseek-ai/cordis';
|
|
6
6
|
import type { ModelCatalog } from '@deepseek-ai/dsh-api-remotes/client';
|
|
7
7
|
import { type SnapshotStore } from '@deepseek-ai/dsh-client-store';
|
|
8
|
-
import type { TeamPresetImportFailure, TeamPresetTransfer } from '../preset-transfer.ts';
|
|
8
|
+
import type { OfficialSkillTransfer, TeamPresetImportFailure, TeamPresetTransfer } from '../preset-transfer.ts';
|
|
9
9
|
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
10
10
|
import type { TeamRosterValue } from '../types.ts';
|
|
11
|
-
import type { TeamAgentPreset, TeamCaptainPreset, TeamCategory, TeamCategoryAssignment, TeamExecutionRow, TeamExecutionState, TeamPreset, ToolChoice } from '../types.ts';
|
|
11
|
+
import type { TeamAgentPreset, TeamCaptainPreset, TeamCategory, TeamCategoryAssignment, TeamExecutionRow, TeamExecutionState, TeamPreset, TeamSkillAssetView, ToolChoice } from '../types.ts';
|
|
12
12
|
/**
|
|
13
13
|
* Loader entry id of the Host row that owns the Team preset namespace. Spelled
|
|
14
14
|
* here rather than imported: a client package must not depend on a Host package.
|
|
@@ -219,6 +219,10 @@ export type DefaultsRestore = 'restored' | 'unchanged';
|
|
|
219
219
|
export type TeamPresetImportPlan = {
|
|
220
220
|
/** The document being imported. */
|
|
221
221
|
readonly transfer: TeamPresetTransfer;
|
|
222
|
+
/** Imported roles with the IDs they will keep if added to the draft. */
|
|
223
|
+
readonly incoming: TeamPreset;
|
|
224
|
+
/** Local identity of the replacement target, when there is a conflict. */
|
|
225
|
+
readonly targetId: string | undefined;
|
|
222
226
|
/** Index of the Team the document would overwrite, or undefined when it adds one. */
|
|
223
227
|
readonly targetIndex: number | undefined;
|
|
224
228
|
/** Display name of that Team, for the dialog that resolves the collision. */
|
|
@@ -257,6 +261,11 @@ export type TeamPresetImportResolution = {
|
|
|
257
261
|
* @returns the resolution that adds the document as a new Team.
|
|
258
262
|
*/
|
|
259
263
|
export declare function defaultImportResolution(plan: TeamPresetImportPlan): TeamPresetImportResolution;
|
|
264
|
+
/** Feedback describes the draft and the current library, before any binding is applied. */
|
|
265
|
+
export type TeamPresetImportSkillRow = OfficialSkillTransfer & {
|
|
266
|
+
readonly source: 'preset' | 'catalog';
|
|
267
|
+
readonly status: 'unknown-skill' | 'missing-role' | 'ambiguous-role' | 'catalog-ignored' | 'eligible' | 'asset-missing' | 'library-unavailable' | 'local-override';
|
|
268
|
+
};
|
|
260
269
|
/**
|
|
261
270
|
* Whether one stored Team still matches a staged draft, so the page can tell
|
|
262
271
|
* a duplicate from a real edit.
|
|
@@ -559,6 +568,8 @@ export declare class TeamPresetsController {
|
|
|
559
568
|
* @returns the plan, or the reason the document is not a Team preset of this format.
|
|
560
569
|
*/
|
|
561
570
|
inspectImport(text: string): TeamPresetImportInspection;
|
|
571
|
+
/** Inspect the draft that the selected collision choices would stage. */
|
|
572
|
+
previewImport(plan: TeamPresetImportPlan, resolution: TeamPresetImportResolution, assets?: readonly TeamSkillAssetView[]): readonly TeamPresetImportSkillRow[];
|
|
562
573
|
/**
|
|
563
574
|
* Stage one inspected document onto the draft.
|
|
564
575
|
*
|
|
@@ -769,6 +780,8 @@ export interface TeamPresetsInjected {
|
|
|
769
780
|
exportTeam: (index: number) => string | undefined;
|
|
770
781
|
/** Read one shared document and report what importing it would collide with. */
|
|
771
782
|
inspectImport: (text: string) => TeamPresetImportInspection;
|
|
783
|
+
/** Preview the declared skills for the selected import choices. */
|
|
784
|
+
previewImport: (plan: TeamPresetImportPlan, resolution: TeamPresetImportResolution, assets?: readonly TeamSkillAssetView[]) => readonly TeamPresetImportSkillRow[];
|
|
772
785
|
/** Stage one inspected document under the user's resolution of its collisions. */
|
|
773
786
|
applyImport: (plan: TeamPresetImportPlan, resolution: TeamPresetImportResolution) => string;
|
|
774
787
|
removeTeam: (index: number) => void;
|
|
@@ -6,7 +6,8 @@ import { createSnapshotStore } from '@deepseek-ai/dsh-client-store';
|
|
|
6
6
|
import { toolMode, withSelection } from "../presets.js";
|
|
7
7
|
import { cloneMetadata, restoreBuiltinTeams } from "../builtin-teams.js";
|
|
8
8
|
import { builtinEntry } from "../team-catalog.js";
|
|
9
|
-
import {
|
|
9
|
+
import { isOfficialSkillAsset, isOfficialSkillOverride, officialSkillDefaults, officialSkillTarget } from "../team-skills/official-bindings.js";
|
|
10
|
+
import { applySharedFields, importConflicts, parseTeamPresetText, serializeTeamPreset, slotNameKey, teamFromTransfer, uniqueName, } from "../preset-transfer.js";
|
|
10
11
|
import { liveAssignments } from "../team-search.js";
|
|
11
12
|
/**
|
|
12
13
|
* Loader entry id of the Host row that owns the Team preset namespace. Spelled
|
|
@@ -74,7 +75,7 @@ export function defaultImportResolution(plan) {
|
|
|
74
75
|
function mergeTransfer(target, plan, resolution) {
|
|
75
76
|
const members = [...target.members];
|
|
76
77
|
const importedNames = new Map();
|
|
77
|
-
for (const incoming of plan.
|
|
78
|
+
for (const incoming of plan.incoming.members) {
|
|
78
79
|
const key = slotNameKey(incoming.name);
|
|
79
80
|
const at = key === '' ? -1 : members.findIndex(member => slotNameKey(member.name) === key);
|
|
80
81
|
if (at >= 0 && (resolution.members[incoming.name] ?? 'replace') === 'replace') {
|
|
@@ -86,31 +87,75 @@ function mergeTransfer(target, plan, resolution) {
|
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
const name = uniqueName(incoming.name, members.map(member => member.name));
|
|
89
|
-
members.push(
|
|
90
|
+
members.push({ ...incoming, name });
|
|
90
91
|
importedNames.set(incoming.name, name);
|
|
91
92
|
}
|
|
92
93
|
const captain = plan.transfer.team.captain;
|
|
93
94
|
const captainName = resolution.captain === 'rename' ? plan.suggestedCaptainName : captain.name;
|
|
94
95
|
importedNames.set(captain.name, captainName);
|
|
95
96
|
return {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
: {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
: { officialSkills: plan.transfer.team.officialSkills.map(binding => ({
|
|
107
|
-
...binding,
|
|
108
|
-
roleName: importedNames.get(binding.roleName) ?? binding.roleName,
|
|
109
|
-
})) }),
|
|
110
|
-
captain: applySharedFields(target.captain, { ...captain, name: captainName }),
|
|
111
|
-
members,
|
|
97
|
+
importedNames,
|
|
98
|
+
team: {
|
|
99
|
+
...target,
|
|
100
|
+
name: plan.transfer.team.name,
|
|
101
|
+
description: plan.transfer.team.description,
|
|
102
|
+
// v1 never carried discovery metadata; v2 owns the field even when empty.
|
|
103
|
+
...(plan.transfer.version < 2 ? {} : { metadata: structuredClone(plan.transfer.team.metadata ?? {}) }),
|
|
104
|
+
captain: applySharedFields(target.captain, { ...captain, name: captainName }),
|
|
105
|
+
members,
|
|
106
|
+
},
|
|
112
107
|
};
|
|
113
108
|
}
|
|
109
|
+
function skillRow(team, declaration, source, assets) {
|
|
110
|
+
const row = { ...declaration, source };
|
|
111
|
+
const target = officialSkillTarget(team, declaration);
|
|
112
|
+
if (target.status !== 'valid')
|
|
113
|
+
return { ...row, status: target.status };
|
|
114
|
+
if (assets === undefined)
|
|
115
|
+
return { ...row, status: 'library-unavailable' };
|
|
116
|
+
if (assets.some(asset => isOfficialSkillOverride(asset, declaration.skillId)
|
|
117
|
+
&& asset.bindings.some(binding => binding.teamId === team.id && binding.roleId === target.roleId))) {
|
|
118
|
+
return { ...row, status: 'local-override' };
|
|
119
|
+
}
|
|
120
|
+
const available = assets.some(asset => isOfficialSkillAsset(asset, target.assetId));
|
|
121
|
+
return { ...row, status: available ? 'eligible' : 'asset-missing' };
|
|
122
|
+
}
|
|
123
|
+
/** Build the same proposed roster and declaration set for preview and staging. */
|
|
124
|
+
function projectImport(teams, plan, resolution, assets) {
|
|
125
|
+
const target = resolution.team === 'replace' ? teams.find(team => team.id === plan.targetId) : undefined;
|
|
126
|
+
const replacement = target === undefined ? undefined : mergeTransfer(target, plan, resolution);
|
|
127
|
+
const preferred = resolution.teamName.trim() === '' ? plan.transfer.team.name : resolution.teamName;
|
|
128
|
+
// New roles already have their draft identities. A new Team gets its local ID
|
|
129
|
+
// at staging, so preview cannot mistake it for a saved Team with bindings.
|
|
130
|
+
const team = replacement?.team ?? { ...plan.incoming, name: uniqueName(preferred, teams.map(candidate => candidate.name)) };
|
|
131
|
+
const defaults = officialSkillDefaults(team);
|
|
132
|
+
const declarations = plan.transfer.team.officialSkills;
|
|
133
|
+
const rows = [];
|
|
134
|
+
const retained = [];
|
|
135
|
+
for (const declaration of declarations ?? []) {
|
|
136
|
+
const original = officialSkillTarget(plan.incoming, declaration);
|
|
137
|
+
if (original.status !== 'valid') {
|
|
138
|
+
rows.push({ ...declaration, source: 'preset', status: original.status });
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (defaults.source === 'catalog') {
|
|
142
|
+
rows.push({ ...declaration, source: 'preset', status: 'catalog-ignored' });
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
const resolved = { ...declaration, roleName: replacement?.importedNames.get(declaration.roleName) ?? declaration.roleName };
|
|
146
|
+
const row = skillRow(team, resolved, 'preset', assets);
|
|
147
|
+
rows.push(row);
|
|
148
|
+
if (row.status !== 'missing-role' && row.status !== 'ambiguous-role')
|
|
149
|
+
retained.push(resolved);
|
|
150
|
+
}
|
|
151
|
+
if (defaults.source === 'catalog' || declarations === undefined) {
|
|
152
|
+
rows.push(...defaults.declarations.map(declaration => skillRow(team, declaration, defaults.source, assets)));
|
|
153
|
+
}
|
|
154
|
+
const staged = defaults.source === 'catalog'
|
|
155
|
+
? { ...team, officialSkills: defaults.declarations.map(declaration => ({ ...declaration })) }
|
|
156
|
+
: declarations === undefined ? team : { ...team, officialSkills: retained };
|
|
157
|
+
return { team: staged, target, rows };
|
|
158
|
+
}
|
|
114
159
|
/**
|
|
115
160
|
* Narrow one stored category list.
|
|
116
161
|
*
|
|
@@ -660,6 +705,7 @@ export class TeamPresetsController {
|
|
|
660
705
|
restoreDefaults: () => { this.restoreDefaults(); },
|
|
661
706
|
exportTeam: (index) => this.exportTeam(index),
|
|
662
707
|
inspectImport: (text) => this.inspectImport(text),
|
|
708
|
+
previewImport: (plan, resolution, assets) => this.previewImport(plan, resolution, assets),
|
|
663
709
|
applyImport: (plan, resolution) => {
|
|
664
710
|
return this.applyImport(plan, resolution);
|
|
665
711
|
},
|
|
@@ -979,8 +1025,7 @@ export class TeamPresetsController {
|
|
|
979
1025
|
const team = this.visibleTeams()[index];
|
|
980
1026
|
if (team === undefined)
|
|
981
1027
|
return undefined;
|
|
982
|
-
|
|
983
|
-
return serializeTeamPreset(team, officialSkills === undefined ? {} : { officialSkills });
|
|
1028
|
+
return serializeTeamPreset(team, { officialSkills: officialSkillDefaults(team).declarations });
|
|
984
1029
|
}
|
|
985
1030
|
/**
|
|
986
1031
|
* Read one document and work out what importing it would collide with.
|
|
@@ -994,7 +1039,21 @@ export class TeamPresetsController {
|
|
|
994
1039
|
const parsed = parseTeamPresetText(text);
|
|
995
1040
|
if (!parsed.ok)
|
|
996
1041
|
return parsed;
|
|
997
|
-
|
|
1042
|
+
const teams = this.visibleTeams();
|
|
1043
|
+
const conflicts = importConflicts(teams, parsed.transfer);
|
|
1044
|
+
return {
|
|
1045
|
+
ok: true,
|
|
1046
|
+
plan: {
|
|
1047
|
+
transfer: parsed.transfer,
|
|
1048
|
+
incoming: teamFromTransfer(parsed.transfer, ''),
|
|
1049
|
+
targetId: conflicts.targetIndex === undefined ? undefined : teams[conflicts.targetIndex]?.id,
|
|
1050
|
+
...conflicts,
|
|
1051
|
+
},
|
|
1052
|
+
};
|
|
1053
|
+
}
|
|
1054
|
+
/** Inspect the draft that the selected collision choices would stage. */
|
|
1055
|
+
previewImport(plan, resolution, assets) {
|
|
1056
|
+
return projectImport(this.visibleTeams(), plan, resolution, assets).rows;
|
|
998
1057
|
}
|
|
999
1058
|
/**
|
|
1000
1059
|
* Stage one inspected document onto the draft.
|
|
@@ -1008,16 +1067,13 @@ export class TeamPresetsController {
|
|
|
1008
1067
|
*/
|
|
1009
1068
|
applyImport(plan, resolution) {
|
|
1010
1069
|
const draft = this.beginDraft();
|
|
1011
|
-
const
|
|
1012
|
-
if (
|
|
1013
|
-
|
|
1014
|
-
this.draft = draft.map((team, position) => position === plan.targetIndex ? merged : team);
|
|
1070
|
+
const projected = projectImport(draft, plan, resolution);
|
|
1071
|
+
if (projected.target !== undefined) {
|
|
1072
|
+
this.draft = draft.map(team => team === projected.target ? projected.team : team);
|
|
1015
1073
|
this.publish();
|
|
1016
|
-
return
|
|
1074
|
+
return projected.team.id;
|
|
1017
1075
|
}
|
|
1018
|
-
const
|
|
1019
|
-
const name = uniqueName(preferred, draft.map(team => team.name));
|
|
1020
|
-
const created = { ...teamFromTransfer(plan.transfer, createTeamPreset(draft).id), name };
|
|
1076
|
+
const created = { ...projected.team, id: createTeamPreset(draft).id };
|
|
1021
1077
|
this.draft = [...draft, created];
|
|
1022
1078
|
this.publish();
|
|
1023
1079
|
return created.id;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @module dsh-agent-team-presets/client/team-skills-controller
|
|
11
11
|
*/
|
|
12
12
|
import type { Context } from '@deepseek-ai/cordis';
|
|
13
|
-
import type { TeamSkillDeleteView, TeamSkillDetailView, TeamSkillLibraryView, TeamSkillScanView } from '../types.ts';
|
|
13
|
+
import type { TeamSkillDeleteView, TeamSkillDetailView, TeamSkillLibraryView, TeamSkillScanEntry, TeamSkillScanView } from '../types.ts';
|
|
14
14
|
/** One page snapshot. */
|
|
15
15
|
export interface TeamSkillsState {
|
|
16
16
|
/** Where the library load stands. */
|
|
@@ -33,6 +33,8 @@ export interface TeamSkillsState {
|
|
|
33
33
|
readonly file: string | undefined;
|
|
34
34
|
/** That file's text, once read. */
|
|
35
35
|
readonly fileText: string | undefined;
|
|
36
|
+
/** Changes found by the last deliberate inbox check. */
|
|
37
|
+
readonly inboxChanges?: readonly TeamSkillScanEntry[];
|
|
36
38
|
/** The last directory scan, so the page can list every folder it judged. */
|
|
37
39
|
readonly scan: TeamSkillScanView | undefined;
|
|
38
40
|
/** Whether this Host can reveal a folder natively; false means the control copies the path. */
|
|
@@ -48,6 +50,9 @@ export declare class TeamSkillsController {
|
|
|
48
50
|
private readonly listeners;
|
|
49
51
|
private readonly ctx;
|
|
50
52
|
private disposed;
|
|
53
|
+
private pendingInboxCheck;
|
|
54
|
+
private libraryRequest;
|
|
55
|
+
private inboxRequest;
|
|
51
56
|
/**
|
|
52
57
|
* The Remote namespace, once the gateway announces it.
|
|
53
58
|
*
|
|
@@ -90,8 +95,8 @@ export declare class TeamSkillsController {
|
|
|
90
95
|
* @param patch - fields to change.
|
|
91
96
|
*/
|
|
92
97
|
private publish;
|
|
93
|
-
/** Read the library
|
|
94
|
-
refresh(): Promise<void>;
|
|
98
|
+
/** Read the library, optionally checking the inbox for pending changes. */
|
|
99
|
+
refresh(checkInbox?: boolean): Promise<void>;
|
|
95
100
|
/**
|
|
96
101
|
* Show one asset's detail.
|
|
97
102
|
* @param assetId - asset identity.
|
|
@@ -117,11 +122,12 @@ export declare class TeamSkillsController {
|
|
|
117
122
|
/**
|
|
118
123
|
* Import one folder the user picked.
|
|
119
124
|
* @param files - the picker's files, already carrying relative paths.
|
|
125
|
+
* @returns the asset identity when the folder was imported.
|
|
120
126
|
*/
|
|
121
127
|
importFolder(files: readonly {
|
|
122
128
|
path: string;
|
|
123
129
|
content: Uint8Array;
|
|
124
|
-
}[]): Promise<
|
|
130
|
+
}[]): Promise<string | undefined>;
|
|
125
131
|
/**
|
|
126
132
|
* Scan the Host's import folder and publish every new legal skill.
|
|
127
133
|
*
|
|
@@ -132,8 +138,11 @@ export declare class TeamSkillsController {
|
|
|
132
138
|
/**
|
|
133
139
|
* Copy one shipped skill into an editable override.
|
|
134
140
|
* @param skillId - shipped skill id.
|
|
141
|
+
* @param switchBindings - whether to move current role bindings to the copy.
|
|
142
|
+
* @returns the copy's asset identity when the Host created it.
|
|
135
143
|
*/
|
|
136
|
-
createOverride(skillId: string): Promise<
|
|
144
|
+
createOverride(skillId: string, switchBindings: boolean): Promise<string | undefined>;
|
|
145
|
+
private showCreatedAsset;
|
|
137
146
|
/**
|
|
138
147
|
* Discard one override's edits by re-copying the shipped skill.
|
|
139
148
|
* @param assetId - override identity.
|
|
@@ -41,6 +41,7 @@ export class TeamSkillsController {
|
|
|
41
41
|
issue: undefined,
|
|
42
42
|
file: undefined,
|
|
43
43
|
fileText: undefined,
|
|
44
|
+
inboxChanges: [],
|
|
44
45
|
scan: undefined,
|
|
45
46
|
canOpenScanFolder: false,
|
|
46
47
|
scanFolderPath: undefined,
|
|
@@ -49,6 +50,9 @@ export class TeamSkillsController {
|
|
|
49
50
|
listeners = new Set();
|
|
50
51
|
ctx;
|
|
51
52
|
disposed = false;
|
|
53
|
+
pendingInboxCheck = false;
|
|
54
|
+
libraryRequest = 0;
|
|
55
|
+
inboxRequest = 0;
|
|
52
56
|
/**
|
|
53
57
|
* The Remote namespace, once the gateway announces it.
|
|
54
58
|
*
|
|
@@ -70,7 +74,9 @@ export class TeamSkillsController {
|
|
|
70
74
|
try {
|
|
71
75
|
ctx.inject(['remote.teamSkills'], (scope) => {
|
|
72
76
|
this.service = scope.remote.teamSkills;
|
|
73
|
-
|
|
77
|
+
const checkInbox = this.pendingInboxCheck;
|
|
78
|
+
this.pendingInboxCheck = false;
|
|
79
|
+
void this.refresh(checkInbox);
|
|
74
80
|
return () => { this.service = undefined; };
|
|
75
81
|
});
|
|
76
82
|
}
|
|
@@ -169,30 +175,36 @@ export class TeamSkillsController {
|
|
|
169
175
|
for (const listener of this.listeners)
|
|
170
176
|
listener();
|
|
171
177
|
}
|
|
172
|
-
/** Read the library
|
|
173
|
-
async refresh() {
|
|
178
|
+
/** Read the library, optionally checking the inbox for pending changes. */
|
|
179
|
+
async refresh(checkInbox = false) {
|
|
180
|
+
if (checkInbox && this.service === undefined)
|
|
181
|
+
this.pendingInboxCheck = true;
|
|
182
|
+
const request = ++this.libraryRequest;
|
|
183
|
+
if (checkInbox)
|
|
184
|
+
this.inboxRequest = request;
|
|
174
185
|
this.publish({ status: this.state.library === undefined ? 'loading' : 'ready' });
|
|
175
186
|
try {
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
// the next build, and this branch must stay correct in the meantime.
|
|
181
|
-
const issue = library.issue;
|
|
182
|
-
if (issue !== undefined) {
|
|
183
|
-
this.publish({ status: 'unavailable', library: undefined, issue });
|
|
184
|
-
return;
|
|
187
|
+
const api = this.api();
|
|
188
|
+
const library = unwrap(await (checkInbox ? api.library(true) : api.library()));
|
|
189
|
+
if (checkInbox && request === this.inboxRequest && library.issue === undefined) {
|
|
190
|
+
this.publish({ inboxChanges: library.inboxChanges ?? [] });
|
|
185
191
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (
|
|
189
|
-
this.publish({
|
|
192
|
+
if (request !== this.libraryRequest)
|
|
193
|
+
return;
|
|
194
|
+
if (library.issue !== undefined) {
|
|
195
|
+
this.publish({ status: 'unavailable', library: undefined, issue: library.issue });
|
|
196
|
+
return;
|
|
190
197
|
}
|
|
198
|
+
const selectedId = this.state.selectedId;
|
|
199
|
+
const selectionGone = selectedId !== undefined && !library.assets.some(asset => asset.id === selectedId);
|
|
200
|
+
this.publish({
|
|
201
|
+
status: 'ready', library, issue: undefined,
|
|
202
|
+
...(selectionGone ? { selectedId: undefined, detail: undefined, file: undefined, fileText: undefined } : {}),
|
|
203
|
+
});
|
|
191
204
|
}
|
|
192
205
|
catch (error) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
this.publish({ status: 'unavailable', issue: String(error) });
|
|
206
|
+
if (request === this.libraryRequest)
|
|
207
|
+
this.publish({ status: 'unavailable', issue: String(error) });
|
|
196
208
|
}
|
|
197
209
|
}
|
|
198
210
|
/**
|
|
@@ -200,7 +212,7 @@ export class TeamSkillsController {
|
|
|
200
212
|
* @param assetId - asset identity.
|
|
201
213
|
*/
|
|
202
214
|
async select(assetId) {
|
|
203
|
-
this.publish({ selectedId: assetId, detail: undefined });
|
|
215
|
+
this.publish({ selectedId: assetId, detail: undefined, file: undefined, fileText: undefined });
|
|
204
216
|
const answer = unwrap(await this.api().detail(assetId));
|
|
205
217
|
if (this.disposed || this.state.selectedId !== assetId)
|
|
206
218
|
return;
|
|
@@ -224,7 +236,7 @@ export class TeamSkillsController {
|
|
|
224
236
|
this.publish({ file: path, fileText: undefined });
|
|
225
237
|
try {
|
|
226
238
|
const answer = unwrap(await this.api().readFile(assetId, path));
|
|
227
|
-
if (this.state.file !== path)
|
|
239
|
+
if (this.state.selectedId !== assetId || this.state.file !== path)
|
|
228
240
|
return;
|
|
229
241
|
if ('text' in answer)
|
|
230
242
|
this.publish({ fileText: answer.text });
|
|
@@ -232,7 +244,9 @@ export class TeamSkillsController {
|
|
|
232
244
|
this.publish({ message: answer.detail, failed: true });
|
|
233
245
|
}
|
|
234
246
|
catch (error) {
|
|
235
|
-
this.
|
|
247
|
+
if (this.state.selectedId === assetId && this.state.file === path) {
|
|
248
|
+
this.publish({ message: String(error), failed: true });
|
|
249
|
+
}
|
|
236
250
|
}
|
|
237
251
|
}
|
|
238
252
|
/**
|
|
@@ -244,13 +258,17 @@ export class TeamSkillsController {
|
|
|
244
258
|
const assetId = this.state.selectedId;
|
|
245
259
|
if (assetId === undefined)
|
|
246
260
|
return;
|
|
261
|
+
const version = this.state.detail?.asset.version;
|
|
247
262
|
await this.run(async () => {
|
|
248
|
-
const
|
|
263
|
+
const api = this.api();
|
|
264
|
+
const answer = unwrap(await api.writeFile(assetId, path, text, version));
|
|
249
265
|
if (!isDetail(answer))
|
|
250
266
|
return answer.detail;
|
|
251
|
-
this.
|
|
252
|
-
|
|
253
|
-
await this.
|
|
267
|
+
if (this.state.selectedId === assetId)
|
|
268
|
+
this.publish({ detail: answer });
|
|
269
|
+
await this.refresh(true);
|
|
270
|
+
if (this.state.selectedId === assetId)
|
|
271
|
+
await this.openFile(path);
|
|
254
272
|
return 'saved';
|
|
255
273
|
});
|
|
256
274
|
}
|
|
@@ -265,13 +283,14 @@ export class TeamSkillsController {
|
|
|
265
283
|
if (!isDetail(answer))
|
|
266
284
|
return answer.detail;
|
|
267
285
|
this.publish({ detail: answer, selectedId: answer.asset.id });
|
|
268
|
-
await this.refresh();
|
|
286
|
+
await this.refresh(true);
|
|
269
287
|
return 'created';
|
|
270
288
|
});
|
|
271
289
|
}
|
|
272
290
|
/**
|
|
273
291
|
* Import one folder the user picked.
|
|
274
292
|
* @param files - the picker's files, already carrying relative paths.
|
|
293
|
+
* @returns the asset identity when the folder was imported.
|
|
275
294
|
*/
|
|
276
295
|
async importFolder(files) {
|
|
277
296
|
if (files.length === 0)
|
|
@@ -280,14 +299,15 @@ export class TeamSkillsController {
|
|
|
280
299
|
path: file.path,
|
|
281
300
|
base64: encodeBase64(file.content),
|
|
282
301
|
}));
|
|
302
|
+
let importedId;
|
|
283
303
|
await this.run(async () => {
|
|
284
304
|
const answer = unwrap(await this.api().importSkill(payload));
|
|
285
305
|
if (!isDetail(answer))
|
|
286
306
|
return answer.detail;
|
|
287
|
-
this.
|
|
288
|
-
await this.refresh();
|
|
307
|
+
importedId = await this.showCreatedAsset(answer);
|
|
289
308
|
return 'imported';
|
|
290
309
|
});
|
|
310
|
+
return importedId;
|
|
291
311
|
}
|
|
292
312
|
/**
|
|
293
313
|
* Scan the Host's import folder and publish every new legal skill.
|
|
@@ -303,23 +323,34 @@ export class TeamSkillsController {
|
|
|
303
323
|
return answer.detail;
|
|
304
324
|
}
|
|
305
325
|
this.publish({ scan: answer });
|
|
306
|
-
await this.refresh();
|
|
326
|
+
await this.refresh(true);
|
|
307
327
|
return 'scanned';
|
|
308
328
|
});
|
|
309
329
|
}
|
|
310
330
|
/**
|
|
311
331
|
* Copy one shipped skill into an editable override.
|
|
312
332
|
* @param skillId - shipped skill id.
|
|
333
|
+
* @param switchBindings - whether to move current role bindings to the copy.
|
|
334
|
+
* @returns the copy's asset identity when the Host created it.
|
|
313
335
|
*/
|
|
314
|
-
async createOverride(skillId) {
|
|
336
|
+
async createOverride(skillId, switchBindings) {
|
|
337
|
+
let copyId;
|
|
315
338
|
await this.run(async () => {
|
|
316
|
-
const
|
|
339
|
+
const api = this.api();
|
|
340
|
+
const answer = unwrap(await api.overrideSkill(skillId, switchBindings));
|
|
317
341
|
if (!isDetail(answer))
|
|
318
342
|
return answer.detail;
|
|
319
|
-
this.
|
|
320
|
-
await this.refresh();
|
|
343
|
+
copyId = await this.showCreatedAsset(answer);
|
|
321
344
|
return 'override-created';
|
|
322
345
|
});
|
|
346
|
+
return copyId;
|
|
347
|
+
}
|
|
348
|
+
async showCreatedAsset(detail) {
|
|
349
|
+
await this.refresh(true);
|
|
350
|
+
const assetId = detail.asset.id;
|
|
351
|
+
this.publish({ selectedId: assetId, detail, file: undefined, fileText: undefined });
|
|
352
|
+
await this.openFile('SKILL.md');
|
|
353
|
+
return assetId;
|
|
323
354
|
}
|
|
324
355
|
/**
|
|
325
356
|
* Discard one override's edits by re-copying the shipped skill.
|
|
@@ -330,7 +361,10 @@ export class TeamSkillsController {
|
|
|
330
361
|
const answer = unwrap(await this.api().resetSkill(assetId));
|
|
331
362
|
if (!isDetail(answer))
|
|
332
363
|
return answer.detail;
|
|
333
|
-
this.
|
|
364
|
+
if (this.state.selectedId === assetId) {
|
|
365
|
+
this.publish({ detail: answer });
|
|
366
|
+
await this.openFile('SKILL.md');
|
|
367
|
+
}
|
|
334
368
|
await this.refresh();
|
|
335
369
|
return 'override-reset';
|
|
336
370
|
});
|
|
@@ -344,7 +378,7 @@ export class TeamSkillsController {
|
|
|
344
378
|
let outcome;
|
|
345
379
|
await this.run(async () => {
|
|
346
380
|
outcome = unwrap(await this.api().deleteAsset(assetId));
|
|
347
|
-
await this.refresh();
|
|
381
|
+
await this.refresh(outcome.ok);
|
|
348
382
|
if (!outcome.ok)
|
|
349
383
|
return outcome.blockers.map(blocker => `${blocker.kind}: ${blocker.detail}`).join('; ');
|
|
350
384
|
this.publish({ selectedId: undefined, detail: undefined });
|
|
@@ -437,7 +471,7 @@ export class TeamSkillsController {
|
|
|
437
471
|
const message = await work();
|
|
438
472
|
// A success is shown by the refreshed panel itself; only a refusal needs
|
|
439
473
|
// words, so a machine key never reaches the user as raw text.
|
|
440
|
-
const succeeded = /^(saved|created|imported|deleted|assigned|unassigned|scanned|override
|
|
474
|
+
const succeeded = /^(saved|created|imported|deleted|assigned|unassigned|scanned|override-created|override-reset|restored-bindings)$/u.test(message);
|
|
441
475
|
this.publish({ busy: false, message: succeeded ? undefined : message, failed: !succeeded });
|
|
442
476
|
}
|
|
443
477
|
catch (error) {
|
package/lib/types/index.js
CHANGED
|
@@ -28,10 +28,10 @@ import { membershipOf } from "./team-runtime.js";
|
|
|
28
28
|
import { RUN_CODE_NAME } from '@deepseek-ai/dsh-tools';
|
|
29
29
|
import { registerPresetTools } from "./preset-tools.js";
|
|
30
30
|
import { teamModeAdmitsTools } from "./team-mode.js";
|
|
31
|
-
import { CAPTAIN_ROLE, TeamSkills, resolveSkillRoot
|
|
31
|
+
import { CAPTAIN_ROLE, TeamSkills, resolveSkillRoot } from "./team-skills/index.js";
|
|
32
32
|
import { TeamSkillService } from "./team-skills/service.js";
|
|
33
33
|
import { registerTeamSkillTools } from "./team-skills/tools.js";
|
|
34
|
-
import { definitionFingerprint, findMemberById, findTeam, memberRouteOf, sameMemberRoute, selectedRoleId, selectedTeam, toolMode } from "./presets.js";
|
|
34
|
+
import { definitionFingerprint, findMemberById, findTeam, memberRouteOf, recordedMemberRole, sameMemberRoute, selectedRoleId, selectedTeam, toolMode } from "./presets.js";
|
|
35
35
|
import TeamPresetsToolCatalog from "./tool-catalog.js";
|
|
36
36
|
import { CAPTAIN_RECOVERY_TOOLS, descriptorPolicy, guardPolicy, hasLegacyPresetBriefing, policyOf } from "./tool-policy.js";
|
|
37
37
|
export { Config } from "./config.js";
|
|
@@ -319,12 +319,10 @@ export function apply(ctx, config) {
|
|
|
319
319
|
quarantines.get(agent)?.dispose();
|
|
320
320
|
quarantines.delete(agent);
|
|
321
321
|
managedMembers.add(agent);
|
|
322
|
-
//
|
|
323
|
-
//
|
|
324
|
-
// the current Settings, exactly as its route and policy are.
|
|
322
|
+
// Use the snapshot's role id or its saved display name when restoring
|
|
323
|
+
// Team Skills. The current summon target may have changed ownership.
|
|
325
324
|
const claimedTeam = findTeam(config.teams.get(), claim.record.teamId);
|
|
326
|
-
const role = claim.record
|
|
327
|
-
?? (claimedTeam === undefined ? claim.record.memberName : roleOfMember(claimedTeam, claim.record.memberName));
|
|
325
|
+
const role = recordedMemberRole(claimedTeam, claim.record);
|
|
328
326
|
let installation;
|
|
329
327
|
if (role !== undefined) {
|
|
330
328
|
const assignment = { teamId: claim.record.teamId, roleId: role, captain: false };
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* edit is testable without one.
|
|
8
8
|
* @module dsh-agent-team-presets/preset-editor
|
|
9
9
|
*/
|
|
10
|
-
import { memberTargets } from "./presets.js";
|
|
10
|
+
import { findMemberInRoster, memberTargets } from "./presets.js";
|
|
11
11
|
/** Longest member description the teammate roster accepts when it spawns that member. */
|
|
12
12
|
export const MEMBER_DESCRIPTION_LIMIT = 200;
|
|
13
13
|
/** Refusal text for a call that names no editable field at all. */
|
|
@@ -56,13 +56,12 @@ export function editTeamPreset(team, edit) {
|
|
|
56
56
|
const members = team.members.map(member => ({ ...member }));
|
|
57
57
|
const roster = memberTargets({ ...team, members });
|
|
58
58
|
for (const entry of edit.members ?? []) {
|
|
59
|
-
const
|
|
60
|
-
const at = roster.findIndex(row => row.target === wanted.toLowerCase() || row.member.name.trim() === wanted);
|
|
61
|
-
const row = roster[at];
|
|
59
|
+
const row = findMemberInRoster(roster, entry.member);
|
|
62
60
|
if (row === undefined) {
|
|
63
61
|
const targets = roster.map(candidate => candidate.target).join(', ');
|
|
64
62
|
return { ok: false, message: `unknown Team member "${entry.member}"; available members: ${targets === '' ? '(none)' : targets}` };
|
|
65
63
|
}
|
|
64
|
+
const at = roster.indexOf(row);
|
|
66
65
|
const current = members[at] ?? row.member;
|
|
67
66
|
const updated = { ...current };
|
|
68
67
|
if (entry.description !== undefined) {
|
|
@@ -71,7 +71,7 @@ export type TeamSlotTransfer = {
|
|
|
71
71
|
export type OfficialSkillTransfer = {
|
|
72
72
|
/** Shipped skill id; resolvable on another deployment of this plugin version. */
|
|
73
73
|
readonly skillId: string;
|
|
74
|
-
/**
|
|
74
|
+
/** Exact role name inside the document. */
|
|
75
75
|
readonly roleName: string;
|
|
76
76
|
};
|
|
77
77
|
/** One Team as a shareable document. */
|