claude-flow-novice 1.6.4 → 1.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/.claude/commands/parse-epic.js +180 -0
  2. package/.claude/settings.local.json +2 -1
  3. package/.claude-flow-novice/dist/mcp/mcp-server-novice.js +37 -2
  4. package/.claude-flow-novice/dist/mcp/transports/base.js +5 -0
  5. package/.claude-flow-novice/dist/mcp/transports/base.js.map +1 -0
  6. package/.claude-flow-novice/dist/mcp/transports/http.js +414 -0
  7. package/.claude-flow-novice/dist/mcp/transports/http.js.map +1 -0
  8. package/.claude-flow-novice/dist/mcp/transports/stdio.js +217 -0
  9. package/.claude-flow-novice/dist/mcp/transports/stdio.js.map +1 -0
  10. package/.claude-flow-novice/dist/src/cli/commands/parse-epic.js +129 -0
  11. package/.claude-flow-novice/dist/src/cli/commands/parse-epic.js.map +1 -0
  12. package/.claude-flow-novice/dist/src/cli/index.js +3 -0
  13. package/.claude-flow-novice/dist/src/cli/index.js.map +1 -1
  14. package/.claude-flow-novice/dist/src/cli/utils/epic-parser.js +266 -0
  15. package/.claude-flow-novice/dist/src/cli/utils/epic-parser.js.map +1 -0
  16. package/.claude-flow-novice/dist/src/communication/message-bus.js +105 -2
  17. package/.claude-flow-novice/dist/src/communication/message-bus.js.map +1 -1
  18. package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js +1 -1
  19. package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js.map +1 -1
  20. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/artifact-cache-optimizer.js +632 -0
  21. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/artifact-cache-optimizer.js.map +1 -0
  22. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/index.js +11 -0
  23. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/index.js.map +1 -0
  24. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/checkpoints/checkpoint-compressor.js +318 -0
  25. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/checkpoints/checkpoint-compressor.js.map +1 -0
  26. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/completion-detector.js +234 -0
  27. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/completion-detector.js.map +1 -0
  28. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/hierarchical-detector.js +347 -0
  29. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/hierarchical-detector.js.map +1 -0
  30. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/index.js +13 -0
  31. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/index.js.map +1 -0
  32. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/lamport-clock.js +173 -0
  33. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/lamport-clock.js.map +1 -0
  34. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/mesh-detector.js +526 -0
  35. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/mesh-detector.js.map +1 -0
  36. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/sdk-completion-detector.js +443 -0
  37. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/sdk-completion-detector.js.map +1 -0
  38. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/swarm-shutdown.js +366 -0
  39. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/swarm-shutdown.js.map +1 -0
  40. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinator-factory.js +287 -0
  41. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinator-factory.js.map +1 -0
  42. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.example.js +364 -0
  43. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.example.js.map +1 -0
  44. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.js +492 -0
  45. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.js.map +1 -0
  46. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/hierarchical-coordinator.js +786 -0
  47. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/hierarchical-coordinator.js.map +1 -0
  48. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/index.js +16 -0
  49. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/index.js.map +1 -0
  50. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/parent-child-manager.js +342 -0
  51. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/parent-child-manager.js.map +1 -0
  52. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/swarm-coordinator-v2.js +601 -0
  53. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/swarm-coordinator-v2.js.map +1 -0
  54. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/agent-state.js +9 -0
  55. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/agent-state.js.map +1 -0
  56. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dead-letter-queue.js +413 -0
  57. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dead-letter-queue.js.map +1 -0
  58. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-graph.js +471 -0
  59. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-graph.js.map +1 -0
  60. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-node.js +379 -0
  61. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-node.js.map +1 -0
  62. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-resolver.js +335 -0
  63. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-resolver.js.map +1 -0
  64. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/help-request-metrics.js +211 -0
  65. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/help-request-metrics.js.map +1 -0
  66. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/index.js +33 -0
  67. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/index.js.map +1 -0
  68. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-broker.js +920 -0
  69. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-broker.js.map +1 -0
  70. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-router.js +385 -0
  71. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-router.js.map +1 -0
  72. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message.js +138 -0
  73. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message.js.map +1 -0
  74. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/resource-manager-safe.js +478 -0
  75. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/resource-manager-safe.js.map +1 -0
  76. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine-config.js +358 -0
  77. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine-config.js.map +1 -0
  78. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine.js +588 -0
  79. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine.js.map +1 -0
  80. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-transition.js +153 -0
  81. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-transition.js.map +1 -0
  82. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/task-scheduler.js +360 -0
  83. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/task-scheduler.js.map +1 -0
  84. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/topic-manager.js +337 -0
  85. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/topic-manager.js.map +1 -0
  86. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/deadlock-detector.js +424 -0
  87. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/deadlock-detector.js.map +1 -0
  88. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/index.js +9 -0
  89. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/index.js.map +1 -0
  90. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/resource-manager.js +669 -0
  91. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/resource-manager.js.map +1 -0
  92. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/artifact-storage.js +451 -0
  93. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/artifact-storage.js.map +1 -0
  94. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/cycle-detector.js +271 -0
  95. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/cycle-detector.js.map +1 -0
  96. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-graph.js +335 -0
  97. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-graph.js.map +1 -0
  98. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-manager.js +439 -0
  99. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-manager.js.map +1 -0
  100. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-request.js +92 -0
  101. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-request.js.map +1 -0
  102. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/index.js +21 -0
  103. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/index.js.map +1 -0
  104. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/topological-sort.js +223 -0
  105. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/topological-sort.js.map +1 -0
  106. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-coordinator.js +436 -0
  107. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-coordinator.js.map +1 -0
  108. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-matcher.js +278 -0
  109. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-matcher.js.map +1 -0
  110. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request-handler.js +317 -0
  111. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request-handler.js.map +1 -0
  112. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request.js +273 -0
  113. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request.js.map +1 -0
  114. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/index.js +15 -0
  115. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/index.js.map +1 -0
  116. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/waiting-agent-pool.js +512 -0
  117. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/waiting-agent-pool.js.map +1 -0
  118. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/index.js +67 -0
  119. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/index.js.map +1 -0
  120. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/help-deadlock-integration.js +557 -0
  121. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/help-deadlock-integration.js.map +1 -0
  122. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/index.js +14 -0
  123. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/index.js.map +1 -0
  124. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.example.js +212 -0
  125. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.example.js.map +1 -0
  126. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.js +552 -0
  127. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.js.map +1 -0
  128. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/state-machine-integration.js +635 -0
  129. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/state-machine-integration.js.map +1 -0
  130. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/IArtifactStorage.js +28 -0
  131. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/IArtifactStorage.js.map +1 -0
  132. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ICoordinator.js +9 -0
  133. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ICoordinator.js.map +1 -0
  134. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ISessionStore.js +25 -0
  135. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ISessionStore.js.map +1 -0
  136. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/index.js +14 -0
  137. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/index.js.map +1 -0
  138. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/artifact-adapter.js +308 -0
  139. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/artifact-adapter.js.map +1 -0
  140. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/completion-storage.js +439 -0
  141. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/completion-storage.js.map +1 -0
  142. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-graph-storage.js +540 -0
  143. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-graph-storage.js.map +1 -0
  144. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-storage.js +367 -0
  145. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-storage.js.map +1 -0
  146. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/index.js +14 -0
  147. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/index.js.map +1 -0
  148. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/message-storage.js +518 -0
  149. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/message-storage.js.map +1 -0
  150. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/state-storage.js +377 -0
  151. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/state-storage.js.map +1 -0
  152. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channel.js +371 -0
  153. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channel.js.map +1 -0
  154. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/dependency-channel.js +355 -0
  155. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/dependency-channel.js.map +1 -0
  156. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/help-channel.js +424 -0
  157. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/help-channel.js.map +1 -0
  158. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/index.js +16 -0
  159. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/index.js.map +1 -0
  160. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/state-channel.js +295 -0
  161. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/state-channel.js.map +1 -0
  162. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/task-channel.js +411 -0
  163. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/task-channel.js.map +1 -0
  164. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/index.js +14 -0
  165. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/index.js.map +1 -0
  166. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-bus.js +387 -0
  167. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-bus.js.map +1 -0
  168. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-persistence.js +589 -0
  169. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-persistence.js.map +1 -0
  170. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-router.js +444 -0
  171. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-router.js.map +1 -0
  172. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/artifact-storage.js +560 -0
  173. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/artifact-storage.js.map +1 -0
  174. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/background-orchestrator.js +335 -0
  175. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/background-orchestrator.js.map +1 -0
  176. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/bash-output-monitor.js +104 -0
  177. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/bash-output-monitor.js.map +1 -0
  178. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/checkpoint-manager.js +847 -0
  179. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/checkpoint-manager.js.map +1 -0
  180. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/help-coordinator.js +470 -0
  181. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/help-coordinator.js.map +1 -0
  182. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/hierarchical-background-integration.js +450 -0
  183. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/hierarchical-background-integration.js.map +1 -0
  184. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/index.js +13 -0
  185. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/index.js.map +1 -0
  186. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/message-bus-integration.js +625 -0
  187. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/message-bus-integration.js.map +1 -0
  188. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/multi-level-control.js +545 -0
  189. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/multi-level-control.js.map +1 -0
  190. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-controller.js +740 -0
  191. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-controller.js.map +1 -0
  192. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-message-integration.js +415 -0
  193. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-message-integration.js.map +1 -0
  194. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/session-pool-optimizer.js +615 -0
  195. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/session-pool-optimizer.js.map +1 -0
  196. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-machine-integration.js +547 -0
  197. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-machine-integration.js.map +1 -0
  198. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-sdk-integration.js +342 -0
  199. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-sdk-integration.js.map +1 -0
  200. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/security/payload-validator.js +259 -0
  201. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/security/payload-validator.js.map +1 -0
  202. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/framework-registry.js +273 -0
  203. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/framework-registry.js.map +1 -0
  204. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/index.js +8 -0
  205. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/index.js.map +1 -0
  206. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-config-manager.js +310 -0
  207. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-config-manager.js.map +1 -0
  208. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-validator.js +218 -0
  209. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-validator.js.map +1 -0
  210. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/types/sdk.js +9 -0
  211. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/types/sdk.js.map +1 -0
  212. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/index.js +6 -0
  213. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/index.js.map +1 -0
  214. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/priority-queue.js +145 -0
  215. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/priority-queue.js.map +1 -0
  216. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/sdk-helpers.js +122 -0
  217. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/sdk-helpers.js.map +1 -0
  218. package/.claude-flow-novice/dist/src/coordination/config-translator.js +17 -43
  219. package/.claude-flow-novice/dist/src/coordination/config-translator.js.map +1 -1
  220. package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js +34 -76
  221. package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js.map +1 -1
  222. package/.claude-flow-novice/dist/src/coordination/shared/core/agent-state.js +172 -0
  223. package/.claude-flow-novice/dist/src/coordination/shared/core/agent-state.js.map +1 -0
  224. package/.claude-flow-novice/dist/src/coordination/shared/core/index.js +7 -0
  225. package/.claude-flow-novice/dist/src/coordination/shared/core/index.js.map +1 -0
  226. package/.claude-flow-novice/dist/src/coordination/shared/index.js +19 -0
  227. package/.claude-flow-novice/dist/src/coordination/shared/index.js.map +1 -0
  228. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/ICoordinator.js +24 -0
  229. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/ICoordinator.js.map +1 -0
  230. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/index.js +7 -0
  231. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/index.js.map +1 -0
  232. package/.claude-flow-novice/dist/src/coordination/shared/message-broker.js +920 -0
  233. package/.claude-flow-novice/dist/src/coordination/shared/message-broker.js.map +1 -0
  234. package/.claude-flow-novice/dist/src/coordination/shared/message.js +138 -0
  235. package/.claude-flow-novice/dist/src/coordination/shared/message.js.map +1 -0
  236. package/.claude-flow-novice/dist/src/coordination/shared/security/payload-validator.js +259 -0
  237. package/.claude-flow-novice/dist/src/coordination/shared/security/payload-validator.js.map +1 -0
  238. package/.claude-flow-novice/dist/src/coordination/shared/transparency/index.js +17 -0
  239. package/.claude-flow-novice/dist/src/coordination/shared/transparency/index.js.map +1 -0
  240. package/.claude-flow-novice/dist/src/coordination/shared/transparency/interfaces/transparency-system.js +19 -0
  241. package/.claude-flow-novice/dist/src/coordination/shared/transparency/interfaces/transparency-system.js.map +1 -0
  242. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-integration.js +357 -0
  243. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-integration.js.map +1 -0
  244. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-system.js +679 -0
  245. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-system.js.map +1 -0
  246. package/.claude-flow-novice/dist/src/coordination/shared/types/index.js +7 -0
  247. package/.claude-flow-novice/dist/src/coordination/shared/types/index.js.map +1 -0
  248. package/.claude-flow-novice/dist/src/coordination/shared/types/sdk.js +10 -0
  249. package/.claude-flow-novice/dist/src/coordination/shared/types/sdk.js.map +1 -0
  250. package/.claude-flow-novice/dist/src/feature-flags/core/FeatureFlagManager.js +52 -2
  251. package/.claude-flow-novice/dist/src/feature-flags/core/FeatureFlagManager.js.map +1 -1
  252. package/.claude-flow-novice/dist/src/mcp/mcp-server-novice.js +37 -2
  253. package/.claude-flow-novice/dist/src/mcp/session-manager.js +3 -1
  254. package/.claude-flow-novice/dist/src/mcp/session-manager.js.map +1 -1
  255. package/.claude-flow-novice/dist/src/providers/provider-manager.js +36 -3
  256. package/.claude-flow-novice/dist/src/providers/provider-manager.js.map +1 -1
  257. package/.claude-flow-novice/dist/src/utils/markdown-sanitizer.js +65 -41
  258. package/.claude-flow-novice/dist/src/utils/markdown-sanitizer.js.map +1 -1
  259. package/.claude-flow-novice/dist/src/web/api/server.js +1 -1
  260. package/.claude-flow-novice/dist/src/web/api/server.js.map +1 -1
  261. package/.claude-flow-novice/dist/src/workflows/progressive-rollout-manager.js +30 -0
  262. package/.claude-flow-novice/dist/src/workflows/progressive-rollout-manager.js.map +1 -1
  263. package/.claude-flow-novice/metrics.db-shm +0 -0
  264. package/.claude-flow-novice/metrics.db-wal +0 -0
  265. package/package.json +2 -2
  266. package/scripts/monitoring/alert-monitor.sh +220 -0
  267. package/scripts/monitoring/view-alerts.sh +307 -0
  268. package/scripts/test-zai-api.cjs +2 -2
  269. package/src/slash-commands/parse-epic.js +1 -1
