claude-flow-novice 1.6.1 → 1.6.3

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 (273) hide show
  1. package/.claude/agents/cfn-loop/product-owner.md +54 -4
  2. package/.claude/commands/cfn-claude-sync.md +303 -0
  3. package/.claude/commands/cfn-loop-epic.md +290 -0
  4. package/.claude/commands/cfn-loop-single.md +168 -0
  5. package/.claude/commands/cfn-loop-sprints.md +384 -0
  6. package/.claude/commands/cfn-loop.md +180 -0
  7. package/.claude/commands/metrics-summary.md +58 -0
  8. package/.claude/commands/parse-epic.md +357 -0
  9. package/.claude/settings.json +5 -4
  10. package/.claude/settings.local.json +9 -2
  11. package/.claude-flow-novice/.claude/agents/cfn-loop/product-owner.md +792 -0
  12. package/.claude-flow-novice/dist/mcp/server.js +21 -2
  13. package/.claude-flow-novice/dist/src/api/auth-service.js +84 -38
  14. package/.claude-flow-novice/dist/src/api/auth-service.js.map +1 -1
  15. package/.claude-flow-novice/dist/src/api/claude-client.js +138 -3
  16. package/.claude-flow-novice/dist/src/api/claude-client.js.map +1 -1
  17. package/.claude-flow-novice/dist/src/cfn-loop/phase-orchestrator-example.js +1 -1
  18. package/.claude-flow-novice/dist/src/cfn-loop/scope-control.js +247 -0
  19. package/.claude-flow-novice/dist/src/cfn-loop/scope-control.js.map +1 -0
  20. package/.claude-flow-novice/dist/src/cli/commands/swarm.js +32 -15
  21. package/.claude-flow-novice/dist/src/cli/commands/swarm.js.map +1 -1
  22. package/.claude-flow-novice/dist/src/cli/commands/transparency.js +455 -0
  23. package/.claude-flow-novice/dist/src/cli/commands/transparency.js.map +1 -0
  24. package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/CLAUDE.md +129 -13
  25. package/.claude-flow-novice/dist/src/components/visualizations/index.js +9 -0
  26. package/.claude-flow-novice/dist/src/components/visualizations/index.js.map +1 -0
  27. package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js +462 -0
  28. package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js.map +1 -0
  29. package/.claude-flow-novice/dist/src/coordination/config-translator.js +248 -0
  30. package/.claude-flow-novice/dist/src/coordination/config-translator.js.map +1 -0
  31. package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js +287 -0
  32. package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js.map +1 -0
  33. package/.claude-flow-novice/dist/src/coordination/distributed-consensus.js +68 -9
  34. package/.claude-flow-novice/dist/src/coordination/distributed-consensus.js.map +1 -1
  35. package/.claude-flow-novice/dist/src/coordination/feature-flags.js +166 -0
  36. package/.claude-flow-novice/dist/src/coordination/feature-flags.js.map +1 -0
  37. package/.claude-flow-novice/dist/src/coordination/queen-agent.js +18 -4
  38. package/.claude-flow-novice/dist/src/coordination/queen-agent.js.map +1 -1
  39. package/.claude-flow-novice/dist/src/coordination/role-assignment.js +6 -110
  40. package/.claude-flow-novice/dist/src/coordination/role-assignment.js.map +1 -1
  41. package/.claude-flow-novice/dist/src/coordination/v2/cache/artifact-cache-optimizer.js +632 -0
  42. package/.claude-flow-novice/dist/src/coordination/v2/cache/artifact-cache-optimizer.js.map +1 -0
  43. package/.claude-flow-novice/dist/src/coordination/v2/cache/index.js +11 -0
  44. package/.claude-flow-novice/dist/src/coordination/v2/cache/index.js.map +1 -0
  45. package/.claude-flow-novice/dist/src/coordination/v2/checkpoints/checkpoint-compressor.js +318 -0
  46. package/.claude-flow-novice/dist/src/coordination/v2/checkpoints/checkpoint-compressor.js.map +1 -0
  47. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.example.js +364 -0
  48. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.example.js.map +1 -0
  49. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.js +492 -0
  50. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.js.map +1 -0
  51. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/hierarchical-coordinator.js +786 -0
  52. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/hierarchical-coordinator.js.map +1 -0
  53. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/index.js +16 -0
  54. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/index.js.map +1 -0
  55. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/parent-child-manager.js +342 -0
  56. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/parent-child-manager.js.map +1 -0
  57. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/swarm-coordinator-v2.js +601 -0
  58. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/swarm-coordinator-v2.js.map +1 -0
  59. package/.claude-flow-novice/dist/src/coordination/v2/core/help-request-metrics.js +211 -0
  60. package/.claude-flow-novice/dist/src/coordination/v2/core/help-request-metrics.js.map +1 -0
  61. package/.claude-flow-novice/dist/src/coordination/v2/core/index.js +1 -0
  62. package/.claude-flow-novice/dist/src/coordination/v2/core/index.js.map +1 -1
  63. package/.claude-flow-novice/dist/src/coordination/v2/core/message-broker.js +365 -6
  64. package/.claude-flow-novice/dist/src/coordination/v2/core/message-broker.js.map +1 -1
  65. package/.claude-flow-novice/dist/src/coordination/v2/core/resource-manager-safe.js +478 -0
  66. package/.claude-flow-novice/dist/src/coordination/v2/core/resource-manager-safe.js.map +1 -0
  67. package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine-config.js +5 -2
  68. package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine-config.js.map +1 -1
  69. package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine.js +189 -0
  70. package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine.js.map +1 -1
  71. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/deadlock-detector.js +424 -0
  72. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/deadlock-detector.js.map +1 -0
  73. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/index.js +9 -0
  74. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/index.js.map +1 -0
  75. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/resource-manager.js +669 -0
  76. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/resource-manager.js.map +1 -0
  77. package/.claude-flow-novice/dist/src/coordination/v2/dependency/artifact-storage.js +451 -0
  78. package/.claude-flow-novice/dist/src/coordination/v2/dependency/artifact-storage.js.map +1 -0
  79. package/.claude-flow-novice/dist/src/coordination/v2/dependency/cycle-detector.js +271 -0
  80. package/.claude-flow-novice/dist/src/coordination/v2/dependency/cycle-detector.js.map +1 -0
  81. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-graph.js +335 -0
  82. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-graph.js.map +1 -0
  83. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-manager.js +439 -0
  84. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-manager.js.map +1 -0
  85. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-request.js +92 -0
  86. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-request.js.map +1 -0
  87. package/.claude-flow-novice/dist/src/coordination/v2/dependency/index.js +21 -0
  88. package/.claude-flow-novice/dist/src/coordination/v2/dependency/index.js.map +1 -0
  89. package/.claude-flow-novice/dist/src/coordination/v2/dependency/topological-sort.js +223 -0
  90. package/.claude-flow-novice/dist/src/coordination/v2/dependency/topological-sort.js.map +1 -0
  91. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-coordinator.js +436 -0
  92. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-coordinator.js.map +1 -0
  93. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-matcher.js +278 -0
  94. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-matcher.js.map +1 -0
  95. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request-handler.js +317 -0
  96. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request-handler.js.map +1 -0
  97. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request.js +273 -0
  98. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request.js.map +1 -0
  99. package/.claude-flow-novice/dist/src/coordination/v2/help-system/index.js +15 -0
  100. package/.claude-flow-novice/dist/src/coordination/v2/help-system/index.js.map +1 -0
  101. package/.claude-flow-novice/dist/src/coordination/v2/help-system/waiting-agent-pool.js +512 -0
  102. package/.claude-flow-novice/dist/src/coordination/v2/help-system/waiting-agent-pool.js.map +1 -0
  103. package/.claude-flow-novice/dist/src/coordination/v2/index.js +6 -0
  104. package/.claude-flow-novice/dist/src/coordination/v2/index.js.map +1 -1
  105. package/.claude-flow-novice/dist/src/coordination/v2/integration/help-deadlock-integration.js +557 -0
  106. package/.claude-flow-novice/dist/src/coordination/v2/integration/help-deadlock-integration.js.map +1 -0
  107. package/.claude-flow-novice/dist/src/coordination/v2/integration/index.js +14 -0
  108. package/.claude-flow-novice/dist/src/coordination/v2/integration/index.js.map +1 -0
  109. package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.example.js +212 -0
  110. package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.example.js.map +1 -0
  111. package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.js +552 -0
  112. package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.js.map +1 -0
  113. package/.claude-flow-novice/dist/src/coordination/v2/memory/dependency-storage.js +367 -0
  114. package/.claude-flow-novice/dist/src/coordination/v2/memory/dependency-storage.js.map +1 -0
  115. package/.claude-flow-novice/dist/src/coordination/v2/memory/index.js +1 -0
  116. package/.claude-flow-novice/dist/src/coordination/v2/memory/index.js.map +1 -1
  117. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channel.js +371 -0
  118. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channel.js.map +1 -0
  119. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/dependency-channel.js +355 -0
  120. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/dependency-channel.js.map +1 -0
  121. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/help-channel.js +424 -0
  122. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/help-channel.js.map +1 -0
  123. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/index.js +16 -0
  124. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/index.js.map +1 -0
  125. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/state-channel.js +295 -0
  126. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/state-channel.js.map +1 -0
  127. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/task-channel.js +411 -0
  128. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/task-channel.js.map +1 -0
  129. package/.claude-flow-novice/dist/src/coordination/v2/messaging/index.js +14 -0
  130. package/.claude-flow-novice/dist/src/coordination/v2/messaging/index.js.map +1 -0
  131. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-bus.js +387 -0
  132. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-bus.js.map +1 -0
  133. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-persistence.js +589 -0
  134. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-persistence.js.map +1 -0
  135. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-router.js +444 -0
  136. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-router.js.map +1 -0
  137. package/.claude-flow-novice/dist/src/coordination/v2/sdk/checkpoint-manager.js +29 -8
  138. package/.claude-flow-novice/dist/src/coordination/v2/sdk/checkpoint-manager.js.map +1 -1
  139. package/.claude-flow-novice/dist/src/coordination/v2/sdk/help-coordinator.js +470 -0
  140. package/.claude-flow-novice/dist/src/coordination/v2/sdk/help-coordinator.js.map +1 -0
  141. package/.claude-flow-novice/dist/src/coordination/v2/sdk/hierarchical-background-integration.js +450 -0
  142. package/.claude-flow-novice/dist/src/coordination/v2/sdk/hierarchical-background-integration.js.map +1 -0
  143. package/.claude-flow-novice/dist/src/coordination/v2/sdk/index.js +5 -0
  144. package/.claude-flow-novice/dist/src/coordination/v2/sdk/index.js.map +1 -1
  145. package/.claude-flow-novice/dist/src/coordination/v2/sdk/multi-level-control.js +545 -0
  146. package/.claude-flow-novice/dist/src/coordination/v2/sdk/multi-level-control.js.map +1 -0
  147. package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-controller.js +44 -0
  148. package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-controller.js.map +1 -1
  149. package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-message-integration.js +415 -0
  150. package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-message-integration.js.map +1 -0
  151. package/.claude-flow-novice/dist/src/coordination/v2/sdk/session-pool-optimizer.js +615 -0
  152. package/.claude-flow-novice/dist/src/coordination/v2/sdk/session-pool-optimizer.js.map +1 -0
  153. package/.claude-flow-novice/dist/src/coordination/v2/security/payload-validator.js +259 -0
  154. package/.claude-flow-novice/dist/src/coordination/v2/security/payload-validator.js.map +1 -0
  155. package/.claude-flow-novice/dist/src/coordination/v2/transparency/index.js +17 -0
  156. package/.claude-flow-novice/dist/src/coordination/v2/transparency/index.js.map +1 -0
  157. package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-integration.js +357 -0
  158. package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-integration.js.map +1 -0
  159. package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-system.js +679 -0
  160. package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-system.js.map +1 -0
  161. package/.claude-flow-novice/dist/src/core/agent-manager.js +30 -0
  162. package/.claude-flow-novice/dist/src/core/agent-manager.js.map +1 -1
  163. package/.claude-flow-novice/dist/src/mcp/server.js +21 -2
  164. package/.claude-flow-novice/dist/src/mcp/server.js.map +1 -1
  165. package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js +719 -0
  166. package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js.map +1 -0
  167. package/.claude-flow-novice/dist/src/monitoring/apm/datadog-collector.js +363 -0
  168. package/.claude-flow-novice/dist/src/monitoring/apm/datadog-collector.js.map +1 -0
  169. package/.claude-flow-novice/dist/src/monitoring/apm/index.js +97 -0
  170. package/.claude-flow-novice/dist/src/monitoring/apm/index.js.map +1 -0
  171. package/.claude-flow-novice/dist/src/monitoring/apm/newrelic-collector.js +384 -0
  172. package/.claude-flow-novice/dist/src/monitoring/apm/newrelic-collector.js.map +1 -0
  173. package/.claude-flow-novice/dist/src/monitoring/apm/performance-optimizer.js +612 -0
  174. package/.claude-flow-novice/dist/src/monitoring/apm/performance-optimizer.js.map +1 -0
  175. package/.claude-flow-novice/dist/src/monitoring/metrics-collector.js +282 -0
  176. package/.claude-flow-novice/dist/src/monitoring/metrics-collector.js.map +1 -0
  177. package/.claude-flow-novice/dist/src/observability/metrics-counter.js +268 -0
  178. package/.claude-flow-novice/dist/src/observability/metrics-counter.js.map +1 -0
  179. package/.claude-flow-novice/dist/src/observability/metrics-storage.js +265 -0
  180. package/.claude-flow-novice/dist/src/observability/metrics-storage.js.map +1 -0
  181. package/.claude-flow-novice/dist/src/observability/telemetry.js +26 -0
  182. package/.claude-flow-novice/dist/src/observability/telemetry.js.map +1 -1
  183. package/.claude-flow-novice/dist/src/providers/tiered-router.js +64 -10
  184. package/.claude-flow-novice/dist/src/providers/tiered-router.js.map +1 -1
  185. package/.claude-flow-novice/dist/src/providers/zai-provider.js +196 -97
  186. package/.claude-flow-novice/dist/src/providers/zai-provider.js.map +1 -1
  187. package/.claude-flow-novice/dist/src/slash-commands/cfn-claude-sync.js +533 -0
  188. package/.claude-flow-novice/dist/src/slash-commands/index.js +5 -0
  189. package/.claude-flow-novice/dist/src/slash-commands/metrics-summary-class.js +74 -0
  190. package/.claude-flow-novice/dist/src/slash-commands/metrics-summary.js +335 -0
  191. package/.claude-flow-novice/dist/src/slash-commands/register-all-commands.js +12 -0
  192. package/.claude-flow-novice/dist/src/verification/checkpoint-compression-demo.js +96 -0
  193. package/.claude-flow-novice/dist/src/verification/checkpoint-compression-demo.js.map +1 -0
  194. package/.claude-flow-novice/dist/src/verification/checkpoint-compression.js +406 -0
  195. package/.claude-flow-novice/dist/src/verification/checkpoint-compression.js.map +1 -0
  196. package/.claude-flow-novice/dist/src/verification/checkpoint-manager.js +35 -5
  197. package/.claude-flow-novice/dist/src/verification/checkpoint-manager.js.map +1 -1
  198. package/.claude-flow-novice/dist/src/web/api/apm-routes.js +355 -0
  199. package/.claude-flow-novice/dist/src/web/api/apm-routes.js.map +1 -0
  200. package/.claude-flow-novice/dist/src/web/api/config/api-config.js +186 -0
  201. package/.claude-flow-novice/dist/src/web/api/config/api-config.js.map +1 -0
  202. package/.claude-flow-novice/dist/src/web/api/middleware/auth.js +205 -0
  203. package/.claude-flow-novice/dist/src/web/api/middleware/auth.js.map +1 -0
  204. package/.claude-flow-novice/dist/src/web/api/middleware/cache.js +262 -0
  205. package/.claude-flow-novice/dist/src/web/api/middleware/cache.js.map +1 -0
  206. package/.claude-flow-novice/dist/src/web/api/middleware/error-handler.js +250 -0
  207. package/.claude-flow-novice/dist/src/web/api/middleware/error-handler.js.map +1 -0
  208. package/.claude-flow-novice/dist/src/web/api/middleware/request-logger.js +217 -0
  209. package/.claude-flow-novice/dist/src/web/api/middleware/request-logger.js.map +1 -0
  210. package/.claude-flow-novice/dist/src/web/api/middleware/validation.js +325 -0
  211. package/.claude-flow-novice/dist/src/web/api/middleware/validation.js.map +1 -0
  212. package/.claude-flow-novice/dist/src/web/api/routes/events.js +465 -0
  213. package/.claude-flow-novice/dist/src/web/api/routes/events.js.map +1 -0
  214. package/.claude-flow-novice/dist/src/web/api/routes/hierarchy.js +302 -0
  215. package/.claude-flow-novice/dist/src/web/api/routes/hierarchy.js.map +1 -0
  216. package/.claude-flow-novice/dist/src/web/api/routes/index.js +14 -0
  217. package/.claude-flow-novice/dist/src/web/api/routes/index.js.map +1 -0
  218. package/.claude-flow-novice/dist/src/web/api/routes/metrics.js +561 -0
  219. package/.claude-flow-novice/dist/src/web/api/routes/metrics.js.map +1 -0
  220. package/.claude-flow-novice/dist/src/web/api/routes/status.js +450 -0
  221. package/.claude-flow-novice/dist/src/web/api/routes/status.js.map +1 -0
  222. package/.claude-flow-novice/dist/src/web/api/server.js +451 -0
  223. package/.claude-flow-novice/dist/src/web/api/server.js.map +1 -0
  224. package/.claude-flow-novice/dist/src/web/dashboard/hooks/useWebSocket.js +385 -0
  225. package/.claude-flow-novice/dist/src/web/dashboard/hooks/useWebSocket.js.map +1 -0
  226. package/.claude-flow-novice/dist/src/web/dashboard/index.js +87 -0
  227. package/.claude-flow-novice/dist/src/web/dashboard/index.js.map +1 -0
  228. package/.claude-flow-novice/dist/src/web/dashboard/types.js +6 -0
  229. package/.claude-flow-novice/dist/src/web/dashboard/types.js.map +1 -0
  230. package/.claude-flow-novice/dist/src/web/frontend/src/utils/security.js +425 -0
  231. package/.claude-flow-novice/dist/src/web/frontend/src/utils/security.js.map +1 -0
  232. package/.claude-flow-novice/dist/src/web/security/security-middleware.js +379 -0
  233. package/.claude-flow-novice/dist/src/web/security/security-middleware.js.map +1 -0
  234. package/.claude-flow-novice/dist/src/web/websocket/apm-websocket-handler.js +441 -0
  235. package/.claude-flow-novice/dist/src/web/websocket/apm-websocket-handler.js.map +1 -0
  236. package/.claude-flow-novice/dist/src/web/websocket/websocket-manager.js +255 -1
  237. package/.claude-flow-novice/dist/src/web/websocket/websocket-manager.js.map +1 -1
  238. package/.claude-flow-novice/metrics.db +0 -0
  239. package/.claude-flow-novice/metrics.db-shm +0 -0
  240. package/.claude-flow-novice/metrics.db-wal +0 -0
  241. package/AGENT_PERFORMANCE_GUIDELINES.md +88 -0
  242. package/CLAUDE.md +60 -3
  243. package/MEMORY_LEAK_ROOT_CAUSE.md +149 -0
  244. package/README.md +27 -0
  245. package/config/hooks/post-edit-pipeline.js +36 -2
  246. package/examples/metrics-counter-demo.ts +106 -0
  247. package/examples/persistent-metrics-demo.ts +83 -0
  248. package/examples/phase-5-multi-level-control.ts +282 -0
  249. package/examples/session-pool-optimizer-example.ts +311 -0
  250. package/package.json +18 -4
  251. package/scripts/check-routing-stats.cjs +122 -0
  252. package/scripts/monitor-loop.sh +65 -0
  253. package/scripts/monitor-memory.sh +47 -0
  254. package/scripts/monitor.py +43 -0
  255. package/scripts/pre-publish-validation.cjs +212 -0
  256. package/scripts/test-provider-routing.cjs +228 -0
  257. package/scripts/test-routing-telemetry.cjs +147 -0
  258. package/scripts/test-zai-10k.cjs +81 -0
  259. package/scripts/test-zai-api.cjs +191 -0
  260. package/scripts/test-zai-diagnostic.cjs +151 -0
  261. package/scripts/test-zai-final.cjs +128 -0
  262. package/scripts/test-zai-with-env.cjs +85 -0
  263. package/scripts/validate-coordination-cli.js +69 -0
  264. package/scripts/validate-coordination-toggle-integration.cjs +501 -0
  265. package/src/cli/simple-commands/init/templates/CLAUDE.md +29 -0
  266. package/src/observability/metrics-counter.ts +347 -0
  267. package/src/observability/metrics-storage.ts +356 -0
  268. package/src/observability/telemetry.ts +658 -0
  269. package/src/slash-commands/cfn-claude-sync.js +533 -0
  270. package/src/slash-commands/index.js +5 -0
  271. package/src/slash-commands/metrics-summary-class.js +74 -0
  272. package/src/slash-commands/metrics-summary.js +335 -0
  273. package/src/slash-commands/register-all-commands.js +12 -0
