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,560 @@
1
+ /**
2
+ * Agent Coordination V2 - Artifact Storage Implementation
3
+ *
4
+ * Binary-optimized storage with compression for agent-generated artifacts.
5
+ * Target performance: <12ms for binary operations (3.7x faster than JSON).
6
+ *
7
+ * @module coordination/v2/sdk/artifact-storage
8
+ */ import { promises as fs } from 'fs';
9
+ import { createReadStream } from 'fs';
10
+ import { join, basename } from 'path';
11
+ import { gzip, gunzip } from 'zlib';
12
+ import { promisify } from 'util';
13
+ import { createHash } from 'crypto';
14
+ import { pipeline } from 'stream';
15
+ const gzipAsync = promisify(gzip);
16
+ const gunzipAsync = promisify(gunzip);
17
+ const pipelineAsync = promisify(pipeline);
18
+ /**
19
+ * FilesystemArtifactStorage - High-performance binary artifact storage
20
+ *
21
+ * Features:
22
+ * - Binary format with gzip compression (3.7x faster than JSON)
23
+ * - SHA-256 integrity verification
24
+ * - Versioning support
25
+ * - Streaming for large files
26
+ * - Auto-cleanup based on retention policy
27
+ * - Metadata indexing for fast queries
28
+ */ export class FilesystemArtifactStorage {
29
+ config;
30
+ index = new Map();
31
+ metrics;
32
+ ready = false;
33
+ startTime;
34
+ constructor(config = {}){
35
+ this.config = {
36
+ backend: 'filesystem',
37
+ path: '.claude-flow/artifacts',
38
+ enableCompression: true,
39
+ compressionThreshold: 1024,
40
+ compressionAlgorithm: 'gzip',
41
+ enableVersioning: true,
42
+ maxVersions: 5,
43
+ cleanupIntervalHours: 24,
44
+ retentionHours: 168,
45
+ maxArtifactSizeBytes: 10 * 1024 * 1024,
46
+ ...config
47
+ };
48
+ this.startTime = Date.now();
49
+ this.metrics = this.initializeMetrics();
50
+ }
51
+ // ===========================
52
+ // Lifecycle
53
+ // ===========================
54
+ async initialize() {
55
+ if (this.ready) return;
56
+ // Create storage directories
57
+ await fs.mkdir(this.config.path, {
58
+ recursive: true
59
+ });
60
+ await fs.mkdir(join(this.config.path, 'metadata'), {
61
+ recursive: true
62
+ });
63
+ await fs.mkdir(join(this.config.path, 'content'), {
64
+ recursive: true
65
+ });
66
+ // Load existing metadata index
67
+ await this.loadIndex();
68
+ this.ready = true;
69
+ }
70
+ async close() {
71
+ // Persist index before closing
72
+ await this.persistIndex();
73
+ this.ready = false;
74
+ }
75
+ isReady() {
76
+ return this.ready;
77
+ }
78
+ // ===========================
79
+ // Upload Operations
80
+ // ===========================
81
+ async uploadArtifact(agentId, sessionId, content, options) {
82
+ this.ensureReady();
83
+ // Validate size
84
+ if (content.length > this.config.maxArtifactSizeBytes) {
85
+ throw new Error(`Artifact exceeds max size: ${content.length} > ${this.config.maxArtifactSizeBytes}`);
86
+ }
87
+ const startTime = Date.now();
88
+ // Generate artifact ID
89
+ const artifactId = this.generateArtifactId(agentId, sessionId, options);
90
+ // Determine compression
91
+ const shouldCompress = !options.disableCompression && (options.forceCompression || this.config.enableCompression && content.length >= this.config.compressionThreshold);
92
+ // Compress if needed
93
+ let finalContent = content;
94
+ let compressed = false;
95
+ if (shouldCompress) {
96
+ finalContent = await gzipAsync(content);
97
+ compressed = true;
98
+ }
99
+ // Calculate checksum
100
+ const checksum = this.calculateChecksum(content);
101
+ // Create metadata
102
+ const version = await this.getNextVersion(artifactId);
103
+ const metadata = {
104
+ artifactId,
105
+ createdBy: agentId,
106
+ sessionId,
107
+ type: options.type,
108
+ mimeType: options.mimeType || this.detectMimeType(options.filename || ''),
109
+ filename: options.filename || `artifact-${Date.now()}`,
110
+ sizeBytes: content.length,
111
+ createdAt: new Date(),
112
+ modifiedAt: new Date(),
113
+ version,
114
+ tags: options.tags || [],
115
+ metadata: options.metadata || {},
116
+ checksum,
117
+ compressed,
118
+ compressionAlgorithm: compressed ? this.config.compressionAlgorithm : undefined
119
+ };
120
+ // Write content to disk
121
+ const contentPath = this.getContentPath(artifactId, version);
122
+ await fs.writeFile(contentPath, finalContent);
123
+ // Update index
124
+ this.updateIndex(metadata, contentPath);
125
+ // Update metrics
126
+ const latency = Date.now() - startTime;
127
+ this.updateUploadMetrics(content.length, finalContent.length, latency);
128
+ return metadata;
129
+ }
130
+ async uploadArtifactFromFile(agentId, sessionId, filePath, options) {
131
+ const content = await fs.readFile(filePath);
132
+ const filename = options.filename || basename(filePath);
133
+ return this.uploadArtifact(agentId, sessionId, content, {
134
+ ...options,
135
+ filename
136
+ });
137
+ }
138
+ async uploadArtifactStream(agentId, sessionId, stream, options) {
139
+ // Read stream into buffer
140
+ const chunks = [];
141
+ for await (const chunk of stream){
142
+ chunks.push(Buffer.from(chunk));
143
+ }
144
+ const content = Buffer.concat(chunks);
145
+ return this.uploadArtifact(agentId, sessionId, content, options);
146
+ }
147
+ // ===========================
148
+ // Download Operations
149
+ // ===========================
150
+ async downloadArtifact(artifactId, version) {
151
+ this.ensureReady();
152
+ const startTime = Date.now();
153
+ const metadata = await this.getArtifactMetadata(artifactId, version);
154
+ if (!metadata) {
155
+ throw new Error(`Artifact not found: ${artifactId}`);
156
+ }
157
+ const entry = this.index.get(artifactId);
158
+ const contentPath = entry.versions.get(metadata.version);
159
+ // Read content
160
+ let content = await fs.readFile(contentPath);
161
+ // Decompress if needed
162
+ if (metadata.compressed) {
163
+ content = await gunzipAsync(content);
164
+ }
165
+ // Verify integrity
166
+ const checksum = this.calculateChecksum(content);
167
+ if (checksum !== metadata.checksum) {
168
+ throw new Error(`Artifact integrity check failed: ${artifactId}`);
169
+ }
170
+ const latency = Date.now() - startTime;
171
+ this.updateDownloadMetrics(latency);
172
+ return {
173
+ metadata,
174
+ content,
175
+ latencyMs: latency
176
+ };
177
+ }
178
+ async downloadArtifactToFile(artifactId, destinationPath, version) {
179
+ const result = await this.downloadArtifact(artifactId, version);
180
+ await fs.writeFile(destinationPath, result.content);
181
+ return result.metadata;
182
+ }
183
+ async downloadArtifactStream(artifactId, version) {
184
+ const metadata = await this.getArtifactMetadata(artifactId, version);
185
+ if (!metadata) {
186
+ throw new Error(`Artifact not found: ${artifactId}`);
187
+ }
188
+ const entry = this.index.get(artifactId);
189
+ const contentPath = entry.versions.get(metadata.version);
190
+ const stream = createReadStream(contentPath);
191
+ // Add decompression if needed
192
+ if (metadata.compressed) {
193
+ const gunzipStream = (await import('zlib')).createGunzip();
194
+ return stream.pipe(gunzipStream);
195
+ }
196
+ return stream;
197
+ }
198
+ // ===========================
199
+ // Metadata Operations
200
+ // ===========================
201
+ async getArtifactMetadata(artifactId, version) {
202
+ const entry = this.index.get(artifactId);
203
+ if (!entry) return null;
204
+ // If specific version requested, return metadata for that version
205
+ // The current metadata always reflects the latest version
206
+ if (version !== undefined && version !== entry.metadata.version) {
207
+ // Check if version exists
208
+ if (!entry.versions.has(version)) return null;
209
+ // Create metadata for historical version
210
+ return {
211
+ ...entry.metadata,
212
+ version,
213
+ modifiedAt: entry.metadata.createdAt // Historical versions use creation date
214
+ };
215
+ }
216
+ return entry.metadata;
217
+ }
218
+ async updateArtifactMetadata(artifactId, updates) {
219
+ const entry = this.index.get(artifactId);
220
+ if (!entry) {
221
+ throw new Error(`Artifact not found: ${artifactId}`);
222
+ }
223
+ // Update metadata
224
+ if (updates.tags) entry.metadata.tags = updates.tags;
225
+ if (updates.metadata) entry.metadata.metadata = {
226
+ ...entry.metadata.metadata,
227
+ ...updates.metadata
228
+ };
229
+ if (updates.filename) entry.metadata.filename = updates.filename;
230
+ entry.metadata.modifiedAt = new Date();
231
+ // Persist changes
232
+ await this.persistIndex();
233
+ }
234
+ async listArtifactVersions(artifactId) {
235
+ const entry = this.index.get(artifactId);
236
+ if (!entry) return [];
237
+ return Array.from(entry.versions.keys()).sort((a, b)=>b - a);
238
+ }
239
+ // ===========================
240
+ // Query Operations
241
+ // ===========================
242
+ async queryArtifacts(filter) {
243
+ let results = Array.from(this.index.values()).map((e)=>e.metadata);
244
+ // Apply filters
245
+ if (filter.artifactId) {
246
+ results = results.filter((m)=>m.artifactId === filter.artifactId);
247
+ }
248
+ if (filter.createdBy) {
249
+ results = results.filter((m)=>m.createdBy === filter.createdBy);
250
+ }
251
+ if (filter.sessionId) {
252
+ results = results.filter((m)=>m.sessionId === filter.sessionId);
253
+ }
254
+ if (filter.type) {
255
+ results = results.filter((m)=>filter.type.includes(m.type));
256
+ }
257
+ if (filter.mimeType) {
258
+ results = results.filter((m)=>filter.mimeType.includes(m.mimeType));
259
+ }
260
+ if (filter.tags && filter.tags.length > 0) {
261
+ results = results.filter((m)=>filter.tags.every((tag)=>m.tags.includes(tag)));
262
+ }
263
+ if (filter.createdAfter) {
264
+ results = results.filter((m)=>m.createdAt >= filter.createdAfter);
265
+ }
266
+ if (filter.createdBefore) {
267
+ results = results.filter((m)=>m.createdAt <= filter.createdBefore);
268
+ }
269
+ if (filter.sizeMin !== undefined) {
270
+ results = results.filter((m)=>m.sizeBytes >= filter.sizeMin);
271
+ }
272
+ if (filter.sizeMax !== undefined) {
273
+ results = results.filter((m)=>m.sizeBytes <= filter.sizeMax);
274
+ }
275
+ // Sort
276
+ if (filter.sortBy) {
277
+ results.sort((a, b)=>{
278
+ const aVal = a[filter.sortBy];
279
+ const bVal = b[filter.sortBy];
280
+ const order = filter.sortOrder === 'desc' ? -1 : 1;
281
+ return aVal < bVal ? -order : aVal > bVal ? order : 0;
282
+ });
283
+ }
284
+ // Pagination
285
+ const offset = filter.offset || 0;
286
+ const limit = filter.limit || results.length;
287
+ return results.slice(offset, offset + limit);
288
+ }
289
+ async listArtifactsByAgent(agentId, limit) {
290
+ return this.queryArtifacts({
291
+ createdBy: agentId,
292
+ limit,
293
+ sortBy: 'createdAt',
294
+ sortOrder: 'desc'
295
+ });
296
+ }
297
+ async listArtifactsBySession(sessionId, limit) {
298
+ return this.queryArtifacts({
299
+ sessionId,
300
+ limit,
301
+ sortBy: 'createdAt',
302
+ sortOrder: 'desc'
303
+ });
304
+ }
305
+ async searchArtifactsByTags(tags, limit) {
306
+ return this.queryArtifacts({
307
+ tags,
308
+ limit,
309
+ sortBy: 'createdAt',
310
+ sortOrder: 'desc'
311
+ });
312
+ }
313
+ // ===========================
314
+ // Deletion Operations
315
+ // ===========================
316
+ async deleteArtifact(artifactId, version) {
317
+ const entry = this.index.get(artifactId);
318
+ if (!entry) return;
319
+ if (version !== undefined) {
320
+ // Delete specific version
321
+ const contentPath = entry.versions.get(version);
322
+ if (contentPath) {
323
+ await fs.unlink(contentPath).catch(()=>{});
324
+ entry.versions.delete(version);
325
+ }
326
+ // If no versions left, delete entire entry
327
+ if (entry.versions.size === 0) {
328
+ this.index.delete(artifactId);
329
+ }
330
+ } else {
331
+ // Delete all versions
332
+ for (const contentPath of entry.versions.values()){
333
+ await fs.unlink(contentPath).catch(()=>{});
334
+ }
335
+ this.index.delete(artifactId);
336
+ }
337
+ this.metrics.totalDeletions++;
338
+ await this.persistIndex();
339
+ }
340
+ async deleteArtifactsByAgent(agentId) {
341
+ const artifacts = await this.listArtifactsByAgent(agentId);
342
+ await Promise.all(artifacts.map((a)=>this.deleteArtifact(a.artifactId)));
343
+ return artifacts.length;
344
+ }
345
+ async deleteArtifactsBySession(sessionId) {
346
+ const artifacts = await this.listArtifactsBySession(sessionId);
347
+ await Promise.all(artifacts.map((a)=>this.deleteArtifact(a.artifactId)));
348
+ return artifacts.length;
349
+ }
350
+ // ===========================
351
+ // Maintenance & Cleanup
352
+ // ===========================
353
+ async cleanup(retentionHours) {
354
+ const retention = retentionHours || this.config.retentionHours;
355
+ const cutoffDate = new Date(Date.now() - retention * 60 * 60 * 1000);
356
+ const artifacts = await this.queryArtifacts({
357
+ createdBefore: cutoffDate
358
+ });
359
+ await Promise.all(artifacts.map((a)=>this.deleteArtifact(a.artifactId)));
360
+ return artifacts.length;
361
+ }
362
+ async verifyArtifactIntegrity(artifactId, version) {
363
+ try {
364
+ const result = await this.downloadArtifact(artifactId, version);
365
+ return true; // If download succeeds, integrity is valid
366
+ } catch {
367
+ return false;
368
+ }
369
+ }
370
+ async optimize() {
371
+ // Recompress artifacts that could benefit
372
+ const artifacts = await this.queryArtifacts({});
373
+ for (const metadata of artifacts){
374
+ if (!metadata.compressed && metadata.sizeBytes >= this.config.compressionThreshold) {
375
+ const result = await this.downloadArtifact(metadata.artifactId);
376
+ await this.uploadArtifact(metadata.createdBy, metadata.sessionId, result.content, {
377
+ type: metadata.type,
378
+ filename: metadata.filename,
379
+ tags: metadata.tags,
380
+ metadata: metadata.metadata,
381
+ forceCompression: true,
382
+ overwrite: true
383
+ });
384
+ }
385
+ }
386
+ // Enforce version limits
387
+ for (const [artifactId, entry] of this.index.entries()){
388
+ const versions = await this.listArtifactVersions(artifactId);
389
+ if (versions.length > this.config.maxVersions) {
390
+ const toDelete = versions.slice(this.config.maxVersions);
391
+ await Promise.all(toDelete.map((v)=>this.deleteArtifact(artifactId, v)));
392
+ }
393
+ }
394
+ await this.persistIndex();
395
+ }
396
+ // ===========================
397
+ // Metrics & Monitoring
398
+ // ===========================
399
+ getMetrics() {
400
+ return {
401
+ ...this.metrics,
402
+ uptimeMs: Date.now() - this.startTime
403
+ };
404
+ }
405
+ async healthCheck() {
406
+ const startTime = Date.now();
407
+ const errors = [];
408
+ try {
409
+ // Test write
410
+ const testContent = Buffer.from('health-check');
411
+ const metadata = await this.uploadArtifact('health-check', 'health-check', testContent, {
412
+ type: 'test'
413
+ });
414
+ // Test read
415
+ await this.downloadArtifact(metadata.artifactId);
416
+ // Cleanup
417
+ await this.deleteArtifact(metadata.artifactId);
418
+ return {
419
+ healthy: true,
420
+ latencyMs: Date.now() - startTime
421
+ };
422
+ } catch (error) {
423
+ errors.push(error instanceof Error ? error.message : String(error));
424
+ return {
425
+ healthy: false,
426
+ latencyMs: Date.now() - startTime,
427
+ errors
428
+ };
429
+ }
430
+ }
431
+ // ===========================
432
+ // Private Helpers
433
+ // ===========================
434
+ ensureReady() {
435
+ if (!this.ready) {
436
+ throw new Error('ArtifactStorage not initialized. Call initialize() first.');
437
+ }
438
+ }
439
+ generateArtifactId(agentId, sessionId, options) {
440
+ // Use stable ID based on agent, session, type, and filename for versioning
441
+ if (options.filename && this.config.enableVersioning) {
442
+ const baseId = `${agentId}-${sessionId}-${options.type}-${options.filename}`;
443
+ return baseId.replace(/[^a-zA-Z0-9-_]/g, '_');
444
+ }
445
+ // Otherwise create unique ID
446
+ const timestamp = Date.now();
447
+ const random = Math.random().toString(36).substring(2, 8);
448
+ return `${agentId}-${sessionId}-${options.type}-${timestamp}-${random}`;
449
+ }
450
+ calculateChecksum(content) {
451
+ return createHash('sha256').update(content).digest('hex');
452
+ }
453
+ detectMimeType(filename) {
454
+ const ext = filename.split('.').pop()?.toLowerCase();
455
+ const mimeTypes = {
456
+ js: 'application/javascript',
457
+ ts: 'application/typescript',
458
+ json: 'application/json',
459
+ txt: 'text/plain',
460
+ html: 'text/html',
461
+ css: 'text/css',
462
+ png: 'image/png',
463
+ jpg: 'image/jpeg',
464
+ jpeg: 'image/jpeg',
465
+ gif: 'image/gif',
466
+ pdf: 'application/pdf',
467
+ zip: 'application/zip'
468
+ };
469
+ return mimeTypes[ext || ''] || 'application/octet-stream';
470
+ }
471
+ async getNextVersion(artifactId) {
472
+ const entry = this.index.get(artifactId);
473
+ if (!entry) return 1;
474
+ if (!this.config.enableVersioning) {
475
+ return entry.metadata.version;
476
+ }
477
+ const versions = await this.listArtifactVersions(artifactId);
478
+ return Math.max(...versions, 0) + 1;
479
+ }
480
+ getContentPath(artifactId, version) {
481
+ return join(this.config.path, 'content', `${artifactId}-v${version}.bin`);
482
+ }
483
+ updateIndex(metadata, contentPath) {
484
+ let entry = this.index.get(metadata.artifactId);
485
+ if (!entry) {
486
+ entry = {
487
+ metadata,
488
+ versions: new Map()
489
+ };
490
+ this.index.set(metadata.artifactId, entry);
491
+ }
492
+ entry.metadata = metadata;
493
+ entry.versions.set(metadata.version, contentPath);
494
+ }
495
+ async loadIndex() {
496
+ const indexPath = join(this.config.path, 'metadata', 'index.json');
497
+ try {
498
+ const data = await fs.readFile(indexPath, 'utf-8');
499
+ const parsed = JSON.parse(data);
500
+ for (const [id, entry] of Object.entries(parsed)){
501
+ const typedEntry = entry;
502
+ this.index.set(id, {
503
+ metadata: {
504
+ ...typedEntry.metadata,
505
+ createdAt: new Date(typedEntry.metadata.createdAt),
506
+ modifiedAt: new Date(typedEntry.metadata.modifiedAt)
507
+ },
508
+ versions: new Map(typedEntry.versions)
509
+ });
510
+ }
511
+ } catch {
512
+ // Index doesn't exist yet
513
+ }
514
+ }
515
+ async persistIndex() {
516
+ const indexPath = join(this.config.path, 'metadata', 'index.json');
517
+ const serializable = Object.fromEntries(Array.from(this.index.entries()).map(([id, entry])=>[
518
+ id,
519
+ {
520
+ metadata: entry.metadata,
521
+ versions: Array.from(entry.versions.entries())
522
+ }
523
+ ]));
524
+ await fs.writeFile(indexPath, JSON.stringify(serializable, null, 2));
525
+ }
526
+ initializeMetrics() {
527
+ return {
528
+ totalArtifacts: 0,
529
+ totalStorageMb: 0,
530
+ compressedStorageMb: 0,
531
+ averageCompressionRatio: 0,
532
+ totalUploads: 0,
533
+ totalDownloads: 0,
534
+ totalDeletions: 0,
535
+ averageUploadLatencyMs: 0,
536
+ averageDownloadLatencyMs: 0,
537
+ uptimeMs: 0
538
+ };
539
+ }
540
+ updateUploadMetrics(originalSize, compressedSize, latency) {
541
+ this.metrics.totalUploads++;
542
+ this.metrics.totalArtifacts = this.index.size;
543
+ this.metrics.totalStorageMb += originalSize / (1024 * 1024);
544
+ this.metrics.compressedStorageMb += compressedSize / (1024 * 1024);
545
+ // Update average upload latency
546
+ const totalLatency = this.metrics.averageUploadLatencyMs * (this.metrics.totalUploads - 1) + latency;
547
+ this.metrics.averageUploadLatencyMs = totalLatency / this.metrics.totalUploads;
548
+ // Update compression ratio
549
+ if (this.metrics.totalStorageMb > 0) {
550
+ this.metrics.averageCompressionRatio = 1 - this.metrics.compressedStorageMb / this.metrics.totalStorageMb;
551
+ }
552
+ }
553
+ updateDownloadMetrics(latency) {
554
+ this.metrics.totalDownloads++;
555
+ const totalLatency = this.metrics.averageDownloadLatencyMs * (this.metrics.totalDownloads - 1) + latency;
556
+ this.metrics.averageDownloadLatencyMs = totalLatency / this.metrics.totalDownloads;
557
+ }
558
+ }
559
+
560
+ //# sourceMappingURL=artifact-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../src/coordination/archives/v2-sdk-typescript/v2/sdk/artifact-storage.ts"],"names":["promises","fs","createReadStream","join","basename","gzip","gunzip","promisify","createHash","pipeline","gzipAsync","gunzipAsync","pipelineAsync","FilesystemArtifactStorage","config","index","Map","metrics","ready","startTime","backend","path","enableCompression","compressionThreshold","compressionAlgorithm","enableVersioning","maxVersions","cleanupIntervalHours","retentionHours","maxArtifactSizeBytes","Date","now","initializeMetrics","initialize","mkdir","recursive","loadIndex","close","persistIndex","isReady","uploadArtifact","agentId","sessionId","content","options","ensureReady","length","Error","artifactId","generateArtifactId","shouldCompress","disableCompression","forceCompression","finalContent","compressed","checksum","calculateChecksum","version","getNextVersion","metadata","createdBy","type","mimeType","detectMimeType","filename","sizeBytes","createdAt","modifiedAt","tags","undefined","contentPath","getContentPath","writeFile","updateIndex","latency","updateUploadMetrics","uploadArtifactFromFile","filePath","readFile","uploadArtifactStream","stream","chunks","chunk","push","Buffer","from","concat","downloadArtifact","getArtifactMetadata","entry","get","versions","updateDownloadMetrics","latencyMs","downloadArtifactToFile","destinationPath","result","downloadArtifactStream","gunzipStream","createGunzip","pipe","has","updateArtifactMetadata","updates","listArtifactVersions","Array","keys","sort","a","b","queryArtifacts","filter","results","values","map","e","m","includes","every","tag","createdAfter","createdBefore","sizeMin","sizeMax","sortBy","aVal","bVal","order","sortOrder","offset","limit","slice","listArtifactsByAgent","listArtifactsBySession","searchArtifactsByTags","deleteArtifact","unlink","catch","delete","size","totalDeletions","deleteArtifactsByAgent","artifacts","Promise","all","deleteArtifactsBySession","cleanup","retention","cutoffDate","verifyArtifactIntegrity","optimize","overwrite","entries","toDelete","v","getMetrics","uptimeMs","healthCheck","errors","testContent","healthy","error","message","String","baseId","replace","timestamp","random","Math","toString","substring","update","digest","ext","split","pop","toLowerCase","mimeTypes","js","ts","json","txt","html","css","png","jpg","jpeg","gif","pdf","zip","max","set","indexPath","data","parsed","JSON","parse","id","Object","typedEntry","serializable","fromEntries","stringify","totalArtifacts","totalStorageMb","compressedStorageMb","averageCompressionRatio","totalUploads","totalDownloads","averageUploadLatencyM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