@@ -0,0 +1,180 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Parse Epic Slash Command
5
+ * Converts natural language epic markdown files to structured JSON
6
+ *
7
+ * Usage: /parse-epic <epic-directory> [--output <file>] [--validate]
8
+ *
9
+ * Fixed: Direct import from compiled dist to avoid CLI module resolution issues
10
+ */
11
+
12
+ import { promises as fs } from 'fs';
13
+ import * as path from 'path';
14
+ import { fileURLToPath } from 'url';
15
+ import chalk from 'chalk';
16
+
17
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
18
+ const projectRoot = path.resolve(__dirname, '../..');
19
+
20
+ const args = process.argv.slice(2);
21
+
22
+ if (args.length === 0 || args[0] === '--help' || args[0] === '-h') {
23
+ console.log(`
24
+ 📖 /parse-epic - Epic Document Parser
25
+
26
+ **Description**:
27
+ Parses natural language epic markdown documents (EPIC_OVERVIEW.md, phase-*.md)
28
+ into structured JSON configuration for project management and automation.
29
+
30
+ **Usage**:
31
+ /parse-epic <epic-directory> [options]
32
+
33
+ **Arguments**:
34
+ <epic-directory> Path to epic directory containing EPIC_OVERVIEW.md and phase files
35
+
36
+ **Options**:
37
+ --output, -o <file> Output JSON file path (default: epic-config.json in epic directory)
38
+ --validate, -v Validate epic config against schema
39
+ --overview <file> Custom overview file path (default: EPIC_OVERVIEW.md)
40
+
41
+ **Examples**:
42
+ /parse-epic planning/example-epic
43
+ /parse-epic planning/auth-system --output config/auth-epic.json
44
+ /parse-epic planning/my-epic --validate
45
+ /parse-epic planning/custom --overview planning/custom/OVERVIEW.md
46
+ `);
47
+ process.exit(0);
48
+ }
49
+
50
+ /**
51
+ * Parse epic directly using compiled epic-parser
52
+ */
53
+ async function parseEpic() {
54
+ try {
55
+ // Parse arguments
56
+ const epicDir = path.resolve(args[0]);
57
+ const outputFlag = args.indexOf('--output') >= 0 ? args.indexOf('--output') : args.indexOf('-o');
58
+ const validateFlag = args.includes('--validate') || args.includes('-v');
59
+ const overviewFlag = args.indexOf('--overview');
60
+
61
+ const outputFile = outputFlag >= 0 ? path.resolve(args[outputFlag + 1]) : path.join(epicDir, 'epic-config.json');
62
+ const overviewFile = overviewFlag >= 0 ? path.resolve(args[overviewFlag + 1]) : undefined;
63
+
64
+ console.log(chalk.cyan('🔍 Epic Parser - Natural Language to Structured JSON\n'));
65
+ console.log(chalk.gray(`Epic directory: ${epicDir}`));
66
+ console.log(chalk.gray(`Output file: ${outputFile}`));
67
+ if (overviewFile) {
68
+ console.log(chalk.gray(`Overview file: ${overviewFile}`));
69
+ }
70
+ console.log('');
71
+
72
+ // Validate epic directory exists
73
+ try {
74
+ await fs.access(epicDir);
75
+ } catch (err) {
76
+ console.error(chalk.red(`❌ Epic directory not found: ${epicDir}`));
77
+ process.exit(1);
78
+ }
79
+
80
+ // Dynamic import of compiled epic-parser
81
+ const distPath = path.join(projectRoot, '.claude-flow-novice/dist/src/parsers/epic-parser.js');
82
+
83
+ try {
84
+ await fs.access(distPath);
85
+ } catch (err) {
86
+ console.error(chalk.red(`❌ Epic parser not found. Please build the project first:`));
87
+ console.error(chalk.yellow(` npm run build`));
88
+ process.exit(1);
89
+ }
90
+
91
+ const { EpicParser } = await import(distPath);
92
+
93
+ // Parse epic
94
+ console.log(chalk.cyan('📝 Parsing epic markdown files...'));
95
+
96
+ const parserOptions = {
97
+ epicDirectory: epicDir
98
+ };
99
+
100
+ if (overviewFile) {
101
+ parserOptions.overviewFile = overviewFile;
102
+ }
103
+
104
+ const parser = new EpicParser(parserOptions);
105
+ const config = parser.parse();
106
+ const validation = parser.getValidationResult();
107
+
108
+ // Display validation results
109
+ if (validation.errors && validation.errors.length > 0) {
110
+ console.error(chalk.red(`\n❌ Parsing errors (${validation.errors.length}):`));
111
+ validation.errors.forEach(err => {
112
+ const location = err.location ? chalk.gray(` (${err.location.file})`) : '';
113
+ console.error(chalk.red(` - [${err.type}] ${err.message}${location}`));
114
+ });
115
+ }
116
+
117
+ if (validation.warnings && validation.warnings.length > 0) {
118
+ console.warn(chalk.yellow(`\n⚠️ Warnings (${validation.warnings.length}):`));
119
+ validation.warnings.forEach(warn => {
120
+ const location = warn.location ? chalk.gray(` (${warn.location.file})`) : '';
121
+ console.warn(chalk.yellow(` - [${warn.type}] ${warn.message}${location}`));
122
+ });
123
+ }
124
+
125
+ // Display statistics
126
+ if (validation.stats) {
127
+ console.log(chalk.green('\n📊 Epic Statistics:'));
128
+ console.log(chalk.cyan(` Epic ID: ${config.epicId}`));
129
+ console.log(chalk.cyan(` Name: ${config.name}`));
130
+ console.log(chalk.cyan(` Status: ${config.status}`));
131
+ console.log(chalk.cyan(` Phases: ${validation.stats.totalPhases}`));
132
+ console.log(chalk.cyan(` Sprints: ${validation.stats.totalSprints}`));
133
+ console.log(chalk.cyan(` Completed: ${validation.stats.completedSprints}/${validation.stats.totalSprints}`));
134
+ console.log(chalk.cyan(` Dependencies: ${validation.stats.dependencyCount}`));
135
+
136
+ if (validation.stats.cyclesDetected > 0) {
137
+ console.log(chalk.red(` Dependency Cycles: ${validation.stats.cyclesDetected}`));
138
+ }
139
+ }
140
+
141
+ // Save output
142
+ await fs.writeFile(outputFile, JSON.stringify(config, null, 2), 'utf-8');
143
+ console.log(chalk.green(`\n✅ Epic config saved: ${outputFile}`));
144
+
145
+ // Validate if requested
146
+ if (validateFlag) {
147
+ console.log(chalk.cyan('\n🔍 Running schema validation...'));
148
+ const { default: validateEpicConfig } = await import(path.join(projectRoot, '.claude-flow-novice/dist/src/validators/epic-config-schema.js'));
149
+
150
+ const schemaValidation = EpicParser.validate(config);
151
+
152
+ if (schemaValidation.valid) {
153
+ console.log(chalk.green('✅ Epic config passes schema validation'));
154
+ } else {
155
+ console.error(chalk.red(`\n❌ Schema validation failed (${schemaValidation.errors.length} errors):`));
156
+ schemaValidation.errors.forEach(err => {
157
+ console.error(chalk.red(` - ${err}`));
158
+ });
159
+ process.exit(1);
160
+ }
161
+ }
162
+
163
+ console.log(chalk.green('\n✅ Epic parsing complete!'));
164
+ process.exit(0);
165
+
166
+ } catch (error) {
167
+ console.error(chalk.red('\n❌ Epic parsing failed:'));
168
+ console.error(chalk.red(error.message));
169
+
170
+ if (error.stack) {
171
+ console.error(chalk.gray('\nStack trace:'));
172
+ console.error(chalk.gray(error.stack));
173
+ }
174
+
175
+ process.exit(1);
176
+ }
177
+ }
178
+
179
+ // Execute
180
+ parseEpic();
@@ -7,7 +7,8 @@
7
7
  "WebSearch",
