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.
Files changed (255) hide show
  1. package/README.md +16 -291
  2. package/dist/client/AIEmployeesContext.d.ts +7 -0
  3. package/dist/client/OrchestratorSettings.d.ts +2 -1
  4. package/dist/client/index.js +1 -1
  5. package/dist/client/plugin.d.ts +1 -0
  6. package/dist/client/skill-hub/components/ExecutionHistory.d.ts +2 -0
  7. package/dist/client/skill-hub/components/ExecutionProgress.d.ts +20 -0
  8. package/dist/client/skill-hub/components/GitSkillImport.d.ts +7 -0
  9. package/dist/client/skill-hub/components/SkillEditor.d.ts +7 -0
  10. package/dist/client/skill-hub/components/SkillManager.d.ts +2 -0
  11. package/dist/client/skill-hub/components/SkillMetrics.d.ts +2 -0
  12. package/dist/client/skill-hub/components/SkillTestPanel.d.ts +7 -0
  13. package/dist/client/skill-hub/index.d.ts +10 -0
  14. package/dist/client/skill-hub/locale.d.ts +3 -0
  15. package/dist/client/skill-hub/tools/InteractionSchemasProvider.d.ts +19 -0
  16. package/dist/client/skill-hub/tools/SkillHubCard.d.ts +3 -0
  17. package/dist/client/skill-hub/utils/jsonFields.d.ts +3 -0
  18. package/dist/externalVersion.js +6 -6
  19. package/dist/node_modules/adm-zip/LICENSE +21 -0
  20. package/dist/node_modules/adm-zip/adm-zip.js +1 -0
  21. package/dist/node_modules/adm-zip/headers/entryHeader.js +377 -0
  22. package/dist/node_modules/adm-zip/headers/index.js +2 -0
  23. package/dist/node_modules/adm-zip/headers/mainHeader.js +130 -0
  24. package/dist/node_modules/adm-zip/methods/deflater.js +33 -0
  25. package/dist/node_modules/adm-zip/methods/index.js +3 -0
  26. package/dist/node_modules/adm-zip/methods/inflater.js +34 -0
  27. package/dist/node_modules/adm-zip/methods/zipcrypto.js +175 -0
  28. package/dist/node_modules/adm-zip/package.json +1 -0
  29. package/dist/node_modules/adm-zip/util/constants.js +142 -0
  30. package/dist/node_modules/adm-zip/util/decoder.js +5 -0
  31. package/dist/node_modules/adm-zip/util/errors.js +63 -0
  32. package/dist/node_modules/adm-zip/util/fattr.js +76 -0
  33. package/dist/node_modules/adm-zip/util/index.js +5 -0
  34. package/dist/node_modules/adm-zip/util/utils.js +339 -0
  35. package/dist/node_modules/adm-zip/zipEntry.js +405 -0
  36. package/dist/node_modules/adm-zip/zipFile.js +446 -0
  37. package/dist/node_modules/simple-git/dist/cjs/index.js +7399 -0
  38. package/dist/node_modules/simple-git/dist/esm/index.js +4745 -0
  39. package/dist/node_modules/simple-git/dist/esm/package.json +3 -0
  40. package/dist/node_modules/simple-git/dist/src/lib/api.d.ts +13 -0
  41. package/dist/node_modules/simple-git/dist/src/lib/args/log-format.d.ts +9 -0
  42. package/dist/node_modules/simple-git/dist/src/lib/errors/git-construct-error.d.ts +15 -0
  43. package/dist/node_modules/simple-git/dist/src/lib/errors/git-error.d.ts +30 -0
  44. package/dist/node_modules/simple-git/dist/src/lib/errors/git-plugin-error.d.ts +7 -0
  45. package/dist/node_modules/simple-git/dist/src/lib/errors/git-response-error.d.ts +32 -0
  46. package/dist/node_modules/simple-git/dist/src/lib/errors/task-configuration-error.d.ts +12 -0
  47. package/dist/node_modules/simple-git/dist/src/lib/git-factory.d.ts +15 -0
  48. package/dist/node_modules/simple-git/dist/src/lib/git-logger.d.ts +21 -0
  49. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-branch-delete.d.ts +5 -0
  50. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-branch.d.ts +2 -0
  51. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-commit.d.ts +2 -0
  52. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-diff-summary.d.ts +3 -0
  53. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-fetch.d.ts +2 -0
  54. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-list-log-summary.d.ts +6 -0
  55. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-merge.d.ts +11 -0
  56. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-move.d.ts +2 -0
  57. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-pull.d.ts +6 -0
  58. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-push.d.ts +4 -0
  59. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-remote-messages.d.ts +5 -0
  60. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-remote-objects.d.ts +3 -0
  61. package/dist/node_modules/simple-git/dist/src/lib/plugins/abort-plugin.d.ts +3 -0
  62. package/dist/node_modules/simple-git/dist/src/lib/plugins/block-unsafe-operations-plugin.d.ts +3 -0
  63. package/dist/node_modules/simple-git/dist/src/lib/plugins/command-config-prefixing-plugin.d.ts +2 -0
  64. package/dist/node_modules/simple-git/dist/src/lib/plugins/completion-detection.plugin.d.ts +3 -0
  65. package/dist/node_modules/simple-git/dist/src/lib/plugins/custom-binary.plugin.d.ts +3 -0
  66. package/dist/node_modules/simple-git/dist/src/lib/plugins/error-detection.plugin.d.ts +7 -0
  67. package/dist/node_modules/simple-git/dist/src/lib/plugins/index.d.ts +11 -0
  68. package/dist/node_modules/simple-git/dist/src/lib/plugins/plugin-store.d.ts +11 -0
  69. package/dist/node_modules/simple-git/dist/src/lib/plugins/progress-monitor-plugin.d.ts +3 -0
  70. package/dist/node_modules/simple-git/dist/src/lib/plugins/simple-git-plugin.d.ts +48 -0
  71. package/dist/node_modules/simple-git/dist/src/lib/plugins/spawn-options-plugin.d.ts +3 -0
  72. package/dist/node_modules/simple-git/dist/src/lib/plugins/suffix-paths.plugin.d.ts +2 -0
  73. package/dist/node_modules/simple-git/dist/src/lib/plugins/timout-plugin.d.ts +3 -0
  74. package/dist/node_modules/simple-git/dist/src/lib/responses/BranchDeleteSummary.d.ts +12 -0
  75. package/dist/node_modules/simple-git/dist/src/lib/responses/BranchSummary.d.ts +14 -0
  76. package/dist/node_modules/simple-git/dist/src/lib/responses/CheckIgnore.d.ts +4 -0
  77. package/dist/node_modules/simple-git/dist/src/lib/responses/CleanSummary.d.ts +9 -0
  78. package/dist/node_modules/simple-git/dist/src/lib/responses/ConfigList.d.ts +13 -0
  79. package/dist/node_modules/simple-git/dist/src/lib/responses/DiffSummary.d.ts +10 -0
  80. package/dist/node_modules/simple-git/dist/src/lib/responses/FileStatusSummary.d.ts +9 -0
  81. package/dist/node_modules/simple-git/dist/src/lib/responses/GetRemoteSummary.d.ts +11 -0
  82. package/dist/node_modules/simple-git/dist/src/lib/responses/InitSummary.d.ts +9 -0
  83. package/dist/node_modules/simple-git/dist/src/lib/responses/MergeSummary.d.ts +16 -0
  84. package/dist/node_modules/simple-git/dist/src/lib/responses/PullSummary.d.ts +25 -0
  85. package/dist/node_modules/simple-git/dist/src/lib/responses/StatusSummary.d.ts +19 -0
  86. package/dist/node_modules/simple-git/dist/src/lib/responses/TagList.d.ts +7 -0
  87. package/dist/node_modules/simple-git/dist/src/lib/runners/git-executor-chain.d.ts +25 -0
  88. package/dist/node_modules/simple-git/dist/src/lib/runners/git-executor.d.ts +14 -0
  89. package/dist/node_modules/simple-git/dist/src/lib/runners/promise-wrapped.d.ts +2 -0
  90. package/dist/node_modules/simple-git/dist/src/lib/runners/scheduler.d.ts +11 -0
  91. package/dist/node_modules/simple-git/dist/src/lib/runners/tasks-pending-queue.d.ts +23 -0
  92. package/dist/node_modules/simple-git/dist/src/lib/simple-git-api.d.ts +20 -0
  93. package/dist/node_modules/simple-git/dist/src/lib/task-callback.d.ts +2 -0
  94. package/dist/node_modules/simple-git/dist/src/lib/tasks/apply-patch.d.ts +3 -0
  95. package/dist/node_modules/simple-git/dist/src/lib/tasks/branch.d.ts +7 -0
  96. package/dist/node_modules/simple-git/dist/src/lib/tasks/change-working-directory.d.ts +2 -0
  97. package/dist/node_modules/simple-git/dist/src/lib/tasks/check-ignore.d.ts +2 -0
  98. package/dist/node_modules/simple-git/dist/src/lib/tasks/check-is-repo.d.ts +9 -0
  99. package/dist/node_modules/simple-git/dist/src/lib/tasks/checkout.d.ts +2 -0
  100. package/dist/node_modules/simple-git/dist/src/lib/tasks/clean.d.ts +25 -0
  101. package/dist/node_modules/simple-git/dist/src/lib/tasks/clone.d.ts +9 -0
  102. package/dist/node_modules/simple-git/dist/src/lib/tasks/commit.d.ts +4 -0
  103. package/dist/node_modules/simple-git/dist/src/lib/tasks/config.d.ts +8 -0
  104. package/dist/node_modules/simple-git/dist/src/lib/tasks/count-objects.d.ts +12 -0
  105. package/dist/node_modules/simple-git/dist/src/lib/tasks/diff-name-status.d.ts +12 -0
  106. package/dist/node_modules/simple-git/dist/src/lib/tasks/diff.d.ts +5 -0
  107. package/dist/node_modules/simple-git/dist/src/lib/tasks/fetch.d.ts +4 -0
  108. package/dist/node_modules/simple-git/dist/src/lib/tasks/first-commit.d.ts +2 -0
  109. package/dist/node_modules/simple-git/dist/src/lib/tasks/grep.d.ts +12 -0
  110. package/dist/node_modules/simple-git/dist/src/lib/tasks/hash-object.d.ts +5 -0
  111. package/dist/node_modules/simple-git/dist/src/lib/tasks/init.d.ts +3 -0
  112. package/dist/node_modules/simple-git/dist/src/lib/tasks/log.d.ts +32 -0
  113. package/dist/node_modules/simple-git/dist/src/lib/tasks/merge.d.ts +4 -0
  114. package/dist/node_modules/simple-git/dist/src/lib/tasks/move.d.ts +3 -0
  115. package/dist/node_modules/simple-git/dist/src/lib/tasks/pull.d.ts +3 -0
  116. package/dist/node_modules/simple-git/dist/src/lib/tasks/push.d.ts +9 -0
  117. package/dist/node_modules/simple-git/dist/src/lib/tasks/remote.d.ts +8 -0
  118. package/dist/node_modules/simple-git/dist/src/lib/tasks/reset.d.ts +11 -0
  119. package/dist/node_modules/simple-git/dist/src/lib/tasks/show.d.ts +2 -0
  120. package/dist/node_modules/simple-git/dist/src/lib/tasks/stash-list.d.ts +4 -0
  121. package/dist/node_modules/simple-git/dist/src/lib/tasks/status.d.ts +3 -0
  122. package/dist/node_modules/simple-git/dist/src/lib/tasks/sub-module.d.ts +5 -0
  123. package/dist/node_modules/simple-git/dist/src/lib/tasks/tag.d.ts +18 -0
  124. package/dist/node_modules/simple-git/dist/src/lib/tasks/task.d.ts +14 -0
  125. package/dist/node_modules/simple-git/dist/src/lib/tasks/version.d.ts +9 -0
  126. package/dist/node_modules/simple-git/dist/src/lib/types/handlers.d.ts +21 -0
  127. package/dist/node_modules/simple-git/dist/src/lib/types/index.d.ts +136 -0
  128. package/dist/node_modules/simple-git/dist/src/lib/types/tasks.d.ts +19 -0
  129. package/dist/node_modules/simple-git/dist/src/lib/utils/argument-filters.d.ts +14 -0
  130. package/dist/node_modules/simple-git/dist/src/lib/utils/exit-codes.d.ts +10 -0
  131. package/dist/node_modules/simple-git/dist/src/lib/utils/git-output-streams.d.ts +7 -0
  132. package/dist/node_modules/simple-git/dist/src/lib/utils/index.d.ts +8 -0
  133. package/dist/node_modules/simple-git/dist/src/lib/utils/line-parser.d.ts +15 -0
  134. package/dist/node_modules/simple-git/dist/src/lib/utils/simple-git-options.d.ts +2 -0
  135. package/dist/node_modules/simple-git/dist/src/lib/utils/task-options.d.ts +13 -0
  136. package/dist/node_modules/simple-git/dist/src/lib/utils/task-parser.d.ts +5 -0
  137. package/dist/node_modules/simple-git/dist/src/lib/utils/util.d.ts +47 -0
  138. package/dist/node_modules/simple-git/dist/typings/errors.d.ts +5 -0
  139. package/dist/node_modules/simple-git/dist/typings/index.d.ts +14 -0
  140. package/dist/node_modules/simple-git/dist/typings/response.d.ts +556 -0
  141. package/dist/node_modules/simple-git/dist/typings/simple-git.d.ts +1033 -0
  142. package/dist/node_modules/simple-git/dist/typings/types.d.ts +22 -0
  143. package/dist/node_modules/simple-git/node_modules/debug/package.json +64 -0
  144. package/dist/node_modules/simple-git/node_modules/debug/src/browser.js +272 -0
  145. package/dist/node_modules/simple-git/node_modules/debug/src/common.js +292 -0
  146. package/dist/node_modules/simple-git/node_modules/debug/src/index.js +10 -0
  147. package/dist/node_modules/simple-git/node_modules/debug/src/node.js +263 -0
  148. package/dist/node_modules/simple-git/package.json +1 -0
  149. package/dist/node_modules/simple-git/promise.js +17 -0
  150. package/dist/server/collections/agent-execution-spans.d.ts +9 -0
  151. package/dist/server/collections/agent-execution-spans.js +152 -0
  152. package/dist/server/collections/orchestrator-config.d.ts +1 -1
  153. package/dist/server/collections/orchestrator-config.js +6 -0
  154. package/dist/server/collections/orchestrator-logs.d.ts +1 -1
  155. package/dist/server/collections/skill-definitions.d.ts +2 -0
  156. package/dist/server/collections/skill-definitions.js +158 -0
  157. package/dist/server/collections/skill-executions.d.ts +2 -0
  158. package/dist/server/collections/skill-executions.js +123 -0
  159. package/dist/server/collections/skill-worker-configs.d.ts +2 -0
  160. package/dist/server/collections/skill-worker-configs.js +115 -0
  161. package/dist/server/migrations/20260423000000-add-progress-fields.d.ts +4 -0
  162. package/dist/server/migrations/20260423000000-add-progress-fields.js +69 -0
  163. package/dist/server/migrations/20260425000000-add-interaction-schema.d.ts +4 -0
  164. package/dist/server/migrations/20260425000000-add-interaction-schema.js +61 -0
  165. package/dist/server/migrations/20260427000000-change-packages-to-text.d.ts +4 -0
  166. package/dist/server/migrations/20260427000000-change-packages-to-text.js +70 -0
  167. package/dist/server/migrations/20260427000001-change-other-json-to-text.d.ts +4 -0
  168. package/dist/server/migrations/20260427000001-change-other-json-to-text.js +80 -0
  169. package/dist/server/migrations/20260429000000-add-llm-fields.js +8 -0
  170. package/dist/server/migrations/20260429000000-fix-inputargs-json-to-text.d.ts +16 -0
  171. package/dist/server/migrations/20260429000000-fix-inputargs-json-to-text.js +51 -0
  172. package/dist/server/migrations/20260503000000-add-orchestrator-trace-fields.d.ts +7 -0
  173. package/dist/server/migrations/20260503000000-add-orchestrator-trace-fields.js +57 -0
  174. package/dist/server/plugin.d.ts +3 -0
  175. package/dist/server/plugin.js +37 -1
  176. package/dist/server/resources/tracing.js +154 -11
  177. package/dist/server/services/CodeValidator.d.ts +32 -0
  178. package/dist/server/services/CodeValidator.js +206 -0
  179. package/dist/server/services/ExecutionSpanService.d.ts +44 -0
  180. package/dist/server/services/ExecutionSpanService.js +104 -0
  181. package/dist/server/services/FileManager.d.ts +28 -0
  182. package/dist/server/services/FileManager.js +151 -0
  183. package/dist/server/services/SandboxRunner.d.ts +41 -0
  184. package/dist/server/services/SandboxRunner.js +167 -0
  185. package/dist/server/services/SkillManager.d.ts +6 -0
  186. package/dist/server/services/SkillManager.js +640 -0
  187. package/dist/server/services/SkillRepositoryService.d.ts +22 -0
  188. package/dist/server/services/SkillRepositoryService.js +157 -0
  189. package/dist/server/services/WorkerEnvManager.d.ts +26 -0
  190. package/dist/server/services/WorkerEnvManager.js +120 -0
  191. package/dist/server/skill-hub/actions/git-import.d.ts +21 -0
  192. package/dist/server/skill-hub/actions/git-import.js +413 -0
  193. package/dist/server/skill-hub/mcp/McpController.d.ts +15 -0
  194. package/dist/server/skill-hub/mcp/McpController.js +111 -0
  195. package/dist/server/skill-hub/plugin.d.ts +58 -0
  196. package/dist/server/skill-hub/plugin.js +694 -0
  197. package/dist/server/skill-hub/sandbox-config.json +6 -0
  198. package/dist/server/skill-hub/tasks/SkillExecutionTask.d.ts +16 -0
  199. package/dist/server/skill-hub/tasks/SkillExecutionTask.js +389 -0
  200. package/dist/server/skill-hub/utils/json-fields.d.ts +7 -0
  201. package/dist/server/skill-hub/utils/json-fields.js +88 -0
  202. package/dist/server/tools/delegate-task.d.ts +4 -0
  203. package/dist/server/tools/delegate-task.js +606 -104
  204. package/dist/server/tools/skill-execute.d.ts +36 -0
  205. package/dist/server/tools/skill-execute.js +167 -0
  206. package/package.json +3 -1
  207. package/src/client/AIEmployeeSelect.tsx +1 -3
  208. package/src/client/AIEmployeesContext.tsx +28 -13
  209. package/src/client/OrchestratorSettings.tsx +43 -5
  210. package/src/client/RulesTab.tsx +253 -32
  211. package/src/client/TracingTab.tsx +277 -213
  212. package/src/client/index.tsx +1 -1
  213. package/src/client/plugin.tsx +54 -15
  214. package/src/client/skill-hub/components/ExecutionHistory.tsx +201 -0
  215. package/src/client/skill-hub/components/ExecutionProgress.tsx +55 -0
  216. package/src/client/skill-hub/components/GitSkillImport.tsx +555 -0
  217. package/src/client/skill-hub/components/SkillEditor.tsx +456 -0
  218. package/src/client/skill-hub/components/SkillManager.tsx +181 -0
  219. package/src/client/skill-hub/components/SkillMetrics.tsx +124 -0
  220. package/src/client/skill-hub/components/SkillTestPanel.tsx +144 -0
  221. package/src/client/skill-hub/index.tsx +75 -0
  222. package/src/client/skill-hub/locale.ts +16 -0
  223. package/src/client/skill-hub/tools/InteractionSchemasProvider.tsx +59 -0
  224. package/src/client/skill-hub/tools/SkillHubCard.tsx +78 -0
  225. package/src/client/skill-hub/utils/jsonFields.ts +37 -0
  226. package/src/server/collections/agent-execution-spans.ts +129 -0
  227. package/src/server/collections/orchestrator-config.ts +7 -0
  228. package/src/server/collections/skill-definitions.ts +128 -0
  229. package/src/server/collections/skill-executions.ts +94 -0
  230. package/src/server/collections/skill-worker-configs.ts +86 -0
  231. package/src/server/migrations/20260423000000-add-progress-fields.ts +50 -0
  232. package/src/server/migrations/20260425000000-add-interaction-schema.ts +35 -0
  233. package/src/server/migrations/20260427000000-add-tracing-detail-fields.ts +5 -5
  234. package/src/server/migrations/20260427000000-change-packages-to-text.ts +47 -0
  235. package/src/server/migrations/20260427000001-change-other-json-to-text.ts +57 -0
  236. package/src/server/migrations/20260429000000-add-llm-fields.ts +11 -2
  237. package/src/server/migrations/20260429000000-fix-inputargs-json-to-text.ts +38 -0
  238. package/src/server/migrations/20260503000000-add-orchestrator-trace-fields.ts +32 -0
  239. package/src/server/plugin.ts +94 -46
  240. package/src/server/resources/tracing.ts +182 -15
  241. package/src/server/services/CodeValidator.ts +159 -0
  242. package/src/server/services/ExecutionSpanService.ts +106 -0
  243. package/src/server/services/FileManager.ts +144 -0
  244. package/src/server/services/SandboxRunner.ts +205 -0
  245. package/src/server/services/SkillManager.ts +623 -0
  246. package/src/server/services/SkillRepositoryService.ts +142 -0
  247. package/src/server/services/WorkerEnvManager.ts +113 -0
  248. package/src/server/skill-hub/actions/git-import.ts +486 -0
  249. package/src/server/skill-hub/mcp/McpController.ts +86 -0
  250. package/src/server/skill-hub/plugin.ts +771 -0
  251. package/src/server/skill-hub/sandbox-config.json +6 -0
  252. package/src/server/skill-hub/tasks/SkillExecutionTask.ts +443 -0
  253. package/src/server/skill-hub/utils/json-fields.ts +57 -0
  254. package/src/server/tools/delegate-task.ts +803 -127
  255. package/src/server/tools/skill-execute.ts +157 -0
