plugin-agent-orchestrator 1.0.6 → 1.0.14
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.js +16 -0
- package/dist/server/collections/orchestrator-logs.js +19 -2
- package/dist/server/collections/skill-definitions.d.ts +3 -0
- package/dist/server/collections/skill-definitions.js +158 -0
- package/dist/server/collections/skill-executions.d.ts +3 -0
- package/dist/server/collections/skill-executions.js +123 -0
- package/dist/server/collections/skill-worker-configs.d.ts +3 -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-add-tracing-detail-fields.d.ts +7 -0
- package/dist/server/migrations/20260427000000-add-tracing-detail-fields.js +62 -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.d.ts +7 -0
- package/dist/server/migrations/20260429000000-add-llm-fields.js +68 -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 +160 -12
- package/dist/server/services/CodeValidator.d.ts +32 -0
- package/dist/server/services/CodeValidator.js +205 -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 +14 -0
- package/dist/server/skill-hub/tasks/SkillExecutionTask.js +267 -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 +832 -119
- 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 +368 -21
- package/src/client/TracingTab.tsx +316 -102
- package/src/client/plugin.tsx +39 -0
- 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 +17 -0
- package/src/server/collections/orchestrator-logs.ts +19 -2
- 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 +41 -0
- 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 +46 -0
- 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 +51 -3
- package/src/server/resources/tracing.ts +187 -16
- 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 +297 -0
- package/src/server/skill-hub/utils/json-fields.ts +57 -0
- package/src/server/tools/delegate-task.ts +1085 -147
- package/src/server/tools/skill-execute.ts +157 -0
|
@@ -0,0 +1,413 @@
|
|
|
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 git_import_exports = {};
|
|
38
|
+
__export(git_import_exports, {
|
|
39
|
+
gitListSkills: () => gitListSkills,
|
|
40
|
+
gitSyncSkills: () => gitSyncSkills
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(git_import_exports);
|
|
43
|
+
var import_fs = require("fs");
|
|
44
|
+
var path = __toESM(require("path"));
|
|
45
|
+
var import_json_fields = require("../utils/json-fields");
|
|
46
|
+
const CODE_FILES = [
|
|
47
|
+
["index.py", "python"],
|
|
48
|
+
["index.js", "node"],
|
|
49
|
+
["main.py", "python"]
|
|
50
|
+
];
|
|
51
|
+
async function gitListSkills(ctx, next) {
|
|
52
|
+
const { repositoryId, ref = "HEAD", prefix = "" } = ctx.action.params;
|
|
53
|
+
const rootFolder = normalizeRootFolder(ctx.action.params.rootFolder);
|
|
54
|
+
if (!repositoryId) {
|
|
55
|
+
ctx.throw(400, "repositoryId and rootFolder are required");
|
|
56
|
+
}
|
|
57
|
+
const gitPlugin = ctx.app.pm.get("plugin-git-manager");
|
|
58
|
+
if (!gitPlugin) {
|
|
59
|
+
ctx.throw(400, "plugin-git-manager is not installed");
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const repo = await ctx.db.getRepository("gitRepositories").findOne({ filterByTk: repositoryId });
|
|
63
|
+
if (!repo) ctx.throw(404, "Repository not found");
|
|
64
|
+
const simpleGit = require("simple-git").default;
|
|
65
|
+
const localPath = getLocalPath(repo.get("localPath"));
|
|
66
|
+
const git = simpleGit(localPath);
|
|
67
|
+
const configPath = joinGitPath(rootFolder, "skills.json");
|
|
68
|
+
const loaded = await loadSkillsManifest(git, ref, localPath, configPath);
|
|
69
|
+
let config = loaded.config;
|
|
70
|
+
let initialized = false;
|
|
71
|
+
if (!loaded.exists) {
|
|
72
|
+
const discovered = await discoverSkills(git, ref, rootFolder);
|
|
73
|
+
config = createSkillsManifest(rootFolder, discovered);
|
|
74
|
+
initialized = initSkillsManifestFile(localPath, configPath, config);
|
|
75
|
+
}
|
|
76
|
+
const manifestSkills = Array.isArray(config.skills) ? config.skills.filter((skill) => getSkillKey(skill)) : [];
|
|
77
|
+
const enriched = manifestSkills.map((skill) => enrichListedSkill(skill, prefix));
|
|
78
|
+
const existingSkills = enriched.length ? await ctx.db.getRepository("skillDefinitions").find({
|
|
79
|
+
filter: { name: { $in: enriched.map((s) => s.name) } },
|
|
80
|
+
fields: ["name"]
|
|
81
|
+
}) : [];
|
|
82
|
+
const existingNames = new Set(existingSkills.map((s) => s.get("name")));
|
|
83
|
+
ctx.body = {
|
|
84
|
+
data: enriched.map((s) => ({
|
|
85
|
+
...s,
|
|
86
|
+
existsInDb: existingNames.has(s.name)
|
|
87
|
+
})),
|
|
88
|
+
config: {
|
|
89
|
+
name: config.name || rootFolder || "skills",
|
|
90
|
+
description: config.description || "",
|
|
91
|
+
rootFolder,
|
|
92
|
+
path: configPath,
|
|
93
|
+
initializedSkillsJson: initialized
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
await next();
|
|
97
|
+
} catch (err) {
|
|
98
|
+
ctx.throw(400, err.message);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async function gitSyncSkills(ctx, next) {
|
|
102
|
+
const { repositoryId, ref = "HEAD" } = ctx.action.params;
|
|
103
|
+
const rootFolder = normalizeRootFolder(ctx.action.params.rootFolder);
|
|
104
|
+
const { skills: selectedKeys, overwrite = false, prefix = "" } = ctx.action.params.values || ctx.action.params;
|
|
105
|
+
if (!repositoryId || !Array.isArray(selectedKeys) || selectedKeys.length === 0) {
|
|
106
|
+
ctx.throw(400, "repositoryId, rootFolder and skills[] are required");
|
|
107
|
+
}
|
|
108
|
+
const repo = await ctx.db.getRepository("gitRepositories").findOne({ filterByTk: repositoryId });
|
|
109
|
+
if (!repo) ctx.throw(404, "Repository not found");
|
|
110
|
+
const simpleGit = require("simple-git").default;
|
|
111
|
+
const localPath = getLocalPath(repo.get("localPath"));
|
|
112
|
+
const git = simpleGit(localPath);
|
|
113
|
+
const configPath = joinGitPath(rootFolder, "skills.json");
|
|
114
|
+
const loaded = await loadSkillsManifest(git, ref, localPath, configPath);
|
|
115
|
+
let config = loaded.config;
|
|
116
|
+
if (!loaded.exists) {
|
|
117
|
+
const discovered = await discoverSkills(git, ref, rootFolder);
|
|
118
|
+
config = createSkillsManifest(rootFolder, discovered);
|
|
119
|
+
initSkillsManifestFile(localPath, configPath, config);
|
|
120
|
+
}
|
|
121
|
+
const manifest = /* @__PURE__ */ new Map();
|
|
122
|
+
for (const entry of config.skills || []) {
|
|
123
|
+
const key = getSkillKey(entry);
|
|
124
|
+
if (key) {
|
|
125
|
+
manifest.set(key, entry);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const results = [];
|
|
129
|
+
const skillRepo = ctx.db.getRepository("skillDefinitions");
|
|
130
|
+
for (const key of selectedKeys) {
|
|
131
|
+
const meta = manifest.get(key) || { folder: key, name: key };
|
|
132
|
+
const isPluginSkill = isPluginStorage(meta);
|
|
133
|
+
const rawName = meta.name || meta.pluginSource || meta.folder || key;
|
|
134
|
+
const skillName = `${prefix}${rawName}`;
|
|
135
|
+
const skillsSubDir = meta.folder ? joinGitPath(rootFolder, "skills", meta.folder) : "";
|
|
136
|
+
const skillBaseDir = skillsSubDir || rootFolder;
|
|
137
|
+
try {
|
|
138
|
+
let frontmatter = {};
|
|
139
|
+
let instructions = "";
|
|
140
|
+
if (skillBaseDir || !meta.folder) {
|
|
141
|
+
try {
|
|
142
|
+
const skillMd = await git.show([`${ref}:${joinGitPath(skillBaseDir, "SKILL.md")}`]);
|
|
143
|
+
const parsed = (0, import_json_fields.parseSkillMarkdown)(skillMd);
|
|
144
|
+
frontmatter = parsed.metadata;
|
|
145
|
+
instructions = parsed.body;
|
|
146
|
+
const otherMds = await fetchAllMarkdownInFolder(git, ref, skillBaseDir);
|
|
147
|
+
if (otherMds) instructions += otherMds;
|
|
148
|
+
} catch {
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const storageType = normalizeStorageType(
|
|
152
|
+
frontmatter.storageType || meta.storageType || (isPluginSkill ? "plugin" : "git")
|
|
153
|
+
);
|
|
154
|
+
const pluginSource = frontmatter.pluginSource || meta.pluginSource || (storageType === "plugin" ? rawName : void 0);
|
|
155
|
+
let detectedLanguage = frontmatter.language || meta.language || "python";
|
|
156
|
+
let codeTemplate = frontmatter.codeTemplate || meta.codeTemplate || "";
|
|
157
|
+
if (!codeTemplate && meta.codeFile) {
|
|
158
|
+
codeTemplate = await readOptionalGitFile(git, ref, joinGitPath(skillBaseDir, meta.codeFile));
|
|
159
|
+
}
|
|
160
|
+
if (!codeTemplate && storageType !== "plugin") {
|
|
161
|
+
const codeFile = await readConventionalCodeFile(git, ref, skillBaseDir);
|
|
162
|
+
if (codeFile) {
|
|
163
|
+
codeTemplate = codeFile.content;
|
|
164
|
+
detectedLanguage = codeFile.language;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const merged = {
|
|
168
|
+
name: skillName,
|
|
169
|
+
title: frontmatter.title || meta.title || rawName,
|
|
170
|
+
description: frontmatter.description || meta.description || "",
|
|
171
|
+
language: detectedLanguage,
|
|
172
|
+
storageType,
|
|
173
|
+
storageUrl: storageType === "plugin" ? `git://${repositoryId}/${rootFolder || ""}@${ref}#${pluginSource || rawName}` : `git://${repositoryId}/${skillsSubDir || rootFolder || ""}@${ref}`,
|
|
174
|
+
timeoutSeconds: parseInteger(frontmatter.timeoutSeconds ?? meta.timeoutSeconds, 60),
|
|
175
|
+
maxOutputSizeMb: parseInteger(frontmatter.maxOutputSizeMb ?? meta.maxOutputSizeMb, 50),
|
|
176
|
+
toolScope: frontmatter.toolScope || meta.toolScope || "CUSTOM",
|
|
177
|
+
enabled: parseBoolean(frontmatter.enabled ?? meta.enabled, true),
|
|
178
|
+
autoCall: parseBoolean(frontmatter.autoCall ?? meta.autoCall, false),
|
|
179
|
+
packages: (0, import_json_fields.stringifyJsonText)((0, import_json_fields.parseJsonLike)(meta.packages ?? frontmatter.packages, []), [])
|
|
180
|
+
};
|
|
181
|
+
if (codeTemplate) {
|
|
182
|
+
merged.codeTemplate = codeTemplate;
|
|
183
|
+
}
|
|
184
|
+
if (pluginSource) {
|
|
185
|
+
merged.pluginSource = pluginSource;
|
|
186
|
+
}
|
|
187
|
+
if (instructions) {
|
|
188
|
+
merged.instructions = instructions.trim();
|
|
189
|
+
}
|
|
190
|
+
const inputSchema = (0, import_json_fields.parseJsonLike)(frontmatter.inputSchema ?? meta.inputSchema, null);
|
|
191
|
+
if (inputSchema) {
|
|
192
|
+
merged.inputSchema = (0, import_json_fields.stringifyJsonText)(inputSchema);
|
|
193
|
+
}
|
|
194
|
+
const interactionSchema = (0, import_json_fields.parseJsonLike)(frontmatter.interactionSchema ?? meta.interactionSchema, null);
|
|
195
|
+
if (interactionSchema) {
|
|
196
|
+
merged.interactionSchema = (0, import_json_fields.stringifyJsonText)(interactionSchema);
|
|
197
|
+
}
|
|
198
|
+
const existing = await skillRepo.findOne({ filter: { name: skillName } });
|
|
199
|
+
if (existing && !overwrite) {
|
|
200
|
+
results.push({ folder: key, name: skillName, status: "skipped", reason: "Already exists" });
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (existing) {
|
|
204
|
+
await skillRepo.update({ filterByTk: existing.get("id"), values: merged });
|
|
205
|
+
results.push({ folder: key, name: skillName, status: "updated" });
|
|
206
|
+
} else {
|
|
207
|
+
await skillRepo.create({ values: merged });
|
|
208
|
+
results.push({ folder: key, name: skillName, status: "created" });
|
|
209
|
+
}
|
|
210
|
+
} catch (err) {
|
|
211
|
+
results.push({ folder: key, name: skillName, status: "error", reason: err.message });
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
ctx.body = { data: results };
|
|
215
|
+
await next();
|
|
216
|
+
}
|
|
217
|
+
async function loadSkillsManifest(git, ref, localPath, configPath) {
|
|
218
|
+
let raw = null;
|
|
219
|
+
try {
|
|
220
|
+
raw = await git.show([`${ref}:${configPath}`]);
|
|
221
|
+
} catch {
|
|
222
|
+
const filePath = resolveRepoFile(localPath, configPath);
|
|
223
|
+
if ((0, import_fs.existsSync)(filePath)) {
|
|
224
|
+
raw = (0, import_fs.readFileSync)(filePath, "utf8");
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (!raw) {
|
|
228
|
+
return { exists: false, config: {} };
|
|
229
|
+
}
|
|
230
|
+
try {
|
|
231
|
+
return { exists: true, config: JSON.parse(raw) };
|
|
232
|
+
} catch (err) {
|
|
233
|
+
throw new Error(`Invalid ${configPath}: ${err.message}`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
async function discoverSkills(git, ref, rootFolder) {
|
|
237
|
+
const folderSkills = await discoverSkillFolders(git, ref, rootFolder);
|
|
238
|
+
if (folderSkills.length > 0) {
|
|
239
|
+
return folderSkills;
|
|
240
|
+
}
|
|
241
|
+
const pluginSkill = await discoverPluginSkill(git, ref, rootFolder);
|
|
242
|
+
return pluginSkill ? [pluginSkill] : [];
|
|
243
|
+
}
|
|
244
|
+
async function discoverSkillFolders(git, ref, rootFolder) {
|
|
245
|
+
const baseDir = joinGitPath(rootFolder, "skills");
|
|
246
|
+
try {
|
|
247
|
+
const dirs = await git.raw(["ls-tree", "-d", "--name-only", `${ref}:${baseDir}/`]);
|
|
248
|
+
return dirs.trim().split("\n").filter(Boolean).map((folder) => ({
|
|
249
|
+
folder,
|
|
250
|
+
name: folder,
|
|
251
|
+
title: folder,
|
|
252
|
+
storageType: "git"
|
|
253
|
+
}));
|
|
254
|
+
} catch {
|
|
255
|
+
return [];
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
async function discoverPluginSkill(git, ref, rootFolder) {
|
|
259
|
+
const packageJsonPath = joinGitPath(rootFolder, "package.json");
|
|
260
|
+
let packageJson;
|
|
261
|
+
try {
|
|
262
|
+
packageJson = JSON.parse(await git.show([`${ref}:${packageJsonPath}`]));
|
|
263
|
+
} catch {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
const definition = await readOptionalGitFile(git, ref, joinGitPath(rootFolder, "src/server/skill-definition.ts")) || await readOptionalGitFile(git, ref, joinGitPath(rootFolder, "src/server/skill-definition.js"));
|
|
267
|
+
const templateName = definition ? extractStringProperty(definition, "name") : null;
|
|
268
|
+
const title = definition ? extractStringProperty(definition, "title") : null;
|
|
269
|
+
const language = definition ? extractStringProperty(definition, "language") : null;
|
|
270
|
+
const pluginSource = templateName || packageJson.name;
|
|
271
|
+
if (!pluginSource) {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
name: pluginSource,
|
|
276
|
+
title: title || packageJson.displayName || packageJson.name || pluginSource,
|
|
277
|
+
description: packageJson.description || "",
|
|
278
|
+
language: language || "python",
|
|
279
|
+
storageType: "plugin",
|
|
280
|
+
pluginSource
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
function createSkillsManifest(rootFolder, skills) {
|
|
284
|
+
return {
|
|
285
|
+
name: rootFolder || "skills",
|
|
286
|
+
description: "",
|
|
287
|
+
initializedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
288
|
+
skills
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
function initSkillsManifestFile(localPath, configPath, config) {
|
|
292
|
+
const filePath = resolveRepoFile(localPath, configPath);
|
|
293
|
+
if ((0, import_fs.existsSync)(filePath)) {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
(0, import_fs.mkdirSync)(path.dirname(filePath), { recursive: true });
|
|
297
|
+
(0, import_fs.writeFileSync)(filePath, `${JSON.stringify(config, null, 2)}
|
|
298
|
+
`, "utf8");
|
|
299
|
+
return true;
|
|
300
|
+
}
|
|
301
|
+
async function readConventionalCodeFile(git, ref, skillsSubDir) {
|
|
302
|
+
for (const [file, language] of CODE_FILES) {
|
|
303
|
+
const content = await readOptionalGitFile(git, ref, joinGitPath(skillsSubDir, file));
|
|
304
|
+
if (content) {
|
|
305
|
+
return { content, language };
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
async function readOptionalGitFile(git, ref, filePath) {
|
|
311
|
+
try {
|
|
312
|
+
return await git.show([`${ref}:${filePath}`]);
|
|
313
|
+
} catch {
|
|
314
|
+
return "";
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
function enrichListedSkill(skill, prefix) {
|
|
318
|
+
const rawName = skill.name || skill.pluginSource || skill.folder || "";
|
|
319
|
+
const finalName = `${prefix}${rawName}`;
|
|
320
|
+
return {
|
|
321
|
+
folder: getSkillKey(skill),
|
|
322
|
+
name: finalName,
|
|
323
|
+
title: skill.title || rawName,
|
|
324
|
+
description: skill.description || "",
|
|
325
|
+
language: skill.language || "python",
|
|
326
|
+
storageType: normalizeStorageType(skill.storageType || (skill.pluginSource ? "plugin" : "git")),
|
|
327
|
+
pluginSource: skill.pluginSource,
|
|
328
|
+
...skill.timeoutSeconds ? { timeoutSeconds: skill.timeoutSeconds } : {},
|
|
329
|
+
...skill.maxOutputSizeMb ? { maxOutputSizeMb: skill.maxOutputSizeMb } : {},
|
|
330
|
+
...skill.packages ? { packages: skill.packages } : {},
|
|
331
|
+
...skill.inputSchema ? { inputSchema: skill.inputSchema } : {},
|
|
332
|
+
...skill.toolScope ? { toolScope: skill.toolScope } : {}
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function getSkillKey(skill) {
|
|
336
|
+
return String(skill.folder || skill.name || skill.pluginSource || "").trim();
|
|
337
|
+
}
|
|
338
|
+
function isPluginStorage(skill) {
|
|
339
|
+
return normalizeStorageType(skill.storageType) === "plugin" || !!skill.pluginSource;
|
|
340
|
+
}
|
|
341
|
+
function normalizeStorageType(storageType) {
|
|
342
|
+
const value = typeof storageType === "string" ? storageType.toLowerCase() : "";
|
|
343
|
+
if (value === "plugin") return "plugin";
|
|
344
|
+
if (value === "local") return "local";
|
|
345
|
+
if (value === "database") return "database";
|
|
346
|
+
return "git";
|
|
347
|
+
}
|
|
348
|
+
function parseInteger(value, fallback) {
|
|
349
|
+
const parsed = parseInt(value, 10);
|
|
350
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
351
|
+
}
|
|
352
|
+
function parseBoolean(value, fallback) {
|
|
353
|
+
if (value === void 0 || value === null || value === "") return fallback;
|
|
354
|
+
if (typeof value === "boolean") return value;
|
|
355
|
+
if (typeof value === "string") return !["false", "0", "no"].includes(value.toLowerCase());
|
|
356
|
+
return Boolean(value);
|
|
357
|
+
}
|
|
358
|
+
function extractStringProperty(source, property) {
|
|
359
|
+
const match = source.match(new RegExp(`${property}\\s*:\\s*(['"\`])([\\s\\S]*?)\\1`));
|
|
360
|
+
return match ? match[2] : null;
|
|
361
|
+
}
|
|
362
|
+
function normalizeRootFolder(rootFolder) {
|
|
363
|
+
if (rootFolder === void 0 || rootFolder === null) {
|
|
364
|
+
throw new Error("repositoryId and rootFolder are required");
|
|
365
|
+
}
|
|
366
|
+
const normalized = String(rootFolder).replace(/\\/g, "/").replace(/^\/+|\/+$/g, "");
|
|
367
|
+
if (normalized.includes("..") || normalized.includes("\0")) {
|
|
368
|
+
throw new Error("Invalid rootFolder");
|
|
369
|
+
}
|
|
370
|
+
return normalized;
|
|
371
|
+
}
|
|
372
|
+
function joinGitPath(...parts) {
|
|
373
|
+
return parts.filter((part) => part !== void 0 && part !== "").join("/").replace(/\/+/g, "/");
|
|
374
|
+
}
|
|
375
|
+
function resolveRepoFile(localPath, gitPath) {
|
|
376
|
+
const basePath = path.resolve(localPath);
|
|
377
|
+
const resolved = path.resolve(basePath, ...gitPath.split("/").filter(Boolean));
|
|
378
|
+
if (resolved !== basePath && !resolved.startsWith(basePath + path.sep)) {
|
|
379
|
+
throw new Error("Invalid file path");
|
|
380
|
+
}
|
|
381
|
+
return resolved;
|
|
382
|
+
}
|
|
383
|
+
function getLocalPath(localPath) {
|
|
384
|
+
const basePath = process.env.GIT_REPOS_BASE_PATH || path.join(process.cwd(), "storage", "git-repos");
|
|
385
|
+
if (path.isAbsolute(localPath)) return localPath;
|
|
386
|
+
return path.resolve(basePath, localPath);
|
|
387
|
+
}
|
|
388
|
+
async function fetchAllMarkdownInFolder(git, ref, folderPath) {
|
|
389
|
+
let combined = "";
|
|
390
|
+
try {
|
|
391
|
+
const filesOut = await git.raw(["ls-tree", "-r", "--name-only", `${ref}:${folderPath}/`]);
|
|
392
|
+
const files = filesOut.trim().split("\n").filter(Boolean);
|
|
393
|
+
for (const file of files) {
|
|
394
|
+
if (file.toLowerCase().endsWith(".md") && file.toUpperCase() !== "SKILL.md") {
|
|
395
|
+
const content = await readOptionalGitFile(git, ref, joinGitPath(folderPath, file));
|
|
396
|
+
if (content) {
|
|
397
|
+
combined += `
|
|
398
|
+
|
|
399
|
+
--- Content from ${file} ---
|
|
400
|
+
|
|
401
|
+
${content}`;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
} catch (err) {
|
|
406
|
+
}
|
|
407
|
+
return combined;
|
|
408
|
+
}
|
|
409
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
410
|
+
0 && (module.exports = {
|
|
411
|
+
gitListSkills,
|
|
412
|
+
gitSyncSkills
|
|
413
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type PluginSkillHubServer from '../plugin';
|
|
2
|
+
export declare class McpController {
|
|
3
|
+
private plugin;
|
|
4
|
+
constructor(plugin: PluginSkillHubServer);
|
|
5
|
+
/**
|
|
6
|
+
* List all enabled skills in standard MCP format.
|
|
7
|
+
* Route: GET /api/skillHub:mcpListTools
|
|
8
|
+
*/
|
|
9
|
+
listTools(ctx: any, next: any): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Execute a skill in standard MCP format.
|
|
12
|
+
* Route: POST /api/skillHub:mcpCallTool
|
|
13
|
+
*/
|
|
14
|
+
callTool(ctx: any, next: any): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
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 McpController_exports = {};
|
|
28
|
+
__export(McpController_exports, {
|
|
29
|
+
McpController: () => McpController
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(McpController_exports);
|
|
32
|
+
var import_json_fields = require("../utils/json-fields");
|
|
33
|
+
class McpController {
|
|
34
|
+
constructor(plugin) {
|
|
35
|
+
this.plugin = plugin;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* List all enabled skills in standard MCP format.
|
|
39
|
+
* Route: GET /api/skillHub:mcpListTools
|
|
40
|
+
*/
|
|
41
|
+
async listTools(ctx, next) {
|
|
42
|
+
const skills = await this.plugin.db.getRepository("skillDefinitions").find({
|
|
43
|
+
filter: { enabled: true }
|
|
44
|
+
});
|
|
45
|
+
const tools = await Promise.all(skills.map(async (skill) => ({
|
|
46
|
+
name: skill.get("name").toLowerCase().replace(/[^a-z0-9_]/g, "_").replace(/_+/g, "_"),
|
|
47
|
+
description: typeof this.plugin.getSkillDescriptionForAI === "function" ? await this.plugin.getSkillDescriptionForAI(skill) : skill.get("description"),
|
|
48
|
+
inputSchema: (0, import_json_fields.parseJsonText)(skill.get("inputSchema"), null)
|
|
49
|
+
})));
|
|
50
|
+
ctx.body = {
|
|
51
|
+
tools
|
|
52
|
+
};
|
|
53
|
+
await next();
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Execute a skill in standard MCP format.
|
|
57
|
+
* Route: POST /api/skillHub:mcpCallTool
|
|
58
|
+
*/
|
|
59
|
+
async callTool(ctx, next) {
|
|
60
|
+
var _a;
|
|
61
|
+
const { name, arguments: args } = ctx.request.body || {};
|
|
62
|
+
if (!name) {
|
|
63
|
+
ctx.throw(400, "Missing tool name");
|
|
64
|
+
}
|
|
65
|
+
const skills = await this.plugin.db.getRepository("skillDefinitions").find({
|
|
66
|
+
filter: { enabled: true }
|
|
67
|
+
});
|
|
68
|
+
const skill = skills.find(
|
|
69
|
+
(s) => s.get("name").toLowerCase().replace(/[^a-z0-9_]/g, "_").replace(/_+/g, "_") === name
|
|
70
|
+
);
|
|
71
|
+
if (!skill) {
|
|
72
|
+
ctx.throw(404, `Tool ${name} not found`);
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const result = await this.plugin.executeSkill(skill, args || {}, ctx);
|
|
76
|
+
let textContent = `Executed successfully.`;
|
|
77
|
+
if (result.stdout) textContent += `
|
|
78
|
+
Output:
|
|
79
|
+
${result.stdout}`;
|
|
80
|
+
if (result.stderr) textContent += `
|
|
81
|
+
Errors:
|
|
82
|
+
${result.stderr}`;
|
|
83
|
+
if ((_a = result.files) == null ? void 0 : _a.length) {
|
|
84
|
+
textContent += `
|
|
85
|
+
Files generated:
|
|
86
|
+
` + result.files.map((f) => {
|
|
87
|
+
return `- [${f.name}](${f.downloadUrl})`;
|
|
88
|
+
}).join("\n");
|
|
89
|
+
}
|
|
90
|
+
ctx.body = {
|
|
91
|
+
content: [
|
|
92
|
+
{
|
|
93
|
+
type: "text",
|
|
94
|
+
text: textContent
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
isError: result.status !== "succeeded"
|
|
98
|
+
};
|
|
99
|
+
} catch (err) {
|
|
100
|
+
ctx.body = {
|
|
101
|
+
content: [{ type: "text", text: `Skill Execution Error: ${err.message}` }],
|
|
102
|
+
isError: true
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
await next();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
109
|
+
0 && (module.exports = {
|
|
110
|
+
McpController
|
|
111
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { SandboxRunner } from '../services/SandboxRunner';
|
|
2
|
+
import { FileManager } from '../services/FileManager';
|
|
3
|
+
import { SkillManager } from '../services/SkillManager';
|
|
4
|
+
import { WorkerEnvManager } from '../services/WorkerEnvManager';
|
|
5
|
+
export declare class SkillHubSubFeature {
|
|
6
|
+
private plugin;
|
|
7
|
+
sandboxRunner: SandboxRunner;
|
|
8
|
+
fileManager: FileManager;
|
|
9
|
+
skillManager: SkillManager;
|
|
10
|
+
workerEnvManager: WorkerEnvManager;
|
|
11
|
+
private cleanupInterval;
|
|
12
|
+
private initEnvDoneCallback;
|
|
13
|
+
private initEnvProgressCallback;
|
|
14
|
+
private mcpController;
|
|
15
|
+
private skillRepoService;
|
|
16
|
+
private rateLimiter;
|
|
17
|
+
private skillTemplates;
|
|
18
|
+
constructor(plugin: any);
|
|
19
|
+
get app(): any;
|
|
20
|
+
get db(): any;
|
|
21
|
+
get name(): any;
|
|
22
|
+
load(): Promise<void>;
|
|
23
|
+
private onQueueTask;
|
|
24
|
+
/**
|
|
25
|
+
* Execute skill — called by both AI tool and REST test endpoint.
|
|
26
|
+
* Dispatches to worker via EventQueue, waits for result via PubSub.
|
|
27
|
+
* Pushes progress to SSE via runtime.writer (if within AI tool context).
|
|
28
|
+
* Includes rate limiting and graceful abort propagation.
|
|
29
|
+
*/
|
|
30
|
+
executeSkill(skill: any, inputArgs: Record<string, any>, ctx?: any): Promise<any>;
|
|
31
|
+
private handleDownload;
|
|
32
|
+
private handleTest;
|
|
33
|
+
/**
|
|
34
|
+
* Handle Init Environment request from admin UI.
|
|
35
|
+
* Dispatches init task to all workers via EventQueue.
|
|
36
|
+
*/
|
|
37
|
+
private handleInitEnv;
|
|
38
|
+
/**
|
|
39
|
+
* Subscribe to init-env done AND progress PubSub channels.
|
|
40
|
+
* When a worker finishes init, auto-update the DB with status.
|
|
41
|
+
*/
|
|
42
|
+
private subscribeInitEnvDone;
|
|
43
|
+
private registerAITools;
|
|
44
|
+
private startCleanupInterval;
|
|
45
|
+
beforeStop(): Promise<void>;
|
|
46
|
+
private handleClearStorage;
|
|
47
|
+
private handleListTemplates;
|
|
48
|
+
/**
|
|
49
|
+
* Register a skill template into memory for UI importing.
|
|
50
|
+
*/
|
|
51
|
+
registerSkillTemplate(pluginName: string, skillDef: any): void;
|
|
52
|
+
resolveSkillTemplate(templateName: string): any;
|
|
53
|
+
getSkillDescriptionForAI(skill: any): Promise<string>;
|
|
54
|
+
getSkillInstructions(skill: any): Promise<any>;
|
|
55
|
+
private hydrateSkillTemplate;
|
|
56
|
+
install(): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
export default SkillHubSubFeature;
|