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.
Files changed (257) 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.js +16 -0
  153. package/dist/server/collections/orchestrator-logs.js +19 -2
  154. package/dist/server/collections/skill-definitions.d.ts +3 -0
  155. package/dist/server/collections/skill-definitions.js +158 -0
  156. package/dist/server/collections/skill-executions.d.ts +3 -0
  157. package/dist/server/collections/skill-executions.js +123 -0
  158. package/dist/server/collections/skill-worker-configs.d.ts +3 -0
  159. package/dist/server/collections/skill-worker-configs.js +115 -0
  160. package/dist/server/migrations/20260423000000-add-progress-fields.d.ts +4 -0
  161. package/dist/server/migrations/20260423000000-add-progress-fields.js +69 -0
  162. package/dist/server/migrations/20260425000000-add-interaction-schema.d.ts +4 -0
  163. package/dist/server/migrations/20260425000000-add-interaction-schema.js +61 -0
  164. package/dist/server/migrations/20260427000000-add-tracing-detail-fields.d.ts +7 -0
  165. package/dist/server/migrations/20260427000000-add-tracing-detail-fields.js +62 -0
  166. package/dist/server/migrations/20260427000000-change-packages-to-text.d.ts +4 -0
  167. package/dist/server/migrations/20260427000000-change-packages-to-text.js +70 -0
  168. package/dist/server/migrations/20260427000001-change-other-json-to-text.d.ts +4 -0
  169. package/dist/server/migrations/20260427000001-change-other-json-to-text.js +80 -0
  170. package/dist/server/migrations/20260429000000-add-llm-fields.d.ts +7 -0
  171. package/dist/server/migrations/20260429000000-add-llm-fields.js +68 -0
  172. package/dist/server/migrations/20260429000000-fix-inputargs-json-to-text.d.ts +16 -0
  173. package/dist/server/migrations/20260429000000-fix-inputargs-json-to-text.js +51 -0
  174. package/dist/server/migrations/20260503000000-add-orchestrator-trace-fields.d.ts +7 -0
  175. package/dist/server/migrations/20260503000000-add-orchestrator-trace-fields.js +57 -0
  176. package/dist/server/plugin.d.ts +3 -0
  177. package/dist/server/plugin.js +37 -1
  178. package/dist/server/resources/tracing.js +160 -12
  179. package/dist/server/services/CodeValidator.d.ts +32 -0
  180. package/dist/server/services/CodeValidator.js +205 -0
  181. package/dist/server/services/ExecutionSpanService.d.ts +44 -0
  182. package/dist/server/services/ExecutionSpanService.js +104 -0
  183. package/dist/server/services/FileManager.d.ts +28 -0
  184. package/dist/server/services/FileManager.js +151 -0
  185. package/dist/server/services/SandboxRunner.d.ts +41 -0
  186. package/dist/server/services/SandboxRunner.js +167 -0
  187. package/dist/server/services/SkillManager.d.ts +6 -0
  188. package/dist/server/services/SkillManager.js +640 -0
  189. package/dist/server/services/SkillRepositoryService.d.ts +22 -0
  190. package/dist/server/services/SkillRepositoryService.js +157 -0
  191. package/dist/server/services/WorkerEnvManager.d.ts +26 -0
  192. package/dist/server/services/WorkerEnvManager.js +120 -0
  193. package/dist/server/skill-hub/actions/git-import.d.ts +21 -0
  194. package/dist/server/skill-hub/actions/git-import.js +413 -0
  195. package/dist/server/skill-hub/mcp/McpController.d.ts +15 -0
  196. package/dist/server/skill-hub/mcp/McpController.js +111 -0
  197. package/dist/server/skill-hub/plugin.d.ts +58 -0
  198. package/dist/server/skill-hub/plugin.js +694 -0
  199. package/dist/server/skill-hub/sandbox-config.json +6 -0
  200. package/dist/server/skill-hub/tasks/SkillExecutionTask.d.ts +14 -0
  201. package/dist/server/skill-hub/tasks/SkillExecutionTask.js +267 -0
  202. package/dist/server/skill-hub/utils/json-fields.d.ts +7 -0
  203. package/dist/server/skill-hub/utils/json-fields.js +88 -0
  204. package/dist/server/tools/delegate-task.d.ts +4 -0
  205. package/dist/server/tools/delegate-task.js +832 -119
  206. package/dist/server/tools/skill-execute.d.ts +36 -0
  207. package/dist/server/tools/skill-execute.js +167 -0
  208. package/package.json +3 -1
  209. package/src/client/AIEmployeeSelect.tsx +1 -3
  210. package/src/client/AIEmployeesContext.tsx +28 -13
  211. package/src/client/OrchestratorSettings.tsx +43 -5
  212. package/src/client/RulesTab.tsx +368 -21
  213. package/src/client/TracingTab.tsx +316 -102
  214. package/src/client/plugin.tsx +39 -0
  215. package/src/client/skill-hub/components/ExecutionHistory.tsx +201 -0
  216. package/src/client/skill-hub/components/ExecutionProgress.tsx +55 -0
  217. package/src/client/skill-hub/components/GitSkillImport.tsx +555 -0
  218. package/src/client/skill-hub/components/SkillEditor.tsx +456 -0
  219. package/src/client/skill-hub/components/SkillManager.tsx +181 -0
  220. package/src/client/skill-hub/components/SkillMetrics.tsx +124 -0
  221. package/src/client/skill-hub/components/SkillTestPanel.tsx +144 -0
  222. package/src/client/skill-hub/index.tsx +75 -0
  223. package/src/client/skill-hub/locale.ts +16 -0
  224. package/src/client/skill-hub/tools/InteractionSchemasProvider.tsx +59 -0
  225. package/src/client/skill-hub/tools/SkillHubCard.tsx +78 -0
  226. package/src/client/skill-hub/utils/jsonFields.ts +37 -0
  227. package/src/server/collections/agent-execution-spans.ts +129 -0
  228. package/src/server/collections/orchestrator-config.ts +17 -0
  229. package/src/server/collections/orchestrator-logs.ts +19 -2
  230. package/src/server/collections/skill-definitions.ts +128 -0
  231. package/src/server/collections/skill-executions.ts +94 -0
  232. package/src/server/collections/skill-worker-configs.ts +86 -0
  233. package/src/server/migrations/20260423000000-add-progress-fields.ts +50 -0
  234. package/src/server/migrations/20260425000000-add-interaction-schema.ts +35 -0
  235. package/src/server/migrations/20260427000000-add-tracing-detail-fields.ts +41 -0
  236. package/src/server/migrations/20260427000000-change-packages-to-text.ts +47 -0
  237. package/src/server/migrations/20260427000001-change-other-json-to-text.ts +57 -0
  238. package/src/server/migrations/20260429000000-add-llm-fields.ts +46 -0
  239. package/src/server/migrations/20260429000000-fix-inputargs-json-to-text.ts +38 -0
  240. package/src/server/migrations/20260503000000-add-orchestrator-trace-fields.ts +32 -0
  241. package/src/server/plugin.ts +51 -3
  242. package/src/server/resources/tracing.ts +187 -16
  243. package/src/server/services/CodeValidator.ts +159 -0
  244. package/src/server/services/ExecutionSpanService.ts +106 -0
  245. package/src/server/services/FileManager.ts +144 -0
  246. package/src/server/services/SandboxRunner.ts +205 -0
  247. package/src/server/services/SkillManager.ts +623 -0
  248. package/src/server/services/SkillRepositoryService.ts +142 -0
  249. package/src/server/services/WorkerEnvManager.ts +113 -0
  250. package/src/server/skill-hub/actions/git-import.ts +486 -0
  251. package/src/server/skill-hub/mcp/McpController.ts +86 -0
  252. package/src/server/skill-hub/plugin.ts +771 -0
  253. package/src/server/skill-hub/sandbox-config.json +6 -0
  254. package/src/server/skill-hub/tasks/SkillExecutionTask.ts +297 -0
  255. package/src/server/skill-hub/utils/json-fields.ts +57 -0
  256. package/src/server/tools/delegate-task.ts +1085 -147
  257. package/src/server/tools/skill-execute.ts +157 -0
