claude-flow-novice 1.6.3 → 1.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (290) hide show
  1. package/.claude/commands/parse-epic.js +180 -0
  2. package/.claude/settings.json +12 -2
  3. package/.claude/settings.local.json +4 -2
  4. package/.claude-flow-novice/dist/mcp/mcp-server-novice.js +37 -2
  5. package/.claude-flow-novice/dist/mcp/transports/base.js +5 -0
  6. package/.claude-flow-novice/dist/mcp/transports/base.js.map +1 -0
  7. package/.claude-flow-novice/dist/mcp/transports/http.js +414 -0
  8. package/.claude-flow-novice/dist/mcp/transports/http.js.map +1 -0
  9. package/.claude-flow-novice/dist/mcp/transports/stdio.js +217 -0
  10. package/.claude-flow-novice/dist/mcp/transports/stdio.js.map +1 -0
  11. package/.claude-flow-novice/dist/src/cli/commands/parse-epic.js +129 -0
  12. package/.claude-flow-novice/dist/src/cli/commands/parse-epic.js.map +1 -0
  13. package/.claude-flow-novice/dist/src/cli/index.js +3 -0
  14. package/.claude-flow-novice/dist/src/cli/index.js.map +1 -1
  15. package/.claude-flow-novice/dist/src/cli/utils/epic-parser.js +266 -0
  16. package/.claude-flow-novice/dist/src/cli/utils/epic-parser.js.map +1 -0
  17. package/.claude-flow-novice/dist/src/communication/message-bus.js +105 -2
  18. package/.claude-flow-novice/dist/src/communication/message-bus.js.map +1 -1
  19. package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js +1 -1
  20. package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js.map +1 -1
  21. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/artifact-cache-optimizer.js +632 -0
  22. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/artifact-cache-optimizer.js.map +1 -0
  23. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/index.js +11 -0
  24. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/index.js.map +1 -0
  25. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/checkpoints/checkpoint-compressor.js +318 -0
  26. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/checkpoints/checkpoint-compressor.js.map +1 -0
  27. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/completion-detector.js +234 -0
  28. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/completion-detector.js.map +1 -0
  29. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/hierarchical-detector.js +347 -0
  30. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/hierarchical-detector.js.map +1 -0
  31. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/index.js +13 -0
  32. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/index.js.map +1 -0
  33. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/lamport-clock.js +173 -0
  34. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/lamport-clock.js.map +1 -0
  35. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/mesh-detector.js +526 -0
  36. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/mesh-detector.js.map +1 -0
  37. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/sdk-completion-detector.js +443 -0
  38. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/sdk-completion-detector.js.map +1 -0
  39. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/swarm-shutdown.js +366 -0
  40. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/swarm-shutdown.js.map +1 -0
  41. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinator-factory.js +287 -0
  42. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinator-factory.js.map +1 -0
  43. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.example.js +364 -0
  44. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.example.js.map +1 -0
  45. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.js +492 -0
  46. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.js.map +1 -0
  47. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/hierarchical-coordinator.js +786 -0
  48. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/hierarchical-coordinator.js.map +1 -0
  49. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/index.js +16 -0
  50. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/index.js.map +1 -0
  51. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/parent-child-manager.js +342 -0
  52. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/parent-child-manager.js.map +1 -0
  53. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/swarm-coordinator-v2.js +601 -0
  54. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/swarm-coordinator-v2.js.map +1 -0
  55. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/agent-state.js +9 -0
  56. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/agent-state.js.map +1 -0
  57. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dead-letter-queue.js +413 -0
  58. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dead-letter-queue.js.map +1 -0
  59. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-graph.js +471 -0
  60. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-graph.js.map +1 -0
  61. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-node.js +379 -0
  62. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-node.js.map +1 -0
  63. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-resolver.js +335 -0
  64. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-resolver.js.map +1 -0
  65. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/help-request-metrics.js +211 -0
  66. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/help-request-metrics.js.map +1 -0
  67. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/index.js +33 -0
  68. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/index.js.map +1 -0
  69. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-broker.js +920 -0
  70. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-broker.js.map +1 -0
  71. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-router.js +385 -0
  72. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-router.js.map +1 -0
  73. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message.js +138 -0
  74. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message.js.map +1 -0
  75. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/resource-manager-safe.js +478 -0
  76. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/resource-manager-safe.js.map +1 -0
  77. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine-config.js +358 -0
  78. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine-config.js.map +1 -0
  79. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine.js +588 -0
  80. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine.js.map +1 -0
  81. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-transition.js +153 -0
  82. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-transition.js.map +1 -0
  83. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/task-scheduler.js +360 -0
  84. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/task-scheduler.js.map +1 -0
  85. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/topic-manager.js +337 -0
  86. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/topic-manager.js.map +1 -0
  87. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/deadlock-detector.js +424 -0
  88. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/deadlock-detector.js.map +1 -0
  89. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/index.js +9 -0
  90. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/index.js.map +1 -0
  91. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/resource-manager.js +669 -0
  92. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/resource-manager.js.map +1 -0
  93. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/artifact-storage.js +451 -0
  94. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/artifact-storage.js.map +1 -0
  95. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/cycle-detector.js +271 -0
  96. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/cycle-detector.js.map +1 -0
  97. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-graph.js +335 -0
  98. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-graph.js.map +1 -0
  99. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-manager.js +439 -0
  100. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-manager.js.map +1 -0
  101. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-request.js +92 -0
  102. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-request.js.map +1 -0
  103. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/index.js +21 -0
  104. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/index.js.map +1 -0
  105. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/topological-sort.js +223 -0
  106. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/topological-sort.js.map +1 -0
  107. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-coordinator.js +436 -0
  108. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-coordinator.js.map +1 -0
  109. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-matcher.js +278 -0
  110. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-matcher.js.map +1 -0
  111. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request-handler.js +317 -0
  112. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request-handler.js.map +1 -0
  113. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request.js +273 -0
  114. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request.js.map +1 -0
  115. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/index.js +15 -0
  116. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/index.js.map +1 -0
  117. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/waiting-agent-pool.js +512 -0
  118. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/waiting-agent-pool.js.map +1 -0
  119. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/index.js +67 -0
  120. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/index.js.map +1 -0
  121. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/help-deadlock-integration.js +557 -0
  122. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/help-deadlock-integration.js.map +1 -0
  123. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/index.js +14 -0
  124. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/index.js.map +1 -0
  125. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.example.js +212 -0
  126. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.example.js.map +1 -0
  127. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.js +552 -0
  128. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.js.map +1 -0
  129. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/state-machine-integration.js +635 -0
  130. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/state-machine-integration.js.map +1 -0
  131. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/IArtifactStorage.js +28 -0
  132. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/IArtifactStorage.js.map +1 -0
  133. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ICoordinator.js +9 -0
  134. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ICoordinator.js.map +1 -0
  135. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ISessionStore.js +25 -0
  136. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ISessionStore.js.map +1 -0
  137. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/index.js +14 -0
  138. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/index.js.map +1 -0
  139. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/artifact-adapter.js +308 -0
  140. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/artifact-adapter.js.map +1 -0
  141. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/completion-storage.js +439 -0
  142. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/completion-storage.js.map +1 -0
  143. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-graph-storage.js +540 -0
  144. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-graph-storage.js.map +1 -0
  145. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-storage.js +367 -0
  146. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-storage.js.map +1 -0
  147. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/index.js +14 -0
  148. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/index.js.map +1 -0
  149. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/message-storage.js +518 -0
  150. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/message-storage.js.map +1 -0
  151. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/state-storage.js +377 -0
  152. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/state-storage.js.map +1 -0
  153. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channel.js +371 -0
  154. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channel.js.map +1 -0
  155. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/dependency-channel.js +355 -0
  156. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/dependency-channel.js.map +1 -0
  157. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/help-channel.js +424 -0
  158. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/help-channel.js.map +1 -0
  159. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/index.js +16 -0
  160. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/index.js.map +1 -0
  161. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/state-channel.js +295 -0
  162. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/state-channel.js.map +1 -0
  163. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/task-channel.js +411 -0
  164. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/task-channel.js.map +1 -0
  165. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/index.js +14 -0
  166. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/index.js.map +1 -0
  167. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-bus.js +387 -0
  168. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-bus.js.map +1 -0
  169. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-persistence.js +589 -0
  170. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-persistence.js.map +1 -0
  171. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-router.js +444 -0
  172. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-router.js.map +1 -0
  173. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/artifact-storage.js +560 -0
  174. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/artifact-storage.js.map +1 -0
  175. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/background-orchestrator.js +335 -0
  176. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/background-orchestrator.js.map +1 -0
  177. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/bash-output-monitor.js +104 -0
  178. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/bash-output-monitor.js.map +1 -0
  179. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/checkpoint-manager.js +847 -0
  180. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/checkpoint-manager.js.map +1 -0
  181. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/help-coordinator.js +470 -0
  182. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/help-coordinator.js.map +1 -0
  183. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/hierarchical-background-integration.js +450 -0
  184. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/hierarchical-background-integration.js.map +1 -0
  185. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/index.js +13 -0
  186. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/index.js.map +1 -0
  187. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/message-bus-integration.js +625 -0
  188. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/message-bus-integration.js.map +1 -0
  189. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/multi-level-control.js +545 -0
  190. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/multi-level-control.js.map +1 -0
  191. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-controller.js +740 -0
  192. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-controller.js.map +1 -0
  193. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-message-integration.js +415 -0
  194. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-message-integration.js.map +1 -0
  195. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/session-pool-optimizer.js +615 -0
  196. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/session-pool-optimizer.js.map +1 -0
  197. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-machine-integration.js +547 -0
  198. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-machine-integration.js.map +1 -0
  199. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-sdk-integration.js +342 -0
  200. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-sdk-integration.js.map +1 -0
  201. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/security/payload-validator.js +259 -0
  202. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/security/payload-validator.js.map +1 -0
  203. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/framework-registry.js +273 -0
  204. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/framework-registry.js.map +1 -0
  205. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/index.js +8 -0
  206. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/index.js.map +1 -0
  207. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-config-manager.js +310 -0
  208. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-config-manager.js.map +1 -0
  209. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-validator.js +218 -0
  210. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-validator.js.map +1 -0
  211. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/types/sdk.js +9 -0
  212. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/types/sdk.js.map +1 -0
  213. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/index.js +6 -0
  214. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/index.js.map +1 -0
  215. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/priority-queue.js +145 -0
  216. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/priority-queue.js.map +1 -0
  217. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/sdk-helpers.js +122 -0
  218. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/sdk-helpers.js.map +1 -0
  219. package/.claude-flow-novice/dist/src/coordination/config-translator.js +17 -43
  220. package/.claude-flow-novice/dist/src/coordination/config-translator.js.map +1 -1
  221. package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js +34 -76
  222. package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js.map +1 -1
  223. package/.claude-flow-novice/dist/src/coordination/index.js +3 -0
  224. package/.claude-flow-novice/dist/src/coordination/index.js.map +1 -1
  225. package/.claude-flow-novice/dist/src/coordination/shared/core/agent-state.js +172 -0
  226. package/.claude-flow-novice/dist/src/coordination/shared/core/agent-state.js.map +1 -0
  227. package/.claude-flow-novice/dist/src/coordination/shared/core/index.js +7 -0
  228. package/.claude-flow-novice/dist/src/coordination/shared/core/index.js.map +1 -0
  229. package/.claude-flow-novice/dist/src/coordination/shared/index.js +19 -0
  230. package/.claude-flow-novice/dist/src/coordination/shared/index.js.map +1 -0
  231. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/ICoordinator.js +24 -0
  232. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/ICoordinator.js.map +1 -0
  233. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/index.js +7 -0
  234. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/index.js.map +1 -0
  235. package/.claude-flow-novice/dist/src/coordination/shared/message-broker.js +920 -0
  236. package/.claude-flow-novice/dist/src/coordination/shared/message-broker.js.map +1 -0
  237. package/.claude-flow-novice/dist/src/coordination/shared/message.js +138 -0
  238. package/.claude-flow-novice/dist/src/coordination/shared/message.js.map +1 -0
  239. package/.claude-flow-novice/dist/src/coordination/shared/security/payload-validator.js +259 -0
  240. package/.claude-flow-novice/dist/src/coordination/shared/security/payload-validator.js.map +1 -0
  241. package/.claude-flow-novice/dist/src/coordination/shared/transparency/index.js +17 -0
  242. package/.claude-flow-novice/dist/src/coordination/shared/transparency/index.js.map +1 -0
  243. package/.claude-flow-novice/dist/src/coordination/shared/transparency/interfaces/transparency-system.js +19 -0
  244. package/.claude-flow-novice/dist/src/coordination/shared/transparency/interfaces/transparency-system.js.map +1 -0
  245. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-integration.js +357 -0
  246. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-integration.js.map +1 -0
  247. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-system.js +679 -0
  248. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-system.js.map +1 -0
  249. package/.claude-flow-novice/dist/src/coordination/shared/types/index.js +7 -0
  250. package/.claude-flow-novice/dist/src/coordination/shared/types/index.js.map +1 -0
  251. package/.claude-flow-novice/dist/src/coordination/shared/types/sdk.js +10 -0
  252. package/.claude-flow-novice/dist/src/coordination/shared/types/sdk.js.map +1 -0
  253. package/.claude-flow-novice/dist/src/coordination/v1-transparency/interfaces/v1-transparency-system.js +12 -0
  254. package/.claude-flow-novice/dist/src/coordination/v1-transparency/interfaces/v1-transparency-system.js.map +1 -0
  255. package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-to-v2-bridge.js +433 -0
  256. package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-to-v2-bridge.js.map +1 -0
  257. package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-transparency-adapter.js +1468 -0
  258. package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-transparency-adapter.js.map +1 -0
  259. package/.claude-flow-novice/dist/src/feature-flags/core/FeatureFlagManager.js +52 -2
  260. package/.claude-flow-novice/dist/src/feature-flags/core/FeatureFlagManager.js.map +1 -1
  261. package/.claude-flow-novice/dist/src/mcp/mcp-server-novice.js +37 -2
  262. package/.claude-flow-novice/dist/src/mcp/session-manager.js +3 -1
  263. package/.claude-flow-novice/dist/src/mcp/session-manager.js.map +1 -1
  264. package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js +5 -0
  265. package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js.map +1 -1
  266. package/.claude-flow-novice/dist/src/providers/provider-manager.js +41 -6
  267. package/.claude-flow-novice/dist/src/providers/provider-manager.js.map +1 -1
  268. package/.claude-flow-novice/dist/src/providers/tiered-router.js +9 -17
  269. package/.claude-flow-novice/dist/src/providers/tiered-router.js.map +1 -1
  270. package/.claude-flow-novice/dist/src/utils/markdown-sanitizer.js +65 -41
  271. package/.claude-flow-novice/dist/src/utils/markdown-sanitizer.js.map +1 -1
  272. package/.claude-flow-novice/dist/src/web/api/server.js +1 -1
  273. package/.claude-flow-novice/dist/src/web/api/server.js.map +1 -1
  274. package/.claude-flow-novice/dist/src/workflows/progressive-rollout-manager.js +30 -0
  275. package/.claude-flow-novice/dist/src/workflows/progressive-rollout-manager.js.map +1 -1
  276. package/.claude-flow-novice/metrics.db +0 -0
  277. package/.claude-flow-novice/metrics.db-shm +0 -0
  278. package/.claude-flow-novice/metrics.db-wal +0 -0
  279. package/CLAUDE.md +72 -0
  280. package/config/hooks/post-edit-pipeline.js +68 -118
  281. package/config/hooks/pre-tool-memory-safety.js +209 -0
  282. package/package.json +7 -4
  283. package/scripts/cleanup-idle-sessions.sh +59 -0
  284. package/scripts/monitoring/alert-monitor.sh +220 -0
  285. package/scripts/monitoring/view-alerts.sh +307 -0
  286. package/scripts/test-provider-routing.cjs +7 -9
  287. package/scripts/test-zai-api.cjs +2 -2
  288. package/src/slash-commands/parse-epic.js +1 -1
  289. package/wiki/Provider-Routing.md +57 -69
  290. package/MEMORY_LEAK_ROOT_CAUSE.md +0 -149
