claude-flow-novice 1.6.4 → 1.6.6

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 (286) 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/mcp-server-sdk.js +45 -0
  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/shared/core/agent-state.js +172 -0
  224. package/.claude-flow-novice/dist/src/coordination/shared/core/agent-state.js.map +1 -0
  225. package/.claude-flow-novice/dist/src/coordination/shared/core/index.js +7 -0
  226. package/.claude-flow-novice/dist/src/coordination/shared/core/index.js.map +1 -0
  227. package/.claude-flow-novice/dist/src/coordination/shared/index.js +19 -0
  228. package/.claude-flow-novice/dist/src/coordination/shared/index.js.map +1 -0
  229. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/ICoordinator.js +24 -0
  230. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/ICoordinator.js.map +1 -0
  231. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/index.js +7 -0
  232. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/index.js.map +1 -0
  233. package/.claude-flow-novice/dist/src/coordination/shared/message-broker.js +920 -0
  234. package/.claude-flow-novice/dist/src/coordination/shared/message-broker.js.map +1 -0
  235. package/.claude-flow-novice/dist/src/coordination/shared/message.js +138 -0
  236. package/.claude-flow-novice/dist/src/coordination/shared/message.js.map +1 -0
  237. package/.claude-flow-novice/dist/src/coordination/shared/security/payload-validator.js +259 -0
  238. package/.claude-flow-novice/dist/src/coordination/shared/security/payload-validator.js.map +1 -0
  239. package/.claude-flow-novice/dist/src/coordination/shared/transparency/index.js +17 -0
  240. package/.claude-flow-novice/dist/src/coordination/shared/transparency/index.js.map +1 -0
  241. package/.claude-flow-novice/dist/src/coordination/shared/transparency/interfaces/transparency-system.js +19 -0
  242. package/.claude-flow-novice/dist/src/coordination/shared/transparency/interfaces/transparency-system.js.map +1 -0
  243. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-integration.js +357 -0
  244. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-integration.js.map +1 -0
  245. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-system.js +679 -0
  246. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-system.js.map +1 -0
  247. package/.claude-flow-novice/dist/src/coordination/shared/types/index.js +7 -0
  248. package/.claude-flow-novice/dist/src/coordination/shared/types/index.js.map +1 -0
  249. package/.claude-flow-novice/dist/src/coordination/shared/types/sdk.js +10 -0
  250. package/.claude-flow-novice/dist/src/coordination/shared/types/sdk.js.map +1 -0
  251. package/.claude-flow-novice/dist/src/feature-flags/core/FeatureFlagManager.js +52 -2
  252. package/.claude-flow-novice/dist/src/feature-flags/core/FeatureFlagManager.js.map +1 -1
  253. package/.claude-flow-novice/dist/src/mcp/mcp-server-novice.js +37 -2
  254. package/.claude-flow-novice/dist/src/mcp/session-manager.js +3 -1
  255. package/.claude-flow-novice/dist/src/mcp/session-manager.js.map +1 -1
  256. package/.claude-flow-novice/dist/src/providers/provider-manager.js +36 -3
  257. package/.claude-flow-novice/dist/src/providers/provider-manager.js.map +1 -1
  258. package/.claude-flow-novice/dist/src/utils/markdown-sanitizer.js +65 -41
  259. package/.claude-flow-novice/dist/src/utils/markdown-sanitizer.js.map +1 -1
  260. package/.claude-flow-novice/dist/src/web/api/server.js +1 -1
  261. package/.claude-flow-novice/dist/src/web/api/server.js.map +1 -1
  262. package/.claude-flow-novice/dist/src/workflows/progressive-rollout-manager.js +30 -0
  263. package/.claude-flow-novice/dist/src/workflows/progressive-rollout-manager.js.map +1 -1
  264. package/.claude-flow-novice/metrics.db-shm +0 -0
  265. package/.claude-flow-novice/metrics.db-wal +0 -0
  266. package/config/.env.example +178 -0
  267. package/config/DEPLOYMENT_GUIDE.md +692 -0
  268. package/config/README-CONFIG.md +331 -0
  269. package/config/coordination-config.sh +327 -0
  270. package/config/docker/env.development +53 -0
  271. package/config/docker/env.production +83 -0
  272. package/config/docker/env.staging +70 -0
  273. package/config/k8s/configmap-development.yaml +60 -0
  274. package/config/k8s/configmap-production.yaml +85 -0
  275. package/config/k8s/configmap-staging.yaml +76 -0
  276. package/config/k8s/secret-production.yaml +62 -0
  277. package/config/k8s/secret-staging.yaml +36 -0
  278. package/package.json +2 -2
  279. package/scripts/monitoring/alert-monitor.sh +220 -0
  280. package/scripts/monitoring/dashboards/rate-limiting-dashboard.json +211 -0
  281. package/scripts/monitoring/quick-test-alerting.sh +118 -0
  282. package/scripts/monitoring/quick-test-rate-limiting.sh +206 -0
  283. package/scripts/monitoring/rate-limiting-monitor.sh +380 -0
  284. package/scripts/monitoring/view-alerts.sh +307 -0
  285. package/scripts/test-zai-api.cjs +2 -2
  286. package/src/slash-commands/parse-epic.js +1 -1
