plugin-agent-orchestrator 1.1.0 → 1.1.3
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/dist/externalVersion.js +6 -6
- package/dist/locale/en-US.json +7 -1
- package/dist/locale/vi-VN.json +7 -1
- package/dist/locale/zh-CN.json +7 -1
- package/dist/node_modules/ajv/.tonic_example.js +20 -0
- package/dist/node_modules/ajv/LICENSE +22 -0
- package/dist/node_modules/ajv/dist/ajv.bundle.js +7189 -0
- package/dist/node_modules/ajv/dist/ajv.min.js +3 -0
- package/dist/node_modules/ajv/lib/ajv.d.ts +397 -0
- package/dist/node_modules/ajv/lib/ajv.js +3 -0
- package/dist/node_modules/ajv/lib/cache.js +26 -0
- package/dist/node_modules/ajv/lib/compile/async.js +90 -0
- package/dist/node_modules/ajv/lib/compile/equal.js +5 -0
- package/dist/node_modules/ajv/lib/compile/error_classes.js +34 -0
- package/dist/node_modules/ajv/lib/compile/formats.js +142 -0
- package/dist/node_modules/ajv/lib/compile/index.js +387 -0
- package/dist/node_modules/ajv/lib/compile/resolve.js +270 -0
- package/dist/node_modules/ajv/lib/compile/rules.js +66 -0
- package/dist/node_modules/ajv/lib/compile/schema_obj.js +9 -0
- package/dist/node_modules/ajv/lib/compile/ucs2length.js +20 -0
- package/dist/node_modules/ajv/lib/compile/util.js +239 -0
- package/dist/node_modules/ajv/lib/data.js +49 -0
- package/dist/node_modules/ajv/lib/definition_schema.js +37 -0
- package/dist/node_modules/ajv/lib/dot/_limit.jst +113 -0
- package/dist/node_modules/ajv/lib/dot/_limitItems.jst +12 -0
- package/dist/node_modules/ajv/lib/dot/_limitLength.jst +12 -0
- package/dist/node_modules/ajv/lib/dot/_limitProperties.jst +12 -0
- package/dist/node_modules/ajv/lib/dot/allOf.jst +32 -0
- package/dist/node_modules/ajv/lib/dot/anyOf.jst +46 -0
- package/dist/node_modules/ajv/lib/dot/coerce.def +51 -0
- package/dist/node_modules/ajv/lib/dot/comment.jst +9 -0
- package/dist/node_modules/ajv/lib/dot/const.jst +11 -0
- package/dist/node_modules/ajv/lib/dot/contains.jst +55 -0
- package/dist/node_modules/ajv/lib/dot/custom.jst +191 -0
- package/dist/node_modules/ajv/lib/dot/defaults.def +47 -0
- package/dist/node_modules/ajv/lib/dot/definitions.def +203 -0
- package/dist/node_modules/ajv/lib/dot/dependencies.jst +79 -0
- package/dist/node_modules/ajv/lib/dot/enum.jst +30 -0
- package/dist/node_modules/ajv/lib/dot/errors.def +194 -0
- package/dist/node_modules/ajv/lib/dot/format.jst +106 -0
- package/dist/node_modules/ajv/lib/dot/if.jst +73 -0
- package/dist/node_modules/ajv/lib/dot/items.jst +98 -0
- package/dist/node_modules/ajv/lib/dot/missing.def +39 -0
- package/dist/node_modules/ajv/lib/dot/multipleOf.jst +22 -0
- package/dist/node_modules/ajv/lib/dot/not.jst +43 -0
- package/dist/node_modules/ajv/lib/dot/oneOf.jst +54 -0
- package/dist/node_modules/ajv/lib/dot/pattern.jst +14 -0
- package/dist/node_modules/ajv/lib/dot/properties.jst +245 -0
- package/dist/node_modules/ajv/lib/dot/propertyNames.jst +52 -0
- package/dist/node_modules/ajv/lib/dot/ref.jst +85 -0
- package/dist/node_modules/ajv/lib/dot/required.jst +108 -0
- package/dist/node_modules/ajv/lib/dot/uniqueItems.jst +62 -0
- package/dist/node_modules/ajv/lib/dot/validate.jst +276 -0
- package/dist/node_modules/ajv/lib/dotjs/_limit.js +163 -0
- package/dist/node_modules/ajv/lib/dotjs/_limitItems.js +80 -0
- package/dist/node_modules/ajv/lib/dotjs/_limitLength.js +85 -0
- package/dist/node_modules/ajv/lib/dotjs/_limitProperties.js +80 -0
- package/dist/node_modules/ajv/lib/dotjs/allOf.js +42 -0
- package/dist/node_modules/ajv/lib/dotjs/anyOf.js +73 -0
- package/dist/node_modules/ajv/lib/dotjs/comment.js +14 -0
- package/dist/node_modules/ajv/lib/dotjs/const.js +56 -0
- package/dist/node_modules/ajv/lib/dotjs/contains.js +81 -0
- package/dist/node_modules/ajv/lib/dotjs/custom.js +228 -0
- package/dist/node_modules/ajv/lib/dotjs/dependencies.js +168 -0
- package/dist/node_modules/ajv/lib/dotjs/enum.js +66 -0
- package/dist/node_modules/ajv/lib/dotjs/format.js +150 -0
- package/dist/node_modules/ajv/lib/dotjs/if.js +103 -0
- package/dist/node_modules/ajv/lib/dotjs/index.js +33 -0
- package/dist/node_modules/ajv/lib/dotjs/items.js +140 -0
- package/dist/node_modules/ajv/lib/dotjs/multipleOf.js +80 -0
- package/dist/node_modules/ajv/lib/dotjs/not.js +84 -0
- package/dist/node_modules/ajv/lib/dotjs/oneOf.js +73 -0
- package/dist/node_modules/ajv/lib/dotjs/pattern.js +75 -0
- package/dist/node_modules/ajv/lib/dotjs/properties.js +335 -0
- package/dist/node_modules/ajv/lib/dotjs/propertyNames.js +81 -0
- package/dist/node_modules/ajv/lib/dotjs/ref.js +124 -0
- package/dist/node_modules/ajv/lib/dotjs/required.js +270 -0
- package/dist/node_modules/ajv/lib/dotjs/uniqueItems.js +86 -0
- package/dist/node_modules/ajv/lib/dotjs/validate.js +482 -0
- package/dist/node_modules/ajv/lib/keyword.js +146 -0
- package/dist/node_modules/ajv/lib/refs/data.json +17 -0
- package/dist/node_modules/ajv/lib/refs/json-schema-draft-04.json +149 -0
- package/dist/node_modules/ajv/lib/refs/json-schema-draft-06.json +154 -0
- package/dist/node_modules/ajv/lib/refs/json-schema-draft-07.json +168 -0
- package/dist/node_modules/ajv/lib/refs/json-schema-secure.json +94 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/.eslintrc.yml +27 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/.travis.yml +8 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/index.js +89 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/package.json +43 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/spec/.eslintrc.yml +6 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/spec/fixtures/schema.js +125 -0
- package/dist/node_modules/ajv/node_modules/json-schema-traverse/spec/index.spec.js +171 -0
- package/dist/node_modules/ajv/package.json +1 -0
- package/dist/node_modules/ajv/scripts/.eslintrc.yml +3 -0
- package/dist/node_modules/ajv/scripts/bundle.js +61 -0
- package/dist/node_modules/ajv/scripts/compile-dots.js +73 -0
- package/dist/node_modules/ajv/scripts/info +10 -0
- package/dist/node_modules/ajv/scripts/prepare-tests +12 -0
- package/dist/node_modules/ajv/scripts/publish-built-version +32 -0
- package/dist/node_modules/ajv/scripts/travis-gh-pages +23 -0
- package/dist/server/collections/skill-definitions.js +31 -0
- package/dist/server/collections/skill-executions.js +19 -0
- package/dist/server/collections/skill-registry-installations.js +70 -0
- package/dist/server/migrations/20260727010000-backfill-skill-tool-names.js +66 -0
- package/dist/server/plugin.js +96 -1
- package/dist/server/services/AgentExecutionContext.js +45 -0
- package/dist/server/services/CodeValidator.js +1 -0
- package/dist/server/services/ExecutionSpanService.js +10 -2
- package/dist/server/services/InputSchemaValidator.js +83 -0
- package/dist/server/services/NativeSubAgentObserver.js +55 -8
- package/dist/server/services/SandboxRunner.js +6 -2
- package/dist/server/services/SkillAccessService.js +109 -0
- package/dist/server/services/SkillManager.js +2 -0
- package/dist/server/services/SkillRepositoryService.js +70 -0
- package/dist/server/skill-hub/actions/git-import.js +479 -216
- package/dist/server/skill-hub/mcp/McpController.js +8 -5
- package/dist/server/skill-hub/middlewares/git-import-request-method-policy.js +69 -0
- package/dist/server/skill-hub/plugin.js +68 -14
- package/dist/server/skill-hub/services/RegistrySkillInstallationService.js +249 -0
- package/dist/server/skill-hub/services/RegistrySkillSnapshotService.js +228 -0
- package/dist/server/skill-hub/tasks/SkillExecutionTask.js +15 -3
- package/dist/server/tools/skill-execute.js +23 -2
- package/dist/server/utils/ctx-utils.js +2 -2
- package/dist/server/utils/skill-tool-name.js +73 -0
- package/package.json +9 -3
- package/src/locale/en-US.json +7 -1
- package/src/locale/vi-VN.json +7 -1
- package/src/locale/zh-CN.json +7 -1
- package/src/server/__tests__/agent-execution-context.test.ts +18 -0
- package/src/server/__tests__/input-schema-validator.test.ts +26 -0
- package/src/server/__tests__/native-sub-agent-observer.test.ts +52 -2
- package/src/server/__tests__/skill-access-service.test.ts +64 -0
- package/src/server/__tests__/skill-execute.test.ts +37 -0
- package/src/server/__tests__/skill-tool-name.test.ts +23 -0
- package/src/server/collections/skill-definitions.ts +31 -0
- package/src/server/collections/skill-executions.ts +19 -0
- package/src/server/collections/skill-registry-installations.ts +41 -0
- package/src/server/migrations/20260727010000-backfill-skill-tool-names.ts +45 -0
- package/src/server/plugin.ts +104 -1
- package/src/server/services/AgentExecutionContext.ts +23 -0
- package/src/server/services/CodeValidator.ts +1 -0
- package/src/server/services/ExecutionSpanService.ts +119 -110
- package/src/server/services/InputSchemaValidator.ts +44 -0
- package/src/server/services/NativeSubAgentObserver.ts +64 -10
- package/src/server/services/SandboxRunner.ts +6 -0
- package/src/server/services/SkillAccessService.ts +100 -0
- package/src/server/services/SkillManager.ts +2 -0
- package/src/server/services/SkillRepositoryService.ts +98 -2
- package/src/server/services/__tests__/SkillRepositoryService.test.ts +33 -0
- package/src/server/skill-hub/actions/__tests__/git-import.test.ts +549 -0
- package/src/server/skill-hub/actions/git-import.ts +682 -236
- package/src/server/skill-hub/mcp/McpController.ts +8 -14
- package/src/server/skill-hub/middlewares/git-import-request-method-policy.ts +51 -0
- package/src/server/skill-hub/plugin.ts +79 -13
- package/src/server/skill-hub/services/RegistrySkillInstallationService.ts +281 -0
- package/src/server/skill-hub/services/RegistrySkillSnapshotService.ts +239 -0
- package/src/server/skill-hub/services/__tests__/RegistrySkillInstallationService.test.ts +295 -0
- package/src/server/skill-hub/services/__tests__/RegistrySkillSnapshotService.test.ts +63 -0
- package/src/server/skill-hub/tasks/SkillExecutionTask.ts +14 -2
- package/src/server/tools/skill-execute.ts +24 -2
- package/src/server/utils/ctx-utils.ts +1 -1
- package/src/server/utils/skill-tool-name.ts +58 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { createHash } from 'crypto';
|
|
2
|
+
|
|
3
|
+
import type { Database } from '@nocobase/database';
|
|
4
|
+
|
|
5
|
+
type JsonValue = boolean | number | string | null | JsonValue[] | { [key: string]: JsonValue };
|
|
6
|
+
|
|
7
|
+
export interface RegistrySkillSnapshotSummary {
|
|
8
|
+
id: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface RegistrySkillSnapshot {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
title: string;
|
|
15
|
+
description: string;
|
|
16
|
+
language: 'python' | 'node';
|
|
17
|
+
suggestedVersion?: string;
|
|
18
|
+
inputSchema: JsonValue;
|
|
19
|
+
instructions: string;
|
|
20
|
+
files: Array<{ path: string; content: Buffer }>;
|
|
21
|
+
portable: boolean;
|
|
22
|
+
reason?: string;
|
|
23
|
+
revision: string;
|
|
24
|
+
dependencies: JsonValue;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type DefinitionModel = {
|
|
28
|
+
get(attribute: string): unknown;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
function positiveLimit(value: string | undefined, fallback: number, maximum: number): number {
|
|
32
|
+
const parsed = Number(value);
|
|
33
|
+
return Number.isSafeInteger(parsed) && parsed > 0 && parsed <= maximum ? parsed : fallback;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const MAX_REGISTRY_SKILL_SNAPSHOTS = positiveLimit(
|
|
37
|
+
process.env.SKILL_REGISTRY_MAX_SOURCE_ITEMS,
|
|
38
|
+
1000,
|
|
39
|
+
10_000,
|
|
40
|
+
);
|
|
41
|
+
const MAX_REGISTRY_TEXT_BYTES = 10 * 1024 * 1024;
|
|
42
|
+
|
|
43
|
+
const registryExportFilter = {
|
|
44
|
+
registryPackageId: null,
|
|
45
|
+
registryVersionId: null,
|
|
46
|
+
registryInstallationId: null,
|
|
47
|
+
registryInstallStatus: null,
|
|
48
|
+
registryExportEnabled: true,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const REGISTRY_EXPORT_NOT_GRANTED = 'REGISTRY_EXPORT_NOT_GRANTED';
|
|
52
|
+
export const REGISTRY_EXPORT_LIMIT_EXCEEDED = 'REGISTRY_EXPORT_LIMIT_EXCEEDED';
|
|
53
|
+
|
|
54
|
+
export class RegistryExportNotGrantedError extends Error {
|
|
55
|
+
readonly code = REGISTRY_EXPORT_NOT_GRANTED;
|
|
56
|
+
|
|
57
|
+
constructor() {
|
|
58
|
+
super('Registry export is not enabled for this Skill Hub definition.');
|
|
59
|
+
this.name = 'RegistryExportNotGrantedError';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export class RegistryExportLimitError extends Error {
|
|
64
|
+
readonly code = REGISTRY_EXPORT_LIMIT_EXCEEDED;
|
|
65
|
+
|
|
66
|
+
constructor(message: string) {
|
|
67
|
+
super(message);
|
|
68
|
+
this.name = 'RegistryExportLimitError';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function value(model: DefinitionModel, attribute: string): unknown {
|
|
73
|
+
return model.get(attribute);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function text(model: DefinitionModel, attribute: string, fallback = ''): string {
|
|
77
|
+
const raw = value(model, attribute);
|
|
78
|
+
return typeof raw === 'string' ? raw : raw === null || raw === undefined ? fallback : String(raw);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function parseJson(raw: unknown, fallback: JsonValue): JsonValue {
|
|
82
|
+
if (raw === null || typeof raw === 'string' || typeof raw === 'boolean') {
|
|
83
|
+
if (typeof raw !== 'string') {
|
|
84
|
+
return raw;
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
return JSON.parse(raw) as JsonValue;
|
|
88
|
+
} catch {
|
|
89
|
+
return fallback;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (typeof raw === 'number' && Number.isFinite(raw)) {
|
|
93
|
+
return raw;
|
|
94
|
+
}
|
|
95
|
+
if (Array.isArray(raw) || (typeof raw === 'object' && raw !== null)) {
|
|
96
|
+
return raw as JsonValue;
|
|
97
|
+
}
|
|
98
|
+
return fallback;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function stableJson(value: JsonValue): string {
|
|
102
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean' || typeof value === 'number') {
|
|
103
|
+
return JSON.stringify(value);
|
|
104
|
+
}
|
|
105
|
+
if (Array.isArray(value)) {
|
|
106
|
+
return `[${value.map(stableJson).join(',')}]`;
|
|
107
|
+
}
|
|
108
|
+
return `{${Object.keys(value)
|
|
109
|
+
.sort()
|
|
110
|
+
.map((key) => `${JSON.stringify(key)}:${stableJson(value[key])}`)
|
|
111
|
+
.join(',')}}`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function digest(value: JsonValue): string {
|
|
115
|
+
return `sha256:${createHash('sha256').update(stableJson(value)).digest('hex')}`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function asPortableSnapshot(model: DefinitionModel): RegistrySkillSnapshot {
|
|
119
|
+
const id = text(model, 'id');
|
|
120
|
+
const name = text(model, 'name');
|
|
121
|
+
const storageType = text(model, 'storageType', 'database');
|
|
122
|
+
const codeTemplate = text(model, 'codeTemplate');
|
|
123
|
+
const language = text(model, 'language', 'python') === 'node' ? 'node' : 'python';
|
|
124
|
+
const inputSchema = parseJson(value(model, 'inputSchema'), { type: 'object', properties: {} });
|
|
125
|
+
const dependencies = parseJson(value(model, 'packages'), []);
|
|
126
|
+
const instructions = text(model, 'instructions');
|
|
127
|
+
if (
|
|
128
|
+
Buffer.byteLength(codeTemplate, 'utf8') > MAX_REGISTRY_TEXT_BYTES ||
|
|
129
|
+
Buffer.byteLength(instructions, 'utf8') > MAX_REGISTRY_TEXT_BYTES
|
|
130
|
+
) {
|
|
131
|
+
throw new RegistryExportLimitError('Skill Hub definition exceeds the registry source-file limit.');
|
|
132
|
+
}
|
|
133
|
+
const revisionInput = {
|
|
134
|
+
id,
|
|
135
|
+
name,
|
|
136
|
+
storageType,
|
|
137
|
+
codeTemplate,
|
|
138
|
+
language,
|
|
139
|
+
inputSchema,
|
|
140
|
+
dependencies,
|
|
141
|
+
instructions,
|
|
142
|
+
title: text(model, 'title'),
|
|
143
|
+
description: text(model, 'description'),
|
|
144
|
+
};
|
|
145
|
+
if (storageType === 'plugin') {
|
|
146
|
+
return {
|
|
147
|
+
id,
|
|
148
|
+
name,
|
|
149
|
+
title: text(model, 'title', name),
|
|
150
|
+
description: text(model, 'description'),
|
|
151
|
+
language,
|
|
152
|
+
inputSchema,
|
|
153
|
+
instructions,
|
|
154
|
+
files: [],
|
|
155
|
+
portable: false,
|
|
156
|
+
reason: 'Plugin-backed skills require an explicit portable export bundle.',
|
|
157
|
+
revision: digest(revisionInput),
|
|
158
|
+
dependencies,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
if (!codeTemplate.trim()) {
|
|
162
|
+
return {
|
|
163
|
+
id,
|
|
164
|
+
name,
|
|
165
|
+
title: text(model, 'title', name),
|
|
166
|
+
description: text(model, 'description'),
|
|
167
|
+
language,
|
|
168
|
+
inputSchema,
|
|
169
|
+
instructions,
|
|
170
|
+
files: [],
|
|
171
|
+
portable: false,
|
|
172
|
+
reason: 'Skill has no inline code bundle to export.',
|
|
173
|
+
revision: digest(revisionInput),
|
|
174
|
+
dependencies,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
const entrypoint = language === 'node' ? 'src/index.js' : 'src/index.py';
|
|
178
|
+
const skillMarkdown = [
|
|
179
|
+
'---',
|
|
180
|
+
`name: ${name}`,
|
|
181
|
+
`title: ${text(model, 'title', name)}`,
|
|
182
|
+
`description: ${text(model, 'description').replace(/\r?\n/g, ' ')}`,
|
|
183
|
+
`language: ${language}`,
|
|
184
|
+
'---',
|
|
185
|
+
'',
|
|
186
|
+
instructions,
|
|
187
|
+
].join('\n');
|
|
188
|
+
return {
|
|
189
|
+
id,
|
|
190
|
+
name,
|
|
191
|
+
title: text(model, 'title', name),
|
|
192
|
+
description: text(model, 'description'),
|
|
193
|
+
language,
|
|
194
|
+
inputSchema,
|
|
195
|
+
instructions,
|
|
196
|
+
files: [
|
|
197
|
+
{ path: 'SKILL.md', content: Buffer.from(skillMarkdown, 'utf8') },
|
|
198
|
+
{ path: entrypoint, content: Buffer.from(codeTemplate, 'utf8') },
|
|
199
|
+
],
|
|
200
|
+
portable: true,
|
|
201
|
+
revision: digest(revisionInput),
|
|
202
|
+
dependencies,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export class RegistrySkillSnapshotService {
|
|
207
|
+
constructor(private readonly database: Database) {}
|
|
208
|
+
|
|
209
|
+
async listSkillSnapshots(): Promise<RegistrySkillSnapshotSummary[]> {
|
|
210
|
+
// Registry-installed rows are local runtime projections of an immutable
|
|
211
|
+
// registry package. Exporting them back through Skill Hub would let the
|
|
212
|
+
// registry re-discover and publish its own installed artifacts.
|
|
213
|
+
const definitions = await this.database.getRepository('skillDefinitions').find({
|
|
214
|
+
fields: ['id'],
|
|
215
|
+
filter: registryExportFilter,
|
|
216
|
+
sort: ['id'],
|
|
217
|
+
limit: MAX_REGISTRY_SKILL_SNAPSHOTS + 1,
|
|
218
|
+
});
|
|
219
|
+
if (definitions.length > MAX_REGISTRY_SKILL_SNAPSHOTS) {
|
|
220
|
+
throw new RegistryExportLimitError('Skill Hub registry export exceeds the configured source-item limit.');
|
|
221
|
+
}
|
|
222
|
+
return definitions.map((definition) => ({ id: String(definition.get('id')) }));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
async getSkillSnapshot(skillDefinitionId: string): Promise<RegistrySkillSnapshot> {
|
|
226
|
+
const definition = await this.database.getRepository('skillDefinitions').findOne({
|
|
227
|
+
filter: {
|
|
228
|
+
id: skillDefinitionId,
|
|
229
|
+
...registryExportFilter,
|
|
230
|
+
},
|
|
231
|
+
});
|
|
232
|
+
if (!definition) {
|
|
233
|
+
// Use one result for missing and ungranted definitions so the internal
|
|
234
|
+
// service cannot be used to enumerate private Skill Hub content.
|
|
235
|
+
throw new RegistryExportNotGrantedError();
|
|
236
|
+
}
|
|
237
|
+
return asPortableSnapshot(definition as unknown as DefinitionModel);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { mkdtempSync, readFileSync, rmSync } from 'fs';
|
|
2
|
+
import { tmpdir } from 'os';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
|
|
5
|
+
import type { Database } from '@nocobase/database';
|
|
6
|
+
|
|
7
|
+
import { SkillRepositoryService } from '../../../services/SkillRepositoryService';
|
|
8
|
+
import { RegistrySkillInstallationService, type RegistryInstallationInput } from '../RegistrySkillInstallationService';
|
|
9
|
+
|
|
10
|
+
function model(values: Record<string, unknown>) {
|
|
11
|
+
return { get: (attribute: string) => values[attribute] };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function installationInput(): RegistryInstallationInput {
|
|
15
|
+
return {
|
|
16
|
+
registryPackageId: 'package-1',
|
|
17
|
+
registryVersionId: 'version-2',
|
|
18
|
+
packageIdentity: 'acme/report',
|
|
19
|
+
version: '2.0.0',
|
|
20
|
+
channel: 'stable',
|
|
21
|
+
artifactDigest: `sha256:${'a'.repeat(64)}`,
|
|
22
|
+
sourceSignature: null,
|
|
23
|
+
updatePolicy: 'pinned',
|
|
24
|
+
runtime: 'python',
|
|
25
|
+
codeTemplate: 'print("new")\n',
|
|
26
|
+
entrypoint: 'src/index.py',
|
|
27
|
+
files: [
|
|
28
|
+
{ path: 'SKILL.md', content: Buffer.from('# Report\n') },
|
|
29
|
+
{ path: 'src/index.py', content: Buffer.from('print("new")\n') },
|
|
30
|
+
],
|
|
31
|
+
instructions: 'Generate a report.',
|
|
32
|
+
inputSchema: { type: 'object', properties: {} },
|
|
33
|
+
dependencies: [],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
describe('RegistrySkillInstallationService', () => {
|
|
38
|
+
let storagePath = '';
|
|
39
|
+
let repository: SkillRepositoryService;
|
|
40
|
+
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
storagePath = mkdtempSync(join(tmpdir(), 'registry-installation-service-'));
|
|
43
|
+
repository = new SkillRepositoryService(storagePath);
|
|
44
|
+
repository.writeSkillPackage('registry-acme-report', [
|
|
45
|
+
{ path: 'SKILL.md', content: Buffer.from('# Report\n') },
|
|
46
|
+
{ path: 'src/index.py', content: Buffer.from('print("old")\n') },
|
|
47
|
+
]);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
afterEach(() => {
|
|
51
|
+
rmSync(storagePath, { recursive: true, force: true });
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('returns only the previous version of an active registry installation as a rollback target', async () => {
|
|
55
|
+
const current = model({
|
|
56
|
+
id: 'installation-2',
|
|
57
|
+
status: 'installed',
|
|
58
|
+
previousInstallationId: 'installation-1',
|
|
59
|
+
});
|
|
60
|
+
const previous = model({
|
|
61
|
+
id: 'installation-1',
|
|
62
|
+
registryVersionId: 'version-1',
|
|
63
|
+
updatePolicy: 'channel',
|
|
64
|
+
});
|
|
65
|
+
const installations = {
|
|
66
|
+
findOne: vi
|
|
67
|
+
.fn()
|
|
68
|
+
.mockImplementation(async ({ filterByTk }: { filterByTk: string }) =>
|
|
69
|
+
filterByTk === 'installation-2' ? current : filterByTk === 'installation-1' ? previous : null,
|
|
70
|
+
),
|
|
71
|
+
};
|
|
72
|
+
const database = {
|
|
73
|
+
getRepository(name: string) {
|
|
74
|
+
if (name !== 'skillRegistryInstallations') {
|
|
75
|
+
throw new Error(`Unexpected repository ${name}`);
|
|
76
|
+
}
|
|
77
|
+
return installations;
|
|
78
|
+
},
|
|
79
|
+
} as unknown as Database;
|
|
80
|
+
const service = new RegistrySkillInstallationService(database, () => repository);
|
|
81
|
+
|
|
82
|
+
await expect(service.getRollbackTarget('installation-2')).resolves.toEqual({
|
|
83
|
+
registryVersionId: 'version-1',
|
|
84
|
+
updatePolicy: 'channel',
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('returns bounded installation state data for registry versions', async () => {
|
|
89
|
+
const installations = {
|
|
90
|
+
find: vi.fn().mockResolvedValue([
|
|
91
|
+
model({
|
|
92
|
+
id: 'installation-2',
|
|
93
|
+
registryPackageId: 'package-1',
|
|
94
|
+
registryVersionId: 'version-2',
|
|
95
|
+
skillDefinitionId: 'skill-1',
|
|
96
|
+
version: '2.0.0',
|
|
97
|
+
updatePolicy: 'channel',
|
|
98
|
+
status: 'installed',
|
|
99
|
+
installedAt: new Date('2026-07-31T00:00:00.000Z'),
|
|
100
|
+
}),
|
|
101
|
+
]),
|
|
102
|
+
};
|
|
103
|
+
const database = { getRepository: () => installations } as unknown as Database;
|
|
104
|
+
const service = new RegistrySkillInstallationService(database, () => repository);
|
|
105
|
+
|
|
106
|
+
await expect(service.getRegistryInstallationStates(['version-2'])).resolves.toEqual([
|
|
107
|
+
expect.objectContaining({
|
|
108
|
+
installationId: 'installation-2',
|
|
109
|
+
registryVersionId: 'version-2',
|
|
110
|
+
updatePolicy: 'channel',
|
|
111
|
+
status: 'installed',
|
|
112
|
+
installedAt: '2026-07-31T00:00:00.000Z',
|
|
113
|
+
}),
|
|
114
|
+
]);
|
|
115
|
+
expect(installations.find).toHaveBeenCalledWith(
|
|
116
|
+
expect.objectContaining({ filter: { registryVersionId: { $in: ['version-2'] } } }),
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('keeps the existing package bytes when an upgrade transaction fails', async () => {
|
|
121
|
+
const previousInstallation = model({ id: 'installation-1', skillDefinitionId: 'skill-1', status: 'installed' });
|
|
122
|
+
const skill = model({ id: 'skill-1', name: 'registry-acme-report', toolName: 'registry_acme_report' });
|
|
123
|
+
const installations = {
|
|
124
|
+
findOne: vi
|
|
125
|
+
.fn()
|
|
126
|
+
.mockImplementation(async ({ filter }: { filter: Record<string, unknown> }) =>
|
|
127
|
+
filter.registryVersionId ? null : previousInstallation,
|
|
128
|
+
),
|
|
129
|
+
create: vi.fn().mockRejectedValue(new Error('database write failed')),
|
|
130
|
+
update: vi.fn().mockResolvedValue(undefined),
|
|
131
|
+
};
|
|
132
|
+
const skillDefinitions = {
|
|
133
|
+
findOne: vi.fn().mockResolvedValue(skill),
|
|
134
|
+
update: vi.fn().mockResolvedValue(undefined),
|
|
135
|
+
};
|
|
136
|
+
const database = {
|
|
137
|
+
getRepository(name: string) {
|
|
138
|
+
return { skillRegistryInstallations: installations, skillDefinitions }[name];
|
|
139
|
+
},
|
|
140
|
+
sequelize: { transaction: async <T>(callback: (transaction: object) => Promise<T>) => callback({}) },
|
|
141
|
+
} as unknown as Database;
|
|
142
|
+
const service = new RegistrySkillInstallationService(database, () => repository);
|
|
143
|
+
|
|
144
|
+
await expect(service.installRegistryVersion(installationInput())).rejects.toThrow('database write failed');
|
|
145
|
+
expect(readFileSync(join(repository.getSkillPath('registry-acme-report'), 'src', 'index.py'), 'utf8')).toContain(
|
|
146
|
+
'old',
|
|
147
|
+
);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('creates distinct local skill names for registry identities that normalize to the same prefix', async () => {
|
|
151
|
+
const createdSkills: Array<{ name: string; toolName: string }> = [];
|
|
152
|
+
let nextInstallationId = 0;
|
|
153
|
+
const installations = {
|
|
154
|
+
findOne: vi.fn().mockResolvedValue(null),
|
|
155
|
+
create: vi.fn().mockImplementation(async () => model({ id: `installation-${++nextInstallationId}` })),
|
|
156
|
+
update: vi.fn().mockResolvedValue(undefined),
|
|
157
|
+
};
|
|
158
|
+
const skillDefinitions = {
|
|
159
|
+
findOne: vi.fn().mockResolvedValue(null),
|
|
160
|
+
create: vi.fn().mockImplementation(async ({ values }: { values: { name: string; toolName: string } }) => {
|
|
161
|
+
createdSkills.push(values);
|
|
162
|
+
return model({
|
|
163
|
+
id: `skill-${createdSkills.length}`,
|
|
164
|
+
name: values.name,
|
|
165
|
+
toolName: values.toolName,
|
|
166
|
+
});
|
|
167
|
+
}),
|
|
168
|
+
update: vi.fn().mockResolvedValue(undefined),
|
|
169
|
+
};
|
|
170
|
+
const database = {
|
|
171
|
+
getRepository(name: string) {
|
|
172
|
+
return { skillRegistryInstallations: installations, skillDefinitions }[name];
|
|
173
|
+
},
|
|
174
|
+
sequelize: { transaction: async <T>(callback: (transaction: object) => Promise<T>) => callback({}) },
|
|
175
|
+
} as unknown as Database;
|
|
176
|
+
const service = new RegistrySkillInstallationService(database, () => repository);
|
|
177
|
+
|
|
178
|
+
const first = await service.installRegistryVersion({
|
|
179
|
+
...installationInput(),
|
|
180
|
+
registryPackageId: 'package-1',
|
|
181
|
+
registryVersionId: 'version-1',
|
|
182
|
+
packageIdentity: 'acme-tools/report',
|
|
183
|
+
});
|
|
184
|
+
const second = await service.installRegistryVersion({
|
|
185
|
+
...installationInput(),
|
|
186
|
+
registryPackageId: 'package-2',
|
|
187
|
+
registryVersionId: 'version-2',
|
|
188
|
+
packageIdentity: 'acme/tools-report',
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
const [firstSkill, secondSkill] = createdSkills;
|
|
192
|
+
expect(firstSkill.name).toMatch(/^registry-acme-tools-report-[a-f0-9]{12}$/);
|
|
193
|
+
expect(secondSkill.name).toMatch(/^registry-acme-tools-report-[a-f0-9]{12}$/);
|
|
194
|
+
expect(firstSkill.name).not.toBe(secondSkill.name);
|
|
195
|
+
expect(first.toolName).not.toBe(second.toolName);
|
|
196
|
+
expect(repository.readSkillPackageFiles(firstSkill.name)).not.toBeNull();
|
|
197
|
+
expect(repository.readSkillPackageFiles(secondSkill.name)).not.toBeNull();
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it('reuses a legacy local skill name when rolling back a registry package', async () => {
|
|
201
|
+
const rollbackInstallation = model({ id: 'installation-1', skillDefinitionId: 'skill-1', status: 'rolled_back' });
|
|
202
|
+
const currentInstallation = model({ id: 'installation-2', skillDefinitionId: 'skill-1', status: 'installed' });
|
|
203
|
+
const skill = model({ id: 'skill-1', name: 'registry-acme-report', toolName: 'registry_acme_report' });
|
|
204
|
+
const installations = {
|
|
205
|
+
findOne: vi
|
|
206
|
+
.fn()
|
|
207
|
+
.mockImplementation(
|
|
208
|
+
async ({ filter, filterByTk }: { filter?: Record<string, unknown>; filterByTk?: string }) => {
|
|
209
|
+
if (filter?.registryVersionId) return rollbackInstallation;
|
|
210
|
+
if (filter?.registryPackageId) return currentInstallation;
|
|
211
|
+
return filterByTk === 'installation-1' ? rollbackInstallation : null;
|
|
212
|
+
},
|
|
213
|
+
),
|
|
214
|
+
create: vi.fn(),
|
|
215
|
+
update: vi.fn().mockResolvedValue(undefined),
|
|
216
|
+
};
|
|
217
|
+
const skillDefinitions = {
|
|
218
|
+
findOne: vi.fn().mockResolvedValue(skill),
|
|
219
|
+
create: vi.fn(),
|
|
220
|
+
update: vi.fn().mockResolvedValue(undefined),
|
|
221
|
+
};
|
|
222
|
+
const database = {
|
|
223
|
+
getRepository(name: string) {
|
|
224
|
+
return { skillRegistryInstallations: installations, skillDefinitions }[name];
|
|
225
|
+
},
|
|
226
|
+
sequelize: { transaction: async <T>(callback: (transaction: object) => Promise<T>) => callback({}) },
|
|
227
|
+
} as unknown as Database;
|
|
228
|
+
const service = new RegistrySkillInstallationService(database, () => repository);
|
|
229
|
+
|
|
230
|
+
await expect(
|
|
231
|
+
service.installRegistryVersion({
|
|
232
|
+
...installationInput(),
|
|
233
|
+
registryVersionId: 'version-1',
|
|
234
|
+
version: '1.0.0',
|
|
235
|
+
}),
|
|
236
|
+
).resolves.toEqual({
|
|
237
|
+
installationId: 'installation-1',
|
|
238
|
+
skillDefinitionId: 'skill-1',
|
|
239
|
+
toolName: 'registry_acme_report',
|
|
240
|
+
status: 'installed',
|
|
241
|
+
});
|
|
242
|
+
expect(skillDefinitions.create).not.toHaveBeenCalled();
|
|
243
|
+
expect(skillDefinitions.update).toHaveBeenCalledWith(
|
|
244
|
+
expect.objectContaining({
|
|
245
|
+
filterByTk: 'skill-1',
|
|
246
|
+
values: expect.objectContaining({ storageUrl: 'local://registry/registry-acme-report' }),
|
|
247
|
+
}),
|
|
248
|
+
);
|
|
249
|
+
expect(readFileSync(join(repository.getSkillPath('registry-acme-report'), 'src', 'index.py'), 'utf8')).toContain(
|
|
250
|
+
'new',
|
|
251
|
+
);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it('updates the existing local projection without changing its tool identity', async () => {
|
|
255
|
+
const previousInstallation = model({ id: 'installation-1', skillDefinitionId: 'skill-1', status: 'installed' });
|
|
256
|
+
const newInstallation = model({ id: 'installation-2' });
|
|
257
|
+
const skill = model({ id: 'skill-1', name: 'registry-acme-report', toolName: 'registry_acme_report' });
|
|
258
|
+
const installations = {
|
|
259
|
+
findOne: vi
|
|
260
|
+
.fn()
|
|
261
|
+
.mockImplementation(async ({ filter }: { filter: Record<string, unknown> }) =>
|
|
262
|
+
filter.registryVersionId ? null : previousInstallation,
|
|
263
|
+
),
|
|
264
|
+
create: vi.fn().mockResolvedValue(newInstallation),
|
|
265
|
+
update: vi.fn().mockResolvedValue(undefined),
|
|
266
|
+
};
|
|
267
|
+
const skillDefinitions = {
|
|
268
|
+
findOne: vi.fn().mockResolvedValue(skill),
|
|
269
|
+
update: vi.fn().mockResolvedValue(undefined),
|
|
270
|
+
};
|
|
271
|
+
const database = {
|
|
272
|
+
getRepository(name: string) {
|
|
273
|
+
return { skillRegistryInstallations: installations, skillDefinitions }[name];
|
|
274
|
+
},
|
|
275
|
+
sequelize: { transaction: async <T>(callback: (transaction: object) => Promise<T>) => callback({}) },
|
|
276
|
+
} as unknown as Database;
|
|
277
|
+
const service = new RegistrySkillInstallationService(database, () => repository);
|
|
278
|
+
|
|
279
|
+
await expect(service.installRegistryVersion(installationInput())).resolves.toEqual({
|
|
280
|
+
installationId: 'installation-2',
|
|
281
|
+
skillDefinitionId: 'skill-1',
|
|
282
|
+
toolName: 'registry_acme_report',
|
|
283
|
+
status: 'installed',
|
|
284
|
+
});
|
|
285
|
+
expect(skillDefinitions.update).toHaveBeenCalledWith(
|
|
286
|
+
expect.objectContaining({
|
|
287
|
+
filterByTk: 'skill-1',
|
|
288
|
+
values: expect.objectContaining({ enabled: false, registryVersionId: 'version-2' }),
|
|
289
|
+
}),
|
|
290
|
+
);
|
|
291
|
+
expect(readFileSync(join(repository.getSkillPath('registry-acme-report'), 'src', 'index.py'), 'utf8')).toContain(
|
|
292
|
+
'new',
|
|
293
|
+
);
|
|
294
|
+
});
|
|
295
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Database } from '@nocobase/database';
|
|
2
|
+
|
|
3
|
+
import { RegistrySkillSnapshotService } from '../RegistrySkillSnapshotService';
|
|
4
|
+
|
|
5
|
+
describe('RegistrySkillSnapshotService', () => {
|
|
6
|
+
it('does not expose registry-installed local projections as Skill Hub sources', async () => {
|
|
7
|
+
const find = vi.fn().mockResolvedValue([{ get: () => 42 }]);
|
|
8
|
+
const database = {
|
|
9
|
+
getRepository: vi.fn().mockReturnValue({ find }),
|
|
10
|
+
} as unknown as Database;
|
|
11
|
+
const service = new RegistrySkillSnapshotService(database);
|
|
12
|
+
|
|
13
|
+
await expect(service.listSkillSnapshots()).resolves.toEqual([{ id: '42' }]);
|
|
14
|
+
expect(find).toHaveBeenCalledWith({
|
|
15
|
+
fields: ['id'],
|
|
16
|
+
filter: {
|
|
17
|
+
registryPackageId: null,
|
|
18
|
+
registryVersionId: null,
|
|
19
|
+
registryInstallationId: null,
|
|
20
|
+
registryInstallStatus: null,
|
|
21
|
+
registryExportEnabled: true,
|
|
22
|
+
},
|
|
23
|
+
sort: ['id'],
|
|
24
|
+
limit: 1001,
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('does not return a snapshot without a provider-owned export grant', async () => {
|
|
29
|
+
const findOne = vi.fn().mockResolvedValue(null);
|
|
30
|
+
const database = {
|
|
31
|
+
getRepository: vi.fn().mockReturnValue({ findOne }),
|
|
32
|
+
} as unknown as Database;
|
|
33
|
+
const service = new RegistrySkillSnapshotService(database);
|
|
34
|
+
|
|
35
|
+
await expect(service.getSkillSnapshot('42')).rejects.toMatchObject({
|
|
36
|
+
code: 'REGISTRY_EXPORT_NOT_GRANTED',
|
|
37
|
+
});
|
|
38
|
+
expect(findOne).toHaveBeenCalledWith({
|
|
39
|
+
filter: {
|
|
40
|
+
id: '42',
|
|
41
|
+
registryPackageId: null,
|
|
42
|
+
registryVersionId: null,
|
|
43
|
+
registryInstallationId: null,
|
|
44
|
+
registryInstallStatus: null,
|
|
45
|
+
registryExportEnabled: true,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('bounds provider discovery before returning an unbounded definition list', async () => {
|
|
51
|
+
const find = vi
|
|
52
|
+
.fn()
|
|
53
|
+
.mockResolvedValue(Array.from({ length: 1001 }, (_, id) => ({ get: () => id + 1 })));
|
|
54
|
+
const database = {
|
|
55
|
+
getRepository: vi.fn().mockReturnValue({ find }),
|
|
56
|
+
} as unknown as Database;
|
|
57
|
+
const service = new RegistrySkillSnapshotService(database);
|
|
58
|
+
|
|
59
|
+
await expect(service.listSkillSnapshots()).rejects.toThrow(
|
|
60
|
+
'Skill Hub registry export exceeds the configured source-item limit.',
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -5,6 +5,8 @@ import { SandboxRunner } from '../../services/SandboxRunner';
|
|
|
5
5
|
import { FileManager } from '../../services/FileManager';
|
|
6
6
|
import { SkillRepositoryService } from '../../services/SkillRepositoryService';
|
|
7
7
|
import { CodeValidator } from '../../services/CodeValidator';
|
|
8
|
+
import { createHash } from 'crypto';
|
|
9
|
+
import { assertSkillToolNameAvailable, buildSkillToolName } from '../../utils/skill-tool-name';
|
|
8
10
|
import { parseJsonText, stringifyJsonText } from '../utils/json-fields';
|
|
9
11
|
|
|
10
12
|
/**
|
|
@@ -168,7 +170,8 @@ export class SkillExecutionTask {
|
|
|
168
170
|
}
|
|
169
171
|
|
|
170
172
|
const code = this.renderTemplate(rawCodeTemplate, inputArgs, execId, skillDir);
|
|
171
|
-
|
|
173
|
+
const skillDigest = createHash('sha256').update(code, 'utf8').digest('hex');
|
|
174
|
+
if (!(await this.updateIfOwned(execId, workerId, { executedCode: code, skillDigest }))) {
|
|
172
175
|
abortController.abort();
|
|
173
176
|
return;
|
|
174
177
|
}
|
|
@@ -253,6 +256,7 @@ export class SkillExecutionTask {
|
|
|
253
256
|
timeoutSeconds: timeoutSeconds || 60,
|
|
254
257
|
maxOutputSizeMb: maxOutputSizeMb || 50,
|
|
255
258
|
skillDir,
|
|
259
|
+
inputArgs,
|
|
256
260
|
signal: abortController.signal,
|
|
257
261
|
packageWhitelist,
|
|
258
262
|
onProgress: (progress) => {
|
|
@@ -367,6 +371,10 @@ export class SkillExecutionTask {
|
|
|
367
371
|
// Inject outputDir so code templates can use {{outputDir}}
|
|
368
372
|
code = code.replaceAll('{{outputDir}}', this.fileManager.getOutputDir(execId).replace(/\\/g, '/'));
|
|
369
373
|
code = code.replaceAll('{{skillDir}}', (skillDir || '').replace(/\\/g, '/'));
|
|
374
|
+
code = code.replaceAll(
|
|
375
|
+
'{{inputFile}}',
|
|
376
|
+
resolve(this.fileManager.getExecDir(execId), 'input.json').replace(/\\/g, '/'),
|
|
377
|
+
);
|
|
370
378
|
return code;
|
|
371
379
|
}
|
|
372
380
|
|
|
@@ -422,6 +430,7 @@ export class SkillExecutionTask {
|
|
|
422
430
|
timeoutSeconds: Math.min(Number(skill.timeoutSeconds || 60), 30),
|
|
423
431
|
maxOutputSizeMb: Math.min(Number(skill.maxOutputSizeMb || 50), 10),
|
|
424
432
|
skillDir: packageDir,
|
|
433
|
+
inputArgs: manifest.testInput,
|
|
425
434
|
});
|
|
426
435
|
|
|
427
436
|
if (!verifyResult.success) {
|
|
@@ -448,6 +457,7 @@ export class SkillExecutionTask {
|
|
|
448
457
|
|
|
449
458
|
const values: any = {
|
|
450
459
|
name,
|
|
460
|
+
toolName: buildSkillToolName(name),
|
|
451
461
|
title: skill.title || name,
|
|
452
462
|
description: skill.description || '',
|
|
453
463
|
instructions: skill.instructions || '',
|
|
@@ -474,10 +484,12 @@ export class SkillExecutionTask {
|
|
|
474
484
|
if (manifest.overwrite === false) {
|
|
475
485
|
throw new Error(`Skill "${name}" already exists and overwrite=false.`);
|
|
476
486
|
}
|
|
477
|
-
|
|
487
|
+
const { toolName: _stableToolName, ...updateValues } = values;
|
|
488
|
+
await repo.update({ filter: { name }, values: updateValues });
|
|
478
489
|
return `[skill-hub] Updated generated skill "${name}" in Skill Hub.`;
|
|
479
490
|
}
|
|
480
491
|
|
|
492
|
+
await assertSkillToolNameAvailable((this as any).app.db, values.toolName);
|
|
481
493
|
await repo.create({ values });
|
|
482
494
|
return `[skill-hub] Installed generated skill "${name}" in Skill Hub.`;
|
|
483
495
|
}
|