claude-flow-novice 1.0.0

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 (1334) hide show
  1. package/.claude/agents/MIGRATION_SUMMARY.md +222 -0
  2. package/.claude/agents/README.md +89 -0
  3. package/.claude/agents/analysis/code-analyzer.md +209 -0
  4. package/.claude/agents/analysis/code-review/analyze-code-quality.md +180 -0
  5. package/.claude/agents/architecture/system-design/arch-system-design.md +156 -0
  6. package/.claude/agents/base-template-generator.md +42 -0
  7. package/.claude/agents/consensus/README.md +253 -0
  8. package/.claude/agents/consensus/byzantine-coordinator.md +63 -0
  9. package/.claude/agents/consensus/consensus-builder.md +242 -0
  10. package/.claude/agents/consensus/crdt-synchronizer.md +997 -0
  11. package/.claude/agents/consensus/gossip-coordinator.md +63 -0
  12. package/.claude/agents/consensus/performance-benchmarker.md +851 -0
  13. package/.claude/agents/consensus/quorum-manager.md +823 -0
  14. package/.claude/agents/consensus/raft-manager.md +63 -0
  15. package/.claude/agents/consensus/security-manager.md +622 -0
  16. package/.claude/agents/core/coder.md +211 -0
  17. package/.claude/agents/core/planner.md +116 -0
  18. package/.claude/agents/core/researcher.md +136 -0
  19. package/.claude/agents/core/reviewer.md +272 -0
  20. package/.claude/agents/core/tester.md +266 -0
  21. package/.claude/agents/data/ml/data-ml-model.md +193 -0
  22. package/.claude/agents/development/backend/dev-backend-api.md +142 -0
  23. package/.claude/agents/devops/ci-cd/ops-cicd-github.md +164 -0
  24. package/.claude/agents/documentation/api-docs/docs-api-openapi.md +174 -0
  25. package/.claude/agents/flow-nexus/app-store.md +88 -0
  26. package/.claude/agents/flow-nexus/authentication.md +69 -0
  27. package/.claude/agents/flow-nexus/challenges.md +81 -0
  28. package/.claude/agents/flow-nexus/neural-network.md +88 -0
  29. package/.claude/agents/flow-nexus/payments.md +83 -0
  30. package/.claude/agents/flow-nexus/sandbox.md +76 -0
  31. package/.claude/agents/flow-nexus/swarm.md +76 -0
  32. package/.claude/agents/flow-nexus/user-tools.md +96 -0
  33. package/.claude/agents/flow-nexus/workflow.md +84 -0
  34. package/.claude/agents/github/code-review-swarm.md +538 -0
  35. package/.claude/agents/github/github-modes.md +173 -0
  36. package/.claude/agents/github/issue-tracker.md +319 -0
  37. package/.claude/agents/github/multi-repo-swarm.md +553 -0
  38. package/.claude/agents/github/pr-manager.md +191 -0
  39. package/.claude/agents/github/project-board-sync.md +509 -0
  40. package/.claude/agents/github/release-manager.md +367 -0
  41. package/.claude/agents/github/release-swarm.md +583 -0
  42. package/.claude/agents/github/repo-architect.md +398 -0
  43. package/.claude/agents/github/swarm-issue.md +573 -0
  44. package/.claude/agents/github/swarm-pr.md +428 -0
  45. package/.claude/agents/github/sync-coordinator.md +452 -0
  46. package/.claude/agents/github/workflow-automation.md +635 -0
  47. package/.claude/agents/goal/goal-planner.md +73 -0
  48. package/.claude/agents/neural/safla-neural.md +74 -0
  49. package/.claude/agents/optimization/README.md +250 -0
  50. package/.claude/agents/optimization/benchmark-suite.md +665 -0
  51. package/.claude/agents/optimization/load-balancer.md +431 -0
  52. package/.claude/agents/optimization/performance-monitor.md +672 -0
  53. package/.claude/agents/optimization/resource-allocator.md +674 -0
  54. package/.claude/agents/optimization/topology-optimizer.md +808 -0
  55. package/.claude/agents/sparc/architecture.md +472 -0
  56. package/.claude/agents/sparc/pseudocode.md +318 -0
  57. package/.claude/agents/sparc/refinement.md +525 -0
  58. package/.claude/agents/sparc/specification.md +276 -0
  59. package/.claude/agents/specialized/mobile/spec-mobile-react-native.md +226 -0
  60. package/.claude/agents/sublinear/consciousness-evolution-agent.md +499 -0
  61. package/.claude/agents/sublinear/matrix-solver-agent.md +113 -0
  62. package/.claude/agents/sublinear/nanosecond-scheduler-agent.md +644 -0
  63. package/.claude/agents/sublinear/pagerank-agent.md +699 -0
  64. package/.claude/agents/sublinear/phi-calculator-agent.md +749 -0
  65. package/.claude/agents/sublinear/psycho-symbolic-agent.md +543 -0
  66. package/.claude/agents/sublinear/sublinear.md +816 -0
  67. package/.claude/agents/sublinear/temporal-advantage-agent.md +360 -0
  68. package/.claude/agents/swarm/README.md +190 -0
  69. package/.claude/agents/swarm/adaptive-coordinator.md +396 -0
  70. package/.claude/agents/swarm/hierarchical-coordinator.md +300 -0
  71. package/.claude/agents/swarm/mesh-coordinator.md +435 -0
  72. package/.claude/agents/templates/automation-smart-agent.md +205 -0
  73. package/.claude/agents/templates/coordinator-swarm-init.md +90 -0
  74. package/.claude/agents/templates/github-pr-manager.md +177 -0
  75. package/.claude/agents/templates/implementer-sparc-coder.md +259 -0
  76. package/.claude/agents/templates/memory-coordinator.md +187 -0
  77. package/.claude/agents/templates/migration-plan.md +746 -0
  78. package/.claude/agents/templates/orchestrator-task.md +139 -0
  79. package/.claude/agents/templates/performance-analyzer.md +199 -0
  80. package/.claude/agents/templates/sparc-coordinator.md +183 -0
  81. package/.claude/agents/testing/e2e/playwright-agent.md +249 -0
  82. package/.claude/agents/testing/unit/tdd-london-swarm.md +244 -0
  83. package/.claude/agents/testing/validation/production-validator.md +395 -0
  84. package/.claude/commands/agents/README.md +10 -0
  85. package/.claude/commands/agents/agent-capabilities.md +21 -0
  86. package/.claude/commands/agents/agent-coordination.md +28 -0
  87. package/.claude/commands/agents/agent-spawning.md +28 -0
  88. package/.claude/commands/agents/agent-types.md +26 -0
  89. package/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +54 -0
  90. package/.claude/commands/analysis/README.md +9 -0
  91. package/.claude/commands/analysis/bottleneck-detect.md +162 -0
  92. package/.claude/commands/analysis/performance-bottlenecks.md +59 -0
  93. package/.claude/commands/analysis/performance-report.md +25 -0
  94. package/.claude/commands/analysis/token-efficiency.md +45 -0
  95. package/.claude/commands/analysis/token-usage.md +25 -0
  96. package/.claude/commands/automation/README.md +9 -0
  97. package/.claude/commands/automation/auto-agent.md +122 -0
  98. package/.claude/commands/automation/self-healing.md +106 -0
  99. package/.claude/commands/automation/session-memory.md +90 -0
  100. package/.claude/commands/automation/smart-agents.md +73 -0
  101. package/.claude/commands/automation/smart-spawn.md +25 -0
  102. package/.claude/commands/automation/workflow-select.md +25 -0
  103. package/.claude/commands/coordination/README.md +9 -0
  104. package/.claude/commands/coordination/agent-spawn.md +25 -0
  105. package/.claude/commands/coordination/init.md +44 -0
  106. package/.claude/commands/coordination/orchestrate.md +43 -0
  107. package/.claude/commands/coordination/spawn.md +45 -0
  108. package/.claude/commands/coordination/swarm-init.md +85 -0
  109. package/.claude/commands/coordination/task-orchestrate.md +25 -0
  110. package/.claude/commands/flow-nexus/app-store.md +124 -0
  111. package/.claude/commands/flow-nexus/challenges.md +120 -0
  112. package/.claude/commands/flow-nexus/login-registration.md +65 -0
  113. package/.claude/commands/flow-nexus/neural-network.md +134 -0
  114. package/.claude/commands/flow-nexus/payments.md +116 -0
  115. package/.claude/commands/flow-nexus/sandbox.md +83 -0
  116. package/.claude/commands/flow-nexus/swarm.md +87 -0
  117. package/.claude/commands/flow-nexus/user-tools.md +152 -0
  118. package/.claude/commands/flow-nexus/workflow.md +115 -0
  119. package/.claude/commands/github/README.md +11 -0
  120. package/.claude/commands/github/code-review-swarm.md +514 -0
  121. package/.claude/commands/github/code-review.md +25 -0
  122. package/.claude/commands/github/github-modes.md +147 -0
  123. package/.claude/commands/github/github-swarm.md +121 -0
  124. package/.claude/commands/github/issue-tracker.md +292 -0
  125. package/.claude/commands/github/issue-triage.md +25 -0
  126. package/.claude/commands/github/multi-repo-swarm.md +519 -0
  127. package/.claude/commands/github/pr-enhance.md +26 -0
  128. package/.claude/commands/github/pr-manager.md +170 -0
  129. package/.claude/commands/github/project-board-sync.md +471 -0
  130. package/.claude/commands/github/release-manager.md +338 -0
  131. package/.claude/commands/github/release-swarm.md +544 -0
  132. package/.claude/commands/github/repo-analyze.md +25 -0
  133. package/.claude/commands/github/repo-architect.md +367 -0
  134. package/.claude/commands/github/swarm-issue.md +482 -0
  135. package/.claude/commands/github/swarm-pr.md +285 -0
  136. package/.claude/commands/github/sync-coordinator.md +301 -0
  137. package/.claude/commands/github/workflow-automation.md +442 -0
  138. package/.claude/commands/hive-mind/README.md +17 -0
  139. package/.claude/commands/hive-mind/hive-mind-consensus.md +8 -0
  140. package/.claude/commands/hive-mind/hive-mind-init.md +18 -0
  141. package/.claude/commands/hive-mind/hive-mind-memory.md +8 -0
  142. package/.claude/commands/hive-mind/hive-mind-metrics.md +8 -0
  143. package/.claude/commands/hive-mind/hive-mind-resume.md +8 -0
  144. package/.claude/commands/hive-mind/hive-mind-sessions.md +8 -0
  145. package/.claude/commands/hive-mind/hive-mind-spawn.md +21 -0
  146. package/.claude/commands/hive-mind/hive-mind-status.md +8 -0
  147. package/.claude/commands/hive-mind/hive-mind-stop.md +8 -0
  148. package/.claude/commands/hive-mind/hive-mind-wizard.md +8 -0
  149. package/.claude/commands/hive-mind/hive-mind.md +27 -0
  150. package/.claude/commands/hooks/README.md +11 -0
  151. package/.claude/commands/hooks/overview.md +58 -0
  152. package/.claude/commands/hooks/post-edit.md +117 -0
  153. package/.claude/commands/hooks/post-task.md +112 -0
  154. package/.claude/commands/hooks/pre-edit.md +113 -0
  155. package/.claude/commands/hooks/pre-task.md +111 -0
  156. package/.claude/commands/hooks/session-end.md +118 -0
  157. package/.claude/commands/hooks/setup.md +103 -0
  158. package/.claude/commands/memory/README.md +9 -0
  159. package/.claude/commands/memory/memory-persist.md +25 -0
  160. package/.claude/commands/memory/memory-search.md +25 -0
  161. package/.claude/commands/memory/memory-usage.md +25 -0
  162. package/.claude/commands/memory/neural.md +47 -0
  163. package/.claude/commands/memory/usage.md +46 -0
  164. package/.claude/commands/monitoring/README.md +9 -0
  165. package/.claude/commands/monitoring/agent-metrics.md +25 -0
  166. package/.claude/commands/monitoring/agents.md +44 -0
  167. package/.claude/commands/monitoring/real-time-view.md +25 -0
  168. package/.claude/commands/monitoring/status.md +46 -0
  169. package/.claude/commands/monitoring/swarm-monitor.md +25 -0
  170. package/.claude/commands/optimization/README.md +9 -0
  171. package/.claude/commands/optimization/auto-topology.md +62 -0
  172. package/.claude/commands/optimization/cache-manage.md +25 -0
  173. package/.claude/commands/optimization/parallel-execute.md +25 -0
  174. package/.claude/commands/optimization/parallel-execution.md +50 -0
  175. package/.claude/commands/optimization/topology-optimize.md +25 -0
  176. package/.claude/commands/pair/README.md +261 -0
  177. package/.claude/commands/pair/commands.md +546 -0
  178. package/.claude/commands/pair/config.md +510 -0
  179. package/.claude/commands/pair/examples.md +512 -0
  180. package/.claude/commands/pair/modes.md +348 -0
  181. package/.claude/commands/pair/session.md +407 -0
  182. package/.claude/commands/pair/start.md +209 -0
  183. package/.claude/commands/sparc/analyzer.md +52 -0
  184. package/.claude/commands/sparc/architect.md +53 -0
  185. package/.claude/commands/sparc/batch-executor.md +54 -0
  186. package/.claude/commands/sparc/coder.md +54 -0
  187. package/.claude/commands/sparc/debugger.md +54 -0
  188. package/.claude/commands/sparc/designer.md +53 -0
  189. package/.claude/commands/sparc/documenter.md +54 -0
  190. package/.claude/commands/sparc/innovator.md +54 -0
  191. package/.claude/commands/sparc/memory-manager.md +54 -0
  192. package/.claude/commands/sparc/optimizer.md +54 -0
  193. package/.claude/commands/sparc/orchestrator.md +132 -0
  194. package/.claude/commands/sparc/researcher.md +54 -0
  195. package/.claude/commands/sparc/reviewer.md +54 -0
  196. package/.claude/commands/sparc/sparc-modes.md +174 -0
  197. package/.claude/commands/sparc/swarm-coordinator.md +54 -0
  198. package/.claude/commands/sparc/tdd.md +54 -0
  199. package/.claude/commands/sparc/tester.md +54 -0
  200. package/.claude/commands/sparc/workflow-manager.md +54 -0
  201. package/.claude/commands/stream-chain/pipeline.md +121 -0
  202. package/.claude/commands/stream-chain/run.md +70 -0
  203. package/.claude/commands/swarm/README.md +15 -0
  204. package/.claude/commands/swarm/analysis.md +95 -0
  205. package/.claude/commands/swarm/development.md +96 -0
  206. package/.claude/commands/swarm/examples.md +168 -0
  207. package/.claude/commands/swarm/maintenance.md +102 -0
  208. package/.claude/commands/swarm/optimization.md +117 -0
  209. package/.claude/commands/swarm/research.md +136 -0
  210. package/.claude/commands/swarm/swarm-analysis.md +8 -0
  211. package/.claude/commands/swarm/swarm-background.md +8 -0
  212. package/.claude/commands/swarm/swarm-init.md +19 -0
  213. package/.claude/commands/swarm/swarm-modes.md +8 -0
  214. package/.claude/commands/swarm/swarm-monitor.md +8 -0
  215. package/.claude/commands/swarm/swarm-spawn.md +19 -0
  216. package/.claude/commands/swarm/swarm-status.md +8 -0
  217. package/.claude/commands/swarm/swarm-strategies.md +8 -0
  218. package/.claude/commands/swarm/swarm.md +27 -0
  219. package/.claude/commands/swarm/testing.md +131 -0
  220. package/.claude/commands/testing/playwright-e2e.md +288 -0
  221. package/.claude/commands/training/README.md +9 -0
  222. package/.claude/commands/training/model-update.md +25 -0
  223. package/.claude/commands/training/neural-patterns.md +74 -0
  224. package/.claude/commands/training/neural-train.md +25 -0
  225. package/.claude/commands/training/pattern-learn.md +25 -0
  226. package/.claude/commands/training/specialization.md +63 -0
  227. package/.claude/commands/truth/start.md +143 -0
  228. package/.claude/commands/verify/check.md +50 -0
  229. package/.claude/commands/verify/start.md +128 -0
  230. package/.claude/commands/workflows/README.md +9 -0
  231. package/.claude/commands/workflows/development.md +78 -0
  232. package/.claude/commands/workflows/research.md +63 -0
  233. package/.claude/commands/workflows/workflow-create.md +25 -0
  234. package/.claude/commands/workflows/workflow-execute.md +25 -0
  235. package/.claude/commands/workflows/workflow-export.md +25 -0
  236. package/.claude/helpers/checkpoint-manager.sh +251 -0
  237. package/.claude/helpers/github-safe.js +106 -0
  238. package/.claude/helpers/github-setup.sh +28 -0
  239. package/.claude/helpers/quick-start.sh +19 -0
  240. package/.claude/helpers/setup-mcp.sh +18 -0
  241. package/.claude/helpers/standard-checkpoint-hooks.sh +179 -0
  242. package/.claude/settings.json +112 -0
  243. package/.claude/settings.local.json +10 -0
  244. package/CHANGELOG.md +1517 -0
  245. package/LICENSE +21 -0
  246. package/README.md +338 -0
  247. package/dist/src/adapters/cliffy-node.js +70 -0
  248. package/dist/src/adapters/cliffy-node.js.map +1 -0
  249. package/dist/src/agents/agent-loader.js +208 -0
  250. package/dist/src/agents/agent-loader.js.map +1 -0
  251. package/dist/src/agents/agent-manager.js +1786 -0
  252. package/dist/src/agents/agent-manager.js.map +1 -0
  253. package/dist/src/agents/agent-registry.js +356 -0
  254. package/dist/src/agents/agent-registry.js.map +1 -0
  255. package/dist/src/agents/agent-validator.js +273 -0
  256. package/dist/src/agents/agent-validator.js.map +1 -0
  257. package/dist/src/agents/github/agent-factory.js +553 -0
  258. package/dist/src/agents/github/agent-factory.js.map +1 -0
  259. package/dist/src/agents/github/compatibility/legacy-agent-mappings.js +307 -0
  260. package/dist/src/agents/github/compatibility/legacy-agent-mappings.js.map +1 -0
  261. package/dist/src/agents/github/compatibility/legacy-agent-proxy.js +334 -0
  262. package/dist/src/agents/github/compatibility/legacy-agent-proxy.js.map +1 -0
  263. package/dist/src/agents/github/core/github-collaboration-manager.js +796 -0
  264. package/dist/src/agents/github/core/github-collaboration-manager.js.map +1 -0
  265. package/dist/src/agents/github/core/github-integration-manager.js +546 -0
  266. package/dist/src/agents/github/core/github-integration-manager.js.map +1 -0
  267. package/dist/src/agents/github/core/github-release-coordinator.js +718 -0
  268. package/dist/src/agents/github/core/github-release-coordinator.js.map +1 -0
  269. package/dist/src/agents/github/index.js +68 -0
  270. package/dist/src/agents/github/index.js.map +1 -0
  271. package/dist/src/agents/github/types/index.js +6 -0
  272. package/dist/src/agents/github/types/index.js.map +1 -0
  273. package/dist/src/agents/github/utils/error-handling.js +496 -0
  274. package/dist/src/agents/github/utils/error-handling.js.map +1 -0
  275. package/dist/src/agents/github/utils/github-client.js +158 -0
  276. package/dist/src/agents/github/utils/github-client.js.map +1 -0
  277. package/dist/src/agents/github/utils/hook-integration.js +450 -0
  278. package/dist/src/agents/github/utils/hook-integration.js.map +1 -0
  279. package/dist/src/agents/github/utils/performance-optimizer.js +501 -0
  280. package/dist/src/agents/github/utils/performance-optimizer.js.map +1 -0
  281. package/dist/src/agents/hierarchical-coordinator.js +775 -0
  282. package/dist/src/agents/hierarchical-coordinator.js.map +1 -0
  283. package/dist/src/agents/lifecycle-manager.js +613 -0
  284. package/dist/src/agents/lifecycle-manager.js.map +1 -0
  285. package/dist/src/agents/mesh-coordinator.js +580 -0
  286. package/dist/src/agents/mesh-coordinator.js.map +1 -0
  287. package/dist/src/agents/simple-agent.js +89 -0
  288. package/dist/src/agents/simple-agent.js.map +1 -0
  289. package/dist/src/agents/task-agent-integration.js +240 -0
  290. package/dist/src/agents/task-agent-integration.js.map +1 -0
  291. package/dist/src/api/auth-service.js +474 -0
  292. package/dist/src/api/auth-service.js.map +1 -0
  293. package/dist/src/api/claude-api-errors.js +171 -0
  294. package/dist/src/api/claude-api-errors.js.map +1 -0
  295. package/dist/src/api/claude-client-enhanced.js +473 -0
  296. package/dist/src/api/claude-client-enhanced.js.map +1 -0
  297. package/dist/src/api/claude-client.js +527 -0
  298. package/dist/src/api/claude-client.js.map +1 -0
  299. package/dist/src/api/database-service.js +666 -0
  300. package/dist/src/api/database-service.js.map +1 -0
  301. package/dist/src/api/swarm-api.js +585 -0
  302. package/dist/src/api/swarm-api.js.map +1 -0
  303. package/dist/src/automation/test-pipeline/E2ETestGenerator.js +448 -0
  304. package/dist/src/automation/test-pipeline/E2ETestGenerator.js.map +1 -0
  305. package/dist/src/automation/test-pipeline/PerformanceMonitor.js +572 -0
  306. package/dist/src/automation/test-pipeline/PerformanceMonitor.js.map +1 -0
  307. package/dist/src/automation/test-pipeline/PipelineValidator.js +654 -0
  308. package/dist/src/automation/test-pipeline/PipelineValidator.js.map +1 -0
  309. package/dist/src/automation/test-pipeline/RegressionTestManager.js +545 -0
  310. package/dist/src/automation/test-pipeline/RegressionTestManager.js.map +1 -0
  311. package/dist/src/automation/test-pipeline/SwarmTestCoordinator.js +450 -0
  312. package/dist/src/automation/test-pipeline/SwarmTestCoordinator.js.map +1 -0
  313. package/dist/src/automation/test-pipeline/TestDataManager.js +708 -0
  314. package/dist/src/automation/test-pipeline/TestDataManager.js.map +1 -0
  315. package/dist/src/automation/test-pipeline/TestReportingSystem.js +527 -0
  316. package/dist/src/automation/test-pipeline/TestReportingSystem.js.map +1 -0
  317. package/dist/src/automation/test-pipeline/utils/chrome-mcp-integration.js +353 -0
  318. package/dist/src/automation/test-pipeline/utils/chrome-mcp-integration.js.map +1 -0
  319. package/dist/src/automation/test-pipeline/utils/swarm-coordinator.js +448 -0
  320. package/dist/src/automation/test-pipeline/utils/swarm-coordinator.js.map +1 -0
  321. package/dist/src/ci-cd/deployment-orchestrator.js +477 -0
  322. package/dist/src/ci-cd/deployment-orchestrator.js.map +1 -0
  323. package/dist/src/ci-cd/github-actions-templates.js +972 -0
  324. package/dist/src/ci-cd/github-actions-templates.js.map +1 -0
  325. package/dist/src/ci-cd/performance/PerformanceGate.js +383 -0
  326. package/dist/src/ci-cd/performance/PerformanceGate.js.map +1 -0
  327. package/dist/src/cli/agents/analyst.js +788 -0
  328. package/dist/src/cli/agents/analyst.js.map +1 -0
  329. package/dist/src/cli/agents/architect.js +846 -0
  330. package/dist/src/cli/agents/architect.js.map +1 -0
  331. package/dist/src/cli/agents/base-agent.js +437 -0
  332. package/dist/src/cli/agents/base-agent.js.map +1 -0
  333. package/dist/src/cli/agents/capabilities.js +701 -0
  334. package/dist/src/cli/agents/capabilities.js.map +1 -0
  335. package/dist/src/cli/agents/coder.js +936 -0
  336. package/dist/src/cli/agents/coder.js.map +1 -0
  337. package/dist/src/cli/agents/coordinator.js +489 -0
  338. package/dist/src/cli/agents/coordinator.js.map +1 -0
  339. package/dist/src/cli/agents/hive-agents.js +708 -0
  340. package/dist/src/cli/agents/hive-agents.js.map +1 -0
  341. package/dist/src/cli/agents/index.js +299 -0
  342. package/dist/src/cli/agents/index.js.map +1 -0
  343. package/dist/src/cli/agents/researcher.js +388 -0
  344. package/dist/src/cli/agents/researcher.js.map +1 -0
  345. package/dist/src/cli/agents/tester.js +634 -0
  346. package/dist/src/cli/agents/tester.js.map +1 -0
  347. package/dist/src/cli/cli-core.js +264 -0
  348. package/dist/src/cli/cli-core.js.map +1 -0
  349. package/dist/src/cli/commands/advanced-memory-commands.js +834 -0
  350. package/dist/src/cli/commands/advanced-memory-commands.js.map +1 -0
  351. package/dist/src/cli/commands/agent-simple.js +346 -0
  352. package/dist/src/cli/commands/agent-simple.js.map +1 -0
  353. package/dist/src/cli/commands/agent.js +368 -0
  354. package/dist/src/cli/commands/agent.js.map +1 -0
  355. package/dist/src/cli/commands/claude-api.js +237 -0
  356. package/dist/src/cli/commands/claude-api.js.map +1 -0
  357. package/dist/src/cli/commands/claude.js +132 -0
  358. package/dist/src/cli/commands/claude.js.map +1 -0
  359. package/dist/src/cli/commands/config-integration.js +395 -0
  360. package/dist/src/cli/commands/config-integration.js.map +1 -0
  361. package/dist/src/cli/commands/config.js +67 -0
  362. package/dist/src/cli/commands/config.js.map +1 -0
  363. package/dist/src/cli/commands/enterprise.js +1523 -0
  364. package/dist/src/cli/commands/enterprise.js.map +1 -0
  365. package/dist/src/cli/commands/goal-init.js +262 -0
  366. package/dist/src/cli/commands/goal-init.js.map +1 -0
  367. package/dist/src/cli/commands/help-new.js +276 -0
  368. package/dist/src/cli/commands/help-new.js.map +1 -0
  369. package/dist/src/cli/commands/help.js +1055 -0
  370. package/dist/src/cli/commands/help.js.map +1 -0
  371. package/dist/src/cli/commands/hive-mind/index.js +20 -0
  372. package/dist/src/cli/commands/hive-mind/index.js.map +1 -0
  373. package/dist/src/cli/commands/hive-mind/init.js +58 -0
  374. package/dist/src/cli/commands/hive-mind/init.js.map +1 -0
  375. package/dist/src/cli/commands/hive-mind/optimize-memory.js +362 -0
  376. package/dist/src/cli/commands/hive-mind/optimize-memory.js.map +1 -0
  377. package/dist/src/cli/commands/hive-mind/pause.js +73 -0
  378. package/dist/src/cli/commands/hive-mind/pause.js.map +1 -0
  379. package/dist/src/cli/commands/hive-mind/ps.js +104 -0
  380. package/dist/src/cli/commands/hive-mind/ps.js.map +1 -0
  381. package/dist/src/cli/commands/hive-mind/resume.js +56 -0
  382. package/dist/src/cli/commands/hive-mind/resume.js.map +1 -0
  383. package/dist/src/cli/commands/hive-mind/spawn.js +242 -0
  384. package/dist/src/cli/commands/hive-mind/spawn.js.map +1 -0
  385. package/dist/src/cli/commands/hive-mind/status.js +250 -0
  386. package/dist/src/cli/commands/hive-mind/status.js.map +1 -0
  387. package/dist/src/cli/commands/hive-mind/stop.js +116 -0
  388. package/dist/src/cli/commands/hive-mind/stop.js.map +1 -0
  389. package/dist/src/cli/commands/hive-mind/task.js +302 -0
  390. package/dist/src/cli/commands/hive-mind/task.js.map +1 -0
  391. package/dist/src/cli/commands/hive-mind/wizard.js +705 -0
  392. package/dist/src/cli/commands/hive-mind/wizard.js.map +1 -0
  393. package/dist/src/cli/commands/hive.js +506 -0
  394. package/dist/src/cli/commands/hive.js.map +1 -0
  395. package/dist/src/cli/commands/hook-types.js +5 -0
  396. package/dist/src/cli/commands/hook-types.js.map +1 -0
  397. package/dist/src/cli/commands/hook-validator.js +177 -0
  398. package/dist/src/cli/commands/hook-validator.js.map +1 -0
  399. package/dist/src/cli/commands/hook.js +303 -0
  400. package/dist/src/cli/commands/hook.js.map +1 -0
  401. package/dist/src/cli/commands/index.js +2745 -0
  402. package/dist/src/cli/commands/index.js.map +1 -0
  403. package/dist/src/cli/commands/maestro.js +242 -0
  404. package/dist/src/cli/commands/maestro.js.map +1 -0
  405. package/dist/src/cli/commands/mcp.js +148 -0
  406. package/dist/src/cli/commands/mcp.js.map +1 -0
  407. package/dist/src/cli/commands/memory.js +193 -0
  408. package/dist/src/cli/commands/memory.js.map +1 -0
  409. package/dist/src/cli/commands/migrate.js +107 -0
  410. package/dist/src/cli/commands/migrate.js.map +1 -0
  411. package/dist/src/cli/commands/monitor.js +574 -0
  412. package/dist/src/cli/commands/monitor.js.map +1 -0
  413. package/dist/src/cli/commands/neural-init.js +211 -0
  414. package/dist/src/cli/commands/neural-init.js.map +1 -0
  415. package/dist/src/cli/commands/ruv-swarm.js +555 -0
  416. package/dist/src/cli/commands/ruv-swarm.js.map +1 -0
  417. package/dist/src/cli/commands/session.js +517 -0
  418. package/dist/src/cli/commands/session.js.map +1 -0
  419. package/dist/src/cli/commands/sparc.js +486 -0
  420. package/dist/src/cli/commands/sparc.js.map +1 -0
  421. package/dist/src/cli/commands/start/event-emitter.js +35 -0
  422. package/dist/src/cli/commands/start/event-emitter.js.map +1 -0
  423. package/dist/src/cli/commands/start/index.js +9 -0
  424. package/dist/src/cli/commands/start/index.js.map +1 -0
  425. package/dist/src/cli/commands/start/process-manager.js +294 -0
  426. package/dist/src/cli/commands/start/process-manager.js.map +1 -0
  427. package/dist/src/cli/commands/start/process-ui-simple.js +322 -0
  428. package/dist/src/cli/commands/start/process-ui-simple.js.map +1 -0
  429. package/dist/src/cli/commands/start/process-ui.js +5 -0
  430. package/dist/src/cli/commands/start/process-ui.js.map +1 -0
  431. package/dist/src/cli/commands/start/start-command.js +463 -0
  432. package/dist/src/cli/commands/start/start-command.js.map +1 -0
  433. package/dist/src/cli/commands/start/system-monitor.js +268 -0
  434. package/dist/src/cli/commands/start/system-monitor.js.map +1 -0
  435. package/dist/src/cli/commands/start/types.js +22 -0
  436. package/dist/src/cli/commands/start/types.js.map +1 -0
  437. package/dist/src/cli/commands/start.js +6 -0
  438. package/dist/src/cli/commands/start.js.map +1 -0
  439. package/dist/src/cli/commands/status.js +328 -0
  440. package/dist/src/cli/commands/status.js.map +1 -0
  441. package/dist/src/cli/commands/swarm-spawn.js +56 -0
  442. package/dist/src/cli/commands/swarm-spawn.js.map +1 -0
  443. package/dist/src/cli/commands/swarm.js +567 -0
  444. package/dist/src/cli/commands/swarm.js.map +1 -0
  445. package/dist/src/cli/commands/task.js +44 -0
  446. package/dist/src/cli/commands/task.js.map +1 -0
  447. package/dist/src/cli/commands/validate-integration.js +122 -0
  448. package/dist/src/cli/commands/validate-integration.js.map +1 -0
  449. package/dist/src/cli/commands/verification.js +351 -0
  450. package/dist/src/cli/commands/verification.js.map +1 -0
  451. package/dist/src/cli/commands/workflow.js +615 -0
  452. package/dist/src/cli/commands/workflow.js.map +1 -0
  453. package/dist/src/cli/completion.js +578 -0
  454. package/dist/src/cli/completion.js.map +1 -0
  455. package/dist/src/cli/consolidated/ConsolidatedCLI.js +379 -0
  456. package/dist/src/cli/consolidated/ConsolidatedCLI.js.map +1 -0
  457. package/dist/src/cli/consolidated/core/CommandHandlers.js +833 -0
  458. package/dist/src/cli/consolidated/core/CommandHandlers.js.map +1 -0
  459. package/dist/src/cli/consolidated/core/TierManager.js +291 -0
  460. package/dist/src/cli/consolidated/core/TierManager.js.map +1 -0
  461. package/dist/src/cli/consolidated/help/InteractiveHelp.js +714 -0
  462. package/dist/src/cli/consolidated/help/InteractiveHelp.js.map +1 -0
  463. package/dist/src/cli/consolidated/index.js +62 -0
  464. package/dist/src/cli/consolidated/index.js.map +1 -0
  465. package/dist/src/cli/consolidated/intelligence/IntelligenceEngine.js +457 -0
  466. package/dist/src/cli/consolidated/intelligence/IntelligenceEngine.js.map +1 -0
  467. package/dist/src/cli/consolidated/routing/CommandRouter.js +526 -0
  468. package/dist/src/cli/consolidated/routing/CommandRouter.js.map +1 -0
  469. package/dist/src/cli/consolidated/utils/IntelligentDefaults.js +729 -0
  470. package/dist/src/cli/consolidated/utils/IntelligentDefaults.js.map +1 -0
  471. package/dist/src/cli/consolidated/utils/PerformanceOptimizer.js +416 -0
  472. package/dist/src/cli/consolidated/utils/PerformanceOptimizer.js.map +1 -0
  473. package/dist/src/cli/formatter.js +284 -0
  474. package/dist/src/cli/formatter.js.map +1 -0
  475. package/dist/src/cli/help-formatter.js +111 -0
  476. package/dist/src/cli/help-formatter.js.map +1 -0
  477. package/dist/src/cli/index-remote.js +125 -0
  478. package/dist/src/cli/index-remote.js.map +1 -0
  479. package/dist/src/cli/index.js +159 -0
  480. package/dist/src/cli/index.js.map +1 -0
  481. package/dist/src/cli/init/batch-tools.js +388 -0
  482. package/dist/src/cli/init/batch-tools.js.map +1 -0
  483. package/dist/src/cli/init/claude-config.js +401 -0
  484. package/dist/src/cli/init/claude-config.js.map +1 -0
  485. package/dist/src/cli/init/directory-structure.js +146 -0
  486. package/dist/src/cli/init/directory-structure.js.map +1 -0
  487. package/dist/src/cli/init/index.js +52 -0
  488. package/dist/src/cli/init/index.js.map +1 -0
  489. package/dist/src/cli/init/sparc-environment.js +543 -0
  490. package/dist/src/cli/init/sparc-environment.js.map +1 -0
  491. package/dist/src/cli/init/swarm-commands.js +796 -0
  492. package/dist/src/cli/init/swarm-commands.js.map +1 -0
  493. package/dist/src/cli/init/utils.js +15 -0
  494. package/dist/src/cli/init/utils.js.map +1 -0
  495. package/dist/src/cli/maestro-cli-bridge.js +426 -0
  496. package/dist/src/cli/maestro-cli-bridge.js.map +1 -0
  497. package/dist/src/cli/main.js +26 -0
  498. package/dist/src/cli/main.js.map +1 -0
  499. package/dist/src/cli/node-repl.js +652 -0
  500. package/dist/src/cli/node-repl.js.map +1 -0
  501. package/dist/src/cli/repl.js +1078 -0
  502. package/dist/src/cli/repl.js.map +1 -0
  503. package/dist/src/cli/simple-cli.js +3026 -0
  504. package/dist/src/cli/simple-cli.js.map +1 -0
  505. package/dist/src/cli/simple-mcp.js +87 -0
  506. package/dist/src/cli/simple-mcp.js.map +1 -0
  507. package/dist/src/cli/simple-orchestrator.js +857 -0
  508. package/dist/src/cli/simple-orchestrator.js.map +1 -0
  509. package/dist/src/cli/ui/compatible-ui.js +322 -0
  510. package/dist/src/cli/ui/compatible-ui.js.map +1 -0
  511. package/dist/src/cli/ui/fallback-handler.js +156 -0
  512. package/dist/src/cli/ui/fallback-handler.js.map +1 -0
  513. package/dist/src/cli/ui/index.js +32 -0
  514. package/dist/src/cli/ui/index.js.map +1 -0
  515. package/dist/src/cli/utils/environment-detector.js +228 -0
  516. package/dist/src/cli/utils/environment-detector.js.map +1 -0
  517. package/dist/src/cli/utils/prompt-defaults.js +234 -0
  518. package/dist/src/cli/utils/prompt-defaults.js.map +1 -0
  519. package/dist/src/cli/validation-helper.js +66 -0
  520. package/dist/src/cli/validation-helper.js.map +1 -0
  521. package/dist/src/communication/message-bus.js +1007 -0
  522. package/dist/src/communication/message-bus.js.map +1 -0
  523. package/dist/src/communication/reliable-communication-manager.js +374 -0
  524. package/dist/src/communication/reliable-communication-manager.js.map +1 -0
  525. package/dist/src/config/ai/decision-tree-generator.js +763 -0
  526. package/dist/src/config/ai/decision-tree-generator.js.map +1 -0
  527. package/dist/src/config/ai/project-detection-engine.js +1081 -0
  528. package/dist/src/config/ai/project-detection-engine.js.map +1 -0
  529. package/dist/src/config/config-manager.js +1285 -0
  530. package/dist/src/config/config-manager.js.map +1 -0
  531. package/dist/src/config/consent-manager.js +433 -0
  532. package/dist/src/config/consent-manager.js.map +1 -0
  533. package/dist/src/config/core/intelligent-configuration-manager.js +674 -0
  534. package/dist/src/config/core/intelligent-configuration-manager.js.map +1 -0
  535. package/dist/src/config/index.js +110 -0
  536. package/dist/src/config/index.js.map +1 -0
  537. package/dist/src/config/integration/hooks-integration.js +548 -0
  538. package/dist/src/config/integration/hooks-integration.js.map +1 -0
  539. package/dist/src/config/migration/config-migration.js +285 -0
  540. package/dist/src/config/migration/config-migration.js.map +1 -0
  541. package/dist/src/config/migration/version-migration-engine.js +984 -0
  542. package/dist/src/config/migration/version-migration-engine.js.map +1 -0
  543. package/dist/src/config/migration-manager.js +529 -0
  544. package/dist/src/config/migration-manager.js.map +1 -0
  545. package/dist/src/config/ruv-swarm-config.js +332 -0
  546. package/dist/src/config/ruv-swarm-config.js.map +1 -0
  547. package/dist/src/config/ruv-swarm-integration.js +285 -0
  548. package/dist/src/config/ruv-swarm-integration.js.map +1 -0
  549. package/dist/src/config/storage/multi-tier-storage.js +626 -0
  550. package/dist/src/config/storage/multi-tier-storage.js.map +1 -0
  551. package/dist/src/config/test-migration-fixer.js +332 -0
  552. package/dist/src/config/test-migration-fixer.js.map +1 -0
  553. package/dist/src/config/ui/progressive-disclosure-engine.js +876 -0
  554. package/dist/src/config/ui/progressive-disclosure-engine.js.map +1 -0
  555. package/dist/src/config/utils/config-export-import.js +454 -0
  556. package/dist/src/config/utils/config-export-import.js.map +1 -0
  557. package/dist/src/config/utils/zero-config-setup.js +238 -0
  558. package/dist/src/config/utils/zero-config-setup.js.map +1 -0
  559. package/dist/src/config/validation/config-validator.js +462 -0
  560. package/dist/src/config/validation/config-validator.js.map +1 -0
  561. package/dist/src/config/web-portal-config.js +343 -0
  562. package/dist/src/config/web-portal-config.js.map +1 -0
  563. package/dist/src/config/zero-config-setup.js +294 -0
  564. package/dist/src/config/zero-config-setup.js.map +1 -0
  565. package/dist/src/constants/agent-types.js +51 -0
  566. package/dist/src/constants/agent-types.js.map +1 -0
  567. package/dist/src/coordination/advanced-scheduler.js +370 -0
  568. package/dist/src/coordination/advanced-scheduler.js.map +1 -0
  569. package/dist/src/coordination/advanced-task-executor.js +481 -0
  570. package/dist/src/coordination/advanced-task-executor.js.map +1 -0
  571. package/dist/src/coordination/background-executor.js +366 -0
  572. package/dist/src/coordination/background-executor.js.map +1 -0
  573. package/dist/src/coordination/circuit-breaker.js +286 -0
  574. package/dist/src/coordination/circuit-breaker.js.map +1 -0
  575. package/dist/src/coordination/conflict-resolution.js +348 -0
  576. package/dist/src/coordination/conflict-resolution.js.map +1 -0
  577. package/dist/src/coordination/dependency-graph.js +398 -0
  578. package/dist/src/coordination/dependency-graph.js.map +1 -0
  579. package/dist/src/coordination/hive-orchestrator.js +309 -0
  580. package/dist/src/coordination/hive-orchestrator.js.map +1 -0
  581. package/dist/src/coordination/hive-protocol.js +363 -0
  582. package/dist/src/coordination/hive-protocol.js.map +1 -0
  583. package/dist/src/coordination/index.js +21 -0
  584. package/dist/src/coordination/index.js.map +1 -0
  585. package/dist/src/coordination/load-balancer.js +737 -0
  586. package/dist/src/coordination/load-balancer.js.map +1 -0
  587. package/dist/src/coordination/manager.js +360 -0
  588. package/dist/src/coordination/manager.js.map +1 -0
  589. package/dist/src/coordination/messaging.js +221 -0
  590. package/dist/src/coordination/messaging.js.map +1 -0
  591. package/dist/src/coordination/metrics.js +415 -0
  592. package/dist/src/coordination/metrics.js.map +1 -0
  593. package/dist/src/coordination/resources.js +276 -0
  594. package/dist/src/coordination/resources.js.map +1 -0
  595. package/dist/src/coordination/scheduler.js +322 -0
  596. package/dist/src/coordination/scheduler.js.map +1 -0
  597. package/dist/src/coordination/swarm-coordinator.js +585 -0
  598. package/dist/src/coordination/swarm-coordinator.js.map +1 -0
  599. package/dist/src/coordination/swarm-monitor.js +359 -0
  600. package/dist/src/coordination/swarm-monitor.js.map +1 -0
  601. package/dist/src/coordination/work-stealing.js +164 -0
  602. package/dist/src/coordination/work-stealing.js.map +1 -0
  603. package/dist/src/core/agent-manager.js +80 -0
  604. package/dist/src/core/agent-manager.js.map +1 -0
  605. package/dist/src/core/config.js +1221 -0
  606. package/dist/src/core/config.js.map +1 -0
  607. package/dist/src/core/event-bus.js +136 -0
  608. package/dist/src/core/event-bus.js.map +1 -0
  609. package/dist/src/core/index.js +6 -0
  610. package/dist/src/core/index.js.map +1 -0
  611. package/dist/src/core/json-persistence.js +112 -0
  612. package/dist/src/core/json-persistence.js.map +1 -0
  613. package/dist/src/core/logger.js +245 -0
  614. package/dist/src/core/logger.js.map +1 -0
  615. package/dist/src/core/orchestrator-fixed.js +236 -0
  616. package/dist/src/core/orchestrator-fixed.js.map +1 -0
  617. package/dist/src/core/orchestrator.js +1136 -0
  618. package/dist/src/core/orchestrator.js.map +1 -0
  619. package/dist/src/core/persistence.js +185 -0
  620. package/dist/src/core/persistence.js.map +1 -0
  621. package/dist/src/core/project-manager.js +80 -0
  622. package/dist/src/core/project-manager.js.map +1 -0
  623. package/dist/src/core/version.js +35 -0
  624. package/dist/src/core/version.js.map +1 -0
  625. package/dist/src/crdt/types.js +509 -0
  626. package/dist/src/crdt/types.js.map +1 -0
  627. package/dist/src/enterprise/analytics-manager.js +1133 -0
  628. package/dist/src/enterprise/analytics-manager.js.map +1 -0
  629. package/dist/src/enterprise/audit-manager.js +1112 -0
  630. package/dist/src/enterprise/audit-manager.js.map +1 -0
  631. package/dist/src/enterprise/cloud-manager.js +886 -0
  632. package/dist/src/enterprise/cloud-manager.js.map +1 -0
  633. package/dist/src/enterprise/deployment-manager.js +963 -0
  634. package/dist/src/enterprise/deployment-manager.js.map +1 -0
  635. package/dist/src/enterprise/index.js +8 -0
  636. package/dist/src/enterprise/index.js.map +1 -0
  637. package/dist/src/enterprise/project-manager.js +577 -0
  638. package/dist/src/enterprise/project-manager.js.map +1 -0
  639. package/dist/src/enterprise/security-manager.js +987 -0
  640. package/dist/src/enterprise/security-manager.js.map +1 -0
  641. package/dist/src/feature-flags/cli/Phase4CLI.js +463 -0
  642. package/dist/src/feature-flags/cli/Phase4CLI.js.map +1 -0
  643. package/dist/src/feature-flags/core/FeatureFlagManager.js +324 -0
  644. package/dist/src/feature-flags/core/FeatureFlagManager.js.map +1 -0
  645. package/dist/src/feature-flags/index.js +237 -0
  646. package/dist/src/feature-flags/index.js.map +1 -0
  647. package/dist/src/feature-flags/monitoring/RolloutMonitor.js +275 -0
  648. package/dist/src/feature-flags/monitoring/RolloutMonitor.js.map +1 -0
  649. package/dist/src/feature-flags/rollout/RolloutController.js +301 -0
  650. package/dist/src/feature-flags/rollout/RolloutController.js.map +1 -0
  651. package/dist/src/feature-flags/validation/HookInterceptor.js +310 -0
  652. package/dist/src/feature-flags/validation/HookInterceptor.js.map +1 -0
  653. package/dist/src/feature-flags/validation/TruthBasedValidator.js +263 -0
  654. package/dist/src/feature-flags/validation/TruthBasedValidator.js.map +1 -0
  655. package/dist/src/hive-mind/core/Agent.js +569 -0
  656. package/dist/src/hive-mind/core/Agent.js.map +1 -0
  657. package/dist/src/hive-mind/core/Communication.js +411 -0
  658. package/dist/src/hive-mind/core/Communication.js.map +1 -0
  659. package/dist/src/hive-mind/core/DatabaseManager.js +599 -0
  660. package/dist/src/hive-mind/core/DatabaseManager.js.map +1 -0
  661. package/dist/src/hive-mind/core/HiveMind.js +575 -0
  662. package/dist/src/hive-mind/core/HiveMind.js.map +1 -0
  663. package/dist/src/hive-mind/core/Memory.js +1159 -0
  664. package/dist/src/hive-mind/core/Memory.js.map +1 -0
  665. package/dist/src/hive-mind/core/MemoryMonitor.js +525 -0
  666. package/dist/src/hive-mind/core/MemoryMonitor.js.map +1 -0
  667. package/dist/src/hive-mind/core/Queen.js +753 -0
  668. package/dist/src/hive-mind/core/Queen.js.map +1 -0
  669. package/dist/src/hive-mind/index.js +21 -0
  670. package/dist/src/hive-mind/index.js.map +1 -0
  671. package/dist/src/hive-mind/integration/ConsensusEngine.js +460 -0
  672. package/dist/src/hive-mind/integration/ConsensusEngine.js.map +1 -0
  673. package/dist/src/hive-mind/integration/MCPToolWrapper.js +243 -0
  674. package/dist/src/hive-mind/integration/MCPToolWrapper.js.map +1 -0
  675. package/dist/src/hive-mind/integration/SwarmOrchestrator.js +812 -0
  676. package/dist/src/hive-mind/integration/SwarmOrchestrator.js.map +1 -0
  677. package/dist/src/hive-mind/types.js +9 -0
  678. package/dist/src/hive-mind/types.js.map +1 -0
  679. package/dist/src/hooks/index.js +197 -0
  680. package/dist/src/hooks/index.js.map +1 -0
  681. package/dist/src/index.js +11 -0
  682. package/dist/src/index.js.map +1 -0
  683. package/dist/src/integration/mock-components.js +362 -0
  684. package/dist/src/integration/mock-components.js.map +1 -0
  685. package/dist/src/integration/system-integration.js +428 -0
  686. package/dist/src/integration/system-integration.js.map +1 -0
  687. package/dist/src/integration/types.js +5 -0
  688. package/dist/src/integration/types.js.map +1 -0
  689. package/dist/src/lifecycle/communication-protocols.js +568 -0
  690. package/dist/src/lifecycle/communication-protocols.js.map +1 -0
  691. package/dist/src/lifecycle/dependency-tracker.js +799 -0
  692. package/dist/src/lifecycle/dependency-tracker.js.map +1 -0
  693. package/dist/src/lifecycle/memory-schema.js +622 -0
  694. package/dist/src/lifecycle/memory-schema.js.map +1 -0
  695. package/dist/src/maestro/maestro-swarm-coordinator.js +504 -0
  696. package/dist/src/maestro/maestro-swarm-coordinator.js.map +1 -0
  697. package/dist/src/maestro/maestro-types.js +3 -0
  698. package/dist/src/maestro/maestro-types.js.map +1 -0
  699. package/dist/src/maestro/tests/native-hive-mind-integration.test.js +382 -0
  700. package/dist/src/maestro/tests/native-hive-mind-integration.test.js.map +1 -0
  701. package/dist/src/mcp/auth.js +347 -0
  702. package/dist/src/mcp/auth.js.map +1 -0
  703. package/dist/src/mcp/claude-code-wrapper.js +717 -0
  704. package/dist/src/mcp/claude-code-wrapper.js.map +1 -0
  705. package/dist/src/mcp/claude-flow-tools.js +1365 -0
  706. package/dist/src/mcp/claude-flow-tools.js.map +1 -0
  707. package/dist/src/mcp/client.js +201 -0
  708. package/dist/src/mcp/client.js.map +1 -0
  709. package/dist/src/mcp/index.js +192 -0
  710. package/dist/src/mcp/index.js.map +1 -0
  711. package/dist/src/mcp/integrate-wrapper.js +85 -0
  712. package/dist/src/mcp/integrate-wrapper.js.map +1 -0
  713. package/dist/src/mcp/lifecycle-manager.js +348 -0
  714. package/dist/src/mcp/lifecycle-manager.js.map +1 -0
  715. package/dist/src/mcp/load-balancer.js +386 -0
  716. package/dist/src/mcp/load-balancer.js.map +1 -0
  717. package/dist/src/mcp/orchestration-integration.js +800 -0
  718. package/dist/src/mcp/orchestration-integration.js.map +1 -0
  719. package/dist/src/mcp/performance-monitor.js +489 -0
  720. package/dist/src/mcp/performance-monitor.js.map +1 -0
  721. package/dist/src/mcp/protocol-manager.js +376 -0
  722. package/dist/src/mcp/protocol-manager.js.map +1 -0
  723. package/dist/src/mcp/recovery/connection-health-monitor.js +240 -0
  724. package/dist/src/mcp/recovery/connection-health-monitor.js.map +1 -0
  725. package/dist/src/mcp/recovery/connection-state-manager.js +309 -0
  726. package/dist/src/mcp/recovery/connection-state-manager.js.map +1 -0
  727. package/dist/src/mcp/recovery/fallback-coordinator.js +288 -0
  728. package/dist/src/mcp/recovery/fallback-coordinator.js.map +1 -0
  729. package/dist/src/mcp/recovery/index.js +10 -0
  730. package/dist/src/mcp/recovery/index.js.map +1 -0
  731. package/dist/src/mcp/recovery/reconnection-manager.js +219 -0
  732. package/dist/src/mcp/recovery/reconnection-manager.js.map +1 -0
  733. package/dist/src/mcp/recovery/recovery-manager.js +262 -0
  734. package/dist/src/mcp/recovery/recovery-manager.js.map +1 -0
  735. package/dist/src/mcp/router.js +220 -0
  736. package/dist/src/mcp/router.js.map +1 -0
  737. package/dist/src/mcp/ruv-swarm-tools.js +671 -0
  738. package/dist/src/mcp/ruv-swarm-tools.js.map +1 -0
  739. package/dist/src/mcp/server-with-wrapper.js +32 -0
  740. package/dist/src/mcp/server-with-wrapper.js.map +1 -0
  741. package/dist/src/mcp/server-wrapper-mode.js +26 -0
  742. package/dist/src/mcp/server-wrapper-mode.js.map +1 -0
  743. package/dist/src/mcp/server.js +539 -0
  744. package/dist/src/mcp/server.js.map +1 -0
  745. package/dist/src/mcp/session-manager.js +338 -0
  746. package/dist/src/mcp/session-manager.js.map +1 -0
  747. package/dist/src/mcp/sparc-modes.js +455 -0
  748. package/dist/src/mcp/sparc-modes.js.map +1 -0
  749. package/dist/src/mcp/swarm-tools.js +903 -0
  750. package/dist/src/mcp/swarm-tools.js.map +1 -0
  751. package/dist/src/mcp/tests/mcp-integration.test.js +493 -0
  752. package/dist/src/mcp/tests/mcp-integration.test.js.map +1 -0
  753. package/dist/src/mcp/tools.js +426 -0
  754. package/dist/src/mcp/tools.js.map +1 -0
  755. package/dist/src/mcp/transports/base.js +5 -0
  756. package/dist/src/mcp/transports/base.js.map +1 -0
  757. package/dist/src/mcp/transports/http.js +414 -0
  758. package/dist/src/mcp/transports/http.js.map +1 -0
  759. package/dist/src/mcp/transports/stdio.js +217 -0
  760. package/dist/src/mcp/transports/stdio.js.map +1 -0
  761. package/dist/src/memory/advanced-memory-manager.js +1522 -0
  762. package/dist/src/memory/advanced-memory-manager.js.map +1 -0
  763. package/dist/src/memory/backends/base.js +5 -0
  764. package/dist/src/memory/backends/base.js.map +1 -0
  765. package/dist/src/memory/backends/markdown.js +235 -0
  766. package/dist/src/memory/backends/markdown.js.map +1 -0
  767. package/dist/src/memory/backends/sqlite.js +295 -0
  768. package/dist/src/memory/backends/sqlite.js.map +1 -0
  769. package/dist/src/memory/cache.js +177 -0
  770. package/dist/src/memory/cache.js.map +1 -0
  771. package/dist/src/memory/distributed-memory.js +745 -0
  772. package/dist/src/memory/distributed-memory.js.map +1 -0
  773. package/dist/src/memory/indexer.js +184 -0
  774. package/dist/src/memory/indexer.js.map +1 -0
  775. package/dist/src/memory/manager.js +457 -0
  776. package/dist/src/memory/manager.js.map +1 -0
  777. package/dist/src/memory/sqlite-enhanced-backend.js +529 -0
  778. package/dist/src/memory/sqlite-enhanced-backend.js.map +1 -0
  779. package/dist/src/memory/swarm-memory.js +446 -0
  780. package/dist/src/memory/swarm-memory.js.map +1 -0
  781. package/dist/src/migration/index.js +94 -0
  782. package/dist/src/migration/index.js.map +1 -0
  783. package/dist/src/migration/logger.js +110 -0
  784. package/dist/src/migration/logger.js.map +1 -0
  785. package/dist/src/migration/migration-analyzer.js +255 -0
  786. package/dist/src/migration/migration-analyzer.js.map +1 -0
  787. package/dist/src/migration/migration-runner.js +511 -0
  788. package/dist/src/migration/migration-runner.js.map +1 -0
  789. package/dist/src/migration/migration-validator.js +272 -0
  790. package/dist/src/migration/migration-validator.js.map +1 -0
  791. package/dist/src/migration/progress-reporter.js +139 -0
  792. package/dist/src/migration/progress-reporter.js.map +1 -0
  793. package/dist/src/migration/rollback-manager.js +310 -0
  794. package/dist/src/migration/rollback-manager.js.map +1 -0
  795. package/dist/src/migration/tests/migration-system.test.js +9 -0
  796. package/dist/src/migration/tests/migration-system.test.js.map +1 -0
  797. package/dist/src/migration/types.js +5 -0
  798. package/dist/src/migration/types.js.map +1 -0
  799. package/dist/src/monitoring/diagnostics.js +532 -0
  800. package/dist/src/monitoring/diagnostics.js.map +1 -0
  801. package/dist/src/monitoring/health-check.js +355 -0
  802. package/dist/src/monitoring/health-check.js.map +1 -0
  803. package/dist/src/monitoring/phase4/analytics/consensus-tracker.js +764 -0
  804. package/dist/src/monitoring/phase4/analytics/consensus-tracker.js.map +1 -0
  805. package/dist/src/monitoring/phase4/analytics/performance-assessor.js +859 -0
  806. package/dist/src/monitoring/phase4/analytics/performance-assessor.js.map +1 -0
  807. package/dist/src/monitoring/phase4/analytics/truth-score-analyzer.js +667 -0
  808. package/dist/src/monitoring/phase4/analytics/truth-score-analyzer.js.map +1 -0
  809. package/dist/src/monitoring/phase4/dashboard/monitoring-dashboard.js +1008 -0
  810. package/dist/src/monitoring/phase4/dashboard/monitoring-dashboard.js.map +1 -0
  811. package/dist/src/monitoring/phase4/rollout-decision-engine.js +849 -0
  812. package/dist/src/monitoring/phase4/rollout-decision-engine.js.map +1 -0
  813. package/dist/src/monitoring/real-time-feedback-system.js +688 -0
  814. package/dist/src/monitoring/real-time-feedback-system.js.map +1 -0
  815. package/dist/src/monitoring/real-time-monitor.js +981 -0
  816. package/dist/src/monitoring/real-time-monitor.js.map +1 -0
  817. package/dist/src/monitoring/regression/RegressionDetector.js +525 -0
  818. package/dist/src/monitoring/regression/RegressionDetector.js.map +1 -0
  819. package/dist/src/neural/NeuralDomainMapper.js +1137 -0
  820. package/dist/src/neural/NeuralDomainMapper.js.map +1 -0
  821. package/dist/src/neural/index.js +418 -0
  822. package/dist/src/neural/index.js.map +1 -0
  823. package/dist/src/neural/integration.js +590 -0
  824. package/dist/src/neural/integration.js.map +1 -0
  825. package/dist/src/providers/anthropic-provider.js +245 -0
  826. package/dist/src/providers/anthropic-provider.js.map +1 -0
  827. package/dist/src/providers/base-provider.js +389 -0
  828. package/dist/src/providers/base-provider.js.map +1 -0
  829. package/dist/src/providers/cohere-provider.js +405 -0
  830. package/dist/src/providers/cohere-provider.js.map +1 -0
  831. package/dist/src/providers/google-provider.js +376 -0
  832. package/dist/src/providers/google-provider.js.map +1 -0
  833. package/dist/src/providers/index.js +18 -0
  834. package/dist/src/providers/index.js.map +1 -0
  835. package/dist/src/providers/ollama-provider.js +400 -0
  836. package/dist/src/providers/ollama-provider.js.map +1 -0
  837. package/dist/src/providers/openai-provider.js +364 -0
  838. package/dist/src/providers/openai-provider.js.map +1 -0
  839. package/dist/src/providers/provider-manager.js +487 -0
  840. package/dist/src/providers/provider-manager.js.map +1 -0
  841. package/dist/src/providers/types.js +55 -0
  842. package/dist/src/providers/types.js.map +1 -0
  843. package/dist/src/providers/utils.js +343 -0
  844. package/dist/src/providers/utils.js.map +1 -0
  845. package/dist/src/quality-gates/automated-review-system.js +645 -0
  846. package/dist/src/quality-gates/automated-review-system.js.map +1 -0
  847. package/dist/src/resources/resource-manager.js +1275 -0
  848. package/dist/src/resources/resource-manager.js.map +1 -0
  849. package/dist/src/rollback/recovery-manager.js +1065 -0
  850. package/dist/src/rollback/recovery-manager.js.map +1 -0
  851. package/dist/src/services/agent-manager.js +308 -0
  852. package/dist/src/services/agent-manager.js.map +1 -0
  853. package/dist/src/services/agentic-flow-hooks/hook-manager.js +506 -0
  854. package/dist/src/services/agentic-flow-hooks/hook-manager.js.map +1 -0
  855. package/dist/src/services/agentic-flow-hooks/index.js +322 -0
  856. package/dist/src/services/agentic-flow-hooks/index.js.map +1 -0
  857. package/dist/src/services/agentic-flow-hooks/llm-hooks.js +445 -0
  858. package/dist/src/services/agentic-flow-hooks/llm-hooks.js.map +1 -0
  859. package/dist/src/services/agentic-flow-hooks/memory-hooks.js +558 -0
  860. package/dist/src/services/agentic-flow-hooks/memory-hooks.js.map +1 -0
  861. package/dist/src/services/agentic-flow-hooks/neural-hooks.js +595 -0
  862. package/dist/src/services/agentic-flow-hooks/neural-hooks.js.map +1 -0
  863. package/dist/src/services/agentic-flow-hooks/performance-hooks.js +640 -0
  864. package/dist/src/services/agentic-flow-hooks/performance-hooks.js.map +1 -0
  865. package/dist/src/services/agentic-flow-hooks/types.js +8 -0
  866. package/dist/src/services/agentic-flow-hooks/types.js.map +1 -0
  867. package/dist/src/services/agentic-flow-hooks/workflow-hooks.js +746 -0
  868. package/dist/src/services/agentic-flow-hooks/workflow-hooks.js.map +1 -0
  869. package/dist/src/services/performance-metrics-collector.js +529 -0
  870. package/dist/src/services/performance-metrics-collector.js.map +1 -0
  871. package/dist/src/services/swarm-coordinator.js +431 -0
  872. package/dist/src/services/swarm-coordinator.js.map +1 -0
  873. package/dist/src/services/swarm-memory-manager.js +513 -0
  874. package/dist/src/services/swarm-memory-manager.js.map +1 -0
  875. package/dist/src/services/swarm-relaunch-manager.js +408 -0
  876. package/dist/src/services/swarm-relaunch-manager.js.map +1 -0
  877. package/dist/src/services/task-handoff-service.js +361 -0
  878. package/dist/src/services/task-handoff-service.js.map +1 -0
  879. package/dist/src/swarm/__tests__/integration.test.js +229 -0
  880. package/dist/src/swarm/__tests__/integration.test.js.map +1 -0
  881. package/dist/src/swarm/__tests__/prompt-copier.test.js +346 -0
  882. package/dist/src/swarm/__tests__/prompt-copier.test.js.map +1 -0
  883. package/dist/src/swarm/advanced-orchestrator.js +1093 -0
  884. package/dist/src/swarm/advanced-orchestrator.js.map +1 -0
  885. package/dist/src/swarm/claude-code-interface.js +959 -0
  886. package/dist/src/swarm/claude-code-interface.js.map +1 -0
  887. package/dist/src/swarm/claude-flow-executor.js +218 -0
  888. package/dist/src/swarm/claude-flow-executor.js.map +1 -0
  889. package/dist/src/swarm/coordinator.js +3001 -0
  890. package/dist/src/swarm/coordinator.js.map +1 -0
  891. package/dist/src/swarm/direct-executor.js +1169 -0
  892. package/dist/src/swarm/direct-executor.js.map +1 -0
  893. package/dist/src/swarm/executor-v2.js +312 -0
  894. package/dist/src/swarm/executor-v2.js.map +1 -0
  895. package/dist/src/swarm/executor.js +813 -0
  896. package/dist/src/swarm/executor.js.map +1 -0
  897. package/dist/src/swarm/hive-mind-integration.js +700 -0
  898. package/dist/src/swarm/hive-mind-integration.js.map +1 -0
  899. package/dist/src/swarm/index.js +43 -0
  900. package/dist/src/swarm/index.js.map +1 -0
  901. package/dist/src/swarm/json-output-aggregator.js +269 -0
  902. package/dist/src/swarm/json-output-aggregator.js.map +1 -0
  903. package/dist/src/swarm/mcp-integration-wrapper.js +623 -0
  904. package/dist/src/swarm/mcp-integration-wrapper.js.map +1 -0
  905. package/dist/src/swarm/memory.js +1119 -0
  906. package/dist/src/swarm/memory.js.map +1 -0
  907. package/dist/src/swarm/optimizations/__tests__/optimization.test.js +350 -0
  908. package/dist/src/swarm/optimizations/__tests__/optimization.test.js.map +1 -0
  909. package/dist/src/swarm/optimizations/async-file-manager.js +273 -0
  910. package/dist/src/swarm/optimizations/async-file-manager.js.map +1 -0
  911. package/dist/src/swarm/optimizations/circular-buffer.js +148 -0
  912. package/dist/src/swarm/optimizations/circular-buffer.js.map +1 -0
  913. package/dist/src/swarm/optimizations/connection-pool.js +239 -0
  914. package/dist/src/swarm/optimizations/connection-pool.js.map +1 -0
  915. package/dist/src/swarm/optimizations/index.js +30 -0
  916. package/dist/src/swarm/optimizations/index.js.map +1 -0
  917. package/dist/src/swarm/optimizations/optimized-executor.js +318 -0
  918. package/dist/src/swarm/optimizations/optimized-executor.js.map +1 -0
  919. package/dist/src/swarm/optimizations/ttl-map.js +223 -0
  920. package/dist/src/swarm/optimizations/ttl-map.js.map +1 -0
  921. package/dist/src/swarm/prompt-cli.js +202 -0
  922. package/dist/src/swarm/prompt-cli.js.map +1 -0
  923. package/dist/src/swarm/prompt-copier-enhanced.js +193 -0
  924. package/dist/src/swarm/prompt-copier-enhanced.js.map +1 -0
  925. package/dist/src/swarm/prompt-copier.js +376 -0
  926. package/dist/src/swarm/prompt-copier.js.map +1 -0
  927. package/dist/src/swarm/prompt-manager.js +287 -0
  928. package/dist/src/swarm/prompt-manager.js.map +1 -0
  929. package/dist/src/swarm/prompt-utils.js +299 -0
  930. package/dist/src/swarm/prompt-utils.js.map +1 -0
  931. package/dist/src/swarm/result-aggregator.js +713 -0
  932. package/dist/src/swarm/result-aggregator.js.map +1 -0
  933. package/dist/src/swarm/sparc-executor.js +1557 -0
  934. package/dist/src/swarm/sparc-executor.js.map +1 -0
  935. package/dist/src/swarm/strategies/auto.js +751 -0
  936. package/dist/src/swarm/strategies/auto.js.map +1 -0
  937. package/dist/src/swarm/strategies/base.js +117 -0
  938. package/dist/src/swarm/strategies/base.js.map +1 -0
  939. package/dist/src/swarm/strategies/research.js +911 -0
  940. package/dist/src/swarm/strategies/research.js.map +1 -0
  941. package/dist/src/swarm/strategies/strategy-metrics-patch.js +4 -0
  942. package/dist/src/swarm/strategies/strategy-metrics-patch.js.map +1 -0
  943. package/dist/src/swarm/types.js +54 -0
  944. package/dist/src/swarm/types.js.map +1 -0
  945. package/dist/src/swarm/workers/copy-worker.js +58 -0
  946. package/dist/src/swarm/workers/copy-worker.js.map +1 -0
  947. package/dist/src/swarm-fullstack/adapters/chrome-mcp-adapter.js +412 -0
  948. package/dist/src/swarm-fullstack/adapters/chrome-mcp-adapter.js.map +1 -0
  949. package/dist/src/swarm-fullstack/adapters/shadcn-mcp-adapter.js +560 -0
  950. package/dist/src/swarm-fullstack/adapters/shadcn-mcp-adapter.js.map +1 -0
  951. package/dist/src/swarm-fullstack/cli/fullstack-cli.js +582 -0
  952. package/dist/src/swarm-fullstack/cli/fullstack-cli.js.map +1 -0
  953. package/dist/src/swarm-fullstack/config/fullstack-config.js +369 -0
  954. package/dist/src/swarm-fullstack/config/fullstack-config.js.map +1 -0
  955. package/dist/src/swarm-fullstack/core/dynamic-agent-spawner.js +687 -0
  956. package/dist/src/swarm-fullstack/core/dynamic-agent-spawner.js.map +1 -0
  957. package/dist/src/swarm-fullstack/core/enhanced-swarm-message-router.js +589 -0
  958. package/dist/src/swarm-fullstack/core/enhanced-swarm-message-router.js.map +1 -0
  959. package/dist/src/swarm-fullstack/core/fullstack-orchestrator.js +538 -0
  960. package/dist/src/swarm-fullstack/core/fullstack-orchestrator.js.map +1 -0
  961. package/dist/src/swarm-fullstack/types/index.js +8 -0
  962. package/dist/src/swarm-fullstack/types/index.js.map +1 -0
  963. package/dist/src/task/commands.js +130 -0
  964. package/dist/src/task/commands.js.map +1 -0
  965. package/dist/src/task/coordination.js +737 -0
  966. package/dist/src/task/coordination.js.map +1 -0
  967. package/dist/src/task/engine.js +490 -0
  968. package/dist/src/task/engine.js.map +1 -0
  969. package/dist/src/task/index.js +269 -0
  970. package/dist/src/task/index.js.map +1 -0
  971. package/dist/src/task/types.js +5 -0
  972. package/dist/src/task/types.js.map +1 -0
  973. package/dist/src/terminal/adapters/base.js +5 -0
  974. package/dist/src/terminal/adapters/base.js.map +1 -0
  975. package/dist/src/terminal/adapters/native.js +473 -0
  976. package/dist/src/terminal/adapters/native.js.map +1 -0
  977. package/dist/src/terminal/adapters/vscode.js +285 -0
  978. package/dist/src/terminal/adapters/vscode.js.map +1 -0
  979. package/dist/src/terminal/manager.js +237 -0
  980. package/dist/src/terminal/manager.js.map +1 -0
  981. package/dist/src/terminal/pool.js +209 -0
  982. package/dist/src/terminal/pool.js.map +1 -0
  983. package/dist/src/terminal/session.js +211 -0
  984. package/dist/src/terminal/session.js.map +1 -0
  985. package/dist/src/terminal/vscode-bridge.js +186 -0
  986. package/dist/src/terminal/vscode-bridge.js.map +1 -0
  987. package/dist/src/testing/performance/PerformanceTestRunner.js +401 -0
  988. package/dist/src/testing/performance/PerformanceTestRunner.js.map +1 -0
  989. package/dist/src/testing-integration/chrome-mcp-integration.js +556 -0
  990. package/dist/src/testing-integration/chrome-mcp-integration.js.map +1 -0
  991. package/dist/src/testing-integration/continuous-test-runner.js +509 -0
  992. package/dist/src/testing-integration/continuous-test-runner.js.map +1 -0
  993. package/dist/src/tests/validation-consistency.test.js +52 -0
  994. package/dist/src/tests/validation-consistency.test.js.map +1 -0
  995. package/dist/src/topology/adaptive-coordinator.js +691 -0
  996. package/dist/src/topology/adaptive-coordinator.js.map +1 -0
  997. package/dist/src/topology/communication-bridge.js +551 -0
  998. package/dist/src/topology/communication-bridge.js.map +1 -0
  999. package/dist/src/topology/enhanced-hierarchical-coordinator.js +1732 -0
  1000. package/dist/src/topology/enhanced-hierarchical-coordinator.js.map +1 -0
  1001. package/dist/src/topology/enhanced-mesh-coordinator.js +1271 -0
  1002. package/dist/src/topology/enhanced-mesh-coordinator.js.map +1 -0
  1003. package/dist/src/topology/topology-manager.js +797 -0
  1004. package/dist/src/topology/topology-manager.js.map +1 -0
  1005. package/dist/src/topology/types.js +8 -0
  1006. package/dist/src/topology/types.js.map +1 -0
  1007. package/dist/src/types/agent-lifecycle-types.js +172 -0
  1008. package/dist/src/types/agent-lifecycle-types.js.map +1 -0
  1009. package/dist/src/types/agent-types.js +11 -0
  1010. package/dist/src/types/agent-types.js.map +1 -0
  1011. package/dist/src/types/cliffy.d.js +9 -0
  1012. package/dist/src/types/cliffy.d.js.map +1 -0
  1013. package/dist/src/types/global.d.js +5 -0
  1014. package/dist/src/types/global.d.js.map +1 -0
  1015. package/dist/src/types/index.js +16 -0
  1016. package/dist/src/types/index.js.map +1 -0
  1017. package/dist/src/types/mcp.d.js +3 -0
  1018. package/dist/src/types/mcp.d.js.map +1 -0
  1019. package/dist/src/types/vscode.d.js +4 -0
  1020. package/dist/src/types/vscode.d.js.map +1 -0
  1021. package/dist/src/ui/hive-dashboard.js +284 -0
  1022. package/dist/src/ui/hive-dashboard.js.map +1 -0
  1023. package/dist/src/utils/error-handler.js +27 -0
  1024. package/dist/src/utils/error-handler.js.map +1 -0
  1025. package/dist/src/utils/errors.js +195 -0
  1026. package/dist/src/utils/errors.js.map +1 -0
  1027. package/dist/src/utils/formatters.js +66 -0
  1028. package/dist/src/utils/formatters.js.map +1 -0
  1029. package/dist/src/utils/helpers.js +451 -0
  1030. package/dist/src/utils/helpers.js.map +1 -0
  1031. package/dist/src/utils/paths.js +43 -0
  1032. package/dist/src/utils/paths.js.map +1 -0
  1033. package/dist/src/utils/type-guards.js +119 -0
  1034. package/dist/src/utils/type-guards.js.map +1 -0
  1035. package/dist/src/utils/types.js +38 -0
  1036. package/dist/src/utils/types.js.map +1 -0
  1037. package/dist/src/verification/agent-scorer.js +633 -0
  1038. package/dist/src/verification/agent-scorer.js.map +1 -0
  1039. package/dist/src/verification/alert-manager.js +1126 -0
  1040. package/dist/src/verification/alert-manager.js.map +1 -0
  1041. package/dist/src/verification/api/types/index.js +6 -0
  1042. package/dist/src/verification/api/types/index.js.map +1 -0
  1043. package/dist/src/verification/checkpoint-manager.js +519 -0
  1044. package/dist/src/verification/checkpoint-manager.js.map +1 -0
  1045. package/dist/src/verification/cli-integration.js +500 -0
  1046. package/dist/src/verification/cli-integration.js.map +1 -0
  1047. package/dist/src/verification/conflict-resolver.js +534 -0
  1048. package/dist/src/verification/conflict-resolver.js.map +1 -0
  1049. package/dist/src/verification/crdt-coordinator.js +506 -0
  1050. package/dist/src/verification/crdt-coordinator.js.map +1 -0
  1051. package/dist/src/verification/dashboard-exporter.js +876 -0
  1052. package/dist/src/verification/dashboard-exporter.js.map +1 -0
  1053. package/dist/src/verification/demo.js +320 -0
  1054. package/dist/src/verification/demo.js.map +1 -0
  1055. package/dist/src/verification/examples.js +508 -0
  1056. package/dist/src/verification/examples.js.map +1 -0
  1057. package/dist/src/verification/hooks.js +961 -0
  1058. package/dist/src/verification/hooks.js.map +1 -0
  1059. package/dist/src/verification/index.js +73 -0
  1060. package/dist/src/verification/index.js.map +1 -0
  1061. package/dist/src/verification/interfaces.js +7 -0
  1062. package/dist/src/verification/interfaces.js.map +1 -0
  1063. package/dist/src/verification/memory-manager.js +510 -0
  1064. package/dist/src/verification/memory-manager.js.map +1 -0
  1065. package/dist/src/verification/middleware.js +579 -0
  1066. package/dist/src/verification/middleware.js.map +1 -0
  1067. package/dist/src/verification/rollback-engine.js +511 -0
  1068. package/dist/src/verification/rollback-engine.js.map +1 -0
  1069. package/dist/src/verification/rollback.js +1710 -0
  1070. package/dist/src/verification/rollback.js.map +1 -0
  1071. package/dist/src/verification/security-bypass-test.js +704 -0
  1072. package/dist/src/verification/security-bypass-test.js.map +1 -0
  1073. package/dist/src/verification/security.js +1125 -0
  1074. package/dist/src/verification/security.js.map +1 -0
  1075. package/dist/src/verification/simple-hooks.js +189 -0
  1076. package/dist/src/verification/simple-hooks.js.map +1 -0
  1077. package/dist/src/verification/system-tracker.js +657 -0
  1078. package/dist/src/verification/system-tracker.js.map +1 -0
  1079. package/dist/src/verification/telemetry.js +922 -0
  1080. package/dist/src/verification/telemetry.js.map +1 -0
  1081. package/dist/src/verification/test-verification.js +43 -0
  1082. package/dist/src/verification/test-verification.js.map +1 -0
  1083. package/dist/src/verification/tests/e2e/verification-pipeline.test.js +1027 -0
  1084. package/dist/src/verification/tests/e2e/verification-pipeline.test.js.map +1 -0
  1085. package/dist/src/verification/tests/integration/cross-agent-communication.test.js +638 -0
  1086. package/dist/src/verification/tests/integration/cross-agent-communication.test.js.map +1 -0
  1087. package/dist/src/verification/tests/mocks/false-reporting-scenarios.test.js +1029 -0
  1088. package/dist/src/verification/tests/mocks/false-reporting-scenarios.test.js.map +1 -0
  1089. package/dist/src/verification/tests/performance/verification-overhead.test.js +587 -0
  1090. package/dist/src/verification/tests/performance/verification-overhead.test.js.map +1 -0
  1091. package/dist/src/verification/tests/unit/truth-scoring.test.js +579 -0
  1092. package/dist/src/verification/tests/unit/truth-scoring.test.js.map +1 -0
  1093. package/dist/src/verification/tests.js +611 -0
  1094. package/dist/src/verification/tests.js.map +1 -0
  1095. package/dist/src/verification/truth-scorer.js +584 -0
  1096. package/dist/src/verification/truth-scorer.js.map +1 -0
  1097. package/dist/src/verification/types.js +56 -0
  1098. package/dist/src/verification/types.js.map +1 -0
  1099. package/dist/src/verification/verification-pipeline.js +884 -0
  1100. package/dist/src/verification/verification-pipeline.js.map +1 -0
  1101. package/dist/src/web/messaging/agent-status-tracker.js +447 -0
  1102. package/dist/src/web/messaging/agent-status-tracker.js.map +1 -0
  1103. package/dist/src/web/messaging/human-intervention-system.js +298 -0
  1104. package/dist/src/web/messaging/human-intervention-system.js.map +1 -0
  1105. package/dist/src/web/messaging/message-filter.js +289 -0
  1106. package/dist/src/web/messaging/message-filter.js.map +1 -0
  1107. package/dist/src/web/messaging/swarm-message-router.js +320 -0
  1108. package/dist/src/web/messaging/swarm-message-router.js.map +1 -0
  1109. package/dist/src/web/messaging/transparency-logger.js +415 -0
  1110. package/dist/src/web/messaging/transparency-logger.js.map +1 -0
  1111. package/dist/src/web/portal-server.js +440 -0
  1112. package/dist/src/web/portal-server.js.map +1 -0
  1113. package/dist/src/web/server.js +311 -0
  1114. package/dist/src/web/server.js.map +1 -0
  1115. package/dist/src/web/websocket/websocket-manager.js +509 -0
  1116. package/dist/src/web/websocket/websocket-manager.js.map +1 -0
  1117. package/dist/src/workflows/feature-lifecycle-manager.js +386 -0
  1118. package/dist/src/workflows/feature-lifecycle-manager.js.map +1 -0
  1119. package/dist/src/workflows/fullstack-coordination-manager.js +801 -0
  1120. package/dist/src/workflows/fullstack-coordination-manager.js.map +1 -0
  1121. package/dist/src/workflows/iterative-development-orchestrator.js +1128 -0
  1122. package/dist/src/workflows/iterative-development-orchestrator.js.map +1 -0
  1123. package/dist/src/workflows/progressive-rollout-manager.js +710 -0
  1124. package/dist/src/workflows/progressive-rollout-manager.js.map +1 -0
  1125. package/package.json +264 -0
  1126. package/scripts/README.md +339 -0
  1127. package/scripts/post-install-claude-md.js +50 -0
  1128. package/src/commands/dependency-recommendations.js +551 -0
  1129. package/src/commands/suggest-improvements.js +492 -0
  1130. package/src/commands/suggest-templates.js +916 -0
  1131. package/src/npx/claude-md-protection.js +169 -0
  1132. package/wiki/INDEX.md +264 -0
  1133. package/wiki/NAVIGATION.md +270 -0
  1134. package/wiki/README.md +101 -0
  1135. package/wiki/accessibility/README.md +103 -0
  1136. package/wiki/accessibility/assistive-tech/screen-reader-support.md +912 -0
  1137. package/wiki/accessibility/automation/agent-testing-automation.md +880 -0
  1138. package/wiki/accessibility/guidelines/wcag-compliance.md +278 -0
  1139. package/wiki/accessibility/i18n/internationalization-strategies.md +1022 -0
  1140. package/wiki/accessibility/motor-accessibility/keyboard-navigation.md +1182 -0
  1141. package/wiki/accessibility/patterns/inclusive-design-patterns.md +715 -0
  1142. package/wiki/accessibility/testing/automated-testing.md +665 -0
  1143. package/wiki/accessibility/visual-design/color-contrast.md +926 -0
  1144. package/wiki/accessibility/workflows/accessibility-first-development.md +916 -0
  1145. package/wiki/accessibility/workflows/inclusive-design-review.md +835 -0
  1146. package/wiki/api-reference/README.md +565 -0
  1147. package/wiki/api-reference/agent-management-api.md +931 -0
  1148. package/wiki/api-reference/cli-api.md +630 -0
  1149. package/wiki/api-reference/configuration-api.md +1355 -0
  1150. package/wiki/api-reference/examples-code-samples.md +2241 -0
  1151. package/wiki/api-reference/hooks-coordination-api.md +1406 -0
  1152. package/wiki/api-reference/mcp-tool-specifications.md +944 -0
  1153. package/wiki/api-reference/plugin-development.md +1695 -0
  1154. package/wiki/api-reference/technical-architecture.md +1729 -0
  1155. package/wiki/command-reference/README.md +305 -0
  1156. package/wiki/command-reference/agent-commands.md +571 -0
  1157. package/wiki/command-reference/cli-commands.md +516 -0
  1158. package/wiki/command-reference/command-syntax.md +676 -0
  1159. package/wiki/command-reference/expert/README.md +616 -0
  1160. package/wiki/command-reference/expert-tier.md +791 -0
  1161. package/wiki/command-reference/intermediate/README.md +628 -0
  1162. package/wiki/command-reference/intermediate-tier.md +1024 -0
  1163. package/wiki/command-reference/mcp-integration.md +412 -0
  1164. package/wiki/command-reference/mcp-tools/README.md +1743 -0
  1165. package/wiki/command-reference/mcp-tools/dual-access-workflows.md +911 -0
  1166. package/wiki/command-reference/mcp-tools/index.md +201 -0
  1167. package/wiki/command-reference/mcp-tools/integration-patterns.md +830 -0
  1168. package/wiki/command-reference/mcp-tools/quick-reference.md +383 -0
  1169. package/wiki/command-reference/mcp-tools/session-management.md +1183 -0
  1170. package/wiki/command-reference/mcp-tools/task-tool-integration.md +827 -0
  1171. package/wiki/command-reference/novice/README.md +661 -0
  1172. package/wiki/command-reference/novice-tier.md +1142 -0
  1173. package/wiki/command-reference/progression-guide.md +772 -0
  1174. package/wiki/command-reference/troubleshooting.md +803 -0
  1175. package/wiki/command-reference/workflows.md +752 -0
  1176. package/wiki/community/README.md +328 -0
  1177. package/wiki/community/contributing/README.md +623 -0
  1178. package/wiki/community/contributing/code-of-conduct.md +388 -0
  1179. package/wiki/community/contributing/collaboration-workflows.md +1 -0
  1180. package/wiki/community/contributing/issue-reporting.md +1 -0
  1181. package/wiki/community/contributing/onboarding-guide.md +1 -0
  1182. package/wiki/community/contributing/recognition-system.md +1 -0
  1183. package/wiki/community/discussions/README.md +54 -0
  1184. package/wiki/community/learning-resources.md +476 -0
  1185. package/wiki/community/showcase/README.md +1 -0
  1186. package/wiki/core-concepts/README.md +656 -0
  1187. package/wiki/core-concepts/agent-feedback-hooks/README.md +298 -0
  1188. package/wiki/core-concepts/agents/README.md +392 -0
  1189. package/wiki/core-concepts/agents/agent-creation-guide.md +431 -0
  1190. package/wiki/core-concepts/agents.md +301 -0
  1191. package/wiki/core-concepts/architecture.md +227 -0
  1192. package/wiki/core-concepts/hooks-lifecycle/README.md +543 -0
  1193. package/wiki/core-concepts/integration.md +507 -0
  1194. package/wiki/core-concepts/memory-system/README.md +521 -0
  1195. package/wiki/core-concepts/performance.md +463 -0
  1196. package/wiki/core-concepts/sparc-methodology/README.md +465 -0
  1197. package/wiki/core-concepts/sparc-workflow.md +407 -0
  1198. package/wiki/core-concepts/swarm-coordination/README.md +525 -0
  1199. package/wiki/core-concepts/swarm-coordination.md +453 -0
  1200. package/wiki/cost-optimization/enterprise-cost-management.md +1356 -0
  1201. package/wiki/deployment/enterprise-deployment-patterns.md +1739 -0
  1202. package/wiki/enterprise-architecture/enterprise-architecture-overview.md +348 -0
  1203. package/wiki/enterprise-architecture/enterprise-scaling-patterns.md +1184 -0
  1204. package/wiki/examples/README.md +288 -0
  1205. package/wiki/examples/automation/cicd-pipeline/README.md +1265 -0
  1206. package/wiki/examples/basic/hello-world/README.md +434 -0
  1207. package/wiki/examples/basic-projects/README.md +427 -0
  1208. package/wiki/examples/enterprise-integration/README.md +602 -0
  1209. package/wiki/examples/integration-patterns.md +825 -0
  1210. package/wiki/examples/legacy-migration/README.md +656 -0
  1211. package/wiki/examples/multi-cloud/README.md +1071 -0
  1212. package/wiki/examples/performance-benchmarks.md +729 -0
  1213. package/wiki/examples/performance-optimization/README.md +1214 -0
  1214. package/wiki/examples/projects/rest-api/README.md +845 -0
  1215. package/wiki/examples/real-time-collaboration/README.md +1092 -0
  1216. package/wiki/examples/scenarios/ecommerce/README.md +1273 -0
  1217. package/wiki/examples/swarm-patterns.md +1026 -0
  1218. package/wiki/examples/templates/download-system.md +993 -0
  1219. package/wiki/examples/templates/javascript/README.md +487 -0
  1220. package/wiki/examples/templates/javascript/package.json +119 -0
  1221. package/wiki/examples/troubleshooting/README.md +1317 -0
  1222. package/wiki/examples/utilities/patterns/README.md +1347 -0
  1223. package/wiki/examples/videos/01-setup.md +403 -0
  1224. package/wiki/examples/workflow-automation/README.md +1023 -0
  1225. package/wiki/getting-started/README.md +398 -0
  1226. package/wiki/getting-started/benefits.md +451 -0
  1227. package/wiki/getting-started/claude-code-mcp/README.md +319 -0
  1228. package/wiki/getting-started/claude-code-mcp/setup.md +431 -0
  1229. package/wiki/getting-started/claude-code-mcp/usage-examples.md +501 -0
  1230. package/wiki/getting-started/cli-access/README.md +300 -0
  1231. package/wiki/getting-started/cli-access/first-commands.md +319 -0
  1232. package/wiki/getting-started/installation/README.md +469 -0
  1233. package/wiki/getting-started/installation/troubleshooting.md +617 -0
  1234. package/wiki/getting-started/learning-path.md +494 -0
  1235. package/wiki/getting-started/learning-plan-generator.md +434 -0
  1236. package/wiki/getting-started/quick-start/README.md +255 -0
  1237. package/wiki/getting-started/quick-start/cli-tutorial.md +680 -0
  1238. package/wiki/getting-started/quick-start/mcp-tutorial.md +544 -0
  1239. package/wiki/governance/multi-project-coordination.md +820 -0
  1240. package/wiki/languages/README.md +349 -0
  1241. package/wiki/languages/go/README.md +124 -0
  1242. package/wiki/languages/go/examples/README.md +1066 -0
  1243. package/wiki/languages/go/frameworks/README.md +708 -0
  1244. package/wiki/languages/go/integration/README.md +748 -0
  1245. package/wiki/languages/go/microservices/README.md +1185 -0
  1246. package/wiki/languages/go/performance/README.md +1310 -0
  1247. package/wiki/languages/go/setup/README.md +397 -0
  1248. package/wiki/languages/go/systems/README.md +1116 -0
  1249. package/wiki/languages/go/testing/README.md +999 -0
  1250. package/wiki/languages/java/README.md +217 -0
  1251. package/wiki/languages/java/claude-flow-integration.md +1220 -0
  1252. package/wiki/languages/java/enterprise-java.md +1247 -0
  1253. package/wiki/languages/java/examples.md +1712 -0
  1254. package/wiki/languages/java/microservices.md +1600 -0
  1255. package/wiki/languages/java/performance.md +1122 -0
  1256. package/wiki/languages/java/project-setup.md +504 -0
  1257. package/wiki/languages/java/spring-boot.md +756 -0
  1258. package/wiki/languages/java/testing.md +1323 -0
  1259. package/wiki/languages/javascript/README.md +575 -0
  1260. package/wiki/languages/javascript/api/README.md +1445 -0
  1261. package/wiki/languages/javascript/backend/README.md +748 -0
  1262. package/wiki/languages/javascript/frontend/README.md +1048 -0
  1263. package/wiki/languages/javascript/integration.md +1107 -0
  1264. package/wiki/languages/javascript/setup/README.md +438 -0
  1265. package/wiki/languages/javascript/testing/README.md +1775 -0
  1266. package/wiki/languages/python/README.md +1002 -0
  1267. package/wiki/languages/python/data-science/README.md +1317 -0
  1268. package/wiki/languages/python/examples/README.md +911 -0
  1269. package/wiki/languages/python/integration.md +1515 -0
  1270. package/wiki/languages/python/mcp-integration.md +843 -0
  1271. package/wiki/languages/python/setup/README.md +622 -0
  1272. package/wiki/languages/python/testing/README.md +1680 -0
  1273. package/wiki/languages/python/web-development/README.md +974 -0
  1274. package/wiki/languages/rust/README.md +936 -0
  1275. package/wiki/languages/rust/examples/cli-mcp-workflows.md +850 -0
  1276. package/wiki/languages/rust/examples/rest-api.md +1927 -0
  1277. package/wiki/languages/rust/setup/cargo-integration.md +780 -0
  1278. package/wiki/languages/rust/testing/quality-validation.md +1098 -0
  1279. package/wiki/languages/rust/web-development/axum.md +1497 -0
  1280. package/wiki/languages/rust/workflows/systems-programming.md +1189 -0
  1281. package/wiki/languages/typescript/README.md +581 -0
  1282. package/wiki/languages/typescript/automation.md +1070 -0
  1283. package/wiki/languages/typescript/coordination.md +971 -0
  1284. package/wiki/languages/typescript/enterprise.md +1368 -0
  1285. package/wiki/languages/typescript/frameworks.md +970 -0
  1286. package/wiki/languages/typescript/migration.md +1384 -0
  1287. package/wiki/languages/typescript/patterns.md +694 -0
  1288. package/wiki/languages/typescript/performance.md +1195 -0
  1289. package/wiki/languages/typescript/setup.md +516 -0
  1290. package/wiki/languages/typescript/workflows.md +481 -0
  1291. package/wiki/monitoring/enterprise-observability.md +1141 -0
  1292. package/wiki/security/enterprise-security-framework.md +1174 -0
  1293. package/wiki/team-coordination/team-scaling-strategies.md +1486 -0
  1294. package/wiki/troubleshooting/README.md +654 -0
  1295. package/wiki/troubleshooting/common-issues/README.md +659 -0
  1296. package/wiki/troubleshooting/common-issues.md +458 -0
  1297. package/wiki/troubleshooting/error-resolution.md +763 -0
  1298. package/wiki/troubleshooting/performance-optimization.md +540 -0
  1299. package/wiki/tutorials/README.md +607 -0
  1300. package/wiki/tutorials/advanced/01-multi-agent-orchestration-patterns.md +585 -0
  1301. package/wiki/tutorials/advanced/02-enterprise-architecture-development.md +661 -0
  1302. package/wiki/tutorials/advanced/03-advanced-sparc-methodology.md +595 -0
  1303. package/wiki/tutorials/advanced/04-performance-optimization-workflows.md +613 -0
  1304. package/wiki/tutorials/advanced/05-custom-agent-development.md +681 -0
  1305. package/wiki/tutorials/advanced/06-legacy-system-integration.md +574 -0
  1306. package/wiki/tutorials/advanced/07-production-deployment-monitoring.md +684 -0
  1307. package/wiki/tutorials/advanced/08-enterprise-scenarios.md +700 -0
  1308. package/wiki/tutorials/advanced/README.md +577 -0
  1309. package/wiki/tutorials/advanced/performance-optimization.md +476 -0
  1310. package/wiki/tutorials/advanced/swarm-orchestration.md +627 -0
  1311. package/wiki/tutorials/beginner/01-first-project.md +532 -0
  1312. package/wiki/tutorials/beginner/02-basic-workflows.md +523 -0
  1313. package/wiki/tutorials/beginner/03-simple-automation.md +641 -0
  1314. package/wiki/tutorials/beginner/04-quality-testing.md +984 -0
  1315. package/wiki/tutorials/beginner/README.md +388 -0
  1316. package/wiki/tutorials/exercises/ecommerce-platform.md +1370 -0
  1317. package/wiki/tutorials/intermediate/01-multi-agent-teams.md +961 -0
  1318. package/wiki/tutorials/intermediate/README.md +452 -0
  1319. package/wiki/tutorials/intermediate/optimization.md +402 -0
  1320. package/wiki/tutorials/skill-assessment.md +522 -0
  1321. package/wiki/tutorials/skill-competency-matrix.md +548 -0
  1322. package/wiki/tutorials/troubleshooting/command-cheatsheet.md +425 -0
  1323. package/wiki/tutorials/troubleshooting/setup-issues.md +717 -0
  1324. package/wiki/video-tutorials/README.md +202 -0
  1325. package/wiki/video-tutorials/accessibility/README.md +1349 -0
  1326. package/wiki/video-tutorials/community/README.md +1366 -0
  1327. package/wiki/video-tutorials/content-organization/README.md +1295 -0
  1328. package/wiki/video-tutorials/distribution/README.md +1093 -0
  1329. package/wiki/video-tutorials/editing/README.md +751 -0
  1330. package/wiki/video-tutorials/interactive/README.md +1151 -0
  1331. package/wiki/video-tutorials/multi-language/README.md +1384 -0
  1332. package/wiki/video-tutorials/planning/README.md +461 -0
  1333. package/wiki/video-tutorials/recording/README.md +619 -0
  1334. package/wiki/video-tutorials/technical-specs/README.md +1018 -0