@@ -0,0 +1,526 @@
1
+ /**
2
+ * Agent Coordination V2 - Mesh Completion Detector
3
+ *
4
+ * Implements Dijkstra-Scholten distributed completion detection algorithm
5
+ * for mesh topology swarms. Provides distributed consensus via completion
6
+ * probes without centralized coordination.
7
+ *
8
+ * Algorithm:
9
+ * - Each agent maintains a deficit counter
10
+ * - Counter increments on message send, decrements on acknowledgment
11
+ * - When counter=0 AND state=COMPLETED, agent sends completion probe
12
+ * - Completion detected when all probes successfully return
13
+ *
14
+ * Performance Target: <2000ms for 10-agent mesh
15
+ *
16
+ * @module coordination/v2/completion/mesh-detector
17
+ */ import { MessagePriority } from '../core/message.js';
18
+ import { AgentState } from '../../shared/core/agent-state.js';
19
+ import { LamportClock } from './lamport-clock.js';
20
+ /**
21
+ * Mesh Completion Detector Implementation.
22
+ *
23
+ * Uses Dijkstra-Scholten distributed algorithm for completion detection
24
+ * in mesh topology swarms without centralized coordination.
25
+ *
26
+ * Key Features:
27
+ * - Distributed deficit counters per agent
28
+ * - Completion probes for consensus
29
+ * - <2000ms target for 10-agent mesh
30
+ * - Zero centralized coordination overhead
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const detector = new MeshCompletionDetector(messageBus);
35
+ *
36
+ * // Initialize swarm
37
+ * await detector.initializeSwarm(swarmId, agentIds);
38
+ *
39
+ * // Start monitoring
40
+ * detector.startMonitoring(swarmId);
41
+ *
42
+ * // Wait for completion
43
+ * const completed = await detector.detectCompletion(swarmId);
44
+ * if (completed) {
45
+ * console.log('Swarm completed with distributed consensus');
46
+ * }
47
+ * ```
48
+ */ export class MeshCompletionDetector {
49
+ messageBus;
50
+ config;
51
+ deficitCounters;
52
+ completionProbes;
53
+ swarmAgents;
54
+ completionPromises;
55
+ deficitLocks;
56
+ lamportClock;
57
+ /**
58
+ * Creates a new mesh completion detector.
59
+ *
60
+ * @param messageBus - Message bus for inter-agent communication
61
+ * @param config - Detector configuration options
62
+ */ constructor(messageBus, config){
63
+ this.messageBus = messageBus;
64
+ this.config = {
65
+ probeTimeout: config?.probeTimeout ?? 2000,
66
+ maxDetectionTime: config?.maxDetectionTime ?? 2000,
67
+ enableLogging: config?.enableLogging ?? false
68
+ };
69
+ this.deficitCounters = new Map();
70
+ this.completionProbes = new Map();
71
+ this.swarmAgents = new Map();
72
+ this.completionPromises = new Map();
73
+ this.deficitLocks = new Map();
74
+ this.lamportClock = new LamportClock();
75
+ }
76
+ // ============================================
77
+ // Swarm Initialization
78
+ // ============================================
79
+ /**
80
+ * Initializes swarm for completion detection.
81
+ *
82
+ * @param swarmId - Swarm identifier
83
+ * @param agentIds - Array of agent IDs in the mesh
84
+ */ async initializeSwarm(swarmId, agentIds) {
85
+ if (agentIds.length === 0) {
86
+ throw new Error('Cannot initialize swarm with zero agents');
87
+ }
88
+ // Store swarm agent list
89
+ this.swarmAgents.set(swarmId, new Set(agentIds));
90
+ // Initialize deficit counters for each agent
91
+ for (const agentId of agentIds){
92
+ this.deficitCounters.set(agentId, {
93
+ agentId,
94
+ counter: 0,
95
+ state: AgentState.IDLE,
96
+ lastUpdated: Date.now()
97
+ });
98
+ }
99
+ // Initialize completion probe storage
100
+ this.completionProbes.set(swarmId, []);
101
+ this.log(`Initialized swarm ${swarmId} with ${agentIds.length} agents`);
102
+ }
103
+ /**
104
+ * Starts monitoring for completion detection.
105
+ *
106
+ * Sets up message bus listeners for:
107
+ * - Outgoing messages (increment deficit)
108
+ * - Acknowledgments (decrement deficit)
109
+ * - Completion probes (consensus tracking)
110
+ *
111
+ * @param swarmId - Swarm identifier
112
+ */ async startMonitoring(swarmId) {
113
+ const agents = this.swarmAgents.get(swarmId);
114
+ if (!agents) {
115
+ throw new Error(`Swarm ${swarmId} not initialized`);
116
+ }
117
+ // Subscribe to message sends (increment deficit)
118
+ await this.messageBus.subscribe({
119
+ topic: 'agent.message.send',
120
+ handler: async (msg)=>{
121
+ const senderId = msg.payload.senderId;
122
+ if (agents.has(senderId)) {
123
+ await this.incrementDeficit(senderId);
124
+ }
125
+ },
126
+ priority: MessagePriority.HIGH
127
+ });
128
+ // Subscribe to acknowledgments (decrement deficit)
129
+ await this.messageBus.subscribe({
130
+ topic: 'agent.message.ack',
131
+ handler: async (msg)=>{
132
+ const senderId = msg.payload.senderId;
133
+ if (agents.has(senderId)) {
134
+ await this.decrementDeficit(senderId, swarmId);
135
+ }
136
+ },
137
+ priority: MessagePriority.HIGH
138
+ });
139
+ // Subscribe to state changes
140
+ await this.messageBus.subscribe({
141
+ topic: 'agent.state.changed',
142
+ handler: async (msg)=>{
143
+ const agentId = msg.payload.agentId;
144
+ const newState = msg.payload.state;
145
+ if (agents.has(agentId)) {
146
+ this.updateAgentState(agentId, newState);
147
+ if (newState === AgentState.COMPLETED) {
148
+ await this.checkAndSendProbe(agentId, swarmId);
149
+ }
150
+ }
151
+ },
152
+ priority: MessagePriority.CRITICAL
153
+ });
154
+ // Subscribe to completion probes
155
+ await this.messageBus.subscribe({
156
+ topic: 'completion.probe',
157
+ handler: async (msg)=>{
158
+ await this.handleCompletionProbe(swarmId, msg);
159
+ },
160
+ priority: MessagePriority.CRITICAL
161
+ });
162
+ // Subscribe to probe acknowledgments
163
+ await this.messageBus.subscribe({
164
+ topic: 'completion.probe.ack',
165
+ handler: async (msg)=>{
166
+ await this.handleProbeAcknowledgment(swarmId, msg);
167
+ },
168
+ priority: MessagePriority.CRITICAL
169
+ });
170
+ this.log(`Started monitoring swarm ${swarmId}`);
171
+ }
172
+ // ============================================
173
+ // Deficit Counter Management (Dijkstra-Scholten)
174
+ // ============================================
175
+ /**
176
+ * Acquires atomic lock for deficit counter operations.
177
+ *
178
+ * Implements race-condition-free mutex using promise chaining.
179
+ * The lock is atomic because:
180
+ * 1. New lock promise is set BEFORE waiting for existing lock
181
+ * 2. Promise chaining ensures sequential execution order
182
+ * 3. No CTOU gap between check and set operations
183
+ *
184
+ * Security: Fixes SEC-017 HIGH-severity race condition in mesh completion detector.
185
+ *
186
+ * @param agentId - Agent identifier for lock isolation
187
+ * @returns Release function that removes lock atomically
188
+ *
189
+ * @example
190
+ * ```typescript
191
+ * const release = await this.acquireDeficitLock('agent-1');
192
+ * try {
193
+ * // Critical section - guaranteed exclusive access
194
+ * counter.value++;
195
+ * } finally {
196
+ * release();
197
+ * }
198
+ * ```
199
+ */ async acquireDeficitLock(agentId) {
200
+ // Get existing lock if present (atomic read)
201
+ const existingLock = this.deficitLocks.get(agentId);
202
+ // Create new lock promise with release callback
203
+ let release;
204
+ const newLock = new Promise((resolve)=>{
205
+ release = ()=>{
206
+ // Atomically remove lock before resolving
207
+ this.deficitLocks.delete(agentId);
208
+ resolve(()=>{});
209
+ };
210
+ });
211
+ // Atomically set new lock BEFORE waiting (eliminates CTOU race)
212
+ this.deficitLocks.set(agentId, newLock);
213
+ // Wait for previous lock if exists (sequential execution via chaining)
214
+ if (existingLock) {
215
+ await existingLock;
216
+ }
217
+ // Return release callback to caller
218
+ return release;
219
+ }
220
+ /**
221
+ * Increments deficit counter on message send (atomic lock protected).
222
+ *
223
+ * @param agentId - Agent that sent the message
224
+ */ async incrementDeficit(agentId) {
225
+ const release = await this.acquireDeficitLock(agentId);
226
+ try {
227
+ const counter = this.deficitCounters.get(agentId);
228
+ if (counter) {
229
+ counter.counter++;
230
+ counter.lastUpdated = Date.now();
231
+ this.log(`Agent ${agentId} deficit: ${counter.counter} (increment)`);
232
+ }
233
+ } finally{
234
+ release();
235
+ }
236
+ }
237
+ /**
238
+ * Decrements deficit counter on acknowledgment (atomic lock protected).
239
+ * If counter reaches zero AND agent is COMPLETED, sends completion probe.
240
+ *
241
+ * @param agentId - Agent that received acknowledgment
242
+ * @param swarmId - Swarm identifier
243
+ */ async decrementDeficit(agentId, swarmId) {
244
+ const release = await this.acquireDeficitLock(agentId);
245
+ try {
246
+ const counter = this.deficitCounters.get(agentId);
247
+ if (counter) {
248
+ counter.counter--;
249
+ counter.lastUpdated = Date.now();
250
+ this.log(`Agent ${agentId} deficit: ${counter.counter} (decrement)`);
251
+ // Check for completion probe condition
252
+ if (counter.counter === 0 && counter.state === AgentState.COMPLETED) {
253
+ await this.checkAndSendProbe(agentId, swarmId);
254
+ }
255
+ }
256
+ } finally{
257
+ release();
258
+ }
259
+ }
260
+ /**
261
+ * Updates agent state in deficit counter.
262
+ *
263
+ * @param agentId - Agent identifier
264
+ * @param state - New agent state
265
+ */ updateAgentState(agentId, state) {
266
+ const counter = this.deficitCounters.get(agentId);
267
+ if (counter) {
268
+ counter.state = state;
269
+ counter.lastUpdated = Date.now();
270
+ this.log(`Agent ${agentId} state: ${state}`);
271
+ }
272
+ }
273
+ // ============================================
274
+ // Completion Probe System
275
+ // ============================================
276
+ /**
277
+ * Checks if agent should send completion probe and sends it.
278
+ * Condition: deficit counter = 0 AND state = COMPLETED
279
+ *
280
+ * @param agentId - Agent to check
281
+ * @param swarmId - Swarm identifier
282
+ */ async checkAndSendProbe(agentId, swarmId) {
283
+ const counter = this.deficitCounters.get(agentId);
284
+ if (!counter) return;
285
+ // Only send probe if counter=0 AND state=COMPLETED
286
+ if (counter.counter === 0 && counter.state === AgentState.COMPLETED) {
287
+ await this.sendCompletionProbe(agentId, swarmId);
288
+ }
289
+ }
290
+ /**
291
+ * Sends completion probe to all peer agents.
292
+ *
293
+ * @param agentId - Agent sending the probe
294
+ * @param swarmId - Swarm identifier
295
+ */ async sendCompletionProbe(agentId, swarmId) {
296
+ const agents = this.swarmAgents.get(swarmId);
297
+ if (!agents) return;
298
+ const peers = Array.from(agents).filter((id)=>id !== agentId);
299
+ this.log(`Agent ${agentId} sending completion probes to ${peers.length} peers`);
300
+ // Create probe metadata for each peer with Lamport timestamp
301
+ for (const peerId of peers){
302
+ // UNIQUE probe ID per peer to prevent Map overwrites
303
+ const probeId = `${this.generateProbeId(swarmId)}-${peerId}`;
304
+ const probe = {
305
+ probeId,
306
+ senderId: agentId,
307
+ recipientId: peerId,
308
+ lamportTimestamp: this.lamportClock.tick(),
309
+ physicalTime: Date.now(),
310
+ acknowledged: false
311
+ };
312
+ const probes = this.completionProbes.get(swarmId) || [];
313
+ probes.push(probe);
314
+ this.completionProbes.set(swarmId, probes);
315
+ // Send probe via message bus with Lamport timestamp
316
+ await this.messageBus.publish({
317
+ topic: 'completion.probe',
318
+ payload: {
319
+ probeId,
320
+ senderId: agentId,
321
+ recipientId: peerId,
322
+ swarmId,
323
+ lamportTimestamp: probe.lamportTimestamp,
324
+ physicalTime: probe.physicalTime
325
+ },
326
+ priority: MessagePriority.CRITICAL,
327
+ senderId: agentId,
328
+ recipientId: peerId
329
+ });
330
+ }
331
+ }
332
+ /**
333
+ * Handles incoming completion probe from peer agent.
334
+ * Updates local Lamport clock based on received timestamp.
335
+ *
336
+ * @param swarmId - Swarm identifier
337
+ * @param msg - Probe message
338
+ */ async handleCompletionProbe(swarmId, msg) {
339
+ const { probeId, senderId, recipientId, lamportTimestamp } = msg.payload;
340
+ // Update local clock based on received Lamport timestamp
341
+ if (lamportTimestamp !== undefined) {
342
+ this.lamportClock.update(lamportTimestamp);
343
+ }
344
+ this.log(`Agent ${recipientId} received completion probe ${probeId} from ${senderId}`);
345
+ // Send acknowledgment back to sender
346
+ await this.messageBus.publish({
347
+ topic: 'completion.probe.ack',
348
+ payload: {
349
+ probeId,
350
+ senderId: recipientId,
351
+ recipientId: senderId,
352
+ swarmId
353
+ },
354
+ priority: MessagePriority.CRITICAL,
355
+ senderId: recipientId,
356
+ recipientId: senderId
357
+ });
358
+ }
359
+ /**
360
+ * Handles probe acknowledgment from peer agent.
361
+ *
362
+ * @param swarmId - Swarm identifier
363
+ * @param msg - Acknowledgment message
364
+ */ async handleProbeAcknowledgment(swarmId, msg) {
365
+ const { probeId, senderId } = msg.payload;
366
+ // Mark probe as acknowledged
367
+ const probes = this.completionProbes.get(swarmId) || [];
368
+ const probe = probes.find((p)=>p.probeId === probeId && p.recipientId === senderId);
369
+ if (probe) {
370
+ probe.acknowledged = true;
371
+ this.log(`Probe ${probeId} acknowledged by ${senderId}`);
372
+ // Check if all probes acknowledged
373
+ await this.checkAllProbesAcknowledged(swarmId);
374
+ }
375
+ }
376
+ /**
377
+ * Checks if all completion probes have been acknowledged.
378
+ * If true, resolves completion detection promise.
379
+ *
380
+ * @param swarmId - Swarm identifier
381
+ */ async checkAllProbesAcknowledged(swarmId) {
382
+ const probes = this.completionProbes.get(swarmId) || [];
383
+ if (probes.length === 0) return;
384
+ const allAcknowledged = probes.every((p)=>p.acknowledged);
385
+ if (allAcknowledged) {
386
+ this.log(`All completion probes acknowledged for swarm ${swarmId}`);
387
+ // Resolve completion detection promise
388
+ const promise = this.completionPromises.get(swarmId);
389
+ if (promise) {
390
+ promise.resolve(true);
391
+ this.completionPromises.delete(swarmId);
392
+ }
393
+ }
394
+ }
395
+ /**
396
+ * Waits for all completion probes to return (distributed consensus).
397
+ *
398
+ * @param swarmId - Swarm identifier
399
+ * @returns Promise resolving to true when all probes acknowledged
400
+ */ async waitForAllProbes(swarmId) {
401
+ return new Promise((resolve, reject)=>{
402
+ // Store promise for later resolution
403
+ this.completionPromises.set(swarmId, {
404
+ resolve,
405
+ reject
406
+ });
407
+ // Set timeout
408
+ setTimeout(()=>{
409
+ const promise = this.completionPromises.get(swarmId);
410
+ if (promise) {
411
+ this.log(`Probe timeout for swarm ${swarmId}`);
412
+ promise.reject(new Error(`Completion probe timeout after ${this.config.probeTimeout}ms`));
413
+ this.completionPromises.delete(swarmId);
414
+ }
415
+ }, this.config.probeTimeout);
416
+ });
417
+ }
418
+ // ============================================
419
+ // Completion Detection
420
+ // ============================================
421
+ /**
422
+ * Detects completion for mesh topology swarm.
423
+ *
424
+ * Algorithm:
425
+ * 1. Check if all agents in COMPLETED state
426
+ * 2. Check if all deficit counters = 0
427
+ * 3. Wait for all completion probes to return
428
+ * 4. Return true if distributed consensus achieved
429
+ *
430
+ * Performance Target: <2000ms for 10-agent mesh
431
+ *
432
+ * @param swarmId - Swarm identifier
433
+ * @returns Promise resolving to true if swarm completed
434
+ */ async detectCompletion(swarmId) {
435
+ const startTime = Date.now();
436
+ const agents = this.swarmAgents.get(swarmId);
437
+ if (!agents) {
438
+ throw new Error(`Swarm ${swarmId} not initialized`);
439
+ }
440
+ // Check if all agents in COMPLETED state
441
+ const allCompleted = Array.from(agents).every((agentId)=>{
442
+ const counter = this.deficitCounters.get(agentId);
443
+ return counter && counter.state === AgentState.COMPLETED;
444
+ });
445
+ if (!allCompleted) {
446
+ this.log(`Swarm ${swarmId} not all agents completed`);
447
+ return false;
448
+ }
449
+ // Check if all deficit counters = 0
450
+ const allZeroDeficit = Array.from(agents).every((agentId)=>{
451
+ const counter = this.deficitCounters.get(agentId);
452
+ return counter && counter.counter === 0;
453
+ });
454
+ if (!allZeroDeficit) {
455
+ this.log(`Swarm ${swarmId} not all deficit counters zero`);
456
+ return false;
457
+ }
458
+ // Wait for all completion probes to return (distributed consensus)
459
+ try {
460
+ const completed = await this.waitForAllProbes(swarmId);
461
+ const elapsedTime = Date.now() - startTime;
462
+ this.log(`Swarm ${swarmId} completion detected in ${elapsedTime}ms`);
463
+ if (elapsedTime > this.config.maxDetectionTime) {
464
+ console.warn(`[MeshCompletionDetector] Completion detection took ${elapsedTime}ms, ` + `exceeding target ${this.config.maxDetectionTime}ms`);
465
+ }
466
+ return completed;
467
+ } catch (error) {
468
+ this.log(`Swarm ${swarmId} completion detection failed: ${error}`);
469
+ return false;
470
+ }
471
+ }
472
+ // ============================================
473
+ // Utilities
474
+ // ============================================
475
+ /**
476
+ * Generates unique probe ID.
477
+ *
478
+ * @param swarmId - Swarm identifier
479
+ * @returns Unique probe ID
480
+ */ generateProbeId(swarmId) {
481
+ return `probe-${swarmId}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
482
+ }
483
+ /**
484
+ * Logs message if logging enabled.
485
+ *
486
+ * @param message - Log message
487
+ */ log(message) {
488
+ if (this.config.enableLogging) {
489
+ console.log(`[MeshCompletionDetector] ${message}`);
490
+ }
491
+ }
492
+ /**
493
+ * Gets current deficit counter for agent.
494
+ *
495
+ * @param agentId - Agent identifier
496
+ * @returns Deficit counter or undefined
497
+ */ getDeficitCounter(agentId) {
498
+ return this.deficitCounters.get(agentId);
499
+ }
500
+ /**
501
+ * Gets all completion probes for swarm.
502
+ *
503
+ * @param swarmId - Swarm identifier
504
+ * @returns Array of completion probes
505
+ */ getCompletionProbes(swarmId) {
506
+ return this.completionProbes.get(swarmId) || [];
507
+ }
508
+ /**
509
+ * Clears all state for swarm (cleanup after completion).
510
+ *
511
+ * @param swarmId - Swarm identifier
512
+ */ cleanup(swarmId) {
513
+ const agents = this.swarmAgents.get(swarmId);
514
+ if (agents) {
515
+ for (const agentId of agents){
516
+ this.deficitCounters.delete(agentId);
517
+ }
518
+ }
519
+ this.swarmAgents.delete(swarmId);
520
+ this.completionProbes.delete(swarmId);
521
+ this.completionPromises.delete(swarmId);
522
+ this.log(`Cleaned up swarm ${swarmId}`);
523
+ }
524
+ }
525
+
526
+ //# sourceMappingURL=mesh-detector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../src/coordination/archives/v2-sdk-typescript/v2/completion/mesh-detector.ts"],"names":["MessagePriority","AgentState","LamportClock","MeshCompletionDetector","messageBus","config","deficitCounters","completionProbes","swarmAgents","completionPromises","deficitLocks","lamportClock","probeTimeout","maxDetectionTime","enableLogging","Map","initializeSwarm","swarmId","agentIds","length","Error","set","Set","agentId","counter","state","IDLE","lastUpdated","Date","now","log","startMonitoring","agents","get","subscribe","topic","handler","msg","senderId","payload","has","incrementDeficit","priority","HIGH","decrementDeficit","newState","updateAgentState","COMPLETED","checkAndSendProbe","CRITICAL","handleCompletionProbe","handleProbeAcknowledgment","acquireDeficitLock","existingLock","release","newLock","Promise","resolve","delete","sendCompletionProbe","peers","Array","from","filter","id","peerId","probeId","generateProbeId","probe","recipientId","lamportTimestamp","tick","physicalTime","acknowledged","probes","push","publish","undefined","update","find","p","checkAllProbesAcknowledged","allAcknowledged","every","promise","waitForAllProbes","reject","setTimeout","detectCompletion","startTime","allCompleted","allZeroDeficit","completed","elapsedTime","console","warn","error","Math","random","toString","substr","message","getDeficitCounter","getCompletionProbes","cleanup"],"mappings":"AAAA;;;;;;;;;;;;;;;;CAgBC,GAGD,SAAkBA,eAAe,QAAQ,qBAAqB;AAC9D,SAASC,UAAU,QAAQ,mCAAmC;AAC9D,SAASC,YAAY,QAAQ,qBAAqB;AAsClD;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BC,GACD,OAAO,MAAMC;IACHC,WAA0B;IAC1BC,OAAqC;IACrCC,gBAA6C;IAC7CC,iBAAiD;IACjDC,YAAsC;IACtCC,mBAAuG;IACvGC,aAA+C;IAC/CC,aAA2B;IAEnC;;;;;GAKC,GACD,YAAYP,UAAyB,EAAEC,MAA2B,CAAE;QAClE,IAAI,CAACD,UAAU,GAAGA;QAClB,IAAI,CAACC,MAA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