plugin-agent-orchestrator 1.1.8 → 1.2.1

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 (495) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +207 -204
  3. package/client-v2.d.ts +2 -2
  4. package/client-v2.js +1 -1
  5. package/client.d.ts +2 -2
  6. package/client.js +1 -1
  7. package/dist/client/117.6c69b6a87751dd18.js +10 -0
  8. package/dist/client/253.52f62e1bc0e9520a.js +10 -0
  9. package/dist/client/325.8f7f509bdb35e142.js +10 -0
  10. package/dist/client/404.86593f98c9768ed5.js +10 -0
  11. package/dist/client/453.fa2d169576262213.js +10 -0
  12. package/dist/client/53.567db3ae078650c6.js +10 -0
  13. package/dist/client/619.01713281e5e951d3.js +10 -0
  14. package/dist/client/652.69da1598312b3a3f.js +10 -0
  15. package/dist/client/773.648965568ff476f9.js +10 -0
  16. package/dist/client/981.37e7aeecdb1ef6fa.js +10 -0
  17. package/dist/client/993.ac89f3852990918d.js +10 -0
  18. package/dist/client/index.js +1 -1
  19. package/dist/client-v2/117.c982d79ff68738f5.js +10 -0
  20. package/dist/client-v2/214.94c4257bf2838577.js +10 -0
  21. package/dist/client-v2/253.8e19956d2a44dfb8.js +10 -0
  22. package/dist/client-v2/264.80e8e358c8c6c2e5.js +10 -0
  23. package/dist/client-v2/325.fafe5a6e83ba9cb3.js +10 -0
  24. package/dist/client-v2/404.ab032b79c95dab6f.js +10 -0
  25. package/dist/client-v2/{41.3deb9e57a0f64fc4.js → 41.cd5610fcf7446127.js} +1 -1
  26. package/dist/client-v2/453.42c6d70628d56cc2.js +10 -0
  27. package/dist/client-v2/{53.349fff8db80b19d4.js → 53.37c08089a648f89a.js} +1 -1
  28. package/dist/client-v2/{619.0a2144aaffefe018.js → 619.6e9618550101e819.js} +1 -1
  29. package/dist/client-v2/652.eeba4e0c38367321.js +10 -0
  30. package/dist/client-v2/{70.ffff2997c10fd4b0.js → 70.332698e53eb59677.js} +1 -1
  31. package/dist/client-v2/773.4de2ba5acb07318c.js +10 -0
  32. package/dist/client-v2/981.76060f466e6f7c11.js +10 -0
  33. package/dist/client-v2/993.f8cdb5172566ce75.js +10 -0
  34. package/dist/client-v2/index.js +1 -1
  35. package/dist/externalVersion.js +13 -7
  36. package/dist/locale/en-US.json +308 -1
  37. package/dist/locale/vi-VN.json +5 -1
  38. package/dist/locale/zh-CN.json +308 -1
  39. package/dist/node_modules/acorn/LICENSE +21 -0
  40. package/dist/node_modules/acorn/bin/acorn +4 -0
  41. package/dist/node_modules/acorn/dist/acorn.d.mts +857 -0
  42. package/dist/node_modules/acorn/dist/acorn.d.ts +857 -0
  43. package/dist/node_modules/acorn/dist/acorn.js +1 -0
  44. package/dist/node_modules/acorn/dist/bin.js +90 -0
  45. package/dist/node_modules/acorn/package.json +1 -0
  46. package/dist/node_modules/acorn-walk/LICENSE +21 -0
  47. package/dist/node_modules/acorn-walk/dist/walk.d.mts +177 -0
  48. package/dist/node_modules/acorn-walk/dist/walk.d.ts +177 -0
  49. package/dist/node_modules/acorn-walk/dist/walk.js +1 -0
  50. package/dist/node_modules/acorn-walk/node_modules/.bin/acorn +15 -0
  51. package/dist/node_modules/acorn-walk/node_modules/.bin/acorn.cmd +7 -0
  52. package/dist/node_modules/acorn-walk/node_modules/acorn/bin/acorn +4 -0
  53. package/dist/node_modules/acorn-walk/node_modules/acorn/dist/acorn.d.mts +866 -0
  54. package/dist/node_modules/acorn-walk/node_modules/acorn/dist/acorn.d.ts +866 -0
  55. package/dist/node_modules/acorn-walk/node_modules/acorn/dist/acorn.js +6174 -0
  56. package/dist/node_modules/acorn-walk/node_modules/acorn/dist/bin.js +90 -0
  57. package/dist/node_modules/acorn-walk/node_modules/acorn/package.json +50 -0
  58. package/dist/node_modules/acorn-walk/package.json +1 -0
  59. package/dist/node_modules/adm-zip/adm-zip.js +1 -1
  60. package/dist/node_modules/adm-zip/package.json +1 -1
  61. package/dist/node_modules/ajv/package.json +1 -1
  62. package/dist/node_modules/zod/index.cjs +1 -1
  63. package/dist/node_modules/zod/package.json +1 -1
  64. package/dist/server/collections/agent-auto-approval-checkpoints.js +47 -0
  65. package/dist/server/collections/agent-execution-spans.js +148 -9
  66. package/dist/server/collections/agent-governance-audit-events.js +47 -0
  67. package/dist/server/collections/agent-governance-policies.js +47 -0
  68. package/dist/server/collections/agent-governance-policy-versions.js +48 -0
  69. package/dist/server/collections/agent-governance-prompt-bindings.js +50 -0
  70. package/dist/server/collections/agent-hierarchy-invocations.js +59 -0
  71. package/dist/server/collections/agent-loop-runs.js +23 -5
  72. package/dist/server/collections/agent-routing-graph-locks.js +40 -0
  73. package/dist/server/collections/agent-session-auto-approvals.js +45 -0
  74. package/dist/server/collections/orchestrator-config.js +17 -0
  75. package/dist/server/migrations/20261110000000-add-usage-pricing-snapshots.js +117 -0
  76. package/dist/server/migrations/20261110010000-add-usage-department-attribution.js +54 -0
  77. package/dist/server/migrations/20261119000000-widen-native-employee-identifiers.js +59 -0
  78. package/dist/server/plugin.js +169 -33
  79. package/dist/server/resources/agent-auto-approval.js +80 -0
  80. package/dist/server/resources/agent-governance.js +192 -0
  81. package/dist/server/resources/agent-harness-profile.js +11 -3
  82. package/dist/server/resources/agent-monitor.js +109 -339
  83. package/dist/server/resources/agent-usage.js +423 -0
  84. package/dist/server/resources/hierarchical-routing.js +60 -0
  85. package/dist/server/resources/native-monitor-format.js +179 -0
  86. package/dist/server/resources/tracing.js +35 -12
  87. package/dist/server/services/AgentGovernanceService.js +500 -0
  88. package/dist/server/services/AutoApprovalCheckpoint.js +133 -0
  89. package/dist/server/services/CodeValidator.js +8 -4
  90. package/dist/server/services/DepartmentAttribution.js +65 -0
  91. package/dist/server/services/ExecutionSpanService.js +96 -3
  92. package/dist/server/services/GovernanceAdmission.js +271 -0
  93. package/dist/server/services/HarnessCapabilities.js +118 -0
  94. package/dist/server/services/HarnessCompiler.js +3 -0
  95. package/dist/server/services/HarnessSchema.js +13 -1
  96. package/dist/server/services/HierarchicalAgentRuntime.js +925 -0
  97. package/dist/server/services/HierarchyEnrollmentGuard.js +216 -0
  98. package/dist/server/services/HierarchyInvocationJournal.js +157 -0
  99. package/dist/server/services/HierarchyRequestCancellation.js +150 -0
  100. package/dist/server/services/LoopBudgetService.js +29 -11
  101. package/dist/server/services/LoopRunRepository.js +16 -7
  102. package/dist/server/services/LoopRunStateMachine.js +20 -9
  103. package/dist/server/services/LoopTriggerService.js +1 -1
  104. package/dist/server/services/LoopWorkerService.js +71 -37
  105. package/dist/server/services/ManagedPromptProtection.js +99 -0
  106. package/dist/server/services/NativeAgentMonitorSyncService.js +584 -0
  107. package/dist/server/services/NativeSubAgentObserver.js +141 -508
  108. package/dist/server/services/NativeUsageAttribution.js +97 -0
  109. package/dist/server/services/PluginAiRuntimeAdapter.js +107 -9
  110. package/dist/server/services/RoutingBindingRepository.js +156 -0
  111. package/dist/server/services/RoutingBindingValidation.js +161 -0
  112. package/dist/server/services/SandboxRunner.js +19 -0
  113. package/dist/server/services/SessionAutoApproval.js +173 -0
  114. package/dist/server/services/TokenTracker.js +787 -104
  115. package/dist/server/services/TracingRetentionPolicy.js +66 -0
  116. package/dist/server/services/VerificationService.js +20 -10
  117. package/dist/server/skill-hub/plugin.js +17 -0
  118. package/dist/server/skill-hub/sandbox-config.json +6 -6
  119. package/dist/server/skill-hub/services/RegistrySkillInstallationService.js +2 -2
  120. package/dist/server/skill-hub/services/registry-node-package.js +191 -0
  121. package/dist/server/skill-hub/tasks/SkillExecutionTask.js +21 -6
  122. package/dist/server/tools/skill-execute.js +1 -0
  123. package/dist/server/utils/ensure-indexes.js +15 -5
  124. package/package.json +66 -53
  125. package/server.d.ts +2 -2
  126. package/server.js +1 -1
  127. package/src/client/AgentRunsTab.tsx +2 -2
  128. package/src/client/ApprovalsTab.tsx +2 -2
  129. package/src/client/HarnessProfilesTab.tsx +2 -2
  130. package/src/client/OrchestratorSettings.tsx +152 -152
  131. package/src/client/SkillPages.tsx +34 -0
  132. package/src/client/__tests__/embedded-settings.test.tsx +225 -0
  133. package/src/client/hooks/useRunEventStream.ts +76 -76
  134. package/src/client/index.tsx +2 -2
  135. package/src/client/plugin.tsx +71 -33
  136. package/src/client/skill-hub/components/ExecutionHistory.tsx +200 -200
  137. package/src/client/skill-hub/components/GitSkillImport.tsx +562 -562
  138. package/src/client/skill-hub/components/LoopSettings.tsx +331 -331
  139. package/src/client/skill-hub/components/SkillEditor.tsx +460 -460
  140. package/src/client/skill-hub/components/SkillManager.tsx +194 -194
  141. package/src/client/skill-hub/components/SkillMetrics.tsx +162 -162
  142. package/src/client/skill-hub/components/SkillTestPanel.tsx +141 -141
  143. package/src/client/skill-hub/index.tsx +6 -6
  144. package/src/client/skill-hub/locale.ts +16 -16
  145. package/src/client/skill-hub/tools/InteractionSchemasProvider.tsx +147 -132
  146. package/src/client/skill-hub/tools/SkillHubCard.tsx +110 -104
  147. package/src/client/skill-hub/tools/__tests__/skill-hub-card.test.tsx +255 -0
  148. package/src/client/skill-hub/tools/loopTemplates.ts +52 -52
  149. package/src/client/skill-hub/tools/registerSkillLoopCards.ts +80 -71
  150. package/src/client/skill-hub/utils/jsonFields.ts +41 -41
  151. package/src/client-v2/__tests__/embedded-settings.test.tsx +202 -0
  152. package/src/client-v2/__tests__/hierarchical-routing-settings.test.tsx +350 -0
  153. package/src/client-v2/auto-approval/AutoApprovalBridge.tsx +513 -0
  154. package/src/client-v2/auto-approval/AutoApprovalProvider.tsx +399 -0
  155. package/src/client-v2/auto-approval/__tests__/session-auto-approval.test.tsx +1676 -0
  156. package/src/client-v2/components/AIEmployeeSelect.tsx +47 -47
  157. package/src/client-v2/components/AIEmployeesContext.tsx +97 -97
  158. package/src/client-v2/components/AgentBindingsTab.tsx +541 -269
  159. package/src/client-v2/components/AgentRunsTab.tsx +85 -83
  160. package/src/client-v2/components/ApprovalsTab.tsx +337 -337
  161. package/src/client-v2/components/EmployeeGovernanceTab.tsx +695 -0
  162. package/src/client-v2/components/HarnessProfilesTab.tsx +700 -541
  163. package/src/client-v2/components/HarnessSettingsForm.tsx +221 -0
  164. package/src/client-v2/components/KnowledgeAccessTab.tsx +116 -116
  165. package/src/client-v2/components/RetrievalTraceTab.tsx +162 -162
  166. package/src/client-v2/components/UsageGovernanceTab.tsx +379 -0
  167. package/src/client-v2/index.tsx +1 -1
  168. package/src/client-v2/pages/AgentBindingsPage.tsx +15 -13
  169. package/src/client-v2/pages/ApprovalsPage.tsx +12 -10
  170. package/src/client-v2/pages/EmployeeGovernancePage.tsx +15 -0
  171. package/src/client-v2/pages/ExecutionHistoryPage.tsx +12 -10
  172. package/src/client-v2/pages/HarnessProfilesPage.tsx +12 -10
  173. package/src/client-v2/pages/KnowledgeAccessPage.tsx +12 -10
  174. package/src/client-v2/pages/LoopSettingsPage.tsx +12 -10
  175. package/src/client-v2/pages/MemoryInspectorPage.tsx +15 -13
  176. package/src/client-v2/pages/RetrievalTracePage.tsx +12 -10
  177. package/src/client-v2/pages/RulesPage.tsx +15 -13
  178. package/src/client-v2/pages/SkillDefinitionsPage.tsx +12 -10
  179. package/src/client-v2/pages/SkillMetricsPage.tsx +12 -10
  180. package/src/client-v2/pages/TracingPage.tsx +15 -13
  181. package/src/client-v2/pages/UsageGovernancePage.tsx +15 -0
  182. package/src/client-v2/plugin.tsx +134 -111
  183. package/src/client-v2/skill-hub/components/ExecutionHistory.tsx +196 -196
  184. package/src/client-v2/skill-hub/components/FileLinkList.tsx +37 -37
  185. package/src/client-v2/skill-hub/components/GitSkillImport.tsx +539 -539
  186. package/src/client-v2/skill-hub/components/LoopSettings.tsx +331 -331
  187. package/src/client-v2/skill-hub/components/SkillEditor.tsx +453 -453
  188. package/src/client-v2/skill-hub/components/SkillManager.tsx +191 -174
  189. package/src/client-v2/skill-hub/components/SkillMetrics.tsx +162 -162
  190. package/src/client-v2/skill-hub/components/SkillTestPanel.tsx +135 -135
  191. package/src/client-v2/skill-hub/locale.ts +13 -13
  192. package/src/client-v2/skill-hub/tools/InteractionSchemasProvider.tsx +62 -0
  193. package/src/client-v2/skill-hub/tools/SkillHubCard.tsx +104 -0
  194. package/src/client-v2/skill-hub/tools/__tests__/interactions.test.ts +126 -0
  195. package/src/client-v2/skill-hub/tools/interactions.ts +137 -0
  196. package/src/client-v2/skill-hub/tools/loopTemplates.ts +52 -52
  197. package/src/client-v2/skill-hub/utils/jsonFields.ts +41 -41
  198. package/src/client-v2/utils/jsonFields.ts +41 -41
  199. package/src/index.ts +2 -2
  200. package/src/locale/en-US.json +308 -1
  201. package/src/locale/vi-VN.json +5 -1
  202. package/src/locale/zh-CN.json +308 -1
  203. package/src/server/__tests__/agent-execution-context.test.ts +18 -18
  204. package/src/server/__tests__/agent-governance.integration.test.ts +385 -0
  205. package/src/server/__tests__/agent-knowledge-insights.test.ts +123 -123
  206. package/src/server/__tests__/agent-monitor-acl.integration.test.ts +267 -0
  207. package/src/server/__tests__/agent-registry-service.test.ts +147 -147
  208. package/src/server/__tests__/agent-runtime-lifecycle.test.ts +46 -46
  209. package/src/server/__tests__/agent-usage-report.integration.test.ts +335 -0
  210. package/src/server/__tests__/auto-approval-checkpoint.integration.test.ts +295 -0
  211. package/src/server/__tests__/code-validator.test.ts +63 -63
  212. package/src/server/__tests__/external-rag-search.test.ts +107 -107
  213. package/src/server/__tests__/harness-capabilities.test.ts +88 -0
  214. package/src/server/__tests__/harness-compiler.test.ts +278 -214
  215. package/src/server/__tests__/harness-profile-service.test.ts +167 -167
  216. package/src/server/__tests__/harness-runtime-policy.test.ts +293 -293
  217. package/src/server/__tests__/harness-tool-plan.test.ts +175 -172
  218. package/src/server/__tests__/hierarchical-routing.integration.test.ts +2318 -0
  219. package/src/server/__tests__/hierarchy-invocation-journal.integration.test.ts +119 -0
  220. package/src/server/__tests__/input-schema-validator.test.ts +26 -26
  221. package/src/server/__tests__/loop-approval-decision.test.ts +624 -512
  222. package/src/server/__tests__/loop-approval-expiry.test.ts +258 -258
  223. package/src/server/__tests__/loop-budget-service.test.ts +29 -0
  224. package/src/server/__tests__/loop-pattern-schema.test.ts +73 -73
  225. package/src/server/__tests__/loop-run-repository.test.ts +25 -0
  226. package/src/server/__tests__/loop-run-state-machine.test.ts +101 -101
  227. package/src/server/__tests__/loop-trigger-service.test.ts +185 -148
  228. package/src/server/__tests__/loop-worker-claim.test.ts +110 -10
  229. package/src/server/__tests__/loop-worker-execution.test.ts +375 -317
  230. package/src/server/__tests__/native-agent-monitor-sync.test.ts +343 -0
  231. package/src/server/__tests__/native-hierarchy-probe.integration.test.ts +527 -0
  232. package/src/server/__tests__/native-sub-agent-observer.test.ts +463 -662
  233. package/src/server/__tests__/native-usage-attribution.integration.test.ts +168 -0
  234. package/src/server/__tests__/plugin-ai-runtime-adapter.test.ts +403 -0
  235. package/src/server/__tests__/registry-node-package.test.ts +299 -0
  236. package/src/server/__tests__/routing-binding-graph.integration.test.ts +217 -0
  237. package/src/server/__tests__/routing-binding-validation.test.ts +256 -0
  238. package/src/server/__tests__/session-auto-approval.integration.test.ts +329 -0
  239. package/src/server/__tests__/skill-access-service.test.ts +64 -64
  240. package/src/server/__tests__/skill-execute.test.ts +81 -70
  241. package/src/server/__tests__/skill-execution-task-policy.test.ts +140 -140
  242. package/src/server/__tests__/skill-review-guard.test.ts +171 -0
  243. package/src/server/__tests__/skill-sandbox-worker-mode.test.ts +15 -15
  244. package/src/server/__tests__/skill-settings.test.ts +63 -63
  245. package/src/server/__tests__/skill-tool-name.test.ts +23 -23
  246. package/src/server/__tests__/token-tracker.test.ts +632 -0
  247. package/src/server/__tests__/tool-loop-detection.test.ts +276 -276
  248. package/src/server/__tests__/tracing-retention-policy.test.ts +30 -0
  249. package/src/server/__tests__/usage-ledger.integration.test.ts +187 -0
  250. package/src/server/collections/agent-auto-approval-checkpoints.ts +18 -0
  251. package/src/server/collections/agent-execution-spans.ts +386 -245
  252. package/src/server/collections/agent-governance-audit-events.ts +19 -0
  253. package/src/server/collections/agent-governance-policies.ts +19 -0
  254. package/src/server/collections/agent-governance-policy-versions.ts +20 -0
  255. package/src/server/collections/agent-governance-prompt-bindings.ts +22 -0
  256. package/src/server/collections/agent-hierarchy-invocations.ts +30 -0
  257. package/src/server/collections/agent-loop-action-approvals.ts +39 -39
  258. package/src/server/collections/agent-loop-runs.ts +389 -369
  259. package/src/server/collections/agent-loop-steps.ts +220 -220
  260. package/src/server/collections/agent-memory-contexts.ts +95 -95
  261. package/src/server/collections/agent-routing-graph-locks.ts +11 -0
  262. package/src/server/collections/agent-session-auto-approvals.ts +16 -0
  263. package/src/server/collections/orchestrator-config.ts +113 -87
  264. package/src/server/collections/orchestrator-logs.ts +116 -116
  265. package/src/server/collections/skill-definitions.ts +159 -159
  266. package/src/server/collections/skill-executions.ts +154 -154
  267. package/src/server/collections/skill-loop-configs.ts +65 -65
  268. package/src/server/collections/skill-metrics.ts +36 -36
  269. package/src/server/collections/skill-registry-installations.ts +41 -41
  270. package/src/server/collections/skill-worker-configs.ts +86 -86
  271. package/src/server/index.ts +1 -1
  272. package/src/server/migrations/20260423000000-add-progress-fields.ts +50 -50
  273. package/src/server/migrations/20260425000000-add-interaction-schema.ts +37 -37
  274. package/src/server/migrations/20260427000000-add-tracing-detail-fields.ts +41 -41
  275. package/src/server/migrations/20260427000001-change-other-json-to-text.ts +61 -61
  276. package/src/server/migrations/20260524001000-add-plan-approval-and-harness-profiles.ts +145 -145
  277. package/src/server/migrations/20260601000000-add-token-fields.ts +89 -89
  278. package/src/server/migrations/20260615000000-normalize-ai-employee-tool-bindings.ts +39 -39
  279. package/src/server/migrations/20260621000000-native-policy-profile-defaults.ts +190 -190
  280. package/src/server/migrations/20260727000000-remove-unused-knowledge-scopes.ts +25 -25
  281. package/src/server/migrations/20260727010000-backfill-skill-tool-names.ts +45 -45
  282. package/src/server/migrations/20261110000000-add-usage-pricing-snapshots.ts +110 -0
  283. package/src/server/migrations/20261110010000-add-usage-department-attribution.ts +28 -0
  284. package/src/server/migrations/20261119000000-widen-native-employee-identifiers.ts +37 -0
  285. package/src/server/plugin.ts +724 -573
  286. package/src/server/resources/agent-auto-approval.ts +51 -0
  287. package/src/server/resources/agent-governance.ts +161 -0
  288. package/src/server/resources/agent-harness-profile.ts +103 -94
  289. package/src/server/resources/agent-knowledge-insights.ts +306 -306
  290. package/src/server/resources/agent-loop-approval.ts +84 -84
  291. package/src/server/resources/agent-loop-events-stream.ts +108 -108
  292. package/src/server/resources/agent-loop.ts +252 -252
  293. package/src/server/resources/agent-monitor.ts +208 -482
  294. package/src/server/resources/agent-usage.ts +413 -0
  295. package/src/server/resources/hierarchical-routing.ts +39 -0
  296. package/src/server/resources/native-monitor-format.ts +150 -0
  297. package/src/server/resources/tracing.ts +296 -267
  298. package/src/server/services/AgentExecutionContext.ts +23 -23
  299. package/src/server/services/AgentGovernanceService.ts +541 -0
  300. package/src/server/services/AgentMemoryContextService.ts +344 -344
  301. package/src/server/services/AgentRegistryService.ts +220 -220
  302. package/src/server/services/AgentRuntimeLifecycle.ts +64 -64
  303. package/src/server/services/AutoApprovalCheckpoint.ts +140 -0
  304. package/src/server/services/CodeValidator.ts +257 -238
  305. package/src/server/services/DepartmentAttribution.ts +47 -0
  306. package/src/server/services/DurableCircuitBreakerService.ts +235 -235
  307. package/src/server/services/ExecutionSpanService.ts +271 -146
  308. package/src/server/services/FileManager.ts +159 -159
  309. package/src/server/services/GovernanceAdmission.ts +314 -0
  310. package/src/server/services/HarnessCapabilities.ts +112 -0
  311. package/src/server/services/HarnessCompiler.ts +182 -170
  312. package/src/server/services/HarnessProfileService.ts +235 -235
  313. package/src/server/services/HarnessSchema.ts +224 -194
  314. package/src/server/services/HierarchicalAgentRuntime.ts +1052 -0
  315. package/src/server/services/HierarchyEnrollmentGuard.ts +211 -0
  316. package/src/server/services/HierarchyInvocationJournal.ts +172 -0
  317. package/src/server/services/HierarchyRequestCancellation.ts +132 -0
  318. package/src/server/services/InputSchemaValidator.ts +44 -44
  319. package/src/server/services/LoopBudgetService.ts +325 -271
  320. package/src/server/services/LoopControlService.ts +120 -120
  321. package/src/server/services/LoopPatternSchema.ts +231 -231
  322. package/src/server/services/LoopPatternService.ts +171 -171
  323. package/src/server/services/LoopRunRepository.ts +343 -332
  324. package/src/server/services/LoopRunStateMachine.ts +538 -525
  325. package/src/server/services/LoopSchedulerService.ts +195 -195
  326. package/src/server/services/LoopTriggerService.ts +162 -159
  327. package/src/server/services/LoopWorkerService.ts +975 -912
  328. package/src/server/services/ManagedPromptProtection.ts +81 -0
  329. package/src/server/services/NativeAgentMonitorSyncService.ts +684 -0
  330. package/src/server/services/NativeSubAgentObserver.ts +324 -757
  331. package/src/server/services/NativeUsageAttribution.ts +91 -0
  332. package/src/server/services/PathLockService.ts +317 -317
  333. package/src/server/services/PluginAiRuntimeAdapter.ts +518 -387
  334. package/src/server/services/RoutingBindingRepository.ts +146 -0
  335. package/src/server/services/RoutingBindingValidation.ts +161 -0
  336. package/src/server/services/RunEventBus.ts +58 -58
  337. package/src/server/services/SandboxRunner.ts +526 -492
  338. package/src/server/services/SessionAutoApproval.ts +167 -0
  339. package/src/server/services/SkillAccessService.ts +175 -175
  340. package/src/server/services/SkillManager.ts +585 -585
  341. package/src/server/services/SkillRepositoryService.ts +236 -236
  342. package/src/server/services/TokenTracker.ts +1151 -287
  343. package/src/server/services/ToolLoopDetectionService.ts +210 -210
  344. package/src/server/services/TracingRetentionPolicy.ts +49 -0
  345. package/src/server/services/VerificationSchema.ts +31 -31
  346. package/src/server/services/VerificationService.ts +325 -313
  347. package/src/server/services/WorkerEnvManager.ts +198 -198
  348. package/src/server/services/__tests__/SkillRepositoryService.test.ts +33 -33
  349. package/src/server/services/harness-runtime-policy.ts +134 -134
  350. package/src/server/services/pythonGuardTemplate.ts +87 -87
  351. package/src/server/services/sandboxCapabilities.ts +348 -348
  352. package/src/server/skill-hub/actions/__tests__/git-import.test.ts +563 -563
  353. package/src/server/skill-hub/actions/git-import.ts +936 -936
  354. package/src/server/skill-hub/mcp/McpController.ts +107 -107
  355. package/src/server/skill-hub/middlewares/git-import-request-method-policy.ts +51 -51
  356. package/src/server/skill-hub/plugin.ts +1272 -1232
  357. package/src/server/skill-hub/sandbox-config.json +6 -6
  358. package/src/server/skill-hub/services/RegistrySkillInstallationService.ts +291 -281
  359. package/src/server/skill-hub/services/__tests__/RegistrySkillInstallationService.test.ts +295 -295
  360. package/src/server/skill-hub/services/registry-node-package.ts +191 -0
  361. package/src/server/skill-hub/tasks/SkillExecutionTask.ts +597 -568
  362. package/src/server/skill-hub/utils/json-fields.ts +57 -57
  363. package/src/server/tools/delegate-task.ts +30 -30
  364. package/src/server/tools/external-rag-search.ts +329 -329
  365. package/src/server/tools/skill-execute.ts +226 -216
  366. package/src/server/types.ts +21 -21
  367. package/src/server/utils/ai-manager.ts +24 -24
  368. package/src/server/utils/ctx-utils.ts +132 -132
  369. package/src/server/utils/ensure-indexes.ts +113 -96
  370. package/src/server/utils/ha-lock.ts +80 -80
  371. package/src/server/utils/loop-pattern-context.ts +84 -84
  372. package/src/server/utils/record-utils.ts +19 -19
  373. package/src/server/utils/skill-settings.ts +135 -135
  374. package/src/server/utils/skill-tool-name.ts +58 -58
  375. package/dist/client-v2/117.7565cff57c39318a.js +0 -10
  376. package/dist/client-v2/214.106635011859dede.js +0 -10
  377. package/dist/client-v2/253.59577b40d9875be0.js +0 -10
  378. package/dist/client-v2/264.7ed8bee71fa5935c.js +0 -10
  379. package/dist/client-v2/418.41ed200e7d6da332.js +0 -10
  380. package/dist/client-v2/794.a67a2614405ba627.js +0 -10
  381. package/dist/client-v2/981.e4a1f41cfc94a856.js +0 -10
  382. package/dist/client-v2/993.b0688fdc5ccb000a.js +0 -10
  383. package/dist/node_modules/simple-git/dist/cjs/index.js +0 -7399
  384. package/dist/node_modules/simple-git/dist/esm/index.js +0 -4745
  385. package/dist/node_modules/simple-git/dist/esm/package.json +0 -3
  386. package/dist/node_modules/simple-git/dist/src/lib/api.d.ts +0 -13
  387. package/dist/node_modules/simple-git/dist/src/lib/args/log-format.d.ts +0 -9
  388. package/dist/node_modules/simple-git/dist/src/lib/errors/git-construct-error.d.ts +0 -15
  389. package/dist/node_modules/simple-git/dist/src/lib/errors/git-error.d.ts +0 -30
  390. package/dist/node_modules/simple-git/dist/src/lib/errors/git-plugin-error.d.ts +0 -7
  391. package/dist/node_modules/simple-git/dist/src/lib/errors/git-response-error.d.ts +0 -32
  392. package/dist/node_modules/simple-git/dist/src/lib/errors/task-configuration-error.d.ts +0 -12
  393. package/dist/node_modules/simple-git/dist/src/lib/git-factory.d.ts +0 -15
  394. package/dist/node_modules/simple-git/dist/src/lib/git-logger.d.ts +0 -21
  395. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-branch-delete.d.ts +0 -5
  396. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-branch.d.ts +0 -2
  397. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-commit.d.ts +0 -2
  398. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-diff-summary.d.ts +0 -3
  399. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-fetch.d.ts +0 -2
  400. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-list-log-summary.d.ts +0 -6
  401. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-merge.d.ts +0 -11
  402. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-move.d.ts +0 -2
  403. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-pull.d.ts +0 -6
  404. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-push.d.ts +0 -4
  405. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-remote-messages.d.ts +0 -5
  406. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-remote-objects.d.ts +0 -3
  407. package/dist/node_modules/simple-git/dist/src/lib/plugins/abort-plugin.d.ts +0 -3
  408. package/dist/node_modules/simple-git/dist/src/lib/plugins/block-unsafe-operations-plugin.d.ts +0 -3
  409. package/dist/node_modules/simple-git/dist/src/lib/plugins/command-config-prefixing-plugin.d.ts +0 -2
  410. package/dist/node_modules/simple-git/dist/src/lib/plugins/completion-detection.plugin.d.ts +0 -3
  411. package/dist/node_modules/simple-git/dist/src/lib/plugins/custom-binary.plugin.d.ts +0 -3
  412. package/dist/node_modules/simple-git/dist/src/lib/plugins/error-detection.plugin.d.ts +0 -7
  413. package/dist/node_modules/simple-git/dist/src/lib/plugins/index.d.ts +0 -11
  414. package/dist/node_modules/simple-git/dist/src/lib/plugins/plugin-store.d.ts +0 -11
  415. package/dist/node_modules/simple-git/dist/src/lib/plugins/progress-monitor-plugin.d.ts +0 -3
  416. package/dist/node_modules/simple-git/dist/src/lib/plugins/simple-git-plugin.d.ts +0 -48
  417. package/dist/node_modules/simple-git/dist/src/lib/plugins/spawn-options-plugin.d.ts +0 -3
  418. package/dist/node_modules/simple-git/dist/src/lib/plugins/suffix-paths.plugin.d.ts +0 -2
  419. package/dist/node_modules/simple-git/dist/src/lib/plugins/timout-plugin.d.ts +0 -3
  420. package/dist/node_modules/simple-git/dist/src/lib/responses/BranchDeleteSummary.d.ts +0 -12
  421. package/dist/node_modules/simple-git/dist/src/lib/responses/BranchSummary.d.ts +0 -14
  422. package/dist/node_modules/simple-git/dist/src/lib/responses/CheckIgnore.d.ts +0 -4
  423. package/dist/node_modules/simple-git/dist/src/lib/responses/CleanSummary.d.ts +0 -9
  424. package/dist/node_modules/simple-git/dist/src/lib/responses/ConfigList.d.ts +0 -13
  425. package/dist/node_modules/simple-git/dist/src/lib/responses/DiffSummary.d.ts +0 -10
  426. package/dist/node_modules/simple-git/dist/src/lib/responses/FileStatusSummary.d.ts +0 -9
  427. package/dist/node_modules/simple-git/dist/src/lib/responses/GetRemoteSummary.d.ts +0 -11
  428. package/dist/node_modules/simple-git/dist/src/lib/responses/InitSummary.d.ts +0 -9
  429. package/dist/node_modules/simple-git/dist/src/lib/responses/MergeSummary.d.ts +0 -16
  430. package/dist/node_modules/simple-git/dist/src/lib/responses/PullSummary.d.ts +0 -25
  431. package/dist/node_modules/simple-git/dist/src/lib/responses/StatusSummary.d.ts +0 -19
  432. package/dist/node_modules/simple-git/dist/src/lib/responses/TagList.d.ts +0 -7
  433. package/dist/node_modules/simple-git/dist/src/lib/runners/git-executor-chain.d.ts +0 -25
  434. package/dist/node_modules/simple-git/dist/src/lib/runners/git-executor.d.ts +0 -14
  435. package/dist/node_modules/simple-git/dist/src/lib/runners/promise-wrapped.d.ts +0 -2
  436. package/dist/node_modules/simple-git/dist/src/lib/runners/scheduler.d.ts +0 -11
  437. package/dist/node_modules/simple-git/dist/src/lib/runners/tasks-pending-queue.d.ts +0 -23
  438. package/dist/node_modules/simple-git/dist/src/lib/simple-git-api.d.ts +0 -20
  439. package/dist/node_modules/simple-git/dist/src/lib/task-callback.d.ts +0 -2
  440. package/dist/node_modules/simple-git/dist/src/lib/tasks/apply-patch.d.ts +0 -3
  441. package/dist/node_modules/simple-git/dist/src/lib/tasks/branch.d.ts +0 -7
  442. package/dist/node_modules/simple-git/dist/src/lib/tasks/change-working-directory.d.ts +0 -2
  443. package/dist/node_modules/simple-git/dist/src/lib/tasks/check-ignore.d.ts +0 -2
  444. package/dist/node_modules/simple-git/dist/src/lib/tasks/check-is-repo.d.ts +0 -9
  445. package/dist/node_modules/simple-git/dist/src/lib/tasks/checkout.d.ts +0 -2
  446. package/dist/node_modules/simple-git/dist/src/lib/tasks/clean.d.ts +0 -25
  447. package/dist/node_modules/simple-git/dist/src/lib/tasks/clone.d.ts +0 -9
  448. package/dist/node_modules/simple-git/dist/src/lib/tasks/commit.d.ts +0 -4
  449. package/dist/node_modules/simple-git/dist/src/lib/tasks/config.d.ts +0 -8
  450. package/dist/node_modules/simple-git/dist/src/lib/tasks/count-objects.d.ts +0 -12
  451. package/dist/node_modules/simple-git/dist/src/lib/tasks/diff-name-status.d.ts +0 -12
  452. package/dist/node_modules/simple-git/dist/src/lib/tasks/diff.d.ts +0 -5
  453. package/dist/node_modules/simple-git/dist/src/lib/tasks/fetch.d.ts +0 -4
  454. package/dist/node_modules/simple-git/dist/src/lib/tasks/first-commit.d.ts +0 -2
  455. package/dist/node_modules/simple-git/dist/src/lib/tasks/grep.d.ts +0 -12
  456. package/dist/node_modules/simple-git/dist/src/lib/tasks/hash-object.d.ts +0 -5
  457. package/dist/node_modules/simple-git/dist/src/lib/tasks/init.d.ts +0 -3
  458. package/dist/node_modules/simple-git/dist/src/lib/tasks/log.d.ts +0 -32
  459. package/dist/node_modules/simple-git/dist/src/lib/tasks/merge.d.ts +0 -4
  460. package/dist/node_modules/simple-git/dist/src/lib/tasks/move.d.ts +0 -3
  461. package/dist/node_modules/simple-git/dist/src/lib/tasks/pull.d.ts +0 -3
  462. package/dist/node_modules/simple-git/dist/src/lib/tasks/push.d.ts +0 -9
  463. package/dist/node_modules/simple-git/dist/src/lib/tasks/remote.d.ts +0 -8
  464. package/dist/node_modules/simple-git/dist/src/lib/tasks/reset.d.ts +0 -11
  465. package/dist/node_modules/simple-git/dist/src/lib/tasks/show.d.ts +0 -2
  466. package/dist/node_modules/simple-git/dist/src/lib/tasks/stash-list.d.ts +0 -4
  467. package/dist/node_modules/simple-git/dist/src/lib/tasks/status.d.ts +0 -3
  468. package/dist/node_modules/simple-git/dist/src/lib/tasks/sub-module.d.ts +0 -5
  469. package/dist/node_modules/simple-git/dist/src/lib/tasks/tag.d.ts +0 -18
  470. package/dist/node_modules/simple-git/dist/src/lib/tasks/task.d.ts +0 -14
  471. package/dist/node_modules/simple-git/dist/src/lib/tasks/version.d.ts +0 -9
  472. package/dist/node_modules/simple-git/dist/src/lib/types/handlers.d.ts +0 -21
  473. package/dist/node_modules/simple-git/dist/src/lib/types/index.d.ts +0 -136
  474. package/dist/node_modules/simple-git/dist/src/lib/types/tasks.d.ts +0 -19
  475. package/dist/node_modules/simple-git/dist/src/lib/utils/argument-filters.d.ts +0 -14
  476. package/dist/node_modules/simple-git/dist/src/lib/utils/exit-codes.d.ts +0 -10
  477. package/dist/node_modules/simple-git/dist/src/lib/utils/git-output-streams.d.ts +0 -7
  478. package/dist/node_modules/simple-git/dist/src/lib/utils/index.d.ts +0 -8
  479. package/dist/node_modules/simple-git/dist/src/lib/utils/line-parser.d.ts +0 -15
  480. package/dist/node_modules/simple-git/dist/src/lib/utils/simple-git-options.d.ts +0 -2
  481. package/dist/node_modules/simple-git/dist/src/lib/utils/task-options.d.ts +0 -13
  482. package/dist/node_modules/simple-git/dist/src/lib/utils/task-parser.d.ts +0 -5
  483. package/dist/node_modules/simple-git/dist/src/lib/utils/util.d.ts +0 -47
  484. package/dist/node_modules/simple-git/dist/typings/errors.d.ts +0 -5
  485. package/dist/node_modules/simple-git/dist/typings/index.d.ts +0 -14
  486. package/dist/node_modules/simple-git/dist/typings/response.d.ts +0 -556
  487. package/dist/node_modules/simple-git/dist/typings/simple-git.d.ts +0 -1033
  488. package/dist/node_modules/simple-git/dist/typings/types.d.ts +0 -22
  489. package/dist/node_modules/simple-git/node_modules/debug/package.json +0 -64
  490. package/dist/node_modules/simple-git/node_modules/debug/src/browser.js +0 -272
  491. package/dist/node_modules/simple-git/node_modules/debug/src/common.js +0 -292
  492. package/dist/node_modules/simple-git/node_modules/debug/src/index.js +0 -10
  493. package/dist/node_modules/simple-git/node_modules/debug/src/node.js +0 -263
  494. package/dist/node_modules/simple-git/package.json +0 -1
  495. package/dist/node_modules/simple-git/promise.js +0 -17
