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
package/README.md CHANGED
@@ -1,291 +1,16 @@
1
- # Plugin Agent Orchestrator
2
-
3
- **Hierarchical Multi-Agent Orchestration for NocoBase AI Employees**
4
-
5
- Plugin này cho phép các AI Employee trong NocoBase hoạt động theo mô hình **Leader ↔ Sub-Agent**: một AI Employee (Leader) có thể tự động ủy thác (delegate) nhiệm vụ cho các AI Employee khác (Sub-Agent) để xử lý các tác vụ chuyên biệt — tất cả mà không cần sửa đổi core `plugin-ai`.
6
-
7
- ---
8
-
9
- ## Tính năng chính
10
-
11
- ### 🏗️ Hierarchical Delegation (Ủy thác phân cấp)
12
- - **Leader** nhận yêu cầu từ user phân tích → gọi Sub-Agent phù hợp qua tool call
13
- - Mỗi Sub-Agent được đăng như một tool riêng (ví dụ: `delegate_to_sql_expert`)
14
- - LLM tự chọn Sub-Agent phù hợp nhất dựa trên mô tả của từng agent
15
-
16
- ### 🔄 Depth Control (Kiểm soát độ sâu)
17
- - Giới hạn số lớp delegation (ví dụ: `maxDepth: 1` = Leader gọi Sub-Agent, Sub-Agent không được gọi tiếp)
18
- - Ngăn chặn vòng lặp vô hạn (circular delegation) — các tool `delegate_to_*` tự động bị loại khỏi Sub-Agent
19
-
20
- ### ⏱️ Timeout & Abort
21
- - Mỗi rule cấu hình thời gian chờ tối đa (mặc định 120s)
22
- - Khi timeout, stream LLM bị hủy ngay lập tức qua `AbortController` — không tốn thêm token
23
-
24
- ### 🛡️ Per-Leader Scoping
25
- - Chỉ Leader được cấu hình mới có thể gọi Sub-Agent tương ứng
26
- - Kiểm tra tại thời điểm invoke — không phụ thuộc vào core API
27
-
28
- ### 📊 Swarm Tracing (Giám sát)
29
- - Ghi log mỗi lần delegation: ai gọi ai, task gì, kết quả ra sao, mất bao lâu
30
- - Trang admin trực quan để theo dõi và debug multi-agent flows
31
-
32
- ### 🔌 Zero Core Modification
33
- - Chỉ sử dụng **public APIs** từ `@nocobase/ai` và `@nocobase/plugin-ai`
34
- - Không import private classes, không patch core code
35
- - Tương thích NocoBase 2.x — upgrade-safe
36
-
37
- ---
38
-
39
- ## 📐 Kiến trúc
40
-
41
- ```
42
- ┌──────────────────────────────────────────────────────────┐
43
- │ User Chat Session │
44
- │ "Hãy phân tích doanh thu Q4 và tạo báo cáo" │
45
- └─────────────────────┬────────────────────────────────────┘
46
-
47
-
48
- ┌──────────────────────────────────────────────────────────┐
49
- │ Leader AI Employee (ví dụ: "Project Manager") │
50
- │ │
51
- │ Tools available: │
52
- │ ├── delegate_to_sql_expert ← plugin-agent-orch │
53
- │ ├── delegate_to_report_writer ← plugin-agent-orch │
54
- │ └── other_skills ← plugin-ai built-in │
55
- └────┬─────────────────────┬───────────────────────────────┘
56
- │ tool_call │ tool_call
57
- ▼ ▼
58
- ┌────────────────┐ ┌─────────────────┐
59
- │ SQL Expert │ │ Report Writer │
60
- │ (Sub-Agent) │ │ (Sub-Agent) │
61
- │ │ │ │
62
- │ createReact │ │ createReact │
63
- │ Agent + tools │ │ Agent + tools │
64
- └───────┬────────┘ └────────┬────────┘
65
- │ result │ result
66
- └─────────┬───────────┘
67
-
68
- ┌──────────────────────────────────────────────────────────┐
69
- │ Leader tổng hợp kết quả → trả lời user │
70
- └──────────────────────────────────────────────────────────┘
71
- ```
72
-
73
- ---
74
-
75
- ## 🚀 Cài đặt & Kích hoạt
76
-
77
- ### Yêu cầu
78
- - NocoBase `>= 2.0`
79
- - Plugin `@nocobase/plugin-ai` đã kích hoạt
80
- - Ít nhất 2 AI Employees đã được tạo (1 Leader, 1+ Sub-Agent)
81
-
82
- ### Bước 1: Cài đặt plugin
83
- ```bash
84
- # Trong monorepo NocoBase
85
- yarn build plugin-agent-orchestrator
86
- ```
87
-
88
- ### Bước 2: Kích hoạt
89
- Vào **Settings → Plugin Manager** → tìm "Agent Orchestrator" → **Enable**
90
-
91
- ### Bước 3: Cấu hình
92
- Sau khi kích hoạt, vào **Settings → AI → Agent Orchestrator**
93
-
94
- ---
95
-
96
- ## 📖 Hướng dẫn sử dụng
97
-
98
- ### Tab 1: Orchestration Rules
99
-
100
- Đây là nơi cấu hình quan hệ Leader ↔ Sub-Agent.
101
-
102
- #### Tạo rule mới
103
- 1. Nhấn **New Rule**
104
- 2. Chọn **Leader (Orchestrator)**: AI Employee đóng vai trò điều phối
105
- 3. Chọn **Sub-Agent**: AI Employee sẽ nhận nhiệm vụ được ủy thác
106
- 4. Cấu hình:
107
- - **Max Delegation Depth**: Độ sâu tối đa (1-3)
108
- - `1` = Leader gọi Sub-Agent, Sub-Agent chỉ dùng tool của mình
109
- - `2` = Sub-Agent có thể gọi tiếp Sub-Agent khác (nếu được cấu hình)
110
- - **Timeout (ms)**: Thời gian chờ tối đa
111
- - `120000` (2 phút) — khuyến nghị cho tác vụ đơn giản
112
- - `300000` (5 phút) — cho tác vụ phức tạp
113
- - **Enabled**: Bật/tắt rule
114
- 5. Nhấn **Save**
115
-
116
- #### Ví dụ cấu hình
117
-
118
- | Leader | Sub-Agent | Max Depth | Timeout | Mô tả |
119
- |--------|-----------|-----------|---------|-------|
120
- | PM Bot | SQL Expert | 1 | 120s | PM giao truy vấn DB cho SQL Expert |
121
- | PM Bot | Report Writer | 1 | 300s | PM giao viết báo cáo |
122
- | PM Bot | Code Reviewer | 1 | 180s | PM giao review code |
123
-
124
- > **Lưu ý**: Leader và Sub-Agent không được trùng nhau. Một Sub-Agent có thể phục vụ nhiều Leader.
125
-
126
- ### Tab 2: Swarm Tracing
127
-
128
- Trang giám sát hiển thị log tất cả các lần delegation:
129
-
130
- | Cột | Mô tả |
131
- |-----|-------|
132
- | **Time** | Thời điểm thực thi |
133
- | **Sub-Agent** | Agent được gọi |
134
- | **Task** | Mô tả nhiệm vụ |
135
- | **Status** | ✅ success hoặc ❌ error |
136
- | **Duration** | Thời gian thực thi |
137
- | **Depth** | Độ sâu delegation (0 = cấp đầu tiên) |
138
-
139
- Nhấn **Detail** để xem chi tiết: task gốc, kết quả đầy đủ, lỗi (nếu có).
140
-
141
- ---
142
-
143
- ## 💡 Best Practices
144
-
145
- ### 1. Thiết kế Agent hiệu quả
146
-
147
- ```
148
- ✅ NÊN: Mỗi Sub-Agent chuyên một lĩnh vực rõ ràng
149
- - "SQL Query Expert" — chỉ chạy truy vấn
150
- - "Document Writer" — chỉ viết tài liệu
151
-
152
- ❌ KHÔNG NÊN: Sub-Agent làm quá nhiều việc
153
- - "General Assistant" — quá rộng, Leader không biết khi nào nên gọi
154
- ```
155
-
156
- ### 2. System Prompt cho Leader
157
-
158
- Thêm hướng dẫn trong system prompt của Leader để nó biết khi nào nên delegate:
159
-
160
- ```
161
- Bạn là Project Manager. Khi nhận yêu cầu:
162
- - Cần truy vấn database → delegate cho SQL Expert
163
- - Cần viết báo cáo → delegate cho Report Writer
164
- - Có thể tự trả lời → trả lời trực tiếp
165
-
166
- KHÔNG BAO GIỜ tự viết SQL. Luôn delegate cho SQL Expert.
167
- ```
168
-
169
- ### 3. Bio/About cho Sub-Agent
170
-
171
- Viết mô tả rõ ràng trong trường `About` của Sub-Agent — nội dung này được LLM đọc để quyết định có gọi agent đó không:
172
-
173
- ```
174
- Chuyên gia truy vấn PostgreSQL. Có khả năng:
175
- - Viết và tối ưu SQL queries
176
- - Phân tích schema và index
177
- - Giải thích execution plan
178
- Không xử lý: tạo báo cáo, viết code ứng dụng.
179
- ```
180
-
181
- ### 4. Timeout hợp lý
182
-
183
- | Loại tác vụ | Timeout khuyến nghị |
184
- |-------------|---------------------|
185
- | Truy vấn DB đơn giản | 30s - 60s |
186
- | Phân tích dữ liệu | 120s |
187
- | Viết tài liệu dài | 300s |
188
- | Tác vụ phức tạp + tool calls | 300s - 600s |
189
-
190
- ---
191
-
192
- ## 🔧 Chi tiết kỹ thuật
193
-
194
- ### Collections
195
-
196
- | Collection | Mục đích |
197
- |------------|----------|
198
- | `orchestratorConfig` | Lưu rules Leader ↔ Sub-Agent |
199
- | `orchestratorLogs` | Lưu log delegation (cho Tracing) |
200
-
201
- ### APIs
202
-
203
- | Endpoint | Mô tả |
204
- |----------|-------|
205
- | `orchestratorConfig:list` | Danh sách rules |
206
- | `orchestratorConfig:create` | Tạo rule mới |
207
- | `orchestratorConfig:update` | Cập nhật rule |
208
- | `orchestratorConfig:destroy` | Xóa rule |
209
- | `orchestratorTracing:list` | Danh sách log delegation |
210
- | `orchestratorTracing:get` | Chi tiết một log |
211
-
212
- ### Execution Flow
213
-
214
- ```
215
- 1. Plugin load
216
- └─ registerDynamicTools() → đăng ký delegate_to_* tools vào core toolsManager
217
-
218
- 2. User chat với Leader
219
- └─ Leader LLM nhận tool list (bao gồm delegate_to_*)
220
- └─ LLM quyết định gọi delegate_to_sql_expert({ task: "..." })
221
-
222
- 3. Tool invoke
223
- ├─ Check per-leader scoping (allowedLeaders)
224
- ├─ Check depth limit (ORCHESTRATOR_DEPTH_KEY)
225
- ├─ Resolve LLM model từ Sub-Agent's modelSettings
226
- ├─ Resolve tools từ Sub-Agent's skillSettings
227
- ├─ createReactAgent({ llm, tools })
228
- ├─ executor.stream({ messages: [system, human] }, { signal })
229
- ├─ Collect AI response chunks
230
- ├─ Log to orchestratorLogs
231
- └─ Return result to Leader
232
-
233
- 4. Leader tổng hợp và trả lời user
234
- ```
235
-
236
- ### Dependencies
237
-
238
- | Package | Version | Mục đích |
239
- |---------|---------|----------|
240
- | `@langchain/core` | ^0.3.0 | DynamicStructuredTool, Messages |
241
- | `@langchain/langgraph` | ^0.2.0 | createReactAgent |
242
- | `zod` | ^3.23.0 | Tool schema validation |
243
-
244
- ---
245
-
246
- ## 📁 Cấu trúc project
247
-
248
- ```
249
- plugin-agent-orchestrator/
250
- ├── package.json
251
- ├── README.md
252
- ├── src/
253
- │ ├── index.ts
254
- │ ├── client/
255
- │ │ ├── index.tsx
256
- │ │ ├── plugin.tsx # Đăng ký settings page
257
- │ │ ├── AIEmployeesContext.tsx # Shared context (P3 optimization)
258
- │ │ ├── AIEmployeeSelect.tsx # Reusable select component
259
- │ │ ├── OrchestratorSettings.tsx # Main settings page
260
- │ │ ├── RulesTab.tsx # CRUD rules
261
- │ │ └── TracingTab.tsx # Tracing dashboard
262
- │ ├── server/
263
- │ │ ├── index.ts
264
- │ │ ├── plugin.ts # Main server plugin
265
- │ │ ├── collections/
266
- │ │ │ ├── orchestrator-config.ts
267
- │ │ │ └── orchestrator-logs.ts
268
- │ │ ├── resources/
269
- │ │ │ └── tracing.ts # Custom read-only resource
270
- │ │ └── tools/
271
- │ │ └── delegate-task.ts # Core delegation logic
272
- │ └── locale/
273
- │ ├── en-US.json
274
- │ └── vi-VN.json
275
- ```
276
-
277
- ---
278
-
279
- ## ⚠️ Lưu ý quan trọng
280
-
281
- 1. **Không sửa core plugin-ai**: Plugin này hoàn toàn standalone, chỉ dùng public APIs
282
- 2. **Sub-Agent cần có LLM model**: Mỗi Sub-Agent phải được cấu hình `modelSettings` (llmService + model) trong AI Employee settings
283
- 3. **Sub-Agent cần có skills**: Tools/skills được gán cho Sub-Agent trong `skillSettings` sẽ được cấp cho nó khi thực thi delegation
284
- 4. **Circular prevention**: Các tool `delegate_to_*` tự động bị loại khỏi Sub-Agent → Sub-Agent không thể gọi lại Leader
285
- 5. **Log retention**: `orchestratorLogs` tích lũy theo thời gian — cân nhắc cleanup định kỳ cho production
286
-
287
- ---
288
-
289
- ## 📜 License
290
-
291
- Apache-2.0
1
+ # plugin-agent-orchestrator
2
+
3
+ ## Overview
4
+ Hierarchical Multi-Agent orchestration for NocoBase AI Employees. Enables Leader agents to delegate tasks to Sub-Agent employees without modifying core plugin-ai.
5
+
6
+ ## Features
7
+ - **Hierarchical Delegation**: Allows AI Leader agents to break down complex tasks and assign them to specialized sub-agents.
8
+ - **Seamless Integration**: Plugs directly into the existing AI Employee framework.
9
+ - **Execution Tracking**: Monitor sub-agent task execution and responses within the main chat interface.
10
+
11
+ ## Usage
12
+ 1. Enable the plugin in the NocoBase Plugin Manager.
13
+ 2. Navigate to the AI Employee configuration page.
14
+ 3. Configure a primary "Leader" agent.
15
+ 4. Add available "Sub-Agents" as tools or skills to the Leader agent.
16
+ 5. Interact with the Leader agent; it will automatically delegate tasks when necessary.
@@ -3,15 +3,22 @@ interface AIEmployeeInfo {
3
3
  username: string;
4
4
  nickname: string;
5
5
  about?: string;
6
+ skills: string[];
6
7
  }
7
8
  interface AIEmployeesContextType {
8
9
  employees: AIEmployeeInfo[];
9
10
  employeeMap: Map<string, string>;
11
+ skillsMap: Map<string, Set<string>>;
10
12
  loading: boolean;
13
+ refresh: () => void;
11
14
  }
12
15
  /**
13
16
  * P3 FIX: Shared context provider that fetches aiEmployees once
14
17
  * and shares the data across RulesTab, TracingTab, and AIEmployeeSelect.
18
+ *
19
+ * Also exposes each employee's configured skills so RulesTab can warn when
20
+ * a delegation rule exists but the leader hasn't added the corresponding
21
+ * delegate_<leader>_to_<sub> tool to its skillSettings.
15
22
  */
16
23
  export declare const AIEmployeesProvider: React.FC<{
17
24
  children: React.ReactNode;
@@ -1,2 +1,3 @@
1
1
  import React from 'react';
2
- export declare const OrchestratorSettings: React.FC;
2
+ declare const OrchestratorSettings: React.FC;
3
+ export { OrchestratorSettings };