@@ -0,0 +1,1732 @@
1
+ /**
2
+ * Enhanced Hierarchical Coordinator with Dynamic Management
3
+ *
4
+ * Advanced hierarchical topology coordinator with dynamic hierarchy management,
5
+ * parent-child delegation with failure recovery, promotion/demotion algorithms,
6
+ * and hierarchical resource allocation strategies.
7
+ */ import { EventEmitter } from 'node:events';
8
+ import { Logger } from '../core/logger.js';
9
+ import { generateId } from '../utils/helpers.js';
10
+ import { lifecycleManager, registerAgentDependency, removeAgentDependency, getAgentDependencyStatus, forceAgentCompletion } from '../agents/lifecycle-manager.js';
11
+ import { DependencyType, getDependencyTracker } from '../lifecycle/dependency-tracker.js';
12
+ // ============================================================================
13
+ // Enhanced Hierarchical Coordinator Implementation
14
+ // ============================================================================
15
+ export class EnhancedHierarchicalCoordinator extends EventEmitter {
16
+ id;
17
+ type = 'hierarchical';
18
+ config;
19
+ logger;
20
+ nodes;
21
+ tasks;
22
+ delegationPaths;
23
+ resourcePools;
24
+ dependencyTracker;
25
+ lifecycleContext;
26
+ communicationBridge;
27
+ isRunning = false;
28
+ rootNodeIds;
29
+ leaderNodes;
30
+ promotionCandidates;
31
+ // Background task timers
32
+ hierarchyRebalanceTimer;
33
+ resourceReallocationTimer;
34
+ failureDetectionTimer;
35
+ promotionEvaluationTimer;
36
+ // Performance tracking
37
+ metrics;
38
+ constructor(config = {}){
39
+ super();
40
+ this.id = generateId('enhanced-hier');
41
+ this.logger = new Logger(`EnhancedHierarchicalCoordinator[${this.id}]`);
42
+ this.config = {
43
+ type: 'hierarchical',
44
+ name: `enhanced-hierarchical-${this.id}`,
45
+ strategy: 'adaptive',
46
+ faultTolerance: 'basic',
47
+ loadBalancing: 'capability-based',
48
+ maxAgents: 200,
49
+ maxDepth: 6,
50
+ enableCrossTopology: true,
51
+ enableAdaptiveOptimization: true,
52
+ performanceThresholds: {
53
+ latency: 800,
54
+ throughput: 30,
55
+ errorRate: 0.08
56
+ },
57
+ timeouts: {
58
+ coordination: 45000,
59
+ completion: 300000,
60
+ heartbeat: 8000
61
+ },
62
+ memoryNamespace: `enhanced-hierarchical-${this.id}`,
63
+ hierarchy: {
64
+ maxDepth: 6,
65
+ maxChildrenPerNode: 12,
66
+ balancingStrategy: 'hybrid',
67
+ promotionThreshold: 0.8,
68
+ demotionThreshold: 0.3,
69
+ rebalanceInterval: 60000
70
+ },
71
+ delegation: {
72
+ strategy: 'adaptive',
73
+ enableSubdelegation: true,
74
+ maxDelegationDepth: 4,
75
+ parallelDelegation: true
76
+ },
77
+ recovery: {
78
+ enableAutomaticRecovery: true,
79
+ failureDetectionTimeout: 20000,
80
+ recoveryAttempts: 3,
81
+ backupLeaderSelection: true
82
+ },
83
+ resourceAllocation: {
84
+ strategy: 'capability-weighted',
85
+ reserveCapacity: 0.2,
86
+ dynamicReallocation: true
87
+ },
88
+ ...config
89
+ };
90
+ this.nodes = new Map();
91
+ this.tasks = new Map();
92
+ this.delegationPaths = new Map();
93
+ this.resourcePools = new Map();
94
+ this.rootNodeIds = new Set();
95
+ this.leaderNodes = new Map();
96
+ this.promotionCandidates = [];
97
+ this.dependencyTracker = getDependencyTracker(this.config.memoryNamespace);
98
+ this.communicationBridge = config.communicationBridge;
99
+ this.metrics = {
100
+ delegationLatency: 0,
101
+ hierarchyEfficiency: 1,
102
+ promotions: 0,
103
+ demotions: 0,
104
+ recoveryActions: 0,
105
+ resourceUtilization: 0
106
+ };
107
+ this.setupEventHandlers();
108
+ }
109
+ // ============================================================================
110
+ // Lifecycle Management
111
+ // ============================================================================
112
+ async initialize() {
113
+ if (this.isRunning) {
114
+ this.logger.warn('Enhanced hierarchical coordinator already running');
115
+ return;
116
+ }
117
+ this.logger.info('Initializing enhanced hierarchical coordinator...');
118
+ // Initialize dependency tracker
119
+ await this.dependencyTracker.initialize();
120
+ // Register with lifecycle management
121
+ this.lifecycleContext = await lifecycleManager.initializeAgent(this.id, {
122
+ name: this.config.name,
123
+ type: 'coordinator',
124
+ capabilities: [
125
+ 'enhanced-hierarchical-coordination',
126
+ 'dynamic-hierarchy-management',
127
+ 'intelligent-delegation',
128
+ 'automatic-recovery',
129
+ 'resource-allocation'
130
+ ],
131
+ lifecycle: {
132
+ state_management: true,
133
+ persistent_memory: true,
134
+ max_retries: 3
135
+ },
136
+ hooks: {
137
+ init: 'echo "Enhanced hierarchical coordinator initialized"',
138
+ task_complete: 'echo "Enhanced hierarchical coordination completed"',
139
+ on_rerun_request: this.handleRerunRequest.bind(this),
140
+ cleanup: 'echo "Enhanced hierarchical coordinator cleanup"'
141
+ }
142
+ }, generateId('enhanced-hier-task'));
143
+ await lifecycleManager.transitionState(this.id, 'running', 'Enhanced hierarchical coordinator started');
144
+ // Initialize resource pools for each level
145
+ await this.initializeResourcePools();
146
+ this.isRunning = true;
147
+ this.startBackgroundTasks();
148
+ this.logger.info('Enhanced hierarchical coordinator initialized successfully');
149
+ this.emit('coordinator:initialized', {
150
+ coordinatorId: this.id
151
+ });
152
+ }
153
+ async shutdown(force = false) {
154
+ if (!this.isRunning) return;
155
+ this.logger.info('Shutting down enhanced hierarchical coordinator...');
156
+ this.isRunning = false;
157
+ // Stop background tasks
158
+ this.stopBackgroundTasks();
159
+ // Handle completion dependencies if not forced
160
+ if (!force) {
161
+ const canComplete = await this.checkHierarchyCompletionDependencies();
162
+ if (!canComplete) {
163
+ this.logger.info('Enhanced hierarchical coordinator has pending dependencies - deferring completion');
164
+ this.emit('coordinator:completion_deferred', {
165
+ coordinatorId: this.id,
166
+ reason: 'Pending hierarchical dependencies'
167
+ });
168
+ return;
169
+ }
170
+ }
171
+ // Gracefully shutdown hierarchy
172
+ await this.shutdownHierarchy();
173
+ // Force completion if requested
174
+ if (force) {
175
+ await forceAgentCompletion(this.id, 'Enhanced hierarchical forced shutdown');
176
+ }
177
+ // Cleanup dependencies
178
+ await this.cleanupDependencies();
179
+ // Transition to stopped state
180
+ await lifecycleManager.transitionState(this.id, 'stopped', 'Enhanced hierarchical coordinator shutdown');
181
+ // Shutdown dependency tracker
182
+ await this.dependencyTracker.shutdown();
183
+ this.logger.info('Enhanced hierarchical coordinator shutdown complete');
184
+ this.emit('coordinator:shutdown', {
185
+ coordinatorId: this.id
186
+ });
187
+ }
188
+ isRunning() {
189
+ return this.isRunning;
190
+ }
191
+ // ============================================================================
192
+ // Agent Management with Enhanced Hierarchy
193
+ // ============================================================================
194
+ async registerAgent(agentId, agentInfo) {
195
+ if (this.nodes.size >= this.config.maxAgents) {
196
+ throw new Error('Maximum agent limit reached for enhanced hierarchy');
197
+ }
198
+ // Determine optimal placement in hierarchy
199
+ const optimalPlacement = await this.findOptimalHierarchyPlacement(agentId, agentInfo);
200
+ const node = {
201
+ id: agentId,
202
+ name: agentInfo.name || `agent-${agentId}`,
203
+ type: agentInfo.type || 'worker',
204
+ status: 'initializing',
205
+ capabilities: agentInfo.capabilities || [],
206
+ topologyRole: agentInfo.topologyRole || 'worker',
207
+ position: {
208
+ level: optimalPlacement.level,
209
+ connections: []
210
+ },
211
+ workload: 0,
212
+ lastActivity: new Date(),
213
+ performanceMetrics: {
214
+ tasksCompleted: 0,
215
+ averageTaskTime: 0,
216
+ errorCount: 0,
217
+ reliability: 1.0
218
+ },
219
+ communicationChannels: new Map(),
220
+ dependencies: [],
221
+ dependents: [],
222
+ hierarchyLevel: optimalPlacement.level,
223
+ parentId: optimalPlacement.parentId,
224
+ childIds: [],
225
+ hierarchyPath: optimalPlacement.path,
226
+ leadershipScore: this.calculateLeadershipScore(agentInfo),
227
+ delegationCapacity: this.calculateDelegationCapacity(agentInfo),
228
+ resourceAllocation: {
229
+ cpu: 0,
230
+ memory: 0,
231
+ bandwidth: 0,
232
+ delegatedTasks: 0
233
+ },
234
+ subtreeMetrics: {
235
+ totalNodes: 1,
236
+ activeNodes: 1,
237
+ failedNodes: 0,
238
+ averagePerformance: 1.0
239
+ },
240
+ ...agentInfo
241
+ };
242
+ this.nodes.set(agentId, node);
243
+ // Establish hierarchy relationships
244
+ await this.establishHierarchyRelationships(node);
245
+ // Allocate resources
246
+ await this.allocateResources(node);
247
+ // Register dependencies
248
+ await this.registerHierarchyDependencies(node);
249
+ // Update subtree metrics for ancestors
250
+ await this.updateAncestorMetrics(agentId);
251
+ node.status = 'ready';
252
+ this.logger.info(`Registered agent ${agentId} at level ${node.hierarchyLevel} in enhanced hierarchy`);
253
+ this.emit('agent:registered', {
254
+ agentId,
255
+ coordinatorId: this.id,
256
+ level: node.hierarchyLevel
257
+ });
258
+ // Consider for leadership role
259
+ if (this.shouldConsiderForLeadership(node)) {
260
+ await this.evaluateLeadershipCandidate(node);
261
+ }
262
+ }
263
+ async unregisterAgent(agentId) {
264
+ const node = this.nodes.get(agentId);
265
+ if (!node) return;
266
+ this.logger.info(`Unregistering agent ${agentId} from enhanced hierarchy`);
267
+ // Handle children redistribution if this node has children
268
+ if (node.childIds.length > 0) {
269
+ await this.redistributeChildren(node);
270
+ }
271
+ // Remove from parent's children
272
+ if (node.parentId) {
273
+ const parent = this.nodes.get(node.parentId);
274
+ if (parent) {
275
+ parent.childIds = parent.childIds.filter((id)=>id !== agentId);
276
+ await this.updateSubtreeMetrics(parent.id);
277
+ }
278
+ } else {
279
+ this.rootNodeIds.delete(agentId);
280
+ }
281
+ // Handle leadership transition if this was a leader
282
+ if (this.isLeaderNode(agentId)) {
283
+ await this.handleLeadershipTransition(agentId);
284
+ }
285
+ // Deallocate resources
286
+ await this.deallocateResources(node);
287
+ // Remove dependencies
288
+ const depStatus = getAgentDependencyStatus(agentId);
289
+ for (const depId of depStatus.dependencies){
290
+ await removeAgentDependency(depId);
291
+ }
292
+ // Remove from registry
293
+ this.nodes.delete(agentId);
294
+ this.emit('agent:unregistered', {
295
+ agentId,
296
+ coordinatorId: this.id
297
+ });
298
+ }
299
+ getAgent(agentId) {
300
+ return this.nodes.get(agentId);
301
+ }
302
+ getAllAgents() {
303
+ return Array.from(this.nodes.values());
304
+ }
305
+ // ============================================================================
306
+ // Dynamic Hierarchy Management
307
+ // ============================================================================
308
+ async findOptimalHierarchyPlacement(agentId, agentInfo) {
309
+ const capabilities = agentInfo.capabilities || [];
310
+ const topologyRole = agentInfo.topologyRole || 'worker';
311
+ // Leaders prefer higher levels
312
+ if (topologyRole === 'coordinator' || capabilities.includes('coordination')) {
313
+ return this.findLeadershipPosition();
314
+ }
315
+ // Workers prefer positions that balance load and capability match
316
+ return this.findWorkerPosition(capabilities);
317
+ }
318
+ async findLeadershipPosition() {
319
+ // Try to place at level 1 (just below root) if space available
320
+ for(let level = 1; level <= 3; level++){
321
+ const nodesAtLevel = Array.from(this.nodes.values()).filter((node)=>node.hierarchyLevel === level);
322
+ if (nodesAtLevel.length < Math.pow(this.config.hierarchy.maxChildrenPerNode, level)) {
323
+ const parentId = level === 0 ? undefined : this.findBestParentAtLevel(level - 1);
324
+ const path = parentId ? [
325
+ ...this.nodes.get(parentId)?.hierarchyPath || [],
326
+ parentId
327
+ ] : [];
328
+ return {
329
+ level,
330
+ parentId,
331
+ path
332
+ };
333
+ }
334
+ }
335
+ // Fallback to worker position
336
+ return this.findWorkerPosition([
337
+ 'coordination'
338
+ ]);
339
+ }
340
+ async findWorkerPosition(capabilities) {
341
+ const candidates = [];
342
+ // Evaluate placement at each level
343
+ for(let level = 2; level <= this.config.hierarchy.maxDepth; level++){
344
+ const potentialParents = Array.from(this.nodes.values()).filter((node)=>node.hierarchyLevel === level - 1 && node.childIds.length < this.config.hierarchy.maxChildrenPerNode && node.status === 'ready');
345
+ for (const parent of potentialParents){
346
+ const capabilityMatch = this.calculateCapabilityMatch(capabilities, parent.capabilities);
347
+ const loadBalance = 1 / (parent.childIds.length + 1);
348
+ const parentPerformance = parent.performanceMetrics.reliability;
349
+ const score = capabilityMatch * 0.4 + loadBalance * 0.4 + parentPerformance * 0.2;
350
+ candidates.push({
351
+ level,
352
+ parentId: parent.id,
353
+ path: [
354
+ ...parent.hierarchyPath,
355
+ parent.id
356
+ ],
357
+ score
358
+ });
359
+ }
360
+ }
361
+ if (candidates.length === 0) {
362
+ // Place at root level if no suitable parents found
363
+ return {
364
+ level: 0,
365
+ path: []
366
+ };
367
+ }
368
+ // Return best placement
369
+ const best = candidates.sort((a, b)=>b.score - a.score)[0];
370
+ return {
371
+ level: best.level,
372
+ parentId: best.parentId,
373
+ path: best.path
374
+ };
375
+ }
376
+ findBestParentAtLevel(level) {
377
+ const candidateParents = Array.from(this.nodes.values()).filter((node)=>node.hierarchyLevel === level && node.childIds.length < this.config.hierarchy.maxChildrenPerNode && node.status === 'ready').sort((a, b)=>{
378
+ const aScore = a.leadershipScore + 1 / (a.childIds.length + 1);
379
+ const bScore = b.leadershipScore + 1 / (b.childIds.length + 1);
380
+ return bScore - aScore;
381
+ });
382
+ return candidateParents[0]?.id;
383
+ }
384
+ calculateCapabilityMatch(caps1, caps2) {
385
+ const set1 = new Set(caps1);
386
+ const set2 = new Set(caps2);
387
+ const intersection = new Set([
388
+ ...set1
389
+ ].filter((x)=>set2.has(x)));
390
+ const union = new Set([
391
+ ...set1,
392
+ ...set2
393
+ ]);
394
+ return union.size > 0 ? intersection.size / union.size : 0;
395
+ }
396
+ calculateLeadershipScore(agentInfo) {
397
+ const capabilities = agentInfo.capabilities || [];
398
+ const hasCoordination = capabilities.includes('coordination');
399
+ const hasLeadership = capabilities.includes('leadership');
400
+ const hasManagement = capabilities.includes('management');
401
+ let score = 0.5; // Base score
402
+ if (hasCoordination) score += 0.3;
403
+ if (hasLeadership) score += 0.2;
404
+ if (hasManagement) score += 0.1;
405
+ return Math.min(1.0, score);
406
+ }
407
+ calculateDelegationCapacity(agentInfo) {
408
+ const capabilities = agentInfo.capabilities || [];
409
+ const hasTaskManagement = capabilities.includes('task-management');
410
+ const hasCoordination = capabilities.includes('coordination');
411
+ let capacity = 5; // Base capacity
412
+ if (hasTaskManagement) capacity += 5;
413
+ if (hasCoordination) capacity += 10;
414
+ return capacity;
415
+ }
416
+ async establishHierarchyRelationships(node) {
417
+ // Add to parent's children if has parent
418
+ if (node.parentId) {
419
+ const parent = this.nodes.get(node.parentId);
420
+ if (parent) {
421
+ parent.childIds.push(node.id);
422
+ // Establish communication channel
423
+ const channelId = generateId('hier-channel');
424
+ const channel = {
425
+ id: channelId,
426
+ sourceAgentId: node.id,
427
+ targetAgentId: parent.id,
428
+ type: 'routed',
429
+ protocol: 'sync',
430
+ status: 'active',
431
+ metrics: {
432
+ messagesSent: 0,
433
+ messagesReceived: 0,
434
+ averageLatency: 0,
435
+ errorCount: 0,
436
+ bandwidth: 0
437
+ },
438
+ queueSize: 0,
439
+ maxQueueSize: 50,
440
+ compressionEnabled: true,
441
+ encryptionEnabled: false
442
+ };
443
+ node.communicationChannels.set(parent.id, channel);
444
+ parent.communicationChannels.set(node.id, channel);
445
+ }
446
+ } else {
447
+ // Add to root nodes
448
+ this.rootNodeIds.add(node.id);
449
+ }
450
+ }
451
+ async redistributeChildren(departingNode) {
452
+ if (departingNode.childIds.length === 0) return;
453
+ this.logger.info(`Redistributing ${departingNode.childIds.length} children of departing node ${departingNode.id}`);
454
+ // Find suitable new parents at the same level or promote children
455
+ const newParentCandidates = Array.from(this.nodes.values()).filter((node)=>node.hierarchyLevel === departingNode.hierarchyLevel && node.id !== departingNode.id && node.childIds.length < this.config.hierarchy.maxChildrenPerNode && node.status === 'ready').sort((a, b)=>{
456
+ const aCapacity = this.config.hierarchy.maxChildrenPerNode - a.childIds.length;
457
+ const bCapacity = this.config.hierarchy.maxChildrenPerNode - b.childIds.length;
458
+ return bCapacity - aCapacity;
459
+ });
460
+ for (const childId of departingNode.childIds){
461
+ const child = this.nodes.get(childId);
462
+ if (!child) continue;
463
+ if (newParentCandidates.length > 0) {
464
+ // Redistribute to existing parent
465
+ const newParent = newParentCandidates[0];
466
+ child.parentId = newParent.id;
467
+ child.hierarchyPath = [
468
+ ...newParent.hierarchyPath,
469
+ newParent.id
470
+ ];
471
+ newParent.childIds.push(childId);
472
+ // Update capacity tracking
473
+ if (newParent.childIds.length >= this.config.hierarchy.maxChildrenPerNode) {
474
+ newParentCandidates.shift();
475
+ }
476
+ } else {
477
+ // Promote child to same level as departing node
478
+ child.hierarchyLevel = departingNode.hierarchyLevel;
479
+ child.parentId = departingNode.parentId;
480
+ child.hierarchyPath = departingNode.hierarchyPath;
481
+ if (departingNode.parentId) {
482
+ const grandparent = this.nodes.get(departingNode.parentId);
483
+ if (grandparent) {
484
+ grandparent.childIds.push(childId);
485
+ }
486
+ } else {
487
+ this.rootNodeIds.add(childId);
488
+ }
489
+ this.metrics.promotions += 1;
490
+ this.logger.info(`Promoted child ${childId} to level ${child.hierarchyLevel}`);
491
+ }
492
+ await this.updateSubtreeMetrics(childId);
493
+ }
494
+ }
495
+ isLeaderNode(agentId) {
496
+ return Array.from(this.leaderNodes.values()).includes(agentId);
497
+ }
498
+ async handleLeadershipTransition(departingLeaderId) {
499
+ const departingNode = this.nodes.get(departingLeaderId);
500
+ if (!departingNode) return;
501
+ const level = departingNode.hierarchyLevel;
502
+ this.logger.info(`Handling leadership transition at level ${level} for departing leader ${departingLeaderId}`);
503
+ // Find replacement leader
504
+ const leadershipCandidates = Array.from(this.nodes.values()).filter((node)=>node.hierarchyLevel === level && node.id !== departingLeaderId && node.status === 'ready' && node.leadershipScore > this.config.hierarchy.promotionThreshold).sort((a, b)=>b.leadershipScore - a.leadershipScore);
505
+ if (leadershipCandidates.length > 0) {
506
+ const newLeader = leadershipCandidates[0];
507
+ this.leaderNodes.set(level, newLeader.id);
508
+ newLeader.topologyRole = 'coordinator';
509
+ this.logger.info(`Selected new leader ${newLeader.id} for level ${level}`);
510
+ this.emit('leadership:transition', {
511
+ level,
512
+ oldLeader: departingLeaderId,
513
+ newLeader: newLeader.id
514
+ });
515
+ } else {
516
+ // No suitable replacement, remove leadership at this level
517
+ this.leaderNodes.delete(level);
518
+ this.logger.warn(`No suitable leadership replacement found for level ${level}`);
519
+ }
520
+ }
521
+ // ============================================================================
522
+ // Resource Allocation and Management
523
+ // ============================================================================
524
+ async initializeResourcePools() {
525
+ for(let level = 0; level <= this.config.hierarchy.maxDepth; level++){
526
+ const pool = {
527
+ levelId: `level-${level}`,
528
+ totalCapacity: {
529
+ cpu: 100 * Math.pow(0.8, level),
530
+ memory: 100 * Math.pow(0.8, level),
531
+ bandwidth: 100 * Math.pow(0.9, level),
532
+ taskSlots: 50 * Math.pow(0.7, level)
533
+ },
534
+ allocatedResources: {
535
+ cpu: 0,
536
+ memory: 0,
537
+ bandwidth: 0,
538
+ taskSlots: 0
539
+ },
540
+ availableResources: {
541
+ cpu: 0,
542
+ memory: 0,
543
+ bandwidth: 0,
544
+ taskSlots: 0
545
+ },
546
+ utilizationRate: 0
547
+ };
548
+ // Calculate available resources (reserve some capacity)
549
+ const reserveRatio = this.config.resourceAllocation.reserveCapacity;
550
+ pool.availableResources = {
551
+ cpu: pool.totalCapacity.cpu * (1 - reserveRatio),
552
+ memory: pool.totalCapacity.memory * (1 - reserveRatio),
553
+ bandwidth: pool.totalCapacity.bandwidth * (1 - reserveRatio),
554
+ taskSlots: Math.floor(pool.totalCapacity.taskSlots * (1 - reserveRatio))
555
+ };
556
+ this.resourcePools.set(level, pool);
557
+ }
558
+ this.logger.debug(`Initialized resource pools for ${this.resourcePools.size} hierarchy levels`);
559
+ }
560
+ async allocateResources(node) {
561
+ const pool = this.resourcePools.get(node.hierarchyLevel);
562
+ if (!pool) return;
563
+ // Calculate resource requirements based on node capabilities and role
564
+ const requirements = this.calculateResourceRequirements(node);
565
+ // Check if resources are available
566
+ if (this.canAllocateResources(pool, requirements)) {
567
+ // Allocate resources
568
+ node.resourceAllocation = requirements;
569
+ pool.allocatedResources.cpu += requirements.cpu;
570
+ pool.allocatedResources.memory += requirements.memory;
571
+ pool.allocatedResources.bandwidth += requirements.bandwidth;
572
+ pool.allocatedResources.delegatedTasks += requirements.delegatedTasks;
573
+ // Update utilization rate
574
+ pool.utilizationRate = this.calculateUtilizationRate(pool);
575
+ this.logger.debug(`Allocated resources to ${node.id}: CPU ${requirements.cpu}, Memory ${requirements.memory}`);
576
+ } else {
577
+ this.logger.warn(`Insufficient resources at level ${node.hierarchyLevel} for node ${node.id}`);
578
+ // Try to reallocate if dynamic reallocation is enabled
579
+ if (this.config.resourceAllocation.dynamicReallocation) {
580
+ await this.reallocateResources(node.hierarchyLevel);
581
+ }
582
+ }
583
+ }
584
+ async deallocateResources(node) {
585
+ const pool = this.resourcePools.get(node.hierarchyLevel);
586
+ if (!pool) return;
587
+ // Deallocate resources
588
+ pool.allocatedResources.cpu -= node.resourceAllocation.cpu;
589
+ pool.allocatedResources.memory -= node.resourceAllocation.memory;
590
+ pool.allocatedResources.bandwidth -= node.resourceAllocation.bandwidth;
591
+ pool.allocatedResources.delegatedTasks -= node.resourceAllocation.delegatedTasks;
592
+ // Ensure non-negative values
593
+ pool.allocatedResources.cpu = Math.max(0, pool.allocatedResources.cpu);
594
+ pool.allocatedResources.memory = Math.max(0, pool.allocatedResources.memory);
595
+ pool.allocatedResources.bandwidth = Math.max(0, pool.allocatedResources.bandwidth);
596
+ pool.allocatedResources.delegatedTasks = Math.max(0, pool.allocatedResources.delegatedTasks);
597
+ // Update utilization rate
598
+ pool.utilizationRate = this.calculateUtilizationRate(pool);
599
+ this.logger.debug(`Deallocated resources from ${node.id}`);
600
+ }
601
+ calculateResourceRequirements(node) {
602
+ const baseCpu = 10;
603
+ const baseMemory = 10;
604
+ const baseBandwidth = 5;
605
+ const baseTaskSlots = 3;
606
+ let multiplier = 1;
607
+ // Increase requirements for coordinators
608
+ if (node.topologyRole === 'coordinator') {
609
+ multiplier *= 2;
610
+ }
611
+ // Increase based on capabilities
612
+ if (node.capabilities.includes('coordination')) multiplier *= 1.5;
613
+ if (node.capabilities.includes('leadership')) multiplier *= 1.3;
614
+ if (node.capabilities.includes('management')) multiplier *= 1.2;
615
+ // Adjust based on hierarchy level (higher levels need more resources)
616
+ const levelMultiplier = 1 + 0.2 * (this.config.hierarchy.maxDepth - node.hierarchyLevel);
617
+ return {
618
+ cpu: Math.ceil(baseCpu * multiplier * levelMultiplier),
619
+ memory: Math.ceil(baseMemory * multiplier * levelMultiplier),
620
+ bandwidth: Math.ceil(baseBandwidth * multiplier * levelMultiplier),
621
+ delegatedTasks: Math.ceil(baseTaskSlots * multiplier)
622
+ };
623
+ }
624
+ canAllocateResources(pool, requirements) {
625
+ const availableCpu = pool.totalCapacity.cpu - pool.allocatedResources.cpu;
626
+ const availableMemory = pool.totalCapacity.memory - pool.allocatedResources.memory;
627
+ const availableBandwidth = pool.totalCapacity.bandwidth - pool.allocatedResources.bandwidth;
628
+ const availableTaskSlots = pool.totalCapacity.taskSlots - pool.allocatedResources.delegatedTasks;
629
+ return availableCpu >= requirements.cpu && availableMemory >= requirements.memory && availableBandwidth >= requirements.bandwidth && availableTaskSlots >= requirements.delegatedTasks;
630
+ }
631
+ calculateUtilizationRate(pool) {
632
+ const cpuUtilization = pool.allocatedResources.cpu / pool.totalCapacity.cpu;
633
+ const memoryUtilization = pool.allocatedResources.memory / pool.totalCapacity.memory;
634
+ const bandwidthUtilization = pool.allocatedResources.bandwidth / pool.totalCapacity.bandwidth;
635
+ const taskUtilization = pool.allocatedResources.delegatedTasks / pool.totalCapacity.taskSlots;
636
+ return (cpuUtilization + memoryUtilization + bandwidthUtilization + taskUtilization) / 4;
637
+ }
638
+ async reallocateResources(level) {
639
+ this.logger.info(`Reallocating resources at level ${level}`);
640
+ const nodesAtLevel = Array.from(this.nodes.values()).filter((node)=>node.hierarchyLevel === level);
641
+ // Collect all allocated resources
642
+ let totalAllocated = {
643
+ cpu: 0,
644
+ memory: 0,
645
+ bandwidth: 0,
646
+ delegatedTasks: 0
647
+ };
648
+ for (const node of nodesAtLevel){
649
+ totalAllocated.cpu += node.resourceAllocation.cpu;
650
+ totalAllocated.memory += node.resourceAllocation.memory;
651
+ totalAllocated.bandwidth += node.resourceAllocation.bandwidth;
652
+ totalAllocated.delegatedTasks += node.resourceAllocation.delegatedTasks;
653
+ }
654
+ // Redistribute based on current performance and needs
655
+ const pool = this.resourcePools.get(level);
656
+ if (pool) {
657
+ pool.allocatedResources = totalAllocated;
658
+ pool.utilizationRate = this.calculateUtilizationRate(pool);
659
+ }
660
+ }
661
+ // ============================================================================
662
+ // Enhanced Task Coordination and Delegation
663
+ // ============================================================================
664
+ async coordinateTask(task) {
665
+ const taskId = task.id || generateId('enhanced-hier-task');
666
+ const enhancedTask = {
667
+ ...task,
668
+ id: taskId,
669
+ topology: 'hierarchical',
670
+ coordinatorId: this.id,
671
+ status: 'pending',
672
+ createdAt: new Date(),
673
+ coordinationPattern: task.coordinationPattern || 'sequential',
674
+ metadata: {
675
+ ...task.metadata,
676
+ enhancedHierarchical: true,
677
+ delegationStrategy: this.config.delegation.strategy,
678
+ requiresSubdelegation: task.priority > 6
679
+ }
680
+ };
681
+ this.tasks.set(taskId, enhancedTask);
682
+ // Select optimal delegation path
683
+ const delegationPath = await this.planDelegationPath(enhancedTask);
684
+ this.delegationPaths.set(taskId, delegationPath);
685
+ // Execute delegation
686
+ await this.executeDelegation(enhancedTask, delegationPath);
687
+ enhancedTask.status = 'active';
688
+ enhancedTask.startedAt = new Date();
689
+ this.logger.info(`Coordinated enhanced hierarchical task ${taskId} with ${delegationPath.totalDepth} levels`);
690
+ this.emit('task:coordinated', {
691
+ taskId,
692
+ agentIds: enhancedTask.assignedAgents,
693
+ delegationDepth: delegationPath.totalDepth
694
+ });
695
+ return taskId;
696
+ }
697
+ async delegateTask(taskId, agentIds) {
698
+ const task = this.tasks.get(taskId);
699
+ if (!task) {
700
+ throw new Error(`Task ${taskId} not found`);
701
+ }
702
+ const agents = agentIds.map((id)=>this.nodes.get(id)).filter((agent)=>agent !== undefined);
703
+ if (agents.length !== agentIds.length) {
704
+ throw new Error('Some specified agents not found');
705
+ }
706
+ task.assignedAgents = agentIds;
707
+ // Create new delegation path for manual delegation
708
+ const delegationPath = await this.createDelegationPath(task, agents);
709
+ this.delegationPaths.set(taskId, delegationPath);
710
+ await this.executeDelegation(task, delegationPath);
711
+ this.logger.info(`Manually delegated task ${taskId} to ${agentIds.length} agents`);
712
+ this.emit('task:delegated', {
713
+ taskId,
714
+ agentIds
715
+ });
716
+ }
717
+ async planDelegationPath(task) {
718
+ const startTime = Date.now();
719
+ // Select appropriate agents based on task requirements and hierarchy
720
+ const selectedAgents = await this.selectAgentsForHierarchicalTask(task);
721
+ if (selectedAgents.length === 0) {
722
+ throw new Error('No suitable agents found for hierarchical delegation');
723
+ }
724
+ // Create delegation path
725
+ const path = await this.createDelegationPath(task, selectedAgents);
726
+ // Update delegation latency metric
727
+ this.metrics.delegationLatency = (this.metrics.delegationLatency + (Date.now() - startTime)) / 2;
728
+ return path;
729
+ }
730
+ async selectAgentsForHierarchicalTask(task) {
731
+ const requiredCapabilities = task.metadata.requiredCapabilities || [];
732
+ const priority = task.priority;
733
+ // Strategy-based selection
734
+ switch(this.config.delegation.strategy){
735
+ case 'top-down':
736
+ return this.selectAgentsTopDown(requiredCapabilities, priority);
737
+ case 'bottom-up':
738
+ return this.selectAgentsBottomUp(requiredCapabilities, priority);
739
+ case 'adaptive':
740
+ return this.selectAgentsAdaptive(task);
741
+ case 'hybrid':
742
+ default:
743
+ return this.selectAgentsHybrid(requiredCapabilities, priority);
744
+ }
745
+ }
746
+ async selectAgentsTopDown(capabilities, priority) {
747
+ const selectedAgents = [];
748
+ // Start from top levels and work down
749
+ for(let level = 0; level <= this.config.hierarchy.maxDepth; level++){
750
+ const candidatesAtLevel = Array.from(this.nodes.values()).filter((node)=>node.hierarchyLevel === level && node.status === 'ready' && this.hasRequiredCapabilities(node, capabilities)).sort((a, b)=>b.leadershipScore - a.leadershipScore);
751
+ if (candidatesAtLevel.length > 0) {
752
+ selectedAgents.push(candidatesAtLevel[0]);
753
+ if (selectedAgents.length >= 3) break; // Limit selection
754
+ }
755
+ }
756
+ return selectedAgents;
757
+ }
758
+ async selectAgentsBottomUp(capabilities, priority) {
759
+ const selectedAgents = [];
760
+ // Start from bottom levels and work up
761
+ for(let level = this.config.hierarchy.maxDepth; level >= 0; level--){
762
+ const candidatesAtLevel = Array.from(this.nodes.values()).filter((node)=>node.hierarchyLevel === level && node.status === 'ready' && this.hasRequiredCapabilities(node, capabilities) && node.workload < node.delegationCapacity * 0.8).sort((a, b)=>b.performanceMetrics.reliability - a.performanceMetrics.reliability);
763
+ if (candidatesAtLevel.length > 0) {
764
+ selectedAgents.push(candidatesAtLevel[0]);
765
+ if (selectedAgents.length >= 3) break;
766
+ }
767
+ }
768
+ return selectedAgents;
769
+ }
770
+ async selectAgentsAdaptive(task) {
771
+ // Analyze task characteristics to determine best approach
772
+ const isComplexTask = task.priority > 7 || (task.metadata.requiredCapabilities || []).length > 3;
773
+ const needsCoordination = task.coordinationPattern === 'parallel' || task.coordinationPattern === 'mapreduce';
774
+ if (needsCoordination || isComplexTask) {
775
+ return this.selectAgentsTopDown(task.metadata.requiredCapabilities || [], task.priority);
776
+ } else {
777
+ return this.selectAgentsBottomUp(task.metadata.requiredCapabilities || [], task.priority);
778
+ }
779
+ }
780
+ async selectAgentsHybrid(capabilities, priority) {
781
+ const selectedAgents = [];
782
+ // Select one coordinator from top levels
783
+ const coordinators = Array.from(this.nodes.values()).filter((node)=>node.hierarchyLevel <= 2 && node.topologyRole === 'coordinator' && node.status === 'ready').sort((a, b)=>b.leadershipScore - a.leadershipScore);
784
+ if (coordinators.length > 0) {
785
+ selectedAgents.push(coordinators[0]);
786
+ }
787
+ // Select workers from appropriate levels
788
+ const workers = Array.from(this.nodes.values()).filter((node)=>node.hierarchyLevel >= 2 && node.status === 'ready' && this.hasRequiredCapabilities(node, capabilities) && node.workload < node.delegationCapacity * 0.7).sort((a, b)=>b.performanceMetrics.reliability - a.performanceMetrics.reliability).slice(0, 4); // Limit workers
789
+ selectedAgents.push(...workers);
790
+ return selectedAgents;
791
+ }
792
+ hasRequiredCapabilities(node, requiredCapabilities) {
793
+ if (requiredCapabilities.length === 0) return true;
794
+ return requiredCapabilities.every((cap)=>node.capabilities.includes(cap));
795
+ }
796
+ async createDelegationPath(task, agents) {
797
+ const path = agents.map((agent)=>({
798
+ agentId: agent.id,
799
+ level: agent.hierarchyLevel,
800
+ delegationTime: new Date(),
801
+ status: 'pending'
802
+ }));
803
+ // Sort by hierarchy level (top-down delegation)
804
+ path.sort((a, b)=>a.level - b.level);
805
+ const estimatedDuration = this.estimateTaskDuration(task, agents);
806
+ return {
807
+ taskId: task.id,
808
+ path,
809
+ totalDepth: path.length,
810
+ expectedCompletionTime: new Date(Date.now() + estimatedDuration)
811
+ };
812
+ }
813
+ estimateTaskDuration(task, agents) {
814
+ const baseEstimate = task.estimatedDuration || 60000; // 1 minute default
815
+ // Adjust based on delegation complexity
816
+ const delegationOverhead = agents.length * 1000; // 1 second per agent
817
+ // Adjust based on hierarchy depth
818
+ const maxLevel = Math.max(...agents.map((a)=>a.hierarchyLevel));
819
+ const depthOverhead = maxLevel * 500; // 0.5 seconds per level
820
+ return baseEstimate + delegationOverhead + depthOverhead;
821
+ }
822
+ async executeDelegation(task, delegationPath) {
823
+ // Register dependencies for hierarchical coordination
824
+ await this.registerHierarchicalTaskDependencies(task, delegationPath);
825
+ // Execute delegation according to pattern
826
+ switch(task.coordinationPattern){
827
+ case 'sequential':
828
+ await this.executeSequentialDelegation(task, delegationPath);
829
+ break;
830
+ case 'parallel':
831
+ await this.executeParallelDelegation(task, delegationPath);
832
+ break;
833
+ case 'pipeline':
834
+ await this.executePipelineDelegation(task, delegationPath);
835
+ break;
836
+ case 'mapreduce':
837
+ await this.executeMapReduceDelegation(task, delegationPath);
838
+ break;
839
+ default:
840
+ await this.executeSequentialDelegation(task, delegationPath);
841
+ }
842
+ // Update task assignment
843
+ task.assignedAgents = delegationPath.path.map((p)=>p.agentId);
844
+ }
845
+ async executeSequentialDelegation(task, delegationPath) {
846
+ // Delegate to agents in sequence (top-down)
847
+ for (const step of delegationPath.path){
848
+ const agent = this.nodes.get(step.agentId);
849
+ if (agent) {
850
+ await this.delegateToAgent(task, agent, 'sequential');
851
+ step.status = 'active';
852
+ step.delegationTime = new Date();
853
+ }
854
+ }
855
+ }
856
+ async executeParallelDelegation(task, delegationPath) {
857
+ // Delegate to all agents simultaneously
858
+ const promises = delegationPath.path.map(async (step)=>{
859
+ const agent = this.nodes.get(step.agentId);
860
+ if (agent) {
861
+ await this.delegateToAgent(task, agent, 'parallel');
862
+ step.status = 'active';
863
+ step.delegationTime = new Date();
864
+ }
865
+ });
866
+ await Promise.allSettled(promises);
867
+ }
868
+ async executePipelineDelegation(task, delegationPath) {
869
+ // Create pipeline stages based on hierarchy levels
870
+ const stages = new Map();
871
+ for (const step of delegationPath.path){
872
+ if (!stages.has(step.level)) {
873
+ stages.set(step.level, []);
874
+ }
875
+ stages.get(step.level).push(step);
876
+ }
877
+ // Execute stages in order
878
+ const sortedLevels = Array.from(stages.keys()).sort();
879
+ for (const level of sortedLevels){
880
+ const stageSteps = stages.get(level);
881
+ const promises = stageSteps.map(async (step)=>{
882
+ const agent = this.nodes.get(step.agentId);
883
+ if (agent) {
884
+ await this.delegateToAgent(task, agent, 'pipeline');
885
+ step.status = 'active';
886
+ step.delegationTime = new Date();
887
+ }
888
+ });
889
+ await Promise.allSettled(promises);
890
+ }
891
+ }
892
+ async executeMapReduceDelegation(task, delegationPath) {
893
+ // Separate mappers and reducers
894
+ const mappers = delegationPath.path.filter((step)=>step.level >= 3); // Lower levels for mapping
895
+ const reducers = delegationPath.path.filter((step)=>step.level < 3); // Higher levels for reducing
896
+ // Execute map phase
897
+ const mapPromises = mappers.map(async (step)=>{
898
+ const agent = this.nodes.get(step.agentId);
899
+ if (agent) {
900
+ await this.delegateToAgent(task, agent, 'map');
901
+ step.status = 'active';
902
+ step.delegationTime = new Date();
903
+ }
904
+ });
905
+ await Promise.allSettled(mapPromises);
906
+ // Execute reduce phase
907
+ const reducePromises = reducers.map(async (step)=>{
908
+ const agent = this.nodes.get(step.agentId);
909
+ if (agent) {
910
+ await this.delegateToAgent(task, agent, 'reduce');
911
+ step.status = 'active';
912
+ step.delegationTime = new Date();
913
+ }
914
+ });
915
+ await Promise.allSettled(reducePromises);
916
+ }
917
+ async delegateToAgent(task, agent, executionMode) {
918
+ // Update agent workload
919
+ agent.workload += 1;
920
+ agent.lastActivity = new Date();
921
+ agent.status = 'working';
922
+ agent.resourceAllocation.delegatedTasks += 1;
923
+ // Create delegation message
924
+ const delegationMessage = {
925
+ id: generateId('delegation'),
926
+ type: 'task',
927
+ sourceId: this.id,
928
+ targetId: agent.id,
929
+ payload: {
930
+ task,
931
+ executionMode,
932
+ hierarchyContext: {
933
+ level: agent.hierarchyLevel,
934
+ parentId: agent.parentId,
935
+ childIds: agent.childIds,
936
+ delegationCapacity: agent.delegationCapacity
937
+ }
938
+ },
939
+ timestamp: new Date(),
940
+ priority: task.priority,
941
+ requiresAck: true,
942
+ ttl: this.config.timeouts.completion,
943
+ retryCount: 0,
944
+ maxRetries: 2
945
+ };
946
+ // Send delegation (simulated)
947
+ await this.sendMessage(delegationMessage);
948
+ this.logger.debug(`Delegated task ${task.id} to agent ${agent.id} in ${executionMode} mode`);
949
+ }
950
+ // ============================================================================
951
+ // Task Completion and Recovery
952
+ // ============================================================================
953
+ async handleTaskCompletion(taskId, agentId, result) {
954
+ const task = this.tasks.get(taskId);
955
+ const agent = this.nodes.get(agentId);
956
+ const delegationPath = this.delegationPaths.get(taskId);
957
+ if (!task || !agent || !delegationPath) return;
958
+ // Update agent metrics and status
959
+ agent.status = 'ready';
960
+ agent.workload = Math.max(0, agent.workload - 1);
961
+ agent.lastActivity = new Date();
962
+ agent.performanceMetrics.tasksCompleted += 1;
963
+ agent.resourceAllocation.delegatedTasks = Math.max(0, agent.resourceAllocation.delegatedTasks - 1);
964
+ // Calculate task completion time
965
+ const taskStartTime = delegationPath.path.find((p)=>p.agentId === agentId)?.delegationTime;
966
+ if (taskStartTime) {
967
+ const completionTime = Date.now() - taskStartTime.getTime();
968
+ agent.performanceMetrics.averageTaskTime = (agent.performanceMetrics.averageTaskTime + completionTime) / 2;
969
+ }
970
+ // Update delegation path
971
+ const pathStep = delegationPath.path.find((p)=>p.agentId === agentId);
972
+ if (pathStep) {
973
+ pathStep.status = 'completed';
974
+ }
975
+ // Check if all agents in delegation path completed
976
+ const allCompleted = delegationPath.path.every((p)=>p.status === 'completed');
977
+ if (allCompleted) {
978
+ task.status = 'completed';
979
+ task.completedAt = new Date();
980
+ task.result = result;
981
+ task.actualDuration = task.completedAt.getTime() - (task.startedAt?.getTime() || task.createdAt.getTime());
982
+ // Resolve dependencies
983
+ await this.resolveHierarchicalTaskDependencies(taskId);
984
+ // Update hierarchy efficiency metric
985
+ this.updateHierarchyEfficiency(task, delegationPath);
986
+ this.logger.info(`Enhanced hierarchical task ${taskId} completed by all agents`);
987
+ this.emit('task:completed', {
988
+ taskId,
989
+ result,
990
+ delegationDepth: delegationPath.totalDepth
991
+ });
992
+ // Check coordinator completion
993
+ await this.checkCoordinatorCompletion();
994
+ }
995
+ // Update subtree metrics
996
+ await this.updateSubtreeMetrics(agentId);
997
+ }
998
+ async handleTaskFailure(taskId, agentId, error) {
999
+ const task = this.tasks.get(taskId);
1000
+ const agent = this.nodes.get(agentId);
1001
+ const delegationPath = this.delegationPaths.get(taskId);
1002
+ if (!task || !agent) return;
1003
+ // Update agent metrics
1004
+ agent.performanceMetrics.errorCount += 1;
1005
+ agent.performanceMetrics.reliability = Math.max(0.1, agent.performanceMetrics.reliability - 0.05);
1006
+ agent.status = 'ready'; // Reset to ready for potential retry
1007
+ agent.workload = Math.max(0, agent.workload - 1);
1008
+ agent.resourceAllocation.delegatedTasks = Math.max(0, agent.resourceAllocation.delegatedTasks - 1);
1009
+ // Update delegation path
1010
+ if (delegationPath) {
1011
+ const pathStep = delegationPath.path.find((p)=>p.agentId === agentId);
1012
+ if (pathStep) {
1013
+ pathStep.status = 'failed';
1014
+ }
1015
+ }
1016
+ // Attempt recovery if enabled
1017
+ if (this.config.recovery.enableAutomaticRecovery) {
1018
+ const recoverySuccessful = await this.attemptHierarchicalRecovery(taskId, agentId, error);
1019
+ if (recoverySuccessful) {
1020
+ this.metrics.recoveryActions += 1;
1021
+ this.logger.info(`Successfully recovered task ${taskId} after failure from ${agentId}`);
1022
+ return; // Recovery successful, don't mark as failed
1023
+ }
1024
+ }
1025
+ // Mark task as failed if recovery unsuccessful
1026
+ task.status = 'failed';
1027
+ task.error = error;
1028
+ task.completedAt = new Date();
1029
+ this.logger.error(`Enhanced hierarchical task ${taskId} failed: ${error}`);
1030
+ this.emit('task:failed', {
1031
+ taskId,
1032
+ error,
1033
+ agentId
1034
+ });
1035
+ // Update subtree metrics
1036
+ await this.updateSubtreeMetrics(agentId);
1037
+ }
1038
+ async attemptHierarchicalRecovery(taskId, failedAgentId, error) {
1039
+ const task = this.tasks.get(taskId);
1040
+ const delegationPath = this.delegationPaths.get(taskId);
1041
+ const failedAgent = this.nodes.get(failedAgentId);
1042
+ if (!task || !delegationPath || !failedAgent) return false;
1043
+ this.logger.info(`Attempting hierarchical recovery for task ${taskId} after failure from ${failedAgentId}`);
1044
+ // Strategy 1: Try sibling agents at the same level
1045
+ const siblings = await this.findSiblingAgents(failedAgent);
1046
+ for (const sibling of siblings){
1047
+ if (sibling.status === 'ready' && sibling.workload < sibling.delegationCapacity * 0.8 && this.hasRequiredCapabilities(sibling, task.metadata.requiredCapabilities || [])) {
1048
+ // Replace failed agent with sibling
1049
+ const pathStep = delegationPath.path.find((p)=>p.agentId === failedAgentId);
1050
+ if (pathStep) {
1051
+ pathStep.agentId = sibling.id;
1052
+ pathStep.status = 'pending';
1053
+ pathStep.delegationTime = new Date();
1054
+ }
1055
+ // Update task assignment
1056
+ task.assignedAgents = task.assignedAgents.map((id)=>id === failedAgentId ? sibling.id : id);
1057
+ // Delegate to recovery agent
1058
+ await this.delegateToAgent(task, sibling, 'recovery');
1059
+ this.logger.info(`Recovered task ${taskId} using sibling agent ${sibling.id}`);
1060
+ return true;
1061
+ }
1062
+ }
1063
+ // Strategy 2: Try agents at parent level (escalation)
1064
+ if (failedAgent.parentId) {
1065
+ const parent = this.nodes.get(failedAgent.parentId);
1066
+ if (parent && parent.status === 'ready' && parent.workload < parent.delegationCapacity * 0.9) {
1067
+ // Escalate to parent
1068
+ const pathStep = delegationPath.path.find((p)=>p.agentId === failedAgentId);
1069
+ if (pathStep) {
1070
+ pathStep.agentId = parent.id;
1071
+ pathStep.level = parent.hierarchyLevel;
1072
+ pathStep.status = 'pending';
1073
+ pathStep.delegationTime = new Date();
1074
+ }
1075
+ task.assignedAgents = task.assignedAgents.map((id)=>id === failedAgentId ? parent.id : id);
1076
+ await this.delegateToAgent(task, parent, 'escalation');
1077
+ this.logger.info(`Recovered task ${taskId} by escalating to parent ${parent.id}`);
1078
+ return true;
1079
+ }
1080
+ }
1081
+ // Strategy 3: Try to delegate to children (sub-delegation)
1082
+ if (this.config.delegation.enableSubdelegation && failedAgent.childIds.length > 0) {
1083
+ const suitableChildren = failedAgent.childIds.map((id)=>this.nodes.get(id)).filter((child)=>child !== undefined && child.status === 'ready' && child.workload < child.delegationCapacity * 0.8);
1084
+ if (suitableChildren.length > 0) {
1085
+ const recoveryChild = suitableChildren[0];
1086
+ const pathStep = delegationPath.path.find((p)=>p.agentId === failedAgentId);
1087
+ if (pathStep) {
1088
+ pathStep.agentId = recoveryChild.id;
1089
+ pathStep.level = recoveryChild.hierarchyLevel;
1090
+ pathStep.status = 'pending';
1091
+ pathStep.delegationTime = new Date();
1092
+ }
1093
+ task.assignedAgents = task.assignedAgents.map((id)=>id === failedAgentId ? recoveryChild.id : id);
1094
+ await this.delegateToAgent(task, recoveryChild, 'sub-delegation');
1095
+ this.logger.info(`Recovered task ${taskId} by sub-delegating to child ${recoveryChild.id}`);
1096
+ return true;
1097
+ }
1098
+ }
1099
+ this.logger.warn(`No recovery strategy available for task ${taskId} failure`);
1100
+ return false;
1101
+ }
1102
+ async findSiblingAgents(agent) {
1103
+ if (!agent.parentId) {
1104
+ // Root level siblings
1105
+ return Array.from(this.nodes.values()).filter((node)=>node.hierarchyLevel === agent.hierarchyLevel && node.id !== agent.id && !node.parentId);
1106
+ }
1107
+ const parent = this.nodes.get(agent.parentId);
1108
+ if (!parent) return [];
1109
+ return parent.childIds.map((id)=>this.nodes.get(id)).filter((sibling)=>sibling !== undefined && sibling.id !== agent.id);
1110
+ }
1111
+ // ============================================================================
1112
+ // Metrics and Monitoring
1113
+ // ============================================================================
1114
+ async updateSubtreeMetrics(nodeId) {
1115
+ const node = this.nodes.get(nodeId);
1116
+ if (!node) return;
1117
+ // Calculate subtree metrics
1118
+ const subtreeNodes = await this.getSubtreeNodes(nodeId);
1119
+ node.subtreeMetrics = {
1120
+ totalNodes: subtreeNodes.length,
1121
+ activeNodes: subtreeNodes.filter((n)=>n.status === 'ready' || n.status === 'working').length,
1122
+ failedNodes: subtreeNodes.filter((n)=>n.status === 'failed').length,
1123
+ averagePerformance: subtreeNodes.reduce((sum, n)=>sum + n.performanceMetrics.reliability, 0) / subtreeNodes.length
1124
+ };
1125
+ // Recursively update parent metrics
1126
+ if (node.parentId) {
1127
+ await this.updateSubtreeMetrics(node.parentId);
1128
+ }
1129
+ }
1130
+ async getSubtreeNodes(rootId) {
1131
+ const root = this.nodes.get(rootId);
1132
+ if (!root) return [];
1133
+ const subtree = [
1134
+ root
1135
+ ];
1136
+ // Recursively collect all descendants
1137
+ for (const childId of root.childIds){
1138
+ const childSubtree = await this.getSubtreeNodes(childId);
1139
+ subtree.push(...childSubtree);
1140
+ }
1141
+ return subtree;
1142
+ }
1143
+ updateHierarchyEfficiency(task, delegationPath) {
1144
+ const actualDuration = task.actualDuration || 0;
1145
+ const expectedDuration = delegationPath.expectedCompletionTime.getTime() - task.createdAt.getTime();
1146
+ const efficiency = expectedDuration > 0 ? Math.min(1, expectedDuration / actualDuration) : 1;
1147
+ this.metrics.hierarchyEfficiency = (this.metrics.hierarchyEfficiency + efficiency) / 2;
1148
+ }
1149
+ async updateAncestorMetrics(nodeId) {
1150
+ const node = this.nodes.get(nodeId);
1151
+ if (!node || !node.parentId) return;
1152
+ await this.updateSubtreeMetrics(node.parentId);
1153
+ }
1154
+ // ============================================================================
1155
+ // Background Tasks and Promotion/Demotion
1156
+ // ============================================================================
1157
+ startBackgroundTasks() {
1158
+ // Hierarchy rebalancing
1159
+ this.hierarchyRebalanceTimer = setInterval(()=>{
1160
+ this.rebalanceHierarchy();
1161
+ }, this.config.hierarchy.rebalanceInterval);
1162
+ // Resource reallocation
1163
+ if (this.config.resourceAllocation.dynamicReallocation) {
1164
+ this.resourceReallocationTimer = setInterval(()=>{
1165
+ this.dynamicResourceReallocation();
1166
+ }, 45000); // Every 45 seconds
1167
+ }
1168
+ // Failure detection
1169
+ if (this.config.recovery.enableAutomaticRecovery) {
1170
+ this.failureDetectionTimer = setInterval(()=>{
1171
+ this.detectAndHandleFailures();
1172
+ }, this.config.recovery.failureDetectionTimeout);
1173
+ }
1174
+ // Promotion/demotion evaluation
1175
+ this.promotionEvaluationTimer = setInterval(()=>{
1176
+ this.evaluatePromotionDemotionOpportunities();
1177
+ }, 90000); // Every 90 seconds
1178
+ }
1179
+ stopBackgroundTasks() {
1180
+ if (this.hierarchyRebalanceTimer) {
1181
+ clearInterval(this.hierarchyRebalanceTimer);
1182
+ this.hierarchyRebalanceTimer = undefined;
1183
+ }
1184
+ if (this.resourceReallocationTimer) {
1185
+ clearInterval(this.resourceReallocationTimer);
1186
+ this.resourceReallocationTimer = undefined;
1187
+ }
1188
+ if (this.failureDetectionTimer) {
1189
+ clearInterval(this.failureDetectionTimer);
1190
+ this.failureDetectionTimer = undefined;
1191
+ }
1192
+ if (this.promotionEvaluationTimer) {
1193
+ clearInterval(this.promotionEvaluationTimer);
1194
+ this.promotionEvaluationTimer = undefined;
1195
+ }
1196
+ }
1197
+ async rebalanceHierarchy() {
1198
+ this.logger.debug('Rebalancing hierarchy...');
1199
+ // Check for overloaded nodes at each level
1200
+ for(let level = 0; level <= this.config.hierarchy.maxDepth; level++){
1201
+ const nodesAtLevel = Array.from(this.nodes.values()).filter((node)=>node.hierarchyLevel === level);
1202
+ for (const node of nodesAtLevel){
1203
+ // Check if node is overloaded
1204
+ if (node.childIds.length > this.config.hierarchy.maxChildrenPerNode * 0.9) {
1205
+ await this.redistributeChildren(node);
1206
+ }
1207
+ // Check for underutilized nodes
1208
+ if (node.childIds.length === 0 && node.hierarchyLevel > 0 && node.workload === 0) {
1209
+ await this.considerNodeDemotion(node);
1210
+ }
1211
+ }
1212
+ }
1213
+ }
1214
+ async dynamicResourceReallocation() {
1215
+ for (const [level, pool] of this.resourcePools){
1216
+ if (pool.utilizationRate > 0.9) {
1217
+ // High utilization - try to reallocate
1218
+ await this.reallocateResources(level);
1219
+ }
1220
+ }
1221
+ // Update global resource utilization metric
1222
+ const totalUtilization = Array.from(this.resourcePools.values()).reduce((sum, pool)=>sum + pool.utilizationRate, 0);
1223
+ this.metrics.resourceUtilization = this.resourcePools.size > 0 ? totalUtilization / this.resourcePools.size : 0;
1224
+ }
1225
+ async detectAndHandleFailures() {
1226
+ const now = new Date();
1227
+ const timeoutThreshold = this.config.recovery.failureDetectionTimeout;
1228
+ for (const [nodeId, node] of this.nodes){
1229
+ const timeSinceActivity = now.getTime() - node.lastActivity.getTime();
1230
+ if (timeSinceActivity > timeoutThreshold && node.status === 'working') {
1231
+ this.logger.warn(`Detected potential failure in node ${nodeId} (no activity for ${timeSinceActivity}ms)`);
1232
+ // Mark as failed and attempt recovery
1233
+ node.status = 'failed';
1234
+ await this.handleNodeFailure(nodeId);
1235
+ }
1236
+ }
1237
+ }
1238
+ async handleNodeFailure(nodeId) {
1239
+ const node = this.nodes.get(nodeId);
1240
+ if (!node) return;
1241
+ this.logger.info(`Handling failure for node ${nodeId}`);
1242
+ // Find active tasks assigned to this node
1243
+ const activeTasks = Array.from(this.tasks.values()).filter((task)=>task.status === 'active' && task.assignedAgents.includes(nodeId));
1244
+ // Attempt recovery for each active task
1245
+ for (const task of activeTasks){
1246
+ await this.attemptHierarchicalRecovery(task.id, nodeId, 'Node failure detected');
1247
+ }
1248
+ // Handle children redistribution
1249
+ if (node.childIds.length > 0) {
1250
+ await this.redistributeChildren(node);
1251
+ }
1252
+ }
1253
+ async evaluatePromotionDemotionOpportunities() {
1254
+ this.promotionCandidates = [];
1255
+ for (const [nodeId, node] of this.nodes){
1256
+ // Check for promotion opportunities
1257
+ if (node.performanceMetrics.reliability > this.config.hierarchy.promotionThreshold && node.leadershipScore > this.config.hierarchy.promotionThreshold && node.hierarchyLevel < this.config.hierarchy.maxDepth - 1) {
1258
+ const promotionCandidate = await this.evaluatePromotionCandidate(node);
1259
+ if (promotionCandidate) {
1260
+ this.promotionCandidates.push(promotionCandidate);
1261
+ }
1262
+ }
1263
+ // Check for demotion opportunities
1264
+ if (node.performanceMetrics.reliability < this.config.hierarchy.demotionThreshold && node.hierarchyLevel > 0) {
1265
+ await this.considerNodeDemotion(node);
1266
+ }
1267
+ }
1268
+ // Execute top promotion recommendations
1269
+ const topPromotions = this.promotionCandidates.sort((a, b)=>b.score - a.score).slice(0, 2); // Limit to 2 promotions per cycle
1270
+ for (const promotion of topPromotions){
1271
+ await this.executePromotion(promotion);
1272
+ }
1273
+ }
1274
+ async evaluatePromotionCandidate(node) {
1275
+ const targetLevel = Math.max(0, node.hierarchyLevel - 1); // Promote one level up
1276
+ // Check if there's space at target level
1277
+ const nodesAtTargetLevel = Array.from(this.nodes.values()).filter((n)=>n.hierarchyLevel === targetLevel);
1278
+ if (nodesAtTargetLevel.length >= Math.pow(this.config.hierarchy.maxChildrenPerNode, targetLevel + 1)) {
1279
+ return null; // No space for promotion
1280
+ }
1281
+ // Calculate promotion score
1282
+ const performanceScore = node.performanceMetrics.reliability;
1283
+ const leadershipScore = node.leadershipScore;
1284
+ const capacityScore = node.delegationCapacity / 20; // Normalize
1285
+ const experienceScore = Math.min(1, node.performanceMetrics.tasksCompleted / 50);
1286
+ const score = performanceScore * 0.3 + leadershipScore * 0.3 + capacityScore * 0.2 + experienceScore * 0.2;
1287
+ if (score < 0.7) return null; // Minimum score threshold
1288
+ return {
1289
+ agentId: node.id,
1290
+ currentLevel: node.hierarchyLevel,
1291
+ targetLevel,
1292
+ score,
1293
+ reasoning: [
1294
+ `High performance: ${(performanceScore * 100).toFixed(1)}%`,
1295
+ `Strong leadership: ${(leadershipScore * 100).toFixed(1)}%`,
1296
+ `Good delegation capacity: ${node.delegationCapacity}`,
1297
+ `Completed ${node.performanceMetrics.tasksCompleted} tasks`
1298
+ ],
1299
+ requirements: [
1300
+ 'Maintain current performance level',
1301
+ 'Accept increased coordination responsibilities',
1302
+ 'Manage additional subordinates'
1303
+ ],
1304
+ promotionPlan: {
1305
+ steps: [
1306
+ 'Update hierarchy position',
1307
+ 'Establish new parent-child relationships',
1308
+ 'Reallocate resources',
1309
+ 'Update communication channels'
1310
+ ],
1311
+ estimatedDuration: 30000,
1312
+ riskAssessment: score > 0.85 ? 'low' : 'medium'
1313
+ }
1314
+ };
1315
+ }
1316
+ async executePromotion(promotion) {
1317
+ const node = this.nodes.get(promotion.agentId);
1318
+ if (!node) return;
1319
+ this.logger.info(`Promoting agent ${promotion.agentId} from level ${promotion.currentLevel} to ${promotion.targetLevel}`);
1320
+ // Find new parent at target level
1321
+ const newParentId = this.findBestParentAtLevel(promotion.targetLevel - 1);
1322
+ // Remove from current parent
1323
+ if (node.parentId) {
1324
+ const oldParent = this.nodes.get(node.parentId);
1325
+ if (oldParent) {
1326
+ oldParent.childIds = oldParent.childIds.filter((id)=>id !== node.id);
1327
+ }
1328
+ } else {
1329
+ this.rootNodeIds.delete(node.id);
1330
+ }
1331
+ // Update node hierarchy position
1332
+ node.hierarchyLevel = promotion.targetLevel;
1333
+ node.parentId = newParentId;
1334
+ node.hierarchyPath = newParentId ? [
1335
+ ...this.nodes.get(newParentId)?.hierarchyPath || [],
1336
+ newParentId
1337
+ ] : [];
1338
+ // Add to new parent or root
1339
+ if (newParentId) {
1340
+ const newParent = this.nodes.get(newParentId);
1341
+ if (newParent) {
1342
+ newParent.childIds.push(node.id);
1343
+ }
1344
+ } else {
1345
+ this.rootNodeIds.add(node.id);
1346
+ }
1347
+ // Reallocate resources
1348
+ await this.deallocateResources(node);
1349
+ await this.allocateResources(node);
1350
+ // Update dependencies
1351
+ await this.updatePromotionDependencies(node);
1352
+ // Update metrics
1353
+ await this.updateSubtreeMetrics(node.id);
1354
+ if (node.parentId) {
1355
+ await this.updateSubtreeMetrics(node.parentId);
1356
+ }
1357
+ this.metrics.promotions += 1;
1358
+ this.emit('agent:promoted', {
1359
+ agentId: promotion.agentId,
1360
+ fromLevel: promotion.currentLevel,
1361
+ toLevel: promotion.targetLevel,
1362
+ score: promotion.score
1363
+ });
1364
+ }
1365
+ async considerNodeDemotion(node) {
1366
+ if (node.hierarchyLevel >= this.config.hierarchy.maxDepth) return;
1367
+ this.logger.info(`Considering demotion for underperforming node ${node.id}`);
1368
+ const targetLevel = node.hierarchyLevel + 1; // Demote one level down
1369
+ // Find suitable parent at current level
1370
+ const potentialParents = Array.from(this.nodes.values()).filter((n)=>n.hierarchyLevel === node.hierarchyLevel && n.id !== node.id && n.childIds.length < this.config.hierarchy.maxChildrenPerNode && n.performanceMetrics.reliability > this.config.hierarchy.promotionThreshold);
1371
+ if (potentialParents.length === 0) return;
1372
+ const newParent = potentialParents[0];
1373
+ // Execute demotion
1374
+ await this.executeDemotion(node, newParent, targetLevel);
1375
+ }
1376
+ async executeDemotion(node, newParent, targetLevel) {
1377
+ this.logger.info(`Demoting agent ${node.id} from level ${node.hierarchyLevel} to ${targetLevel}`);
1378
+ // Remove from current parent
1379
+ if (node.parentId) {
1380
+ const oldParent = this.nodes.get(node.parentId);
1381
+ if (oldParent) {
1382
+ oldParent.childIds = oldParent.childIds.filter((id)=>id !== node.id);
1383
+ }
1384
+ } else {
1385
+ this.rootNodeIds.delete(node.id);
1386
+ }
1387
+ // Update hierarchy position
1388
+ node.hierarchyLevel = targetLevel;
1389
+ node.parentId = newParent.id;
1390
+ node.hierarchyPath = [
1391
+ ...newParent.hierarchyPath,
1392
+ newParent.id
1393
+ ];
1394
+ // Add to new parent
1395
+ newParent.childIds.push(node.id);
1396
+ // Reallocate resources
1397
+ await this.deallocateResources(node);
1398
+ await this.allocateResources(node);
1399
+ // Update dependencies
1400
+ await this.updatePromotionDependencies(node);
1401
+ // Update metrics
1402
+ await this.updateSubtreeMetrics(node.id);
1403
+ await this.updateSubtreeMetrics(newParent.id);
1404
+ this.metrics.demotions += 1;
1405
+ this.emit('agent:demoted', {
1406
+ agentId: node.id,
1407
+ fromLevel: targetLevel - 1,
1408
+ toLevel: targetLevel,
1409
+ newParentId: newParent.id
1410
+ });
1411
+ }
1412
+ // ============================================================================
1413
+ // Utility Methods
1414
+ // ============================================================================
1415
+ shouldConsiderForLeadership(node) {
1416
+ return node.leadershipScore > 0.7 && node.capabilities.includes('coordination') && node.hierarchyLevel <= 2;
1417
+ }
1418
+ async evaluateLeadershipCandidate(node) {
1419
+ const level = node.hierarchyLevel;
1420
+ const currentLeader = this.leaderNodes.get(level);
1421
+ if (!currentLeader || node.leadershipScore > (this.nodes.get(currentLeader)?.leadershipScore || 0)) {
1422
+ this.leaderNodes.set(level, node.id);
1423
+ node.topologyRole = 'coordinator';
1424
+ this.logger.info(`Agent ${node.id} elected as leader for level ${level}`);
1425
+ this.emit('leadership:elected', {
1426
+ agentId: node.id,
1427
+ level,
1428
+ previousLeader: currentLeader
1429
+ });
1430
+ }
1431
+ }
1432
+ async registerHierarchyDependencies(node) {
1433
+ // Register coordination dependency
1434
+ await registerAgentDependency(this.id, node.id, DependencyType.COORDINATION, {
1435
+ timeout: this.config.timeouts.coordination,
1436
+ metadata: {
1437
+ coordinatorType: 'enhanced-hierarchical',
1438
+ relationship: 'hierarchical-participation',
1439
+ level: node.hierarchyLevel,
1440
+ capabilities: node.capabilities
1441
+ }
1442
+ });
1443
+ // Register parent-child dependencies if applicable
1444
+ if (node.parentId) {
1445
+ await registerAgentDependency(node.parentId, node.id, DependencyType.COMPLETION, {
1446
+ timeout: this.config.timeouts.completion,
1447
+ metadata: {
1448
+ coordinatorType: 'enhanced-hierarchical',
1449
+ relationship: 'parent-child',
1450
+ parentLevel: node.hierarchyLevel - 1,
1451
+ childLevel: node.hierarchyLevel
1452
+ }
1453
+ });
1454
+ }
1455
+ }
1456
+ async registerHierarchicalTaskDependencies(task, delegationPath) {
1457
+ // Register completion dependencies for each agent in delegation path
1458
+ for (const step of delegationPath.path){
1459
+ await registerAgentDependency(this.id, step.agentId, DependencyType.COMPLETION, {
1460
+ timeout: this.config.timeouts.completion,
1461
+ metadata: {
1462
+ taskId: task.id,
1463
+ coordinatorType: 'enhanced-hierarchical',
1464
+ relationship: 'hierarchical-task-completion',
1465
+ delegationLevel: step.level,
1466
+ delegationDepth: delegationPath.totalDepth
1467
+ }
1468
+ });
1469
+ }
1470
+ }
1471
+ async updatePromotionDependencies(node) {
1472
+ // Remove old dependencies
1473
+ const depStatus = getAgentDependencyStatus(node.id);
1474
+ for (const depId of depStatus.dependencies){
1475
+ const dep = this.dependencyTracker.getDependencyDetails(depId);
1476
+ if (dep?.metadata?.relationship === 'parent-child') {
1477
+ await removeAgentDependency(depId);
1478
+ }
1479
+ }
1480
+ // Add new dependencies based on updated hierarchy position
1481
+ await this.registerHierarchyDependencies(node);
1482
+ }
1483
+ async sendMessage(message) {
1484
+ // Simulate message sending in hierarchical topology
1485
+ this.logger.debug(`Sending message ${message.id} from ${message.sourceId} to ${message.targetId}`);
1486
+ // In a real implementation, this would route through the hierarchy
1487
+ // For now, just emit an event
1488
+ this.emit('message:sent', message);
1489
+ }
1490
+ async shutdownHierarchy() {
1491
+ this.logger.info('Gracefully shutting down hierarchy...');
1492
+ // Notify all nodes of shutdown
1493
+ const shutdownMessage = {
1494
+ id: generateId('shutdown'),
1495
+ type: 'coordination',
1496
+ sourceId: this.id,
1497
+ payload: {
1498
+ type: 'coordinator_shutdown'
1499
+ },
1500
+ timestamp: new Date(),
1501
+ priority: 10,
1502
+ requiresAck: false,
1503
+ ttl: 5000,
1504
+ retryCount: 0,
1505
+ maxRetries: 0
1506
+ };
1507
+ for (const nodeId of this.nodes.keys()){
1508
+ await this.sendMessage({
1509
+ ...shutdownMessage,
1510
+ targetId: nodeId
1511
+ });
1512
+ }
1513
+ }
1514
+ async checkHierarchyCompletionDependencies() {
1515
+ const blockerInfo = await this.dependencyTracker.canAgentComplete(this.id);
1516
+ return blockerInfo.canComplete;
1517
+ }
1518
+ async checkCoordinatorCompletion() {
1519
+ const pendingTasks = Array.from(this.tasks.values()).filter((t)=>t.status === 'pending' || t.status === 'active');
1520
+ if (pendingTasks.length === 0) {
1521
+ const canComplete = await this.checkHierarchyCompletionDependencies();
1522
+ if (canComplete && !this.isRunning) {
1523
+ await this.finalizeCompletion();
1524
+ }
1525
+ }
1526
+ }
1527
+ async finalizeCompletion() {
1528
+ this.logger.info('Enhanced hierarchical coordinator ready for completion');
1529
+ await this.cleanupDependencies();
1530
+ await lifecycleManager.transitionState(this.id, 'stopped', 'Enhanced hierarchical coordination completed');
1531
+ this.emit('coordinator:completed', {
1532
+ coordinatorId: this.id
1533
+ });
1534
+ }
1535
+ async cleanupDependencies() {
1536
+ const depStatus = getAgentDependencyStatus(this.id);
1537
+ for (const depId of depStatus.dependencies){
1538
+ await removeAgentDependency(depId);
1539
+ }
1540
+ }
1541
+ async resolveHierarchicalTaskDependencies(taskId) {
1542
+ const depStatus = getAgentDependencyStatus(this.id);
1543
+ for (const depId of depStatus.dependencies){
1544
+ const dep = this.dependencyTracker.getDependencyDetails(depId);
1545
+ if (dep?.metadata?.taskId === taskId) {
1546
+ await this.dependencyTracker.resolveDependency(depId, this.tasks.get(taskId)?.result);
1547
+ }
1548
+ }
1549
+ }
1550
+ async handleRerunRequest() {
1551
+ this.logger.info('Enhanced hierarchical coordinator rerun requested');
1552
+ await lifecycleManager.transitionState(this.id, 'running', 'Enhanced hierarchical coordinator rerun');
1553
+ this.isRunning = true;
1554
+ this.startBackgroundTasks();
1555
+ this.emit('coordinator:rerun', {
1556
+ coordinatorId: this.id
1557
+ });
1558
+ }
1559
+ setupEventHandlers() {
1560
+ this.on('task:completed', this.handleTaskCompletionEvent.bind(this));
1561
+ this.on('task:failed', this.handleTaskFailureEvent.bind(this));
1562
+ this.on('agent:promoted', this.handleAgentPromotionEvent.bind(this));
1563
+ this.on('agent:demoted', this.handleAgentDemotionEvent.bind(this));
1564
+ }
1565
+ async handleTaskCompletionEvent(event) {
1566
+ this.logger.debug(`Enhanced hierarchical task completion event: ${event.taskId}`);
1567
+ }
1568
+ async handleTaskFailureEvent(event) {
1569
+ this.logger.debug(`Enhanced hierarchical task failure event: ${event.taskId}`);
1570
+ }
1571
+ async handleAgentPromotionEvent(event) {
1572
+ this.logger.debug(`Agent promotion event: ${event.agentId} promoted from level ${event.fromLevel} to ${event.toLevel}`);
1573
+ }
1574
+ async handleAgentDemotionEvent(event) {
1575
+ this.logger.debug(`Agent demotion event: ${event.agentId} demoted from level ${event.fromLevel} to ${event.toLevel}`);
1576
+ }
1577
+ // ============================================================================
1578
+ // Public Status and Metrics Methods
1579
+ // ============================================================================
1580
+ getMetrics() {
1581
+ const totalConnections = Array.from(this.nodes.values()).reduce((sum, node)=>sum + node.communicationChannels.size, 0);
1582
+ const totalLatency = Array.from(this.nodes.values()).reduce((sum, node)=>{
1583
+ const channelLatencies = Array.from(node.communicationChannels.values()).map((channel)=>channel.metrics.averageLatency);
1584
+ return sum + channelLatencies.reduce((a, b)=>a + b, 0) / Math.max(1, channelLatencies.length);
1585
+ }, 0);
1586
+ const averageLatency = this.nodes.size > 0 ? totalLatency / this.nodes.size : 0;
1587
+ const totalErrors = Array.from(this.nodes.values()).reduce((sum, node)=>sum + node.performanceMetrics.errorCount, 0);
1588
+ const totalTasks = Array.from(this.nodes.values()).reduce((sum, node)=>sum + node.performanceMetrics.tasksCompleted, 0);
1589
+ const errorRate = totalTasks > 0 ? totalErrors / totalTasks : 0;
1590
+ const throughput = Array.from(this.tasks.values()).filter((t)=>t.status === 'completed').length;
1591
+ return {
1592
+ id: this.id,
1593
+ type: 'hierarchical',
1594
+ agentCount: this.nodes.size,
1595
+ connectionCount: totalConnections,
1596
+ averageLatency,
1597
+ throughput,
1598
+ errorRate,
1599
+ cpuUsage: this.metrics.resourceUtilization,
1600
+ memoryUsage: 0.4,
1601
+ lastUpdate: new Date(),
1602
+ coordinationEfficiency: this.metrics.hierarchyEfficiency,
1603
+ faultToleranceScore: this.calculateFaultToleranceScore()
1604
+ };
1605
+ }
1606
+ getPerformanceStats() {
1607
+ return {
1608
+ delegationLatency: this.metrics.delegationLatency,
1609
+ hierarchyEfficiency: this.metrics.hierarchyEfficiency,
1610
+ promotions: this.metrics.promotions,
1611
+ demotions: this.metrics.demotions,
1612
+ recoveryActions: this.metrics.recoveryActions,
1613
+ resourceUtilization: this.metrics.resourceUtilization,
1614
+ hierarchyDepth: this.config.hierarchy.maxDepth,
1615
+ activeLeaders: this.leaderNodes.size,
1616
+ totalResourcePools: this.resourcePools.size,
1617
+ promotionCandidates: this.promotionCandidates.length
1618
+ };
1619
+ }
1620
+ canAdaptTo(newType) {
1621
+ // Enhanced hierarchical can adapt to mesh or hybrid
1622
+ return [
1623
+ 'mesh',
1624
+ 'hybrid'
1625
+ ].includes(newType);
1626
+ }
1627
+ getOptimizationRecommendations() {
1628
+ // Placeholder - would analyze hierarchy performance and suggest improvements
1629
+ return [];
1630
+ }
1631
+ calculateFaultToleranceScore() {
1632
+ const totalRecoveryAttempts = this.metrics.recoveryActions;
1633
+ const successfulRecoveries = totalRecoveryAttempts * 0.8; // Assume 80% success rate
1634
+ const recoveryRate = totalRecoveryAttempts > 0 ? successfulRecoveries / totalRecoveryAttempts : 1;
1635
+ const hierarchyStability = this.metrics.hierarchyEfficiency;
1636
+ return recoveryRate * 0.6 + hierarchyStability * 0.4;
1637
+ }
1638
+ // Public methods for hierarchy inspection
1639
+ getHierarchyStructure() {
1640
+ const levelMap = new Map();
1641
+ // Group nodes by level
1642
+ for (const node of this.nodes.values()){
1643
+ if (!levelMap.has(node.hierarchyLevel)) {
1644
+ levelMap.set(node.hierarchyLevel, []);
1645
+ }
1646
+ levelMap.get(node.hierarchyLevel).push(node);
1647
+ }
1648
+ const levels = Array.from(levelMap.entries()).sort(([a], [b])=>a - b).map(([level, nodes])=>({
1649
+ level,
1650
+ nodes: nodes.map((node)=>({
1651
+ id: node.id,
1652
+ name: node.name,
1653
+ parentId: node.parentId,
1654
+ childIds: [
1655
+ ...node.childIds
1656
+ ],
1657
+ isLeader: this.leaderNodes.get(level) === node.id,
1658
+ workload: node.workload,
1659
+ status: node.status
1660
+ }))
1661
+ }));
1662
+ return {
1663
+ levels,
1664
+ depth: Math.max(...Array.from(levelMap.keys())) + 1,
1665
+ totalNodes: this.nodes.size
1666
+ };
1667
+ }
1668
+ getResourceAllocation() {
1669
+ const allocation = {};
1670
+ for (const [level, pool] of this.resourcePools){
1671
+ allocation[level] = {
1672
+ level,
1673
+ totalCapacity: {
1674
+ ...pool.totalCapacity
1675
+ },
1676
+ allocated: {
1677
+ ...pool.allocatedResources
1678
+ },
1679
+ utilization: pool.utilizationRate
1680
+ };
1681
+ }
1682
+ return allocation;
1683
+ }
1684
+ getDelegationPaths() {
1685
+ return Array.from(this.delegationPaths.values()).map((path)=>({
1686
+ taskId: path.taskId,
1687
+ totalDepth: path.totalDepth,
1688
+ expectedCompletion: path.expectedCompletionTime,
1689
+ path: path.path.map((step)=>({
1690
+ agentId: step.agentId,
1691
+ level: step.level,
1692
+ status: step.status,
1693
+ delegationTime: step.delegationTime
1694
+ }))
1695
+ }));
1696
+ }
1697
+ }
1698
+ // ============================================================================
1699
+ // Factory Functions
1700
+ // ============================================================================
1701
+ export function createEnhancedHierarchicalCoordinator(config) {
1702
+ return new EnhancedHierarchicalCoordinator(config);
1703
+ }
1704
+ export function createEnhancedHierarchicalCoordinatorWithRecovery(namespace, maxDepth = 6, config) {
1705
+ const enhancedConfig = {
1706
+ ...config,
1707
+ memoryNamespace: namespace,
1708
+ hierarchy: {
1709
+ maxDepth,
1710
+ maxChildrenPerNode: 12,
1711
+ balancingStrategy: 'hybrid',
1712
+ promotionThreshold: 0.8,
1713
+ demotionThreshold: 0.3,
1714
+ rebalanceInterval: 60000
1715
+ },
1716
+ recovery: {
1717
+ enableAutomaticRecovery: true,
1718
+ failureDetectionTimeout: 20000,
1719
+ recoveryAttempts: 3,
1720
+ backupLeaderSelection: true
1721
+ },
1722
+ delegation: {
1723
+ strategy: 'adaptive',
1724
+ enableSubdelegation: true,
1725
+ maxDelegationDepth: Math.max(4, maxDepth - 2),
1726
+ parallelDelegation: true
1727
+ }
1728
+ };
1729
+ return new EnhancedHierarchicalCoordinator(enhancedConfig);
1730
+ }
1731
+
1732
+ //# sourceMappingURL=enhanced-hierarchical-coordinator.js.map