claude-flow-novice 1.6.3 → 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 (290) hide show
  1. package/.claude/commands/parse-epic.js +180 -0
  2. package/.claude/settings.json +12 -2
  3. package/.claude/settings.local.json +4 -2
  4. package/.claude-flow-novice/dist/mcp/mcp-server-novice.js +37 -2
  5. package/.claude-flow-novice/dist/mcp/transports/base.js +5 -0
  6. package/.claude-flow-novice/dist/mcp/transports/base.js.map +1 -0
  7. package/.claude-flow-novice/dist/mcp/transports/http.js +414 -0
  8. package/.claude-flow-novice/dist/mcp/transports/http.js.map +1 -0
  9. package/.claude-flow-novice/dist/mcp/transports/stdio.js +217 -0
  10. package/.claude-flow-novice/dist/mcp/transports/stdio.js.map +1 -0
  11. package/.claude-flow-novice/dist/src/cli/commands/parse-epic.js +129 -0
  12. package/.claude-flow-novice/dist/src/cli/commands/parse-epic.js.map +1 -0
  13. package/.claude-flow-novice/dist/src/cli/index.js +3 -0
  14. package/.claude-flow-novice/dist/src/cli/index.js.map +1 -1
  15. package/.claude-flow-novice/dist/src/cli/utils/epic-parser.js +266 -0
  16. package/.claude-flow-novice/dist/src/cli/utils/epic-parser.js.map +1 -0
  17. package/.claude-flow-novice/dist/src/communication/message-bus.js +105 -2
  18. package/.claude-flow-novice/dist/src/communication/message-bus.js.map +1 -1
  19. package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js +1 -1
  20. package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js.map +1 -1
  21. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/artifact-cache-optimizer.js +632 -0
  22. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/artifact-cache-optimizer.js.map +1 -0
  23. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/index.js +11 -0
  24. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/index.js.map +1 -0
  25. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/checkpoints/checkpoint-compressor.js +318 -0
  26. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/checkpoints/checkpoint-compressor.js.map +1 -0
  27. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/completion-detector.js +234 -0
  28. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/completion-detector.js.map +1 -0
  29. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/hierarchical-detector.js +347 -0
  30. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/hierarchical-detector.js.map +1 -0
  31. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/index.js +13 -0
  32. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/index.js.map +1 -0
  33. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/lamport-clock.js +173 -0
  34. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/lamport-clock.js.map +1 -0
  35. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/mesh-detector.js +526 -0
  36. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/mesh-detector.js.map +1 -0
  37. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/sdk-completion-detector.js +443 -0
  38. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/sdk-completion-detector.js.map +1 -0
  39. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/swarm-shutdown.js +366 -0
  40. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/swarm-shutdown.js.map +1 -0
  41. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinator-factory.js +287 -0
  42. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinator-factory.js.map +1 -0
  43. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.example.js +364 -0
  44. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.example.js.map +1 -0
  45. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.js +492 -0
  46. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.js.map +1 -0
  47. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/hierarchical-coordinator.js +786 -0
  48. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/hierarchical-coordinator.js.map +1 -0
  49. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/index.js +16 -0
  50. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/index.js.map +1 -0
  51. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/parent-child-manager.js +342 -0
  52. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/parent-child-manager.js.map +1 -0
  53. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/swarm-coordinator-v2.js +601 -0
  54. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/swarm-coordinator-v2.js.map +1 -0
  55. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/agent-state.js +9 -0
  56. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/agent-state.js.map +1 -0
  57. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dead-letter-queue.js +413 -0
  58. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dead-letter-queue.js.map +1 -0
  59. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-graph.js +471 -0
  60. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-graph.js.map +1 -0
  61. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-node.js +379 -0
  62. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-node.js.map +1 -0
  63. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-resolver.js +335 -0
  64. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-resolver.js.map +1 -0
  65. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/help-request-metrics.js +211 -0
  66. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/help-request-metrics.js.map +1 -0
  67. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/index.js +33 -0
  68. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/index.js.map +1 -0
  69. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-broker.js +920 -0
  70. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-broker.js.map +1 -0
  71. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-router.js +385 -0
  72. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-router.js.map +1 -0
  73. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message.js +138 -0
  74. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message.js.map +1 -0
  75. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/resource-manager-safe.js +478 -0
  76. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/resource-manager-safe.js.map +1 -0
  77. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine-config.js +358 -0
  78. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine-config.js.map +1 -0
  79. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine.js +588 -0
  80. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine.js.map +1 -0
  81. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-transition.js +153 -0
  82. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-transition.js.map +1 -0
  83. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/task-scheduler.js +360 -0
  84. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/task-scheduler.js.map +1 -0
  85. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/topic-manager.js +337 -0
  86. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/topic-manager.js.map +1 -0
  87. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/deadlock-detector.js +424 -0
  88. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/deadlock-detector.js.map +1 -0
  89. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/index.js +9 -0
  90. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/index.js.map +1 -0
  91. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/resource-manager.js +669 -0
  92. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/resource-manager.js.map +1 -0
  93. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/artifact-storage.js +451 -0
  94. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/artifact-storage.js.map +1 -0
  95. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/cycle-detector.js +271 -0
  96. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/cycle-detector.js.map +1 -0
  97. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-graph.js +335 -0
  98. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-graph.js.map +1 -0
  99. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-manager.js +439 -0
  100. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-manager.js.map +1 -0
  101. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-request.js +92 -0
  102. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-request.js.map +1 -0
  103. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/index.js +21 -0
  104. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/index.js.map +1 -0
  105. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/topological-sort.js +223 -0
  106. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/topological-sort.js.map +1 -0
  107. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-coordinator.js +436 -0
  108. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-coordinator.js.map +1 -0
  109. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-matcher.js +278 -0
  110. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-matcher.js.map +1 -0
  111. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request-handler.js +317 -0
  112. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request-handler.js.map +1 -0
  113. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request.js +273 -0
  114. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request.js.map +1 -0
  115. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/index.js +15 -0
  116. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/index.js.map +1 -0
  117. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/waiting-agent-pool.js +512 -0
  118. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/waiting-agent-pool.js.map +1 -0
  119. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/index.js +67 -0
  120. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/index.js.map +1 -0
  121. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/help-deadlock-integration.js +557 -0
  122. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/help-deadlock-integration.js.map +1 -0
  123. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/index.js +14 -0
  124. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/index.js.map +1 -0
  125. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.example.js +212 -0
  126. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.example.js.map +1 -0
  127. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.js +552 -0
  128. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.js.map +1 -0
  129. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/state-machine-integration.js +635 -0
  130. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/state-machine-integration.js.map +1 -0
  131. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/IArtifactStorage.js +28 -0
  132. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/IArtifactStorage.js.map +1 -0
  133. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ICoordinator.js +9 -0
  134. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ICoordinator.js.map +1 -0
  135. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ISessionStore.js +25 -0
  136. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ISessionStore.js.map +1 -0
  137. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/index.js +14 -0
  138. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/index.js.map +1 -0
  139. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/artifact-adapter.js +308 -0
  140. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/artifact-adapter.js.map +1 -0
  141. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/completion-storage.js +439 -0
  142. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/completion-storage.js.map +1 -0
  143. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-graph-storage.js +540 -0
  144. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-graph-storage.js.map +1 -0
  145. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-storage.js +367 -0
  146. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-storage.js.map +1 -0
  147. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/index.js +14 -0
  148. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/index.js.map +1 -0
  149. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/message-storage.js +518 -0
  150. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/message-storage.js.map +1 -0
  151. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/state-storage.js +377 -0
  152. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/state-storage.js.map +1 -0
  153. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channel.js +371 -0
  154. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channel.js.map +1 -0
  155. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/dependency-channel.js +355 -0
  156. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/dependency-channel.js.map +1 -0
  157. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/help-channel.js +424 -0
  158. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/help-channel.js.map +1 -0
  159. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/index.js +16 -0
  160. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/index.js.map +1 -0
  161. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/state-channel.js +295 -0
  162. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/state-channel.js.map +1 -0
  163. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/task-channel.js +411 -0
  164. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/task-channel.js.map +1 -0
  165. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/index.js +14 -0
  166. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/index.js.map +1 -0
  167. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-bus.js +387 -0
  168. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-bus.js.map +1 -0
  169. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-persistence.js +589 -0
  170. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-persistence.js.map +1 -0
  171. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-router.js +444 -0
  172. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-router.js.map +1 -0
  173. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/artifact-storage.js +560 -0
  174. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/artifact-storage.js.map +1 -0
  175. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/background-orchestrator.js +335 -0
  176. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/background-orchestrator.js.map +1 -0
  177. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/bash-output-monitor.js +104 -0
  178. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/bash-output-monitor.js.map +1 -0
  179. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/checkpoint-manager.js +847 -0
  180. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/checkpoint-manager.js.map +1 -0
  181. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/help-coordinator.js +470 -0
  182. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/help-coordinator.js.map +1 -0
  183. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/hierarchical-background-integration.js +450 -0
  184. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/hierarchical-background-integration.js.map +1 -0
  185. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/index.js +13 -0
  186. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/index.js.map +1 -0
  187. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/message-bus-integration.js +625 -0
  188. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/message-bus-integration.js.map +1 -0
  189. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/multi-level-control.js +545 -0
  190. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/multi-level-control.js.map +1 -0
  191. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-controller.js +740 -0
  192. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-controller.js.map +1 -0
  193. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-message-integration.js +415 -0
  194. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-message-integration.js.map +1 -0
  195. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/session-pool-optimizer.js +615 -0
  196. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/session-pool-optimizer.js.map +1 -0
  197. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-machine-integration.js +547 -0
  198. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-machine-integration.js.map +1 -0
  199. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-sdk-integration.js +342 -0
  200. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-sdk-integration.js.map +1 -0
  201. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/security/payload-validator.js +259 -0
  202. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/security/payload-validator.js.map +1 -0
  203. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/framework-registry.js +273 -0
  204. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/framework-registry.js.map +1 -0
  205. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/index.js +8 -0
  206. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/index.js.map +1 -0
  207. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-config-manager.js +310 -0
  208. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-config-manager.js.map +1 -0
  209. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-validator.js +218 -0
  210. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-validator.js.map +1 -0
  211. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/types/sdk.js +9 -0
  212. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/types/sdk.js.map +1 -0
  213. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/index.js +6 -0
  214. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/index.js.map +1 -0
  215. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/priority-queue.js +145 -0
  216. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/priority-queue.js.map +1 -0
  217. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/sdk-helpers.js +122 -0
  218. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/sdk-helpers.js.map +1 -0
  219. package/.claude-flow-novice/dist/src/coordination/config-translator.js +17 -43
  220. package/.claude-flow-novice/dist/src/coordination/config-translator.js.map +1 -1
  221. package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js +34 -76
  222. package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js.map +1 -1
  223. package/.claude-flow-novice/dist/src/coordination/index.js +3 -0
  224. package/.claude-flow-novice/dist/src/coordination/index.js.map +1 -1
  225. package/.claude-flow-novice/dist/src/coordination/shared/core/agent-state.js +172 -0
  226. package/.claude-flow-novice/dist/src/coordination/shared/core/agent-state.js.map +1 -0
  227. package/.claude-flow-novice/dist/src/coordination/shared/core/index.js +7 -0
  228. package/.claude-flow-novice/dist/src/coordination/shared/core/index.js.map +1 -0
  229. package/.claude-flow-novice/dist/src/coordination/shared/index.js +19 -0
  230. package/.claude-flow-novice/dist/src/coordination/shared/index.js.map +1 -0
  231. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/ICoordinator.js +24 -0
  232. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/ICoordinator.js.map +1 -0
  233. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/index.js +7 -0
  234. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/index.js.map +1 -0
  235. package/.claude-flow-novice/dist/src/coordination/shared/message-broker.js +920 -0
  236. package/.claude-flow-novice/dist/src/coordination/shared/message-broker.js.map +1 -0
  237. package/.claude-flow-novice/dist/src/coordination/shared/message.js +138 -0
  238. package/.claude-flow-novice/dist/src/coordination/shared/message.js.map +1 -0
  239. package/.claude-flow-novice/dist/src/coordination/shared/security/payload-validator.js +259 -0
  240. package/.claude-flow-novice/dist/src/coordination/shared/security/payload-validator.js.map +1 -0
  241. package/.claude-flow-novice/dist/src/coordination/shared/transparency/index.js +17 -0
  242. package/.claude-flow-novice/dist/src/coordination/shared/transparency/index.js.map +1 -0
  243. package/.claude-flow-novice/dist/src/coordination/shared/transparency/interfaces/transparency-system.js +19 -0
  244. package/.claude-flow-novice/dist/src/coordination/shared/transparency/interfaces/transparency-system.js.map +1 -0
  245. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-integration.js +357 -0
  246. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-integration.js.map +1 -0
  247. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-system.js +679 -0
  248. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-system.js.map +1 -0
  249. package/.claude-flow-novice/dist/src/coordination/shared/types/index.js +7 -0
  250. package/.claude-flow-novice/dist/src/coordination/shared/types/index.js.map +1 -0
  251. package/.claude-flow-novice/dist/src/coordination/shared/types/sdk.js +10 -0
  252. package/.claude-flow-novice/dist/src/coordination/shared/types/sdk.js.map +1 -0
  253. package/.claude-flow-novice/dist/src/coordination/v1-transparency/interfaces/v1-transparency-system.js +12 -0
  254. package/.claude-flow-novice/dist/src/coordination/v1-transparency/interfaces/v1-transparency-system.js.map +1 -0
  255. package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-to-v2-bridge.js +433 -0
  256. package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-to-v2-bridge.js.map +1 -0
  257. package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-transparency-adapter.js +1468 -0
  258. package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-transparency-adapter.js.map +1 -0
  259. package/.claude-flow-novice/dist/src/feature-flags/core/FeatureFlagManager.js +52 -2
  260. package/.claude-flow-novice/dist/src/feature-flags/core/FeatureFlagManager.js.map +1 -1
  261. package/.claude-flow-novice/dist/src/mcp/mcp-server-novice.js +37 -2
  262. package/.claude-flow-novice/dist/src/mcp/session-manager.js +3 -1
  263. package/.claude-flow-novice/dist/src/mcp/session-manager.js.map +1 -1
  264. package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js +5 -0
  265. package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js.map +1 -1
  266. package/.claude-flow-novice/dist/src/providers/provider-manager.js +41 -6
  267. package/.claude-flow-novice/dist/src/providers/provider-manager.js.map +1 -1
  268. package/.claude-flow-novice/dist/src/providers/tiered-router.js +9 -17
  269. package/.claude-flow-novice/dist/src/providers/tiered-router.js.map +1 -1
  270. package/.claude-flow-novice/dist/src/utils/markdown-sanitizer.js +65 -41
  271. package/.claude-flow-novice/dist/src/utils/markdown-sanitizer.js.map +1 -1
  272. package/.claude-flow-novice/dist/src/web/api/server.js +1 -1
  273. package/.claude-flow-novice/dist/src/web/api/server.js.map +1 -1
  274. package/.claude-flow-novice/dist/src/workflows/progressive-rollout-manager.js +30 -0
  275. package/.claude-flow-novice/dist/src/workflows/progressive-rollout-manager.js.map +1 -1
  276. package/.claude-flow-novice/metrics.db +0 -0
  277. package/.claude-flow-novice/metrics.db-shm +0 -0
  278. package/.claude-flow-novice/metrics.db-wal +0 -0
  279. package/CLAUDE.md +72 -0
  280. package/config/hooks/post-edit-pipeline.js +68 -118
  281. package/config/hooks/pre-tool-memory-safety.js +209 -0
  282. package/package.json +7 -4
  283. package/scripts/cleanup-idle-sessions.sh +59 -0
  284. package/scripts/monitoring/alert-monitor.sh +220 -0
  285. package/scripts/monitoring/view-alerts.sh +307 -0
  286. package/scripts/test-provider-routing.cjs +7 -9
  287. package/scripts/test-zai-api.cjs +2 -2
  288. package/src/slash-commands/parse-epic.js +1 -1
  289. package/wiki/Provider-Routing.md +57 -69
  290. package/MEMORY_LEAK_ROOT_CAUSE.md +0 -149
