claude-flow-novice 1.6.4 → 1.6.5

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 (269) hide show
  1. package/.claude/commands/parse-epic.js +180 -0
  2. package/.claude/settings.local.json +2 -1
  3. package/.claude-flow-novice/dist/mcp/mcp-server-novice.js +37 -2
  4. package/.claude-flow-novice/dist/mcp/transports/base.js +5 -0
  5. package/.claude-flow-novice/dist/mcp/transports/base.js.map +1 -0
  6. package/.claude-flow-novice/dist/mcp/transports/http.js +414 -0
  7. package/.claude-flow-novice/dist/mcp/transports/http.js.map +1 -0
  8. package/.claude-flow-novice/dist/mcp/transports/stdio.js +217 -0
  9. package/.claude-flow-novice/dist/mcp/transports/stdio.js.map +1 -0
  10. package/.claude-flow-novice/dist/src/cli/commands/parse-epic.js +129 -0
  11. package/.claude-flow-novice/dist/src/cli/commands/parse-epic.js.map +1 -0
  12. package/.claude-flow-novice/dist/src/cli/index.js +3 -0
  13. package/.claude-flow-novice/dist/src/cli/index.js.map +1 -1
  14. package/.claude-flow-novice/dist/src/cli/utils/epic-parser.js +266 -0
  15. package/.claude-flow-novice/dist/src/cli/utils/epic-parser.js.map +1 -0
  16. package/.claude-flow-novice/dist/src/communication/message-bus.js +105 -2
  17. package/.claude-flow-novice/dist/src/communication/message-bus.js.map +1 -1
  18. package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js +1 -1
  19. package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js.map +1 -1
  20. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/artifact-cache-optimizer.js +632 -0
  21. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/artifact-cache-optimizer.js.map +1 -0
  22. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/index.js +11 -0
  23. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/index.js.map +1 -0
  24. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/checkpoints/checkpoint-compressor.js +318 -0
  25. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/checkpoints/checkpoint-compressor.js.map +1 -0
  26. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/completion-detector.js +234 -0
  27. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/completion-detector.js.map +1 -0
  28. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/hierarchical-detector.js +347 -0
  29. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/hierarchical-detector.js.map +1 -0
  30. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/index.js +13 -0
  31. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/index.js.map +1 -0
  32. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/lamport-clock.js +173 -0
  33. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/lamport-clock.js.map +1 -0
  34. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/mesh-detector.js +526 -0
  35. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/mesh-detector.js.map +1 -0
  36. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/sdk-completion-detector.js +443 -0
  37. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/sdk-completion-detector.js.map +1 -0
  38. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/swarm-shutdown.js +366 -0
  39. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/swarm-shutdown.js.map +1 -0
  40. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinator-factory.js +287 -0
  41. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinator-factory.js.map +1 -0
  42. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.example.js +364 -0
  43. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.example.js.map +1 -0
  44. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.js +492 -0
  45. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.js.map +1 -0
  46. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/hierarchical-coordinator.js +786 -0
  47. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/hierarchical-coordinator.js.map +1 -0
  48. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/index.js +16 -0
  49. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/index.js.map +1 -0
  50. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/parent-child-manager.js +342 -0
  51. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/parent-child-manager.js.map +1 -0
  52. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/swarm-coordinator-v2.js +601 -0
  53. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/swarm-coordinator-v2.js.map +1 -0
  54. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/agent-state.js +9 -0
  55. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/agent-state.js.map +1 -0
  56. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dead-letter-queue.js +413 -0
  57. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dead-letter-queue.js.map +1 -0
  58. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-graph.js +471 -0
  59. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-graph.js.map +1 -0
  60. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-node.js +379 -0
  61. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-node.js.map +1 -0
  62. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-resolver.js +335 -0
  63. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-resolver.js.map +1 -0
  64. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/help-request-metrics.js +211 -0
  65. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/help-request-metrics.js.map +1 -0
  66. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/index.js +33 -0
  67. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/index.js.map +1 -0
  68. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-broker.js +920 -0
  69. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-broker.js.map +1 -0
  70. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-router.js +385 -0
  71. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-router.js.map +1 -0
  72. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message.js +138 -0
  73. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message.js.map +1 -0
  74. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/resource-manager-safe.js +478 -0
  75. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/resource-manager-safe.js.map +1 -0
  76. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine-config.js +358 -0
  77. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine-config.js.map +1 -0
  78. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine.js +588 -0
  79. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine.js.map +1 -0
  80. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-transition.js +153 -0
  81. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-transition.js.map +1 -0
  82. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/task-scheduler.js +360 -0
  83. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/task-scheduler.js.map +1 -0
  84. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/topic-manager.js +337 -0
  85. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/topic-manager.js.map +1 -0
  86. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/deadlock-detector.js +424 -0
  87. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/deadlock-detector.js.map +1 -0
  88. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/index.js +9 -0
  89. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/index.js.map +1 -0
  90. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/resource-manager.js +669 -0
  91. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/resource-manager.js.map +1 -0
  92. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/artifact-storage.js +451 -0
  93. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/artifact-storage.js.map +1 -0
  94. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/cycle-detector.js +271 -0
  95. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/cycle-detector.js.map +1 -0
  96. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-graph.js +335 -0
  97. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-graph.js.map +1 -0
  98. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-manager.js +439 -0
  99. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-manager.js.map +1 -0
  100. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-request.js +92 -0
  101. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-request.js.map +1 -0
  102. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/index.js +21 -0
  103. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/index.js.map +1 -0
  104. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/topological-sort.js +223 -0
  105. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/topological-sort.js.map +1 -0
  106. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-coordinator.js +436 -0
  107. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-coordinator.js.map +1 -0
  108. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-matcher.js +278 -0
  109. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-matcher.js.map +1 -0
  110. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request-handler.js +317 -0
  111. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request-handler.js.map +1 -0
  112. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request.js +273 -0
  113. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request.js.map +1 -0
  114. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/index.js +15 -0
  115. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/index.js.map +1 -0
  116. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/waiting-agent-pool.js +512 -0
  117. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/waiting-agent-pool.js.map +1 -0
  118. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/index.js +67 -0
  119. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/index.js.map +1 -0
  120. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/help-deadlock-integration.js +557 -0
  121. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/help-deadlock-integration.js.map +1 -0
  122. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/index.js +14 -0
  123. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/index.js.map +1 -0
  124. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.example.js +212 -0
  125. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.example.js.map +1 -0
  126. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.js +552 -0
  127. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.js.map +1 -0
  128. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/state-machine-integration.js +635 -0
  129. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/state-machine-integration.js.map +1 -0
  130. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/IArtifactStorage.js +28 -0
  131. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/IArtifactStorage.js.map +1 -0
  132. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ICoordinator.js +9 -0
  133. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ICoordinator.js.map +1 -0
  134. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ISessionStore.js +25 -0
  135. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ISessionStore.js.map +1 -0
  136. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/index.js +14 -0
  137. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/index.js.map +1 -0
  138. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/artifact-adapter.js +308 -0
  139. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/artifact-adapter.js.map +1 -0
  140. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/completion-storage.js +439 -0
  141. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/completion-storage.js.map +1 -0
  142. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-graph-storage.js +540 -0
  143. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-graph-storage.js.map +1 -0
  144. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-storage.js +367 -0
  145. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-storage.js.map +1 -0
  146. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/index.js +14 -0
  147. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/index.js.map +1 -0
  148. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/message-storage.js +518 -0
  149. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/message-storage.js.map +1 -0
  150. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/state-storage.js +377 -0
  151. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/state-storage.js.map +1 -0
  152. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channel.js +371 -0
  153. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channel.js.map +1 -0
  154. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/dependency-channel.js +355 -0
  155. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/dependency-channel.js.map +1 -0
  156. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/help-channel.js +424 -0
  157. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/help-channel.js.map +1 -0
  158. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/index.js +16 -0
  159. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/index.js.map +1 -0
  160. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/state-channel.js +295 -0
  161. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/state-channel.js.map +1 -0
  162. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/task-channel.js +411 -0
  163. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/task-channel.js.map +1 -0
  164. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/index.js +14 -0
  165. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/index.js.map +1 -0
  166. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-bus.js +387 -0
  167. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-bus.js.map +1 -0
  168. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-persistence.js +589 -0
  169. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-persistence.js.map +1 -0
  170. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-router.js +444 -0
  171. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-router.js.map +1 -0
  172. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/artifact-storage.js +560 -0
  173. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/artifact-storage.js.map +1 -0
  174. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/background-orchestrator.js +335 -0
  175. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/background-orchestrator.js.map +1 -0
  176. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/bash-output-monitor.js +104 -0
  177. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/bash-output-monitor.js.map +1 -0
  178. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/checkpoint-manager.js +847 -0
  179. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/checkpoint-manager.js.map +1 -0
  180. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/help-coordinator.js +470 -0
  181. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/help-coordinator.js.map +1 -0
  182. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/hierarchical-background-integration.js +450 -0
  183. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/hierarchical-background-integration.js.map +1 -0
  184. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/index.js +13 -0
  185. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/index.js.map +1 -0
  186. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/message-bus-integration.js +625 -0
  187. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/message-bus-integration.js.map +1 -0
  188. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/multi-level-control.js +545 -0
  189. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/multi-level-control.js.map +1 -0
  190. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-controller.js +740 -0
  191. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-controller.js.map +1 -0
  192. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-message-integration.js +415 -0
  193. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-message-integration.js.map +1 -0
  194. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/session-pool-optimizer.js +615 -0
  195. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/session-pool-optimizer.js.map +1 -0
  196. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-machine-integration.js +547 -0
  197. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-machine-integration.js.map +1 -0
  198. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-sdk-integration.js +342 -0
  199. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-sdk-integration.js.map +1 -0
  200. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/security/payload-validator.js +259 -0
  201. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/security/payload-validator.js.map +1 -0
  202. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/framework-registry.js +273 -0
  203. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/framework-registry.js.map +1 -0
  204. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/index.js +8 -0
  205. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/index.js.map +1 -0
  206. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-config-manager.js +310 -0
  207. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-config-manager.js.map +1 -0
  208. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-validator.js +218 -0
  209. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-validator.js.map +1 -0
  210. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/types/sdk.js +9 -0
  211. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/types/sdk.js.map +1 -0
  212. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/index.js +6 -0
  213. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/index.js.map +1 -0
  214. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/priority-queue.js +145 -0
  215. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/priority-queue.js.map +1 -0
  216. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/sdk-helpers.js +122 -0
  217. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/sdk-helpers.js.map +1 -0
  218. package/.claude-flow-novice/dist/src/coordination/config-translator.js +17 -43
  219. package/.claude-flow-novice/dist/src/coordination/config-translator.js.map +1 -1
  220. package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js +34 -76
  221. package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js.map +1 -1
  222. package/.claude-flow-novice/dist/src/coordination/shared/core/agent-state.js +172 -0
  223. package/.claude-flow-novice/dist/src/coordination/shared/core/agent-state.js.map +1 -0
  224. package/.claude-flow-novice/dist/src/coordination/shared/core/index.js +7 -0
  225. package/.claude-flow-novice/dist/src/coordination/shared/core/index.js.map +1 -0
  226. package/.claude-flow-novice/dist/src/coordination/shared/index.js +19 -0
  227. package/.claude-flow-novice/dist/src/coordination/shared/index.js.map +1 -0
  228. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/ICoordinator.js +24 -0
  229. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/ICoordinator.js.map +1 -0
  230. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/index.js +7 -0
  231. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/index.js.map +1 -0
  232. package/.claude-flow-novice/dist/src/coordination/shared/message-broker.js +920 -0
  233. package/.claude-flow-novice/dist/src/coordination/shared/message-broker.js.map +1 -0
  234. package/.claude-flow-novice/dist/src/coordination/shared/message.js +138 -0
  235. package/.claude-flow-novice/dist/src/coordination/shared/message.js.map +1 -0
  236. package/.claude-flow-novice/dist/src/coordination/shared/security/payload-validator.js +259 -0
  237. package/.claude-flow-novice/dist/src/coordination/shared/security/payload-validator.js.map +1 -0
  238. package/.claude-flow-novice/dist/src/coordination/shared/transparency/index.js +17 -0
  239. package/.claude-flow-novice/dist/src/coordination/shared/transparency/index.js.map +1 -0
  240. package/.claude-flow-novice/dist/src/coordination/shared/transparency/interfaces/transparency-system.js +19 -0
  241. package/.claude-flow-novice/dist/src/coordination/shared/transparency/interfaces/transparency-system.js.map +1 -0
  242. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-integration.js +357 -0
  243. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-integration.js.map +1 -0
  244. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-system.js +679 -0
  245. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-system.js.map +1 -0
  246. package/.claude-flow-novice/dist/src/coordination/shared/types/index.js +7 -0
  247. package/.claude-flow-novice/dist/src/coordination/shared/types/index.js.map +1 -0
  248. package/.claude-flow-novice/dist/src/coordination/shared/types/sdk.js +10 -0
  249. package/.claude-flow-novice/dist/src/coordination/shared/types/sdk.js.map +1 -0
  250. package/.claude-flow-novice/dist/src/feature-flags/core/FeatureFlagManager.js +52 -2
  251. package/.claude-flow-novice/dist/src/feature-flags/core/FeatureFlagManager.js.map +1 -1
  252. package/.claude-flow-novice/dist/src/mcp/mcp-server-novice.js +37 -2
  253. package/.claude-flow-novice/dist/src/mcp/session-manager.js +3 -1
  254. package/.claude-flow-novice/dist/src/mcp/session-manager.js.map +1 -1
  255. package/.claude-flow-novice/dist/src/providers/provider-manager.js +36 -3
  256. package/.claude-flow-novice/dist/src/providers/provider-manager.js.map +1 -1
  257. package/.claude-flow-novice/dist/src/utils/markdown-sanitizer.js +65 -41
  258. package/.claude-flow-novice/dist/src/utils/markdown-sanitizer.js.map +1 -1
  259. package/.claude-flow-novice/dist/src/web/api/server.js +1 -1
  260. package/.claude-flow-novice/dist/src/web/api/server.js.map +1 -1
  261. package/.claude-flow-novice/dist/src/workflows/progressive-rollout-manager.js +30 -0
  262. package/.claude-flow-novice/dist/src/workflows/progressive-rollout-manager.js.map +1 -1
  263. package/.claude-flow-novice/metrics.db-shm +0 -0
  264. package/.claude-flow-novice/metrics.db-wal +0 -0
  265. package/package.json +2 -2
  266. package/scripts/monitoring/alert-monitor.sh +220 -0
  267. package/scripts/monitoring/view-alerts.sh +307 -0
  268. package/scripts/test-zai-api.cjs +2 -2
  269. package/src/slash-commands/parse-epic.js +1 -1