@@ -0,0 +1,205 @@
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
+ "tempfile",
115
+ "xml",
116
+ "zipfile",
117
+ // Pre-installed local packages (trusted, bundled with plugin)
118
+ "svg_to_pptx"
119
+ ];
120
+ const PYTHON_IMPORT_NAME_MAP = {
121
+ "python-docx": "docx",
122
+ "python-pptx": "pptx",
123
+ "Pillow": "PIL",
124
+ "pyyaml": "yaml"
125
+ };
126
+ class CodeValidator {
127
+ /**
128
+ * Check code against forbidden patterns (dangerous modules/functions).
129
+ * @throws CodeValidationError if a forbidden pattern is found.
130
+ */
131
+ validate(code, language) {
132
+ const patterns = language === "node" ? DANGEROUS_NODE_PATTERNS : DANGEROUS_PYTHON_PATTERNS;
133
+ for (const { pattern, reason } of patterns) {
134
+ if (pattern.test(code)) {
135
+ throw new CodeValidationError(reason, pattern.source);
136
+ }
137
+ }
138
+ }
139
+ /**
140
+ * Validate that code only imports packages in the whitelist.
141
+ * Called after the basic forbidden pattern check.
142
+ * Skips validation if whitelist is empty (env not initialized yet).
143
+ *
144
+ * @param code - The code to validate
145
+ * @param language - 'node' or 'python'
146
+ * @param whitelist - Array of allowed package names (from skillWorkerConfigs.packageWhitelist)
147
+ */
148
+ validateImports(code, language, whitelist) {
149
+ if (!(whitelist == null ? void 0 : whitelist.length)) return;
150
+ if (language === "node") {
151
+ this.validateNodeImports(code, whitelist);
152
+ } else if (language === "python") {
153
+ this.validatePythonImports(code, whitelist);
154
+ }
155
+ }
156
+ /**
157
+ * Check Node.js require() calls against the whitelist.
158
+ * Built-in modules (fs, path, etc.) are always allowed.
159
+ */
160
+ validateNodeImports(code, whitelist) {
161
+ const requires = [...code.matchAll(/require\s*\(\s*['"]([^'"./][^'"]*)['"]\s*\)/g)];
162
+ for (const match of requires) {
163
+ const raw = match[1];
164
+ const pkgName = raw.startsWith("@") ? raw.split("/").slice(0, 2).join("/") : raw.split("/")[0];
165
+ if (NODE_BUILTINS.includes(pkgName)) continue;
166
+ if (whitelist.includes(pkgName)) continue;
167
+ throw new CodeValidationError(
168
+ `Package "${pkgName}" is not in the allowed whitelist. Allowed: ${whitelist.join(", ")}`,
169
+ `require('${pkgName}')`
170
+ );
171
+ }
172
+ }
173
+ /**
174
+ * Check Python import/from statements against the whitelist.
175
+ * Built-in modules (os, sys, json, etc.) are always allowed.
176
+ * Handles PyPI→import name mapping (e.g., python-docx → docx, Pillow → PIL).
177
+ */
178
+ validatePythonImports(code, whitelist) {
179
+ const imports = [...code.matchAll(/(?:^|\n)\s*(?:import|from)\s+([a-zA-Z_][a-zA-Z0-9_]*)/g)];
180
+ const allowedImports = /* @__PURE__ */ new Set([
181
+ ...PYTHON_BUILTINS,
182
+ ...whitelist.map((p) => PYTHON_IMPORT_NAME_MAP[p] || p)
183
+ ]);
184
+ for (const match of imports) {
185
+ const pkg = match[1];
186
+ if (allowedImports.has(pkg)) continue;
187
+ throw new CodeValidationError(
188
+ `Module "${pkg}" is not in the allowed whitelist. Allowed: ${[...allowedImports].join(", ")}`,
189
+ `import ${pkg}`
190
+ );
191
+ }
192
+ }
193
+ }
194
+ class CodeValidationError extends Error {
195
+ constructor(message, matchedPattern) {
196
+ super(`Code validation failed: ${message}`);
197
+ this.matchedPattern = matchedPattern;
198
+ this.name = "CodeValidationError";
199
+ }
200
+ }
201
+ // Annotate the CommonJS export names for ESM import in node:
202
+ 0 && (module.exports = {
203
+ CodeValidationError,
204
+ CodeValidator
205
+ });
@@ -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 {};
@@ -0,0 +1,104 @@
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 ExecutionSpanService_exports = {};
28
+ __export(ExecutionSpanService_exports, {
29
+ ExecutionSpanService: () => ExecutionSpanService,
30
+ ORCHESTRATOR_TRACE_CONTEXT_KEY: () => ORCHESTRATOR_TRACE_CONTEXT_KEY,
31
+ getOrchestratorTraceContext: () => getOrchestratorTraceContext,
32
+ setOrchestratorTraceContext: () => setOrchestratorTraceContext
33
+ });
34
+ module.exports = __toCommonJS(ExecutionSpanService_exports);
35
+ const ORCHESTRATOR_TRACE_CONTEXT_KEY = "__orchestratorTraceContext";
36
+ function toPlain(record) {
37
+ var _a;
38
+ return ((_a = record == null ? void 0 : record.toJSON) == null ? void 0 : _a.call(record)) || record;
39
+ }
40
+ class ExecutionSpanService {
41
+ constructor(plugin) {
42
+ this.plugin = plugin;
43
+ }
44
+ async create(values) {
45
+ var _a, _b;
46
+ try {
47
+ const repo = this.plugin.db.getRepository("agentExecutionSpans");
48
+ if (!repo) return null;
49
+ const record = await repo.create({
50
+ values: {
51
+ ...values,
52
+ startedAt: values.startedAt || /* @__PURE__ */ new Date(),
53
+ createdAt: /* @__PURE__ */ new Date()
54
+ }
55
+ });
56
+ return toPlain(record);
57
+ } catch (error) {
58
+ (_b = (_a = this.plugin.app.log) == null ? void 0 : _a.warn) == null ? void 0 : _b.call(_a, "[AgentOrchestrator] Failed to create execution span", error);
59
+ return null;
60
+ }
61
+ }
62
+ async update(spanId, values) {
63
+ var _a, _b;
64
+ if (!spanId) return null;
65
+ try {
66
+ const repo = this.plugin.db.getRepository("agentExecutionSpans");
67
+ if (!repo) return null;
68
+ await repo.update({
69
+ filterByTk: spanId,
70
+ values: {
71
+ ...values,
72
+ updatedAt: /* @__PURE__ */ new Date()
73
+ }
74
+ });
75
+ return { id: spanId };
76
+ } catch (error) {
77
+ (_b = (_a = this.plugin.app.log) == null ? void 0 : _a.warn) == null ? void 0 : _b.call(_a, `[AgentOrchestrator] Failed to update execution span ${spanId}`, error);
78
+ return null;
79
+ }
80
+ }
81
+ async finish(spanId, status, startedAt, values = {}) {
82
+ return this.update(spanId, {
83
+ ...values,
84
+ status,
85
+ endedAt: /* @__PURE__ */ new Date(),
86
+ durationMs: Date.now() - startedAt
87
+ });
88
+ }
89
+ }
90
+ function getOrchestratorTraceContext(ctx) {
91
+ var _a, _b, _c;
92
+ return (ctx == null ? void 0 : ctx[ORCHESTRATOR_TRACE_CONTEXT_KEY]) || ((_a = ctx == null ? void 0 : ctx.state) == null ? void 0 : _a.orchestratorTraceContext) || ((_c = (_b = ctx == null ? void 0 : ctx.runtime) == null ? void 0 : _b.context) == null ? void 0 : _c.orchestratorTraceContext) || null;
93
+ }
94
+ function setOrchestratorTraceContext(ctx, traceContext) {
95
+ ctx[ORCHESTRATOR_TRACE_CONTEXT_KEY] = traceContext;
96
+ return ctx;
97
+ }
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ ExecutionSpanService,
101
+ ORCHESTRATOR_TRACE_CONTEXT_KEY,
102
+ getOrchestratorTraceContext,
103
+ setOrchestratorTraceContext
104
+ });
@@ -0,0 +1,28 @@
1
+ export interface OutputFileInfo {
2
+ name: string;
3
+ size: number;
4
+ mimeType: string;
5
+ }
6
+ export declare class FileManager {
7
+ private storagePath;
8
+ private executionsDir;
9
+ constructor(storagePath: string);
10
+ createExecDir(execId: string): string;
11
+ getExecDir(execId: string): string;
12
+ getOutputDir(execId: string): string;
13
+ /**
14
+ * Returns absolute path to an output file, or null if invalid/not found.
15
+ * Includes path traversal protection.
16
+ */
17
+ getOutputFilePath(execId: string, filename: string): string | null;
18
+ listOutputFiles(execId: string): OutputFileInfo[];
19
+ getTotalOutputSize(execId: string): number;
20
+ /**
21
+ * Remove a specific execution directory by execId.
22
+ */
23
+ removeExecDir(execId: string): void;
24
+ /**
25
+ * Remove execution directories older than maxAgeMs.
26
+ */
27
+ cleanupOlderThan(maxAgeMs: number): number;
28
+ }
@@ -0,0 +1,151 @@
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 FileManager_exports = {};
28
+ __export(FileManager_exports, {
29
+ FileManager: () => FileManager
30
+ });
31
+ module.exports = __toCommonJS(FileManager_exports);
32
+ var import_fs = require("fs");
33
+ var import_path = require("path");
34
+ const MIME_MAP = {
35
+ ".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
36
+ ".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
37
+ ".pdf": "application/pdf",
38
+ ".csv": "text/csv",
39
+ ".json": "application/json",
40
+ ".txt": "text/plain",
41
+ ".png": "image/png",
42
+ ".jpg": "image/jpeg",
43
+ ".jpeg": "image/jpeg",
44
+ ".svg": "image/svg+xml",
45
+ ".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
46
+ ".zip": "application/zip",
47
+ ".html": "text/html",
48
+ ".xml": "application/xml"
49
+ };
50
+ function getMimeType(filename) {
51
+ const ext = filename.substring(filename.lastIndexOf(".")).toLowerCase();
52
+ return MIME_MAP[ext] || "application/octet-stream";
53
+ }
54
+ class FileManager {
55
+ constructor(storagePath) {
56
+ this.storagePath = storagePath;
57
+ this.executionsDir = (0, import_path.resolve)(storagePath, "executions");
58
+ (0, import_fs.mkdirSync)(this.executionsDir, { recursive: true });
59
+ }
60
+ executionsDir;
61
+ createExecDir(execId) {
62
+ const dir = (0, import_path.resolve)(this.executionsDir, execId);
63
+ (0, import_fs.mkdirSync)(dir, { recursive: true });
64
+ (0, import_fs.mkdirSync)((0, import_path.resolve)(dir, "output"), { recursive: true });
65
+ return dir;
66
+ }
67
+ getExecDir(execId) {
68
+ return (0, import_path.resolve)(this.executionsDir, execId);
69
+ }
70
+ getOutputDir(execId) {
71
+ return (0, import_path.resolve)(this.executionsDir, execId, "output");
72
+ }
73
+ /**
74
+ * Returns absolute path to an output file, or null if invalid/not found.
75
+ * Includes path traversal protection.
76
+ */
77
+ getOutputFilePath(execId, filename) {
78
+ const safeBase = (0, import_path.resolve)(this.executionsDir, execId, "output");
79
+ const filePath = (0, import_path.resolve)(safeBase, filename);
80
+ if (!filePath.startsWith(safeBase)) {
81
+ return null;
82
+ }
83
+ if (!(0, import_fs.existsSync)(filePath)) {
84
+ return null;
85
+ }
86
+ return filePath;
87
+ }
88
+ listOutputFiles(execId) {
89
+ const outputDir = this.getOutputDir(execId);
90
+ if (!(0, import_fs.existsSync)(outputDir)) return [];
91
+ try {
92
+ return (0, import_fs.readdirSync)(outputDir).filter((name) => {
93
+ const filePath = (0, import_path.join)(outputDir, name);
94
+ return (0, import_fs.statSync)(filePath).isFile();
95
+ }).map((name) => {
96
+ const filePath = (0, import_path.join)(outputDir, name);
97
+ const stat = (0, import_fs.statSync)(filePath);
98
+ return {
99
+ name,
100
+ size: stat.size,
101
+ mimeType: getMimeType(name)
102
+ };
103
+ });
104
+ } catch {
105
+ return [];
106
+ }
107
+ }
108
+ getTotalOutputSize(execId) {
109
+ const files = this.listOutputFiles(execId);
110
+ return files.reduce((sum, f) => sum + f.size, 0);
111
+ }
112
+ /**
113
+ * Remove a specific execution directory by execId.
114
+ */
115
+ removeExecDir(execId) {
116
+ const dirPath = (0, import_path.resolve)(this.executionsDir, execId);
117
+ if ((0, import_fs.existsSync)(dirPath)) {
118
+ try {
119
+ (0, import_fs.rmSync)(dirPath, { recursive: true, force: true });
120
+ } catch {
121
+ }
122
+ }
123
+ }
124
+ /**
125
+ * Remove execution directories older than maxAgeMs.
126
+ */
127
+ cleanupOlderThan(maxAgeMs) {
128
+ if (!(0, import_fs.existsSync)(this.executionsDir)) return 0;
129
+ let cleaned = 0;
130
+ const now = Date.now();
131
+ try {
132
+ for (const dir of (0, import_fs.readdirSync)(this.executionsDir)) {
133
+ const dirPath = (0, import_path.resolve)(this.executionsDir, dir);
134
+ try {
135
+ const stat = (0, import_fs.statSync)(dirPath);
136
+ if (stat.isDirectory() && now - stat.mtimeMs > maxAgeMs) {
137
+ (0, import_fs.rmSync)(dirPath, { recursive: true, force: true });
138
+ cleaned++;
139
+ }
140
+ } catch {
141
+ }
142
+ }
143
+ } catch {
144
+ }
145
+ return cleaned;
146
+ }
147
+ }
148
+ // Annotate the CommonJS export names for ESM import in node:
149
+ 0 && (module.exports = {
150
+ FileManager
151
+ });
@@ -0,0 +1,41 @@
1
+ import { FileManager, OutputFileInfo } from './FileManager';
2
+ export interface ExecuteOptions {
3
+ language: 'node' | 'python';
4
+ code: string;
5
+ execId: string;
6
+ timeoutSeconds?: number;
7
+ maxOutputSizeMb?: number;
8
+ onProgress?: (progress: ProgressUpdate) => void;
9
+ /** AbortSignal — when aborted, the child process is killed */
10
+ signal?: {
11
+ addEventListener(event: string, listener: () => void): void;
12
+ };
13
+ /** Package whitelist for import validation (from skillWorkerConfigs) */
14
+ packageWhitelist?: string[];
15
+ /** Optional installed/copied skill package root exposed to the runtime as SKILL_DIR. */
16
+ skillDir?: string;
17
+ }
18
+ export interface ProgressUpdate {
19
+ percent: number;
20
+ log: string;
21
+ }
22
+ export interface ExecutionResult {
23
+ success: boolean;
24
+ stdout: string;
25
+ stderr: string;
26
+ files: OutputFileInfo[];
27
+ durationMs: number;
28
+ /** true if execution was canceled by user */
29
+ canceled?: boolean;
30
+ /** true if execution timed out */
31
+ timedOut?: boolean;
32
+ }
33
+ export declare class SandboxRunner {
34
+ private fileManager;
35
+ private logger;
36
+ private storagePath;
37
+ private validator;
38
+ private sandboxWorkspace;
39
+ constructor(fileManager: FileManager, logger: any, storagePath: string);
40
+ execute(options: ExecuteOptions): Promise<ExecutionResult>;
41
+ }