plugin-agent-orchestrator 1.1.0 → 1.1.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/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 +501 -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,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var skill_registry_installations_exports = {};
|
|
28
|
+
__export(skill_registry_installations_exports, {
|
|
29
|
+
default: () => skill_registry_installations_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(skill_registry_installations_exports);
|
|
32
|
+
var skill_registry_installations_default = {
|
|
33
|
+
name: "skillRegistryInstallations",
|
|
34
|
+
title: "Skill Registry Installations",
|
|
35
|
+
fields: [
|
|
36
|
+
{ name: "id", type: "bigInt", autoIncrement: true, primaryKey: true },
|
|
37
|
+
{ name: "registryPackageId", type: "bigInt", allowNull: false },
|
|
38
|
+
{ name: "registryVersionId", type: "bigInt", allowNull: false, unique: true },
|
|
39
|
+
{ name: "packageIdentity", type: "string", length: 220, allowNull: false },
|
|
40
|
+
{ name: "version", type: "string", length: 64, allowNull: false },
|
|
41
|
+
{ name: "channel", type: "string", length: 20, defaultValue: "stable" },
|
|
42
|
+
{ name: "artifactDigest", type: "string", length: 71, allowNull: false },
|
|
43
|
+
{ name: "sourceSignature", type: "text", allowNull: true },
|
|
44
|
+
{ name: "updatePolicy", type: "string", length: 20, defaultValue: "pinned" },
|
|
45
|
+
{ name: "status", type: "string", length: 24, defaultValue: "verifying" },
|
|
46
|
+
{
|
|
47
|
+
name: "skillDefinition",
|
|
48
|
+
type: "belongsTo",
|
|
49
|
+
target: "skillDefinitions",
|
|
50
|
+
foreignKey: "skillDefinitionId",
|
|
51
|
+
onDelete: "RESTRICT"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "previousInstallation",
|
|
55
|
+
type: "belongsTo",
|
|
56
|
+
target: "skillRegistryInstallations",
|
|
57
|
+
foreignKey: "previousInstallationId",
|
|
58
|
+
onDelete: "SET NULL"
|
|
59
|
+
},
|
|
60
|
+
{ name: "lastError", type: "text", allowNull: true },
|
|
61
|
+
{ name: "installedAt", type: "date", allowNull: true },
|
|
62
|
+
{ name: "installedBy", type: "belongsTo", target: "users", foreignKey: "installedById" },
|
|
63
|
+
{ name: "createdAt", type: "date" },
|
|
64
|
+
{ name: "updatedAt", type: "date" }
|
|
65
|
+
],
|
|
66
|
+
indexes: [
|
|
67
|
+
{ name: "skill_registry_installations_package_status", fields: ["registryPackageId", "status"] },
|
|
68
|
+
{ name: "skill_registry_installations_skill_definition", fields: ["skillDefinitionId"] }
|
|
69
|
+
]
|
|
70
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var backfill_skill_tool_names_exports = {};
|
|
28
|
+
__export(backfill_skill_tool_names_exports, {
|
|
29
|
+
default: () => BackfillSkillToolNames
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(backfill_skill_tool_names_exports);
|
|
32
|
+
var import_server = require("@nocobase/server");
|
|
33
|
+
var import_skill_tool_name = require("../utils/skill-tool-name");
|
|
34
|
+
class BackfillSkillToolNames extends import_server.Migration {
|
|
35
|
+
on = "afterLoad";
|
|
36
|
+
appVersion = ">=0.1.0";
|
|
37
|
+
async up() {
|
|
38
|
+
const repo = this.db.getRepository("skillDefinitions");
|
|
39
|
+
if (!repo) return;
|
|
40
|
+
const skills = await repo.find({ sort: ["id"] });
|
|
41
|
+
const used = /* @__PURE__ */ new Set();
|
|
42
|
+
for (const skill of skills) {
|
|
43
|
+
const current = (0, import_skill_tool_name.readRecordValue)(skill, "toolName");
|
|
44
|
+
if (typeof current === "string" && current.trim()) {
|
|
45
|
+
used.add(current.trim());
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
for (const skill of skills) {
|
|
49
|
+
const current = (0, import_skill_tool_name.readRecordValue)(skill, "toolName");
|
|
50
|
+
if (typeof current === "string" && current.trim()) continue;
|
|
51
|
+
const id = (0, import_skill_tool_name.readRecordValue)(skill, "id");
|
|
52
|
+
const baseName = (0, import_skill_tool_name.buildSkillToolName)(String((0, import_skill_tool_name.readRecordValue)(skill, "name") || ""));
|
|
53
|
+
let toolName = baseName;
|
|
54
|
+
if (used.has(toolName)) {
|
|
55
|
+
toolName = `${baseName}_${id}`;
|
|
56
|
+
}
|
|
57
|
+
await repo.update({
|
|
58
|
+
filterByTk: id,
|
|
59
|
+
values: { toolName }
|
|
60
|
+
});
|
|
61
|
+
used.add(toolName);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async down() {
|
|
65
|
+
}
|
|
66
|
+
}
|
package/dist/server/plugin.js
CHANGED
|
@@ -49,12 +49,16 @@ var import_agent_loop = require("./resources/agent-loop");
|
|
|
49
49
|
var import_agent_knowledge_insights = require("./resources/agent-knowledge-insights");
|
|
50
50
|
var import_plugin = __toESM(require("./skill-hub/plugin"));
|
|
51
51
|
var import_NativeSubAgentObserver = require("./services/NativeSubAgentObserver");
|
|
52
|
+
var import_RegistrySkillSnapshotService = require("./skill-hub/services/RegistrySkillSnapshotService");
|
|
53
|
+
var import_RegistrySkillInstallationService = require("./skill-hub/services/RegistrySkillInstallationService");
|
|
52
54
|
var import_AgentLoopService = require("./services/AgentLoopService");
|
|
53
55
|
var import_agent_loop2 = require("./tools/agent-loop");
|
|
54
56
|
var import_PlanningPromptService = require("./services/PlanningPromptService");
|
|
55
57
|
var import_ctx_utils = require("./utils/ctx-utils");
|
|
56
58
|
var import_ai_manager = require("./utils/ai-manager");
|
|
57
59
|
var import_AgentRuntimeLifecycle = require("./services/AgentRuntimeLifecycle");
|
|
60
|
+
var import_InputSchemaValidator = require("./services/InputSchemaValidator");
|
|
61
|
+
var import_skill_tool_name = require("./utils/skill-tool-name");
|
|
58
62
|
function normalizeOptionalString(value) {
|
|
59
63
|
return typeof value === "string" ? value.trim() : "";
|
|
60
64
|
}
|
|
@@ -62,6 +66,30 @@ function readModelValue(record, key) {
|
|
|
62
66
|
const model = record;
|
|
63
67
|
return typeof (model == null ? void 0 : model.get) === "function" ? model.get(key) : model == null ? void 0 : model[key];
|
|
64
68
|
}
|
|
69
|
+
const PRIVATE_SKILL_FIELDS = ["codeTemplate", "instructions", "storageUrl", "packages", "fileId"];
|
|
70
|
+
function redactSkillRecord(record) {
|
|
71
|
+
var _a;
|
|
72
|
+
if (!record || typeof record !== "object") return record;
|
|
73
|
+
const source = ((_a = record.toJSON) == null ? void 0 : _a.call(record)) || record;
|
|
74
|
+
const result = { ...source };
|
|
75
|
+
for (const field of PRIVATE_SKILL_FIELDS) {
|
|
76
|
+
delete result[field];
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
function redactSkillResponse(body) {
|
|
81
|
+
if (Array.isArray(body)) return body.map(redactSkillRecord);
|
|
82
|
+
if (!body || typeof body !== "object") return body;
|
|
83
|
+
const value = body;
|
|
84
|
+
if (Array.isArray(value.rows)) return { ...value, rows: value.rows.map(redactSkillRecord) };
|
|
85
|
+
if (Object.prototype.hasOwnProperty.call(value, "data")) {
|
|
86
|
+
return {
|
|
87
|
+
...value,
|
|
88
|
+
data: Array.isArray(value.data) ? value.data.map(redactSkillRecord) : redactSkillRecord(value.data)
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return redactSkillRecord(value);
|
|
92
|
+
}
|
|
65
93
|
function buildAgentMemoryContextKey(values) {
|
|
66
94
|
const userPart = values.scope === "public" ? "public" : String(values.userId || "");
|
|
67
95
|
const agentPart = values.aiEmployeeUsername || "*";
|
|
@@ -153,6 +181,8 @@ async function resolveTracingRetentionDays(plugin) {
|
|
|
153
181
|
}
|
|
154
182
|
class PluginAgentOrchestratorServer extends import_server.Plugin {
|
|
155
183
|
skillHub;
|
|
184
|
+
registrySkillSnapshotService;
|
|
185
|
+
registrySkillInstallationService;
|
|
156
186
|
nativeObserver;
|
|
157
187
|
agentRuntimeLifecycle;
|
|
158
188
|
installNativeObserver = () => {
|
|
@@ -161,6 +191,11 @@ class PluginAgentOrchestratorServer extends import_server.Plugin {
|
|
|
161
191
|
};
|
|
162
192
|
async afterAdd() {
|
|
163
193
|
this.skillHub = new import_plugin.default(this);
|
|
194
|
+
this.registrySkillSnapshotService = new import_RegistrySkillSnapshotService.RegistrySkillSnapshotService(this.db);
|
|
195
|
+
this.registrySkillInstallationService = new import_RegistrySkillInstallationService.RegistrySkillInstallationService(
|
|
196
|
+
this.db,
|
|
197
|
+
() => this.skillHub.getSkillRepositoryService()
|
|
198
|
+
);
|
|
164
199
|
this.nativeObserver = new import_NativeSubAgentObserver.NativeSubAgentObserver(this);
|
|
165
200
|
this.agentRuntimeLifecycle = new import_AgentRuntimeLifecycle.AgentRuntimeLifecycle((hookType, name, error) => {
|
|
166
201
|
this.app.logger.warn(`[AgentOrchestrator] ${hookType} hook "${name}" failed; continuing agent execution.`, {
|
|
@@ -206,7 +241,6 @@ class PluginAgentOrchestratorServer extends import_server.Plugin {
|
|
|
206
241
|
this.app.acl.allow("skillLoopConfigs", "get", "loggedIn");
|
|
207
242
|
this.app.acl.allow("skillExecutions", "list", "loggedIn");
|
|
208
243
|
this.app.acl.allow("skillExecutions", "get", "loggedIn");
|
|
209
|
-
this.app.acl.allow("skillHub", "test", "loggedIn");
|
|
210
244
|
this.app.acl.allow("skillHub", "download", "loggedIn");
|
|
211
245
|
this.app.acl.allow("skillHub", "listTemplates", "loggedIn");
|
|
212
246
|
this.app.acl.allow("agentMonitor", ["list", "get"], "loggedIn");
|
|
@@ -225,6 +259,67 @@ class PluginAgentOrchestratorServer extends import_server.Plugin {
|
|
|
225
259
|
},
|
|
226
260
|
{ tag: "orchestrator-skill-executions-scope", after: "acl" }
|
|
227
261
|
);
|
|
262
|
+
this.app.resourceManager.use(
|
|
263
|
+
async (ctx, next) => {
|
|
264
|
+
var _a2, _b2, _c2, _d2, _e, _f;
|
|
265
|
+
const { resourceName, actionName } = ctx.action || {};
|
|
266
|
+
if (resourceName !== "skillDefinitions") {
|
|
267
|
+
await next();
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
const values = ((_b2 = (_a2 = ctx.action) == null ? void 0 : _a2.params) == null ? void 0 : _b2.values) || {};
|
|
271
|
+
if (actionName === "create" || actionName === "update") {
|
|
272
|
+
try {
|
|
273
|
+
if (Object.prototype.hasOwnProperty.call(values, "inputSchema")) {
|
|
274
|
+
(0, import_InputSchemaValidator.validateInputSchemaDefinition)(values.inputSchema);
|
|
275
|
+
}
|
|
276
|
+
if (actionName === "create") {
|
|
277
|
+
const toolName = (0, import_skill_tool_name.buildSkillToolName)(values.name);
|
|
278
|
+
await (0, import_skill_tool_name.assertSkillToolNameAvailable)(ctx.db, toolName);
|
|
279
|
+
values.toolName = toolName;
|
|
280
|
+
} else {
|
|
281
|
+
const existing = await ctx.db.getRepository("skillDefinitions").findOne({
|
|
282
|
+
filterByTk: (_d2 = (_c2 = ctx.action) == null ? void 0 : _c2.params) == null ? void 0 : _d2.filterByTk
|
|
283
|
+
});
|
|
284
|
+
if (existing) {
|
|
285
|
+
const stableToolName = (0, import_skill_tool_name.getSkillToolName)(existing);
|
|
286
|
+
if (values.toolName && values.toolName !== stableToolName) {
|
|
287
|
+
ctx.throw(400, "toolName is immutable after a skill is created.");
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
values.toolName = stableToolName;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
} catch (error) {
|
|
294
|
+
ctx.throw(400, error instanceof Error ? error.message : String(error));
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if (actionName === "destroy") {
|
|
299
|
+
const existing = await ctx.db.getRepository("skillDefinitions").findOne({
|
|
300
|
+
filterByTk: (_f = (_e = ctx.action) == null ? void 0 : _e.params) == null ? void 0 : _f.filterByTk
|
|
301
|
+
});
|
|
302
|
+
if (existing) {
|
|
303
|
+
const toolName = (0, import_skill_tool_name.getSkillToolName)(existing);
|
|
304
|
+
const agentUsernames = await this.skillHub.skillAccessService.findAgentUsernamesUsingTool(toolName);
|
|
305
|
+
if (agentUsernames.length > 0) {
|
|
306
|
+
ctx.throw(
|
|
307
|
+
409,
|
|
308
|
+
`Skill tool "${toolName}" is still bound to AI employees: ${agentUsernames.join(
|
|
309
|
+
", "
|
|
310
|
+
)}. Disable or unbind it before deletion.`
|
|
311
|
+
);
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
await next();
|
|
317
|
+
if ((actionName === "list" || actionName === "get") && !(0, import_ctx_utils.isAdminUser)(ctx)) {
|
|
318
|
+
ctx.body = redactSkillResponse(ctx.body);
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
{ tag: "orchestrator-skill-definition-policy", after: "acl" }
|
|
322
|
+
);
|
|
228
323
|
this.app.resourceManager.use(
|
|
229
324
|
async (ctx, next) => {
|
|
230
325
|
const { resourceName, actionName } = ctx.action || {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var AgentExecutionContext_exports = {};
|
|
28
|
+
__export(AgentExecutionContext_exports, {
|
|
29
|
+
getAgentExecutionContext: () => getAgentExecutionContext,
|
|
30
|
+
runWithAgentExecutionContext: () => runWithAgentExecutionContext
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(AgentExecutionContext_exports);
|
|
33
|
+
var import_async_hooks = require("async_hooks");
|
|
34
|
+
const storage = new import_async_hooks.AsyncLocalStorage();
|
|
35
|
+
function runWithAgentExecutionContext(identity, callback) {
|
|
36
|
+
return storage.run(identity, callback);
|
|
37
|
+
}
|
|
38
|
+
function getAgentExecutionContext() {
|
|
39
|
+
return storage.getStore();
|
|
40
|
+
}
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
getAgentExecutionContext,
|
|
44
|
+
runWithAgentExecutionContext
|
|
45
|
+
});
|
|
@@ -33,6 +33,7 @@ __export(ExecutionSpanService_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(ExecutionSpanService_exports);
|
|
35
35
|
var import_ctx_utils = require("../utils/ctx-utils");
|
|
36
|
+
var import_AgentExecutionContext = require("./AgentExecutionContext");
|
|
36
37
|
const ORCHESTRATOR_TRACE_CONTEXT_KEY = "__orchestratorTraceContext";
|
|
37
38
|
class ExecutionSpanService {
|
|
38
39
|
constructor(plugin) {
|
|
@@ -85,8 +86,15 @@ class ExecutionSpanService {
|
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
function getOrchestratorTraceContext(ctx) {
|
|
88
|
-
var _a, _b, _c;
|
|
89
|
-
|
|
89
|
+
var _a, _b, _c, _d;
|
|
90
|
+
const requestContext = (ctx == null ? void 0 : ctx[ORCHESTRATOR_TRACE_CONTEXT_KEY]) || ((_a = ctx == null ? void 0 : ctx.state) == null ? void 0 : _a.orchestratorTraceContext) || ((_c = (_b = ctx == null ? void 0 : ctx.runtime) == null ? void 0 : _b.context) == null ? void 0 : _c.orchestratorTraceContext) || null;
|
|
91
|
+
const agentContext = (0, import_AgentExecutionContext.getAgentExecutionContext)();
|
|
92
|
+
if (!requestContext && !agentContext) return null;
|
|
93
|
+
return {
|
|
94
|
+
...agentContext || {},
|
|
95
|
+
...requestContext || {},
|
|
96
|
+
toolCallId: ((_d = ctx == null ? void 0 : ctx.runtime) == null ? void 0 : _d.toolCallId) || (requestContext == null ? void 0 : requestContext.toolCallId) || (agentContext == null ? void 0 : agentContext.toolCallId)
|
|
97
|
+
};
|
|
90
98
|
}
|
|
91
99
|
function setOrchestratorTraceContext(ctx, traceContext) {
|
|
92
100
|
ctx[ORCHESTRATOR_TRACE_CONTEXT_KEY] = traceContext;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var InputSchemaValidator_exports = {};
|
|
38
|
+
__export(InputSchemaValidator_exports, {
|
|
39
|
+
validateInputSchemaDefinition: () => validateInputSchemaDefinition,
|
|
40
|
+
validateSkillInput: () => validateSkillInput
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(InputSchemaValidator_exports);
|
|
43
|
+
var import_ajv = __toESM(require("ajv"));
|
|
44
|
+
var import_json_fields = require("../skill-hub/utils/json-fields");
|
|
45
|
+
const ajv = new import_ajv.default({
|
|
46
|
+
allErrors: true,
|
|
47
|
+
jsonPointers: true
|
|
48
|
+
});
|
|
49
|
+
function parseSchema(value) {
|
|
50
|
+
if (value === void 0 || value === null || value === "") return null;
|
|
51
|
+
const schema = (0, import_json_fields.parseJsonText)(value, void 0);
|
|
52
|
+
if (typeof schema === "boolean") return schema;
|
|
53
|
+
if (schema && typeof schema === "object" && !Array.isArray(schema)) {
|
|
54
|
+
return schema;
|
|
55
|
+
}
|
|
56
|
+
throw new Error("Input Schema must be a valid JSON Schema object.");
|
|
57
|
+
}
|
|
58
|
+
function validateInputSchemaDefinition(value) {
|
|
59
|
+
const schema = parseSchema(value);
|
|
60
|
+
if (schema === null) return;
|
|
61
|
+
try {
|
|
62
|
+
ajv.compile(schema);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
throw new Error(`Invalid Input Schema: ${error instanceof Error ? error.message : String(error)}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function validateSkillInput(schemaValue, input) {
|
|
68
|
+
const schema = parseSchema(schemaValue);
|
|
69
|
+
if (schema === null) return;
|
|
70
|
+
let validate;
|
|
71
|
+
try {
|
|
72
|
+
validate = ajv.compile(schema);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
throw new Error(`Invalid Input Schema: ${error instanceof Error ? error.message : String(error)}`);
|
|
75
|
+
}
|
|
76
|
+
if (validate(input)) return;
|
|
77
|
+
throw new Error(`Skill input validation failed: ${ajv.errorsText(validate.errors, { separator: "; " })}`);
|
|
78
|
+
}
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
validateInputSchemaDefinition,
|
|
82
|
+
validateSkillInput
|
|
83
|
+
});
|
|
@@ -35,6 +35,7 @@ var import_crypto = require("crypto");
|
|
|
35
35
|
var import_ExecutionSpanService = require("./ExecutionSpanService");
|
|
36
36
|
var import_AgentMemoryContextService = require("./AgentMemoryContextService");
|
|
37
37
|
var import_TokenTracker = require("./TokenTracker");
|
|
38
|
+
var import_AgentExecutionContext = require("./AgentExecutionContext");
|
|
38
39
|
var import_ctx_utils = require("../utils/ctx-utils");
|
|
39
40
|
const WRAP_STATE_KEY = Symbol.for("plugin-agent-orchestrator.nativeSubAgentObserver");
|
|
40
41
|
const NATIVE_SOURCE = "native-plugin-ai";
|
|
@@ -61,6 +62,18 @@ function chunkBody(chunk) {
|
|
|
61
62
|
function chunkCurrentConversation(chunk) {
|
|
62
63
|
return (0, import_ctx_utils.asObject)(chunk.currentConversation);
|
|
63
64
|
}
|
|
65
|
+
function readSkillExecutionId(result) {
|
|
66
|
+
const nestedResult = (0, import_ctx_utils.asObject)(result.result);
|
|
67
|
+
const direct = nestedResult.execId || result.execId;
|
|
68
|
+
if (typeof direct === "string" || typeof direct === "number") return direct;
|
|
69
|
+
if (typeof result.content !== "string") return void 0;
|
|
70
|
+
try {
|
|
71
|
+
const content = (0, import_ctx_utils.asObject)(JSON.parse(result.content));
|
|
72
|
+
return typeof content.execId === "string" || typeof content.execId === "number" ? content.execId : void 0;
|
|
73
|
+
} catch {
|
|
74
|
+
return void 0;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
64
77
|
class NativeSubAgentObserver {
|
|
65
78
|
constructor(plugin) {
|
|
66
79
|
this.plugin = plugin;
|
|
@@ -131,14 +144,18 @@ class NativeSubAgentObserver {
|
|
|
131
144
|
aiEmployeeUsername: employeeUsername,
|
|
132
145
|
settings
|
|
133
146
|
});
|
|
134
|
-
const observedTask =
|
|
147
|
+
const observedTask = {
|
|
135
148
|
...task,
|
|
136
|
-
|
|
149
|
+
// Native dispatch passes the leader conversation's skillSettings to the
|
|
150
|
+
// sub-agent. Clear that inherited filter so plugin-ai resolves tools from
|
|
151
|
+
// the sub-agent employee's own bindings instead.
|
|
152
|
+
skillSettings: void 0,
|
|
153
|
+
question: memory.context ? `${memory.context}
|
|
137
154
|
|
|
138
155
|
<agent_task>
|
|
139
156
|
${task.question}
|
|
140
|
-
</agent_task>`
|
|
141
|
-
}
|
|
157
|
+
</agent_task>` : task.question
|
|
158
|
+
};
|
|
142
159
|
const state = {
|
|
143
160
|
rootRunId,
|
|
144
161
|
rootStartedAt: Date.now(),
|
|
@@ -174,7 +191,17 @@ ${task.question}
|
|
|
174
191
|
return originalWriter == null ? void 0 : originalWriter(chunk);
|
|
175
192
|
};
|
|
176
193
|
try {
|
|
177
|
-
const result = await
|
|
194
|
+
const result = await (0, import_AgentExecutionContext.runWithAgentExecutionContext)(
|
|
195
|
+
{
|
|
196
|
+
rootRunId,
|
|
197
|
+
spanId: state.rootSpanId ? String(state.rootSpanId) : void 0,
|
|
198
|
+
toolCallId,
|
|
199
|
+
leaderUsername,
|
|
200
|
+
employeeUsername,
|
|
201
|
+
sessionId: subSessionId
|
|
202
|
+
},
|
|
203
|
+
() => this.runWithKnowledgeBaseAgentContext(employeeUsername, () => originalRun(observedTask))
|
|
204
|
+
);
|
|
178
205
|
await this.flushPending(state);
|
|
179
206
|
await this.spanService.finish(state.rootSpanId, "success", state.rootStartedAt, {
|
|
180
207
|
output: (0, import_ctx_utils.trimText)(result, 2e4),
|
|
@@ -290,6 +317,7 @@ ${task.question}
|
|
|
290
317
|
ready: Promise.resolve()
|
|
291
318
|
};
|
|
292
319
|
state.toolSpans.set(toolCallId, toolSpan);
|
|
320
|
+
const toolName = normalizeString(toolCall.name);
|
|
293
321
|
toolSpan.ready = this.spanService.create({
|
|
294
322
|
rootRunId: state.rootRunId,
|
|
295
323
|
parentSpanId: state.rootSpanId ? String(state.rootSpanId) : void 0,
|
|
@@ -297,12 +325,12 @@ ${task.question}
|
|
|
297
325
|
parentSessionId: state.parentSessionId || void 0,
|
|
298
326
|
subSessionId: normalizeString(conversation.sessionId) || state.subSessionId || void 0,
|
|
299
327
|
toolCallId,
|
|
300
|
-
type:
|
|
328
|
+
type: toolName === "dispatch-sub-agent-task" ? "dispatch" : toolName === "skill_hub_execute" || toolName.startsWith("skill_hub_") ? "skill" : "tool",
|
|
301
329
|
status: "running",
|
|
302
330
|
leaderUsername: state.leaderUsername,
|
|
303
331
|
employeeUsername: normalizeString(conversation.username) || state.employeeUsername,
|
|
304
|
-
toolName
|
|
305
|
-
title:
|
|
332
|
+
toolName,
|
|
333
|
+
title: toolName || "tool call",
|
|
306
334
|
input: (0, import_ctx_utils.asObject)(toolCall.args),
|
|
307
335
|
metadata: {
|
|
308
336
|
source: NATIVE_SOURCE,
|
|
@@ -326,6 +354,8 @@ ${task.question}
|
|
|
326
354
|
const error = body.error;
|
|
327
355
|
const status = forceError || result.status === "error" ? "error" : "success";
|
|
328
356
|
const output = result.content ?? result.result ?? result;
|
|
357
|
+
const toolName = normalizeString(toolCall.name);
|
|
358
|
+
const skillExecutionId = toolName === "skill_hub_execute" || toolName.startsWith("skill_hub_") ? readSkillExecutionId(result) : void 0;
|
|
329
359
|
const invokeStart = Number(result.invokeStartTime);
|
|
330
360
|
const invokeEnd = Number(result.invokeEndTime);
|
|
331
361
|
const durationMs = Number.isFinite(invokeStart) && Number.isFinite(invokeEnd) && invokeEnd >= invokeStart ? invokeEnd - invokeStart : Date.now() - existing.startedAt;
|
|
@@ -335,6 +365,7 @@ ${task.question}
|
|
|
335
365
|
durationMs,
|
|
336
366
|
output: forceError ? void 0 : (0, import_ctx_utils.trimText)(output, 2e4),
|
|
337
367
|
error: forceError ? (0, import_ctx_utils.trimText)(errorMessage(error), 1e4) : void 0,
|
|
368
|
+
skillExecutionId,
|
|
338
369
|
metadata: {
|
|
339
370
|
source: NATIVE_SOURCE,
|
|
340
371
|
toolCallResultStatus: result.status,
|
|
@@ -342,12 +373,28 @@ ${task.question}
|
|
|
342
373
|
messageId: toolCall.messageId
|
|
343
374
|
}
|
|
344
375
|
});
|
|
376
|
+
if (skillExecutionId && existing.spanId) {
|
|
377
|
+
await this.linkExecutionToSpan(skillExecutionId, existing.spanId);
|
|
378
|
+
}
|
|
345
379
|
await this.tokenTracker.estimateAndTrack(
|
|
346
380
|
existing.spanId,
|
|
347
381
|
normalizeString(toolCall.name),
|
|
348
382
|
typeof output === "string" ? output : JSON.stringify(output)
|
|
349
383
|
);
|
|
350
384
|
}
|
|
385
|
+
async linkExecutionToSpan(skillExecutionId, spanId) {
|
|
386
|
+
var _a, _b;
|
|
387
|
+
try {
|
|
388
|
+
const repo = this.plugin.db.getRepository("skillExecutions");
|
|
389
|
+
if (!repo) return;
|
|
390
|
+
await repo.update({
|
|
391
|
+
filterByTk: skillExecutionId,
|
|
392
|
+
values: { orchestratorSpanId: spanId }
|
|
393
|
+
});
|
|
394
|
+
} catch (error) {
|
|
395
|
+
(_b = (_a = this.plugin.app.logger) == null ? void 0 : _a.warn) == null ? void 0 : _b.call(_a, "[AgentOrchestrator] Failed to link skill execution to native span", error);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
351
398
|
resolveParentSessionId(task) {
|
|
352
399
|
var _a, _b, _c;
|
|
353
400
|
const values = ((_c = (_b = (_a = task.ctx) == null ? void 0 : _a.action) == null ? void 0 : _b.params) == null ? void 0 : _c.values) || {};
|
|
@@ -135,13 +135,16 @@ class SandboxRunner {
|
|
|
135
135
|
onProgress,
|
|
136
136
|
signal,
|
|
137
137
|
packageWhitelist,
|
|
138
|
-
skillDir
|
|
138
|
+
skillDir,
|
|
139
|
+
inputArgs
|
|
139
140
|
} = options;
|
|
140
141
|
this.validator.validate(code, language);
|
|
141
142
|
this.validator.validateImports(code, language, packageWhitelist || []);
|
|
142
143
|
const capabilities = await (0, import_sandboxCapabilities.ensureSandboxCapabilities)(this.logger, this.storagePath);
|
|
143
144
|
const workDir = this.fileManager.createExecDir(execId);
|
|
144
145
|
const outputDir = this.fileManager.getOutputDir(execId);
|
|
146
|
+
const inputFile = (0, import_path.resolve)(workDir, "input.json");
|
|
147
|
+
(0, import_fs.writeFileSync)(inputFile, JSON.stringify(inputArgs || {}, null, 2), "utf-8");
|
|
145
148
|
const filename = language === "node" ? "script.js" : "script.py";
|
|
146
149
|
const scriptPath = (0, import_path.resolve)(workDir, filename);
|
|
147
150
|
(0, import_fs.writeFileSync)(scriptPath, code, "utf-8");
|
|
@@ -181,7 +184,8 @@ class SandboxRunner {
|
|
|
181
184
|
PYTHONDONTWRITEBYTECODE: "1",
|
|
182
185
|
// Consumed by the sitecustomize.py guard to scope file writes.
|
|
183
186
|
SKILL_HUB_WRITE_ROOTS: [workDir, outputDir, (0, import_os.tmpdir)()].join(import_path.delimiter),
|
|
184
|
-
SKILL_DIR: skillDir || ""
|
|
187
|
+
SKILL_DIR: skillDir || "",
|
|
188
|
+
SKILL_INPUT_FILE: inputFile
|
|
185
189
|
// DO NOT pass: DB credentials, API keys, APP_KEY, etc.
|
|
186
190
|
};
|
|
187
191
|
const memLimitMb = Math.max(64, Number(process.env.SKILL_HUB_MEM_LIMIT_MB || 512));
|