@@ -0,0 +1,6 @@
1
+ {
2
+ "verifyPackages": [
3
+ "xlsx",
4
+ "dayjs"
5
+ ]
6
+ }
@@ -0,0 +1,16 @@
1
+ import Application from '@nocobase/server';
2
+ import { SandboxRunner } from '../../services/SandboxRunner';
3
+ import { FileManager } from '../../services/FileManager';
4
+ import { SkillRepositoryService } from '../../services/SkillRepositoryService';
5
+ export declare class SkillExecutionTask {
6
+ private execution;
7
+ private sandboxRunner;
8
+ private fileManager;
9
+ private skillRepoService;
10
+ private app;
11
+ constructor(execution: any, sandboxRunner: SandboxRunner, fileManager: FileManager, skillRepoService: SkillRepositoryService, app: Application);
12
+ run(): Promise<void>;
13
+ private renderTemplate;
14
+ private installGeneratedSkillIfRequested;
15
+ private validateGeneratedSkillPackages;
16
+ }
@@ -0,0 +1,389 @@
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 SkillExecutionTask_exports = {};
28
+ __export(SkillExecutionTask_exports, {
29
+ SkillExecutionTask: () => SkillExecutionTask
30
+ });
31
+ module.exports = __toCommonJS(SkillExecutionTask_exports);
32
+ var import_fs = require("fs");
33
+ var import_path = require("path");
34
+ var import_CodeValidator = require("../../services/CodeValidator");
35
+ var import_json_fields = require("../utils/json-fields");
36
+ class TaskAbortController {
37
+ listeners = [];
38
+ _aborted = false;
39
+ get aborted() {
40
+ return this._aborted;
41
+ }
42
+ get signal() {
43
+ return {
44
+ addEventListener: (_event, listener) => {
45
+ if (this._aborted) {
46
+ listener();
47
+ } else {
48
+ this.listeners.push(listener);
49
+ }
50
+ }
51
+ };
52
+ }
53
+ abort() {
54
+ if (this._aborted) return;
55
+ this._aborted = true;
56
+ for (const listener of this.listeners) {
57
+ try {
58
+ listener();
59
+ } catch {
60
+ }
61
+ }
62
+ this.listeners = [];
63
+ }
64
+ }
65
+ class SkillExecutionTask {
66
+ constructor(execution, sandboxRunner, fileManager, skillRepoService, app) {
67
+ this.execution = execution;
68
+ this.sandboxRunner = sandboxRunner;
69
+ this.fileManager = fileManager;
70
+ this.skillRepoService = skillRepoService;
71
+ this.app = app;
72
+ }
73
+ async run() {
74
+ var _a, _b, _c, _d, _e;
75
+ const skill = this.execution.get("skill") || this.execution.skill;
76
+ const execId = String(this.execution.get("id"));
77
+ await this.execution.update({ status: "running" });
78
+ const abortController = new TaskAbortController();
79
+ const abortChannel = `skill-hub.abort.${execId}`;
80
+ const abortCallback = async () => {
81
+ this.app.logger.info(`[skill-hub] Task ${execId}: received abort signal`);
82
+ abortController.abort();
83
+ };
84
+ try {
85
+ await this.app.pubSubManager.subscribe(abortChannel, abortCallback);
86
+ const inputArgs = (0, import_json_fields.parseJsonText)(this.execution.get("inputArgs"), {});
87
+ const storageType = skill.get ? skill.get("storageType") : skill.storageType;
88
+ let rawCodeTemplate = skill.get ? skill.get("codeTemplate") : skill.codeTemplate;
89
+ let language = skill.get ? skill.get("language") : skill.language;
90
+ let timeoutSeconds = skill.get ? skill.get("timeoutSeconds") : skill.timeoutSeconds;
91
+ let maxOutputSizeMb = skill.get ? skill.get("maxOutputSizeMb") : skill.maxOutputSizeMb;
92
+ const skillName = skill.get ? skill.get("name") : skill.name;
93
+ const workDir = this.fileManager.createExecDir(execId);
94
+ let skillDir;
95
+ if (storageType === "plugin") {
96
+ const pluginSkillName = (skill.get ? skill.get("pluginSource") : skill.pluginSource) || skillName;
97
+ const orchestratorPlugin = this.app.pm.get("plugin-agent-orchestrator");
98
+ const skillHub = orchestratorPlugin == null ? void 0 : orchestratorPlugin.skillHub;
99
+ let pluginTemplate = typeof (skillHub == null ? void 0 : skillHub.resolveSkillTemplate) === "function" ? skillHub.resolveSkillTemplate(pluginSkillName) : (_a = skillHub == null ? void 0 : skillHub.skillTemplates) == null ? void 0 : _a.get(pluginSkillName);
100
+ if (!pluginTemplate && skillHub) {
101
+ const allPlugins = this.app.pm.getPlugins();
102
+ for (const [, pInstance] of allPlugins) {
103
+ if (typeof pInstance.getSkillTemplates === "function") {
104
+ const pluginSkills = pInstance.getSkillTemplates();
105
+ if (Array.isArray(pluginSkills)) {
106
+ for (const s of pluginSkills) {
107
+ if (s.name === pluginSkillName) {
108
+ pluginTemplate = typeof (skillHub == null ? void 0 : skillHub.hydrateSkillTemplate) === "function" ? skillHub.hydrateSkillTemplate(pInstance.name, s) : { ...s, pluginSource: s.name, pluginName: pInstance.name };
109
+ skillHub.skillTemplates.set(s.name, pluginTemplate);
110
+ break;
111
+ }
112
+ }
113
+ }
114
+ }
115
+ if (pluginTemplate) break;
116
+ }
117
+ }
118
+ if (pluginTemplate) {
119
+ rawCodeTemplate = pluginTemplate.codeTemplate;
120
+ language = pluginTemplate.language;
121
+ if (pluginTemplate.timeoutSeconds) timeoutSeconds = pluginTemplate.timeoutSeconds;
122
+ if (pluginTemplate.maxOutputSizeMb) maxOutputSizeMb = pluginTemplate.maxOutputSizeMb;
123
+ const packageRoot = (_b = pluginTemplate.skillPackage) == null ? void 0 : _b.rootDir;
124
+ if (packageRoot) {
125
+ const mountMode = ((_c = pluginTemplate.skillPackage) == null ? void 0 : _c.mountMode) || "reference";
126
+ if (mountMode === "copy") {
127
+ skillDir = (0, import_path.resolve)(workDir, "skill");
128
+ this.skillRepoService.copyDirectoryTo(packageRoot, skillDir);
129
+ } else {
130
+ skillDir = packageRoot;
131
+ }
132
+ }
133
+ } else {
134
+ throw new Error(`Plugin skill "${pluginSkillName}" not found. Is the parent plugin enabled?`);
135
+ }
136
+ }
137
+ if (!rawCodeTemplate) {
138
+ throw new Error(
139
+ `Skill "${skillName}" has no codeTemplate. Add a code file, inline codeTemplate, or bind it to an installed plugin skill.`
140
+ );
141
+ }
142
+ if (storageType !== "plugin") {
143
+ skillDir = workDir;
144
+ }
145
+ const code = this.renderTemplate(rawCodeTemplate, inputArgs, execId, skillDir);
146
+ await this.execution.update({ executedCode: code });
147
+ let packageWhitelist = [];
148
+ try {
149
+ const workerConfig = await this.app.db.getRepository("skillWorkerConfigs").findOne();
150
+ if (workerConfig) {
151
+ const wl = (0, import_json_fields.parseJsonText)(
152
+ workerConfig.get ? workerConfig.get("packageWhitelist") : workerConfig.packageWhitelist,
153
+ { python: [], node: [], apt: [] }
154
+ );
155
+ if (wl) {
156
+ packageWhitelist = (language === "node" ? wl.node : wl.python) || [];
157
+ }
158
+ }
159
+ } catch {
160
+ }
161
+ const fileId = skill.get ? skill.get("fileId") : skill.fileId;
162
+ if (!require("fs").existsSync(this.skillRepoService.getSkillPath(skillName)) && fileId) {
163
+ const fmPlugin = this.app.pm.get("@nocobase/plugin-file-manager");
164
+ const attachment = await this.app.db.getRepository("attachments").findOne({ filter: { id: fileId } });
165
+ if (fmPlugin && attachment) {
166
+ try {
167
+ const streamData = await fmPlugin.getFileStream(attachment);
168
+ if (streamData == null ? void 0 : streamData.stream) {
169
+ const tempZipPath = require("path").resolve(require("os").tmpdir(), `skill_${Date.now()}_exec.zip`);
170
+ await new Promise((resolve2, reject) => {
171
+ const writeStream = require("fs").createWriteStream(tempZipPath);
172
+ streamData.stream.pipe(writeStream);
173
+ writeStream.on("finish", resolve2);
174
+ writeStream.on("error", reject);
175
+ streamData.stream.on("error", reject);
176
+ });
177
+ await this.skillRepoService.extractSkillPackage(skillName, tempZipPath);
178
+ require("fs").unlinkSync(tempZipPath);
179
+ this.app.logger.info(
180
+ `[skill-hub] Task ${execId}: Auto-restored skill package ${skillName} from S3/Storage`
181
+ );
182
+ }
183
+ } catch (fetchErr) {
184
+ this.app.logger.warn(
185
+ `[skill-hub] Task ${execId}: Failed to fetch skill package ${skillName} from storage`,
186
+ { error: fetchErr }
187
+ );
188
+ }
189
+ }
190
+ }
191
+ if (storageType !== "plugin") {
192
+ this.skillRepoService.copySkillPackageTo(skillName, workDir);
193
+ skillDir = workDir;
194
+ }
195
+ const result = await this.sandboxRunner.execute({
196
+ language,
197
+ code,
198
+ execId,
199
+ timeoutSeconds: timeoutSeconds || 60,
200
+ maxOutputSizeMb: maxOutputSizeMb || 50,
201
+ skillDir,
202
+ signal: abortController.signal,
203
+ packageWhitelist,
204
+ onProgress: (progress) => {
205
+ this.app.pubSubManager.publish(`skill-hub.progress.${execId}`, progress);
206
+ }
207
+ });
208
+ if (result.success) {
209
+ const installMessage = await this.installGeneratedSkillIfRequested(execId);
210
+ if (installMessage) {
211
+ result.stdout = [result.stdout, installMessage].filter(Boolean).join("\n");
212
+ }
213
+ }
214
+ let status;
215
+ if (result.canceled) {
216
+ status = "canceled";
217
+ } else if (result.timedOut) {
218
+ status = "timeout";
219
+ } else {
220
+ status = result.success ? "succeeded" : "failed";
221
+ }
222
+ await this.execution.update({
223
+ status,
224
+ stdout: result.stdout,
225
+ stderr: result.stderr,
226
+ outputFiles: (0, import_json_fields.stringifyJsonText)(result.files, []),
227
+ durationMs: result.durationMs
228
+ });
229
+ await this.app.pubSubManager.publish(`skill-hub.done.${execId}`, {
230
+ status,
231
+ stdout: (_d = result.stdout) == null ? void 0 : _d.slice(0, 3e3),
232
+ stderr: (_e = result.stderr) == null ? void 0 : _e.slice(0, 1e3),
233
+ files: result.files,
234
+ durationMs: result.durationMs
235
+ });
236
+ this.app.logger.info(
237
+ `[skill-hub] Execution ${execId} ${status}: skill=${skill.get ? skill.get("name") : skill.name}, language=${language}, duration=${result.durationMs}ms, files=${result.files.length}, outputSize=${this.fileManager.getTotalOutputSize(execId)}bytes`
238
+ );
239
+ } catch (error) {
240
+ const errorMessage = error instanceof Error ? error.message : String(error);
241
+ await this.execution.update({
242
+ status: "failed",
243
+ stderr: errorMessage
244
+ });
245
+ await this.app.pubSubManager.publish(`skill-hub.done.${execId}`, {
246
+ status: "failed",
247
+ stderr: errorMessage,
248
+ files: [],
249
+ durationMs: 0
250
+ });
251
+ this.app.logger.error(`[skill-hub] Execution ${execId} error: ${errorMessage}`);
252
+ } finally {
253
+ try {
254
+ await this.app.pubSubManager.unsubscribe(abortChannel, abortCallback);
255
+ } catch {
256
+ }
257
+ }
258
+ }
259
+ renderTemplate(template, args, execId, skillDir) {
260
+ let code = template;
261
+ for (const [key, value] of Object.entries(args)) {
262
+ const serialized = typeof value === "string" ? value : JSON.stringify(value);
263
+ code = code.replaceAll(`{{${key}}}`, serialized);
264
+ const b64 = Buffer.from(serialized, "utf-8").toString("base64");
265
+ code = code.replaceAll(`{{${key}_b64}}`, b64);
266
+ }
267
+ code = code.replaceAll("{{outputDir}}", this.fileManager.getOutputDir(execId).replace(/\\/g, "/"));
268
+ code = code.replaceAll("{{skillDir}}", (skillDir || "").replace(/\\/g, "/"));
269
+ return code;
270
+ }
271
+ async installGeneratedSkillIfRequested(execId) {
272
+ const manifestPath = this.fileManager.getOutputFilePath(execId, "skill-hub-install.json");
273
+ if (!manifestPath) return null;
274
+ let manifest;
275
+ try {
276
+ manifest = JSON.parse((0, import_fs.readFileSync)(manifestPath, "utf8"));
277
+ } catch (error) {
278
+ throw new Error(`Generated skill install manifest is invalid JSON: ${error instanceof Error ? error.message : String(error)}`);
279
+ }
280
+ if (!(manifest == null ? void 0 : manifest.autoInstall)) return null;
281
+ const skill = manifest.skill || {};
282
+ const name = String(skill.name || "").trim();
283
+ if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(name)) {
284
+ throw new Error(`Generated skill name "${name}" is invalid. Use lowercase letters, numbers, and hyphens.`);
285
+ }
286
+ const language = skill.language;
287
+ if (language !== "python" && language !== "node") {
288
+ throw new Error(`Generated skill "${name}" has unsupported language "${language}".`);
289
+ }
290
+ if (!skill.codeTemplate) {
291
+ throw new Error(`Generated skill "${name}" is missing codeTemplate.`);
292
+ }
293
+ const validator = new import_CodeValidator.CodeValidator();
294
+ validator.validate(skill.codeTemplate, language);
295
+ await this.validateGeneratedSkillPackages(name, language, skill.packages);
296
+ const outputDir = this.fileManager.getOutputDir(execId);
297
+ const outputRoot = (0, import_path.resolve)(outputDir);
298
+ const packageDirName = String(manifest.packageDir || name);
299
+ const packageDir = (0, import_path.resolve)(outputRoot, packageDirName);
300
+ if (packageDir !== outputRoot && !packageDir.startsWith(outputRoot + import_path.sep) || !(0, import_fs.existsSync)(packageDir)) {
301
+ throw new Error(`Generated skill package directory "${packageDirName}" was not found in output.`);
302
+ }
303
+ if (manifest.testInput && Object.keys(manifest.testInput).length > 0) {
304
+ const verifyExecId = `${execId}-verify-${name}`;
305
+ const verifyCode = this.renderTemplate(skill.codeTemplate, manifest.testInput, verifyExecId, packageDir);
306
+ const verifyResult = await this.sandboxRunner.execute({
307
+ language,
308
+ code: verifyCode,
309
+ execId: verifyExecId,
310
+ timeoutSeconds: Math.min(Number(skill.timeoutSeconds || 60), 30),
311
+ maxOutputSizeMb: Math.min(Number(skill.maxOutputSizeMb || 50), 10),
312
+ skillDir: packageDir
313
+ });
314
+ if (!verifyResult.success) {
315
+ throw new Error(
316
+ `Generated skill "${name}" failed smoke verification: ${verifyResult.stderr || verifyResult.stdout || "unknown error"}`
317
+ );
318
+ }
319
+ }
320
+ const skillRepoDir = this.skillRepoService.getSkillPath(name);
321
+ if ((0, import_fs.existsSync)(skillRepoDir)) {
322
+ (0, import_fs.rmSync)(skillRepoDir, { recursive: true, force: true });
323
+ }
324
+ (0, import_fs.cpSync)(packageDir, skillRepoDir, {
325
+ recursive: true,
326
+ force: true,
327
+ filter: (src) => {
328
+ const leaf = src.split(/[\\/]/).pop();
329
+ return !["node_modules", ".git", "__pycache__"].includes(leaf || "") && !src.endsWith(".pyc");
330
+ }
331
+ });
332
+ const values = {
333
+ name,
334
+ title: skill.title || name,
335
+ description: skill.description || "",
336
+ instructions: skill.instructions || "",
337
+ language,
338
+ codeTemplate: skill.codeTemplate,
339
+ inputSchema: (0, import_json_fields.stringifyJsonText)(skill.inputSchema || { type: "object", properties: {} }),
340
+ packages: (0, import_json_fields.stringifyJsonText)(skill.packages || [], []),
341
+ timeoutSeconds: skill.timeoutSeconds || 60,
342
+ maxOutputSizeMb: skill.maxOutputSizeMb || 50,
343
+ enabled: skill.enabled !== false,
344
+ toolScope: skill.toolScope || "CUSTOM",
345
+ autoCall: !!skill.autoCall,
346
+ storageType: "local",
347
+ storageUrl: `local://generated/${name}`
348
+ };
349
+ if (skill.interactionSchema) {
350
+ values.interactionSchema = (0, import_json_fields.stringifyJsonText)(skill.interactionSchema);
351
+ }
352
+ const repo = this.app.db.getRepository("skillDefinitions");
353
+ const existing = await repo.findOne({ filter: { name } });
354
+ if (existing) {
355
+ if (manifest.overwrite === false) {
356
+ throw new Error(`Skill "${name}" already exists and overwrite=false.`);
357
+ }
358
+ await repo.update({ filter: { name }, values });
359
+ return `[skill-hub] Updated generated skill "${name}" in Skill Hub.`;
360
+ }
361
+ await repo.create({ values });
362
+ return `[skill-hub] Installed generated skill "${name}" in Skill Hub.`;
363
+ }
364
+ async validateGeneratedSkillPackages(name, language, packages) {
365
+ if (!Array.isArray(packages) || packages.length === 0) return;
366
+ if (!packages.every((pkg) => typeof pkg === "string" && pkg.trim())) {
367
+ throw new Error(`Generated skill "${name}" has invalid packages. Use an array of package names.`);
368
+ }
369
+ const workerConfig = await this.app.db.getRepository("skillWorkerConfigs").findOne();
370
+ if (!workerConfig) return;
371
+ const whitelist = (0, import_json_fields.parseJsonText)(
372
+ workerConfig.get ? workerConfig.get("packageWhitelist") : workerConfig.packageWhitelist,
373
+ null
374
+ );
375
+ const allowed = whitelist == null ? void 0 : whitelist[language];
376
+ if (!Array.isArray(allowed) || allowed.length === 0) return;
377
+ const allowedSet = new Set(allowed.map((pkg) => pkg.toLowerCase()));
378
+ const missing = packages.map((pkg) => pkg.trim()).filter((pkg) => !allowedSet.has(pkg.toLowerCase()));
379
+ if (missing.length > 0) {
380
+ throw new Error(
381
+ `Generated skill "${name}" requires ${language} package(s) not available in the Skill Hub worker environment: ${missing.join(", ")}. Add them to the worker environment and refresh/init Skill Hub before installing this skill.`
382
+ );
383
+ }
384
+ }
385
+ }
386
+ // Annotate the CommonJS export names for ESM import in node:
387
+ 0 && (module.exports = {
388
+ SkillExecutionTask
389
+ });
@@ -0,0 +1,7 @@
1
+ export declare function parseJsonText<T = any>(value: any, fallback: T): T;
2
+ export declare function stringifyJsonText(value: any, fallback?: any): string;
3
+ export declare function parseJsonLike(value: any, fallback: any): any;
4
+ export declare function parseSkillMarkdown(markdown: string): {
5
+ metadata: Record<string, any>;
6
+ body: string;
7
+ };
@@ -0,0 +1,88 @@
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 json_fields_exports = {};
28
+ __export(json_fields_exports, {
29
+ parseJsonLike: () => parseJsonLike,
30
+ parseJsonText: () => parseJsonText,
31
+ parseSkillMarkdown: () => parseSkillMarkdown,
32
+ stringifyJsonText: () => stringifyJsonText
33
+ });
34
+ module.exports = __toCommonJS(json_fields_exports);
35
+ function parseJsonText(value, fallback) {
36
+ if (value === void 0 || value === null || value === "") return fallback;
37
+ if (typeof value !== "string") return value;
38
+ const trimmed = value.trim();
39
+ const fenced = trimmed.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/i);
40
+ const json = fenced ? fenced[1].trim() : trimmed;
41
+ try {
42
+ return JSON.parse(json);
43
+ } catch {
44
+ return fallback;
45
+ }
46
+ }
47
+ function stringifyJsonText(value, fallback = null) {
48
+ const normalized = value === void 0 || value === null || value === "" ? fallback : value;
49
+ if (typeof normalized === "string") {
50
+ const parsed = parseJsonText(normalized, void 0);
51
+ if (parsed === void 0) return normalized;
52
+ return `\`\`\`json
53
+ ${JSON.stringify(parsed, null, 2)}
54
+ \`\`\``;
55
+ }
56
+ return `\`\`\`json
57
+ ${JSON.stringify(normalized, null, 2)}
58
+ \`\`\``;
59
+ }
60
+ function parseJsonLike(value, fallback) {
61
+ if (value === void 0 || value === null || value === "") return fallback;
62
+ if (typeof value !== "string") return value;
63
+ const parsed = parseJsonText(value, void 0);
64
+ if (parsed !== void 0) return parsed;
65
+ return value.includes(",") ? value.split(",").map((item) => item.trim()).filter(Boolean) : fallback;
66
+ }
67
+ function parseSkillMarkdown(markdown) {
68
+ const match = markdown.match(/^---\r?\n([\s\S]*?)\r?\n---/);
69
+ if (!match) return { metadata: {}, body: markdown.trim() };
70
+ const result = {};
71
+ match[1].split(/\r?\n/).forEach((line) => {
72
+ const idx = line.indexOf(":");
73
+ if (idx > 0) {
74
+ const key = line.substring(0, idx).trim();
75
+ const value = line.substring(idx + 1).trim();
76
+ if (key) result[key] = value;
77
+ }
78
+ });
79
+ const body = markdown.substring(match[0].length).trim();
80
+ return { metadata: result, body };
81
+ }
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ parseJsonLike,
85
+ parseJsonText,
86
+ parseSkillMarkdown,
87
+ stringifyJsonText
88
+ });
@@ -13,3 +13,7 @@
13
13
  * leaderUsername field, so scoping is enforced in the invoke callback)
14
14
  */
15
15
  export declare function createDelegateToolsProvider(plugin: any): (register: any) => Promise<void>;
16
+ /**
17
+ * Test/internal helper to drop the in-memory tool cache (e.g., from a CLI op).
18
+ */
19
+ export declare function invalidateDelegateToolsCache(): void;