plugin-agent-orchestrator 1.0.13 → 1.0.15
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/README.md +16 -291
- package/dist/client/AIEmployeesContext.d.ts +7 -0
- package/dist/client/OrchestratorSettings.d.ts +2 -1
- package/dist/client/index.js +1 -1
- package/dist/client/plugin.d.ts +1 -0
- package/dist/client/skill-hub/components/ExecutionHistory.d.ts +2 -0
- package/dist/client/skill-hub/components/ExecutionProgress.d.ts +20 -0
- package/dist/client/skill-hub/components/GitSkillImport.d.ts +7 -0
- package/dist/client/skill-hub/components/SkillEditor.d.ts +7 -0
- package/dist/client/skill-hub/components/SkillManager.d.ts +2 -0
- package/dist/client/skill-hub/components/SkillMetrics.d.ts +2 -0
- package/dist/client/skill-hub/components/SkillTestPanel.d.ts +7 -0
- package/dist/client/skill-hub/index.d.ts +10 -0
- package/dist/client/skill-hub/locale.d.ts +3 -0
- package/dist/client/skill-hub/tools/InteractionSchemasProvider.d.ts +19 -0
- package/dist/client/skill-hub/tools/SkillHubCard.d.ts +3 -0
- package/dist/client/skill-hub/utils/jsonFields.d.ts +3 -0
- package/dist/externalVersion.js +6 -6
- package/dist/node_modules/adm-zip/LICENSE +21 -0
- package/dist/node_modules/adm-zip/adm-zip.js +1 -0
- package/dist/node_modules/adm-zip/headers/entryHeader.js +377 -0
- package/dist/node_modules/adm-zip/headers/index.js +2 -0
- package/dist/node_modules/adm-zip/headers/mainHeader.js +130 -0
- package/dist/node_modules/adm-zip/methods/deflater.js +33 -0
- package/dist/node_modules/adm-zip/methods/index.js +3 -0
- package/dist/node_modules/adm-zip/methods/inflater.js +34 -0
- package/dist/node_modules/adm-zip/methods/zipcrypto.js +175 -0
- package/dist/node_modules/adm-zip/package.json +1 -0
- package/dist/node_modules/adm-zip/util/constants.js +142 -0
- package/dist/node_modules/adm-zip/util/decoder.js +5 -0
- package/dist/node_modules/adm-zip/util/errors.js +63 -0
- package/dist/node_modules/adm-zip/util/fattr.js +76 -0
- package/dist/node_modules/adm-zip/util/index.js +5 -0
- package/dist/node_modules/adm-zip/util/utils.js +339 -0
- package/dist/node_modules/adm-zip/zipEntry.js +405 -0
- package/dist/node_modules/adm-zip/zipFile.js +446 -0
- package/dist/node_modules/simple-git/dist/cjs/index.js +7399 -0
- package/dist/node_modules/simple-git/dist/esm/index.js +4745 -0
- package/dist/node_modules/simple-git/dist/esm/package.json +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/api.d.ts +13 -0
- package/dist/node_modules/simple-git/dist/src/lib/args/log-format.d.ts +9 -0
- package/dist/node_modules/simple-git/dist/src/lib/errors/git-construct-error.d.ts +15 -0
- package/dist/node_modules/simple-git/dist/src/lib/errors/git-error.d.ts +30 -0
- package/dist/node_modules/simple-git/dist/src/lib/errors/git-plugin-error.d.ts +7 -0
- package/dist/node_modules/simple-git/dist/src/lib/errors/git-response-error.d.ts +32 -0
- package/dist/node_modules/simple-git/dist/src/lib/errors/task-configuration-error.d.ts +12 -0
- package/dist/node_modules/simple-git/dist/src/lib/git-factory.d.ts +15 -0
- package/dist/node_modules/simple-git/dist/src/lib/git-logger.d.ts +21 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-branch-delete.d.ts +5 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-branch.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-commit.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-diff-summary.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-fetch.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-list-log-summary.d.ts +6 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-merge.d.ts +11 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-move.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-pull.d.ts +6 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-push.d.ts +4 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-remote-messages.d.ts +5 -0
- package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-remote-objects.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/abort-plugin.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/block-unsafe-operations-plugin.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/command-config-prefixing-plugin.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/completion-detection.plugin.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/custom-binary.plugin.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/error-detection.plugin.d.ts +7 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/index.d.ts +11 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/plugin-store.d.ts +11 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/progress-monitor-plugin.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/simple-git-plugin.d.ts +48 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/spawn-options-plugin.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/suffix-paths.plugin.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/plugins/timout-plugin.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/BranchDeleteSummary.d.ts +12 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/BranchSummary.d.ts +14 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/CheckIgnore.d.ts +4 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/CleanSummary.d.ts +9 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/ConfigList.d.ts +13 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/DiffSummary.d.ts +10 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/FileStatusSummary.d.ts +9 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/GetRemoteSummary.d.ts +11 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/InitSummary.d.ts +9 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/MergeSummary.d.ts +16 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/PullSummary.d.ts +25 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/StatusSummary.d.ts +19 -0
- package/dist/node_modules/simple-git/dist/src/lib/responses/TagList.d.ts +7 -0
- package/dist/node_modules/simple-git/dist/src/lib/runners/git-executor-chain.d.ts +25 -0
- package/dist/node_modules/simple-git/dist/src/lib/runners/git-executor.d.ts +14 -0
- package/dist/node_modules/simple-git/dist/src/lib/runners/promise-wrapped.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/runners/scheduler.d.ts +11 -0
- package/dist/node_modules/simple-git/dist/src/lib/runners/tasks-pending-queue.d.ts +23 -0
- package/dist/node_modules/simple-git/dist/src/lib/simple-git-api.d.ts +20 -0
- package/dist/node_modules/simple-git/dist/src/lib/task-callback.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/apply-patch.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/branch.d.ts +7 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/change-working-directory.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/check-ignore.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/check-is-repo.d.ts +9 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/checkout.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/clean.d.ts +25 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/clone.d.ts +9 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/commit.d.ts +4 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/config.d.ts +8 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/count-objects.d.ts +12 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/diff-name-status.d.ts +12 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/diff.d.ts +5 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/fetch.d.ts +4 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/first-commit.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/grep.d.ts +12 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/hash-object.d.ts +5 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/init.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/log.d.ts +32 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/merge.d.ts +4 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/move.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/pull.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/push.d.ts +9 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/remote.d.ts +8 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/reset.d.ts +11 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/show.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/stash-list.d.ts +4 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/status.d.ts +3 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/sub-module.d.ts +5 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/tag.d.ts +18 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/task.d.ts +14 -0
- package/dist/node_modules/simple-git/dist/src/lib/tasks/version.d.ts +9 -0
- package/dist/node_modules/simple-git/dist/src/lib/types/handlers.d.ts +21 -0
- package/dist/node_modules/simple-git/dist/src/lib/types/index.d.ts +136 -0
- package/dist/node_modules/simple-git/dist/src/lib/types/tasks.d.ts +19 -0
- package/dist/node_modules/simple-git/dist/src/lib/utils/argument-filters.d.ts +14 -0
- package/dist/node_modules/simple-git/dist/src/lib/utils/exit-codes.d.ts +10 -0
- package/dist/node_modules/simple-git/dist/src/lib/utils/git-output-streams.d.ts +7 -0
- package/dist/node_modules/simple-git/dist/src/lib/utils/index.d.ts +8 -0
- package/dist/node_modules/simple-git/dist/src/lib/utils/line-parser.d.ts +15 -0
- package/dist/node_modules/simple-git/dist/src/lib/utils/simple-git-options.d.ts +2 -0
- package/dist/node_modules/simple-git/dist/src/lib/utils/task-options.d.ts +13 -0
- package/dist/node_modules/simple-git/dist/src/lib/utils/task-parser.d.ts +5 -0
- package/dist/node_modules/simple-git/dist/src/lib/utils/util.d.ts +47 -0
- package/dist/node_modules/simple-git/dist/typings/errors.d.ts +5 -0
- package/dist/node_modules/simple-git/dist/typings/index.d.ts +14 -0
- package/dist/node_modules/simple-git/dist/typings/response.d.ts +556 -0
- package/dist/node_modules/simple-git/dist/typings/simple-git.d.ts +1033 -0
- package/dist/node_modules/simple-git/dist/typings/types.d.ts +22 -0
- package/dist/node_modules/simple-git/node_modules/debug/package.json +64 -0
- package/dist/node_modules/simple-git/node_modules/debug/src/browser.js +272 -0
- package/dist/node_modules/simple-git/node_modules/debug/src/common.js +292 -0
- package/dist/node_modules/simple-git/node_modules/debug/src/index.js +10 -0
- package/dist/node_modules/simple-git/node_modules/debug/src/node.js +263 -0
- package/dist/node_modules/simple-git/package.json +1 -0
- package/dist/node_modules/simple-git/promise.js +17 -0
- package/dist/server/collections/agent-execution-spans.d.ts +9 -0
- package/dist/server/collections/agent-execution-spans.js +152 -0
- package/dist/server/collections/orchestrator-config.d.ts +1 -1
- package/dist/server/collections/orchestrator-config.js +6 -0
- package/dist/server/collections/orchestrator-logs.d.ts +1 -1
- package/dist/server/collections/skill-definitions.d.ts +2 -0
- package/dist/server/collections/skill-definitions.js +158 -0
- package/dist/server/collections/skill-executions.d.ts +2 -0
- package/dist/server/collections/skill-executions.js +123 -0
- package/dist/server/collections/skill-worker-configs.d.ts +2 -0
- package/dist/server/collections/skill-worker-configs.js +115 -0
- package/dist/server/migrations/20260423000000-add-progress-fields.d.ts +4 -0
- package/dist/server/migrations/20260423000000-add-progress-fields.js +69 -0
- package/dist/server/migrations/20260425000000-add-interaction-schema.d.ts +4 -0
- package/dist/server/migrations/20260425000000-add-interaction-schema.js +61 -0
- package/dist/server/migrations/20260427000000-change-packages-to-text.d.ts +4 -0
- package/dist/server/migrations/20260427000000-change-packages-to-text.js +70 -0
- package/dist/server/migrations/20260427000001-change-other-json-to-text.d.ts +4 -0
- package/dist/server/migrations/20260427000001-change-other-json-to-text.js +80 -0
- package/dist/server/migrations/20260429000000-add-llm-fields.js +8 -0
- package/dist/server/migrations/20260429000000-fix-inputargs-json-to-text.d.ts +16 -0
- package/dist/server/migrations/20260429000000-fix-inputargs-json-to-text.js +51 -0
- package/dist/server/migrations/20260503000000-add-orchestrator-trace-fields.d.ts +7 -0
- package/dist/server/migrations/20260503000000-add-orchestrator-trace-fields.js +57 -0
- package/dist/server/plugin.d.ts +3 -0
- package/dist/server/plugin.js +37 -1
- package/dist/server/resources/tracing.js +154 -11
- package/dist/server/services/CodeValidator.d.ts +32 -0
- package/dist/server/services/CodeValidator.js +206 -0
- package/dist/server/services/ExecutionSpanService.d.ts +44 -0
- package/dist/server/services/ExecutionSpanService.js +104 -0
- package/dist/server/services/FileManager.d.ts +28 -0
- package/dist/server/services/FileManager.js +151 -0
- package/dist/server/services/SandboxRunner.d.ts +41 -0
- package/dist/server/services/SandboxRunner.js +167 -0
- package/dist/server/services/SkillManager.d.ts +6 -0
- package/dist/server/services/SkillManager.js +640 -0
- package/dist/server/services/SkillRepositoryService.d.ts +22 -0
- package/dist/server/services/SkillRepositoryService.js +157 -0
- package/dist/server/services/WorkerEnvManager.d.ts +26 -0
- package/dist/server/services/WorkerEnvManager.js +120 -0
- package/dist/server/skill-hub/actions/git-import.d.ts +21 -0
- package/dist/server/skill-hub/actions/git-import.js +413 -0
- package/dist/server/skill-hub/mcp/McpController.d.ts +15 -0
- package/dist/server/skill-hub/mcp/McpController.js +111 -0
- package/dist/server/skill-hub/plugin.d.ts +58 -0
- package/dist/server/skill-hub/plugin.js +694 -0
- package/dist/server/skill-hub/sandbox-config.json +6 -0
- package/dist/server/skill-hub/tasks/SkillExecutionTask.d.ts +16 -0
- package/dist/server/skill-hub/tasks/SkillExecutionTask.js +389 -0
- package/dist/server/skill-hub/utils/json-fields.d.ts +7 -0
- package/dist/server/skill-hub/utils/json-fields.js +88 -0
- package/dist/server/tools/delegate-task.d.ts +4 -0
- package/dist/server/tools/delegate-task.js +606 -104
- package/dist/server/tools/skill-execute.d.ts +36 -0
- package/dist/server/tools/skill-execute.js +167 -0
- package/package.json +3 -1
- package/src/client/AIEmployeeSelect.tsx +1 -3
- package/src/client/AIEmployeesContext.tsx +28 -13
- package/src/client/OrchestratorSettings.tsx +43 -5
- package/src/client/RulesTab.tsx +253 -32
- package/src/client/TracingTab.tsx +277 -213
- package/src/client/index.tsx +1 -1
- package/src/client/plugin.tsx +54 -15
- package/src/client/skill-hub/components/ExecutionHistory.tsx +201 -0
- package/src/client/skill-hub/components/ExecutionProgress.tsx +55 -0
- package/src/client/skill-hub/components/GitSkillImport.tsx +555 -0
- package/src/client/skill-hub/components/SkillEditor.tsx +456 -0
- package/src/client/skill-hub/components/SkillManager.tsx +181 -0
- package/src/client/skill-hub/components/SkillMetrics.tsx +124 -0
- package/src/client/skill-hub/components/SkillTestPanel.tsx +144 -0
- package/src/client/skill-hub/index.tsx +75 -0
- package/src/client/skill-hub/locale.ts +16 -0
- package/src/client/skill-hub/tools/InteractionSchemasProvider.tsx +59 -0
- package/src/client/skill-hub/tools/SkillHubCard.tsx +78 -0
- package/src/client/skill-hub/utils/jsonFields.ts +37 -0
- package/src/server/collections/agent-execution-spans.ts +129 -0
- package/src/server/collections/orchestrator-config.ts +7 -0
- package/src/server/collections/skill-definitions.ts +128 -0
- package/src/server/collections/skill-executions.ts +94 -0
- package/src/server/collections/skill-worker-configs.ts +86 -0
- package/src/server/migrations/20260423000000-add-progress-fields.ts +50 -0
- package/src/server/migrations/20260425000000-add-interaction-schema.ts +35 -0
- package/src/server/migrations/20260427000000-add-tracing-detail-fields.ts +5 -5
- package/src/server/migrations/20260427000000-change-packages-to-text.ts +47 -0
- package/src/server/migrations/20260427000001-change-other-json-to-text.ts +57 -0
- package/src/server/migrations/20260429000000-add-llm-fields.ts +11 -2
- package/src/server/migrations/20260429000000-fix-inputargs-json-to-text.ts +38 -0
- package/src/server/migrations/20260503000000-add-orchestrator-trace-fields.ts +32 -0
- package/src/server/plugin.ts +94 -46
- package/src/server/resources/tracing.ts +182 -15
- package/src/server/services/CodeValidator.ts +159 -0
- package/src/server/services/ExecutionSpanService.ts +106 -0
- package/src/server/services/FileManager.ts +144 -0
- package/src/server/services/SandboxRunner.ts +205 -0
- package/src/server/services/SkillManager.ts +623 -0
- package/src/server/services/SkillRepositoryService.ts +142 -0
- package/src/server/services/WorkerEnvManager.ts +113 -0
- package/src/server/skill-hub/actions/git-import.ts +486 -0
- package/src/server/skill-hub/mcp/McpController.ts +86 -0
- package/src/server/skill-hub/plugin.ts +771 -0
- package/src/server/skill-hub/sandbox-config.json +6 -0
- package/src/server/skill-hub/tasks/SkillExecutionTask.ts +443 -0
- package/src/server/skill-hub/utils/json-fields.ts +57 -0
- package/src/server/tools/delegate-task.ts +803 -127
- package/src/server/tools/skill-execute.ts +157 -0
|
@@ -0,0 +1,57 @@
|
|
|
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 add_orchestrator_trace_fields_exports = {};
|
|
28
|
+
__export(add_orchestrator_trace_fields_exports, {
|
|
29
|
+
default: () => AddOrchestratorTraceFieldsToSkillExecutions
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(add_orchestrator_trace_fields_exports);
|
|
32
|
+
var import_server = require("@nocobase/server");
|
|
33
|
+
class AddOrchestratorTraceFieldsToSkillExecutions extends import_server.Migration {
|
|
34
|
+
on = "afterLoad";
|
|
35
|
+
appVersion = ">=0.1.0";
|
|
36
|
+
async up() {
|
|
37
|
+
const queryInterface = this.db.sequelize.getQueryInterface();
|
|
38
|
+
const tablePrefix = this.db.options.tablePrefix || "";
|
|
39
|
+
const tableName = `${tablePrefix}skillExecutions`;
|
|
40
|
+
const tableExists = await queryInterface.tableExists(tableName).catch(() => false);
|
|
41
|
+
if (!tableExists) return;
|
|
42
|
+
const tableDesc = await queryInterface.describeTable(tableName);
|
|
43
|
+
const addIfMissing = async (name) => {
|
|
44
|
+
if (tableDesc[name]) return;
|
|
45
|
+
await queryInterface.addColumn(tableName, name, {
|
|
46
|
+
type: "VARCHAR(100)",
|
|
47
|
+
allowNull: true
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
await addIfMissing("orchestratorRootRunId");
|
|
51
|
+
await addIfMissing("orchestratorSpanId");
|
|
52
|
+
await addIfMissing("orchestratorParentSpanId");
|
|
53
|
+
await addIfMissing("orchestratorToolCallId");
|
|
54
|
+
}
|
|
55
|
+
async down() {
|
|
56
|
+
}
|
|
57
|
+
}
|
package/dist/server/plugin.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Plugin } from '@nocobase/server';
|
|
2
|
+
import SkillHubSubFeature from './skill-hub/plugin';
|
|
2
3
|
export declare class PluginAgentOrchestratorServer extends Plugin {
|
|
4
|
+
skillHub: SkillHubSubFeature;
|
|
3
5
|
afterAdd(): Promise<void>;
|
|
4
6
|
beforeLoad(): Promise<void>;
|
|
5
7
|
load(): Promise<void>;
|
|
@@ -7,5 +9,6 @@ export declare class PluginAgentOrchestratorServer extends Plugin {
|
|
|
7
9
|
afterEnable(): Promise<void>;
|
|
8
10
|
afterDisable(): Promise<void>;
|
|
9
11
|
remove(): Promise<void>;
|
|
12
|
+
beforeStop(): Promise<void>;
|
|
10
13
|
}
|
|
11
14
|
export default PluginAgentOrchestratorServer;
|
package/dist/server/plugin.js
CHANGED
|
@@ -44,22 +44,55 @@ var import_server = require("@nocobase/server");
|
|
|
44
44
|
var import_path = __toESM(require("path"));
|
|
45
45
|
var import_delegate_task = require("./tools/delegate-task");
|
|
46
46
|
var import_tracing = require("./resources/tracing");
|
|
47
|
+
var import_plugin = __toESM(require("./skill-hub/plugin"));
|
|
47
48
|
class PluginAgentOrchestratorServer extends import_server.Plugin {
|
|
49
|
+
skillHub;
|
|
48
50
|
async afterAdd() {
|
|
51
|
+
this.skillHub = new import_plugin.default(this);
|
|
49
52
|
}
|
|
50
53
|
async beforeLoad() {
|
|
51
54
|
this.db.import({ directory: import_path.default.resolve(__dirname, "collections") });
|
|
55
|
+
this.db.addMigrations({
|
|
56
|
+
namespace: this.name,
|
|
57
|
+
directory: import_path.default.resolve(__dirname, "migrations"),
|
|
58
|
+
context: { plugin: this }
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
async load() {
|
|
62
|
+
await this.skillHub.load();
|
|
54
63
|
this.app.acl.registerSnippet({
|
|
55
64
|
name: `pm.${this.name}`,
|
|
56
|
-
actions: ["orchestratorConfig:*"]
|
|
65
|
+
actions: ["orchestratorConfig:*", "orchestratorTracing:*", "agentExecutionSpans:*", "skillDefinitions:*", "skillExecutions:*", "skillHub:*", "skillWorkerConfigs:*"]
|
|
57
66
|
});
|
|
58
67
|
const toolsManager = this.app.aiManager.toolsManager;
|
|
59
68
|
toolsManager.registerDynamicTools((0, import_delegate_task.createDelegateToolsProvider)(this));
|
|
60
69
|
(0, import_tracing.registerTracingResource)(this);
|
|
70
|
+
this.app.cronJobManager.addJob({
|
|
71
|
+
cronTime: "0 30 2 * * *",
|
|
72
|
+
onTick: async () => {
|
|
73
|
+
try {
|
|
74
|
+
const days = Number(process.env.ORCHESTRATOR_LOG_RETENTION_DAYS || 30);
|
|
75
|
+
if (!Number.isFinite(days) || days <= 0) return;
|
|
76
|
+
const cutoff = new Date(Date.now() - days * 864e5);
|
|
77
|
+
const repo = this.db.getRepository("orchestratorLogs");
|
|
78
|
+
const spansRepo = this.db.getRepository("agentExecutionSpans");
|
|
79
|
+
const deletedLogs = repo ? await repo.destroy({
|
|
80
|
+
filter: { createdAt: { $lt: cutoff.toISOString() } }
|
|
81
|
+
}) : 0;
|
|
82
|
+
const deletedSpans = spansRepo ? await spansRepo.destroy({
|
|
83
|
+
filter: { createdAt: { $lt: cutoff.toISOString() } }
|
|
84
|
+
}) : 0;
|
|
85
|
+
this.app.log.info(
|
|
86
|
+
`[AgentOrchestrator] Pruned ${deletedLogs} orchestratorLogs and ${deletedSpans} agentExecutionSpans rows older than ${days} day(s).`
|
|
87
|
+
);
|
|
88
|
+
} catch (e) {
|
|
89
|
+
this.app.log.error("[AgentOrchestrator] Log retention job failed", e);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
61
93
|
}
|
|
62
94
|
async install() {
|
|
95
|
+
await this.skillHub.install();
|
|
63
96
|
}
|
|
64
97
|
async afterEnable() {
|
|
65
98
|
}
|
|
@@ -67,6 +100,9 @@ class PluginAgentOrchestratorServer extends import_server.Plugin {
|
|
|
67
100
|
}
|
|
68
101
|
async remove() {
|
|
69
102
|
}
|
|
103
|
+
async beforeStop() {
|
|
104
|
+
await this.skillHub.beforeStop();
|
|
105
|
+
}
|
|
70
106
|
}
|
|
71
107
|
var plugin_default = PluginAgentOrchestratorServer;
|
|
72
108
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -29,6 +29,94 @@ __export(tracing_exports, {
|
|
|
29
29
|
registerTracingResource: () => registerTracingResource
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(tracing_exports);
|
|
32
|
+
function toPlain(row) {
|
|
33
|
+
var _a;
|
|
34
|
+
return ((_a = row == null ? void 0 : row.toJSON) == null ? void 0 : _a.call(row)) || row;
|
|
35
|
+
}
|
|
36
|
+
function normalizeSpanFilter(filter = {}) {
|
|
37
|
+
const next = { ...filter };
|
|
38
|
+
if (next.subAgentUsername) {
|
|
39
|
+
next.employeeUsername = next.subAgentUsername;
|
|
40
|
+
delete next.subAgentUsername;
|
|
41
|
+
}
|
|
42
|
+
return next;
|
|
43
|
+
}
|
|
44
|
+
function spanTitle(row) {
|
|
45
|
+
if (row.title) return row.title;
|
|
46
|
+
if (row.type === "sub_agent") return `${row.leaderUsername || "-"} -> ${row.employeeUsername || "-"}`;
|
|
47
|
+
return row.toolName || row.type || "span";
|
|
48
|
+
}
|
|
49
|
+
function formatSpanListRow(raw) {
|
|
50
|
+
const row = toPlain(raw);
|
|
51
|
+
const metadata = row.metadata || {};
|
|
52
|
+
const input = row.input || {};
|
|
53
|
+
return {
|
|
54
|
+
id: row.id,
|
|
55
|
+
rootRunId: row.rootRunId,
|
|
56
|
+
parentSpanId: row.parentSpanId,
|
|
57
|
+
type: row.type,
|
|
58
|
+
leaderUsername: row.leaderUsername,
|
|
59
|
+
subAgentUsername: row.employeeUsername,
|
|
60
|
+
employeeUsername: row.employeeUsername,
|
|
61
|
+
toolName: row.toolName,
|
|
62
|
+
task: input.task || metadata.task || row.title || "",
|
|
63
|
+
context: input.context || "",
|
|
64
|
+
result: row.output,
|
|
65
|
+
status: row.status,
|
|
66
|
+
depth: metadata.depth ?? 0,
|
|
67
|
+
durationMs: row.durationMs,
|
|
68
|
+
error: row.error,
|
|
69
|
+
userId: row.userId,
|
|
70
|
+
createdAt: row.createdAt || row.startedAt,
|
|
71
|
+
traceCount: metadata.traceCount || 0,
|
|
72
|
+
messageCount: Array.isArray(metadata.messages) ? metadata.messages.length : metadata.messageCount || 0,
|
|
73
|
+
hasUnifiedTrace: true
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function buildSpanTree(rows) {
|
|
77
|
+
const plainRows = rows.map(toPlain);
|
|
78
|
+
const byId = /* @__PURE__ */ new Map();
|
|
79
|
+
const roots = [];
|
|
80
|
+
for (const row of plainRows) {
|
|
81
|
+
const node = { ...row, children: [] };
|
|
82
|
+
byId.set(String(row.id), node);
|
|
83
|
+
}
|
|
84
|
+
for (const row of byId.values()) {
|
|
85
|
+
if (row.parentSpanId && byId.has(String(row.parentSpanId))) {
|
|
86
|
+
byId.get(String(row.parentSpanId)).children.push(row);
|
|
87
|
+
} else {
|
|
88
|
+
roots.push(row);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const sortTree = (items) => {
|
|
92
|
+
items.sort(
|
|
93
|
+
(a, b) => new Date(a.startedAt || a.createdAt || 0).getTime() - new Date(b.startedAt || b.createdAt || 0).getTime()
|
|
94
|
+
);
|
|
95
|
+
for (const item of items) sortTree(item.children || []);
|
|
96
|
+
};
|
|
97
|
+
sortTree(roots);
|
|
98
|
+
return roots;
|
|
99
|
+
}
|
|
100
|
+
function flattenSpanTimeline(rows) {
|
|
101
|
+
return rows.map(toPlain).sort(
|
|
102
|
+
(a, b) => new Date(a.startedAt || a.createdAt || 0).getTime() - new Date(b.startedAt || b.createdAt || 0).getTime()
|
|
103
|
+
).map((row) => {
|
|
104
|
+
const input = row.input || {};
|
|
105
|
+
const metadata = row.metadata || {};
|
|
106
|
+
return {
|
|
107
|
+
type: row.type,
|
|
108
|
+
at: row.startedAt || row.createdAt,
|
|
109
|
+
title: spanTitle(row),
|
|
110
|
+
toolName: row.toolName,
|
|
111
|
+
args: row.type === "tool" || row.type === "skill" ? input : void 0,
|
|
112
|
+
status: row.status,
|
|
113
|
+
content: row.output || row.error || input.task || metadata.summary || "",
|
|
114
|
+
spanId: row.id,
|
|
115
|
+
parentSpanId: row.parentSpanId,
|
|
116
|
+
skillExecutionId: row.skillExecutionId
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
}
|
|
32
120
|
function registerTracingResource(plugin) {
|
|
33
121
|
const app = plugin.app;
|
|
34
122
|
app.resource({
|
|
@@ -38,9 +126,36 @@ function registerTracingResource(plugin) {
|
|
|
38
126
|
* List all delegation execution logs.
|
|
39
127
|
*/
|
|
40
128
|
async list(ctx, next) {
|
|
41
|
-
const repo = ctx.db.getRepository("orchestratorLogs");
|
|
42
129
|
const { page = 1, pageSize = 50, sort = ["-createdAt"], filter = {} } = ctx.action.params;
|
|
43
130
|
try {
|
|
131
|
+
const spanRepo = ctx.db.getRepository("agentExecutionSpans");
|
|
132
|
+
if (spanRepo) {
|
|
133
|
+
const spanFilter = {
|
|
134
|
+
...normalizeSpanFilter(filter),
|
|
135
|
+
parentSpanId: null,
|
|
136
|
+
type: "sub_agent"
|
|
137
|
+
};
|
|
138
|
+
const [spanRows, spanCount] = await spanRepo.findAndCount({
|
|
139
|
+
filter: spanFilter,
|
|
140
|
+
sort,
|
|
141
|
+
offset: (Number(page) - 1) * Number(pageSize),
|
|
142
|
+
limit: Number(pageSize)
|
|
143
|
+
});
|
|
144
|
+
if (spanCount > 0) {
|
|
145
|
+
ctx.body = {
|
|
146
|
+
data: spanRows.map(formatSpanListRow),
|
|
147
|
+
meta: {
|
|
148
|
+
count: spanCount,
|
|
149
|
+
page: Number(page),
|
|
150
|
+
pageSize: Number(pageSize),
|
|
151
|
+
totalPage: Math.ceil(spanCount / Number(pageSize))
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
await next();
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const repo = ctx.db.getRepository("orchestratorLogs");
|
|
44
159
|
const [rows, count] = await repo.findAndCount({
|
|
45
160
|
filter,
|
|
46
161
|
sort,
|
|
@@ -63,7 +178,8 @@ function registerTracingResource(plugin) {
|
|
|
63
178
|
userId: row.userId,
|
|
64
179
|
createdAt: row.createdAt,
|
|
65
180
|
traceCount: Array.isArray(row.trace) ? row.trace.length : 0,
|
|
66
|
-
messageCount: Array.isArray(row.messages) ? row.messages.length : 0
|
|
181
|
+
messageCount: Array.isArray(row.messages) ? row.messages.length : 0,
|
|
182
|
+
hasUnifiedTrace: false
|
|
67
183
|
})),
|
|
68
184
|
meta: {
|
|
69
185
|
count,
|
|
@@ -74,7 +190,7 @@ function registerTracingResource(plugin) {
|
|
|
74
190
|
};
|
|
75
191
|
} catch (e) {
|
|
76
192
|
ctx.log.error("[AgentOrchestrator] Tracing list error", e);
|
|
77
|
-
ctx.
|
|
193
|
+
ctx.throw(500, (e == null ? void 0 : e.message) || "Failed to load tracing logs");
|
|
78
194
|
}
|
|
79
195
|
await next();
|
|
80
196
|
},
|
|
@@ -83,29 +199,56 @@ function registerTracingResource(plugin) {
|
|
|
83
199
|
*/
|
|
84
200
|
async get(ctx, next) {
|
|
85
201
|
var _a;
|
|
86
|
-
const { filterByTk } = ctx.action.params;
|
|
202
|
+
const { filterByTk, source } = ctx.action.params;
|
|
87
203
|
if (!filterByTk) {
|
|
88
204
|
ctx.throw(400, "id is required");
|
|
89
205
|
return;
|
|
90
206
|
}
|
|
91
207
|
try {
|
|
208
|
+
const spanRepo = ctx.db.getRepository("agentExecutionSpans");
|
|
209
|
+
if (spanRepo && source !== "log") {
|
|
210
|
+
const span = await spanRepo.findOne({
|
|
211
|
+
filter: { id: filterByTk }
|
|
212
|
+
});
|
|
213
|
+
if (span) {
|
|
214
|
+
const plainSpan = toPlain(span);
|
|
215
|
+
const rows = await spanRepo.find({
|
|
216
|
+
filter: { rootRunId: plainSpan.rootRunId },
|
|
217
|
+
sort: ["createdAt"]
|
|
218
|
+
});
|
|
219
|
+
const tree = buildSpanTree(rows);
|
|
220
|
+
const timeline = flattenSpanTimeline(rows);
|
|
221
|
+
const rootRow = formatSpanListRow(plainSpan);
|
|
222
|
+
const metadata = plainSpan.metadata || {};
|
|
223
|
+
ctx.body = {
|
|
224
|
+
data: {
|
|
225
|
+
...rootRow,
|
|
226
|
+
input: plainSpan.input,
|
|
227
|
+
output: plainSpan.output,
|
|
228
|
+
metadata,
|
|
229
|
+
trace: timeline,
|
|
230
|
+
messages: metadata.messages || [],
|
|
231
|
+
children: tree
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
await next();
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
92
238
|
const repo = ctx.db.getRepository("orchestratorLogs");
|
|
93
|
-
const log = await repo.findOne({
|
|
239
|
+
const log = source === "span" ? null : await repo.findOne({
|
|
94
240
|
filter: { id: filterByTk }
|
|
95
241
|
});
|
|
96
|
-
|
|
242
|
+
const plainLog = ((_a = log == null ? void 0 : log.toJSON) == null ? void 0 : _a.call(log)) || log;
|
|
243
|
+
ctx.body = { data: plainLog ? { ...plainLog, hasUnifiedTrace: false } : null };
|
|
97
244
|
} catch (e) {
|
|
98
245
|
ctx.log.error("[AgentOrchestrator] Tracing get error", e);
|
|
99
|
-
ctx.
|
|
246
|
+
ctx.throw(500, (e == null ? void 0 : e.message) || "Failed to load tracing log");
|
|
100
247
|
}
|
|
101
248
|
await next();
|
|
102
249
|
}
|
|
103
250
|
}
|
|
104
251
|
});
|
|
105
|
-
app.acl.registerSnippet({
|
|
106
|
-
name: `pm.${plugin.name}.tracing`,
|
|
107
|
-
actions: ["orchestratorTracing:list", "orchestratorTracing:get"]
|
|
108
|
-
});
|
|
109
252
|
}
|
|
110
253
|
// Annotate the CommonJS export names for ESM import in node:
|
|
111
254
|
0 && (module.exports = {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare class CodeValidator {
|
|
2
|
+
/**
|
|
3
|
+
* Check code against forbidden patterns (dangerous modules/functions).
|
|
4
|
+
* @throws CodeValidationError if a forbidden pattern is found.
|
|
5
|
+
*/
|
|
6
|
+
validate(code: string, language: 'node' | 'python'): void;
|
|
7
|
+
/**
|
|
8
|
+
* Validate that code only imports packages in the whitelist.
|
|
9
|
+
* Called after the basic forbidden pattern check.
|
|
10
|
+
* Skips validation if whitelist is empty (env not initialized yet).
|
|
11
|
+
*
|
|
12
|
+
* @param code - The code to validate
|
|
13
|
+
* @param language - 'node' or 'python'
|
|
14
|
+
* @param whitelist - Array of allowed package names (from skillWorkerConfigs.packageWhitelist)
|
|
15
|
+
*/
|
|
16
|
+
validateImports(code: string, language: 'node' | 'python', whitelist: string[]): void;
|
|
17
|
+
/**
|
|
18
|
+
* Check Node.js require() calls against the whitelist.
|
|
19
|
+
* Built-in modules (fs, path, etc.) are always allowed.
|
|
20
|
+
*/
|
|
21
|
+
private validateNodeImports;
|
|
22
|
+
/**
|
|
23
|
+
* Check Python import/from statements against the whitelist.
|
|
24
|
+
* Built-in modules (os, sys, json, etc.) are always allowed.
|
|
25
|
+
* Handles PyPI→import name mapping (e.g., python-docx → docx, Pillow → PIL).
|
|
26
|
+
*/
|
|
27
|
+
private validatePythonImports;
|
|
28
|
+
}
|
|
29
|
+
export declare class CodeValidationError extends Error {
|
|
30
|
+
matchedPattern: string;
|
|
31
|
+
constructor(message: string, matchedPattern: string);
|
|
32
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
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 CodeValidator_exports = {};
|
|
28
|
+
__export(CodeValidator_exports, {
|
|
29
|
+
CodeValidationError: () => CodeValidationError,
|
|
30
|
+
CodeValidator: () => CodeValidator
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(CodeValidator_exports);
|
|
33
|
+
const DANGEROUS_NODE_PATTERNS = [
|
|
34
|
+
{ pattern: /require\s*\(\s*['"]child_process['"]\s*\)/, reason: "child_process module not allowed" },
|
|
35
|
+
{ pattern: /require\s*\(\s*['"]cluster['"]\s*\)/, reason: "cluster module not allowed" },
|
|
36
|
+
{ pattern: /require\s*\(\s*['"]dgram['"]\s*\)/, reason: "dgram module not allowed" },
|
|
37
|
+
{ pattern: /require\s*\(\s*['"]net['"]\s*\)/, reason: "net module not allowed" },
|
|
38
|
+
{ pattern: /require\s*\(\s*['"]http['"]\s*\)/, reason: "http module not allowed" },
|
|
39
|
+
{ pattern: /require\s*\(\s*['"]https['"]\s*\)/, reason: "https module not allowed" },
|
|
40
|
+
{ pattern: /require\s*\(\s*['"]vm['"]\s*\)/, reason: "vm module not allowed" },
|
|
41
|
+
{ pattern: /process\.exit/, reason: "process.exit not allowed" },
|
|
42
|
+
{ pattern: /process\.env(?!\s*\.OUTPUT_DIR)/, reason: "process.env access not allowed (use OUTPUT_DIR only)" },
|
|
43
|
+
{ pattern: /process\.kill/, reason: "process.kill not allowed" }
|
|
44
|
+
];
|
|
45
|
+
const DANGEROUS_PYTHON_PATTERNS = [
|
|
46
|
+
{ pattern: /import\s+subprocess/, reason: "subprocess module not allowed" },
|
|
47
|
+
{ pattern: /from\s+subprocess\s+import/, reason: "subprocess module not allowed" },
|
|
48
|
+
{ pattern: /import\s+shutil/, reason: "shutil module not allowed" },
|
|
49
|
+
{ pattern: /__import__\s*\(/, reason: "__import__ not allowed" },
|
|
50
|
+
{ pattern: /os\.system\s*\(/, reason: "os.system not allowed" },
|
|
51
|
+
{ pattern: /os\.popen\s*\(/, reason: "os.popen not allowed" },
|
|
52
|
+
{ pattern: /os\.exec\w*\s*\(/, reason: "os.exec* not allowed" },
|
|
53
|
+
{ pattern: /os\.spawn\w*\s*\(/, reason: "os.spawn* not allowed" },
|
|
54
|
+
{ pattern: /\beval\s*\(/, reason: "eval not allowed" },
|
|
55
|
+
{ pattern: /\bexec\s*\(/, reason: "exec not allowed" },
|
|
56
|
+
{ pattern: /\bcompile\s*\(/, reason: "compile not allowed" }
|
|
57
|
+
];
|
|
58
|
+
const NODE_BUILTINS = [
|
|
59
|
+
"fs",
|
|
60
|
+
"path",
|
|
61
|
+
"os",
|
|
62
|
+
"crypto",
|
|
63
|
+
"util",
|
|
64
|
+
"stream",
|
|
65
|
+
"buffer",
|
|
66
|
+
"querystring",
|
|
67
|
+
"url",
|
|
68
|
+
"assert",
|
|
69
|
+
"events",
|
|
70
|
+
"string_decoder",
|
|
71
|
+
"zlib"
|
|
72
|
+
];
|
|
73
|
+
const PYTHON_BUILTINS = [
|
|
74
|
+
"os",
|
|
75
|
+
"sys",
|
|
76
|
+
"json",
|
|
77
|
+
"math",
|
|
78
|
+
"datetime",
|
|
79
|
+
"collections",
|
|
80
|
+
"itertools",
|
|
81
|
+
"functools",
|
|
82
|
+
"pathlib",
|
|
83
|
+
"typing",
|
|
84
|
+
"io",
|
|
85
|
+
"csv",
|
|
86
|
+
"re",
|
|
87
|
+
"string",
|
|
88
|
+
"textwrap",
|
|
89
|
+
"decimal",
|
|
90
|
+
"fractions",
|
|
91
|
+
"random",
|
|
92
|
+
"statistics",
|
|
93
|
+
"copy",
|
|
94
|
+
"enum",
|
|
95
|
+
"dataclasses",
|
|
96
|
+
"abc",
|
|
97
|
+
"contextlib",
|
|
98
|
+
"operator",
|
|
99
|
+
"time",
|
|
100
|
+
"calendar",
|
|
101
|
+
"locale",
|
|
102
|
+
"struct",
|
|
103
|
+
"hashlib",
|
|
104
|
+
"base64",
|
|
105
|
+
"binascii",
|
|
106
|
+
"codecs",
|
|
107
|
+
"unicodedata",
|
|
108
|
+
"pprint",
|
|
109
|
+
"warnings",
|
|
110
|
+
"traceback",
|
|
111
|
+
"logging",
|
|
112
|
+
"unittest",
|
|
113
|
+
"argparse",
|
|
114
|
+
"ast",
|
|
115
|
+
"tempfile",
|
|
116
|
+
"xml",
|
|
117
|
+
"zipfile",
|
|
118
|
+
// Pre-installed local packages (trusted, bundled with plugin)
|
|
119
|
+
"svg_to_pptx"
|
|
120
|
+
];
|
|
121
|
+
const PYTHON_IMPORT_NAME_MAP = {
|
|
122
|
+
"python-docx": "docx",
|
|
123
|
+
"python-pptx": "pptx",
|
|
124
|
+
"Pillow": "PIL",
|
|
125
|
+
"pyyaml": "yaml"
|
|
126
|
+
};
|
|
127
|
+
class CodeValidator {
|
|
128
|
+
/**
|
|
129
|
+
* Check code against forbidden patterns (dangerous modules/functions).
|
|
130
|
+
* @throws CodeValidationError if a forbidden pattern is found.
|
|
131
|
+
*/
|
|
132
|
+
validate(code, language) {
|
|
133
|
+
const patterns = language === "node" ? DANGEROUS_NODE_PATTERNS : DANGEROUS_PYTHON_PATTERNS;
|
|
134
|
+
for (const { pattern, reason } of patterns) {
|
|
135
|
+
if (pattern.test(code)) {
|
|
136
|
+
throw new CodeValidationError(reason, pattern.source);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Validate that code only imports packages in the whitelist.
|
|
142
|
+
* Called after the basic forbidden pattern check.
|
|
143
|
+
* Skips validation if whitelist is empty (env not initialized yet).
|
|
144
|
+
*
|
|
145
|
+
* @param code - The code to validate
|
|
146
|
+
* @param language - 'node' or 'python'
|
|
147
|
+
* @param whitelist - Array of allowed package names (from skillWorkerConfigs.packageWhitelist)
|
|
148
|
+
*/
|
|
149
|
+
validateImports(code, language, whitelist) {
|
|
150
|
+
if (!(whitelist == null ? void 0 : whitelist.length)) return;
|
|
151
|
+
if (language === "node") {
|
|
152
|
+
this.validateNodeImports(code, whitelist);
|
|
153
|
+
} else if (language === "python") {
|
|
154
|
+
this.validatePythonImports(code, whitelist);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Check Node.js require() calls against the whitelist.
|
|
159
|
+
* Built-in modules (fs, path, etc.) are always allowed.
|
|
160
|
+
*/
|
|
161
|
+
validateNodeImports(code, whitelist) {
|
|
162
|
+
const requires = [...code.matchAll(/require\s*\(\s*['"]([^'"./][^'"]*)['"]\s*\)/g)];
|
|
163
|
+
for (const match of requires) {
|
|
164
|
+
const raw = match[1];
|
|
165
|
+
const pkgName = raw.startsWith("@") ? raw.split("/").slice(0, 2).join("/") : raw.split("/")[0];
|
|
166
|
+
if (NODE_BUILTINS.includes(pkgName)) continue;
|
|
167
|
+
if (whitelist.includes(pkgName)) continue;
|
|
168
|
+
throw new CodeValidationError(
|
|
169
|
+
`Package "${pkgName}" is not in the allowed whitelist. Allowed: ${whitelist.join(", ")}`,
|
|
170
|
+
`require('${pkgName}')`
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Check Python import/from statements against the whitelist.
|
|
176
|
+
* Built-in modules (os, sys, json, etc.) are always allowed.
|
|
177
|
+
* Handles PyPI→import name mapping (e.g., python-docx → docx, Pillow → PIL).
|
|
178
|
+
*/
|
|
179
|
+
validatePythonImports(code, whitelist) {
|
|
180
|
+
const imports = [...code.matchAll(/(?:^|\n)\s*(?:import|from)\s+([a-zA-Z_][a-zA-Z0-9_]*)/g)];
|
|
181
|
+
const allowedImports = /* @__PURE__ */ new Set([
|
|
182
|
+
...PYTHON_BUILTINS,
|
|
183
|
+
...whitelist.map((p) => PYTHON_IMPORT_NAME_MAP[p] || p)
|
|
184
|
+
]);
|
|
185
|
+
for (const match of imports) {
|
|
186
|
+
const pkg = match[1];
|
|
187
|
+
if (allowedImports.has(pkg)) continue;
|
|
188
|
+
throw new CodeValidationError(
|
|
189
|
+
`Module "${pkg}" is not in the allowed whitelist. Allowed: ${[...allowedImports].join(", ")}`,
|
|
190
|
+
`import ${pkg}`
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
class CodeValidationError extends Error {
|
|
196
|
+
constructor(message, matchedPattern) {
|
|
197
|
+
super(`Code validation failed: ${message}`);
|
|
198
|
+
this.matchedPattern = matchedPattern;
|
|
199
|
+
this.name = "CodeValidationError";
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
203
|
+
0 && (module.exports = {
|
|
204
|
+
CodeValidationError,
|
|
205
|
+
CodeValidator
|
|
206
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare const ORCHESTRATOR_TRACE_CONTEXT_KEY = "__orchestratorTraceContext";
|
|
2
|
+
export type OrchestratorTraceContext = {
|
|
3
|
+
rootRunId: string;
|
|
4
|
+
spanId?: string;
|
|
5
|
+
parentSpanId?: string;
|
|
6
|
+
toolCallId?: string;
|
|
7
|
+
leaderUsername?: string;
|
|
8
|
+
employeeUsername?: string;
|
|
9
|
+
toolName?: string;
|
|
10
|
+
};
|
|
11
|
+
type SpanValues = {
|
|
12
|
+
rootRunId: string;
|
|
13
|
+
parentSpanId?: string;
|
|
14
|
+
type: string;
|
|
15
|
+
status: string;
|
|
16
|
+
leaderUsername?: string;
|
|
17
|
+
employeeUsername?: string;
|
|
18
|
+
toolName?: string;
|
|
19
|
+
title?: string;
|
|
20
|
+
input?: any;
|
|
21
|
+
output?: string;
|
|
22
|
+
error?: string;
|
|
23
|
+
durationMs?: number;
|
|
24
|
+
startedAt?: Date;
|
|
25
|
+
endedAt?: Date;
|
|
26
|
+
orchestratorLogId?: string | number;
|
|
27
|
+
skillExecutionId?: string | number;
|
|
28
|
+
metadata?: any;
|
|
29
|
+
userId?: string | number;
|
|
30
|
+
};
|
|
31
|
+
export declare class ExecutionSpanService {
|
|
32
|
+
private readonly plugin;
|
|
33
|
+
constructor(plugin: any);
|
|
34
|
+
create(values: SpanValues): Promise<any>;
|
|
35
|
+
update(spanId: string | number | undefined, values: Record<string, any>): Promise<{
|
|
36
|
+
id: string | number;
|
|
37
|
+
}>;
|
|
38
|
+
finish(spanId: string | number | undefined, status: 'success' | 'error' | 'canceled' | 'timeout', startedAt: number, values?: Record<string, any>): Promise<{
|
|
39
|
+
id: string | number;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
export declare function getOrchestratorTraceContext(ctx: any): OrchestratorTraceContext | null;
|
|
43
|
+
export declare function setOrchestratorTraceContext(ctx: any, traceContext: OrchestratorTraceContext): any;
|
|
44
|
+
export {};
|