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,347 @@
1
+ /**
2
+ * Agent Coordination V2 - Hierarchical Completion Detection
3
+ *
4
+ * PM-based completion detection for hierarchical swarms.
5
+ * Project Manager checks all children are COMPLETED before declaring completion.
6
+ *
7
+ * Performance targets:
8
+ * - Detection: <1000ms for 20-agent swarm
9
+ * - Bottom-up traversal (leaves → root)
10
+ * - Zero false positives via checkpoint validation
11
+ *
12
+ * @module coordination/v2/completion/hierarchical-detector
13
+ */ import { AgentState } from '../../shared/core/agent-state.js';
14
+ import { CompletionDetector } from './completion-detector.js';
15
+ /**
16
+ * HierarchicalCompletionDetector
17
+ *
18
+ * Implements PM-based completion detection pattern:
19
+ * 1. Leaf agents complete their tasks
20
+ * 2. PM checks if all children are COMPLETED
21
+ * 3. If all children complete, PM can complete
22
+ * 4. Traverse bottom-up until root PM completes
23
+ * 5. Create checkpoint BEFORE declaring completion
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const detector = new HierarchicalCompletionDetector(
28
+ * stateMachine,
29
+ * messageBroker,
30
+ * checkpointManager,
31
+ * dependencyGraph,
32
+ * { autoCheckpoint: true }
33
+ * );
34
+ *
35
+ * // Register swarm hierarchy
36
+ * detector.registerSwarm('swarm-1', 'pm-1', [
37
+ * { agentId: 'agent-1', parentId: 'pm-1' },
38
+ * { agentId: 'agent-2', parentId: 'pm-1' },
39
+ * ]);
40
+ *
41
+ * // Detect completion (triggered by state transitions)
42
+ * const result = await detector.detectCompletion('swarm-1');
43
+ * console.log(result.completed); // true when all agents complete
44
+ * ```
45
+ */ export class HierarchicalCompletionDetector extends CompletionDetector {
46
+ swarms;
47
+ dependencyGraph;
48
+ constructor(stateMachine, messageBroker, checkpointManager, dependencyGraph, config){
49
+ super(stateMachine, messageBroker, checkpointManager, config);
50
+ this.swarms = new Map();
51
+ this.dependencyGraph = dependencyGraph;
52
+ if (this.config.enableLogging) {
53
+ this.log('HierarchicalCompletionDetector initialized', {
54
+ hasDependencyGraph: !!dependencyGraph
55
+ });
56
+ }
57
+ }
58
+ /**
59
+ * Register swarm hierarchy for completion tracking
60
+ *
61
+ * @param swarmId - Swarm identifier
62
+ * @param rootPmId - Root Project Manager agent ID
63
+ * @param agents - Agent hierarchy definitions
64
+ */ registerSwarm(swarmId, rootPmId, agents) {
65
+ const nodes = new Map();
66
+ // Build hierarchy nodes
67
+ for (const agent of agents){
68
+ const currentState = this.stateMachine.getState(agent.agentId) || AgentState.IDLE;
69
+ nodes.set(agent.agentId, {
70
+ agentId: agent.agentId,
71
+ state: currentState,
72
+ parentId: agent.parentId,
73
+ childIds: [],
74
+ isProjectManager: agent.isProjectManager || agent.agentId === rootPmId,
75
+ lastUpdated: this.lamportClock.tick()
76
+ });
77
+ }
78
+ // Add root PM if not in agents list
79
+ if (!nodes.has(rootPmId)) {
80
+ nodes.set(rootPmId, {
81
+ agentId: rootPmId,
82
+ state: this.stateMachine.getState(rootPmId) || AgentState.IDLE,
83
+ parentId: undefined,
84
+ childIds: [],
85
+ isProjectManager: true,
86
+ lastUpdated: this.lamportClock.tick()
87
+ });
88
+ }
89
+ // Build parent-child relationships
90
+ for (const node of Array.from(nodes.values())){
91
+ if (node.parentId) {
92
+ const parent = nodes.get(node.parentId);
93
+ if (parent) {
94
+ parent.childIds.push(node.agentId);
95
+ }
96
+ }
97
+ }
98
+ const hierarchy = {
99
+ swarmId,
100
+ rootPmId,
101
+ nodes,
102
+ dependencyGraph: this.dependencyGraph
103
+ };
104
+ this.swarms.set(swarmId, hierarchy);
105
+ if (this.config.enableLogging) {
106
+ this.log('Swarm hierarchy registered', {
107
+ swarmId,
108
+ rootPmId,
109
+ totalAgents: nodes.size,
110
+ pmCount: Array.from(nodes.values()).filter((n)=>n.isProjectManager).length
111
+ });
112
+ }
113
+ }
114
+ /**
115
+ * Detect swarm completion using PM-based pattern
116
+ */ async detectCompletion(swarmId) {
117
+ const startTime = performance.now();
118
+ try {
119
+ const hierarchy = this.swarms.get(swarmId);
120
+ if (!hierarchy) {
121
+ throw new Error(`Swarm ${swarmId} not registered`);
122
+ }
123
+ // Update all agent states from state machine
124
+ await this.updateAgentStates(hierarchy);
125
+ // Check root PM completion (bottom-up traversal implicit via state checks)
126
+ const allCompleted = this.checkHierarchyCompletion(hierarchy);
127
+ // Gather agent states
128
+ const agentStates = new Map();
129
+ for (const node of Array.from(hierarchy.nodes.values())){
130
+ agentStates.set(node.agentId, node.state);
131
+ }
132
+ const completedCount = Array.from(agentStates.values()).filter((state)=>state === AgentState.COMPLETED).length;
133
+ let checkpointId;
134
+ const warnings = [];
135
+ if (allCompleted) {
136
+ // Validate completion before declaring
137
+ if (this.config.enableValidation) {
138
+ const validation = await this.validateCompletion(swarmId, agentStates);
139
+ if (!validation.valid) {
140
+ warnings.push(...validation.errors);
141
+ if (this.config.enableLogging) {
142
+ this.log('Completion validation failed', {
143
+ swarmId,
144
+ errors: validation.errors
145
+ });
146
+ }
147
+ }
148
+ }
149
+ // Create checkpoint BEFORE declaring completion
150
+ if (this.config.autoCheckpoint) {
151
+ checkpointId = await this.createCompletionCheckpoint(swarmId, agentStates);
152
+ }
153
+ }
154
+ const latencyMs = performance.now() - startTime;
155
+ const result = {
156
+ completed: allCompleted,
157
+ swarmId,
158
+ timestamp: new Date(),
159
+ agentStates,
160
+ completedCount,
161
+ totalCount: hierarchy.nodes.size,
162
+ latencyMs,
163
+ checkpointId,
164
+ metadata: {
165
+ strategy: 'hierarchical',
166
+ warnings: warnings.length > 0 ? warnings : undefined,
167
+ context: {
168
+ rootPmId: hierarchy.rootPmId,
169
+ pmCount: Array.from(hierarchy.nodes.values()).filter((n)=>n.isProjectManager).length
170
+ }
171
+ }
172
+ };
173
+ this.updateMetrics(latencyMs, true);
174
+ if (allCompleted) {
175
+ this.emitCompletionDetected(result);
176
+ }
177
+ return result;
178
+ } catch (error) {
179
+ const latencyMs = performance.now() - startTime;
180
+ this.updateMetrics(latencyMs, false);
181
+ this.emitCompletionFailed(swarmId, error);
182
+ throw error;
183
+ }
184
+ }
185
+ /**
186
+ * Validate completion conditions
187
+ *
188
+ * Checks:
189
+ * - All agents in COMPLETED state
190
+ * - Root PM completed last
191
+ * - No blocked or error agents
192
+ * - Dependency graph satisfied (if available)
193
+ */ async validateCompletion(swarmId, agentStates) {
194
+ const startTime = performance.now();
195
+ const errors = [];
196
+ const warnings = [];
197
+ const hierarchy = this.swarms.get(swarmId);
198
+ if (!hierarchy) {
199
+ errors.push(`Swarm ${swarmId} not registered`);
200
+ return {
201
+ valid: false,
202
+ errors,
203
+ warnings,
204
+ latencyMs: performance.now() - startTime
205
+ };
206
+ }
207
+ // Check all agents completed
208
+ for (const [agentId, state] of Array.from(agentStates.entries())){
209
+ if (state !== AgentState.COMPLETED) {
210
+ errors.push(`Agent ${agentId} not completed (state: ${state})`);
211
+ }
212
+ if (state === AgentState.BLOCKED || state === AgentState.ERROR) {
213
+ errors.push(`Agent ${agentId} in error state: ${state}`);
214
+ }
215
+ }
216
+ // Check root PM completed
217
+ const rootPm = hierarchy.nodes.get(hierarchy.rootPmId);
218
+ if (rootPm && rootPm.state !== AgentState.COMPLETED) {
219
+ errors.push(`Root PM ${hierarchy.rootPmId} not completed (state: ${rootPm.state})`);
220
+ }
221
+ // Check PM hierarchy completion order (PMs should complete after their children)
222
+ for (const node of Array.from(hierarchy.nodes.values())){
223
+ if (node.isProjectManager && node.state === AgentState.COMPLETED) {
224
+ for (const childId of node.childIds){
225
+ const childState = agentStates.get(childId);
226
+ if (childState !== AgentState.COMPLETED) {
227
+ warnings.push(`PM ${node.agentId} completed before child ${childId}`);
228
+ }
229
+ }
230
+ }
231
+ }
232
+ // Validate dependency graph if available
233
+ if (hierarchy.dependencyGraph) {
234
+ const graphStats = hierarchy.dependencyGraph.getStatistics();
235
+ if (graphStats.completedNodeCount !== graphStats.nodeCount) {
236
+ errors.push(`Dependency graph incomplete: ${graphStats.completedNodeCount}/${graphStats.nodeCount} completed`);
237
+ }
238
+ }
239
+ const latencyMs = performance.now() - startTime;
240
+ return {
241
+ valid: errors.length === 0,
242
+ errors,
243
+ warnings,
244
+ latencyMs
245
+ };
246
+ }
247
+ /**
248
+ * Get detection strategy
249
+ */ getStrategy() {
250
+ return 'hierarchical';
251
+ }
252
+ /**
253
+ * Handle state transition events
254
+ *
255
+ * Updates agent states and triggers completion checks.
256
+ * Uses Lamport timestamp for causal ordering.
257
+ */ handleStateTransition(event) {
258
+ const { agentId, toState } = event;
259
+ // Increment Lamport clock for state transition event
260
+ const lamportTimestamp = this.lamportClock.tick();
261
+ // Find swarm containing this agent
262
+ for (const [swarmId, hierarchy] of Array.from(this.swarms.entries())){
263
+ const node = hierarchy.nodes.get(agentId);
264
+ if (node) {
265
+ // Update node state with Lamport timestamp
266
+ node.state = toState;
267
+ node.lastUpdated = lamportTimestamp;
268
+ // If agent completed, check if swarm completion triggered
269
+ if (toState === AgentState.COMPLETED) {
270
+ // Async completion check (don't block state transition)
271
+ this.detectCompletion(swarmId).catch((error)=>{
272
+ if (this.config.enableLogging) {
273
+ this.log('Completion check failed', {
274
+ swarmId,
275
+ agentId,
276
+ error: error.message
277
+ });
278
+ }
279
+ });
280
+ }
281
+ break;
282
+ }
283
+ }
284
+ }
285
+ /**
286
+ * Check if entire hierarchy completed using PM-based pattern
287
+ */ checkHierarchyCompletion(hierarchy) {
288
+ // Check if root PM completed (implies all children completed)
289
+ const rootPm = hierarchy.nodes.get(hierarchy.rootPmId);
290
+ if (!rootPm || rootPm.state !== AgentState.COMPLETED) {
291
+ return false;
292
+ }
293
+ // Verify all children completed (bottom-up validation)
294
+ return this.checkNodeCompletion(rootPm, hierarchy);
295
+ }
296
+ /**
297
+ * Recursively check if node and all children completed
298
+ */ checkNodeCompletion(node, hierarchy) {
299
+ // Check node itself completed
300
+ if (node.state !== AgentState.COMPLETED) {
301
+ return false;
302
+ }
303
+ // Check all children completed
304
+ for (const childId of node.childIds){
305
+ const child = hierarchy.nodes.get(childId);
306
+ if (!child) {
307
+ return false;
308
+ }
309
+ // Recursive check
310
+ if (!this.checkNodeCompletion(child, hierarchy)) {
311
+ return false;
312
+ }
313
+ }
314
+ return true;
315
+ }
316
+ /**
317
+ * Update agent states from state machine with Lamport timestamps
318
+ */ async updateAgentStates(hierarchy) {
319
+ const allStates = this.stateMachine.getAllStates();
320
+ const lamportTimestamp = this.lamportClock.tick();
321
+ for (const [agentId, state] of Array.from(allStates.entries())){
322
+ const node = hierarchy.nodes.get(agentId);
323
+ if (node) {
324
+ node.state = state;
325
+ node.lastUpdated = lamportTimestamp;
326
+ }
327
+ }
328
+ }
329
+ /**
330
+ * Unregister swarm
331
+ */ unregisterSwarm(swarmId) {
332
+ return this.swarms.delete(swarmId);
333
+ }
334
+ /**
335
+ * Get swarm hierarchy
336
+ */ getSwarmHierarchy(swarmId) {
337
+ return this.swarms.get(swarmId);
338
+ }
339
+ /**
340
+ * Cleanup detector resources
341
+ */ async cleanup() {
342
+ this.swarms.clear();
343
+ await super.cleanup();
344
+ }
345
+ }
346
+
347
+ //# sourceMappingURL=hierarchical-detector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../src/coordination/archives/v2-sdk-typescript/v2/completion/hierarchical-detector.ts"],"names":["AgentState","CompletionDetector","HierarchicalCompletionDetector","swarms","dependencyGraph","stateMachine","messageBroker","checkpointManager","config","Map","enableLogging","log","hasDependencyGraph","registerSwarm","swarmId","rootPmId","agents","nodes","agent","currentState","getState","agentId","IDLE","set","state","parentId","childIds","isProjectManager","lastUpdated","lamportClock","tick","has","undefined","node","Array","from","values","parent","get","push","hierarchy","totalAgents","size","pmCount","filter","n","length","detectCompletion","startTime","performance","now","Error","updateAgentStates","allCompleted","checkHierarchyCompletion","agentStates","completedCount","COMPLETED","checkpointId","warnings","enableValidation","validation","validateCompletion","valid","errors","autoCheckpoint","createCompletionCheckpoint","latencyMs","result","completed","timestamp","Date","totalCount","metadata","strategy","context","updateMetrics","emitCompletionDetected","error","emitCompletionFailed","entries","BLOCKED","ERROR","rootPm","childId","childState","graphStats","getStatistics","completedNodeCount","nodeCount","getStrategy","handleStateTransition","event","toState","lamportTimestamp","catch","message","checkNodeCompletion","child","allStates","getAllStates","unregisterSwarm","delete","getSwarmHierarchy","cleanup","clear"],"mappings":"AAAA;;;;;;;;;;;;CAYC,GAED,SAASA,UAAU,QAAQ,mCAAmC;AAC9D,SACEC,kBAAkB,QAIb,2BAA2B;AA8ClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BC,GACD,OAAO,MAAMC,uCAAuCD;IAC1CE,OAAoC;IACpCC,gBAAkC;IAE1C,YACEC,YAA0B,EAC1BC,aAA4B,EAC5BC,iBAAoC,EACpCH,eAAiC,EACjCI,MAAiC,CACjC;QACA,KAAK,CAACH,cAAcC,eAAeC,mBAAmBC;QAEtD,IAAI,CAACL,MAAM,GAAG,IAAIM;QAClB,IAAI,CAACL,eAAe,GAAGA;QAEvB,IAAI,IAAI,CAACI,MAAM,CAACE,aAAa,EAAE;YAC7B,IAAI,CAACC,GAAG,CAAC,8CAA8C;gBACrDC,oBAAoB,CAAC,CAACR;YACxB;QACF;IACF;IAEA;;;;;;GAMC,GACDS,cACEC,OAAe,EACfC,QAAgB,EAChBC,MAAiF,EAC3E;QACN,MAAMC,QAAQ,IAAIR;QAElB,wBAAwB;QACxB,KAAK,MAAMS,SAASF,OAAQ;YAC1B,MAAMG,eAAe,IAAI,CAACd,YAAY,CAACe,QAAQ,CAACF,MAAMG,OAAO,KAAKrB,WAAWsB,IAAI;YAEjFL,MAAMM,GAAG,CAACL,MAAMG,OAAO,EAAE;gBACvBA,SAASH,MAAMG,OAAO;gBACtBG,OAAOL;gBACPM,UAAUP,MAAMO,QAAQ;gBACxBC,UAAU,EAAE;gBACZC,k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AAyB,EAAW;QACtF,8BAA8B;QAC9B,IAAIP,KAAKT,KAAK,KAAKxB,WAAWyD,SAAS,EAAE;YACvC,OAAO;QACT;QAEA,+BAA+B;QAC/B,KAAK,MAAM2B,WAAWnD,KAAKP,QAAQ,CAAE;YACnC,MAAMwE,QAAQ1D,UAAUvB,KAAK,CAACqB,GAAG,CAAC8C;YAClC,IAAI,CAACc,OAAO;gBACV,OAAO;YACT;YAEA,kBAAkB;YAClB,IAAI,CAAC,IAAI,CAACD,mBAAmB,CAACC,OAAO1D,YAAY;gBAC/C,OAAO;YACT;QACF;QAEA,OAAO;IACT;IAEA;;GAEC,GACD,MAAcY,kBAAkBZ,SAAyB,EAAiB;QACxE,MAAM2D,YAAY,IAAI,CAAC9F,YAAY,CAAC+F,YAAY;QAChD,MAAMN,mBAAmB,IAAI,CAACjE,YAAY,CAACC,IAAI;QAE/C,KAAK,MAAM,CAACT,SAASG,MAAM,IAAIU,MAAMC,IAAI,CAACgE,UAAUnB,OAAO,IAAK;YAC9D,MAAM/C,OAAOO,UAAUvB,KAAK,CAACqB,GAAG,CAACjB;YACjC,IAAIY,MAAM;gBACRA,KAAKT,KAAK,GAAGA;gBACbS,KAAKL,WAAW,GAAGkE;YACrB;QACF;IACF;IAEA;;GAEC,GACDO,gBAAgBvF,OAAe,EAAW;QACxC,OAAO,IAAI,CAACX,MAAM,CAACmG,MAAM,CAACxF;IAC5B;IAEA;;GAEC,GACDyF,kBAAkBzF,OAAe,EAA8B;QAC7D,OAAO,IAAI,CAACX,MAAM,CAACmC,GAAG,CAACxB;IACzB;IAEA;;GAEC,GACD,MAAM0F,UAAyB;QAC7B,IAAI,CAACrG,MAAM,CAACsG,KAAK;QACjB,MAAM,KAAK,CAACD;IACd;AACF"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Agent Coordination V2 - Completion Module
3
+ *
4
+ * Exports completion detection, shutdown coordination, and completion storage.
5
+ *
6
+ * @module coordination/v2/completion
7
+ */ export { CompletionDetector, CompletionResult, ValidationResult, CompletionMetrics, ValidationContext, StateSnapshot } from './completion-detector.js';
8
+ export { HierarchicalCompletionDetector } from './hierarchical-detector.js';
9
+ export { MeshCompletionDetector } from './mesh-detector.js';
10
+ export { SDKCompletionDetector, AgentCompletionEventData, SDKCompletionDetectorConfig, CompletionValidationResult, CheckpointValidationResult, RecoveryResult, CompletionDetectorMetrics } from './sdk-completion-detector.js';
11
+ export { SwarmShutdown, SwarmShutdownConfig, AgentShutdownResult, SwarmShutdownResult } from './swarm-shutdown.js';
12
+
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../src/coordination/archives/v2-sdk-typescript/v2/completion/index.ts"],"names":["CompletionDetector","CompletionResult","ValidationResult","CompletionMetrics","ValidationContext","StateSnapshot","HierarchicalCompletionDetector","MeshCompletionDetector","SDKCompletionDetector","AgentCompletionEventData","SDKCompletionDetectorConfig","CompletionValidationResult","CheckpointValidationResult","RecoveryResult","CompletionDetectorMetrics","SwarmShutdown","SwarmShutdownConfig","AgentShutdownResult","SwarmShutdownResult"],"mappings":"AAAA;;;;;;CAMC,GAED,SACEA,kBAAkB,EAClBC,gBAAgB,EAChBC,gBAAgB,EAChBC,iBAAiB,EACjBC,iBAAiB,EACjBC,aAAa,QACR,2BAA2B;AAIlC,SACEC,8BAA8B,QACzB,6BAA6B;AAEpC,SACEC,sBAAsB,QACjB,qBAAqB;AAE5B,SACEC,qBAAqB,EACrBC,wBAAwB,EACxBC,2BAA2B,EAC3BC,0BAA0B,EAC1BC,0BAA0B,EAC1BC,cAAc,EACdC,yBAAyB,QACpB,+BAA+B;AAEtC,SACEC,aAAa,EACbC,mBAAmB,EACnBC,mBAAmB,EACnBC,mBAAmB,QACd,sBAAsB"}
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Lamport Clock Implementation for Causal Event Ordering
3
+ *
4
+ * Provides logical timestamps for distributed event ordering in agent coordination.
5
+ * Ensures happens-before relationship tracking without physical clock synchronization.
6
+ *
7
+ * Use Case: SEC-024 Fix - Replace Date.now() with Lamport timestamps in completion events
8
+ * to prevent incorrect completion order in distributed mesh topology.
9
+ *
10
+ * Algorithm:
11
+ * - Each process maintains a counter (logical clock)
12
+ * - Counter increments on local events
13
+ * - Counter updates on message receive: max(local, received) + 1
14
+ * - Guarantees: if A happened-before B, then timestamp(A) < timestamp(B)
15
+ *
16
+ * @module coordination/v2/completion/lamport-clock
17
+ */ /**
18
+ * Lamport Clock for distributed event ordering
19
+ *
20
+ * Provides logical timestamps that preserve causal ordering of events
21
+ * across distributed agents without requiring synchronized physical clocks.
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const clock = new LamportClock();
26
+ *
27
+ * // Local event (e.g., agent starts task)
28
+ * const timestamp1 = clock.tick(); // 1
29
+ *
30
+ * // Another local event
31
+ * const timestamp2 = clock.tick(); // 2
32
+ *
33
+ * // Receive message with timestamp 5 from remote agent
34
+ * const timestamp3 = clock.update(5); // 6 (max(2, 5) + 1)
35
+ *
36
+ * // Check causal ordering
37
+ * if (LamportClock.happenedBefore(timestamp1, timestamp3)) {
38
+ * console.log('Event 1 happened before Event 3');
39
+ * }
40
+ * ```
41
+ */ export class LamportClock {
42
+ counter = 0;
43
+ /**
44
+ * Increment clock for local event
45
+ *
46
+ * Use this when agent performs local action:
47
+ * - Agent state transition
48
+ * - Completion detection
49
+ * - Internal task completion
50
+ *
51
+ * @returns New Lamport timestamp after increment
52
+ */ tick() {
53
+ this.counter++;
54
+ return this.counter;
55
+ }
56
+ /**
57
+ * Update clock when receiving message with remote timestamp
58
+ *
59
+ * Use this when agent receives message from another agent:
60
+ * - Completion probe acknowledgment
61
+ * - Inter-agent communication
62
+ * - Coordinator status update
63
+ *
64
+ * Ensures happens-before relationship:
65
+ * If remote event E1 happened before local event E2,
66
+ * then timestamp(E1) < timestamp(E2)
67
+ *
68
+ * @param remoteTimestamp - Lamport timestamp from received message
69
+ * @returns New local timestamp after synchronization
70
+ */ update(remoteTimestamp) {
71
+ this.counter = Math.max(this.counter, remoteTimestamp) + 1;
72
+ return this.counter;
73
+ }
74
+ /**
75
+ * Get current timestamp without incrementing
76
+ *
77
+ * Use this for read-only operations where you need current clock value
78
+ * but don't want to advance logical time (e.g., debugging, logging).
79
+ *
80
+ * @returns Current Lamport timestamp
81
+ */ getTimestamp() {
82
+ return this.counter;
83
+ }
84
+ /**
85
+ * Reset clock to initial state (for testing only)
86
+ *
87
+ * WARNING: Only use in test scenarios. Resetting clock in production
88
+ * breaks causal ordering guarantees.
89
+ */ reset() {
90
+ this.counter = 0;
91
+ }
92
+ /**
93
+ * Compare two Lamport timestamps for happens-before relation
94
+ *
95
+ * Returns true if t1 happened before t2 in logical time.
96
+ *
97
+ * Note: Lamport clocks provide partial ordering:
98
+ * - If happenedBefore(t1, t2) is true, t1 definitely happened before t2
99
+ * - If happenedBefore(t1, t2) is false, t1 and t2 may be concurrent
100
+ *
101
+ * For total ordering, use Vector Clocks (not implemented here).
102
+ *
103
+ * @param t1 - First Lamport timestamp
104
+ * @param t2 - Second Lamport timestamp
105
+ * @returns True if t1 happened before t2
106
+ */ static happenedBefore(t1, t2) {
107
+ return t1 < t2;
108
+ }
109
+ /**
110
+ * Compare two events with Lamport timestamps and tie-breaking IDs
111
+ *
112
+ * When two events have same Lamport timestamp (concurrent events),
113
+ * use agent/process ID for deterministic ordering.
114
+ *
115
+ * @param t1 - First Lamport timestamp
116
+ * @param id1 - First event/agent identifier (for tie-breaking)
117
+ * @param t2 - Second Lamport timestamp
118
+ * @param id2 - Second event/agent identifier (for tie-breaking)
119
+ * @returns -1 if e1 < e2, 0 if e1 == e2, 1 if e1 > e2
120
+ */ static compareEvents(t1, id1, t2, id2) {
121
+ if (t1 !== t2) {
122
+ return t1 < t2 ? -1 : 1;
123
+ }
124
+ // Tie-breaking: use lexicographic order of IDs for deterministic ordering
125
+ return id1.localeCompare(id2);
126
+ }
127
+ /**
128
+ * Serialize clock state (for persistence or network transmission)
129
+ *
130
+ * @returns Serializable clock state
131
+ */ serialize() {
132
+ return {
133
+ counter: this.counter
134
+ };
135
+ }
136
+ /**
137
+ * Deserialize clock state (from persistence or network)
138
+ *
139
+ * @param state - Serialized clock state
140
+ */ deserialize(state) {
141
+ this.counter = state.counter;
142
+ }
143
+ }
144
+ /**
145
+ * Create Lamport-timestamped event
146
+ *
147
+ * @param clock - Lamport clock instance
148
+ * @param eventId - Unique event identifier
149
+ * @param sourceId - Event source agent/process ID
150
+ * @param data - Event payload
151
+ * @returns Lamport-timestamped event
152
+ */ export function createLamportEvent(clock, eventId, sourceId, data) {
153
+ return {
154
+ timestamp: clock.tick(),
155
+ eventId,
156
+ sourceId,
157
+ physicalTime: Date.now(),
158
+ data
159
+ };
160
+ }
161
+ /**
162
+ * Process received Lamport event
163
+ *
164
+ * Updates local clock based on received timestamp and returns synchronized clock value.
165
+ *
166
+ * @param clock - Local Lamport clock
167
+ * @param event - Received Lamport event
168
+ * @returns New local timestamp after synchronization
169
+ */ export function processLamportEvent(clock, event) {
170
+ return clock.update(event.timestamp);
171
+ }
172
+
173
+ //# sourceMappingURL=lamport-clock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../src/coordination/archives/v2-sdk-typescript/v2/completion/lamport-clock.ts"],"names":["LamportClock","counter","tick","update","remoteTimestamp","Math","max","getTimestamp","reset","happenedBefore","t1","t2","compareEvents","id1","id2","localeCompare","serialize","deserialize","state","createLamportEvent","clock","eventId","sourceId","data","timestamp","physicalTime","Date","now","processLamportEvent","event"],"mappings":"AAAA;;;;;;;;;;;;;;;;CAgBC,GAED;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GACD,OAAO,MAAMA;IACHC,UAAkB,EAAE;IAE5B;;;;;;;;;GASC,GACDC,OAAe;QACb,IAAI,CAACD,OAAO;QACZ,OAAO,IAAI,CAACA,OAAO;IACrB;IAEA;;;;;;;;;;;;;;GAcC,GACDE,OAAOC,eAAuB,EAAU;QACtC,IAAI,CAACH,OAAO,GAAGI,KAAK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