@@ -0,0 +1,635 @@
1
+ /**
2
+ * Agent Coordination V2 - State Machine Integration
3
+ *
4
+ * Bidirectional synchronization between Phase 01 state machine and Phase 02 dependency graph.
5
+ * Bridges agent lifecycle states with task scheduling and dependency resolution.
6
+ *
7
+ * Integration flow:
8
+ * - State machine transitions → Task status updates
9
+ * - Task assignments → Agent state transitions
10
+ * - Completion events → Dependency resolution
11
+ * - Error handling → Blocked state propagation
12
+ *
13
+ * Performance Requirements:
14
+ * - Dependency resolution: <50ms (p95)
15
+ * - State transition handling: <100ms (p99)
16
+ * - Agent assignment: <20ms (p95)
17
+ * - Memory leak prevention: Automatic listener cleanup
18
+ *
19
+ * @module coordination/v2/integration/state-machine-integration
20
+ */ import { EventEmitter } from 'node:events';
21
+ import { AgentState } from '../../shared/core/agent-state.js';
22
+ import { DependencyNodeStatus } from '../core/dependency-node.js';
23
+ import { Logger } from '../../../core/logger.js';
24
+ /**
25
+ * StateMachineIntegration - Bidirectional synchronization layer
26
+ *
27
+ * Responsibilities:
28
+ * 1. Listen to state machine events and update task statuses
29
+ * 2. Listen to scheduler events and trigger state transitions
30
+ * 3. Manage agent-task assignments
31
+ * 4. Propagate errors and handle retries
32
+ * 5. Maintain consistency between state machine and dependency graph
33
+ */ export class StateMachineIntegration extends EventEmitter {
34
+ logger;
35
+ stateMachine;
36
+ scheduler;
37
+ graph;
38
+ config;
39
+ agentTaskMappings;
40
+ taskAgentMappings;
41
+ taskRetryCount;
42
+ statistics;
43
+ isRunning;
44
+ schedulingInterval;
45
+ constructor(stateMachine, scheduler, graph, config){
46
+ super();
47
+ this.logger = new Logger({
48
+ level: 'info',
49
+ format: 'text',
50
+ destination: 'console'
51
+ });
52
+ this.stateMachine = stateMachine;
53
+ this.scheduler = scheduler;
54
+ this.graph = graph;
55
+ this.config = {
56
+ autoAssignAgents: config?.autoAssignAgents ?? true,
57
+ maxRetryAttempts: config?.maxRetryAttempts ?? 3,
58
+ validateTaskStatus: config?.validateTaskStatus ?? true,
59
+ enableConsistencyChecks: config?.enableConsistencyChecks ?? true
60
+ };
61
+ this.agentTaskMappings = new Map();
62
+ this.taskAgentMappings = new Map();
63
+ this.taskRetryCount = new Map();
64
+ this.isRunning = false;
65
+ this.statistics = {
66
+ totalAssignments: 0,
67
+ totalCompletions: 0,
68
+ totalFailures: 0,
69
+ totalRetries: 0,
70
+ activeAssignments: 0,
71
+ consistencyChecksPassed: 0,
72
+ consistencyChecksFailed: 0
73
+ };
74
+ this.setupEventListeners();
75
+ this.logger.info('StateMachineIntegration initialized', {
76
+ autoAssignAgents: this.config.autoAssignAgents,
77
+ maxRetryAttempts: this.config.maxRetryAttempts
78
+ });
79
+ }
80
+ /**
81
+ * Setup bidirectional event listeners
82
+ */ setupEventListeners() {
83
+ // State machine → Scheduler (agent state changes affect tasks)
84
+ this.stateMachine.on('state:transition', this.onAgentStateChange.bind(this));
85
+ // Scheduler → State machine (task events trigger agent state changes)
86
+ this.scheduler.on('task:scheduled', this.onTaskScheduled.bind(this));
87
+ this.scheduler.on('task:completed', this.onTaskCompleted.bind(this));
88
+ // Custom event for task failures (emitted by scheduler or manually)
89
+ this.on('task:failed', this.onTaskFailed.bind(this));
90
+ this.logger.debug('Event listeners configured');
91
+ }
92
+ // ============================================
93
+ // State Machine → Scheduler Integration
94
+ // ============================================
95
+ /**
96
+ * Handle agent state transitions
97
+ * Maps state machine events to task status updates
98
+ */ async onAgentStateChange(event) {
99
+ const { agentId, fromState, toState } = event;
100
+ this.logger.debug('Agent state changed', {
101
+ agentId,
102
+ fromState,
103
+ toState,
104
+ timestamp: event.timestamp
105
+ });
106
+ const mapping = this.agentTaskMappings.get(agentId);
107
+ if (!mapping) {
108
+ // Agent has no assigned task, this is normal for IDLE agents
109
+ return;
110
+ }
111
+ const taskId = mapping.taskId;
112
+ const node = this.graph.getNode(taskId);
113
+ if (!node) {
114
+ this.logger.warn('Task not found in graph', {
115
+ taskId,
116
+ agentId
117
+ });
118
+ return;
119
+ }
120
+ // Update mapping status
121
+ mapping.status = toState;
122
+ // Map agent states to task statuses
123
+ try {
124
+ if (toState === AgentState.WORKING) {
125
+ // Agent started working → task is executing
126
+ await this.updateTaskStatus(node, DependencyNodeStatus.EXECUTING, {
127
+ agentId,
128
+ startedAt: Date.now()
129
+ });
130
+ } else if (toState === AgentState.COMPLETED) {
131
+ // Agent completed → mark task as completed
132
+ await this.updateTaskStatus(node, DependencyNodeStatus.COMPLETED, {
133
+ agentId,
134
+ completedAt: Date.now()
135
+ });
136
+ // Notify scheduler of completion
137
+ await this.scheduler.onTaskComplete(taskId);
138
+ // Clear assignment
139
+ this.clearAgentAssignment(agentId);
140
+ } else if (toState === AgentState.BLOCKED || toState === AgentState.ERROR) {
141
+ // Agent blocked/errored → task failed
142
+ const error = new Error(`Agent ${agentId} transitioned to ${toState}`);
143
+ await this.handleTaskFailure(taskId, agentId, error);
144
+ } else if (toState === AgentState.WAITING) {
145
+ // Agent waiting → task pending dependencies
146
+ await this.updateTaskStatus(node, DependencyNodeStatus.PENDING, {
147
+ agentId,
148
+ waitingAt: Date.now()
149
+ });
150
+ } else if (toState === AgentState.IDLE) {
151
+ // Agent returned to idle → ready for new assignment
152
+ // Only clear if task was previously completed
153
+ if (fromState === AgentState.COMPLETED) {
154
+ this.clearAgentAssignment(agentId);
155
+ }
156
+ }
157
+ // Consistency check
158
+ if (this.config.enableConsistencyChecks) {
159
+ await this.validateStateConsistency(agentId, taskId);
160
+ }
161
+ } catch (error) {
162
+ this.logger.error('Failed to handle agent state change', {
163
+ agentId,
164
+ taskId,
165
+ error: error instanceof Error ? error.message : String(error)
166
+ });
167
+ }
168
+ }
169
+ // ============================================
170
+ // Scheduler → State Machine Integration
171
+ // ============================================
172
+ /**
173
+ * Handle task scheduled event
174
+ * Assigns tasks to available agents
175
+ */ async onTaskScheduled(event) {
176
+ const { taskId, priority } = event;
177
+ this.logger.debug('Task scheduled', {
178
+ taskId,
179
+ priority,
180
+ dependenciesMet: event.dependenciesMet
181
+ });
182
+ // Only assign if dependencies are met and auto-assignment is enabled
183
+ if (!event.dependenciesMet || !this.config.autoAssignAgents) {
184
+ return;
185
+ }
186
+ try {
187
+ // Find available agent
188
+ const agentId = await this.findAvailableAgent();
189
+ if (!agentId) {
190
+ this.logger.debug('No available agents for task assignment', {
191
+ taskId
192
+ });
193
+ return;
194
+ }
195
+ // Assign task to agent
196
+ await this.assignTaskToAgent(taskId, agentId);
197
+ } catch (error) {
198
+ this.logger.error('Failed to assign task', {
199
+ taskId,
200
+ error: error instanceof Error ? error.message : String(error)
201
+ });
202
+ }
203
+ }
204
+ /**
205
+ * Handle task completion event
206
+ * Transitions agent to completed state
207
+ */ async onTaskCompleted(event) {
208
+ const { taskId, agentId } = event;
209
+ this.logger.info('Task completed', {
210
+ taskId,
211
+ agentId,
212
+ completionTime: event.completionTime,
213
+ newlyReadyTasks: event.newlyReadyTasks
214
+ });
215
+ if (!agentId) {
216
+ this.logger.warn('Task completed without assigned agent', {
217
+ taskId
218
+ });
219
+ return;
220
+ }
221
+ try {
222
+ // Transition agent to COMPLETED then IDLE
223
+ const currentState = this.stateMachine.getState(agentId);
224
+ if (currentState !== AgentState.COMPLETED) {
225
+ await this.stateMachine.transition(agentId, AgentState.COMPLETED, {
226
+ metadata: {
227
+ taskId,
228
+ completedAt: Date.now()
229
+ }
230
+ });
231
+ }
232
+ // Then to IDLE for next assignment
233
+ await this.stateMachine.transition(agentId, AgentState.IDLE);
234
+ // Update statistics
235
+ this.statistics.totalCompletions++;
236
+ this.statistics.activeAssignments--;
237
+ // Emit completion event
238
+ this.emit('integration:task-completed', {
239
+ taskId,
240
+ agentId
241
+ });
242
+ } catch (error) {
243
+ this.logger.error('Failed to handle task completion', {
244
+ taskId,
245
+ agentId,
246
+ error: error instanceof Error ? error.message : String(error)
247
+ });
248
+ }
249
+ }
250
+ /**
251
+ * Handle task failure event
252
+ * Manages retries and agent error states
253
+ */ async onTaskFailed(event) {
254
+ const { taskId, agentId, error } = event;
255
+ this.logger.warn('Task failed', {
256
+ taskId,
257
+ agentId,
258
+ error: error.message
259
+ });
260
+ try {
261
+ await this.handleTaskFailure(taskId, agentId, error);
262
+ } catch (handlingError) {
263
+ this.logger.error('Failed to handle task failure', {
264
+ taskId,
265
+ agentId,
266
+ error: handlingError instanceof Error ? handlingError.message : String(handlingError)
267
+ });
268
+ }
269
+ }
270
+ // ============================================
271
+ // Agent Assignment Logic
272
+ // ============================================
273
+ /**
274
+ * Assign a task to an available agent
275
+ */ async assignTaskToAgent(taskId, agentId) {
276
+ const node = this.graph.getNode(taskId);
277
+ if (!node) {
278
+ throw new Error(`Task ${taskId} not found in graph`);
279
+ }
280
+ this.logger.info('Assigning task to agent', {
281
+ taskId,
282
+ agentId
283
+ });
284
+ // Create mapping
285
+ const mapping = {
286
+ agentId,
287
+ taskId,
288
+ assignedAt: Date.now(),
289
+ status: AgentState.WORKING
290
+ };
291
+ this.agentTaskMappings.set(agentId, mapping);
292
+ this.taskAgentMappings.set(taskId, agentId);
293
+ // Update statistics
294
+ this.statistics.totalAssignments++;
295
+ this.statistics.activeAssignments++;
296
+ // Transition agent to WORKING
297
+ await this.stateMachine.transition(agentId, AgentState.WORKING, {
298
+ metadata: {
299
+ taskId,
300
+ assignedAt: Date.now()
301
+ }
302
+ });
303
+ // Update task node
304
+ await this.updateTaskStatus(node, DependencyNodeStatus.EXECUTING, {
305
+ agentId,
306
+ assignedAt: Date.now()
307
+ });
308
+ // Emit assignment event
309
+ const event = {
310
+ taskId,
311
+ agentId,
312
+ timestamp: new Date()
313
+ };
314
+ this.emit('task:assigned', event);
315
+ }
316
+ /**
317
+ * Find an available agent (IDLE or WAITING state)
318
+ */ async findAvailableAgent() {
319
+ const allStates = this.stateMachine.getAllStates();
320
+ for (const [agentId, state] of allStates){
321
+ // Agent is available if idle or waiting
322
+ if (state === AgentState.IDLE || state === AgentState.WAITING) {
323
+ // Check not already assigned
324
+ if (!this.agentTaskMappings.has(agentId)) {
325
+ return agentId;
326
+ }
327
+ }
328
+ }
329
+ return undefined;
330
+ }
331
+ /**
332
+ * Clear agent assignment
333
+ */ clearAgentAssignment(agentId) {
334
+ const mapping = this.agentTaskMappings.get(agentId);
335
+ if (mapping) {
336
+ this.taskAgentMappings.delete(mapping.taskId);
337
+ this.agentTaskMappings.delete(agentId);
338
+ this.statistics.activeAssignments--;
339
+ this.logger.debug('Cleared agent assignment', {
340
+ agentId,
341
+ taskId: mapping.taskId
342
+ });
343
+ }
344
+ }
345
+ // ============================================
346
+ // Error Handling & Retry Logic
347
+ // ============================================
348
+ /**
349
+ * Handle task failure with retry logic
350
+ */ async handleTaskFailure(taskId, agentId, error) {
351
+ const node = this.graph.getNode(taskId);
352
+ if (!node) {
353
+ this.logger.warn('Task not found for failure handling', {
354
+ taskId
355
+ });
356
+ return;
357
+ }
358
+ // Update statistics
359
+ this.statistics.totalFailures++;
360
+ // Check retry count
361
+ const retryCount = this.taskRetryCount.get(taskId) || 0;
362
+ if (retryCount < this.config.maxRetryAttempts) {
363
+ // Retry task
364
+ this.taskRetryCount.set(taskId, retryCount + 1);
365
+ this.statistics.totalRetries++;
366
+ this.logger.info('Retrying failed task', {
367
+ taskId,
368
+ attempt: retryCount + 1,
369
+ maxAttempts: this.config.maxRetryAttempts
370
+ });
371
+ // Reset task to READY status
372
+ await this.updateTaskStatus(node, DependencyNodeStatus.READY, {
373
+ retryCount: retryCount + 1,
374
+ lastError: error.message
375
+ });
376
+ // Transition agent to ERROR then IDLE
377
+ if (this.stateMachine.getState(agentId) !== AgentState.ERROR) {
378
+ await this.stateMachine.transition(agentId, AgentState.ERROR, {
379
+ metadata: {
380
+ taskId,
381
+ error: error.message
382
+ }
383
+ });
384
+ }
385
+ await this.stateMachine.transition(agentId, AgentState.IDLE);
386
+ // Clear assignment
387
+ this.clearAgentAssignment(agentId);
388
+ // Re-schedule task
389
+ await this.scheduler.scheduleTask(node);
390
+ } else {
391
+ // Max retries exceeded → permanent failure
392
+ this.logger.error('Task failed permanently after max retries', {
393
+ taskId,
394
+ attempts: retryCount + 1,
395
+ error: error.message
396
+ });
397
+ // Mark as failed
398
+ await this.updateTaskStatus(node, DependencyNodeStatus.FAILED, {
399
+ error: error.message,
400
+ failedAt: Date.now()
401
+ });
402
+ // Transition agent to ERROR then IDLE
403
+ if (this.stateMachine.getState(agentId) !== AgentState.ERROR) {
404
+ await this.stateMachine.transition(agentId, AgentState.ERROR, {
405
+ metadata: {
406
+ taskId,
407
+ error: error.message
408
+ }
409
+ });
410
+ }
411
+ await this.stateMachine.transition(agentId, AgentState.IDLE);
412
+ // Clear assignment
413
+ this.clearAgentAssignment(agentId);
414
+ // Emit permanent failure event
415
+ this.emit('integration:task-permanent-failure', {
416
+ taskId,
417
+ agentId,
418
+ error
419
+ });
420
+ }
421
+ }
422
+ // ============================================
423
+ // Helper Methods
424
+ // ============================================
425
+ /**
426
+ * Update task status in graph
427
+ */ async updateTaskStatus(node, status, metadata = {}) {
428
+ if (this.config.validateTaskStatus) {
429
+ // Validate status transition
430
+ const currentStatus = node.status;
431
+ if (!this.isValidTaskStatusTransition(currentStatus, status)) {
432
+ throw new Error(`Invalid task status transition: ${currentStatus} -> ${status}`);
433
+ }
434
+ }
435
+ // Update node (requires mutable access, assume graph handles this)
436
+ // Note: DependencyNode interface is readonly, but implementation may provide update methods
437
+ const mutableNode = node;
438
+ mutableNode._status = status;
439
+ mutableNode._metadata = {
440
+ ...node.metadata,
441
+ ...metadata
442
+ };
443
+ mutableNode._updatedAt = Date.now();
444
+ this.logger.debug('Updated task status', {
445
+ taskId: node.taskId,
446
+ status,
447
+ metadata
448
+ });
449
+ }
450
+ /**
451
+ * Validate task status transition
452
+ */ isValidTaskStatusTransition(current, next) {
453
+ const validTransitions = {
454
+ [DependencyNodeStatus.PENDING]: [
455
+ DependencyNodeStatus.READY,
456
+ DependencyNodeStatus.FAILED
457
+ ],
458
+ [DependencyNodeStatus.READY]: [
459
+ DependencyNodeStatus.EXECUTING,
460
+ DependencyNodeStatus.FAILED
461
+ ],
462
+ [DependencyNodeStatus.EXECUTING]: [
463
+ DependencyNodeStatus.COMPLETED,
464
+ DependencyNodeStatus.FAILED,
465
+ DependencyNodeStatus.READY
466
+ ],
467
+ [DependencyNodeStatus.COMPLETED]: [],
468
+ [DependencyNodeStatus.FAILED]: [
469
+ DependencyNodeStatus.READY
470
+ ]
471
+ };
472
+ return validTransitions[current]?.includes(next) ?? false;
473
+ }
474
+ /**
475
+ * Validate state consistency between agent and task
476
+ */ async validateStateConsistency(agentId, taskId) {
477
+ const agentState = this.stateMachine.getState(agentId);
478
+ const node = this.graph.getNode(taskId);
479
+ if (!agentState || !node) {
480
+ this.statistics.consistencyChecksFailed++;
481
+ return false;
482
+ }
483
+ // Define expected mappings
484
+ const expectedMappings = {
485
+ [AgentState.IDLE]: [
486
+ DependencyNodeStatus.PENDING,
487
+ DependencyNodeStatus.READY
488
+ ],
489
+ [AgentState.WORKING]: [
490
+ DependencyNodeStatus.EXECUTING
491
+ ],
492
+ [AgentState.WAITING]: [
493
+ DependencyNodeStatus.PENDING
494
+ ],
495
+ [AgentState.COMPLETED]: [
496
+ DependencyNodeStatus.COMPLETED
497
+ ],
498
+ [AgentState.ERROR]: [
499
+ DependencyNodeStatus.FAILED
500
+ ],
501
+ [AgentState.BLOCKED]: [
502
+ DependencyNodeStatus.FAILED,
503
+ DependencyNodeStatus.PENDING
504
+ ],
505
+ [AgentState.HELPING]: [
506
+ DependencyNodeStatus.EXECUTING
507
+ ],
508
+ [AgentState.PAUSED]: [
509
+ DependencyNodeStatus.EXECUTING,
510
+ DependencyNodeStatus.PENDING
511
+ ],
512
+ [AgentState.TERMINATED]: [
513
+ DependencyNodeStatus.COMPLETED,
514
+ DependencyNodeStatus.FAILED
515
+ ]
516
+ };
517
+ const allowedStatuses = expectedMappings[agentState] || [];
518
+ const isConsistent = allowedStatuses.includes(node.status);
519
+ if (isConsistent) {
520
+ this.statistics.consistencyChecksPassed++;
521
+ } else {
522
+ this.statistics.consistencyChecksFailed++;
523
+ this.logger.warn('State inconsistency detected', {
524
+ agentId,
525
+ taskId,
526
+ agentState,
527
+ taskStatus: node.status,
528
+ expectedTaskStatuses: allowedStatuses
529
+ });
530
+ }
531
+ return isConsistent;
532
+ }
533
+ /**
534
+ * Get task for agent
535
+ */ async getTaskForAgent(agentId) {
536
+ const mapping = this.agentTaskMappings.get(agentId);
537
+ return mapping?.taskId;
538
+ }
539
+ /**
540
+ * Get agent for task
541
+ */ getAgentForTask(taskId) {
542
+ return this.taskAgentMappings.get(taskId);
543
+ }
544
+ // ============================================
545
+ // Public API
546
+ // ============================================
547
+ /**
548
+ * Start the integration layer
549
+ * Begins automatic agent assignment and scheduling
550
+ */ async start() {
551
+ if (this.isRunning) {
552
+ this.logger.warn('Integration already running');
553
+ return;
554
+ }
555
+ this.isRunning = true;
556
+ // Start automatic task scheduling loop
557
+ if (this.config.autoAssignAgents) {
558
+ this.schedulingInterval = setInterval(()=>{
559
+ this.processReadyTasks();
560
+ }, 1000); // Check every second
561
+ }
562
+ this.logger.info('StateMachineIntegration started');
563
+ }
564
+ /**
565
+ * Stop the integration layer
566
+ */ async stop() {
567
+ if (!this.isRunning) {
568
+ return;
569
+ }
570
+ this.isRunning = false;
571
+ // Clear scheduling interval
572
+ if (this.schedulingInterval) {
573
+ clearInterval(this.schedulingInterval);
574
+ this.schedulingInterval = undefined;
575
+ }
576
+ this.logger.info('StateMachineIntegration stopped');
577
+ }
578
+ /**
579
+ * Process ready tasks and assign to available agents
580
+ */ async processReadyTasks() {
581
+ try {
582
+ const readyTasks = this.graph.getReadyTasks();
583
+ for (const node of readyTasks){
584
+ // Skip if already assigned
585
+ if (this.taskAgentMappings.has(node.taskId)) {
586
+ continue;
587
+ }
588
+ // Find available agent
589
+ const agentId = await this.findAvailableAgent();
590
+ if (!agentId) {
591
+ break; // No more agents available
592
+ }
593
+ // Assign task
594
+ await this.assignTaskToAgent(node.taskId, agentId);
595
+ }
596
+ } catch (error) {
597
+ this.logger.error('Error processing ready tasks', {
598
+ error: error instanceof Error ? error.message : String(error)
599
+ });
600
+ }
601
+ }
602
+ /**
603
+ * Get integration statistics
604
+ */ getStatistics() {
605
+ return {
606
+ ...this.statistics
607
+ };
608
+ }
609
+ /**
610
+ * Get all active agent-task assignments
611
+ */ getActiveAssignments() {
612
+ return Array.from(this.agentTaskMappings.values());
613
+ }
614
+ /**
615
+ * Cleanup and reset integration state
616
+ */ async cleanup() {
617
+ await this.stop();
618
+ this.agentTaskMappings.clear();
619
+ this.taskAgentMappings.clear();
620
+ this.taskRetryCount.clear();
621
+ this.statistics = {
622
+ totalAssignments: 0,
623
+ totalCompletions: 0,
624
+ totalFailures: 0,
625
+ totalRetries: 0,
626
+ activeAssignments: 0,
627
+ consistencyChecksPassed: 0,
628
+ consistencyChecksFailed: 0
629
+ };
630
+ this.removeAllListeners();
631
+ this.logger.info('StateMachineIntegration cleaned up');
632
+ }
633
+ }
634
+
635
+ //# sourceMappingURL=state-machine-integration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../src/coordination/archives/v2-sdk-typescript/v2/integration/state-machine-integration.ts"],"names":["EventEmitter","AgentState","DependencyNodeStatus","Logger","StateMachineIntegration","logger","stateMachine","scheduler","graph","config","agentTaskMappings","taskAgentMappings","taskRetryCount","statistics","isRunning","schedulingInterval","level","format","destination","autoAssignAgents","maxRetryAttempts","validateTaskStatus","enableConsistencyChecks","Map","totalAssignments","totalCompletions","totalFailures","totalRetries","activeAssignments","consistencyChecksPassed","consistencyChecksFailed","setupEventListeners","info","on","onAgentStateChange","bind","onTaskScheduled","onTaskCompleted","onTaskFailed","debug","event","agentId","fromState","toState","timestamp","mapping","get","taskId","node","getNode","warn","status","WORKING","updateTaskStatus","EXECUTING","startedAt","Date","now","COMPLETED","completedAt","onTaskComplete","clearAgentAssignment","BLOCKED","ERROR","error","Error","handleTaskFailure","WAITING","PENDING","waitingAt","IDLE","validateStateConsistency","message","String","priority","dependenciesMet","findAvailableAgent","assignTaskToAgent","completionTime","newlyReadyTasks","currentState","getState","transition","metadata","emit","handlingError","assignedAt","set","allStates","getAllStates","state","has","undefined","delete","retryCount","attempt","maxAttempts","READY","lastError","scheduleTask","attempts","FAILED","failedAt","currentStatus","isValidTaskStatusTransition","mutableNode","_status","_metadata","_updatedAt","current","next","validTransitions","includes","agentState","expectedMappings","HELPING","PAUSED","TERMINATED","allowedStatuses","isConsistent","taskStatus","expectedTaskStatuses","getTaskForAgent","getAgentForTask","start","setInterval","processReadyTasks","stop","clearInterval","readyTasks","getReadyTasks","getStatistics","getActiveAssignments","Array","from","values","cleanup","clear","removeAllListeners"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;CAmBC,GAED,SAASA,YAAY,QAAQ,cAAc;AAE3C,SAASC,UAAU,QAAQ,mCAAmC;AAG9D,SAAyBC,oBAAoB,QAAQ,6BAA6B;AAClF,SAASC,MAAM,QAAQ,0BAA0B;AA6DjD;;;;;;;;;CASC,GACD,OAAO,MAAMC,gCAAgCJ;IAC1BK,OAAe;IACfC,aAA2B;IAC3BC,UAAyB;IACzBC,MAAuB;IACvBC,OAAoC;IAE7CC,kBAAiD;IACjDC,kBAAuC;IACvCC,eAAoC;IACpCC,WAAkC;IAClCC,UAAmB;IACnBC,mBAAoC;IAE5C,YACET,YAA0B,EAC1BC,SAAwB,EACxBC,KAAsB,EACtBC,MAAmC,CACnC;QACA,KAAK;QAEL,IAAI,CAACJ,MAAM,GAAG,IAAIF,OAAO;YACvBa,OAAO;YACPC,QAAQ;YACRC,aAAa;QACf;QAEA,IAAI,CAACZ,YAAY,GAAGA;QACpB,IAAI,CAACC,SAAS,GAAGA;QACjB,IAAI,CAACC,KAAK,GAAGA;QAEb,IAAI,CAACC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