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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { parseJsonText } from '../skill-hub/utils/json-fields';
|
|
2
2
|
import type { ToolsRuntime } from '@nocobase/ai';
|
|
3
|
+
import { getSkillToolName } from '../utils/skill-tool-name';
|
|
3
4
|
|
|
4
5
|
type ToolRuntimeInput = string | ToolsRuntime | undefined;
|
|
5
6
|
|
|
@@ -68,11 +69,23 @@ IMPORTANT: If the skill returns file download URLs, you MUST format them as clic
|
|
|
68
69
|
if (args.action === 'list') {
|
|
69
70
|
const skills = await plugin.db.getRepository('skillDefinitions').find({
|
|
70
71
|
filter: { enabled: true },
|
|
71
|
-
fields: [
|
|
72
|
+
fields: [
|
|
73
|
+
'name',
|
|
74
|
+
'toolName',
|
|
75
|
+
'title',
|
|
76
|
+
'description',
|
|
77
|
+
'language',
|
|
78
|
+
'inputSchema',
|
|
79
|
+
'instructions',
|
|
80
|
+
'storageType',
|
|
81
|
+
'toolScope',
|
|
82
|
+
],
|
|
72
83
|
});
|
|
73
84
|
|
|
74
|
-
const
|
|
85
|
+
const accessibleSkills = await plugin.skillAccessService.filterAccessibleSkills(ctx, skills);
|
|
86
|
+
const skillList = accessibleSkills.map((s: any) => ({
|
|
75
87
|
name: s.get('name'),
|
|
88
|
+
toolName: getSkillToolName(s),
|
|
76
89
|
title: s.get('title'),
|
|
77
90
|
description: s.get('description'),
|
|
78
91
|
language: s.get('language'),
|
|
@@ -104,6 +117,14 @@ IMPORTANT: If the skill returns file download URLs, you MUST format them as clic
|
|
|
104
117
|
};
|
|
105
118
|
}
|
|
106
119
|
|
|
120
|
+
const accessible = await plugin.skillAccessService.filterAccessibleSkills(ctx, [skill]);
|
|
121
|
+
if (accessible.length === 0) {
|
|
122
|
+
return {
|
|
123
|
+
status: 'error',
|
|
124
|
+
content: `Skill "${args.skillName}" is not available to this AI employee`,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
107
128
|
const instructions =
|
|
108
129
|
typeof plugin.getSkillInstructions === 'function'
|
|
109
130
|
? await plugin.getSkillInstructions(skill)
|
|
@@ -113,6 +134,7 @@ IMPORTANT: If the skill returns file download URLs, you MUST format them as clic
|
|
|
113
134
|
status: 'success',
|
|
114
135
|
content: JSON.stringify({
|
|
115
136
|
name: skill.get('name'),
|
|
137
|
+
toolName: getSkillToolName(skill),
|
|
116
138
|
title: skill.get('title'),
|
|
117
139
|
description: skill.get('description'),
|
|
118
140
|
language: skill.get('language'),
|
|
@@ -50,7 +50,7 @@ export function currentUserId(ctx: any) {
|
|
|
50
50
|
* scoping and file access stay consistent.
|
|
51
51
|
*/
|
|
52
52
|
export function isAdminUser(ctx: any): boolean {
|
|
53
|
-
const roles = ctx?.state?.currentUser?.roles || ctx?.auth?.user?.roles;
|
|
53
|
+
const roles = ctx?.state?.currentUser?.roles || ctx?.auth?.user?.roles || ctx?.state?.currentRoles;
|
|
54
54
|
if (!Array.isArray(roles)) return false;
|
|
55
55
|
return roles.some((r: any) => {
|
|
56
56
|
const name = typeof r === 'string' ? r : r?.name;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
type RecordLike = Record<string, unknown> & {
|
|
2
|
+
get?: (name: string) => unknown;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export type SkillToolScope = 'CUSTOM' | 'GENERAL' | 'SPECIFIED';
|
|
6
|
+
|
|
7
|
+
export function readRecordValue(record: unknown, key: string): unknown {
|
|
8
|
+
const value = record as RecordLike | null | undefined;
|
|
9
|
+
return typeof value?.get === 'function' ? value.get(key) : value?.[key];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Preserve the legacy Skill Hub tool-name algorithm so existing AI employee
|
|
14
|
+
* bindings continue to resolve after toolName becomes a persisted identity.
|
|
15
|
+
*/
|
|
16
|
+
export function buildSkillToolName(skillName: string): string {
|
|
17
|
+
const normalized = String(skillName || '')
|
|
18
|
+
.trim()
|
|
19
|
+
.toLowerCase()
|
|
20
|
+
.replace(/[^a-z0-9_]/g, '_')
|
|
21
|
+
.replace(/_+/g, '_')
|
|
22
|
+
.replace(/^_|_$/g, '');
|
|
23
|
+
|
|
24
|
+
if (!normalized) {
|
|
25
|
+
throw new Error('Skill name must contain at least one ASCII letter or number.');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return `skill_hub_${normalized}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function getSkillToolName(skill: unknown): string {
|
|
32
|
+
const persisted = readRecordValue(skill, 'toolName');
|
|
33
|
+
if (typeof persisted === 'string' && persisted.trim()) {
|
|
34
|
+
return persisted.trim();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return buildSkillToolName(String(readRecordValue(skill, 'name') || ''));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function normalizeSkillToolScope(value: unknown): SkillToolScope {
|
|
41
|
+
return value === 'GENERAL' || value === 'SPECIFIED' || value === 'CUSTOM' ? value : 'CUSTOM';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function assertSkillToolNameAvailable(
|
|
45
|
+
db: { getRepository: (name: string) => { findOne: (options: Record<string, unknown>) => Promise<unknown> } },
|
|
46
|
+
toolName: string,
|
|
47
|
+
excludeId?: string | number,
|
|
48
|
+
): Promise<void> {
|
|
49
|
+
const existing = await db.getRepository('skillDefinitions').findOne({
|
|
50
|
+
filter: { toolName },
|
|
51
|
+
});
|
|
52
|
+
if (!existing) return;
|
|
53
|
+
|
|
54
|
+
const existingId = readRecordValue(existing, 'id');
|
|
55
|
+
if (excludeId != null && String(existingId) === String(excludeId)) return;
|
|
56
|
+
|
|
57
|
+
throw new Error(`Skill tool name "${toolName}" is already registered.`);
|
|
58
|
+
}
|