@@ -0,0 +1,588 @@
1
+ /**
2
+ * Agent Coordination V2 - Core State Machine
3
+ *
4
+ * Manages agent lifecycle through 7 distinct states with SDK integration.
5
+ * Features:
6
+ * - Auto-checkpoint on state transitions
7
+ * - Zero-cost pausing during transitions
8
+ * - Artifact-backed state persistence
9
+ * - <100ms transition latency (p99)
10
+ *
11
+ * @module coordination/v2/core/state-machine
12
+ */ import { EventEmitter } from 'node:events';
13
+ import { AgentState } from './agent-state.js';
14
+ import { Logger } from '../../../core/logger.js';
15
+ import { STATE_TRANSITIONS } from './state-machine-config.js';
16
+ import { HelpRequestTracker } from './help-request-metrics.js';
17
+ /**
18
+ * StateMachine - Core state machine managing agent lifecycle
19
+ *
20
+ * Responsibilities:
21
+ * 1. Validate state transitions using STATE_TRANSITIONS matrix
22
+ * 2. Pause agents during transitions (zero token cost)
23
+ * 3. Create checkpoints BEFORE state changes
24
+ * 4. Persist state to artifact storage
25
+ * 5. Broadcast state changes via SDK events
26
+ * 6. Resume agents after transitions
27
+ */ export class StateMachine extends EventEmitter {
28
+ logger;
29
+ config;
30
+ queryController;
31
+ checkpointManager;
32
+ stateStorage;
33
+ helpRequestTracker;
34
+ agentStates;
35
+ agentSessions;
36
+ metrics;
37
+ transitionLatencies;
38
+ transitionLock;
39
+ constructor(queryController, checkpointManager, stateStorage, config){
40
+ super();
41
+ this.logger = new Logger({
42
+ level: 'info',
43
+ format: 'text',
44
+ destination: 'console'
45
+ });
46
+ this.config = {
47
+ autoCheckpoint: config?.autoCheckpoint ?? true,
48
+ pauseDuringTransition: config?.pauseDuringTransition ?? true,
49
+ maxTransitionLatencyMs: config?.maxTransitionLatencyMs ?? 100,
50
+ validateTransitions: config?.validateTransitions ?? true
51
+ };
52
+ this.queryController = queryController;
53
+ this.checkpointManager = checkpointManager;
54
+ this.stateStorage = stateStorage;
55
+ this.helpRequestTracker = new HelpRequestTracker();
56
+ this.agentStates = new Map();
57
+ this.agentSessions = new Map();
58
+ this.transitionLock = new Map();
59
+ this.transitionLatencies = [];
60
+ this.metrics = {
61
+ totalTransitions: 0,
62
+ successfulTransitions: 0,
63
+ failedTransitions: 0,
64
+ averageTransitionLatencyMs: 0,
65
+ p99TransitionLatencyMs: 0,
66
+ totalCheckpointsCreated: 0,
67
+ invalidTransitionAttempts: 0
68
+ };
69
+ this.logger.info('StateMachine initialized', {
70
+ autoCheckpoint: this.config.autoCheckpoint,
71
+ pauseDuringTransition: this.config.pauseDuringTransition
72
+ });
73
+ }
74
+ /**
75
+ * Register agent with state machine
76
+ */ async registerAgent(agentId, sessionId, initialState = AgentState.IDLE) {
77
+ this.agentStates.set(agentId, initialState);
78
+ this.agentSessions.set(agentId, sessionId);
79
+ // Persist initial state
80
+ await this.stateStorage.setState(agentId, initialState);
81
+ this.logger.debug('Agent registered', {
82
+ agentId,
83
+ sessionId,
84
+ initialState
85
+ });
86
+ }
87
+ /**
88
+ * Transition agent to new state with full SDK integration
89
+ *
90
+ * Process:
91
+ * 1. Validate transition
92
+ * 2. Pause agent (zero token cost)
93
+ * 3. Create checkpoint BEFORE state change
94
+ * 4. Update state in artifact storage
95
+ * 5. Broadcast state change via events
96
+ * 6. Resume agent after transition
97
+ */ async transition(agentId, newState, optionsOrMetadata) {
98
+ // Support both calling patterns:
99
+ // 1. transition(id, state, { metadata: {...}, timeoutMs: 5000 }) - explicit options
100
+ // 2. transition(id, state, { reason: '...', context: {...} }) - direct metadata (legacy)
101
+ const hasExplicitOptions = optionsOrMetadata && ('timeoutMs' in optionsOrMetadata || 'metadata' in optionsOrMetadata);
102
+ const options = hasExplicitOptions ? optionsOrMetadata : {
103
+ metadata: optionsOrMetadata
104
+ };
105
+ const timeout = options?.timeoutMs || 30000; // 30s default
106
+ const metadata = options?.metadata;
107
+ const startTime = performance.now();
108
+ // STRENGTHEN: Wait for existing transition to complete before proceeding
109
+ const existingTransition = this.transitionLock.get(agentId);
110
+ if (existingTransition) {
111
+ this.logger.warn('Concurrent transition detected, waiting for lock release', {
112
+ agentId,
113
+ newState
114
+ });
115
+ try {
116
+ // Wait for existing transition to complete
117
+ await existingTransition;
118
+ } catch (error) {
119
+ // Lock released after error, can proceed with new transition
120
+ this.logger.debug('Previous transition failed, proceeding with new transition', {
121
+ agentId
122
+ });
123
+ }
124
+ // Lock released, proceed with fresh state check
125
+ }
126
+ // Create transition promise with timeout protection
127
+ const transitionPromise = this.executeTransition(agentId, newState, metadata, startTime);
128
+ const timeoutPromise = new Promise((_, reject)=>setTimeout(()=>reject(new Error(`Transition timeout after ${timeout}ms`)), timeout));
129
+ this.transitionLock.set(agentId, transitionPromise);
130
+ try {
131
+ const result = await Promise.race([
132
+ transitionPromise,
133
+ timeoutPromise
134
+ ]);
135
+ return result;
136
+ } catch (error) {
137
+ // Ensure agent resumed even on timeout
138
+ try {
139
+ await this.queryController.resumeAgent(agentId);
140
+ } catch (resumeError) {
141
+ this.logger.error('Failed to resume agent after timeout', {
142
+ agentId,
143
+ error: resumeError instanceof Error ? resumeError.message : String(resumeError)
144
+ });
145
+ }
146
+ // Return error result instead of throwing
147
+ return {
148
+ success: false,
149
+ fromState: this.agentStates.get(agentId) || AgentState.IDLE,
150
+ toState: newState,
151
+ latencyMs: performance.now() - startTime,
152
+ error: error instanceof Error ? error.message : String(error)
153
+ };
154
+ } finally{
155
+ this.transitionLock.delete(agentId);
156
+ }
157
+ }
158
+ /**
159
+ * Execute state transition (internal implementation)
160
+ */ async executeTransition(agentId, newState, metadata, startTime) {
161
+ const currentState = this.agentStates.get(agentId);
162
+ const sessionId = this.agentSessions.get(agentId);
163
+ if (!currentState || !sessionId) {
164
+ this.metrics.failedTransitions++;
165
+ return {
166
+ success: false,
167
+ fromState: AgentState.IDLE,
168
+ toState: newState,
169
+ latencyMs: performance.now() - startTime,
170
+ error: `Agent ${agentId} not registered`
171
+ };
172
+ }
173
+ // Skip if already in target state
174
+ if (currentState === newState) {
175
+ return {
176
+ success: true,
177
+ fromState: currentState,
178
+ toState: newState,
179
+ latencyMs: performance.now() - startTime
180
+ };
181
+ }
182
+ // Step 1: Validate transition
183
+ if (this.config.validateTransitions) {
184
+ if (!this.validateTransition(currentState, newState)) {
185
+ this.metrics.invalidTransitionAttempts++;
186
+ this.metrics.failedTransitions++;
187
+ const error = `Invalid state transition: ${currentState} -> ${newState}`;
188
+ this.logger.error(error, {
189
+ agentId,
190
+ currentState,
191
+ newState
192
+ });
193
+ return {
194
+ success: false,
195
+ fromState: currentState,
196
+ toState: newState,
197
+ latencyMs: performance.now() - startTime,
198
+ error
199
+ };
200
+ }
201
+ }
202
+ let checkpointId;
203
+ let wasPaused = false;
204
+ try {
205
+ // Step 2: Pause agent during transition (zero token cost)
206
+ if (this.config.pauseDuringTransition) {
207
+ const session = await this.queryController.getAgentSession(agentId);
208
+ if (!session.isPaused) {
209
+ await this.queryController.pauseAgent(agentId, `State transition: ${currentState} -> ${newState}`);
210
+ wasPaused = true;
211
+ }
212
+ }
213
+ // Step 3: Create checkpoint BEFORE state change
214
+ if (this.config.autoCheckpoint) {
215
+ const session = await this.queryController.getAgentSession(agentId);
216
+ const messageUUID = session.currentMessageUUID || `transition_${Date.now()}`;
217
+ checkpointId = await this.checkpointManager.createCheckpoint(sessionId, agentId, messageUUID, currentState, {
218
+ currentState,
219
+ metadata: metadata || {}
220
+ }, {
221
+ reason: `State transition: ${currentState} -> ${newState}`,
222
+ autoCheckpoint: true,
223
+ context: metadata
224
+ });
225
+ this.metrics.totalCheckpointsCreated++;
226
+ }
227
+ // Step 4: Update state in artifact storage
228
+ await this.stateStorage.setState(agentId, newState, checkpointId);
229
+ // VERIFY: Ensure state consistency after storage update
230
+ const verifiedState = await this.stateStorage.getState(agentId);
231
+ if (verifiedState !== newState) {
232
+ throw new Error(`State consistency check failed for ${agentId}: expected ${newState}, got ${verifiedState}`);
233
+ }
234
+ // Step 5: Update in-memory state
235
+ this.agentStates.set(agentId, newState);
236
+ // Step 6: Broadcast state change via SDK events
237
+ const event = {
238
+ agentId,
239
+ sessionId,
240
+ fromState: currentState,
241
+ toState: newState,
242
+ timestamp: new Date(),
243
+ checkpointId,
244
+ latencyMs: performance.now() - startTime,
245
+ metadata
246
+ };
247
+ this.emit('state:transition', event);
248
+ // Step 7: Resume agent after transition
249
+ if (wasPaused && this.config.pauseDuringTransition) {
250
+ await this.queryController.resumeAgent(agentId, checkpointId);
251
+ }
252
+ // Update metrics
253
+ const latencyMs = performance.now() - startTime;
254
+ this.metrics.totalTransitions++;
255
+ this.metrics.successfulTransitions++;
256
+ this.updateLatencyMetrics(latencyMs);
257
+ // Warn if exceeding latency budget
258
+ if (latencyMs > this.config.maxTransitionLatencyMs) {
259
+ this.logger.warn('State transition exceeded latency budget', {
260
+ agentId,
261
+ latencyMs: latencyMs.toFixed(2),
262
+ budget: this.config.maxTransitionLatencyMs,
263
+ transition: `${currentState} -> ${newState}`
264
+ });
265
+ }
266
+ this.logger.info('State transition completed', {
267
+ agentId,
268
+ transition: `${currentState} -> ${newState}`,
269
+ latencyMs: latencyMs.toFixed(2),
270
+ checkpointId
271
+ });
272
+ return {
273
+ success: true,
274
+ fromState: currentState,
275
+ toState: newState,
276
+ checkpointId,
277
+ latencyMs
278
+ };
279
+ } catch (error) {
280
+ this.metrics.failedTransitions++;
281
+ const errorMessage = error instanceof Error ? error.message : String(error);
282
+ this.logger.error('State transition failed', {
283
+ agentId,
284
+ transition: `${currentState} -> ${newState}`,
285
+ error: errorMessage
286
+ });
287
+ // Attempt to resume if we paused
288
+ if (wasPaused) {
289
+ try {
290
+ await this.queryController.resumeAgent(agentId);
291
+ } catch (resumeError) {
292
+ this.logger.error('Failed to resume agent after transition error', {
293
+ agentId,
294
+ resumeError: resumeError instanceof Error ? resumeError.message : String(resumeError)
295
+ });
296
+ }
297
+ }
298
+ return {
299
+ success: false,
300
+ fromState: currentState,
301
+ toState: newState,
302
+ latencyMs: performance.now() - startTime,
303
+ error: errorMessage
304
+ };
305
+ }
306
+ }
307
+ /**
308
+ * Validate state transition using STATE_TRANSITIONS matrix
309
+ */ validateTransition(fromState, toState) {
310
+ const allowedTransitions = STATE_TRANSITIONS[fromState];
311
+ return allowedTransitions.includes(toState);
312
+ }
313
+ /**
314
+ * Get current state for agent
315
+ */ getState(agentId) {
316
+ return this.agentStates.get(agentId);
317
+ }
318
+ /**
319
+ * Get all agent states
320
+ */ getAllStates() {
321
+ return new Map(this.agentStates);
322
+ }
323
+ /**
324
+ * Restore agent state from checkpoint
325
+ */ async restoreFromCheckpoint(agentId, checkpointId) {
326
+ await this.stateStorage.restoreFromCheckpoint(agentId, checkpointId);
327
+ const restoredState = await this.stateStorage.getState(agentId);
328
+ if (restoredState) {
329
+ this.agentStates.set(agentId, restoredState);
330
+ this.logger.info('Agent state restored from checkpoint', {
331
+ agentId,
332
+ checkpointId,
333
+ restoredState
334
+ });
335
+ }
336
+ }
337
+ /**
338
+ * Unregister agent and cleanup
339
+ */ async unregisterAgent(agentId) {
340
+ this.agentStates.delete(agentId);
341
+ this.agentSessions.delete(agentId);
342
+ await this.stateStorage.deleteState(agentId);
343
+ this.logger.debug('Agent unregistered', {
344
+ agentId
345
+ });
346
+ }
347
+ /**
348
+ * Get state machine metrics
349
+ */ getMetrics() {
350
+ return {
351
+ ...this.metrics
352
+ };
353
+ }
354
+ /**
355
+ * Reset metrics (for testing)
356
+ */ resetMetrics() {
357
+ this.metrics = {
358
+ totalTransitions: 0,
359
+ successfulTransitions: 0,
360
+ failedTransitions: 0,
361
+ averageTransitionLatencyMs: 0,
362
+ p99TransitionLatencyMs: 0,
363
+ totalCheckpointsCreated: 0,
364
+ invalidTransitionAttempts: 0
365
+ };
366
+ this.transitionLatencies = [];
367
+ }
368
+ /**
369
+ * Update latency metrics
370
+ */ updateLatencyMetrics(latencyMs) {
371
+ this.transitionLatencies.push(latencyMs);
372
+ // FIX: Implement periodic cleanup BEFORE reaching 1000
373
+ if (this.transitionLatencies.length >= 100) {
374
+ // Keep only recent 100 samples for rolling statistics
375
+ this.transitionLatencies = this.transitionLatencies.slice(-100);
376
+ }
377
+ // Update average
378
+ this.metrics.averageTransitionLatencyMs = (this.metrics.averageTransitionLatencyMs * (this.metrics.successfulTransitions - 1) + latencyMs) / this.metrics.successfulTransitions;
379
+ // Update p99 from current sample set
380
+ if (this.transitionLatencies.length > 0) {
381
+ const sorted = [
382
+ ...this.transitionLatencies
383
+ ].sort((a, b)=>a - b);
384
+ const p99Index = Math.floor(sorted.length * 0.99);
385
+ this.metrics.p99TransitionLatencyMs = sorted[p99Index] || sorted[sorted.length - 1];
386
+ }
387
+ }
388
+ /**
389
+ * Request help: Transition agent from WAITING to HELPING with checkpoint preservation
390
+ *
391
+ * @param requestingAgentId - Agent in WAITING state requesting help
392
+ * @param helperAgentId - Agent that will transition to HELPING state
393
+ * @param reason - Reason for help request
394
+ * @returns Help request ID and checkpoint ID for recovery
395
+ */ async requestHelp(requestingAgentId, helperAgentId, reason) {
396
+ const startTime = performance.now();
397
+ // Validate requesting agent is in WAITING state
398
+ const requestingState = this.agentStates.get(requestingAgentId);
399
+ if (requestingState !== AgentState.WAITING) {
400
+ throw new Error(`Agent ${requestingAgentId} must be in WAITING state to request help (current: ${requestingState})`);
401
+ }
402
+ // Validate helper agent can transition to HELPING
403
+ const helperState = this.agentStates.get(helperAgentId);
404
+ if (!helperState) {
405
+ throw new Error(`Helper agent ${helperAgentId} not registered`);
406
+ }
407
+ // Create help request
408
+ const requestId = this.helpRequestTracker.createHelpRequest(requestingAgentId, helperAgentId, reason);
409
+ // Create checkpoint BEFORE transitioning helper to HELPING state
410
+ let checkpointId;
411
+ const helperSessionId = this.agentSessions.get(helperAgentId);
412
+ if (helperSessionId && this.config.autoCheckpoint) {
413
+ const session = await this.queryController.getAgentSession(helperAgentId);
414
+ const messageUUID = session.currentMessageUUID || `help_request_${Date.now()}`;
415
+ checkpointId = await this.checkpointManager.createCheckpoint(helperSessionId, helperAgentId, messageUUID, helperState, {
416
+ currentState: helperState,
417
+ helpRequestId: requestId,
418
+ requestingAgentId,
419
+ reason
420
+ }, {
421
+ reason: `Help request: ${helperAgentId} helping ${requestingAgentId}`,
422
+ autoCheckpoint: true,
423
+ context: {
424
+ helpRequestId: requestId,
425
+ requestingAgentId,
426
+ reason
427
+ }
428
+ });
429
+ this.logger.info('Help checkpoint created', {
430
+ helperAgentId,
431
+ checkpointId,
432
+ requestId
433
+ });
434
+ }
435
+ // Transition helper to HELPING state (atomic with checkpoint)
436
+ const transitionResult = await this.transition(helperAgentId, AgentState.HELPING, {
437
+ metadata: {
438
+ helpRequestId: requestId,
439
+ requestingAgentId,
440
+ checkpointId,
441
+ reason
442
+ }
443
+ });
444
+ if (!transitionResult.success) {
445
+ this.helpRequestTracker.failHelp(requestId, transitionResult.error || 'Transition failed');
446
+ throw new Error(`Failed to transition ${helperAgentId} to HELPING: ${transitionResult.error}`);
447
+ }
448
+ // Mark help as started
449
+ this.helpRequestTracker.startHelp(requestId, checkpointId);
450
+ const latencyMs = performance.now() - startTime;
451
+ this.logger.info('Help request created', {
452
+ requestId,
453
+ requestingAgentId,
454
+ helperAgentId,
455
+ checkpointId,
456
+ latencyMs: latencyMs.toFixed(2)
457
+ });
458
+ // Emit help request event
459
+ this.emit('help:requested', {
460
+ requestId,
461
+ requestingAgentId,
462
+ helperAgentId,
463
+ checkpointId,
464
+ timestamp: new Date()
465
+ });
466
+ return {
467
+ requestId,
468
+ checkpointId
469
+ };
470
+ }
471
+ /**
472
+ * Complete help: Restore helper from checkpoint and transition back to original state
473
+ *
474
+ * @param requestId - Help request ID
475
+ * @returns Recovery result with latency metrics
476
+ */ async completeHelp(requestId) {
477
+ const startTime = performance.now();
478
+ const helpRequest = this.helpRequestTracker.getHelpRequest(requestId);
479
+ if (!helpRequest) {
480
+ throw new Error(`Help request ${requestId} not found`);
481
+ }
482
+ const { helperAgentId, checkpointId } = helpRequest;
483
+ // Validate helper is in HELPING state
484
+ const helperState = this.agentStates.get(helperAgentId);
485
+ if (helperState !== AgentState.HELPING) {
486
+ this.logger.warn('Helper not in HELPING state during completion', {
487
+ helperAgentId,
488
+ currentState: helperState,
489
+ requestId
490
+ });
491
+ }
492
+ let recoveryLatencyMs = 0;
493
+ // Restore from checkpoint if available (preserves helper's original state)
494
+ if (checkpointId) {
495
+ const recoveryStart = performance.now();
496
+ try {
497
+ const restoreResult = await this.checkpointManager.restoreCheckpoint(checkpointId);
498
+ if (restoreResult.success) {
499
+ // Restore agent state from checkpoint
500
+ await this.restoreFromCheckpoint(helperAgentId, checkpointId);
501
+ recoveryLatencyMs = performance.now() - recoveryStart;
502
+ this.helpRequestTracker.trackCheckpointRecovery(recoveryLatencyMs);
503
+ this.logger.info('Helper state restored from checkpoint', {
504
+ helperAgentId,
505
+ checkpointId,
506
+ restoredState: restoreResult.restoredState,
507
+ recoveryLatencyMs: recoveryLatencyMs.toFixed(2)
508
+ });
509
+ // Verify p99 recovery time requirement (<500ms)
510
+ const metrics = this.helpRequestTracker.getMetrics();
511
+ if (recoveryLatencyMs > 500 && metrics.totalCheckpointRecoveries >= 100) {
512
+ this.logger.warn('Checkpoint recovery exceeded 500ms requirement', {
513
+ recoveryLatencyMs: recoveryLatencyMs.toFixed(2),
514
+ p99: metrics.p99CheckpointRecoveryMs.toFixed(2),
515
+ requirement: '500ms'
516
+ });
517
+ }
518
+ } else {
519
+ this.logger.error('Checkpoint restoration failed', {
520
+ helperAgentId,
521
+ checkpointId,
522
+ error: restoreResult.latencyMs
523
+ });
524
+ }
525
+ } catch (error) {
526
+ this.logger.error('Checkpoint recovery error', {
527
+ helperAgentId,
528
+ checkpointId,
529
+ error: error instanceof Error ? error.message : String(error)
530
+ });
531
+ }
532
+ } else {
533
+ // No checkpoint - default transition to WORKING
534
+ await this.transition(helperAgentId, AgentState.WORKING, {
535
+ metadata: {
536
+ helpRequestId: requestId,
537
+ reason: 'Help completed, no checkpoint'
538
+ }
539
+ });
540
+ }
541
+ // Mark help as completed
542
+ this.helpRequestTracker.completeHelp(requestId);
543
+ const totalLatencyMs = performance.now() - startTime;
544
+ this.logger.info('Help request completed', {
545
+ requestId,
546
+ helperAgentId,
547
+ recoveryLatencyMs: recoveryLatencyMs.toFixed(2),
548
+ totalLatencyMs: totalLatencyMs.toFixed(2)
549
+ });
550
+ // Emit help completion event
551
+ this.emit('help:completed', {
552
+ requestId,
553
+ helperAgentId,
554
+ recoveryLatencyMs,
555
+ timestamp: new Date()
556
+ });
557
+ return {
558
+ success: true,
559
+ recoveryLatencyMs
560
+ };
561
+ }
562
+ /**
563
+ * Get help request metrics
564
+ */ getHelpMetrics() {
565
+ return this.helpRequestTracker.getMetrics();
566
+ }
567
+ /**
568
+ * Get active help requests
569
+ */ getActiveHelpRequests() {
570
+ return this.helpRequestTracker.getActiveHelpRequests();
571
+ }
572
+ /**
573
+ * Cleanup state machine
574
+ */ async cleanup() {
575
+ this.logger.info('Cleaning up state machine', {
576
+ totalAgents: this.agentStates.size,
577
+ totalTransitions: this.metrics.totalTransitions
578
+ });
579
+ // Cleanup help request tracker
580
+ this.helpRequestTracker.cleanup();
581
+ this.agentStates.clear();
582
+ this.agentSessions.clear();
583
+ this.transitionLock.clear();
584
+ this.removeAllListeners();
585
+ }
586
+ }
587
+
588
+ //# sourceMappingURL=state-machine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../src/coordination/archives/v2-sdk-typescript/v2/core/state-machine.ts"],"names":["EventEmitter","AgentState","Logger","STATE_TRANSITIONS","HelpRequestTracker","StateMachine","logger","config","queryController","checkpointManager","stateStorage","helpRequestTracker","agentStates","agentSessions","metrics","transitionLatencies","transitionLock","level","format","destination","autoCheckpoint","pauseDuringTransition","maxTransitionLatencyMs","validateTransitions","Map","totalTransitions","successfulTransitions","failedTransitions","averageTransitionLatencyMs","p99TransitionLatencyMs","totalCheckpointsCreated","invalidTransitionAttempts","info","registerAgent","agentId","sessionId","initialState","IDLE","set","setState","debug","transition","newState","optionsOrMetadata","hasExplicitOptions","options","metadata","timeout","timeoutMs","startTime","performance","now","existingTransition","get","warn","error","transitionPromise","executeTransition","timeoutPromise","Promise","_","reject","setTimeout","Error","result","race","resumeAgent","resumeError","message","String","success","fromState","toState","latencyMs","delete","currentState","validateTransition","checkpointId","wasPaused","session","getAgentSession","isPaused","pauseAgent","messageUUID","currentMessageUUID","Date","createCheckpoint","reason","context","verifiedState","getState","event","timestamp","emit","updateLatencyMetrics","toFixed","budget","errorMessage","allowedTransitions","includes","getAllStates","restoreFromCheckpoint","restoredState","unregisterAgent","deleteState","getMetrics","resetMetrics","push","length","slice","sorted","sort","a","b","p99Index","Math","floor","requestHelp","requestingAgentId","helperAgentId","requestingState","WAITING","helperState","requestId","createHelpRequest","helperSessionId","helpRequestId","transitionResult","HELPING","failHelp","startHelp","completeHelp","helpRequest","getHelpRequest","recoveryLatencyMs","recoveryStart","restoreResult","restoreCheckpoint","trackCheckpointRecovery","totalCheckpointRecoveries","p99","p99CheckpointRecoveryMs","requirement","WORKING","totalLatencyMs","getHelpMetrics","getActiveHelpRequests","cleanup","totalAgents","size","clear","removeAllListeners"],"mappings":"AAAA;;;;;;;;;;;CAWC,GAED,SAASA,YAAY,QAAQ,cAAc;AAC3C,SAASC,UAAU,QAAQ,mBAAmB;AAG9C,SAASC,MAAM,QAAQ,0BAA0B;AACjD,SAASC,iBAAiB,QAA2B,4BAA4B;AACjF,SAASC,kBAAkB,QAAQ,4BAA4B;AAqE/D;;;;;;;;;;CAUC,GACD,OAAO,MAAMC,qBAAqBL;IACfM,OAAe;IACfC,OAAwC;IACxCC,gBAAiC;IACjCC,kBAAqC;IACrCC,aAA4B;IAC5BC,mBAAuC;IAEhDC,YAAqC;IACrCC,cAAmC;IACnCC,QAA6B;IAC7BC,oBAA8B;IAC9BC,eAA4D;IAEpE,YACER,eAAgC,EAChCC,iBAAoC,EACpCC,YAA2B,EAC3BH,MAAuC,CACvC;QACA,KAAK;QAEL,IAAI,CAACD,MAAM,GAAG,IAAIJ,OAAO;YACvBe,OAAO;YACPC,QAAQ;YACRC,aAAa;QACf;QAEA,IAAI,CAACZ,MAAM,GAAG;YACZa,gBAAgBb,QAAQa,kBAAkB;YAC1CC,uBAAuBd,QAAQc,yBAAyB;YACxDC,wBAAwBf,QAAQe,0BAA0B;YAC1DC,qBAAqBhB,QAAQgB,uB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