package/README.md CHANGED
@@ -1,204 +1,207 @@
1
- # plugin-agent-orchestrator
2
-
3
- ## Overview
4
-
5
- Agent orchestration layer for NocoBase AI Employees (plugin-ai). The plugin provides three main subsystems:
6
-
7
- 1. **Agent Loop Control Plane** — durable, policy-governed multi-step runs with a leader/maker/verifier role model, cron/event/manual triggers, budgets, approvals, and independent verification.
8
- 2. **Harness (Policy Profiles)** — versioned, tag-addressed policy bundles that constrain what each role may do (tools, memory, delegation, limits, isolation, observability), compiled layer-by-layer with most-restrictive-wins semantics.
9
- 3. **Skill Hub** — sandboxed Python/Node.js skills that AI employees can execute as tools, with async execution, human-in-the-loop review, an MCP-style surface, and Git/registry import.
10
-
11
- On top of these, the plugin observes native sub-agent dispatching from plugin-ai, records a unified execution-span tree, injects agent memory context, and exposes an external RAG search tool.
12
-
13
- ## Agent Loop Control Plane
14
-
15
- ### Patterns
16
-
17
- A loop pattern (`agentLoopPatterns`) defines a repeatable unit of autonomous work:
18
-
19
- - `key`, `goalTemplate` — identity and the goal rendered for each run.
20
- - `autonomyLevel` — `L1` (supervised), `L2`, `L3` (autonomous). L2/L3 require repository identity (`repositoryKey`, `repositoryRoot`, `baseRef`, `actingOn[]`) and worktree isolation (`policy.harness.isolation.requireWorktree`).
21
- - `triggerType` — `manual`, `cron` (`cronExpression` + `timezone`), or `event` (`eventKey`).
22
- - Role bindings — `leaderUsername`, `makerUsernames[]`, `verifierUsername` (verifier must differ from leader and makers).
23
- - Per-role harness tags — `leaderHarnessTag` / `makerHarnessTag` (default `default`), `verifierHarnessTag` (default `safe`).
24
- - `policy` — concurrency, per-run/daily budgets (invocations, tool calls, delegations, verifications, tokens, cost), circuit-breaker limits, path restrictions (`maxFiles`, deny list), action approval settings (`autoAllowlist`, approvers, timeout), tool-loop detection thresholds (`warnAt`/`blockAt`/`escalateAt`), and required verification checks.
25
-
26
- ### Run lifecycle
27
-
28
- `LoopTriggerService` compiles the pattern (including layered harness compilation), snapshots role bindings and harness settings onto the run row, and enqueues it. `LoopWorkerService` claims queued runs with a lease + heartbeat, acquires path locks on `actingOn`, then drives the run:
29
-
30
- `queued → preparing → waiting_lock → running → waiting_approval → verifying → waiting_human → succeeded | failed | canceled` (plus `paused`, `blocked`).
31
-
32
- - **Leader** invocation plans the work but changes nothing.
33
- - **Maker** invocations execute the plan, each under its own compiled harness.
34
- - Tool calls gated as `ask` park the run in `waiting_approval` until the approval row is resolved via `agentLoopApprovals:decide` (approve — optionally substituting an edited input — or reject).
35
- - **Tool-loop detection** (`ToolLoopDetectionService`, active in both worker and verifier) guards against repeated identical tool calls: `warnAt` injects a notice into the run, `blockAt` refuses the call, `escalateAt` escalates the run for human review.
36
- - **Verifier** (via `VerificationService`) runs an independent pass and returns a JSON verdict: `pass` → `succeeded` (L1) or `waiting_human` (L2/L3); `reject` → `failed`; `escalate` → `waiting_human`. Required checks and artifact evidence ownership are enforced.
37
-
38
- Human actions on runs: pause, resume, cancel, retry, escalate, accept result. Budgets, circuit-breaker state, usage buckets, events, steps, artifacts, and worktrees are persisted in dedicated collections.
39
-
40
- ### Sub-agent observation and memory
41
-
42
- - `NativeSubAgentObserver` wraps plugin-ai's native `dispatch-sub-agent-task` flow: it resolves harness policy, injects memory context into the delegated question, records root/tool spans in `agentExecutionSpans`, tracks tokens/cost, and links skill executions. Legacy `delegate_*` / `dispatch_subagents_*` tools are retired.
43
- - `AgentMemoryContextService` builds an `<agent_memory_context>` block from `agentMemoryContexts` records (scopes `public`, `user`, `agent_user`, plus plugin-user-memory content), trimmed to the harness-configured character limit.
44
- - `AgentRegistryService` resolves leader↔sub-agent bindings from `orchestratorConfig`, model overrides, and alternative sub-agents for retry.
45
-
46
- ## Harness (Policy Profiles)
47
-
48
- A harness profile is a versioned policy bundle addressed by a unique `tag`. Settings (validated by a strict zod schema in `HarnessSchema.ts`) have six sections:
49
-
50
- | Section | Controls |
51
- | --- | --- |
52
- | `tools` | `allow` / `ask` / `deny` lists, per-tool `effects` (`read` / `write` / `external`), `trustedPreHandlerTools` |
53
- | `memory` | `enabled`, `scopes` (`public` / `user` / `agent_user`), `maxChars` |
54
- | `delegation` | `allowedEmployees`, `maxDepth`, `maxCount` |
55
- | `limits` | `timeoutMs`, `recursionLimit`, max invocations/tool calls/tokens/cost |
56
- | `isolation` | `mode` (`none` / `worktree`), `requireWorktree`, `allowedConnectors`, `networkAccess` (`deny` / `restricted` / `allow`) |
57
- | `observability` | `enabled`, `tracingRetentionDays`, `captureInputs`, `captureOutputs` |
58
-
59
- ### Layered compilation
60
-
61
- `HarnessCompiler.compileHarness()` merges an ordered list of layers with most-restrictive-wins semantics: allow-lists and scopes are intersected, `ask`/`deny` are unioned, numeric limits take the minimum, booleans AND, network access takes the strictest value. For each run role, `LoopPatternService` stacks:
62
-
63
- `platform` (hard ceilings) → `profile:<tag>@<version>` (published profile) → `pattern` → `employee:<username>` → per-run overrides.
64
-
65
- The compiled result is persisted on the run as an immutable snapshot (`leaderHarnessSnapshot`, per-maker `makerHarnessSnapshot`, `verifierHarnessSnapshot`), so runs always execute against the policy that was in force at enqueue time.
66
-
67
- ### Tool planning
68
-
69
- At invocation time, `PluginAiRuntimeAdapter` converts the compiled harness into a tool plan: `deny` > `ask` > `allow`. Tools not explicitly allowed become `ask`; allowed tools with `write`/`external` effects stay `ask` unless listed in `trustedPreHandlerTools`. `ask` tools are attached without auto-call so they interrupt for approval; unenforceable system tools (e.g. web search) are blocked at the source.
70
-
71
- ### Versioning
72
-
73
- `HarnessProfileService` manages draft/publish lifecycle over `agentHarnessProfileVersions`: create draft → update draft → publish (points the profile's `currentVersionId` at the published version). One open draft per profile — `saveDraft` writes into the latest unpublished draft and only starts a new version once the previous one shipped, keeping the version history a clean publish trail. `createProfile` bootstraps a profile together with its first published version atomically, and version numbering is row-locked so concurrent saves/publishes cannot collide. Published versions are immutable. Profiles are resolved by tag via `getPublishedByTag(tag)`. Seeded profiles: `default`, `safe`, `file-heavy`.
74
-
75
- ## Skill Hub
76
-
77
- ### Skills
78
-
79
- A skill (`skillDefinitions`) is a sandboxed Python or Node.js code unit with:
80
-
81
- - immutable `toolName`, `title`, `description`, `instructions`;
82
- - `codeTemplate` with `{{placeholder}}` rendering and a JSON Schema `inputSchema`;
83
- - optional `interactionSchema` for human-in-the-loop review UI;
84
- - `packages`, `timeoutSeconds`, `maxOutputSizeMb`, `enabled`, `autoCall`;
85
- - `toolScope` (`CUSTOM` / `GENERAL` / `SPECIFIED`) controlling visibility across AI employees;
86
- - storage source: database (zip upload), local, s3, plugin template, or Git.
87
-
88
- ### Execution
89
-
90
- `skill_hub_execute` and per-skill `skill_hub_<toolName>` tools validate input, check per-agent access (`SkillAccessService`), apply a per-user rate limit, create a `skillExecutions` row, and publish `skill-hub.task`. Sandbox workers claim executions, render and validate the code, run it in a sandbox, stream progress, and store stdout/stderr/output files (downloadable via `skillHub:download`). A poller recovers stale executions. Executions link into the tracing graph via `agentExecutionSpans` (span type `skill`).
91
-
92
- ### MCP surface
93
-
94
- The Skill Hub exposes an MCP-style server surface: `skillHub:mcpListTools` lists enabled skills as `{name, description, inputSchema}` tools; `skillHub:mcpCallTool` executes one and returns MCP content (including a file manifest).
95
-
96
- ### Import and registry
97
-
98
- - **Git import**: `gitListSkills` / `gitSyncSkills` read a `skills.json` manifest and `SKILL.md` frontmatter through plugin-git-manager (optional peer dependency).
99
- - **Registry**: `RegistrySkillInstallationService` installs registry package versions into local `skillDefinitions` (disabled by default, with rollback chain), and `RegistrySkillSnapshotService` exports opt-in snapshots of local skills for an external registry plugin.
100
-
101
- ### Human-in-the-loop review
102
-
103
- `skillLoopConfigs` stores review templates (prompt + schema) per skill; the chat UI renders approval cards for skill executions that require review.
104
-
105
- ## External RAG Search
106
-
107
- The plugin registers the `external_rag_search` tool so leaders and sub-agents can retrieve context from NocoBase knowledge bases, including external RAG services. Source ownership stays in NocoBase; chunking, embedding, vector storage, and retrieval live in an external lightweight RAG service. The tool calls `plugin-knowledge-base.searchKnowledgeBases()`, so access control and mixed local/external search stay centralized.
108
-
109
- Knowledge bases of type `EXTERNAL_RAG` carry options such as `ragProvider` (`external-http` or `e5-http`), `ragApiUrl`, `ragApiKey`, `ragNamespace`, `ragTopK`, `ragScoreThreshold`.
110
-
111
- ### External search contract
112
-
113
- The built-in `external-http` strategy expects:
114
-
115
- ```http
116
- POST /search
117
- Authorization: Bearer <ragApiKey>
118
- Content-Type: application/json
119
- ```
120
-
121
- ```json
122
- {
123
- "query": "search text",
124
- "topK": 5,
125
- "scoreThreshold": 0.3,
126
- "namespace": "optional-kb-namespace",
127
- "filter": {}
128
- }
129
- ```
130
-
131
- Response:
132
-
133
- ```json
134
- {
135
- "results": [
136
- {
137
- "id": "chunk-or-source-id",
138
- "content": "matched text",
139
- "score": 0.82,
140
- "metadata": {
141
- "fileId": "123",
142
- "filename": "contract.pdf",
143
- "collection": "orders",
144
- "recordId": "456",
145
- "sourceUrl": "/api/attachments/123:download"
146
- }
147
- }
148
- ]
149
- }
150
- ```
151
-
152
- Every result must return enough metadata for NocoBase to resolve the original source: `fileId`/`filename` for files, or `collection`/`recordId` for datasource records.
153
-
154
- For E5-family models behind an OpenAI-compatible `/v1/embeddings` API, use `ragProvider: "e5-http"`: queries are embedded as `query: <question>`, chunks as `passage: <chunk>`, and the vector collection must be recreated when the model or vector dimensions change.
155
-
156
- ## UI
157
-
158
- Settings pages under **AI Employee → Agent Orchestrator** (both v1 client and client-v2):
159
-
160
- | Tab | Purpose |
161
- | --- | --- |
162
- | Native Monitor | Loop run list with status, budgets, approvals |
163
- | Execution Tracing | Span tree of sub-agent and tool executions |
164
- | Policy Profiles | Harness profile CRUD with draft/publish versioning and version history |
165
- | Approvals | Pending tool-call/escalation approvals; approve or reject with optional edited input |
166
- | Agent Bindings | Leader↔sub-agent binding configuration |
167
- | Knowledge Access | Per-agent knowledge base access matrix |
168
- | Retrieval Trace | Retrieval tracing for knowledge lookups |
169
- | Memory Inspector | Inspect agent memory context records |
170
- | Skill Hub Definitions | Skill CRUD, editor, test panel, Git import |
171
- | Execution History | Skill execution logs and output files |
172
- | Skill Review Settings | Human-in-the-loop review templates |
173
- | Metrics | Skill usage metrics |
174
-
175
- ## API Resources
176
-
177
- - `agentLoops` — list, get, runNow, pause, resume, cancel, retry, escalate, acceptResult, status
178
- - `agentLoopApprovals` — list, get, decide
179
- - `agentLoopArtifactsView` — list, get
180
- - `agentLoopEventsStream` — stream
181
- - `agentMonitor` — list, get, sync
182
- - `agentKnowledgeInsights` — accessMatrix, retrievalTrace, memoryPreview
183
- - `orchestratorTracing` — list, get
184
- - `skillHub` — download, test, initEnv, clearStorage, mcpListTools, mcpCallTool, listTemplates, gitListSkills, gitSyncSkills
185
- - `agentHarnessProfiles` — standard CRUD plus listVersions, saveDraft, publish, createProfile, validate
186
- - Standard CRUD on `skillDefinitions`, `skillExecutions`, `agentMemoryContexts`, and related collections
187
-
188
- ## Collections
189
-
190
- Agent loops: `agentLoopPatterns`, `agentLoopRuns`, `agentLoopSteps`, `agentLoopEvents`, `agentLoopActionApprovals`, `agentLoopArtifacts`, `agentLoopCircuitStates`, `agentLoopControlSettings`, `agentLoopPathLocks`, `agentLoopUsageBuckets`, `agentLoopWorktrees`.
191
-
192
- Harness: `agentHarnessProfiles`, `agentHarnessProfileVersions`.
193
-
194
- Observation/memory: `agentExecutionSpans`, `orchestratorConfig`, `orchestratorLogs`, `agentMemoryContexts`.
195
-
196
- Skill Hub: `skillDefinitions`, `skillExecutions`, `skillLoopConfigs`, `skillWorkerConfigs`, `skillRegistryInstallations`.
197
-
198
- ## Usage
199
-
200
- 1. Enable the plugin in the NocoBase Plugin Manager (requires plugin-ai; plugin-git-manager is optional for Git skill import).
201
- 2. Configure **Policy Profiles** (harness tags) for your risk levels — the seeded `default`, `safe`, and `file-heavy` profiles are a starting point.
202
- 3. For sub-agent delegation: configure leader↔sub-agent bindings in **Agent Bindings**, add the built-in **AI employee task dispatching** (`dispatch-sub-agent-task`) tool to the leader, and ensure the user role can access both employees.
203
- 4. For autonomous loops: create a pattern (goal, autonomy level, trigger, roles, harness tags, policy), then trigger runs manually, by cron, or by event; monitor runs in **Native Monitor** and resolve approvals/verification escalations there.
204
- 5. For skills: define skills in **Skill Hub Definitions** (or import from Git/registry), test them with the test panel, then bind the generated `skill_hub_*` tools to AI employees.
1
+ # plugin-agent-orchestrator
2
+
3
+ ## Overview
4
+
5
+ Agent orchestration layer for NocoBase AI Employees (plugin-ai). The plugin provides three main subsystems:
6
+
7
+ 1. **Agent Loop Control Plane** — durable, policy-governed multi-step runs with a leader/maker/verifier role model, cron/event/manual triggers, budgets, approvals, and independent verification.
8
+ 2. **Harness (Policy Profiles)** — versioned, tag-addressed policy bundles that constrain what each role may do (tools, memory, delegation, limits, isolation, observability), compiled layer-by-layer with most-restrictive-wins semantics.
9
+ 3. **Skill Hub** — sandboxed Python/Node.js skills that AI employees can execute as tools, with async execution, human-in-the-loop review, an MCP-style surface, and Git/registry import.
10
+
11
+ The legacy loop engine remains available for compatibility. Native agent execution is owned by plugin-ai. The native observer does not change a task, prompt, memory, tool binding, result, or error; persisted native records can be reconciled into a session-level execution tree with model usage and configured cost snapshots. The plugin also exposes an external RAG search tool.
12
+
13
+ Native harness settings are not global enforcement gates. The capability view describes which settings apply to plugin-owned components and which native policies are unsupported or observation-only. Cost is calculated from configured pricing, not provider billing, and missing usage or price remains unknown. Daily/global legacy cost buckets are not reconciled against every native provider call and must not be treated as confirmed actual-spend caps.
14
+
15
+ ## Agent Loop Control Plane
16
+
17
+ ### Patterns
18
+
19
+ A loop pattern (`agentLoopPatterns`) defines a repeatable unit of autonomous work:
20
+
21
+ - `key`, `goalTemplate` — identity and the goal rendered for each run.
22
+ - `autonomyLevel` — `L1` (supervised), `L2`, `L3` (autonomous). L2/L3 require repository identity (`repositoryKey`, `repositoryRoot`, `baseRef`, `actingOn[]`) and worktree isolation (`policy.harness.isolation.requireWorktree`).
23
+ - `triggerType` — `manual`, `cron` (`cronExpression` + `timezone`), or `event` (`eventKey`).
24
+ - Role bindings — `leaderUsername`, `makerUsernames[]`, `verifierUsername` (verifier must differ from leader and makers).
25
+ - Per-role harness tags — `leaderHarnessTag` / `makerHarnessTag` (default `default`), `verifierHarnessTag` (default `safe`).
26
+ - `policy` — concurrency, per-run/daily budgets (invocations, tool calls, delegations, verifications, tokens, cost), circuit-breaker limits, path restrictions (`maxFiles`, deny list), action approval settings (`autoAllowlist`, approvers, timeout), tool-loop detection thresholds (`warnAt`/`blockAt`/`escalateAt`), and required verification checks.
27
+
28
+ ### Run lifecycle
29
+
30
+ `LoopTriggerService` compiles the pattern (including layered harness compilation), snapshots role bindings and harness settings onto the run row, and enqueues it. `LoopWorkerService` claims queued runs with a lease + heartbeat, acquires path locks on `actingOn`, then drives the run:
31
+
32
+ `queued → preparing → waiting_lock → running → waiting_approval → verifying → waiting_human → succeeded | failed | canceled` (plus `paused`, `blocked`).
33
+
34
+ - **Leader** invocation plans the work but changes nothing.
35
+ - **Maker** invocations execute the plan, each under its own compiled harness.
36
+ - Tool calls gated as `ask` park the run in `waiting_approval` until the approval row is resolved via `agentLoopApprovals:decide` (approve — optionally substituting an edited input — or reject).
37
+ - **Tool-loop detection** (`ToolLoopDetectionService`, active in both worker and verifier) guards against repeated identical tool calls: `warnAt` injects a notice into the run, `blockAt` refuses the call, `escalateAt` escalates the run for human review.
38
+ - **Verifier** (via `VerificationService`) runs an independent pass and returns a JSON verdict: `pass` → `succeeded` (L1) or `waiting_human` (L2/L3); `reject` → `failed`; `escalate` → `waiting_human`. Required checks and artifact evidence ownership are enforced.
39
+
40
+ Human actions on runs: pause, resume, cancel, retry, escalate, accept result. Budgets, circuit-breaker state, usage buckets, events, steps, artifacts, and worktrees are persisted in dedicated collections.
41
+
42
+ ### Sub-agent observation and memory
43
+
44
+ - `NativeSubAgentObserver` observes the native `dispatch-sub-agent-task` flow without changing the task, result, or error. `agentMonitor:sync` reconciles persisted native sessions and calls in bounded pages; repeat complete passes to include late records and updates to older rows. A session root is not an individual request or complete real-time trace. Native message and tool content is omitted when no invocation-time capture-policy snapshot is available.
45
+ - Trace reconciliation and cleanup use the same global retention window, based on native source activity rather than reconciliation time. The cleanup falls back to source start/creation timestamps for older rows without an activity field. Model-call usage and pricing snapshots are retained separately as accounting data; trace retention is not a deletion policy for that ledger or for native core records.
46
+ - `AgentMemoryContextService` still provides context-building utilities for compatible plugin-owned consumers. The native observer no longer injects memory into delegated questions.
47
+ - `AgentRegistryService` resolves leader↔sub-agent bindings from `orchestratorConfig`, model overrides, and alternative sub-agents for retry.
48
+
49
+ ## Harness (Policy Profiles)
50
+
51
+ A harness profile is a versioned policy bundle addressed by a unique `tag`. Settings (validated by a strict zod schema in `HarnessSchema.ts`) have six sections:
52
+
53
+ | Section | Controls |
54
+ | --- | --- |
55
+ | `tools` | `allow` / `ask` / `deny` lists, per-tool `effects` (`read` / `write` / `external`), `trustedPreHandlerTools` |
56
+ | `memory` | `enabled`, `scopes` (`public` / `user` / `agent_user`), `maxChars` |
57
+ | `delegation` | `allowedEmployees`, `maxDepth`, `maxCount` |
58
+ | `limits` | `timeoutMs`, `recursionLimit`, max invocations/tool calls/tokens/cost |
59
+ | `isolation` | `mode` (`none` / `worktree`), `requireWorktree`, `allowedConnectors`, `networkAccess` (`deny` / `restricted` / `allow`) |
60
+ | `observability` | `enabled`, `tracingRetentionDays`, `captureInputs`, `captureOutputs` |
61
+
62
+ ### Layered compilation
63
+
64
+ `HarnessCompiler.compileHarness()` merges an ordered list of layers with most-restrictive-wins semantics: allow-lists and scopes are intersected, `ask`/`deny` are unioned, numeric limits take the minimum, booleans AND, network access takes the strictest value. For each run role, `LoopPatternService` stacks:
65
+
66
+ `platform` (hard ceilings) → `profile:<tag>@<version>` (published profile) → `pattern` → `employee:<username>` → per-run overrides.
67
+
68
+ The compiled result is persisted on the run as an immutable snapshot (`leaderHarnessSnapshot`, per-maker `makerHarnessSnapshot`, `verifierHarnessSnapshot`), so runs always execute against the policy that was in force at enqueue time.
69
+
70
+ ### Tool planning
71
+
72
+ For legacy plugin-owned loop invocations, `PluginAiRuntimeAdapter` converts the compiled harness into a tool plan: `deny` > `ask` > `allow`. Tools not explicitly allowed become `ask`; allowed tools with `write`/`external` effects stay `ask` unless listed in `trustedPreHandlerTools`. `ask` tools are attached without auto-call so they interrupt for approval; unenforceable system tools (e.g. web search) are blocked at the source. This adapter does not establish a global gate for native chat, API, workflow, or sub-agent execution.
73
+
74
+ ### Versioning
75
+
76
+ `HarnessProfileService` manages draft/publish lifecycle over `agentHarnessProfileVersions`: create draft → update draft → publish (points the profile's `currentVersionId` at the published version). One open draft per profile — `saveDraft` writes into the latest unpublished draft and only starts a new version once the previous one shipped, keeping the version history a clean publish trail. `createProfile` bootstraps a profile together with its first published version atomically, and version numbering is row-locked so concurrent saves/publishes cannot collide. Published versions are immutable. Profiles are resolved by tag via `getPublishedByTag(tag)`. Seeded profiles: `default`, `safe`, `file-heavy`.
77
+
78
+ ## Skill Hub
79
+
80
+ ### Skills
81
+
82
+ A skill (`skillDefinitions`) is a sandboxed Python or Node.js code unit with:
83
+
84
+ - immutable `toolName`, `title`, `description`, `instructions`;
85
+ - `codeTemplate` with `{{placeholder}}` rendering and a JSON Schema `inputSchema`;
86
+ - optional `interactionSchema` for human-in-the-loop review UI;
87
+ - `packages`, `timeoutSeconds`, `maxOutputSizeMb`, `enabled`, `autoCall`;
88
+ - `toolScope` (`CUSTOM` / `GENERAL` / `SPECIFIED`) controlling visibility across AI employees;
89
+ - storage source: database (zip upload), local, s3, plugin template, or Git.
90
+
91
+ ### Execution
92
+
93
+ `skill_hub_execute` and per-skill `skill_hub_<toolName>` tools validate input, check per-agent access (`SkillAccessService`), apply a per-user rate limit, create a `skillExecutions` row, and publish `skill-hub.task`. Sandbox workers claim executions, render and validate the code, run it in a sandbox, stream progress, and store stdout/stderr/output files (downloadable via `skillHub:download`). A poller recovers stale executions. Executions link into the tracing graph via `agentExecutionSpans` (span type `skill`).
94
+
95
+ ### MCP surface
96
+
97
+ The Skill Hub exposes an MCP-style server surface: `skillHub:mcpListTools` lists enabled skills as `{name, description, inputSchema}` tools; `skillHub:mcpCallTool` executes one and returns MCP content (including a file manifest).
98
+
99
+ ### Import and registry
100
+
101
+ - **Git import**: `gitListSkills` / `gitSyncSkills` read a `skills.json` manifest and `SKILL.md` frontmatter through plugin-git-manager (optional peer dependency).
102
+ - **Registry**: `RegistrySkillInstallationService` installs registry package versions into local `skillDefinitions` (disabled by default, with rollback chain), and `RegistrySkillSnapshotService` exports opt-in snapshots of local skills for an external registry plugin.
103
+
104
+ ### Human-in-the-loop review
105
+
106
+ `skillLoopConfigs` stores review templates (prompt + schema) per skill; the chat UI renders approval cards for skill executions that require review.
107
+
108
+ ## External RAG Search
109
+
110
+ The plugin registers the `external_rag_search` tool so leaders and sub-agents can retrieve context from NocoBase knowledge bases, including external RAG services. Source ownership stays in NocoBase; chunking, embedding, vector storage, and retrieval live in an external lightweight RAG service. The tool calls `plugin-knowledge-base.searchKnowledgeBases()`, so access control and mixed local/external search stay centralized.
111
+
112
+ Knowledge bases of type `EXTERNAL_RAG` carry options such as `ragProvider` (`external-http` or `e5-http`), `ragApiUrl`, `ragApiKey`, `ragNamespace`, `ragTopK`, `ragScoreThreshold`.
113
+
114
+ ### External search contract
115
+
116
+ The built-in `external-http` strategy expects:
117
+
118
+ ```http
119
+ POST /search
120
+ Authorization: Bearer <ragApiKey>
121
+ Content-Type: application/json
122
+ ```
123
+
124
+ ```json
125
+ {
126
+ "query": "search text",
127
+ "topK": 5,
128
+ "scoreThreshold": 0.3,
129
+ "namespace": "optional-kb-namespace",
130
+ "filter": {}
131
+ }
132
+ ```
133
+
134
+ Response:
135
+
136
+ ```json
137
+ {
138
+ "results": [
139
+ {
140
+ "id": "chunk-or-source-id",
141
+ "content": "matched text",
142
+ "score": 0.82,
143
+ "metadata": {
144
+ "fileId": "123",
145
+ "filename": "contract.pdf",
146
+ "collection": "orders",
147
+ "recordId": "456",
148
+ "sourceUrl": "/api/attachments/123:download"
149
+ }
150
+ }
151
+ ]
152
+ }
153
+ ```
154
+
155
+ Every result must return enough metadata for NocoBase to resolve the original source: `fileId`/`filename` for files, or `collection`/`recordId` for datasource records.
156
+
157
+ For E5-family models behind an OpenAI-compatible `/v1/embeddings` API, use `ragProvider: "e5-http"`: queries are embedded as `query: <question>`, chunks as `passage: <chunk>`, and the vector collection must be recreated when the model or vector dimensions change.
158
+
159
+ ## UI
160
+
161
+ Settings pages under **AI Employee → Agent Orchestrator** (both v1 client and client-v2):
162
+
163
+ | Tab | Purpose |
164
+ | --- | --- |
165
+ | Native Monitor | Loop run list with status, budgets, approvals |
166
+ | Execution Tracing | Span tree of sub-agent and tool executions |
167
+ | Policy Profiles | Harness profile CRUD with draft/publish versioning and version history |
168
+ | Approvals | Pending tool-call/escalation approvals; approve or reject with optional edited input |
169
+ | Agent Bindings | Leader↔sub-agent binding configuration |
170
+ | Knowledge Access | Per-agent knowledge base access matrix |
171
+ | Retrieval Trace | Retrieval tracing for knowledge lookups |
172
+ | Memory Inspector | Inspect agent memory context records |
173
+ | Skill Hub Definitions | Skill CRUD, editor, test panel, Git import |
174
+ | Execution History | Skill execution logs and output files |
175
+ | Skill Review Settings | Human-in-the-loop review templates |
176
+ | Metrics | Skill usage metrics |
177
+
178
+ ## API Resources
179
+
180
+ - `agentLoops` — list, get, runNow, pause, resume, cancel, retry, escalate, acceptResult, status
181
+ - `agentLoopApprovals` — list, get, decide
182
+ - `agentLoopArtifactsView` — list, get
183
+ - `agentLoopEventsStream` — stream
184
+ - `agentMonitor` — list, get, sync
185
+ - `agentKnowledgeInsights` — accessMatrix, retrievalTrace, memoryPreview
186
+ - `orchestratorTracing` — list, get
187
+ - `skillHub` — download, test, initEnv, clearStorage, mcpListTools, mcpCallTool, listTemplates, gitListSkills, gitSyncSkills
188
+ - `agentHarnessProfiles` — standard CRUD plus listVersions, saveDraft, publish, createProfile, validate
189
+ - Standard CRUD on `skillDefinitions`, `skillExecutions`, `agentMemoryContexts`, and related collections
190
+
191
+ ## Collections
192
+
193
+ Agent loops: `agentLoopPatterns`, `agentLoopRuns`, `agentLoopSteps`, `agentLoopEvents`, `agentLoopActionApprovals`, `agentLoopArtifacts`, `agentLoopCircuitStates`, `agentLoopControlSettings`, `agentLoopPathLocks`, `agentLoopUsageBuckets`, `agentLoopWorktrees`.
194
+
195
+ Harness: `agentHarnessProfiles`, `agentHarnessProfileVersions`.
196
+
197
+ Observation/memory: `agentExecutionSpans`, `orchestratorConfig`, `orchestratorLogs`, `agentMemoryContexts`.
198
+
199
+ Skill Hub: `skillDefinitions`, `skillExecutions`, `skillLoopConfigs`, `skillWorkerConfigs`, `skillRegistryInstallations`.
200
+
201
+ ## Usage
202
+
203
+ 1. Enable the plugin in the NocoBase Plugin Manager (requires plugin-ai; plugin-git-manager is optional for Git skill import).
204
+ 2. Configure **Policy Profiles** (harness tags) for your risk levels — the seeded `default`, `safe`, and `file-heavy` profiles are a starting point.
205
+ 3. For sub-agent delegation: configure leader↔sub-agent bindings in **Agent Bindings**, add the built-in **AI employee task dispatching** (`dispatch-sub-agent-task`) tool to the leader, and ensure the user role can access both employees.
206
+ 4. For autonomous loops: create a pattern (goal, autonomy level, trigger, roles, harness tags, policy), then trigger runs manually, by cron, or by event; monitor runs in **Native Monitor** and resolve approvals/verification escalations there.
207
+ 5. For skills: define skills in **Skill Hub Definitions** (or import from Git/registry), test them with the test panel, then bind the generated `skill_hub_*` tools to AI employees.
package/client-v2.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './dist/client-v2';
2
- export { default } from './dist/client-v2';
1
+ export * from './dist/client-v2';
2
+ export { default } from './dist/client-v2';
package/client-v2.js CHANGED
@@ -1 +1 @@
1
- module.exports = require('./dist/client-v2/index.js');
1
+ module.exports = require('./dist/client-v2/index.js');
package/client.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './dist/client';
2
- export { default } from './dist/client';
1
+ export * from './dist/client';
2
+ export { default } from './dist/client';
package/client.js CHANGED
@@ -1 +1 @@
1
- module.exports = require('./dist/client');
1
+ module.exports = require('./dist/client');
@@ -0,0 +1,10 @@
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
+ "use strict";(self.webpackChunkplugin_agent_orchestrator=self.webpackChunkplugin_agent_orchestrator||[]).push([["117"],{532:function(e,t,r){r.d(t,{j:function(){return d},l:function(){return c}});var n=r(155),a=r.n(n),l=r(608);function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function u(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e){if(e){if("string"==typeof e)return o(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return o(e,void 0)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var i=(0,n.createContext)({employees:[],employeeMap:new Map,toolNamesMap:new Map,loading:!1,refresh:function(){}}),s=new Set(["dispatch-sub-agent-task","external_rag_search","skill_hub_execute"]),c=function(e){var t=e.children,r=(0,l.b)({url:"aiEmployees:list",params:{pageSize:200}}),n=r.data,o=r.loading,c=r.refresh,d=a().useMemo(function(){var e=((null==n?void 0:n.data)||[]).map(function(e){var t,r,n,a,l=(r=Array.isArray(null==(t=e.skillSettings)?void 0:t.tools)?t.tools.map(function(e){return"string"==typeof e?e:null==e?void 0:e.name}).filter(function(e){return"string"==typeof e&&e.length>0}):[],n=Array.isArray(null==t?void 0:t.skills)?t.skills.map(function(e){if("string"==typeof e)return s.has(e)||e.startsWith("skill_hub_")||e.startsWith("browser_")||e.startsWith("drawio-")?e:null;return null==e?void 0:e.name}).filter(function(e){return"string"==typeof e&&e.length>0}):[],Array.from(new Set(u(r).concat(u(n)))));return{username:e.username,nickname:e.nickname||e.username,about:null==(a=e.about)?void 0:a.substring(0,80),tools:l}}),t=new Map,r=new Map,a=!0,l=!1,i=void 0;try{for(var d,m=e[Symbol.iterator]();!(a=(d=m.next()).done);a=!0){var f=d.value;t.set(f.username,f.nickname),r.set(f.username,new Set(f.tools))}}catch(e){l=!0,i=e}finally{try{a||null==m.return||m.return()}finally{if(l)throw i}}return{employees:e,employeeMap:t,toolNamesMap:r,loading:o,refresh:c}},[n,o,c]);return a().createElement(i.Provider,{value:d},t)},d=function(){return(0,n.useContext)(i)}},524:function(e,t,r){r.r(t),r.d(t,{default:function(){return S}});var n=r(155),a=r.n(n),l=r(532),o=r(59),u=r(375),i=r(608),s=r(603);function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function d(e,t,r,n,a,l,o){try{var u=e[l](o),i=u.value}catch(e){r(e);return}u.done?t(i):Promise.resolve(i).then(n,a)}function m(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var l=e.apply(t,r);function o(e){d(l,n,a,o,u,"next",e)}function u(e){d(l,n,a,o,u,"throw",e)}o(void 0)})}}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,u=!1;try{for(a=a.call(e);!(o=(r=a.next()).done)&&(l.push(r.value),!t||l.length!==t);o=!0);}catch(e){u=!0,n=e}finally{try{o||null==a.return||a.return()}finally{if(u)throw n}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,t){var r,n,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(o,"next",{value:i(0)}),u(o,"throw",{value:i(1)}),u(o,"return",{value:i(2)}),"function"==typeof Symbol&&u(o,Symbol.iterator,{value:function(){return this}}),o;function i(u){return function(i){var s=[u,i];if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(l=0)),l;)try{if(r=1,n&&(a=2&s[0]?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return l.label++,{value:s[1],done:!1};case 5:l.label++,n=s[1],s=[0];continue;case 7:s=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){l=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){l.label=s[1];break}if(6===s[0]&&l.label<a[1]){l.label=a[1],a=s;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(s);break}a[2]&&l.ops.pop(),l.trys.pop();continue}s=t.call(e,l)}catch(e){s=[6,e],n=0}finally{r=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}var y=o.Typography.Paragraph,b=o.Typography.Text;function v(e){var t=e.status;return a().createElement(o.Tag,{color:function(e){switch(e){case"success":return"success";case"error":return"error";case"running":return"processing";default:return"default"}}(t),icon:"success"===t?a().createElement(u.CheckCircleOutlined,null):"error"===t?a().createElement(u.CloseCircleOutlined,null):void 0},t||"-")}function g(e){return e?new Date(e).toLocaleString():"-"}function h(e){return e?e>=6e4?"".concat(Math.round(e/6e4),"m"):e>=1e3?"".concat((e/1e3).toFixed(1),"s"):"".concat(e,"ms"):"-"}function E(e){var t=e.value,r=e.rows,n=function(e){if(null==e||""===e)return"";if("string"==typeof e)return e;try{return JSON.stringify(e,null,2)}catch(t){return String(e)}}(t);return n?a().createElement(y,{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",margin:0,fontSize:12},ellipsis:{rows:void 0===r?8:r,expandable:!0}},n):a().createElement(b,{type:"secondary"},"-")}var w=function(){var e,t,r,c,d,y,w,S,k,A,I,C,x,O,M,D=(0,i.R)(),j=(0,s.k)(),T=(0,l.j)(),P=T.employees,U=T.employeeMap,z=f((0,n.useState)({}),2),R=z[0],N=z[1],_=f((0,n.useState)(1),2),F=_[0],B=_[1],W=f((0,n.useState)(20),2),q=W[0],L=W[1],G=f((0,n.useState)(null),2),$=G[0],H=G[1],J=f((0,n.useState)(!1),2),K=J[0],Q=J[1],V=f((0,n.useState)(!1),2),X=V[0],Y=V[1],Z=f((0,n.useState)(null),2),ee=Z[0],et=Z[1],er=(0,n.useRef)(0),en=(0,n.useMemo)(function(){var e={};return R.leader&&(e.leaderUsername=R.leader),R.subAgent&&(e.subAgentUsername=R.subAgent),R.status&&(e.status=R.status),{sort:["-startedAt"],page:F,pageSize:q,filter:e}},[R,F,q]),ea=(0,i.b)({url:"agentMonitor:list",params:en},{refreshDeps:[en]}),el=ea.data,eo=ea.loading,eu=ea.refresh,ei=(0,n.useMemo)(function(){var e=null==el?void 0:el.data;return Array.isArray(e)?e:[]},[el]),es=(0,n.useMemo)(function(){var e,t=null==el||null==(e=el.meta)?void 0:e.count;return"number"==typeof t?t:0},[el]),ec=(0,n.useMemo)(function(){return P.map(function(e){return{label:e.nickname||e.username,value:e.username}})},[P]),ed=function(e){N(function(t){return function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},t,e)}),B(1)},em=!!(R.leader||R.subAgent||R.status),ef=Array.isArray(null==$?void 0:$.trace)?$.trace:[],ep=[{title:j("Time"),dataIndex:"createdAt",key:"createdAt",width:170,render:g},{title:j("Leader"),dataIndex:"leaderUsername",key:"leaderUsername",width:160,render:function(e){return a().createElement(o.Tag,{color:"blue"},U.get(e)||e||"-")}},{title:j("Sub-Agent"),dataIndex:"subAgentUsername",key:"subAgentUsername",width:160,render:function(e){return a().createElement(o.Tag,{color:"green"},U.get(e)||e||"-")}},{title:j("Task"),dataIndex:"task",key:"task",render:function(e){return a().createElement(b,{ellipsis:!0,style:{maxWidth:360}},e||"-")}},{title:j("Status"),dataIndex:"status",key:"status",width:110,render:function(e){return a().createElement(v,{status:e})}},{title:j("Duration"),dataIndex:"durationMs",key:"durationMs",width:100,render:h},{title:j("Context"),dataIndex:"memoryContextApplied",key:"memoryContextApplied",width:100,render:function(e){return e?a().createElement(o.Tag,{color:"purple"},"memory"):a().createElement(b,{type:"secondary"},"-")}},{title:"",key:"actions",width:90,render:function(e,t){return a().createElement(o.Button,{type:"link",size:"small",icon:a().createElement(u.EyeOutlined,null),onClick:function(){return m(function(){var e,r,n,a,l,u,i,s,c,d,m,f;return p(this,function(p){switch(p.label){case 0:e=++er.current,H(t),Q(!0),p.label=1;case 1:return p.trys.push([1,3,4,5]),[4,D.request({url:"agentMonitor:get",params:{filterByTk:t.id}})];case 2:if(l=p.sent(),e!==er.current)return[2];return H((null==(u=l)||null==(n=u.data)||null==(r=n.data)?void 0:r.data)||(null==u||null==(a=u.data)?void 0:a.data)||t),[3,5];case 3:if(i=p.sent(),e!==er.current)return[2];return f=(null==i||null==(m=i.response)||null==(d=m.data)||null==(c=d.errors)||null==(s=c[0])?void 0:s.message)||(null==i?void 0:i.message)||j("Failed to load run detail"),o.message.error(f),[3,5];case 4:return e===er.current&&Q(!1),[7];case 5:return[2]}})})()}},j("Detail"))}}];return a().createElement("div",null,a().createElement(o.Alert,{type:"info",showIcon:!0,style:{marginBottom:16},message:j("Native Agent Runs"),description:a().createElement(b,{type:"secondary"},j("Native monitor coverage description")," ",j("Monitor descendant filters follow up to 32 levels"))}),a().createElement(o.Card,{bordered:!1},a().createElement(o.Form,{layout:"inline",style:{marginBottom:16,rowGap:8,flexWrap:"wrap"}},a().createElement(o.Form.Item,{label:j("Leader")},a().createElement(o.Select,{allowClear:!0,showSearch:!0,optionFilterProp:"label",placeholder:j("Any leader"),style:{minWidth:180},options:ec,value:R.leader,onChange:function(e){return ed({leader:e})}})),a().createElement(o.Form.Item,{label:j("Sub-Agent")},a().createElement(o.Select,{allowClear:!0,showSearch:!0,optionFilterProp:"label",placeholder:j("Any sub-agent"),style:{minWidth:180},options:ec,value:R.subAgent,onChange:function(e){return ed({subAgent:e})}})),a().createElement(o.Form.Item,{label:j("Status")},a().createElement(o.Select,{allowClear:!0,placeholder:j("Any status"),style:{minWidth:140},value:R.status,onChange:function(e){return ed({status:e})},options:[{label:j("Running"),value:"running"},{label:j("Success"),value:"success"},{label:j("Error"),value:"error"}]})),a().createElement(o.Form.Item,null,a().createElement(o.Space,null,a().createElement(o.Button,{onClick:function(){N({}),B(1)},disabled:!em},j("Reset")),a().createElement(o.Button,{icon:a().createElement(u.ReloadOutlined,null),onClick:eu},j("Refresh")),a().createElement(o.Button,{icon:a().createElement(u.SyncOutlined,null),onClick:function(){return m(function(){var e,t,r,n,a,l,u,i,s,c,d,m,f,y,b;return p(this,function(p){switch(p.label){case 0:Y(!0),p.label=1;case 1:return p.trys.push([1,3,4,5]),[4,D.request({url:"agentMonitor:sync",method:"post",data:{limit:500,cursor:ee}})];case 2:return et((i=(null==(u=null==(l=p.sent())||null==(e=l.data)?void 0:e.data)?void 0:u.data)||u||{}).cursor||null),s=((null==(t=i.counts)?void 0:t.conversations)||0)+((null==(r=i.counts)?void 0:r.linkedSubAgents)||0)+((null==(n=i.counts)?void 0:n.toolMessages)||0)+((null==(a=i.counts)?void 0:a.modelCalls)||0),o.message.success(i.complete?j("Native sync pass completed ({{count}} records in this page)",{count:s}):j("Synced {{count}} records; continue to finish this pass",{count:s})),eu(),[3,5];case 3:return b=(null==(c=p.sent())||null==(y=c.response)||null==(f=y.data)||null==(m=f.errors)||null==(d=m[0])?void 0:d.message)||(null==c?void 0:c.message)||j("Sync failed"),o.message.error(b),[3,5];case 4:return Y(!1),[7];case 5:return[2]}})})()},loading:X},ee?j("Continue sync"):j("Sync"))))),a().createElement(o.Table,{rowKey:"id",loading:eo,dataSource:ei,columns:ep,scroll:{x:"max-content"},pagination:{current:F,pageSize:q,total:es,showSizeChanger:!0,pageSizeOptions:[10,20,50,100],showTotal:function(e){return j("{{count}} runs",{count:e})},onChange:function(e,t){B(e),t&&t!==q&&L(t)}},locale:{emptyText:a().createElement(o.Empty,{description:em?j("No runs match the current filters"):j("No native runs yet")})}})),a().createElement(o.Drawer,{title:j("Native Run Detail"),width:960,onClose:function(){return H(null)},open:!!$},$&&a().createElement(o.Spin,{spinning:K},a().createElement(o.Space,{direction:"vertical",size:16,style:{width:"100%"}},a().createElement(o.Descriptions,{bordered:!0,size:"small",column:2},a().createElement(o.Descriptions.Item,{label:j("Status")},a().createElement(v,{status:$.status})),a().createElement(o.Descriptions.Item,{label:j("Harness")},$.harnessTag||"default"),a().createElement(o.Descriptions.Item,{label:j("Leader")},a().createElement(o.Tag,{color:"blue"},U.get($.leaderUsername||"")||$.leaderUsername||"-")),a().createElement(o.Descriptions.Item,{label:j("Sub-Agent")},a().createElement(o.Tag,{color:"green"},U.get($.subAgentUsername||"")||$.subAgentUsername||"-")),a().createElement(o.Descriptions.Item,{label:j("Parent session")},a().createElement(b,{code:!0},$.parentSessionId||"-")),a().createElement(o.Descriptions.Item,{label:j("Sub session")},a().createElement(b,{code:!0},$.subSessionId||"-")),a().createElement(o.Descriptions.Item,{label:j("Tool call")},a().createElement(b,{code:!0},$.toolCallId||"-")),a().createElement(o.Descriptions.Item,{label:j("Duration")},h($.durationMs)),a().createElement(o.Descriptions.Item,{label:j("Started")},g($.startedAt||$.createdAt)),a().createElement(o.Descriptions.Item,{label:j("Ended")},g($.endedAt))),a().createElement(o.Card,{title:j("Task"),size:"small"},a().createElement(E,{value:$.task||(null==(w=$.input)?void 0:w.question),rows:6})),a().createElement(o.Card,{title:j("Execution Flow"),size:"small"},ef.length?a().createElement(o.Timeline,{items:ef.map(function(e){var t,r;return{key:e.id,color:"error"===e.status?"red":"running"===e.status?"blue":"green",children:a().createElement(o.Space,{direction:"vertical",size:2,style:{width:"100%"}},a().createElement(o.Space,{wrap:!0},a().createElement(b,{strong:!0},e.title||e.type),a().createElement(o.Tag,null,e.type),a().createElement(v,{status:e.status}),e.toolName&&a().createElement(b,{code:!0},e.toolName),e.durationMs?a().createElement(b,{type:"secondary"},h(e.durationMs)):null),a().createElement(b,{type:"secondary"},g(e.at)),"model_call"===e.type&&a().createElement(b,{type:"secondary"},[e.provider,e.model].filter(Boolean).join(" / ")||"-"," \xb7 ",j("Input tokens"),":"," ",null!=(t=e.inputTokens)?t:"?"," \xb7 ",j("Output tokens"),": ",null!=(r=e.outputTokens)?r:"?"," \xb7"," ",j(e.usageSource||"missing")," \xb7 ",j("Calculated cost"),":"," ",null==e.cost?j("Unpriced or incomplete"):"".concat(e.cost," USD")),e.content?a().createElement(E,{value:e.content,rows:4}):null)}})}):a().createElement(o.Empty,{description:j("No execution flow captured")})),a().createElement(o.Card,{title:j("Model usage"),size:"small"},a().createElement(o.Descriptions,{size:"small",column:2},a().createElement(o.Descriptions.Item,{label:j("Model calls")},null!=(e=null==(S=$.usage)?void 0:S.modelCalls)?e:"-"),a().createElement(o.Descriptions.Item,{label:j("Input tokens")},null!=(t=null==(k=$.usage)?void 0:k.inputTokens)?t:j("Incomplete")),a().createElement(o.Descriptions.Item,{label:j("Output tokens")},null!=(r=null==(A=$.usage)?void 0:A.outputTokens)?r:j("Incomplete")),a().createElement(o.Descriptions.Item,{label:j("Calculated cost")},(null==(I=$.usage)?void 0:I.cost)==null?j("Unpriced or incomplete"):"".concat($.usage.cost," ").concat($.usage.currency||"USD")),a().createElement(o.Descriptions.Item,{label:j("Estimated calls")},null!=(c=null==(C=$.usage)?void 0:C.estimatedCalls)?c:0),a().createElement(o.Descriptions.Item,{label:j("Missing usage calls")},null!=(d=null==(x=$.usage)?void 0:x.missingUsageCalls)?d:0),a().createElement(o.Descriptions.Item,{label:j("Unpriced calls")},null!=(y=null==(O=$.usage)?void 0:O.unpricedCalls)?y:0)),(null==(M=$.coverage)?void 0:M.truncated)&&a().createElement(o.Alert,{type:"warning",showIcon:!0,message:j("Trace detail truncated; usage totals are incomplete")})),a().createElement(o.Alert,{type:"info",showIcon:!0,message:j("Native content omitted without capture snapshot")}),a().createElement(o.Collapse,{items:[{key:"metadata",label:j("Monitor metadata"),children:a().createElement(E,{value:$.metadata,rows:10})}]}),!!($.output||$.error)&&a().createElement(o.Card,{title:$.error?j("Error"):j("Result"),size:"small"},a().createElement(E,{value:$.error||$.output,rows:12}))))))},S=function(e){var t=e.embedded;return a().createElement(l.l,null,a().createElement("div",{style:t?void 0:{padding:"0 24px 24px"}},a().createElement(w,null)))}},608:function(e,t,r){r.d(t,{R:function(){return s},b:function(){return c}});var n=r(485),a=r(155);function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function o(e,t,r,n,a,l,o){try{var u=e[l](o),i=u.value}catch(e){r(e);return}u.done?t(i):Promise.resolve(i).then(n,a)}function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,u=!1;try{for(a=a.call(e);!(o=(r=a.next()).done)&&(l.push(r.value),!t||l.length!==t);o=!0);}catch(e){u=!0,n=e}finally{try{o||null==a.return||a.return()}finally{if(u)throw n}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return l(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return l(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function s(){return(0,n.useApp)().apiClient}function c(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=s(),n=t.manual,l=void 0!==n&&n,c=t.refreshDeps,d=t.onSuccess,m=t.onError,f=u((0,a.useState)(void 0),2),p=f[0],y=f[1],b=u((0,a.useState)(!l),2),v=b[0],g=b[1],h=u((0,a.useState)(void 0),2),E=h[0],w=h[1],S=(0,a.useRef)(e);S.current=e;var k=(0,a.useRef)(d);k.current=d;var A=(0,a.useRef)(m);A.current=m;var I=(0,a.useRef)(!0),C=(0,a.useRef)(0);(0,a.useEffect)(function(){return I.current=!0,function(){I.current=!1}},[]);var x=(0,a.useCallback)(function(e){var t;return(t=function(){var t,n,a,l,o,u,s,c,d;return function(e,t){var r,n,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(o,"next",{value:i(0)}),u(o,"throw",{value:i(1)}),u(o,"return",{value:i(2)}),"function"==typeof Symbol&&u(o,Symbol.iterator,{value:function(){return this}}),o;function i(u){return function(i){var s=[u,i];if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(l=0)),l;)try{if(r=1,n&&(a=2&s[0]?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return l.label++,{value:s[1],done:!1};case 5:l.label++,n=s[1],s=[0];continue;case 7:s=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){l=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){l.label=s[1];break}if(6===s[0]&&l.label<a[1]){l.label=a[1],a=s;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(s);break}a[2]&&l.ops.pop(),l.trys.pop();continue}s=t.call(e,l)}catch(e){s=[6,e],n=0}finally{r=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}(this,function(m){switch(m.label){case 0:t=S.current,n=++C.current,a=function(){return I.current&&n===C.current},g(!0),w(void 0),m.label=1;case 1:if(m.trys.push([1,6,7,8]),"function"!=typeof t)return[3,3];return[4,t()];case 2:return o=m.sent(),[3,5];case 3:return[4,r.request({url:t.url,method:t.method||"get",params:function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},t.params||{},e||{}),data:t.data})];case 4:o=(s=null==(u=m.sent())?void 0:u.data)&&(void 0===s?"undefined":i(s))==="object"&&s.data&&"object"===i(s.data)&&"data"in s.data?s.data:s,m.label=5;case 5:if(!a())return[2,void 0];return y(o),null==(l=k.current)||l.call(k,o),[2,o];case 6:if(c=m.sent(),!a())return[2,void 0];return w(c),null==(d=A.current)||d.call(A,c),[2,void 0];case 7:return a()&&g(!1),[7];case 8:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(n,a){var l=t.apply(e,r);function u(e){o(l,n,a,u,i,"next",e)}function i(e){o(l,n,a,u,i,"throw",e)}u(void 0)})})()},[r]),O=(0,a.useCallback)(function(){x()},[x]);return(0,a.useEffect)(function(){l||x()},void 0===c?[]:c),{data:p,loading:v,error:E,refresh:O,run:x}}}}]);
@@ -0,0 +1,10 @@
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
+ "use strict";(self.webpackChunkplugin_agent_orchestrator=self.webpackChunkplugin_agent_orchestrator||[]).push([["253"],{740:function(e,t,r){r.r(t),r.d(t,{default:function(){return f}});var n=r(155),a=r.n(n),o=r(59),u=r(375),l=r(608),i=r(603);function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var s=function(){var e,t=(0,i.k)(),r=function(e){if(Array.isArray(e))return e}(e=(0,n.useState)(!1))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var a=[],o=!0,u=!1;try{for(n=n.call(e);!(o=(t=n.next()).done)&&(a.push(t.value),2!==a.length);o=!0);}catch(e){u=!0,r=e}finally{try{o||null==n.return||n.return()}finally{if(u)throw r}}return a}}(e)||function(e){if(e){if("string"==typeof e)return c(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return c(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=r[0],f=r[1],d=(0,l.b)({url:"agentKnowledgeInsights:accessMatrix"}),y=(0,n.useMemo)(function(){var e;return Array.isArray(null==(e=d.data)?void 0:e.data)?e.data:[]},[d.data]),p=(0,n.useMemo)(function(){return s?y.filter(function(e){return"denied"===e.access}):y},[y,s]),m=[{title:t("AI Employee"),dataIndex:"employeeUsername",key:"employeeUsername"},{title:t("Knowledge Base"),dataIndex:"knowledgeBaseName",key:"knowledgeBaseName",render:function(e,t){return a().createElement(o.Space,{size:4,wrap:!0},a().createElement("span",null,e),a().createElement(o.Tag,null,t.knowledgeBaseType))}},{title:t("Assignment"),dataIndex:"assigned",key:"assigned",width:120,render:function(e){return a().createElement(o.Tag,{color:e?"blue":"default"},e?t("Assigned"):t("Not assigned"))}},{title:t("Agent access"),dataIndex:"access",key:"access",width:130,render:function(e){return a().createElement(o.Tag,{color:"allowed"===e?"success":"error"},"allowed"===e?t("Allowed"):t("Denied"))}},{title:t("Reason"),dataIndex:"reason",key:"reason",render:function(e){return a().createElement(o.Typography.Text,null,e)}},{title:t("Runtime user gate"),dataIndex:"userGate",key:"userGate",render:function(e){return a().createElement(o.Tooltip,{title:e},a().createElement(o.Typography.Text,{ellipsis:!0,style:{maxWidth:260}},e))}}];return a().createElement(o.Card,{bordered:!1},a().createElement(o.Space,{direction:"vertical",size:16,style:{width:"100%"}},a().createElement(o.Typography.Text,{type:"secondary"},t("This matrix checks employee assignment and static agent policy. BASIC and SHARED user access is still evaluated when a run starts.")),a().createElement(o.Space,{wrap:!0},a().createElement(o.Button,{type:s?"primary":"default",onClick:function(){return f(function(e){return!e})}},s?t("Show all"):t("Show denied only")),a().createElement(o.Button,{icon:a().createElement(u.ReloadOutlined,null),onClick:d.refresh},t("Refresh"))),a().createElement(o.Table,{rowKey:"key",loading:d.loading,dataSource:p,columns:m,scroll:{x:"max-content"},pagination:{pageSize:50,showSizeChanger:!0}})))},f=function(e){var t=e.embedded;return a().createElement("div",{style:t?void 0:{padding:"0 24px 24px"}},a().createElement(s,null))}},608:function(e,t,r){r.d(t,{R:function(){return c},b:function(){return s}});var n=r(485),a=r(155);function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function u(e,t,r,n,a,o,u){try{var l=e[o](u),i=l.value}catch(e){r(e);return}l.done?t(i):Promise.resolve(i).then(n,a)}function l(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],u=!0,l=!1;try{for(a=a.call(e);!(u=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);u=!0);}catch(e){l=!0,n=e}finally{try{u||null==a.return||a.return()}finally{if(l)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function c(){return(0,n.useApp)().apiClient}function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=c(),n=t.manual,o=void 0!==n&&n,s=t.refreshDeps,f=t.onSuccess,d=t.onError,y=l((0,a.useState)(void 0),2),p=y[0],m=y[1],h=l((0,a.useState)(!o),2),b=h[0],v=h[1],g=l((0,a.useState)(void 0),2),w=g[0],S=g[1],E=(0,a.useRef)(e);E.current=e;var k=(0,a.useRef)(f);k.current=f;var x=(0,a.useRef)(d);x.current=d;var A=(0,a.useRef)(!0),I=(0,a.useRef)(0);(0,a.useEffect)(function(){return A.current=!0,function(){A.current=!1}},[]);var j=(0,a.useCallback)(function(e){var t;return(t=function(){var t,n,a,o,u,l,c,s,f;return function(e,t){var r,n,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(u,"next",{value:i(0)}),l(u,"throw",{value:i(1)}),l(u,"return",{value:i(2)}),"function"==typeof Symbol&&l(u,Symbol.iterator,{value:function(){return this}}),u;function i(l){return function(i){var c=[l,i];if(r)throw TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&c[0]?n.return:c[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,c[1])).done)return a;switch(n=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,n=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){o=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){o.label=c[1];break}if(6===c[0]&&o.label<a[1]){o.label=a[1],a=c;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(c);break}a[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],n=0}finally{r=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(d){switch(d.label){case 0:t=E.current,n=++I.current,a=function(){return A.current&&n===I.current},v(!0),S(void 0),d.label=1;case 1:if(d.trys.push([1,6,7,8]),"function"!=typeof t)return[3,3];return[4,t()];case 2:return u=d.sent(),[3,5];case 3:return[4,r.request({url:t.url,method:t.method||"get",params:function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},t.params||{},e||{}),data:t.data})];case 4:u=(c=null==(l=d.sent())?void 0:l.data)&&(void 0===c?"undefined":i(c))==="object"&&c.data&&"object"===i(c.data)&&"data"in c.data?c.data:c,d.label=5;case 5:if(!a())return[2,void 0];return m(u),null==(o=k.current)||o.call(k,u),[2,u];case 6:if(s=d.sent(),!a())return[2,void 0];return S(s),null==(f=x.current)||f.call(x,s),[2,void 0];case 7:return a()&&v(!1),[7];case 8:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(n,a){var o=t.apply(e,r);function l(e){u(o,n,a,l,i,"next",e)}function i(e){u(o,n,a,l,i,"throw",e)}l(void 0)})})()},[r]),O=(0,a.useCallback)(function(){j()},[j]);return(0,a.useEffect)(function(){o||j()},void 0===s?[]:s),{data:p,loading:b,error:w,refresh:O,run:j}}}}]);
@@ -0,0 +1,10 @@
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
+ "use strict";(self.webpackChunkplugin_agent_orchestrator=self.webpackChunkplugin_agent_orchestrator||[]).push([["325"],{660:function(e,t,n){n.r(t),n.d(t,{default:function(){return I}});var r=n(155),l=n.n(r),a=n(532),o=n(59),c=n(185),i=n.n(c),u=n(608),d=n(603),s=n(956);function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function p(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function g(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,l=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=l){var a=[],o=!0,c=!1;try{for(l=l.call(e);!(o=(n=l.next()).done)&&(a.push(n.value),!t||a.length!==t);o=!0);}catch(e){c=!0,r=e}finally{try{o||null==l.return||l.return()}finally{if(c)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return m(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return m(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var y=o.Typography.Text;function v(e){if(null==e||""===e)return"—";var t=Number(e);return Number.isFinite(t)?t.toLocaleString(void 0,{maximumFractionDigits:8}):"—"}var b=[i()().subtract(29,"day").startOf("day"),i()().endOf("day")],E=function(){var e,t,n,a,c,i,m,E,I,h,S,k,w,C,O=(0,d.k)(),T=f(o.Form.useForm(),1)[0],D=f((0,r.useState)({from:b[0].toISOString(),to:b[1].add(1,"millisecond").toISOString()}),2),x=D[0],U=D[1],P=f((0,r.useState)("model"),2),j=P[0],A=P[1],M=f((0,r.useState)(1),2),F=M[0],L=M[1],z=f((0,r.useState)(1),2),B=z[0],N=z[1],_=f((0,r.useState)(null),2),R=_[0],G=_[1],K=(0,r.useMemo)(function(){return g(p({},x),{groupBy:j,page:F,pageSize:20})},[x,j,F]),V=(0,r.useMemo)(function(){return g(p({},x),{page:B,pageSize:20})},[x,B]),q=(0,u.b)({url:"agentUsage:summary",params:x},{refreshDeps:[x]}),$=(0,u.b)({url:"agentUsage:breakdown",params:K},{refreshDeps:[K]}),H=(0,u.b)({url:"agentUsage:calls",params:V},{refreshDeps:[V]}),J=null==(e=q.data)?void 0:e.data,Q=[{title:O("Group"),dataIndex:"key",render:function(e){return null!=e?e:O("Unknown")}},{title:O("Department attribution"),dataIndex:"departmentAttribution",render:function(e){return e?O("Usage attribution: ".concat(e)):"—"}},{title:O("Model calls"),dataIndex:"calls",render:v},{title:O("Input tokens"),dataIndex:"inputTokens",render:v},{title:O("Output tokens"),dataIndex:"outputTokens",render:v},{title:O("Priced subtotal"),key:"cost",render:function(e,t){return"".concat(v(t.knownCost)," ").concat(t.currency||"")}},{title:O("Missing usage calls"),dataIndex:"missingCalls",render:v},{title:O("Unpriced calls"),dataIndex:"unpricedCalls",render:v}],W=[{title:O("Time"),key:"time",render:function(e,t){var n=t.usageOccurredAt||t.startedAt||t.createdAt;if(!n)return"—";var r=new Date(n);return Number.isNaN(r.getTime())?"—":r.toLocaleString()}},{title:O("Model"),dataIndex:"model",render:function(e){return e||"—"}},{title:O("Employee"),dataIndex:"employeeUsername",render:function(e){return e||"—"}},{title:O("User ID"),dataIndex:"userId",render:function(e){return null!=e?e:"—"}},{title:O("Department ID"),dataIndex:"departmentId",render:function(e){return null!=e?e:"—"}},{title:O("Input tokens"),dataIndex:"inputTokens",render:v},{title:O("Output tokens"),dataIndex:"outputTokens",render:v},{title:O("Cost"),key:"cost",render:function(e,t){return"".concat(v(t.cost)," ").concat(t.priceCurrency||"")}},{title:O("Usage source"),dataIndex:"usageSource",render:function(e){return e?O(e):O("Unknown")}},{title:O("Actions"),key:"actions",render:function(e,t){return l().createElement(o.Button,{onClick:function(){return G(t)}},O("Details"))}}];return l().createElement(o.Space,{direction:"vertical",size:"large",style:{width:"100%"}},l().createElement(o.Alert,{type:"info",showIcon:!0,message:O("Usage ledger coverage"),description:O("Usage ledger coverage description")}),l().createElement(o.Card,{title:O("Usage filters")},l().createElement(o.Form,{form:T,layout:"vertical",initialValues:{dates:b},onFinish:function(e){for(var t=f(e.dates||b,2),n=t[0],r=t[1],l={from:n.startOf("day").toISOString(),to:r.add(1,"day").startOf("day").toISOString()},a=0,o=["provider","llmService","model","employeeUsername","userId","departmentId"];a<o.length;a++){var c,i=o[a],u=null==(c=e[i])?void 0:c.trim();u&&(l[i]=u)}e.includeInferredDepartment&&(l.includeInferredDepartment=!0),L(1),N(1),G(null),U(l)}},l().createElement(o.Space,{wrap:!0,align:"start"},l().createElement(o.Form.Item,{name:"dates",label:O("Date range"),rules:[{required:!0,message:O("Select a date range")}]},l().createElement(o.DatePicker.RangePicker,{allowClear:!1})),l().createElement(o.Form.Item,{name:"employeeUsername",label:O("Employee")},l().createElement(s.j,{placeholder:O("All employees")})),l().createElement(o.Form.Item,{name:"provider",label:O("Provider")},l().createElement(o.Input,{allowClear:!0})),l().createElement(o.Form.Item,{name:"llmService",label:O("LLM service")},l().createElement(o.Input,{allowClear:!0})),l().createElement(o.Form.Item,{name:"model",label:O("Model")},l().createElement(o.Input,{allowClear:!0})),l().createElement(o.Form.Item,{name:"userId",label:O("User ID")},l().createElement(o.Input,{allowClear:!0,inputMode:"numeric"})),l().createElement(o.Form.Item,{name:"departmentId",label:O("Department ID")},l().createElement(o.Input,{allowClear:!0,inputMode:"numeric"}))),l().createElement(o.Form.Item,{name:"includeInferredDepartment",valuePropName:"checked",label:O("Include inferred departments")},l().createElement(o.Switch,{"aria-label":O("Include inferred departments")})),l().createElement(o.Button,{type:"primary",htmlType:"submit"},O("Apply filters")))),!!(q.error||$.error||H.error)&&l().createElement(o.Alert,{type:"error",showIcon:!0,message:O("Unable to load usage data")}),l().createElement(o.Card,{title:O("Usage summary"),loading:q.loading},l().createElement(o.Space,{direction:"vertical",style:{width:"100%"}},l().createElement(o.Space,{wrap:!0},l().createElement(o.Tag,null,O("Model calls"),": ",v(null==J?void 0:J.calls)),l().createElement(o.Tag,null,O("Input tokens"),": ",v(null==J?void 0:J.inputTokens)),l().createElement(o.Tag,null,O("Output tokens"),": ",v(null==J?void 0:J.outputTokens)),l().createElement(o.Tag,null,O("Cached input tokens"),": ",v(null==J?void 0:J.cachedTokens)),l().createElement(o.Tag,null,O("Reasoning tokens"),": ",v(null==J?void 0:J.reasoningTokens)),l().createElement(o.Tag,null,O("Actual usage calls"),": ",v(null==J?void 0:J.actualCalls)),l().createElement(o.Tag,{color:"gold"},O("Estimated calls"),": ",v(null==J?void 0:J.estimatedCalls)),l().createElement(o.Tag,{color:"gold"},O("Missing usage calls"),": ",v(null==J?void 0:J.missingCalls)),l().createElement(o.Tag,{color:"gold"},O("Unpriced calls"),": ",v(null==J?void 0:J.unpricedCalls))),l().createElement(o.Space,{wrap:!0},l().createElement(o.Tag,null,O("Department snapshot calls"),": ",v(null==J||null==(t=J.coverage)?void 0:t.snapshotCalls)),l().createElement(o.Tag,null,O("Department inferred calls"),": ",v(null==J||null==(n=J.coverage)?void 0:n.inferredCalls)),l().createElement(o.Tag,{color:"gold"},O("Department unattributed calls"),": ",v(null==J||null==(a=J.coverage)?void 0:a.unattributedCalls)),l().createElement(o.Tag,{color:"gold"},O("Calls without usage identity"),": ",v(null==J||null==(c=J.coverage)?void 0:c.unidentifiedCalls))),l().createElement(y,null,O("Priced subtotal"),":"," ",(null==J||null==(i=J.costByCurrency)?void 0:i.length)?J.costByCurrency.map(function(e){return"".concat(v(e.knownCost)," ").concat(e.currency)}).join(", "):"—"),l().createElement(y,{type:"secondary"},O("Inferred departments are current membership only")))),l().createElement(o.Card,{title:O("Usage breakdown"),extra:l().createElement(o.Select,{"aria-label":O("Group by"),value:j,style:{width:180},onChange:function(e){L(1),A(e)},options:[{value:"model",label:O("Model")},{value:"provider",label:O("Provider")},{value:"llmService",label:O("LLM service")},{value:"employeeUsername",label:O("Employee")},{value:"userId",label:O("User")},{value:"departmentId",label:O("Department")}]})},l().createElement(o.Table,{rowKey:function(e){var t,n,r;return"".concat(null!=(t=e.key)?t:"unknown",":").concat(null!=(n=e.currency)?n:"",":").concat(null!=(r=e.departmentAttribution)?r:"")},columns:Q,dataSource:(null==(m=$.data)?void 0:m.data)||[],loading:$.loading,scroll:{x:"max-content"},pagination:{current:F,pageSize:20,total:(F-1)*20+((null==(I=$.data)||null==(E=I.data)?void 0:E.length)||0)+ +(null!=(S=$.data)&&null!=(h=S.meta)&&!!h.hasMore),showSizeChanger:!1,onChange:L}})),l().createElement(o.Card,{title:O("Model calls")},l().createElement(o.Table,{rowKey:"id",columns:W,dataSource:(null==(k=H.data)?void 0:k.data)||[],loading:H.loading,scroll:{x:"max-content"},pagination:{current:B,pageSize:20,total:(null==(C=H.data)||null==(w=C.meta)?void 0:w.count)||0,onChange:N}})),R&&l().createElement(o.Card,{title:O("Model call details"),extra:l().createElement(o.Button,{onClick:function(){return G(null)}},O("Close"))},l().createElement(o.Space,{direction:"vertical"},l().createElement(y,null,O("Provider"),": ",R.provider||"—"),l().createElement(y,null,O("LLM service"),": ",R.llmService||"—"),l().createElement(y,null,O("Cached input tokens"),": ",v(R.cachedTokens)),l().createElement(y,null,O("Reasoning tokens"),": ",v(R.reasoningTokens)),l().createElement(y,null,O("Department attribution"),":"," ",R.departmentAttribution?O("Usage attribution: ".concat(R.departmentAttribution)):O("Unknown")),l().createElement(y,null,O("Pricing status"),": ",R.pricingStatus||"—"),l().createElement(y,null,O("Price version"),": ",R.priceVersion||"—"),l().createElement(y,null,O("Session"),": ",R.usageSessionId||"—"))))},I=function(e){var t=e.embedded;return l().createElement(a.l,null,l().createElement("div",{style:t?void 0:{padding:"0 24px 24px"}},l().createElement(E,null)))}}}]);