8
8
  "Bash(npm run build:*)",
9
9
  "Bash(node:*)",
10
- "Bash(npm run build:types:*)"
10
+ "Bash(npm run build:types:*)",
11
+ "mcp__claude-flow-novice__swarm_init"
11
12
  ],
12
13
  "deny": []
13
14
  },
@@ -150,6 +150,18 @@ class ClaudeFlowNoviceMCPServer {
150
150
  properties: { swarmId: { type: 'string' } },
151
151
  },
152
152
  },
153
+ session_extend: {
154
+ name: 'session_extend',
155
+ description: 'Extend MCP session timeout for long-running CFN loops (prevents disconnection during multi-hour operations)',
156
+ inputSchema: {
157
+ type: 'object',
158
+ properties: {
159
+ sessionId: { type: 'string' },
160
+ extensionHours: { type: 'number', default: 4, minimum: 1, maximum: 24 },
161
+ },
162
+ required: ['sessionId'],
163
+ },
164
+ },
153
165
 
154
166
  // Essential Memory Management Tools (8)
155
167
  memory_usage: {
@@ -573,6 +585,18 @@ class ClaudeFlowNoviceMCPServer {
573
585
  }
574
586
  return { success: true, action: args.action };
575
587
 
588
+ case 'session_extend':
589
+ const extensionHours = args.extensionHours || 4;
590
+ const extensionMs = extensionHours * 60 * 60 * 1000;
591
+ return {
592
+ success: true,
593
+ sessionId: args.sessionId || this.sessionId,
594
+ extensionHours,
595
+ newTimeoutMs: extensionMs,
596
+ message: `Session timeout extended by ${extensionHours} hours (${extensionMs}ms)`,
597
+ note: 'Session timeout configured at server startup (8 hours default). This tool reports extension confirmation.',
598
+ };
599
+
576
600
  default:
577
601
  return {
578
602
  success: true,
@@ -695,9 +719,20 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
695
719
 
696
720
  process.stdin.on('end', () => {
697
721
  console.error(
698
- `[${new Date().toISOString()}] INFO [claude-flow-novice-mcp] (${server.sessionId}) 🔌 Connection closed: ${server.sessionId}`,
722
+ `[${new Date().toISOString()}] WARN [claude-flow-novice-mcp] (${server.sessionId}) MCP server received stdin close, attempting graceful shutdown...`,
699
723
  );
700
- process.exit(0);
724
+
725
+ // Grace period for pending operations (30 seconds)
726
+ // Allows CFN loop agents to complete final memory writes before shutdown
727
+ setTimeout(async () => {
728
+ if (server.memoryStore) {
729
+ await server.memoryStore.close();
730
+ }
731
+ console.error(
732
+ `[${new Date().toISOString()}] INFO [claude-flow-novice-mcp] (${server.sessionId}) 🔌 MCP server shutdown complete: ${server.sessionId}`,
733
+ );
734
+ process.exit(0);
735
+ }, 30000);
701
736
  });
702
737
 
703
738
  // Handle process termination
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Base transport interface for MCP
3
+ */ export { };
4
+
5
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/mcp/transports/base.ts"],"names":[],"mappings":"AAAA;;CAEC,GAOD,WAcC"}
@@ -0,0 +1,414 @@
1
+ /**
2
+ * HTTP transport for MCP
3
+ */ import express from 'express';
4
+ import { createServer } from 'node:http';
5
+ import { WebSocketServer, WebSocket } from 'ws';
6
+ import cors from 'cors';
7
+ import helmet from 'helmet';
8
+ import { join, dirname } from 'node:path';
9
+ import { fileURLToPath } from 'node:url';
10
+ import { MCPTransportError } from '../../utils/errors.js';
11
+ /**
12
+ * HTTP transport implementation
13
+ */ export class HttpTransport {
14
+ host;
15
+ port;
16
+ tlsEnabled;
17
+ logger;
18
+ config;
19
+ requestHandler;
20
+ notificationHandler;
21
+ app;
22
+ server;
23
+ wss;
24
+ messageCount = 0;
25
+ notificationCount = 0;
26
+ running = false;
27
+ connections = new Set();
28
+ activeWebSockets = new Set();
29
+ constructor(host, port, tlsEnabled, logger, config){
30
+ this.host = host;
31
+ this.port = port;
32
+ this.tlsEnabled = tlsEnabled;
33
+ this.logger = logger;
34
+ this.config = config;
35
+ this.app = express();
36
+ this.setupMiddleware();
37
+ this.setupRoutes();
38
+ }
39
+ async start() {
40
+ if (this.running) {
41
+ throw new MCPTransportError('Transport already running');
42
+ }
43
+ this.logger.info('Starting HTTP transport', {
44
+ host: this.host,
45
+ port: this.port,
46
+ tls: this.tlsEnabled
47
+ });
48
+ try {
49
+ // Create HTTP server
50
+ this.server = createServer(this.app);
51
+ // Create WebSocket server
52
+ this.wss = new WebSocketServer({
53
+ server: this.server,
54
+ path: '/ws'
55
+ });
56
+ this.setupWebSocketHandlers();
57
+ // Start server
58
+ await new Promise((resolve, reject)=>{
59
+ this.server.listen(this.port, this.host, ()=>{
60
+ this.logger.info(`HTTP server listening on ${this.host}:${this.port}`);
61
+ resolve();
62
+ });
63
+ this.server.on('error', reject);
64
+ });
65
+ this.running = true;
66
+ this.logger.info('HTTP transport started');
67
+ } catch (error) {
68
+ throw new MCPTransportError('Failed to start HTTP transport', {
69
+ error
70
+ });
71
+ }
72
+ }
73
+ async stop() {
74
+ if (!this.running) {
75
+ return;
76
+ }
77
+ this.logger.info('Stopping HTTP transport');
78
+ this.running = false;
79
+ // Close all WebSocket connections
80
+ for (const ws of this.activeWebSockets){
81
+ try {
82
+ ws.close();
83
+ } catch {
84
+ // Ignore errors
85
+ }
86
+ }
87
+ this.activeWebSockets.clear();
88
+ this.connections.clear();
89
+ // Close WebSocket server
90
+ if (this.wss) {
91
+ this.wss.close();
92
+ this.wss = undefined;
93
+ }
94
+ // Shutdown HTTP server
95
+ if (this.server) {
96
+ await new Promise((resolve)=>{
97
+ this.server.close(()=>resolve());
98
+ });
99
+ this.server = undefined;
100
+ }
101
+ this.logger.info('HTTP transport stopped');
102
+ }
103
+ onRequest(handler) {
104
+ this.requestHandler = handler;
105
+ }
106
+ onNotification(handler) {
107
+ this.notificationHandler = handler;
108
+ }
109
+ async getHealthStatus() {
110
+ return {
111
+ healthy: this.running,
112
+ metrics: {
113
+ messagesReceived: this.messageCount,
114
+ notificationsSent: this.notificationCount,
115
+ activeConnections: this.connections.size,
116
+ activeWebSockets: this.activeWebSockets.size
117
+ }
118
+ };
119
+ }
120
+ setupMiddleware() {
121
+ // Security middleware
122
+ this.app.use(helmet());
123
+ // CORS middleware
124
+ if (this.config?.corsEnabled) {
125
+ const origins = this.config.corsOrigins || [
126
+ '*'
127
+ ];
128
+ this.app.use(cors({
129
+ origin: origins,
130
+ credentials: true,
131
+ maxAge: 86400
132
+ }));
133
+ }
134
+ // Body parsing middleware
135
+ this.app.use(express.json({
136
+ limit: '10mb'
137
+ }));
138
+ this.app.use(express.text());
139
+ }
140
+ setupRoutes() {
141
+ // Get current file directory for static files
142
+ const __filename = typeof import.meta?.url !== 'undefined' ? fileURLToPath(import.meta.url) : __filename || __dirname + '/http.ts';
143
+ const __dirname = dirname(__filename);
144
+ const consoleDir = join(__dirname, '../../ui/console');
145
+ // Serve static files for the web console
146
+ this.app.use('/console', express.static(consoleDir));
147
+ // Web console route
148
+ this.app.get('/', (req, res)=>{
149
+ res.redirect('/console');
150
+ });
151
+ this.app.get('/console', (req, res)=>{
152
+ res.sendFile(join(consoleDir, 'index.html'));
153
+ });
154
+ // Health check endpoint
155
+ this.app.get('/health', (req, res)=>{
156
+ res.json({
157
+ status: 'ok',
158
+ timestamp: new Date().toISOString()
159
+ });
160
+ });
161
+ // MCP JSON-RPC endpoint
162
+ this.app.post('/rpc', async (req, res)=>{
163
+ await this.handleJsonRpcRequest(req, res);
164
+ });
165
+ // Handle preflight requests
166
+ this.app.options('*', (req, res)=>{
167
+ res.status(204).end();
168
+ });
169
+ // 404 handler
170
+ this.app.use((req, res)=>{
171
+ res.status(404).json({
172
+ error: 'Not found'
173
+ });
174
+ });
175
+ // Error handler
176
+ this.app.use((err, req, res, next)=>{
177
+ this.logger.error('Express error', err);
178
+ res.status(500).json({
179
+ error: 'Internal server error',
180
+ message: err.message
181
+ });
182
+ });
183
+ }
184
+ setupWebSocketHandlers() {
185
+ if (!this.wss) return;
186
+ this.wss.on('connection', (ws, req)=>{
187
+ this.activeWebSockets.add(ws);
188
+ this.logger.info('WebSocket client connected', {
189
+ totalClients: this.activeWebSockets.size
190
+ });
191
+ ws.on('close', ()=>{
192
+ this.activeWebSockets.delete(ws);
193
+ this.logger.info('WebSocket client disconnected', {
194
+ totalClients: this.activeWebSockets.size
195
+ });
196
+ });
197
+ ws.on('error', (error)=>{
198
+ this.logger.error('WebSocket error', error);
199
+ this.activeWebSockets.delete(ws);
200
+ });
201
+ ws.on('message', async (data)=>{
202
+ try {
203
+ const message = JSON.parse(data.toString());
204
+ if (message.id === undefined) {
205
+ // Notification from client
206
+ await this.handleNotificationMessage(message);
207
+ } else {
208
+ // Request from client
209
+ const response = await this.handleRequestMessage(message);
210
+ ws.send(JSON.stringify(response));
211
+ }
212
+ } catch (error) {
213
+ this.logger.error('Error processing WebSocket message', error);
214
+ // Send error response if it was a request
215
+ try {
216
+ const parsed = JSON.parse(data.toString());
217
+ if (parsed.id !== undefined) {
218
+ ws.send(JSON.stringify({
219
+ jsonrpc: '2.0',
220
+ id: parsed.id,
221
+ error: {
222
+ code: -32603,
223
+ message: 'Internal error'
224
+ }
225
+ }));
226
+ }
227
+ } catch {
228
+ // Ignore parse errors for error responses
229
+ }
230
+ }
231
+ });
232
+ });
233
+ }
234
+ async handleJsonRpcRequest(req, res) {
235
+ // Check content type
236
+ if (!req.is('application/json')) {
237
+ res.status(400).json({
238
+ jsonrpc: '2.0',
239
+ id: null,
240
+ error: {
241
+ code: -32600,
242
+ message: 'Invalid content type - expected application/json'
243
+ }
244
+ });
245
+ return;
246
+ }
247
+ // Check authorization if authentication is enabled
248
+ if (this.config?.auth?.enabled) {
249
+ const authResult = await this.validateAuth(req);
250
+ if (!authResult.valid) {
251
+ res.status(401).json({
252
+ error: authResult.error || 'Unauthorized'
253
+ });
254
+ return;
255
+ }
256
+ }
257
+ try {
258
+ const mcpMessage = req.body;
259
+ // Validate JSON-RPC format
260
+ if (!mcpMessage.jsonrpc || mcpMessage.jsonrpc !== '2.0') {
261
+ res.status(400).json({
262
+ jsonrpc: '2.0',
263
+ id: mcpMessage.id || null,
264
+ error: {
265
+ code: -32600,
266
+ message: 'Invalid request - missing or invalid jsonrpc version'
267
+ }
268
+ });
269
+ return;
270
+ }
271
+ if (!mcpMessage.method) {
272
+ res.status(400).json({
273
+ jsonrpc: '2.0',
274
+ id: mcpMessage.id || null,
275
+ error: {
276
+ code: -32600,
277
+ message: 'Invalid request - missing method'
278
+ }
279
+ });
280
+ return;
281
+ }
282
+ this.messageCount++;
283
+ // Check if this is a notification (no id) or request
284
+ if (mcpMessage.id === undefined) {
285
+ // Handle notification
286
+ await this.handleNotificationMessage(mcpMessage);
287
+ // Notifications don't get responses
288
+ res.status(204).end();
289
+ } else {
290
+ // Handle request
291
+ const response = await this.handleRequestMessage(mcpMessage);
292
+ res.json(response);
293
+ }
294
+ } catch (error) {
295
+ this.logger.error('Error handling JSON-RPC request', error);
296
+ res.status(500).json({
297
+ jsonrpc: '2.0',
298
+ id: null,
299
+ error: {
300
+ code: -32603,
301
+ message: 'Internal error',
302
+ data: error instanceof Error ? error.message : String(error)
303
+ }
304
+ });
305
+ }
306
+ }
307
+ async handleRequestMessage(request) {
308
+ if (!this.requestHandler) {
309
+ return {
310
+ jsonrpc: '2.0',
311
+ id: request.id,
312
+ error: {
313
+ code: -32603,
314
+ message: 'No request handler registered'
315
+ }
316
+ };
317
+ }
318
+ try {
319
+ return await this.requestHandler(request);
320
+ } catch (error) {
321
+ this.logger.error('Request handler error', {
322
+ request,
323
+ error
324
+ });
325
+ return {
326
+ jsonrpc: '2.0',
327
+ id: request.id,
328
+ error: {
329
+ code: -32603,
330
+ message: 'Internal error',
331
+ data: error instanceof Error ? error.message : String(error)
332
+ }
333
+ };
334
+ }
335
+ }
336
+ async handleNotificationMessage(notification) {
337
+ if (!this.notificationHandler) {
338
+ this.logger.warn('Received notification but no handler registered', {
339
+ method: notification.method
340
+ });
341
+ return;
342
+ }
343
+ try {
344
+ await this.notificationHandler(notification);
345
+ } catch (error) {
346
+ this.logger.error('Notification handler error', {
347
+ notification,
348
+ error
349
+ });
350
+ // Notifications don't send error responses
351
+ }
352
+ }
353
+ async validateAuth(req) {
354
+ const auth = req.headers.authorization;
355
+ if (!auth) {
356
+ return {
357
+ valid: false,
358
+ error: 'Authorization header required'
359
+ };
360
+ }
361
+ // Extract token from Authorization header
362
+ const tokenMatch = auth.match(/^Bearer\s+(.+)$/i);
363
+ if (!tokenMatch) {
364
+ return {
365
+ valid: false,
366
+ error: 'Invalid authorization format - use Bearer token'
367
+ };
368
+ }
369
+ const token = tokenMatch[1];
370
+ // Validate against configured tokens
371
+ if (this.config?.auth?.tokens && this.config.auth.tokens.length > 0) {
372
+ const isValid = this.config.auth.tokens.includes(token);
373
+ if (!isValid) {
374
+ return {
375
+ valid: false,
376
+ error: 'Invalid token'
377
+ };
378
+ }
379
+ }
380
+ return {
381
+ valid: true
382
+ };
383
+ }
384
+ async connect() {
385
+ // For HTTP transport, connect is handled by start()
386
+ if (!this.running) {
387
+ await this.start();
388
+ }
389
+ }
390
+ async disconnect() {
391
+ // For HTTP transport, disconnect is handled by stop()
392
+ await this.stop();
393
+ }
394
+ async sendRequest(request) {
395
+ // HTTP transport is server-side, it doesn't send requests
396
+ throw new Error('HTTP transport does not support sending requests');
397
+ }
398
+ async sendNotification(notification) {
399
+ // Broadcast notification to all connected WebSocket clients
400
+ const message = JSON.stringify(notification);
401
+ for (const ws of this.activeWebSockets){
402
+ try {
403
+ if (ws.readyState === WebSocket.OPEN) {
404
+ ws.send(message);
405
+ }
406
+ } catch (error) {
407
+ this.logger.error('Failed to send notification to WebSocket', error);
408
+ }
409
+ }
410
+ this.notificationCount++;
411
+ }
412
+ }
413
+
414
+ //# sourceMappingURL=http.js.map