@@ -0,0 +1,271 @@
1
+ /**
2
+ * Agent Coordination V2 - Cycle Detector
3
+ *
4
+ * DFS-based cycle detection algorithm for dependency graphs.
5
+ * Uses three-color marking (white/gray/black) for O(V+E) detection.
6
+ *
7
+ * Algorithm:
8
+ * - White nodes: unvisited
9
+ * - Gray nodes: currently being visited (on stack)
10
+ * - Black nodes: fully processed
11
+ * - Cycle detected when gray node encountered during DFS
12
+ *
13
+ * @module coordination/v2/dependency/cycle-detector
14
+ */ /**
15
+ * Node color for cycle detection
16
+ */ var NodeColor = /*#__PURE__*/ function(NodeColor) {
17
+ /** Unvisited node */ NodeColor["WHITE"] = "white";
18
+ /** Currently being visited (on DFS stack) */ NodeColor["GRAY"] = "gray";
19
+ /** Fully processed */ NodeColor["BLACK"] = "black";
20
+ return NodeColor;
21
+ }(NodeColor || {});
22
+ /**
23
+ * CycleDetector - DFS-based cycle detection
24
+ *
25
+ * Time complexity: O(V + E) where V = nodes, E = edges
26
+ * Space complexity: O(V) for color map and recursion stack
27
+ *
28
+ * Algorithm:
29
+ * 1. Initialize all nodes as WHITE (unvisited)
30
+ * 2. For each WHITE node, start DFS
31
+ * 3. Mark node GRAY (on stack)
32
+ * 4. Visit all dependencies
33
+ * 5. If GRAY node encountered -> cycle detected
34
+ * 6. Mark node BLACK (processed)
35
+ */ export class CycleDetector {
36
+ /** Node color map for DFS */ colorMap;
37
+ /** DFS recursion stack for cycle path reconstruction */ stack;
38
+ /** Nodes visited during current detection */ nodesVisited;
39
+ /** Cycle detection metrics */ metrics;
40
+ constructor(){
41
+ this.colorMap = new Map();
42
+ this.stack = [];
43
+ this.nodesVisited = 0;
44
+ this.metrics = {
45
+ totalDetections: 0,
46
+ cyclesFound: 0,
47
+ averageLatencyMs: 0
48
+ };
49
+ }
50
+ /**
51
+ * Detect cycles in dependency graph
52
+ * O(V + E) time complexity
53
+ *
54
+ * @param graph - Dependency graph to analyze
55
+ * @returns CycleDetectionResult with cycle details
56
+ */ detectCycle(graph) {
57
+ const startTime = performance.now();
58
+ // Reset detection state
59
+ this.colorMap.clear();
60
+ this.stack = [];
61
+ this.nodesVisited = 0;
62
+ // Initialize all nodes as WHITE
63
+ const allNodes = graph.getAllNodes();
64
+ for (const node of allNodes){
65
+ this.colorMap.set(node.agentId, "white");
66
+ }
67
+ // Run DFS from each WHITE node
68
+ for (const node of allNodes){
69
+ if (this.colorMap.get(node.agentId) === "white") {
70
+ const cycleResult = this.dfsVisit(graph, node.agentId);
71
+ if (cycleResult) {
72
+ // Cycle detected
73
+ const latencyMs = performance.now() - startTime;
74
+ this.updateMetrics(latencyMs, true);
75
+ return {
76
+ hasCycle: true,
77
+ cyclePath: cycleResult,
78
+ latencyMs,
79
+ nodesVisited: this.nodesVisited,
80
+ timestamp: new Date()
81
+ };
82
+ }
83
+ }
84
+ }
85
+ // No cycle found
86
+ const latencyMs = performance.now() - startTime;
87
+ this.updateMetrics(latencyMs, false);
88
+ return {
89
+ hasCycle: false,
90
+ latencyMs,
91
+ nodesVisited: this.nodesVisited,
92
+ timestamp: new Date()
93
+ };
94
+ }
95
+ /**
96
+ * DFS visit with three-color marking
97
+ * Detects cycle when GRAY node encountered
98
+ *
99
+ * @param graph - Dependency graph
100
+ * @param nodeId - Current node being visited
101
+ * @returns Cycle path if cycle detected, undefined otherwise
102
+ */ dfsVisit(graph, nodeId) {
103
+ // Mark node as GRAY (on stack)
104
+ this.colorMap.set(nodeId, "gray");
105
+ this.stack.push(nodeId);
106
+ this.nodesVisited++;
107
+ // Visit all dependencies (outgoing edges)
108
+ const dependencies = graph.getDependencies(nodeId);
109
+ for (const depId of dependencies){
110
+ const depColor = this.colorMap.get(depId);
111
+ if (depColor === "gray") {
112
+ // CYCLE DETECTED: Gray node encountered (on stack)
113
+ const cycleStartIndex = this.stack.indexOf(depId);
114
+ const cyclePath = this.stack.slice(cycleStartIndex);
115
+ cyclePath.push(depId); // Close the cycle
116
+ return cyclePath;
117
+ }
118
+ if (depColor === "white") {
119
+ // Unvisited node - continue DFS
120
+ const cycleResult = this.dfsVisit(graph, depId);
121
+ if (cycleResult) {
122
+ return cycleResult; // Propagate cycle up the call stack
123
+ }
124
+ }
125
+ // BLACK nodes are already processed - skip
126
+ }
127
+ // Mark node as BLACK (fully processed)
128
+ this.colorMap.set(nodeId, "black");
129
+ this.stack.pop();
130
+ return undefined; // No cycle found from this node
131
+ }
132
+ /**
133
+ * Get detailed cycle information
134
+ *
135
+ * @param cyclePath - Cycle path from detection
136
+ * @returns CycleDetails with formatted cycle information
137
+ */ getCycleDetails(cyclePath) {
138
+ if (cyclePath.length < 2) {
139
+ throw new Error('Invalid cycle path: must contain at least 2 nodes');
140
+ }
141
+ return {
142
+ agents: cyclePath,
143
+ startNode: cyclePath[0],
144
+ endNode: cyclePath[cyclePath.length - 1],
145
+ length: cyclePath.length - 1,
146
+ detectedAt: new Date()
147
+ };
148
+ }
149
+ /**
150
+ * Detect all cycles in graph (not just first one)
151
+ * More expensive: O(V * (V + E))
152
+ *
153
+ * @param graph - Dependency graph to analyze
154
+ * @returns Array of all detected cycles
155
+ */ detectAllCycles(graph) {
156
+ const cycles = [];
157
+ const visited = new Set();
158
+ const allNodes = graph.getAllNodes();
159
+ for (const node of allNodes){
160
+ if (!visited.has(node.agentId)) {
161
+ // Reset for each new DFS tree
162
+ this.colorMap.clear();
163
+ this.stack = [];
164
+ for (const n of allNodes){
165
+ this.colorMap.set(n.agentId, "white");
166
+ }
167
+ const cycleResult = this.dfsVisit(graph, node.agentId);
168
+ if (cycleResult) {
169
+ cycles.push(this.getCycleDetails(cycleResult));
170
+ // Mark all nodes in cycle as visited
171
+ for (const agentId of cycleResult){
172
+ visited.add(agentId);
173
+ }
174
+ }
175
+ }
176
+ }
177
+ return cycles;
178
+ }
179
+ /**
180
+ * Check if specific path would create cycle
181
+ * Used for pre-validation before adding edges
182
+ *
183
+ * @param graph - Current dependency graph
184
+ * @param from - Source agent
185
+ * @param to - Target agent
186
+ * @returns True if adding edge would create cycle
187
+ */ wouldCreateCycle(graph, from, to) {
188
+ // Adding edge from -> to creates cycle if:
189
+ // There's already a path from to -> from
190
+ // Check if 'to' can reach 'from' via existing dependencies
191
+ const reachable = this.getReachableNodes(graph, to);
192
+ return reachable.has(from);
193
+ }
194
+ /**
195
+ * Get all nodes reachable from start node
196
+ * Uses BFS for efficient traversal
197
+ *
198
+ * @param graph - Dependency graph
199
+ * @param startNode - Starting node
200
+ * @returns Set of reachable node IDs
201
+ */ getReachableNodes(graph, startNode) {
202
+ const reachable = new Set();
203
+ const queue = [
204
+ startNode
205
+ ];
206
+ const visited = new Set();
207
+ while(queue.length > 0){
208
+ const current = queue.shift();
209
+ if (visited.has(current)) {
210
+ continue;
211
+ }
212
+ visited.add(current);
213
+ reachable.add(current);
214
+ // Add all dependencies to queue
215
+ const dependencies = graph.getDependencies(current);
216
+ for (const dep of dependencies){
217
+ if (!visited.has(dep)) {
218
+ queue.push(dep);
219
+ }
220
+ }
221
+ }
222
+ return reachable;
223
+ }
224
+ /**
225
+ * Update cycle detection metrics
226
+ */ updateMetrics(latencyMs, cycleFound) {
227
+ this.metrics.totalDetections++;
228
+ if (cycleFound) {
229
+ this.metrics.cyclesFound++;
230
+ }
231
+ // Update running average
232
+ this.metrics.averageLatencyMs = (this.metrics.averageLatencyMs * (this.metrics.totalDetections - 1) + latencyMs) / this.metrics.totalDetections;
233
+ }
234
+ /**
235
+ * Get cycle detection metrics
236
+ */ getMetrics() {
237
+ return {
238
+ ...this.metrics
239
+ };
240
+ }
241
+ /**
242
+ * Reset detector state
243
+ */ reset() {
244
+ this.colorMap.clear();
245
+ this.stack = [];
246
+ this.nodesVisited = 0;
247
+ }
248
+ }
249
+ /**
250
+ * Utility function to detect cycle in graph
251
+ * Convenience wrapper around CycleDetector
252
+ *
253
+ * @param graph - Dependency graph to check
254
+ * @returns CycleDetectionResult
255
+ */ export function detectCycle(graph) {
256
+ const detector = new CycleDetector();
257
+ return detector.detectCycle(graph);
258
+ }
259
+ /**
260
+ * Utility function to check if adding edge would create cycle
261
+ *
262
+ * @param graph - Current dependency graph
263
+ * @param from - Source agent
264
+ * @param to - Target agent
265
+ * @returns True if edge would create cycle
266
+ */ export function wouldCreateCycle(graph, from, to) {
267
+ const detector = new CycleDetector();
268
+ return detector.wouldCreateCycle(graph, from, to);
269
+ }
270
+
271
+ //# sourceMappingURL=cycle-detector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/coordination/v2/dependency/cycle-detector.ts"],"names":["NodeColor","CycleDetector","colorMap","stack","nodesVisited","metrics","Map","totalDetections","cyclesFound","averageLatencyMs","detectCycle","graph","startTime","performance","now","clear","allNodes","getAllNodes","node","set","agentId","get","cycleResult","dfsVisit","latencyMs","updateMetrics","hasCycle","cyclePath","timestamp","Date","nodeId","push","dependencies","getDependencies","depId","depColor","cycleStartIndex","indexOf","slice","pop","undefined","getCycleDetails","length","Error","agents","startNode","endNode","detectedAt","detectAllCycles","cycles","visited","Set","has","n","add","wouldCreateCycle","from","to","reachable","getReachableNodes","queue","current","shift","dep","cycleFound","getMetrics","reset","detector"],"mappings":"AAAA;;;;;;;;;;;;;CAaC,GAID;;CAEC,GACD,IAAA,AAAKA,mCAAAA;IACH,mBAAmB;IAGnB,2CAA2C;IAG3C,oBAAoB;WAPjBA;EAAAA;AAmDL;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAMC;IACX,2BAA2B,GAC3B,AAAQC,SAAiC;IAEzC,sDAAsD,GACtD,AAAQC,MAAgB;IAExB,2CAA2C,GAC3C,AAAQC,aAAqB;IAE7B,4BAA4B,GAC5B,AAAQC,QAIN;IAEF,aAAc;QACZ,IAAI,CAACH,QAAQ,GAAG,IAAII;QACpB,IAAI,CAACH,KAAK,GAAG,EAAE;QACf,IAAI,CAACC,YAAY,GAAG;QACpB,IAAI,CAACC,OAAO,GAAG;YACbE,iBAAiB;YACjBC,aAAa;YACbC,kBAAkB;QACpB;IACF;IAEA;;;;;;GAMC,GACDC,YAAYC,KAAsB,EAAwB;QACxD,MAAMC,YAAYC,YAAYC,GAAG;QAEjC,wBAAwB;QACxB,IAAI,CAACZ,QAAQ,CAACa,KAAK;QACnB,IAAI,CAACZ,KAAK,GAAG,EAAE;QACf,IAAI,CAACC,YAAY,GAAG;QAEpB,gCAAgC;QAChC,MAAMY,WAAWL,MAAMM,WAAW;QAClC,KAAK,MAAMC,QAAQF,SAAU;YAC3B,IAAI,CAACd,QAAQ,CAACiB,GAAG,CAACD,KAAKE,OAAO;QAChC;QAEA,+BAA+B;QAC/B,KAAK,MAAMF,QAAQF,SAAU;YAC3B,IAAI,IAAI,CAACd,QAAQ,CAACmB,GAAG,CAAC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AAK;QACnB,IAAI,CAACZ,KAAK,GAAG,EAAE;QACf,IAAI,CAACC,YAAY,GAAG;IACtB;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAASM,YAAYC,KAAsB;IAChD,MAAMwD,WAAW,IAAIlE;IACrB,OAAOkE,SAASzD,WAAW,CAACC;AAC9B;AAEA;;;;;;;CAOC,GACD,OAAO,SAAS4C,iBACd5C,KAAsB,EACtB6C,IAAY,EACZC,EAAU;IAEV,MAAMU,WAAW,IAAIlE;IACrB,OAAOkE,SAASZ,gBAAgB,CAAC5C,OAAO6C,MAAMC;AAChD"}
@@ -0,0 +1,335 @@
1
+ /**
2
+ * Agent Coordination V2 - Dependency Graph (DAG)
3
+ *
4
+ * Directed Acyclic Graph (DAG) data structure for managing agent dependencies.
5
+ * Uses adjacency list representation for O(V+E) space complexity.
6
+ *
7
+ * Features:
8
+ * - Adjacency list representation
9
+ * - Topological sorting
10
+ * - Transitive dependency resolution
11
+ * - Cycle detection integration
12
+ *
13
+ * @module coordination/v2/dependency/dependency-graph
14
+ */ /**
15
+ * DependencyGraph - DAG implementation using adjacency list
16
+ *
17
+ * Space complexity: O(V + E) where V = nodes, E = edges
18
+ * Time complexity:
19
+ * - addNode: O(1)
20
+ * - addEdge: O(1)
21
+ * - removeEdge: O(1)
22
+ * - getDependencies: O(1)
23
+ * - topologicalSort: O(V + E)
24
+ */ export class DependencyGraph {
25
+ /** Adjacency list: agentId -> DependencyNode */ nodes;
26
+ /** Edge list for quick edge lookups */ edges;
27
+ /** Graph creation timestamp */ createdAt;
28
+ /** Graph metrics */ metrics;
29
+ constructor(){
30
+ this.nodes = new Map();
31
+ this.edges = new Map();
32
+ this.createdAt = new Date();
33
+ this.metrics = {
34
+ totalNodesAdded: 0,
35
+ totalEdgesAdded: 0,
36
+ totalNodesRemoved: 0,
37
+ totalEdgesRemoved: 0
38
+ };
39
+ }
40
+ /**
41
+ * Add node to graph
42
+ * O(1) time complexity
43
+ */ addNode(agentId, priority = 5) {
44
+ if (this.nodes.has(agentId)) {
45
+ return; // Node already exists
46
+ }
47
+ const node = {
48
+ agentId,
49
+ dependencies: new Set(),
50
+ dependents: new Set(),
51
+ requests: new Map(),
52
+ metadata: {
53
+ createdAt: new Date(),
54
+ lastUpdated: new Date(),
55
+ priority
56
+ }
57
+ };
58
+ this.nodes.set(agentId, node);
59
+ this.metrics.totalNodesAdded++;
60
+ }
61
+ /**
62
+ * Add directed edge: from -> to (from depends on to)
63
+ * O(1) time complexity
64
+ *
65
+ * @throws Error if edge would create cycle
66
+ */ addEdge(from, to, request) {
67
+ // Ensure both nodes exist
68
+ this.addNode(from);
69
+ this.addNode(to);
70
+ const edgeKey = `${from}->${to}`;
71
+ // Skip if edge already exists
72
+ if (this.edges.has(edgeKey)) {
73
+ return;
74
+ }
75
+ // Create edge
76
+ const edge = {
77
+ from,
78
+ to,
79
+ requestId: request.requestId,
80
+ weight: request.priority,
81
+ createdAt: new Date()
82
+ };
83
+ // Update adjacency lists
84
+ const fromNode = this.nodes.get(from);
85
+ const toNode = this.nodes.get(to);
86
+ fromNode.dependencies.add(to);
87
+ fromNode.requests.set(request.requestId, request);
88
+ fromNode.metadata.lastUpdated = new Date();
89
+ toNode.dependents.add(from);
90
+ toNode.metadata.lastUpdated = new Date();
91
+ // Store edge
92
+ this.edges.set(edgeKey, edge);
93
+ this.metrics.totalEdgesAdded++;
94
+ }
95
+ /**
96
+ * Remove edge from graph
97
+ * O(1) time complexity
98
+ */ removeEdge(from, to) {
99
+ const edgeKey = `${from}->${to}`;
100
+ if (!this.edges.has(edgeKey)) {
101
+ return false;
102
+ }
103
+ // Update adjacency lists
104
+ const fromNode = this.nodes.get(from);
105
+ const toNode = this.nodes.get(to);
106
+ if (fromNode) {
107
+ fromNode.dependencies.delete(to);
108
+ fromNode.metadata.lastUpdated = new Date();
109
+ }
110
+ if (toNode) {
111
+ toNode.dependents.delete(from);
112
+ toNode.metadata.lastUpdated = new Date();
113
+ }
114
+ // Remove edge
115
+ this.edges.delete(edgeKey);
116
+ this.metrics.totalEdgesRemoved++;
117
+ return true;
118
+ }
119
+ /**
120
+ * Remove node and all associated edges
121
+ * O(E) time complexity where E = edges connected to node
122
+ */ removeNode(agentId) {
123
+ const node = this.nodes.get(agentId);
124
+ if (!node) {
125
+ return false;
126
+ }
127
+ // Remove all incoming edges (from dependents)
128
+ for (const dependent of node.dependents){
129
+ this.removeEdge(dependent, agentId);
130
+ }
131
+ // Remove all outgoing edges (to dependencies)
132
+ for (const dependency of node.dependencies){
133
+ this.removeEdge(agentId, dependency);
134
+ }
135
+ // Remove node
136
+ this.nodes.delete(agentId);
137
+ this.metrics.totalNodesRemoved++;
138
+ return true;
139
+ }
140
+ /**
141
+ * Get direct dependencies for an agent
142
+ * O(1) time complexity
143
+ */ getDependencies(agentId) {
144
+ const node = this.nodes.get(agentId);
145
+ return node ? new Set(node.dependencies) : new Set();
146
+ }
147
+ /**
148
+ * Get direct dependents for an agent
149
+ * O(1) time complexity
150
+ */ getDependents(agentId) {
151
+ const node = this.nodes.get(agentId);
152
+ return node ? new Set(node.dependents) : new Set();
153
+ }
154
+ /**
155
+ * Get all transitive dependencies (recursive)
156
+ * O(V + E) time complexity with memoization
157
+ */ getTransitiveDependencies(agentId) {
158
+ const visited = new Set();
159
+ const transitive = new Set();
160
+ const traverse = (nodeId)=>{
161
+ if (visited.has(nodeId)) {
162
+ return;
163
+ }
164
+ visited.add(nodeId);
165
+ const dependencies = this.getDependencies(nodeId);
166
+ for (const dep of dependencies){
167
+ transitive.add(dep);
168
+ traverse(dep);
169
+ }
170
+ };
171
+ traverse(agentId);
172
+ return transitive;
173
+ }
174
+ /**
175
+ * Check if agent has any dependencies
176
+ */ hasDependencies(agentId) {
177
+ const node = this.nodes.get(agentId);
178
+ return node ? node.dependencies.size > 0 : false;
179
+ }
180
+ /**
181
+ * Check if agent has any dependents
182
+ */ hasDependents(agentId) {
183
+ const node = this.nodes.get(agentId);
184
+ return node ? node.dependents.size > 0 : false;
185
+ }
186
+ /**
187
+ * Get node by agent ID
188
+ */ getNode(agentId) {
189
+ return this.nodes.get(agentId);
190
+ }
191
+ /**
192
+ * Get edge between two agents
193
+ */ getEdge(from, to) {
194
+ return this.edges.get(`${from}->${to}`);
195
+ }
196
+ /**
197
+ * Get all nodes in graph
198
+ */ getAllNodes() {
199
+ return Array.from(this.nodes.values());
200
+ }
201
+ /**
202
+ * Get all edges in graph
203
+ */ getAllEdges() {
204
+ return Array.from(this.edges.values());
205
+ }
206
+ /**
207
+ * Topological sort using Kahn's algorithm
208
+ * O(V + E) time complexity
209
+ *
210
+ * @returns TopologicalSortResult with sorted order or cycle info
211
+ */ topologicalSort() {
212
+ // Calculate in-degree for each node
213
+ const inDegree = new Map();
214
+ const queue = [];
215
+ for (const [agentId, node] of this.nodes){
216
+ inDegree.set(agentId, node.dependencies.size);
217
+ if (node.dependencies.size === 0) {
218
+ queue.push(agentId);
219
+ }
220
+ }
221
+ const order = [];
222
+ // Process nodes with in-degree 0
223
+ while(queue.length > 0){
224
+ const current = queue.shift();
225
+ order.push(current);
226
+ // Reduce in-degree for all dependents
227
+ const dependents = this.getDependents(current);
228
+ for (const dependent of dependents){
229
+ const degree = inDegree.get(dependent) - 1;
230
+ inDegree.set(dependent, degree);
231
+ if (degree === 0) {
232
+ queue.push(dependent);
233
+ }
234
+ }
235
+ }
236
+ // If all nodes processed, graph is acyclic
237
+ if (order.length === this.nodes.size) {
238
+ return {
239
+ success: true,
240
+ order
241
+ };
242
+ }
243
+ // Cycle detected - find remaining nodes
244
+ const remainingNodes = Array.from(this.nodes.keys()).filter((agentId)=>!order.includes(agentId));
245
+ return {
246
+ success: false,
247
+ cycle: {
248
+ agents: remainingNodes,
249
+ detectedAt: new Date()
250
+ }
251
+ };
252
+ }
253
+ /**
254
+ * Get graph statistics
255
+ */ getStatistics() {
256
+ const sourceNodes = [];
257
+ const sinkNodes = [];
258
+ let totalDependencies = 0;
259
+ let maxDepth = 0;
260
+ for (const [agentId, node] of this.nodes){
261
+ // Source nodes: no dependencies
262
+ if (node.dependencies.size === 0) {
263
+ sourceNodes.push(agentId);
264
+ }
265
+ // Sink nodes: no dependents
266
+ if (node.dependents.size === 0) {
267
+ sinkNodes.push(agentId);
268
+ }
269
+ totalDependencies += node.dependencies.size;
270
+ // Calculate depth from source nodes
271
+ const depth = this.calculateDepth(agentId);
272
+ if (depth > maxDepth) {
273
+ maxDepth = depth;
274
+ }
275
+ }
276
+ return {
277
+ nodeCount: this.nodes.size,
278
+ edgeCount: this.edges.size,
279
+ maxDepth,
280
+ averageDependencies: this.nodes.size > 0 ? totalDependencies / this.nodes.size : 0,
281
+ sourceNodes,
282
+ sinkNodes
283
+ };
284
+ }
285
+ /**
286
+ * Calculate depth of node from source nodes
287
+ * O(V + E) time complexity
288
+ */ calculateDepth(agentId) {
289
+ const visited = new Set();
290
+ const dfs = (nodeId)=>{
291
+ if (visited.has(nodeId)) {
292
+ return 0; // Avoid cycles
293
+ }
294
+ visited.add(nodeId);
295
+ const dependencies = this.getDependencies(nodeId);
296
+ if (dependencies.size === 0) {
297
+ return 0; // Source node
298
+ }
299
+ let maxDepth = 0;
300
+ for (const dep of dependencies){
301
+ const depth = dfs(dep) + 1;
302
+ if (depth > maxDepth) {
303
+ maxDepth = depth;
304
+ }
305
+ }
306
+ return maxDepth;
307
+ };
308
+ return dfs(agentId);
309
+ }
310
+ /**
311
+ * Get graph metrics
312
+ */ getMetrics() {
313
+ return {
314
+ ...this.metrics
315
+ };
316
+ }
317
+ /**
318
+ * Clear entire graph
319
+ */ clear() {
320
+ this.nodes.clear();
321
+ this.edges.clear();
322
+ }
323
+ /**
324
+ * Get graph size
325
+ */ size() {
326
+ return this.nodes.size;
327
+ }
328
+ /**
329
+ * Check if graph is empty
330
+ */ isEmpty() {
331
+ return this.nodes.size === 0;
332
+ }
333
+ }
334
+
335
+ //# sourceMappingURL=dependency-graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/coordination/v2/dependency/dependency-graph.ts"],"names":["DependencyGraph","nodes","edges","createdAt","metrics","Map","Date","totalNodesAdded","totalEdgesAdded","totalNodesRemoved","totalEdgesRemoved","addNode","agentId","priority","has","node","dependencies","Set","dependents","requests","metadata","lastUpdated","set","addEdge","from","to","request","edgeKey","edge","requestId","weight","fromNode","get","toNode","add","removeEdge","delete","removeNode","dependent","dependency","getDependencies","getDependents","getTransitiveDependencies","visited","transitive","traverse","nodeId","dep","hasDependencies","size","hasDependents","getNode","getEdge","getAllNodes","Array","values","getAllEdges","topologicalSort","inDegree","queue","push","order","length","current","shift","degree","success","remainingNodes","keys","filter","includes","cycle","agents","detectedAt","getStatistics","sourceNodes","sinkNodes","totalDependencies","maxDepth","depth","calculateDepth","nodeCount","edgeCount","averageDependencies","dfs","getMetrics","clear","isEmpty"],"mappings":"AAAA;;;;;;;;;;;;;CAaC,GA2FD;;;;;;;;;;CAUC,GACD,OAAO,MAAMA;IACX,8CAA8C,GAC9C,AAAQC,MAAmC;IAE3C,qCAAqC,GACrC,AAAQC,MAAmC;IAE3C,6BAA6B,GAC7B,AAAiBC,UAAgB;IAEjC,kBAAkB,GAClB,AAAQC,QAKN;IAEF,aAAc;QACZ,IAAI,CAACH,KAAK,GAAG,IAAII;QACjB,IAAI,CAACH,KAAK,GAAG,IAAIG;QACjB,IAAI,CAACF,SAAS,GAAG,IAAIG;QACrB,IAAI,CAACF,OAAO,GAAG;YACbG,iBAAiB;YACjBC,iBAAiB;YACjBC,mBAAmB;YACnBC,mBAAmB;QACrB;IACF;IAEA;;;GAGC,GACDC,QAAQC,OAAe,EAAEC,WAAmB,CAAC,EAAQ;QACnD,IAAI,IAAI,CAACZ,KAAK,CAACa,GAAG,CAACF,UAAU;YAC3B,QAAQ,sBAAsB;QAChC;QAEA,MAAMG,OAAuB;YAC3BH;YACAI,cAAc,IAAIC;YAClBC,YAAY,IAAID;YAChBE,UAAU,IAAId;YACde,UAAU;gBACRjB,WAAW,IAAIG;gBACfe,aAAa,IAAIf;gBACjBO;YACF;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