@@ -0,0 +1,589 @@
1
+ /**
2
+ * Agent Coordination V2 - Message Persistence Implementation
3
+ *
4
+ * Artifact-backed message persistence with TTL-based expiration,
5
+ * circular buffer capacity limits, and replay functionality.
6
+ *
7
+ * Performance targets:
8
+ * - Storage: <15ms (p95) for message append
9
+ * - Retrieval: <15ms (p95) for message replay
10
+ * - Compression: MessagePack + gzip (60-70% size reduction)
11
+ *
12
+ * Features:
13
+ * - TTL-based automatic message expiration
14
+ * - Circular buffer with configurable capacity limits
15
+ * - Message replay for history reconstruction
16
+ * - Topic-based message filtering
17
+ * - Binary serialization (MessagePack)
18
+ * - Gzip compression for storage efficiency
19
+ * - Integrity verification with SHA-256 checksums
20
+ *
21
+ * @module coordination/v2/messaging/message-persistence
22
+ */ import { DependencyArtifactStorage } from '../dependency/artifact-storage.js';
23
+ import { gzip, gunzip } from 'zlib';
24
+ import { promisify } from 'util';
25
+ const gzipAsync = promisify(gzip);
26
+ const gunzipAsync = promisify(gunzip);
27
+ /**
28
+ * MessagePersistence - High-performance message storage and replay
29
+ *
30
+ * Provides artifact-backed persistence for message bus with:
31
+ * - TTL-based automatic expiration
32
+ * - Circular buffer capacity limits
33
+ * - Message replay for history reconstruction
34
+ * - Binary serialization (MessagePack) + compression (gzip)
35
+ * - Topic-based filtering and indexing
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * const persistence = new MessagePersistence({
40
+ * storagePath: '.claude-flow/artifacts/messages',
41
+ * maxMessages: 10000,
42
+ * defaultTtlMs: 24 * 60 * 60 * 1000 // 24 hours
43
+ * });
44
+ * await persistence.initialize();
45
+ *
46
+ * // Store message
47
+ * await persistence.storeMessage(message);
48
+ *
49
+ * // Replay messages by topic
50
+ * const history = await persistence.replayMessages({
51
+ * topic: 'task.completed',
52
+ * startTime: Date.now() - 3600000 // Last hour
53
+ * });
54
+ *
55
+ * console.log(persistence.getMetrics().p95StoreLatencyMs); // Target: <15ms
56
+ * ```
57
+ */ export class MessagePersistence {
58
+ storage;
59
+ config;
60
+ messages;
61
+ topicIndex;
62
+ expirationQueue;
63
+ metrics;
64
+ latencyBuffer;
65
+ cleanupTimer;
66
+ ready = false;
67
+ /**
68
+ * Creates a new message persistence instance
69
+ *
70
+ * @param config - Persistence configuration
71
+ */ constructor(config = {}){
72
+ this.config = {
73
+ storagePath: config.storagePath || '.claude-flow/artifacts/messages',
74
+ maxMessages: config.maxMessages || 10000,
75
+ defaultTtlMs: config.defaultTtlMs || 24 * 60 * 60 * 1000,
76
+ cacheSize: config.cacheSize || 100,
77
+ autoCleanup: config.autoCleanup !== false,
78
+ cleanupIntervalMs: config.cleanupIntervalMs || 5 * 60 * 1000 // 5 minutes
79
+ };
80
+ this.storage = new DependencyArtifactStorage({
81
+ storagePath: this.config.storagePath,
82
+ cacheSize: this.config.cacheSize
83
+ });
84
+ this.messages = new Map();
85
+ this.topicIndex = new Map();
86
+ this.expirationQueue = [];
87
+ this.metrics = this.initializeMetrics();
88
+ this.latencyBuffer = [];
89
+ }
90
+ // ===========================
91
+ // Lifecycle
92
+ // ===========================
93
+ /**
94
+ * Initialize message persistence
95
+ *
96
+ * Loads existing message store and starts cleanup timer.
97
+ */ async initialize() {
98
+ if (this.ready) return;
99
+ // Initialize storage backend
100
+ await this.storage.initialize();
101
+ // Load existing message store
102
+ await this.loadMessageStore();
103
+ // Start automatic cleanup if enabled
104
+ if (this.config.autoCleanup) {
105
+ this.startCleanupTimer();
106
+ }
107
+ this.ready = true;
108
+ }
109
+ /**
110
+ * Close persistence and persist state
111
+ */ async close() {
112
+ if (!this.ready) return;
113
+ // Stop cleanup timer
114
+ if (this.cleanupTimer) {
115
+ clearInterval(this.cleanupTimer);
116
+ this.cleanupTimer = undefined;
117
+ }
118
+ // Persist current message store
119
+ await this.persistMessageStore();
120
+ // Close storage backend
121
+ await this.storage.close();
122
+ this.ready = false;
123
+ }
124
+ /**
125
+ * Check if persistence is ready
126
+ */ isReady() {
127
+ return this.ready;
128
+ }
129
+ // ===========================
130
+ // Core Persistence Operations
131
+ // ===========================
132
+ /**
133
+ * Store message with TTL-based expiration
134
+ *
135
+ * Performance target: <15ms (p95)
136
+ *
137
+ * @param message - Message to store
138
+ * @param ttlMs - Time-to-live in milliseconds (optional, uses default if not provided)
139
+ * @throws Error if storage fails
140
+ */ async storeMessage(message, ttlMs) {
141
+ this.ensureReady();
142
+ const startTime = Date.now();
143
+ try {
144
+ // Calculate expiration timestamp
145
+ const effectiveTtl = ttlMs ?? this.config.defaultTtlMs;
146
+ const expiresAt = message.timestamp + effectiveTtl;
147
+ // Serialize message
148
+ const serialized = {
149
+ id: message.id,
150
+ topic: message.topic,
151
+ payload: message.payload,
152
+ priority: message.priority,
153
+ timestamp: message.timestamp,
154
+ expiresAt,
155
+ replyTo: message.replyTo,
156
+ correlationId: message.correlationId,
157
+ senderId: message.senderId,
158
+ recipientId: message.recipientId,
159
+ metadata: message.metadata
160
+ };
161
+ // Check circular buffer capacity and evict oldest if needed
162
+ if (this.messages.size >= this.config.maxMessages) {
163
+ await this.evictOldestMessage();
164
+ }
165
+ // Add to in-memory store
166
+ this.messages.set(message.id, serialized);
167
+ // Update topic index
168
+ this.indexMessageByTopic(message.id, message.topic);
169
+ // Add to expiration queue
170
+ this.expirationQueue.push({
171
+ messageId: message.id,
172
+ expiresAt
173
+ });
174
+ this.expirationQueue.sort((a, b)=>a.expiresAt - b.expiresAt);
175
+ // Persist to storage (batched for performance)
176
+ await this.persistMessageStore();
177
+ // Update metrics
178
+ const latency = Date.now() - startTime;
179
+ this.updateStoreMetrics(latency);
180
+ // Performance warning if exceeds target
181
+ if (latency > 15) {
182
+ console.warn(`[MessagePersistence] Store latency ${latency}ms exceeds 15ms target for message ${message.id}`);
183
+ }
184
+ } catch (error) {
185
+ throw new Error(`Failed to store message ${message.id}: ${error instanceof Error ? error.message : String(error)}`);
186
+ }
187
+ }
188
+ /**
189
+ * Retrieve message by ID
190
+ *
191
+ * Performance target: <15ms (p95)
192
+ *
193
+ * @param messageId - Message identifier
194
+ * @returns Message if found and not expired, null otherwise
195
+ */ async retrieveMessage(messageId) {
196
+ this.ensureReady();
197
+ const startTime = Date.now();
198
+ try {
199
+ const serialized = this.messages.get(messageId);
200
+ if (!serialized) {
201
+ return null;
202
+ }
203
+ // Check if expired
204
+ if (Date.now() > serialized.expiresAt) {
205
+ // Remove expired message
206
+ await this.removeMessage(messageId);
207
+ return null;
208
+ }
209
+ // Reconstruct message
210
+ const message = this.deserializeMessage(serialized);
211
+ // Update metrics
212
+ const latency = Date.now() - startTime;
213
+ this.updateRetrieveMetrics(latency);
214
+ return message;
215
+ } catch (error) {
216
+ throw new Error(`Failed to retrieve message ${messageId}: ${error instanceof Error ? error.message : String(error)}`);
217
+ }
218
+ }
219
+ /**
220
+ * Replay messages matching query criteria
221
+ *
222
+ * Supports topic filtering, time ranges, priority filtering, and pagination.
223
+ *
224
+ * @param options - Query options for filtering and pagination
225
+ * @returns Array of matching messages (sorted by timestamp ascending)
226
+ */ async replayMessages(options = {}) {
227
+ this.ensureReady();
228
+ const startTime = Date.now();
229
+ try {
230
+ let candidates;
231
+ // Filter by topic if provided
232
+ if (options.topic) {
233
+ const messageIds = this.getMessageIdsByTopic(options.topic);
234
+ candidates = Array.from(messageIds).map((id)=>this.messages.get(id)).filter((msg)=>msg !== undefined);
235
+ } else {
236
+ candidates = Array.from(this.messages.values());
237
+ }
238
+ // Apply filters
239
+ const filtered = candidates.filter((msg)=>{
240
+ // Check expiration
241
+ if (Date.now() > msg.expiresAt) {
242
+ return false;
243
+ }
244
+ // Time range filter
245
+ if (options.startTime !== undefined && msg.timestamp < options.startTime) {
246
+ return false;
247
+ }
248
+ if (options.endTime !== undefined && msg.timestamp > options.endTime) {
249
+ return false;
250
+ }
251
+ // Priority filter
252
+ if (options.minPriority !== undefined && msg.priority < options.minPriority) {
253
+ return false;
254
+ }
255
+ // Sender filter
256
+ if (options.senderId !== undefined && msg.senderId !== options.senderId) {
257
+ return false;
258
+ }
259
+ // Recipient filter
260
+ if (options.recipientId !== undefined && msg.recipientId !== options.recipientId) {
261
+ return false;
262
+ }
263
+ // Correlation ID filter
264
+ if (options.correlationId !== undefined && msg.correlationId !== options.correlationId) {
265
+ return false;
266
+ }
267
+ return true;
268
+ });
269
+ // Sort by timestamp (ascending)
270
+ filtered.sort((a, b)=>a.timestamp - b.timestamp);
271
+ // Apply limit
272
+ const limited = options.limit !== undefined ? filtered.slice(0, options.limit) : filtered;
273
+ // Reconstruct messages
274
+ const messages = limited.map((msg)=>this.deserializeMessage(msg));
275
+ // Update metrics
276
+ const latency = Date.now() - startTime;
277
+ this.metrics.totalRetrieved += messages.length;
278
+ this.updateRetrieveMetrics(latency);
279
+ return messages;
280
+ } catch (error) {
281
+ throw new Error(`Failed to replay messages: ${error instanceof Error ? error.message : String(error)}`);
282
+ }
283
+ }
284
+ /**
285
+ * Remove message from persistence
286
+ *
287
+ * @param messageId - Message identifier
288
+ */ async removeMessage(messageId) {
289
+ this.ensureReady();
290
+ const serialized = this.messages.get(messageId);
291
+ if (!serialized) {
292
+ return;
293
+ }
294
+ // Remove from in-memory store
295
+ this.messages.delete(messageId);
296
+ // Remove from topic index
297
+ this.removeFromTopicIndex(messageId, serialized.topic);
298
+ // Remove from expiration queue
299
+ this.expirationQueue = this.expirationQueue.filter((e)=>e.messageId !== messageId);
300
+ // Persist changes
301
+ await this.persistMessageStore();
302
+ }
303
+ /**
304
+ * Clear all messages
305
+ */ async clear() {
306
+ this.ensureReady();
307
+ this.messages.clear();
308
+ this.topicIndex.clear();
309
+ this.expirationQueue = [];
310
+ await this.storage.clear();
311
+ this.metrics = this.initializeMetrics();
312
+ }
313
+ // ===========================
314
+ // Maintenance Operations
315
+ // ===========================
316
+ /**
317
+ * Clean up expired messages
318
+ *
319
+ * Removes messages that have exceeded their TTL.
320
+ *
321
+ * @returns Number of messages removed
322
+ */ async cleanupExpiredMessages() {
323
+ this.ensureReady();
324
+ const now = Date.now();
325
+ const expiredCount = 0;
326
+ let removed = 0;
327
+ // Process expiration queue (already sorted by expiresAt)
328
+ while(this.expirationQueue.length > 0 && this.expirationQueue[0].expiresAt <= now){
329
+ const { messageId } = this.expirationQueue.shift();
330
+ const serialized = this.messages.get(messageId);
331
+ if (serialized) {
332
+ this.messages.delete(messageId);
333
+ this.removeFromTopicIndex(messageId, serialized.topic);
334
+ removed++;
335
+ }
336
+ }
337
+ if (removed > 0) {
338
+ // Persist changes
339
+ await this.persistMessageStore();
340
+ // Update metrics
341
+ this.metrics.totalExpired += removed;
342
+ this.metrics.lastCleanupAt = now;
343
+ }
344
+ return removed;
345
+ }
346
+ /**
347
+ * Get persistence metrics
348
+ */ getMetrics() {
349
+ return {
350
+ ...this.metrics,
351
+ currentCount: this.messages.size
352
+ };
353
+ }
354
+ // ===========================
355
+ // Private Helpers
356
+ // ===========================
357
+ /**
358
+ * Ensure persistence is ready
359
+ */ ensureReady() {
360
+ if (!this.ready) {
361
+ throw new Error('MessagePersistence not initialized. Call initialize() first.');
362
+ }
363
+ }
364
+ /**
365
+ * Start automatic cleanup timer
366
+ */ startCleanupTimer() {
367
+ this.cleanupTimer = setInterval(async ()=>{
368
+ try {
369
+ await this.cleanupExpiredMessages();
370
+ } catch (error) {
371
+ console.error('[MessagePersistence] Cleanup error:', error);
372
+ }
373
+ }, this.config.cleanupIntervalMs);
374
+ }
375
+ /**
376
+ * Evict oldest message (circular buffer behavior)
377
+ */ async evictOldestMessage() {
378
+ if (this.messages.size === 0) return;
379
+ // Find oldest message by timestamp
380
+ let oldestId;
381
+ let oldestTimestamp = Infinity;
382
+ for (const [id, msg] of Array.from(this.messages.entries())){
383
+ if (msg.timestamp < oldestTimestamp) {
384
+ oldestTimestamp = msg.timestamp;
385
+ oldestId = id;
386
+ }
387
+ }
388
+ if (oldestId) {
389
+ await this.removeMessage(oldestId);
390
+ }
391
+ }
392
+ /**
393
+ * Index message by topic for fast topic-based queries
394
+ */ indexMessageByTopic(messageId, topic) {
395
+ if (!this.topicIndex.has(topic)) {
396
+ this.topicIndex.set(topic, new Set());
397
+ }
398
+ this.topicIndex.get(topic).add(messageId);
399
+ }
400
+ /**
401
+ * Remove message from topic index
402
+ */ removeFromTopicIndex(messageId, topic) {
403
+ const messageIds = this.topicIndex.get(topic);
404
+ if (messageIds) {
405
+ messageIds.delete(messageId);
406
+ if (messageIds.size === 0) {
407
+ this.topicIndex.delete(topic);
408
+ }
409
+ }
410
+ }
411
+ /**
412
+ * Get message IDs by topic pattern (supports wildcards)
413
+ */ getMessageIdsByTopic(topicPattern) {
414
+ const result = new Set();
415
+ for (const [topic, messageIds] of Array.from(this.topicIndex.entries())){
416
+ if (this.matchesTopic(topic, topicPattern)) {
417
+ for (const id of Array.from(messageIds)){
418
+ result.add(id);
419
+ }
420
+ }
421
+ }
422
+ return result;
423
+ }
424
+ /**
425
+ * Check if topic matches pattern (supports wildcards)
426
+ */ matchesTopic(topic, pattern) {
427
+ if (pattern === '*' || pattern === '**') {
428
+ return true;
429
+ }
430
+ if (!pattern.includes('*')) {
431
+ return topic === pattern;
432
+ }
433
+ const regexPattern = pattern.replace(/\./g, '\\.').replace(/\*\*/g, '.*').replace(/\*/g, '[^.]*');
434
+ const regex = new RegExp(`^${regexPattern}$`);
435
+ return regex.test(topic);
436
+ }
437
+ /**
438
+ * Persist message store to artifact storage
439
+ */ async persistMessageStore() {
440
+ const storeId = 'message-store';
441
+ const store = {
442
+ version: 1,
443
+ metadata: {
444
+ storeId,
445
+ createdAt: Date.now(),
446
+ updatedAt: Date.now(),
447
+ messageCount: this.messages.size,
448
+ oldestTimestamp: this.getOldestTimestamp(),
449
+ newestTimestamp: this.getNewestTimestamp()
450
+ },
451
+ messages: Array.from(this.messages.values())
452
+ };
453
+ // Store using artifact storage (MessagePack + gzip)
454
+ await this.storage.store(storeId, store);
455
+ }
456
+ /**
457
+ * Load message store from artifact storage
458
+ */ async loadMessageStore() {
459
+ const storeId = 'message-store';
460
+ try {
461
+ if (this.storage.has(storeId)) {
462
+ const store = await this.storage.retrieve(storeId);
463
+ // Validate schema version
464
+ if (store.version !== 1) {
465
+ console.warn(`[MessagePersistence] Unsupported schema version ${store.version}, starting fresh`);
466
+ return;
467
+ }
468
+ // Rebuild in-memory structures
469
+ this.messages.clear();
470
+ this.topicIndex.clear();
471
+ this.expirationQueue = [];
472
+ const now = Date.now();
473
+ for (const msg of store.messages){
474
+ // Skip expired messages
475
+ if (msg.expiresAt <= now) {
476
+ continue;
477
+ }
478
+ this.messages.set(msg.id, msg);
479
+ this.indexMessageByTopic(msg.id, msg.topic);
480
+ this.expirationQueue.push({
481
+ messageId: msg.id,
482
+ expiresAt: msg.expiresAt
483
+ });
484
+ }
485
+ // Sort expiration queue
486
+ this.expirationQueue.sort((a, b)=>a.expiresAt - b.expiresAt);
487
+ // Update metrics
488
+ this.metrics.currentCount = this.messages.size;
489
+ }
490
+ } catch (error) {
491
+ console.warn('[MessagePersistence] Failed to load message store, starting fresh:', error);
492
+ }
493
+ }
494
+ /**
495
+ * Deserialize message from storage format
496
+ */ deserializeMessage(serialized) {
497
+ return {
498
+ id: serialized.id,
499
+ topic: serialized.topic,
500
+ payload: serialized.payload,
501
+ priority: serialized.priority,
502
+ timestamp: serialized.timestamp,
503
+ replyTo: serialized.replyTo,
504
+ correlationId: serialized.correlationId,
505
+ senderId: serialized.senderId,
506
+ recipientId: serialized.recipientId,
507
+ metadata: serialized.metadata
508
+ };
509
+ }
510
+ /**
511
+ * Get oldest message timestamp
512
+ */ getOldestTimestamp() {
513
+ let oldest = Infinity;
514
+ for (const msg of Array.from(this.messages.values())){
515
+ if (msg.timestamp < oldest) {
516
+ oldest = msg.timestamp;
517
+ }
518
+ }
519
+ return oldest === Infinity ? Date.now() : oldest;
520
+ }
521
+ /**
522
+ * Get newest message timestamp
523
+ */ getNewestTimestamp() {
524
+ let newest = 0;
525
+ for (const msg of Array.from(this.messages.values())){
526
+ if (msg.timestamp > newest) {
527
+ newest = msg.timestamp;
528
+ }
529
+ }
530
+ return newest === 0 ? Date.now() : newest;
531
+ }
532
+ // ===========================
533
+ // Metrics Tracking
534
+ // ===========================
535
+ /**
536
+ * Initialize metrics structure
537
+ */ initializeMetrics() {
538
+ return {
539
+ totalStored: 0,
540
+ totalRetrieved: 0,
541
+ totalExpired: 0,
542
+ currentCount: 0,
543
+ averageStoreLatencyMs: 0,
544
+ p95StoreLatencyMs: 0,
545
+ averageRetrieveLatencyMs: 0,
546
+ p95RetrieveLatencyMs: 0,
547
+ totalStorageMb: 0,
548
+ averageCompressionRatio: 0
549
+ };
550
+ }
551
+ /**
552
+ * Update store operation metrics
553
+ */ updateStoreMetrics(latency) {
554
+ this.metrics.totalStored++;
555
+ this.metrics.averageStoreLatencyMs = this.updateAverage(this.metrics.averageStoreLatencyMs, latency, this.metrics.totalStored);
556
+ this.latencyBuffer.push(latency);
557
+ if (this.latencyBuffer.length > 1000) {
558
+ this.latencyBuffer = this.latencyBuffer.slice(-1000);
559
+ }
560
+ this.metrics.p95StoreLatencyMs = this.calculateP95(this.latencyBuffer);
561
+ }
562
+ /**
563
+ * Update retrieve operation metrics
564
+ */ updateRetrieveMetrics(latency) {
565
+ this.metrics.averageRetrieveLatencyMs = this.updateAverage(this.metrics.averageRetrieveLatencyMs, latency, this.metrics.totalRetrieved || 1);
566
+ this.latencyBuffer.push(latency);
567
+ if (this.latencyBuffer.length > 1000) {
568
+ this.latencyBuffer = this.latencyBuffer.slice(-1000);
569
+ }
570
+ this.metrics.p95RetrieveLatencyMs = this.calculateP95(this.latencyBuffer);
571
+ }
572
+ /**
573
+ * Calculate rolling average
574
+ */ updateAverage(current, newValue, count) {
575
+ return (current * (count - 1) + newValue) / count;
576
+ }
577
+ /**
578
+ * Calculate 95th percentile latency
579
+ */ calculateP95(latencies) {
580
+ if (latencies.length === 0) return 0;
581
+ const sorted = [
582
+ ...latencies
583
+ ].sort((a, b)=>a - b);
584
+ const index = Math.floor(sorted.length * 0.95);
585
+ return sorted[index] || 0;
586
+ }
587
+ }
588
+
589
+ //# sourceMappingURL=message-persistence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../src/coordination/archives/v2-sdk-typescript/v2/messaging/message-persistence.ts"],"names":["DependencyArtifactStorage","gzip","gunzip","promisify","gzipAsync","gunzipAsync","MessagePersistence","storage","config","messages","topicIndex","expirationQueue","metrics","latencyBuffer","cleanupTimer","ready","storagePath","maxMessages","defaultTtlMs","cacheSize","autoCleanup","cleanupIntervalMs","Map","initializeMetrics","initialize","loadMessageStore","startCleanupTimer","close","clearInterval","undefined","persistMessageStore","isReady","storeMessage","message","ttlMs","ensureReady","startTime","Date","now","effectiveTtl","expiresAt","timestamp","serialized","id","topic","payload","priority","replyTo","correlationId","senderId","recipientId","metadata","size","evictOldestMessage","set","indexMessageByTopic","push","messageId","sort","a","b","latency","updateStoreMetrics","console","warn","error","Error","String","retrieveMessage","get","removeMessage","deserializeMessage","updateRetrieveMetrics","replayMessages","options","candidates","messageIds","getMessageIdsByTopic","Array","from","map","filter","msg","values","filtered","endTime","minPriority","limited","limit","slice","totalRetrieved","length","delete","removeFromTopicIndex","e","clear","cleanupExpiredMessages","expiredCount","removed","shift","totalExpired","lastCleanupAt","getMetrics","currentCount","setInterval","oldestId","oldestTimestamp","Infinity","entries","has","Set","add","topicPattern","result","matchesTopic","pattern","includes","regexPattern","replace","regex","RegExp","test","storeId","store","version","createdAt","updatedAt","messageCount","getOldestTimestamp","newestTimestamp","getNewestTimestamp","retrieve","oldest","newest","totalStored","averageStoreLatencyMs","p95StoreLatencyMs","averageRetrieveLatencyMs","p95RetrieveLatencyMs","totalStorageMb","averageCompressionRatio","updateAverage","calculateP95","current","newValue","count","latencies","sorted","index","Math","floor"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;CAqBC,GAGD,SAASA,yBAAyB,QAAQ,oCAAoC;AAE9E,SAASC,IAAI,EAAEC,MAAM,QAAQ,OAAO;AACpC,SAASC,SAAS,QAAQ,OAAO;AAGjC,MAAMC,YAAYD,UAAUF;AAC5B,MAAMI,cAAcF,UAAUD;AAuJ9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BC,GACD,OAAO,MAAMI;IACHC,QAAmC;IACnCC,OAA2C;IAC3CC,SAAyC;IACz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