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,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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/mcp/transports/http.ts"],"names":["express","createServer","WebSocketServer","WebSocket","cors","helmet","join","dirname","fileURLToPath","MCPTransportError","HttpTransport","requestHandler","notificationHandler","app","server","wss","messageCount","notificationCount","running","connections","Set","activeWebSockets","host","port","tlsEnabled","logger","config","setupMiddleware","setupRoutes","start","info","tls","path","setupWebSocketHandlers","Promise","resolve","reject","listen","on","error","stop","ws","close","clear","undefined","onRequest","handler","onNotification","getHealthStatus","healthy","metrics","messagesReceived","notificationsSent","activeConnections","size","use","corsEnabled","origins","corsOrigins","origin","credentials","maxAge","json","limit","text","__filename","url","__dirname","consoleDir","static","get","req","res","redirect","sendFile","status","timestamp","Date","toISOString","post","handleJsonRpcRequest","options","end","err","next","message","add","totalClients","delete","data","JSON","parse","toString","id","handleNotificationMessage","response","handleRequestMessage","send","stringify","parsed","jsonrpc","code","is","auth","enabled","authResult","validateAuth","valid","mcpMessage","body","method","Error","String","request","notification","warn","headers","authorization","tokenMatch","match","token","tokens","length","isValid","includes","connect","disconnect","sendRequest","sendNotification","readyState","OPEN"],"mappings":"AAAA;;CAEC,GAED,OAAOA,aAA6C,UAAU;AAC9D,SAASC,YAAY,QAAgB,YAAY;AACjD,SAASC,eAAe,EAAEC,SAAS,QAAQ,KAAK;AAChD,OAAOC,UAAU,OAAO;AACxB,OAAOC,YAAY,SAAS;AAC5B,SAASC,IAAI,EAAEC,OAAO,Q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IACxB;AACF"}
@@ -0,0 +1,217 @@
1
+ /**
2
+ * Standard I/O transport for MCP
3
+ */ import { stdin, stdout } from 'node:process';
4
+ import { createInterface } from 'node:readline';
5
+ import { MCPTransportError } from '../../utils/errors.js';
6
+ /**
7
+ * Stdio transport implementation
8
+ */ export class StdioTransport {
9
+ logger;
10
+ requestHandler;
11
+ notificationHandler;
12
+ readline;
13
+ messageCount = 0;
14
+ notificationCount = 0;
15
+ running = false;
16
+ constructor(logger){
17
+ this.logger = logger;
18
+ }
19
+ async start() {
20
+ if (this.running) {
21
+ throw new MCPTransportError('Transport already running');
22
+ }
23
+ this.logger.info('Starting stdio transport');
24
+ try {
25
+ // Create readline interface for stdin
26
+ this.readline = createInterface({
27
+ input: stdin,
28
+ output: stdout,
29
+ terminal: false
30
+ });
31
+ // Set up line handler
32
+ this.readline.on('line', (line)=>{
33
+ this.processMessage(line.trim()).catch((error)=>{
34
+ this.logger.error('Error processing message', {
35
+ line,
36
+ error
37
+ });
38
+ });
39
+ });
40
+ this.readline.on('close', ()=>{
41
+ this.logger.info('Stdin closed');
42
+ this.running = false;
43
+ });
44
+ this.running = true;
45
+ this.logger.info('Stdio transport started');
46
+ } catch (error) {
47
+ throw new MCPTransportError('Failed to start stdio transport', {
48
+ error
49
+ });
50
+ }
51
+ }
52
+ async stop() {
53
+ if (!this.running) {
54
+ return;
55
+ }
56
+ this.logger.info('Stopping stdio transport');
57
+ this.running = false;
58
+ if (this.readline) {
59
+ this.readline.close();
60
+ this.readline = undefined;
61
+ }
62
+ this.logger.info('Stdio transport stopped');
63
+ }
64
+ onRequest(handler) {
65
+ this.requestHandler = handler;
66
+ }
67
+ onNotification(handler) {
68
+ this.notificationHandler = handler;
69
+ }
70
+ async getHealthStatus() {
71
+ return {
72
+ healthy: this.running,
73
+ metrics: {
74
+ messagesReceived: this.messageCount,
75
+ notificationsSent: this.notificationCount,
76
+ stdinOpen: this.readline ? 1 : 0
77
+ }
78
+ };
79
+ }
80
+ async processMessage(line) {
81
+ let message;
82
+ try {
83
+ message = JSON.parse(line);
84
+ if (!message.jsonrpc || message.jsonrpc !== '2.0') {
85
+ throw new Error('Invalid JSON-RPC version');
86
+ }
87
+ if (!message.method) {
88
+ throw new Error('Missing method');
89
+ }
90
+ } catch (error) {
91
+ this.logger.error('Failed to parse message', {
92
+ line,
93
+ error
94
+ });
95
+ // Send error response if we can extract an ID
96
+ let id = 'unknown';
97
+ try {
98
+ const parsed = JSON.parse(line);
99
+ if (parsed.id !== undefined) {
100
+ id = parsed.id;
101
+ }
102
+ } catch {
103
+ // Ignore parse error for ID extraction
104
+ }
105
+ await this.sendResponse({
106
+ jsonrpc: '2.0',
107
+ id,
108
+ error: {
109
+ code: -32700,
110
+ message: 'Parse error'
111
+ }
112
+ });
113
+ return;
114
+ }
115
+ this.messageCount++;
116
+ // Check if this is a notification (no id field) or a request
117
+ if (message.id === undefined) {
118
+ // This is a notification
119
+ await this.handleNotification(message);
120
+ } else {
121
+ // This is a request
122
+ await this.handleRequest(message);
123
+ }
124
+ }
125
+ async handleRequest(request) {
126
+ if (!this.requestHandler) {
127
+ await this.sendResponse({
128
+ jsonrpc: '2.0',
129
+ id: request.id,
130
+ error: {
131
+ code: -32603,
132
+ message: 'No request handler registered'
133
+ }
134
+ });
135
+ return;
136
+ }
137
+ try {
138
+ const response = await this.requestHandler(request);
139
+ await this.sendResponse(response);
140
+ } catch (error) {
141
+ this.logger.error('Request handler error', {
142
+ request,
143
+ error
144
+ });
145
+ await this.sendResponse({
146
+ jsonrpc: '2.0',
147
+ id: request.id,
148
+ error: {
149
+ code: -32603,
150
+ message: 'Internal error',
151
+ data: error instanceof Error ? error.message : String(error)
152
+ }
153
+ });
154
+ }
155
+ }
156
+ async handleNotification(notification) {
157
+ if (!this.notificationHandler) {
158
+ this.logger.warn('Received notification but no handler registered', {
159
+ method: notification.method
160
+ });
161
+ return;
162
+ }
163
+ try {
164
+ await this.notificationHandler(notification);
165
+ } catch (error) {
166
+ this.logger.error('Notification handler error', {
167
+ notification,
168
+ error
169
+ });
170
+ // Notifications don't send error responses
171
+ }
172
+ }
173
+ async sendResponse(response) {
174
+ try {
175
+ const json = JSON.stringify(response);
176
+ stdout.write(json + '\n');
177
+ } catch (error) {
178
+ this.logger.error('Failed to send response', {
179
+ response,
180
+ error
181
+ });
182
+ }
183
+ }
184
+ async connect() {
185
+ // For STDIO transport, connect is handled by start()
186
+ if (!this.running) {
187
+ await this.start();
188
+ }
189
+ }
190
+ async disconnect() {
191
+ // For STDIO transport, disconnect is handled by stop()
192
+ await this.stop();
193
+ }
194
+ async sendRequest(request) {
195
+ // Send request to stdout
196
+ const json = JSON.stringify(request);
197
+ stdout.write(json + '\n');
198
+ // In STDIO transport, responses are handled asynchronously
199
+ // This would need a proper request/response correlation mechanism
200
+ throw new Error('STDIO transport sendRequest requires request/response correlation');
201
+ }
202
+ async sendNotification(notification) {
203
+ try {
204
+ const json = JSON.stringify(notification);
205
+ stdout.write(json + '\n');
206
+ this.notificationCount++;
207
+ } catch (error) {
208
+ this.logger.error('Failed to send notification', {
209
+ notification,
210
+ error
211
+ });
212
+ throw error;
213
+ }
214
+ }
215
+ }
216
+
217
+ //# sourceMappingURL=stdio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/mcp/transports/stdio.ts"],"names":["stdin","stdout","createInterface","MCPTransportError","StdioTransport","requestHandler","notificationHandler","readline","messageCount","notificationCount","running","logger","start","info","input","output","terminal","on","line","processMessage","trim","catch","error","stop","close","undefined","onRequest","handler","onNotification","getHealthStatus","healthy","metrics","messagesReceived","notificationsSent","stdinOpen","message","JSON","parse","jsonrpc","Error","method","id","parsed","sendResponse","code","handleNotification","handleRequest","request","response","data","String","notification","warn","json","stringify","write","connect","disconnect","sendRequest","sendNotification"],"mappings":"AAAA;;CAEC,GAGD,SAASA,KAAK,EAAEC,MAAM,QAAQ,eAAe;AAC7C,SAASC,eAAe,QAAmB,gBAAgB;AAI3D,SAASC,iBAAiB,QAAQ,wBAAw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