kynjal-cli 3.1.3 → 4.0.0

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 (566) hide show
  1. package/.claude/agents/core/coder.md +1 -1
  2. package/.claude/agents/core/planner.md +2 -2
  3. package/.claude/agents/core/researcher.md +1 -1
  4. package/.claude/agents/core/reviewer.md +1 -1
  5. package/.claude/agents/core/tester.md +1 -1
  6. package/.claude/agents/data/data-ml-model.md +4 -4
  7. package/.claude/agents/development/dev-backend-api.md +4 -4
  8. package/.claude/agents/documentation/docs-api-openapi.md +4 -4
  9. package/.claude/agents/github/code-review-swarm.md +2 -2
  10. package/.claude/agents/github/issue-tracker.md +2 -2
  11. package/.claude/agents/github/pr-manager.md +2 -2
  12. package/.claude/agents/github/release-manager.md +2 -2
  13. package/.claude/agents/github/workflow-automation.md +2 -2
  14. package/.claude/agents/sparc/architecture.md +3 -3
  15. package/.claude/agents/sparc/pseudocode.md +2 -2
  16. package/.claude/agents/sparc/refinement.md +3 -3
  17. package/.claude/agents/sparc/specification.md +2 -2
  18. package/.claude/agents/swarm/adaptive-coordinator.md +1 -1
  19. package/.claude/agents/swarm/hierarchical-coordinator.md +1 -1
  20. package/.claude/agents/swarm/mesh-coordinator.md +1 -1
  21. package/.claude/agents/templates/base-template-generator.md +25 -4
  22. package/.claude/agents/templates/sparc-coordinator.md +3 -3
  23. package/.claude/helpers/auto-commit.sh +1 -1
  24. package/.claude/helpers/auto-memory-hook.mjs +27 -9
  25. package/.claude/helpers/hook-handler.cjs +58 -18
  26. package/.claude/helpers/statusline.cjs +14 -33
  27. package/.claude/helpers/statusline.js +3 -3
  28. package/.claude/settings.json +9 -9
  29. package/.claude/skills/reasoningbank-intelligence/SKILL.md +2 -2
  30. package/.claude/skills/swarm-orchestration/SKILL.md +1 -1
  31. package/README.md +383 -170
  32. package/bin/cli.js +6 -6
  33. package/bin/mcp-server.js +1 -1
  34. package/bin/preinstall.cjs +2 -0
  35. package/dist/src/appliance/gguf-engine.js +664 -0
  36. package/dist/src/appliance/gguf-engine.js.map +1 -0
  37. package/dist/src/appliance/ruvllm-bridge.js +492 -0
  38. package/dist/src/appliance/ruvllm-bridge.js.map +1 -0
  39. package/dist/src/appliance/rvfa-builder.js +383 -0
  40. package/dist/src/appliance/rvfa-builder.js.map +1 -0
  41. package/dist/src/appliance/rvfa-distribution.js +533 -0
  42. package/dist/src/appliance/rvfa-distribution.js.map +1 -0
  43. package/dist/src/appliance/rvfa-format.js +465 -0
  44. package/dist/src/appliance/rvfa-format.js.map +1 -0
  45. package/dist/src/appliance/rvfa-runner.js +373 -0
  46. package/dist/src/appliance/rvfa-runner.js.map +1 -0
  47. package/dist/src/appliance/rvfa-signing.js +469 -0
  48. package/dist/src/appliance/rvfa-signing.js.map +1 -0
  49. package/dist/src/benchmarks/pretrain/index.js +542 -331
  50. package/dist/src/benchmarks/pretrain/index.js.map +1 -1
  51. package/dist/src/commands/agent.d.ts.map +1 -1
  52. package/dist/src/commands/agent.js +725 -502
  53. package/dist/src/commands/agent.js.map +1 -1
  54. package/dist/src/commands/analyze.js +1548 -1218
  55. package/dist/src/commands/analyze.js.map +1 -1
  56. package/dist/src/commands/appliance-advanced.d.ts +9 -0
  57. package/dist/src/commands/appliance-advanced.d.ts.map +1 -0
  58. package/dist/src/commands/appliance-advanced.js +324 -0
  59. package/dist/src/commands/appliance-advanced.js.map +1 -0
  60. package/dist/src/commands/appliance.d.ts +8 -0
  61. package/dist/src/commands/appliance.d.ts.map +1 -0
  62. package/dist/src/commands/appliance.js +581 -0
  63. package/dist/src/commands/appliance.js.map +1 -0
  64. package/dist/src/commands/benchmark.js +523 -372
  65. package/dist/src/commands/benchmark.js.map +1 -1
  66. package/dist/src/commands/claims.js +364 -274
  67. package/dist/src/commands/claims.js.map +1 -1
  68. package/dist/src/commands/cleanup.d.ts +13 -0
  69. package/dist/src/commands/cleanup.d.ts.map +1 -0
  70. package/dist/src/commands/cleanup.js +262 -0
  71. package/dist/src/commands/cleanup.js.map +1 -0
  72. package/dist/src/commands/completions.js +118 -477
  73. package/dist/src/commands/completions.js.map +1 -1
  74. package/dist/src/commands/config.js +303 -237
  75. package/dist/src/commands/config.js.map +1 -1
  76. package/dist/src/commands/daemon.d.ts.map +1 -1
  77. package/dist/src/commands/daemon.js +597 -425
  78. package/dist/src/commands/daemon.js.map +1 -1
  79. package/dist/src/commands/deployment.js +275 -194
  80. package/dist/src/commands/deployment.js.map +1 -1
  81. package/dist/src/commands/doctor.d.ts.map +1 -1
  82. package/dist/src/commands/doctor.js +690 -460
  83. package/dist/src/commands/doctor.js.map +1 -1
  84. package/dist/src/commands/embeddings.js +1543 -1293
  85. package/dist/src/commands/embeddings.js.map +1 -1
  86. package/dist/src/commands/guidance.js +596 -449
  87. package/dist/src/commands/guidance.js.map +1 -1
  88. package/dist/src/commands/hive-mind.js +938 -854
  89. package/dist/src/commands/hive-mind.js.map +1 -1
  90. package/dist/src/commands/hooks.d.ts.map +1 -1
  91. package/dist/src/commands/hooks.js +3677 -2570
  92. package/dist/src/commands/hooks.js.map +1 -1
  93. package/dist/src/commands/index.js +322 -122
  94. package/dist/src/commands/index.js.map +1 -1
  95. package/dist/src/commands/init.d.ts +1 -1
  96. package/dist/src/commands/init.d.ts.map +1 -1
  97. package/dist/src/commands/init.js +943 -787
  98. package/dist/src/commands/init.js.map +1 -1
  99. package/dist/src/commands/issues.js +558 -383
  100. package/dist/src/commands/issues.js.map +1 -1
  101. package/dist/src/commands/mcp.d.ts.map +1 -1
  102. package/dist/src/commands/mcp.js +605 -475
  103. package/dist/src/commands/mcp.js.map +1 -1
  104. package/dist/src/commands/memory.d.ts.map +1 -1
  105. package/dist/src/commands/memory.js +1031 -814
  106. package/dist/src/commands/memory.js.map +1 -1
  107. package/dist/src/commands/migrate.js +347 -282
  108. package/dist/src/commands/migrate.js.map +1 -1
  109. package/dist/src/commands/neural.d.ts.map +1 -1
  110. package/dist/src/commands/neural.js +1563 -1283
  111. package/dist/src/commands/neural.js.map +1 -1
  112. package/dist/src/commands/performance.js +643 -497
  113. package/dist/src/commands/performance.js.map +1 -1
  114. package/dist/src/commands/plugins.js +841 -668
  115. package/dist/src/commands/plugins.js.map +1 -1
  116. package/dist/src/commands/process.js +447 -392
  117. package/dist/src/commands/process.js.map +1 -1
  118. package/dist/src/commands/progress.js +256 -162
  119. package/dist/src/commands/progress.js.map +1 -1
  120. package/dist/src/commands/providers.js +220 -150
  121. package/dist/src/commands/providers.js.map +1 -1
  122. package/dist/src/commands/route.js +665 -520
  123. package/dist/src/commands/route.js.map +1 -1
  124. package/dist/src/commands/ruvector/backup.js +651 -505
  125. package/dist/src/commands/ruvector/backup.js.map +1 -1
  126. package/dist/src/commands/ruvector/benchmark.js +401 -349
  127. package/dist/src/commands/ruvector/benchmark.js.map +1 -1
  128. package/dist/src/commands/ruvector/import.js +267 -225
  129. package/dist/src/commands/ruvector/import.js.map +1 -1
  130. package/dist/src/commands/ruvector/index.js +75 -37
  131. package/dist/src/commands/ruvector/index.js.map +1 -1
  132. package/dist/src/commands/ruvector/init.js +359 -336
  133. package/dist/src/commands/ruvector/init.js.map +1 -1
  134. package/dist/src/commands/ruvector/migrate.js +322 -335
  135. package/dist/src/commands/ruvector/migrate.js.map +1 -1
  136. package/dist/src/commands/ruvector/optimize.js +431 -375
  137. package/dist/src/commands/ruvector/optimize.js.map +1 -1
  138. package/dist/src/commands/ruvector/setup.js +117 -703
  139. package/dist/src/commands/ruvector/setup.js.map +1 -1
  140. package/dist/src/commands/ruvector/status.js +419 -364
  141. package/dist/src/commands/ruvector/status.js.map +1 -1
  142. package/dist/src/commands/security.d.ts.map +1 -1
  143. package/dist/src/commands/security.js +610 -456
  144. package/dist/src/commands/security.js.map +1 -1
  145. package/dist/src/commands/session.d.ts +1 -1
  146. package/dist/src/commands/session.js +627 -505
  147. package/dist/src/commands/session.js.map +1 -1
  148. package/dist/src/commands/start.d.ts +1 -1
  149. package/dist/src/commands/start.js +368 -271
  150. package/dist/src/commands/start.js.map +1 -1
  151. package/dist/src/commands/status.d.ts +1 -1
  152. package/dist/src/commands/status.d.ts.map +1 -1
  153. package/dist/src/commands/status.js +492 -379
  154. package/dist/src/commands/status.js.map +1 -1
  155. package/dist/src/commands/swarm.js +488 -408
  156. package/dist/src/commands/swarm.js.map +1 -1
  157. package/dist/src/commands/task.d.ts +1 -1
  158. package/dist/src/commands/task.js +539 -424
  159. package/dist/src/commands/task.js.map +1 -1
  160. package/dist/src/commands/transfer-store.js +412 -322
  161. package/dist/src/commands/transfer-store.js.map +1 -1
  162. package/dist/src/commands/update.js +291 -196
  163. package/dist/src/commands/update.js.map +1 -1
  164. package/dist/src/commands/workflow.js +486 -386
  165. package/dist/src/commands/workflow.js.map +1 -1
  166. package/dist/src/config-adapter.js +40 -39
  167. package/dist/src/config-adapter.js.map +1 -1
  168. package/dist/src/index.js +416 -312
  169. package/dist/src/index.js.map +1 -1
  170. package/dist/src/infrastructure/in-memory-repositories.js +507 -246
  171. package/dist/src/infrastructure/in-memory-repositories.js.map +1 -1
  172. package/dist/src/init/claudemd-generator.js +78 -368
  173. package/dist/src/init/claudemd-generator.js.map +1 -1
  174. package/dist/src/init/executor.js +1019 -1345
  175. package/dist/src/init/executor.js.map +1 -1
  176. package/dist/src/init/helpers-generator.js +60 -635
  177. package/dist/src/init/helpers-generator.js.map +1 -1
  178. package/dist/src/init/index.d.ts +1 -1
  179. package/dist/src/init/index.d.ts.map +1 -1
  180. package/dist/src/init/index.js +1 -1
  181. package/dist/src/init/index.js.map +1 -1
  182. package/dist/src/init/mcp-generator.d.ts +0 -1
  183. package/dist/src/init/mcp-generator.d.ts.map +1 -1
  184. package/dist/src/init/mcp-generator.js +62 -42
  185. package/dist/src/init/mcp-generator.js.map +1 -1
  186. package/dist/src/init/settings-generator.d.ts.map +1 -1
  187. package/dist/src/init/settings-generator.js +167 -100
  188. package/dist/src/init/settings-generator.js.map +1 -1
  189. package/dist/src/init/statusline-generator.d.ts +16 -8
  190. package/dist/src/init/statusline-generator.d.ts.map +1 -1
  191. package/dist/src/init/statusline-generator.js +20 -1300
  192. package/dist/src/init/statusline-generator.js.map +1 -1
  193. package/dist/src/init/types.d.ts +15 -5
  194. package/dist/src/init/types.d.ts.map +1 -1
  195. package/dist/src/init/types.js +66 -76
  196. package/dist/src/init/types.js.map +1 -1
  197. package/dist/src/mcp-client.js +130 -76
  198. package/dist/src/mcp-client.js.map +1 -1
  199. package/dist/src/mcp-server.js +758 -445
  200. package/dist/src/mcp-server.js.map +1 -1
  201. package/dist/src/mcp-tools/agent-tools.js +492 -391
  202. package/dist/src/mcp-tools/agent-tools.js.map +1 -1
  203. package/dist/src/mcp-tools/agentdb-tools.d.ts +30 -0
  204. package/dist/src/mcp-tools/agentdb-tools.d.ts.map +1 -0
  205. package/dist/src/mcp-tools/agentdb-tools.js +758 -0
  206. package/dist/src/mcp-tools/agentdb-tools.js.map +1 -0
  207. package/dist/src/mcp-tools/analyze-tools.js +236 -172
  208. package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
  209. package/dist/src/mcp-tools/auto-install.js +142 -80
  210. package/dist/src/mcp-tools/auto-install.js.map +1 -1
  211. package/dist/src/mcp-tools/browser-tools.js +375 -252
  212. package/dist/src/mcp-tools/browser-tools.js.map +1 -1
  213. package/dist/src/mcp-tools/claims-tools.js +565 -473
  214. package/dist/src/mcp-tools/claims-tools.js.map +1 -1
  215. package/dist/src/mcp-tools/config-tools.d.ts.map +1 -1
  216. package/dist/src/mcp-tools/config-tools.js +284 -190
  217. package/dist/src/mcp-tools/config-tools.js.map +1 -1
  218. package/dist/src/mcp-tools/coordination-tools.d.ts.map +1 -1
  219. package/dist/src/mcp-tools/coordination-tools.js +600 -349
  220. package/dist/src/mcp-tools/coordination-tools.js.map +1 -1
  221. package/dist/src/mcp-tools/daa-tools.js +367 -289
  222. package/dist/src/mcp-tools/daa-tools.js.map +1 -1
  223. package/dist/src/mcp-tools/embeddings-tools.js +693 -582
  224. package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
  225. package/dist/src/mcp-tools/github-tools.js +312 -261
  226. package/dist/src/mcp-tools/github-tools.js.map +1 -1
  227. package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -1
  228. package/dist/src/mcp-tools/hive-mind-tools.js +718 -423
  229. package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
  230. package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
  231. package/dist/src/mcp-tools/hooks-tools.js +2726 -1978
  232. package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
  233. package/dist/src/mcp-tools/index.d.ts +2 -0
  234. package/dist/src/mcp-tools/index.d.ts.map +1 -1
  235. package/dist/src/mcp-tools/index.js +2 -0
  236. package/dist/src/mcp-tools/index.js.map +1 -1
  237. package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
  238. package/dist/src/mcp-tools/memory-tools.js +514 -329
  239. package/dist/src/mcp-tools/memory-tools.js.map +1 -1
  240. package/dist/src/mcp-tools/neural-tools.d.ts.map +1 -1
  241. package/dist/src/mcp-tools/neural-tools.js +428 -326
  242. package/dist/src/mcp-tools/neural-tools.js.map +1 -1
  243. package/dist/src/mcp-tools/performance-tools.js +480 -420
  244. package/dist/src/mcp-tools/performance-tools.js.map +1 -1
  245. package/dist/src/mcp-tools/progress-tools.js +278 -204
  246. package/dist/src/mcp-tools/progress-tools.js.map +1 -1
  247. package/dist/src/mcp-tools/ruvllm-tools.d.ts +9 -0
  248. package/dist/src/mcp-tools/ruvllm-tools.d.ts.map +1 -0
  249. package/dist/src/mcp-tools/ruvllm-tools.js +399 -0
  250. package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -0
  251. package/dist/src/mcp-tools/security-tools.js +429 -297
  252. package/dist/src/mcp-tools/security-tools.js.map +1 -1
  253. package/dist/src/mcp-tools/session-tools.js +234 -185
  254. package/dist/src/mcp-tools/session-tools.js.map +1 -1
  255. package/dist/src/mcp-tools/swarm-tools.d.ts +2 -1
  256. package/dist/src/mcp-tools/swarm-tools.d.ts.map +1 -1
  257. package/dist/src/mcp-tools/swarm-tools.js +303 -64
  258. package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
  259. package/dist/src/mcp-tools/system-tools.d.ts.map +1 -1
  260. package/dist/src/mcp-tools/system-tools.js +352 -200
  261. package/dist/src/mcp-tools/system-tools.js.map +1 -1
  262. package/dist/src/mcp-tools/task-tools.d.ts.map +1 -1
  263. package/dist/src/mcp-tools/task-tools.js +357 -189
  264. package/dist/src/mcp-tools/task-tools.js.map +1 -1
  265. package/dist/src/mcp-tools/terminal-tools.js +196 -148
  266. package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
  267. package/dist/src/mcp-tools/transfer-tools.js +333 -186
  268. package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
  269. package/dist/src/mcp-tools/wasm-agent-tools.d.ts +9 -0
  270. package/dist/src/mcp-tools/wasm-agent-tools.d.ts.map +1 -0
  271. package/dist/src/mcp-tools/wasm-agent-tools.js +377 -0
  272. package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -0
  273. package/dist/src/mcp-tools/workflow-tools.d.ts.map +1 -1
  274. package/dist/src/mcp-tools/workflow-tools.js +471 -335
  275. package/dist/src/mcp-tools/workflow-tools.js.map +1 -1
  276. package/dist/src/memory/ewc-consolidation.js +345 -173
  277. package/dist/src/memory/ewc-consolidation.js.map +1 -1
  278. package/dist/src/memory/intelligence.js +841 -359
  279. package/dist/src/memory/intelligence.js.map +1 -1
  280. package/dist/src/memory/memory-bridge.js +1964 -0
  281. package/dist/src/memory/memory-bridge.js.map +1 -0
  282. package/dist/src/memory/memory-initializer.js +1895 -1602
  283. package/dist/src/memory/memory-initializer.js.map +1 -1
  284. package/dist/src/memory/sona-optimizer.js +329 -199
  285. package/dist/src/memory/sona-optimizer.js.map +1 -1
  286. package/dist/src/output.d.ts +2 -2
  287. package/dist/src/output.d.ts.map +1 -1
  288. package/dist/src/output.js +273 -242
  289. package/dist/src/output.js.map +1 -1
  290. package/dist/src/parser.js +217 -124
  291. package/dist/src/parser.js.map +1 -1
  292. package/dist/src/plugins/manager.js +531 -278
  293. package/dist/src/plugins/manager.js.map +1 -1
  294. package/dist/src/plugins/store/discovery.js +362 -275
  295. package/dist/src/plugins/store/discovery.js.map +1 -1
  296. package/dist/src/plugins/store/index.js +105 -48
  297. package/dist/src/plugins/store/index.js.map +1 -1
  298. package/dist/src/plugins/store/search.js +107 -69
  299. package/dist/src/plugins/store/search.js.map +1 -1
  300. package/dist/src/plugins/tests/demo-plugin-store.js +160 -113
  301. package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -1
  302. package/dist/src/plugins/tests/standalone-test.js +223 -172
  303. package/dist/src/plugins/tests/standalone-test.js.map +1 -1
  304. package/dist/src/plugins/tests/test-plugin-store.js +228 -190
  305. package/dist/src/plugins/tests/test-plugin-store.js.map +1 -1
  306. package/dist/src/production/circuit-breaker.js +126 -62
  307. package/dist/src/production/circuit-breaker.js.map +1 -1
  308. package/dist/src/production/error-handler.js +156 -86
  309. package/dist/src/production/error-handler.js.map +1 -1
  310. package/dist/src/production/monitoring.js +220 -139
  311. package/dist/src/production/monitoring.js.map +1 -1
  312. package/dist/src/production/rate-limiter.js +93 -74
  313. package/dist/src/production/rate-limiter.js.map +1 -1
  314. package/dist/src/production/retry.js +167 -75
  315. package/dist/src/production/retry.js.map +1 -1
  316. package/dist/src/prompt.js +560 -436
  317. package/dist/src/prompt.js.map +1 -1
  318. package/dist/src/runtime/headless.js +289 -200
  319. package/dist/src/runtime/headless.js.map +1 -1
  320. package/dist/src/ruvector/agent-wasm.js +511 -0
  321. package/dist/src/ruvector/agent-wasm.js.map +1 -0
  322. package/dist/src/ruvector/ast-analyzer.js +232 -145
  323. package/dist/src/ruvector/ast-analyzer.js.map +1 -1
  324. package/dist/src/ruvector/coverage-router.js +419 -287
  325. package/dist/src/ruvector/coverage-router.js.map +1 -1
  326. package/dist/src/ruvector/coverage-tools.js +101 -56
  327. package/dist/src/ruvector/coverage-tools.js.map +1 -1
  328. package/dist/src/ruvector/diff-classifier.js +451 -324
  329. package/dist/src/ruvector/diff-classifier.js.map +1 -1
  330. package/dist/src/ruvector/enhanced-model-router.js +337 -251
  331. package/dist/src/ruvector/enhanced-model-router.js.map +1 -1
  332. package/dist/src/ruvector/flash-attention.js +254 -223
  333. package/dist/src/ruvector/flash-attention.js.map +1 -1
  334. package/dist/src/ruvector/graph-analyzer.js +680 -486
  335. package/dist/src/ruvector/graph-analyzer.js.map +1 -1
  336. package/dist/src/ruvector/index.js +113 -27
  337. package/dist/src/ruvector/index.js.map +1 -1
  338. package/dist/src/ruvector/lora-adapter.js +248 -155
  339. package/dist/src/ruvector/lora-adapter.js.map +1 -1
  340. package/dist/src/ruvector/model-router.js +248 -175
  341. package/dist/src/ruvector/model-router.js.map +1 -1
  342. package/dist/src/ruvector/moe-router.js +286 -228
  343. package/dist/src/ruvector/moe-router.js.map +1 -1
  344. package/dist/src/ruvector/q-learning-router.js +338 -257
  345. package/dist/src/ruvector/q-learning-router.js.map +1 -1
  346. package/dist/src/ruvector/ruvllm-wasm.js +527 -0
  347. package/dist/src/ruvector/ruvllm-wasm.js.map +1 -0
  348. package/dist/src/ruvector/semantic-router.js +67 -60
  349. package/dist/src/ruvector/semantic-router.js.map +1 -1
  350. package/dist/src/ruvector/vector-db.js +205 -119
  351. package/dist/src/ruvector/vector-db.js.map +1 -1
  352. package/dist/src/services/agentic-flow-bridge.js +168 -0
  353. package/dist/src/services/agentic-flow-bridge.js.map +1 -0
  354. package/dist/src/services/claim-service.js +940 -615
  355. package/dist/src/services/claim-service.js.map +1 -1
  356. package/dist/src/services/container-worker-pool.js +669 -399
  357. package/dist/src/services/container-worker-pool.js.map +1 -1
  358. package/dist/src/services/headless-worker-executor.js +467 -441
  359. package/dist/src/services/headless-worker-executor.js.map +1 -1
  360. package/dist/src/services/index.d.ts +5 -5
  361. package/dist/src/services/index.d.ts.map +1 -1
  362. package/dist/src/services/index.js +4 -4
  363. package/dist/src/services/index.js.map +1 -1
  364. package/dist/src/services/registry-api.js +201 -93
  365. package/dist/src/services/registry-api.js.map +1 -1
  366. package/dist/src/services/ruvector-training.js +414 -144
  367. package/dist/src/services/ruvector-training.js.map +1 -1
  368. package/dist/src/services/worker-daemon.js +928 -531
  369. package/dist/src/services/worker-daemon.js.map +1 -1
  370. package/dist/src/services/worker-queue.js +550 -331
  371. package/dist/src/services/worker-queue.js.map +1 -1
  372. package/dist/src/suggest.js +55 -45
  373. package/dist/src/suggest.js.map +1 -1
  374. package/dist/src/transfer/anonymization/index.js +37 -29
  375. package/dist/src/transfer/anonymization/index.js.map +1 -1
  376. package/dist/src/transfer/deploy-seraphine.d.ts +1 -1
  377. package/dist/src/transfer/deploy-seraphine.js +156 -129
  378. package/dist/src/transfer/deploy-seraphine.js.map +1 -1
  379. package/dist/src/transfer/export.js +142 -84
  380. package/dist/src/transfer/export.js.map +1 -1
  381. package/dist/src/transfer/index.d.ts +1 -1
  382. package/dist/src/transfer/index.d.ts.map +1 -1
  383. package/dist/src/transfer/index.js +2 -0
  384. package/dist/src/transfer/index.js.map +1 -1
  385. package/dist/src/transfer/ipfs/client.js +337 -179
  386. package/dist/src/transfer/ipfs/client.js.map +1 -1
  387. package/dist/src/transfer/ipfs/upload.js +434 -290
  388. package/dist/src/transfer/ipfs/upload.js.map +1 -1
  389. package/dist/src/transfer/models/seraphine.js +58 -58
  390. package/dist/src/transfer/models/seraphine.js.map +1 -1
  391. package/dist/src/transfer/serialization/cfp.js +37 -33
  392. package/dist/src/transfer/serialization/cfp.js.map +1 -1
  393. package/dist/src/transfer/storage/gcs.js +248 -139
  394. package/dist/src/transfer/storage/gcs.js.map +1 -1
  395. package/dist/src/transfer/store/discovery.js +353 -243
  396. package/dist/src/transfer/store/discovery.js.map +1 -1
  397. package/dist/src/transfer/store/download.js +365 -243
  398. package/dist/src/transfer/store/download.js.map +1 -1
  399. package/dist/src/transfer/store/index.js +130 -63
  400. package/dist/src/transfer/store/index.js.map +1 -1
  401. package/dist/src/transfer/store/publish.js +258 -184
  402. package/dist/src/transfer/store/publish.js.map +1 -1
  403. package/dist/src/transfer/store/registry.js +73 -51
  404. package/dist/src/transfer/store/registry.js.map +1 -1
  405. package/dist/src/transfer/store/search.js +96 -64
  406. package/dist/src/transfer/store/search.js.map +1 -1
  407. package/dist/src/transfer/store/tests/standalone-test.js +231 -174
  408. package/dist/src/transfer/store/tests/standalone-test.js.map +1 -1
  409. package/dist/src/transfer/test-seraphine.js +130 -95
  410. package/dist/src/transfer/test-seraphine.js.map +1 -1
  411. package/dist/src/transfer/tests/test-store.js +239 -194
  412. package/dist/src/transfer/tests/test-store.js.map +1 -1
  413. package/dist/src/types.js +56 -27
  414. package/dist/src/types.js.map +1 -1
  415. package/dist/src/update/checker.js +183 -106
  416. package/dist/src/update/checker.js.map +1 -1
  417. package/dist/src/update/executor.js +198 -135
  418. package/dist/src/update/executor.js.map +1 -1
  419. package/dist/src/update/index.js +85 -38
  420. package/dist/src/update/index.js.map +1 -1
  421. package/dist/src/update/rate-limiter.js +31 -19
  422. package/dist/src/update/rate-limiter.js.map +1 -1
  423. package/dist/src/update/validator.js +64 -38
  424. package/dist/src/update/validator.js.map +1 -1
  425. package/dist/tsconfig.tsbuildinfo +1 -1
  426. package/package.json +13 -10
  427. package/.claude/agents/custom/accessibility-auditor.yaml +0 -56
  428. package/.claude/agents/custom/design-architect.yaml +0 -48
  429. package/.claude/agents/custom/ui-developer.yaml +0 -46
  430. package/.claude/agents/custom/ux-researcher.yaml +0 -60
  431. package/dist/src/benchmarks/pretrain/index.d.ts +0 -58
  432. package/dist/src/benchmarks/pretrain/index.d.ts.map +0 -1
  433. package/dist/src/commands/index.d.ts +0 -108
  434. package/dist/src/commands/index.d.ts.map +0 -1
  435. package/dist/src/config-adapter.d.ts +0 -15
  436. package/dist/src/config-adapter.d.ts.map +0 -1
  437. package/dist/src/index.d.ts +0 -76
  438. package/dist/src/index.d.ts.map +0 -1
  439. package/dist/src/infrastructure/in-memory-repositories.d.ts +0 -68
  440. package/dist/src/infrastructure/in-memory-repositories.d.ts.map +0 -1
  441. package/dist/src/init/claudemd-generator.d.ts +0 -25
  442. package/dist/src/init/claudemd-generator.d.ts.map +0 -1
  443. package/dist/src/init/executor.d.ts +0 -41
  444. package/dist/src/init/executor.d.ts.map +0 -1
  445. package/dist/src/init/helpers-generator.d.ts +0 -60
  446. package/dist/src/init/helpers-generator.d.ts.map +0 -1
  447. package/dist/src/mcp-client.d.ts +0 -92
  448. package/dist/src/mcp-client.d.ts.map +0 -1
  449. package/dist/src/mcp-server.d.ts +0 -161
  450. package/dist/src/mcp-server.d.ts.map +0 -1
  451. package/dist/src/mcp-tools/auto-install.d.ts +0 -83
  452. package/dist/src/mcp-tools/auto-install.d.ts.map +0 -1
  453. package/dist/src/mcp-tools/types.d.ts +0 -31
  454. package/dist/src/mcp-tools/types.d.ts.map +0 -1
  455. package/dist/src/memory/ewc-consolidation.d.ts +0 -271
  456. package/dist/src/memory/ewc-consolidation.d.ts.map +0 -1
  457. package/dist/src/memory/intelligence.d.ts +0 -285
  458. package/dist/src/memory/intelligence.d.ts.map +0 -1
  459. package/dist/src/memory/memory-initializer.d.ts +0 -396
  460. package/dist/src/memory/memory-initializer.d.ts.map +0 -1
  461. package/dist/src/memory/sona-optimizer.d.ts +0 -227
  462. package/dist/src/memory/sona-optimizer.d.ts.map +0 -1
  463. package/dist/src/parser.d.ts +0 -41
  464. package/dist/src/parser.d.ts.map +0 -1
  465. package/dist/src/plugins/manager.d.ts +0 -133
  466. package/dist/src/plugins/manager.d.ts.map +0 -1
  467. package/dist/src/plugins/store/discovery.d.ts +0 -88
  468. package/dist/src/plugins/store/discovery.d.ts.map +0 -1
  469. package/dist/src/plugins/store/index.d.ts +0 -76
  470. package/dist/src/plugins/store/index.d.ts.map +0 -1
  471. package/dist/src/plugins/store/search.d.ts +0 -46
  472. package/dist/src/plugins/store/search.d.ts.map +0 -1
  473. package/dist/src/plugins/store/types.d.ts +0 -274
  474. package/dist/src/plugins/store/types.d.ts.map +0 -1
  475. package/dist/src/production/circuit-breaker.d.ts +0 -101
  476. package/dist/src/production/circuit-breaker.d.ts.map +0 -1
  477. package/dist/src/production/error-handler.d.ts +0 -92
  478. package/dist/src/production/error-handler.d.ts.map +0 -1
  479. package/dist/src/production/monitoring.d.ts +0 -161
  480. package/dist/src/production/monitoring.d.ts.map +0 -1
  481. package/dist/src/production/rate-limiter.d.ts +0 -80
  482. package/dist/src/production/rate-limiter.d.ts.map +0 -1
  483. package/dist/src/production/retry.d.ts +0 -48
  484. package/dist/src/production/retry.d.ts.map +0 -1
  485. package/dist/src/prompt.d.ts +0 -44
  486. package/dist/src/prompt.d.ts.map +0 -1
  487. package/dist/src/runtime/headless.d.ts +0 -60
  488. package/dist/src/runtime/headless.d.ts.map +0 -1
  489. package/dist/src/ruvector/ast-analyzer.d.ts +0 -67
  490. package/dist/src/ruvector/ast-analyzer.d.ts.map +0 -1
  491. package/dist/src/ruvector/coverage-router.d.ts +0 -160
  492. package/dist/src/ruvector/coverage-router.d.ts.map +0 -1
  493. package/dist/src/ruvector/diff-classifier.d.ts +0 -175
  494. package/dist/src/ruvector/diff-classifier.d.ts.map +0 -1
  495. package/dist/src/ruvector/enhanced-model-router.d.ts +0 -146
  496. package/dist/src/ruvector/enhanced-model-router.d.ts.map +0 -1
  497. package/dist/src/ruvector/flash-attention.d.ts +0 -195
  498. package/dist/src/ruvector/flash-attention.d.ts.map +0 -1
  499. package/dist/src/ruvector/graph-analyzer.d.ts +0 -187
  500. package/dist/src/ruvector/graph-analyzer.d.ts.map +0 -1
  501. package/dist/src/ruvector/index.d.ts +0 -34
  502. package/dist/src/ruvector/index.d.ts.map +0 -1
  503. package/dist/src/ruvector/lora-adapter.d.ts +0 -218
  504. package/dist/src/ruvector/lora-adapter.d.ts.map +0 -1
  505. package/dist/src/ruvector/model-router.d.ts +0 -220
  506. package/dist/src/ruvector/model-router.d.ts.map +0 -1
  507. package/dist/src/ruvector/moe-router.d.ts +0 -206
  508. package/dist/src/ruvector/moe-router.d.ts.map +0 -1
  509. package/dist/src/ruvector/q-learning-router.d.ts +0 -211
  510. package/dist/src/ruvector/q-learning-router.d.ts.map +0 -1
  511. package/dist/src/ruvector/semantic-router.d.ts +0 -77
  512. package/dist/src/ruvector/semantic-router.d.ts.map +0 -1
  513. package/dist/src/ruvector/vector-db.d.ts +0 -69
  514. package/dist/src/ruvector/vector-db.d.ts.map +0 -1
  515. package/dist/src/services/claim-service.d.ts +0 -204
  516. package/dist/src/services/claim-service.d.ts.map +0 -1
  517. package/dist/src/services/container-worker-pool.d.ts +0 -197
  518. package/dist/src/services/container-worker-pool.d.ts.map +0 -1
  519. package/dist/src/services/headless-worker-executor.d.ts +0 -304
  520. package/dist/src/services/headless-worker-executor.d.ts.map +0 -1
  521. package/dist/src/services/registry-api.d.ts +0 -58
  522. package/dist/src/services/registry-api.d.ts.map +0 -1
  523. package/dist/src/services/ruvector-training.d.ts +0 -213
  524. package/dist/src/services/ruvector-training.d.ts.map +0 -1
  525. package/dist/src/services/worker-daemon.d.ts +0 -203
  526. package/dist/src/services/worker-daemon.d.ts.map +0 -1
  527. package/dist/src/services/worker-queue.d.ts +0 -194
  528. package/dist/src/services/worker-queue.d.ts.map +0 -1
  529. package/dist/src/suggest.d.ts +0 -53
  530. package/dist/src/suggest.d.ts.map +0 -1
  531. package/dist/src/transfer/export.d.ts +0 -25
  532. package/dist/src/transfer/export.d.ts.map +0 -1
  533. package/dist/src/transfer/ipfs/client.d.ts +0 -109
  534. package/dist/src/transfer/ipfs/client.d.ts.map +0 -1
  535. package/dist/src/transfer/ipfs/upload.d.ts +0 -95
  536. package/dist/src/transfer/ipfs/upload.d.ts.map +0 -1
  537. package/dist/src/transfer/models/seraphine.d.ts +0 -72
  538. package/dist/src/transfer/models/seraphine.d.ts.map +0 -1
  539. package/dist/src/transfer/serialization/cfp.d.ts +0 -49
  540. package/dist/src/transfer/serialization/cfp.d.ts.map +0 -1
  541. package/dist/src/transfer/storage/gcs.d.ts +0 -82
  542. package/dist/src/transfer/storage/gcs.d.ts.map +0 -1
  543. package/dist/src/transfer/store/discovery.d.ts +0 -84
  544. package/dist/src/transfer/store/discovery.d.ts.map +0 -1
  545. package/dist/src/transfer/store/download.d.ts +0 -70
  546. package/dist/src/transfer/store/download.d.ts.map +0 -1
  547. package/dist/src/transfer/store/index.d.ts +0 -84
  548. package/dist/src/transfer/store/index.d.ts.map +0 -1
  549. package/dist/src/transfer/store/publish.d.ts +0 -76
  550. package/dist/src/transfer/store/publish.d.ts.map +0 -1
  551. package/dist/src/transfer/store/search.d.ts +0 -54
  552. package/dist/src/transfer/store/search.d.ts.map +0 -1
  553. package/dist/src/transfer/types.d.ts +0 -245
  554. package/dist/src/transfer/types.d.ts.map +0 -1
  555. package/dist/src/types.d.ts +0 -198
  556. package/dist/src/types.d.ts.map +0 -1
  557. package/dist/src/update/checker.d.ts +0 -34
  558. package/dist/src/update/checker.d.ts.map +0 -1
  559. package/dist/src/update/executor.d.ts +0 -32
  560. package/dist/src/update/executor.d.ts.map +0 -1
  561. package/dist/src/update/index.d.ts +0 -33
  562. package/dist/src/update/index.d.ts.map +0 -1
  563. package/dist/src/update/rate-limiter.d.ts +0 -20
  564. package/dist/src/update/rate-limiter.d.ts.map +0 -1
  565. package/dist/src/update/validator.d.ts +0 -17
  566. package/dist/src/update/validator.d.ts.map +0 -1
@@ -16,6 +16,68 @@
16
16
  * @module @claude-flow/cli/mcp-server
17
17
  * @version 3.0.0
18
18
  */
19
+ var __extends = (this && this.__extends) || (function () {
20
+ var extendStatics = function (d, b) {
21
+ extendStatics = Object.setPrototypeOf ||
22
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
24
+ return extendStatics(d, b);
25
+ };
26
+ return function (d, b) {
27
+ if (typeof b !== "function" && b !== null)
28
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
29
+ extendStatics(d, b);
30
+ function __() { this.constructor = d; }
31
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32
+ };
33
+ })();
34
+ var __assign = (this && this.__assign) || function () {
35
+ __assign = Object.assign || function(t) {
36
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
37
+ s = arguments[i];
38
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
39
+ t[p] = s[p];
40
+ }
41
+ return t;
42
+ };
43
+ return __assign.apply(this, arguments);
44
+ };
45
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
46
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
47
+ return new (P || (P = Promise))(function (resolve, reject) {
48
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
49
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
50
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
51
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
52
+ });
53
+ };
54
+ var __generator = (this && this.__generator) || function (thisArg, body) {
55
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
56
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
57
+ function verb(n) { return function (v) { return step([n, v]); }; }
58
+ function step(op) {
59
+ if (f) throw new TypeError("Generator is already executing.");
60
+ while (_) try {
61
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
62
+ if (y = 0, t) op = [op[0] & 2, t.value];
63
+ switch (op[0]) {
64
+ case 0: case 1: t = op; break;
65
+ case 4: _.label++; return { value: op[1], done: false };
66
+ case 5: _.label++; y = op[1]; op = [0]; continue;
67
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
68
+ default:
69
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
70
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
71
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
72
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
73
+ if (t[2]) _.ops.pop();
74
+ _.trys.pop(); continue;
75
+ }
76
+ op = body.call(thisArg, _);
77
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
78
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
79
+ }
80
+ };
19
81
  import { EventEmitter } from 'events';
20
82
  import { randomUUID } from 'crypto';
21
83
  import * as path from 'path';
@@ -24,12 +86,12 @@ import * as os from 'os';
24
86
  import { fileURLToPath } from 'url';
25
87
  import { dirname } from 'path';
26
88
  // ESM-compatible __dirname
27
- const __filename = fileURLToPath(import.meta.url);
28
- const __dirname = dirname(__filename);
89
+ var __filename = fileURLToPath(import.meta.url);
90
+ var __dirname = dirname(__filename);
29
91
  /**
30
92
  * Default configuration
31
93
  */
32
- const DEFAULT_OPTIONS = {
94
+ var DEFAULT_OPTIONS = {
33
95
  transport: 'stdio',
34
96
  host: 'localhost',
35
97
  port: 3000,
@@ -37,514 +99,736 @@ const DEFAULT_OPTIONS = {
37
99
  logFile: path.join(os.tmpdir(), 'claude-flow-mcp.log'),
38
100
  tools: 'all',
39
101
  daemonize: false,
40
- timeout: 30000,
102
+ timeout: 30000
41
103
  };
42
104
  /**
43
105
  * MCP Server Manager
44
106
  *
45
107
  * Manages the lifecycle of the MCP server process
46
108
  */
47
- export class MCPServerManager extends EventEmitter {
48
- options;
49
- process;
50
- server;
51
- startTime;
52
- healthCheckInterval;
53
- constructor(options = {}) {
54
- super();
55
- this.options = { ...DEFAULT_OPTIONS, ...options };
109
+ var MCPServerManager = /** @class */ (function (_super) {
110
+ __extends(MCPServerManager, _super);
111
+ function MCPServerManager(options) {
112
+ if (options === void 0) { options = {}; }
113
+ var _this = _super.call(this) || this;
114
+ _this.options = __assign(__assign({}, DEFAULT_OPTIONS), options);
115
+ return _this;
56
116
  }
57
117
  /**
58
118
  * Start the MCP server
59
119
  */
60
- async start() {
61
- // Check if already running
62
- const status = await this.getStatus();
63
- if (status.running) {
64
- throw new Error(`MCP Server already running (PID: ${status.pid})`);
65
- }
66
- const startTime = performance.now();
67
- this.startTime = new Date();
68
- this.emit('starting', { options: this.options });
69
- try {
70
- if (this.options.transport === 'stdio') {
71
- // For stdio transport, spawn the server process
72
- await this.startStdioServer();
73
- }
74
- else {
75
- // For HTTP/WebSocket, start in-process server
76
- await this.startHttpServer();
77
- }
78
- const duration = performance.now() - startTime;
79
- // Write PID file
80
- await this.writePidFile();
81
- // Start health check monitoring
82
- this.startHealthMonitoring();
83
- const finalStatus = await this.getStatus();
84
- this.emit('started', {
85
- ...finalStatus,
86
- startupTime: duration,
120
+ MCPServerManager.prototype.start = function () {
121
+ return __awaiter(this, void 0, Promise, function () {
122
+ var status, startTime, duration, finalStatus, error_1;
123
+ return __generator(this, function (_a) {
124
+ switch (_a.label) {
125
+ case 0: return [4 /*yield*/, this.getStatus()];
126
+ case 1:
127
+ status = _a.sent();
128
+ if (status.running) {
129
+ throw new Error("MCP Server already running (PID: " + status.pid + ")");
130
+ }
131
+ startTime = performance.now();
132
+ this.startTime = new Date();
133
+ this.emit('starting', { options: this.options });
134
+ _a.label = 2;
135
+ case 2:
136
+ _a.trys.push([2, 9, , 10]);
137
+ if (!(this.options.transport === 'stdio')) return [3 /*break*/, 4];
138
+ // For stdio transport, spawn the server process
139
+ return [4 /*yield*/, this.startStdioServer()];
140
+ case 3:
141
+ // For stdio transport, spawn the server process
142
+ _a.sent();
143
+ return [3 /*break*/, 6];
144
+ case 4:
145
+ // For HTTP/WebSocket, start in-process server
146
+ return [4 /*yield*/, this.startHttpServer()];
147
+ case 5:
148
+ // For HTTP/WebSocket, start in-process server
149
+ _a.sent();
150
+ _a.label = 6;
151
+ case 6:
152
+ duration = performance.now() - startTime;
153
+ // Write PID file
154
+ return [4 /*yield*/, this.writePidFile()];
155
+ case 7:
156
+ // Write PID file
157
+ _a.sent();
158
+ // Start health check monitoring
159
+ this.startHealthMonitoring();
160
+ return [4 /*yield*/, this.getStatus()];
161
+ case 8:
162
+ finalStatus = _a.sent();
163
+ this.emit('started', __assign(__assign({}, finalStatus), { startupTime: duration }));
164
+ return [2 /*return*/, finalStatus];
165
+ case 9:
166
+ error_1 = _a.sent();
167
+ this.emit('error', error_1);
168
+ throw error_1;
169
+ case 10: return [2 /*return*/];
170
+ }
87
171
  });
88
- return finalStatus;
89
- }
90
- catch (error) {
91
- this.emit('error', error);
92
- throw error;
93
- }
94
- }
172
+ });
173
+ };
95
174
  /**
96
175
  * Stop the MCP server
97
176
  */
98
- async stop(force = false) {
99
- const status = await this.getStatus();
100
- if (!status.running) {
101
- return;
102
- }
103
- this.emit('stopping', { force });
104
- try {
105
- // Stop health monitoring
106
- if (this.healthCheckInterval) {
107
- clearInterval(this.healthCheckInterval);
108
- this.healthCheckInterval = undefined;
109
- }
110
- if (this.process) {
111
- // Graceful shutdown
112
- if (!force) {
113
- this.process.kill('SIGTERM');
114
- await this.waitForExit(5000);
115
- }
116
- // Force kill if still running
117
- if (this.process && !this.process.killed) {
118
- this.process.kill('SIGKILL');
177
+ MCPServerManager.prototype.stop = function (force) {
178
+ if (force === void 0) { force = false; }
179
+ return __awaiter(this, void 0, Promise, function () {
180
+ var status, error_2;
181
+ var _this = this;
182
+ return __generator(this, function (_a) {
183
+ switch (_a.label) {
184
+ case 0: return [4 /*yield*/, this.getStatus()];
185
+ case 1:
186
+ status = _a.sent();
187
+ if (!status.running) {
188
+ return [2 /*return*/];
189
+ }
190
+ this.emit('stopping', { force: force });
191
+ _a.label = 2;
192
+ case 2:
193
+ _a.trys.push([2, 9, , 10]);
194
+ // Stop health monitoring
195
+ if (this.healthCheckInterval) {
196
+ clearInterval(this.healthCheckInterval);
197
+ this.healthCheckInterval = undefined;
198
+ }
199
+ if (!this.process) return [3 /*break*/, 5];
200
+ if (!!force) return [3 /*break*/, 4];
201
+ this.process.kill('SIGTERM');
202
+ return [4 /*yield*/, this.waitForExit(5000)];
203
+ case 3:
204
+ _a.sent();
205
+ _a.label = 4;
206
+ case 4:
207
+ // Force kill if still running
208
+ if (this.process && !this.process.killed) {
209
+ this.process.kill('SIGKILL');
210
+ }
211
+ this.process = undefined;
212
+ _a.label = 5;
213
+ case 5:
214
+ if (!this.server) return [3 /*break*/, 7];
215
+ return [4 /*yield*/, new Promise(function (resolve) {
216
+ _this.server.close(function () { return resolve(); });
217
+ })];
218
+ case 6:
219
+ _a.sent();
220
+ this.server = undefined;
221
+ _a.label = 7;
222
+ case 7:
223
+ // Remove PID file
224
+ return [4 /*yield*/, this.removePidFile()];
225
+ case 8:
226
+ // Remove PID file
227
+ _a.sent();
228
+ this.startTime = undefined;
229
+ this.emit('stopped');
230
+ return [3 /*break*/, 10];
231
+ case 9:
232
+ error_2 = _a.sent();
233
+ this.emit('error', error_2);
234
+ throw error_2;
235
+ case 10: return [2 /*return*/];
119
236
  }
120
- this.process = undefined;
121
- }
122
- if (this.server) {
123
- await new Promise((resolve) => {
124
- this.server.close(() => resolve());
125
- });
126
- this.server = undefined;
127
- }
128
- // Remove PID file
129
- await this.removePidFile();
130
- this.startTime = undefined;
131
- this.emit('stopped');
132
- }
133
- catch (error) {
134
- this.emit('error', error);
135
- throw error;
136
- }
137
- }
237
+ });
238
+ });
239
+ };
138
240
  /**
139
241
  * Get server status
140
242
  */
141
- async getStatus() {
142
- // Check PID file
143
- const pid = await this.readPidFile();
144
- if (!pid) {
145
- return { running: false };
146
- }
147
- // Check if process is running
148
- const isRunning = this.isProcessRunning(pid);
149
- if (!isRunning) {
150
- // Clean up stale PID file
151
- await this.removePidFile();
152
- return { running: false };
153
- }
154
- // Build status
155
- const status = {
156
- running: true,
157
- pid,
158
- transport: this.options.transport,
159
- host: this.options.host,
160
- port: this.options.port,
161
- startedAt: this.startTime?.toISOString(),
162
- uptime: this.startTime
163
- ? Math.floor((Date.now() - this.startTime.getTime()) / 1000)
164
- : undefined,
165
- };
166
- // Get health status for HTTP transport
167
- if (this.options.transport !== 'stdio') {
168
- status.health = await this.checkHealth();
169
- }
170
- return status;
171
- }
243
+ MCPServerManager.prototype.getStatus = function () {
244
+ var _a, _b;
245
+ return __awaiter(this, void 0, Promise, function () {
246
+ var pid, isStdio, envTransport, isRunning, status, _c;
247
+ return __generator(this, function (_d) {
248
+ switch (_d.label) {
249
+ case 0: return [4 /*yield*/, this.readPidFile()];
250
+ case 1:
251
+ pid = _d.sent();
252
+ if (!pid) {
253
+ isStdio = !process.stdin.isTTY;
254
+ envTransport = process.env.CLAUDE_FLOW_MCP_TRANSPORT;
255
+ if (isStdio || envTransport === 'stdio' || this.options.transport === 'stdio') {
256
+ return [2 /*return*/, {
257
+ running: true,
258
+ pid: process.pid,
259
+ transport: 'stdio',
260
+ startedAt: (_a = this.startTime) === null || _a === void 0 ? void 0 : _a.toISOString(),
261
+ uptime: this.startTime
262
+ ? Math.floor((Date.now() - this.startTime.getTime()) / 1000)
263
+ : undefined
264
+ }];
265
+ }
266
+ return [2 /*return*/, { running: false }];
267
+ }
268
+ isRunning = this.isProcessRunning(pid);
269
+ if (!!isRunning) return [3 /*break*/, 3];
270
+ // Clean up stale PID file
271
+ return [4 /*yield*/, this.removePidFile()];
272
+ case 2:
273
+ // Clean up stale PID file
274
+ _d.sent();
275
+ return [2 /*return*/, { running: false }];
276
+ case 3:
277
+ status = {
278
+ running: true,
279
+ pid: pid,
280
+ transport: this.options.transport,
281
+ host: this.options.host,
282
+ port: this.options.port,
283
+ startedAt: (_b = this.startTime) === null || _b === void 0 ? void 0 : _b.toISOString(),
284
+ uptime: this.startTime
285
+ ? Math.floor((Date.now() - this.startTime.getTime()) / 1000)
286
+ : undefined
287
+ };
288
+ if (!(this.options.transport !== 'stdio')) return [3 /*break*/, 5];
289
+ _c = status;
290
+ return [4 /*yield*/, this.checkHealth()];
291
+ case 4:
292
+ _c.health = _d.sent();
293
+ _d.label = 5;
294
+ case 5: return [2 /*return*/, status];
295
+ }
296
+ });
297
+ });
298
+ };
172
299
  /**
173
300
  * Check server health
174
301
  */
175
- async checkHealth() {
176
- if (this.options.transport === 'stdio') {
177
- // For stdio, check if process is running
178
- const pid = await this.readPidFile();
179
- if (pid === null) {
180
- return { healthy: false, error: 'No PID file found' };
181
- }
182
- if (!this.isProcessRunning(pid)) {
183
- // Clean up stale PID file
184
- await this.removePidFile();
185
- return { healthy: false, error: 'Process not running (cleaned up stale PID)' };
186
- }
187
- return { healthy: true };
188
- }
189
- // For HTTP/WebSocket, make health check request
190
- try {
191
- const response = await this.httpRequest(`http://${this.options.host}:${this.options.port}/health`, 'GET', this.options.timeout);
192
- return {
193
- healthy: response.status === 'ok',
194
- metrics: {
195
- connections: response.connections || 0,
196
- },
197
- };
198
- }
199
- catch (error) {
200
- return {
201
- healthy: false,
202
- error: error instanceof Error ? error.message : 'Unknown error',
203
- };
204
- }
205
- }
302
+ MCPServerManager.prototype.checkHealth = function () {
303
+ return __awaiter(this, void 0, Promise, function () {
304
+ var pid, response, error_3;
305
+ return __generator(this, function (_a) {
306
+ switch (_a.label) {
307
+ case 0:
308
+ if (!(this.options.transport === 'stdio')) return [3 /*break*/, 4];
309
+ return [4 /*yield*/, this.readPidFile()];
310
+ case 1:
311
+ pid = _a.sent();
312
+ if (pid === null) {
313
+ return [2 /*return*/, { healthy: false, error: 'No PID file found' }];
314
+ }
315
+ if (!!this.isProcessRunning(pid)) return [3 /*break*/, 3];
316
+ // Clean up stale PID file
317
+ return [4 /*yield*/, this.removePidFile()];
318
+ case 2:
319
+ // Clean up stale PID file
320
+ _a.sent();
321
+ return [2 /*return*/, { healthy: false, error: 'Process not running (cleaned up stale PID)' }];
322
+ case 3: return [2 /*return*/, { healthy: true }];
323
+ case 4:
324
+ _a.trys.push([4, 6, , 7]);
325
+ return [4 /*yield*/, this.httpRequest("http://" + this.options.host + ":" + this.options.port + "/health", 'GET', this.options.timeout)];
326
+ case 5:
327
+ response = _a.sent();
328
+ return [2 /*return*/, {
329
+ healthy: response.status === 'ok',
330
+ metrics: {
331
+ connections: response.connections || 0
332
+ }
333
+ }];
334
+ case 6:
335
+ error_3 = _a.sent();
336
+ return [2 /*return*/, {
337
+ healthy: false,
338
+ error: error_3 instanceof Error ? error_3.message : 'Unknown error'
339
+ }];
340
+ case 7: return [2 /*return*/];
341
+ }
342
+ });
343
+ });
344
+ };
206
345
  /**
207
346
  * Restart the server
208
347
  */
209
- async restart() {
210
- await this.stop();
211
- return await this.start();
212
- }
348
+ MCPServerManager.prototype.restart = function () {
349
+ return __awaiter(this, void 0, Promise, function () {
350
+ return __generator(this, function (_a) {
351
+ switch (_a.label) {
352
+ case 0: return [4 /*yield*/, this.stop()];
353
+ case 1:
354
+ _a.sent();
355
+ return [4 /*yield*/, this.start()];
356
+ case 2: return [2 /*return*/, _a.sent()];
357
+ }
358
+ });
359
+ });
360
+ };
213
361
  /**
214
362
  * Start stdio server in-process
215
363
  * Handles stdin/stdout directly like V2 implementation
216
364
  */
217
- async startStdioServer() {
218
- // Import the tool registry
219
- const { listMCPTools, callMCPTool, hasTool } = await import('./mcp-client.js');
220
- const VERSION = '3.0.0';
221
- const sessionId = `mcp-${Date.now()}-${randomUUID().slice(0, 8)}`;
222
- // Log to stderr to not corrupt stdout
223
- console.error(`[${new Date().toISOString()}] INFO [claude-flow-mcp] (${sessionId}) Starting in stdio mode`);
224
- console.error(JSON.stringify({
225
- arch: process.arch,
226
- mode: 'mcp-stdio',
227
- nodeVersion: process.version,
228
- pid: process.pid,
229
- platform: process.platform,
230
- protocol: 'stdio',
231
- sessionId,
232
- version: VERSION,
233
- }));
234
- // Send server initialization notification
235
- console.log(JSON.stringify({
236
- jsonrpc: '2.0',
237
- method: 'server.initialized',
238
- params: {
239
- serverInfo: {
240
- name: 'kynjalflow',
241
- version: VERSION,
242
- capabilities: {
243
- tools: { listChanged: true },
244
- resources: { subscribe: true, listChanged: true },
245
- },
246
- },
247
- },
248
- }));
249
- // Handle stdin messages
250
- let buffer = '';
251
- process.stdin.on('data', async (chunk) => {
252
- buffer += chunk.toString();
253
- // Process complete JSON messages
254
- let lines = buffer.split('\n');
255
- buffer = lines.pop() || ''; // Keep incomplete line in buffer
256
- for (const line of lines) {
257
- if (line.trim()) {
258
- try {
259
- const message = JSON.parse(line);
260
- const response = await this.handleMCPMessage(message, sessionId);
261
- if (response) {
262
- console.log(JSON.stringify(response));
263
- }
264
- }
265
- catch (error) {
266
- console.error(`[${new Date().toISOString()}] ERROR [claude-flow-mcp] Failed to parse message:`, error instanceof Error ? error.message : String(error));
267
- }
365
+ MCPServerManager.prototype.startStdioServer = function () {
366
+ return __awaiter(this, void 0, Promise, function () {
367
+ var _a, listMCPTools, callMCPTool, hasTool, VERSION, sessionId, MAX_BUFFER_SIZE, buffer;
368
+ var _this = this;
369
+ return __generator(this, function (_b) {
370
+ switch (_b.label) {
371
+ case 0: return [4 /*yield*/, import('./mcp-client.js')];
372
+ case 1:
373
+ _a = _b.sent(), listMCPTools = _a.listMCPTools, callMCPTool = _a.callMCPTool, hasTool = _a.hasTool;
374
+ VERSION = '3.0.0';
375
+ sessionId = "mcp-" + Date.now() + "-" + randomUUID().slice(0, 8);
376
+ // Log to stderr to not corrupt stdout
377
+ console.error("[" + new Date().toISOString() + "] INFO [claude-flow-mcp] (" + sessionId + ") Starting in stdio mode");
378
+ console.error(JSON.stringify({
379
+ arch: process.arch,
380
+ mode: 'mcp-stdio',
381
+ nodeVersion: process.version,
382
+ pid: process.pid,
383
+ platform: process.platform,
384
+ protocol: 'stdio',
385
+ sessionId: sessionId,
386
+ version: VERSION
387
+ }));
388
+ // Send server initialization notification
389
+ console.log(JSON.stringify({
390
+ jsonrpc: '2.0',
391
+ method: 'server.initialized',
392
+ params: {
393
+ serverInfo: {
394
+ name: 'ruflo',
395
+ version: VERSION,
396
+ capabilities: {
397
+ tools: { listChanged: true },
398
+ resources: { subscribe: true, listChanged: true }
399
+ }
400
+ }
401
+ }
402
+ }));
403
+ MAX_BUFFER_SIZE = 10 * 1024 * 1024;
404
+ buffer = '';
405
+ process.stdin.on('data', function (chunk) { return __awaiter(_this, void 0, void 0, function () {
406
+ var lines, _i, lines_1, line, message, response, error_4;
407
+ return __generator(this, function (_a) {
408
+ switch (_a.label) {
409
+ case 0:
410
+ buffer += chunk.toString();
411
+ if (buffer.length > MAX_BUFFER_SIZE) {
412
+ console.error("[" + new Date().toISOString() + "] ERROR [claude-flow-mcp] Buffer exceeded " + MAX_BUFFER_SIZE + " bytes, rejecting");
413
+ buffer = '';
414
+ console.log(JSON.stringify({
415
+ jsonrpc: '2.0',
416
+ error: { code: -32600, message: 'Request too large' }
417
+ }));
418
+ return [2 /*return*/];
419
+ }
420
+ lines = buffer.split('\n');
421
+ buffer = lines.pop() || ''; // Keep incomplete line in buffer
422
+ _i = 0, lines_1 = lines;
423
+ _a.label = 1;
424
+ case 1:
425
+ if (!(_i < lines_1.length)) return [3 /*break*/, 6];
426
+ line = lines_1[_i];
427
+ if (!line.trim()) return [3 /*break*/, 5];
428
+ _a.label = 2;
429
+ case 2:
430
+ _a.trys.push([2, 4, , 5]);
431
+ message = JSON.parse(line);
432
+ return [4 /*yield*/, this.handleMCPMessage(message, sessionId)];
433
+ case 3:
434
+ response = _a.sent();
435
+ if (response) {
436
+ console.log(JSON.stringify(response));
437
+ }
438
+ return [3 /*break*/, 5];
439
+ case 4:
440
+ error_4 = _a.sent();
441
+ console.error("[" + new Date().toISOString() + "] ERROR [claude-flow-mcp] Failed to parse message:", error_4 instanceof Error ? error_4.message : String(error_4));
442
+ return [3 /*break*/, 5];
443
+ case 5:
444
+ _i++;
445
+ return [3 /*break*/, 1];
446
+ case 6: return [2 /*return*/];
447
+ }
448
+ });
449
+ }); });
450
+ process.stdin.on('end', function () {
451
+ console.error("[" + new Date().toISOString() + "] INFO [claude-flow-mcp] (" + sessionId + ") stdin closed, shutting down...");
452
+ process.exit(0);
453
+ });
454
+ // Handle process termination
455
+ process.on('SIGINT', function () {
456
+ console.error("[" + new Date().toISOString() + "] INFO [claude-flow-mcp] (" + sessionId + ") Received SIGINT, shutting down...");
457
+ process.exit(0);
458
+ });
459
+ process.on('SIGTERM', function () {
460
+ console.error("[" + new Date().toISOString() + "] INFO [claude-flow-mcp] (" + sessionId + ") Received SIGTERM, shutting down...");
461
+ process.exit(0);
462
+ });
463
+ // Mark as ready immediately for stdio
464
+ this.emit('ready');
465
+ return [2 /*return*/];
268
466
  }
269
- }
270
- });
271
- process.stdin.on('end', () => {
272
- console.error(`[${new Date().toISOString()}] INFO [claude-flow-mcp] (${sessionId}) stdin closed, shutting down...`);
273
- process.exit(0);
274
- });
275
- // Handle process termination
276
- process.on('SIGINT', () => {
277
- console.error(`[${new Date().toISOString()}] INFO [claude-flow-mcp] (${sessionId}) Received SIGINT, shutting down...`);
278
- process.exit(0);
279
- });
280
- process.on('SIGTERM', () => {
281
- console.error(`[${new Date().toISOString()}] INFO [claude-flow-mcp] (${sessionId}) Received SIGTERM, shutting down...`);
282
- process.exit(0);
467
+ });
283
468
  });
284
- // Mark as ready immediately for stdio
285
- this.emit('ready');
286
- }
469
+ };
287
470
  /**
288
471
  * Handle incoming MCP message
289
472
  */
290
- async handleMCPMessage(message, sessionId) {
291
- const { listMCPTools, callMCPTool, hasTool } = await import('./mcp-client.js');
292
- if (!message.method) {
293
- return {
294
- jsonrpc: '2.0',
295
- id: message.id,
296
- error: { code: -32600, message: 'Invalid Request: missing method' },
297
- };
298
- }
299
- const params = (message.params || {});
300
- try {
301
- switch (message.method) {
302
- case 'initialize':
303
- return {
304
- jsonrpc: '2.0',
305
- id: message.id,
306
- result: {
307
- protocolVersion: '2024-11-05',
308
- serverInfo: { name: 'kynjalflow', version: '3.0.0' },
309
- capabilities: {
310
- tools: { listChanged: true },
311
- resources: { subscribe: true, listChanged: true },
312
- },
313
- },
314
- };
315
- case 'tools/list':
316
- const tools = listMCPTools();
317
- return {
318
- jsonrpc: '2.0',
319
- id: message.id,
320
- result: {
321
- tools: tools.map(tool => ({
322
- name: tool.name,
323
- description: tool.description,
324
- inputSchema: tool.inputSchema,
325
- })),
326
- },
327
- };
328
- case 'tools/call':
329
- const toolName = params.name;
330
- const toolParams = (params.arguments || {});
331
- if (!hasTool(toolName)) {
332
- return {
473
+ MCPServerManager.prototype.handleMCPMessage = function (message, sessionId) {
474
+ return __awaiter(this, void 0, Promise, function () {
475
+ var _a, listMCPTools, callMCPTool, hasTool, params, _b, tools, toolName, toolParams, result, error_5, error_6;
476
+ return __generator(this, function (_c) {
477
+ switch (_c.label) {
478
+ case 0: return [4 /*yield*/, import('./mcp-client.js')];
479
+ case 1:
480
+ _a = _c.sent(), listMCPTools = _a.listMCPTools, callMCPTool = _a.callMCPTool, hasTool = _a.hasTool;
481
+ if (!message.method) {
482
+ return [2 /*return*/, {
483
+ jsonrpc: '2.0',
484
+ id: message.id,
485
+ error: { code: -32600, message: 'Invalid Request: missing method' }
486
+ }];
487
+ }
488
+ params = (message.params || {});
489
+ _c.label = 2;
490
+ case 2:
491
+ _c.trys.push([2, 13, , 14]);
492
+ _b = message.method;
493
+ switch (_b) {
494
+ case 'initialize': return [3 /*break*/, 3];
495
+ case 'tools/list': return [3 /*break*/, 4];
496
+ case 'tools/call': return [3 /*break*/, 5];
497
+ case 'notifications/initialized': return [3 /*break*/, 9];
498
+ case 'ping': return [3 /*break*/, 10];
499
+ }
500
+ return [3 /*break*/, 11];
501
+ case 3: return [2 /*return*/, {
333
502
  jsonrpc: '2.0',
334
503
  id: message.id,
335
- error: { code: -32601, message: `Tool not found: ${toolName}` },
336
- };
337
- }
338
- try {
339
- const result = await callMCPTool(toolName, toolParams, { sessionId });
340
- return {
504
+ result: {
505
+ protocolVersion: '2024-11-05',
506
+ serverInfo: { name: 'ruflo', version: '3.0.0' },
507
+ capabilities: {
508
+ tools: { listChanged: true },
509
+ resources: { subscribe: true, listChanged: true }
510
+ }
511
+ }
512
+ }];
513
+ case 4:
514
+ tools = listMCPTools();
515
+ return [2 /*return*/, {
516
+ jsonrpc: '2.0',
517
+ id: message.id,
518
+ result: {
519
+ tools: tools.map(function (tool) { return ({
520
+ name: tool.name,
521
+ description: tool.description,
522
+ inputSchema: tool.inputSchema
523
+ }); })
524
+ }
525
+ }];
526
+ case 5:
527
+ toolName = params.name;
528
+ toolParams = (params.arguments || {});
529
+ if (!hasTool(toolName)) {
530
+ return [2 /*return*/, {
531
+ jsonrpc: '2.0',
532
+ id: message.id,
533
+ error: { code: -32601, message: "Tool not found: " + toolName }
534
+ }];
535
+ }
536
+ _c.label = 6;
537
+ case 6:
538
+ _c.trys.push([6, 8, , 9]);
539
+ return [4 /*yield*/, callMCPTool(toolName, toolParams, { sessionId: sessionId })];
540
+ case 7:
541
+ result = _c.sent();
542
+ return [2 /*return*/, {
543
+ jsonrpc: '2.0',
544
+ id: message.id,
545
+ result: { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }
546
+ }];
547
+ case 8:
548
+ error_5 = _c.sent();
549
+ return [2 /*return*/, {
550
+ jsonrpc: '2.0',
551
+ id: message.id,
552
+ error: {
553
+ code: -32603,
554
+ message: error_5 instanceof Error ? error_5.message : 'Tool execution failed'
555
+ }
556
+ }];
557
+ case 9:
558
+ // Client notification - no response needed
559
+ console.error("[" + new Date().toISOString() + "] INFO [claude-flow-mcp] (" + sessionId + ") Client initialized");
560
+ return [2 /*return*/, null];
561
+ case 10: return [2 /*return*/, {
341
562
  jsonrpc: '2.0',
342
563
  id: message.id,
343
- result: { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] },
344
- };
345
- }
346
- catch (error) {
347
- return {
564
+ result: {}
565
+ }];
566
+ case 11: return [2 /*return*/, {
348
567
  jsonrpc: '2.0',
349
568
  id: message.id,
350
- error: {
351
- code: -32603,
352
- message: error instanceof Error ? error.message : 'Tool execution failed',
353
- },
354
- };
355
- }
356
- case 'notifications/initialized':
357
- // Client notification - no response needed
358
- console.error(`[${new Date().toISOString()}] INFO [claude-flow-mcp] (${sessionId}) Client initialized`);
359
- return null;
360
- case 'ping':
361
- return {
362
- jsonrpc: '2.0',
363
- id: message.id,
364
- result: {},
365
- };
366
- default:
367
- return {
368
- jsonrpc: '2.0',
369
- id: message.id,
370
- error: { code: -32601, message: `Method not found: ${message.method}` },
371
- };
372
- }
373
- }
374
- catch (error) {
375
- console.error(`[${new Date().toISOString()}] ERROR [claude-flow-mcp] Error handling ${message.method}:`, error);
376
- return {
377
- jsonrpc: '2.0',
378
- id: message.id,
379
- error: {
380
- code: -32603,
381
- message: error instanceof Error ? error.message : 'Internal error',
382
- },
383
- };
384
- }
385
- }
569
+ error: { code: -32601, message: "Method not found: " + message.method }
570
+ }];
571
+ case 12: return [3 /*break*/, 14];
572
+ case 13:
573
+ error_6 = _c.sent();
574
+ console.error("[" + new Date().toISOString() + "] ERROR [claude-flow-mcp] Error handling " + message.method + ":", error_6);
575
+ return [2 /*return*/, {
576
+ jsonrpc: '2.0',
577
+ id: message.id,
578
+ error: {
579
+ code: -32603,
580
+ message: error_6 instanceof Error ? error_6.message : 'Internal error'
581
+ }
582
+ }];
583
+ case 14: return [2 /*return*/];
584
+ }
585
+ });
586
+ });
587
+ };
386
588
  /**
387
589
  * Start HTTP server in-process
388
590
  */
389
- async startHttpServer() {
390
- // Dynamically import the MCP server package
391
- // FIX for issue #942: Use proper package import instead of broken relative path
392
- const { createMCPServer } = await import('@claude-flow/mcp');
393
- const logger = {
394
- debug: (msg, data) => this.emit('log', { level: 'debug', msg, data }),
395
- info: (msg, data) => this.emit('log', { level: 'info', msg, data }),
396
- warn: (msg, data) => this.emit('log', { level: 'warn', msg, data }),
397
- error: (msg, data) => this.emit('log', { level: 'error', msg, data }),
398
- };
399
- const mcpServer = createMCPServer({
400
- name: 'KynjalFlow MCP Server V3',
401
- version: '3.0.0',
402
- transport: this.options.transport,
403
- host: this.options.host,
404
- port: this.options.port,
405
- enableMetrics: true,
406
- enableCaching: true,
407
- }, logger);
408
- await mcpServer.start();
409
- // Store reference for stopping
410
- this._mcpServer = mcpServer;
411
- }
591
+ MCPServerManager.prototype.startHttpServer = function () {
592
+ return __awaiter(this, void 0, Promise, function () {
593
+ var createMCPServer, logger, mcpServer;
594
+ var _this = this;
595
+ return __generator(this, function (_a) {
596
+ switch (_a.label) {
597
+ case 0: return [4 /*yield*/, import('@claude-flow/mcp')];
598
+ case 1:
599
+ createMCPServer = (_a.sent()).createMCPServer;
600
+ logger = {
601
+ debug: function (msg, data) { return _this.emit('log', { level: 'debug', msg: msg, data: data }); },
602
+ info: function (msg, data) { return _this.emit('log', { level: 'info', msg: msg, data: data }); },
603
+ warn: function (msg, data) { return _this.emit('log', { level: 'warn', msg: msg, data: data }); },
604
+ error: function (msg, data) { return _this.emit('log', { level: 'error', msg: msg, data: data }); }
605
+ };
606
+ mcpServer = createMCPServer({
607
+ name: 'Claude-Flow MCP Server V3',
608
+ version: '3.0.0',
609
+ transport: this.options.transport,
610
+ host: this.options.host,
611
+ port: this.options.port,
612
+ enableMetrics: true,
613
+ enableCaching: true
614
+ }, logger);
615
+ return [4 /*yield*/, mcpServer.start()];
616
+ case 2:
617
+ _a.sent();
618
+ // Store reference for stopping
619
+ this._mcpServer = mcpServer;
620
+ return [2 /*return*/];
621
+ }
622
+ });
623
+ });
624
+ };
412
625
  /**
413
626
  * Wait for server to be ready
414
627
  */
415
- async waitForReady(timeout = 10000) {
416
- // For stdio transport, we're ready immediately (in-process)
417
- if (this.options.transport === 'stdio') {
418
- return;
419
- }
420
- const startTime = Date.now();
421
- while (Date.now() - startTime < timeout) {
422
- const health = await this.checkHealth();
423
- if (health.healthy) {
424
- return;
425
- }
426
- await this.sleep(100);
427
- }
428
- throw new Error('Server failed to start within timeout');
429
- }
628
+ MCPServerManager.prototype.waitForReady = function (timeout) {
629
+ if (timeout === void 0) { timeout = 10000; }
630
+ return __awaiter(this, void 0, Promise, function () {
631
+ var startTime, health;
632
+ return __generator(this, function (_a) {
633
+ switch (_a.label) {
634
+ case 0:
635
+ // For stdio transport, we're ready immediately (in-process)
636
+ if (this.options.transport === 'stdio') {
637
+ return [2 /*return*/];
638
+ }
639
+ startTime = Date.now();
640
+ _a.label = 1;
641
+ case 1:
642
+ if (!(Date.now() - startTime < timeout)) return [3 /*break*/, 4];
643
+ return [4 /*yield*/, this.checkHealth()];
644
+ case 2:
645
+ health = _a.sent();
646
+ if (health.healthy) {
647
+ return [2 /*return*/];
648
+ }
649
+ return [4 /*yield*/, this.sleep(100)];
650
+ case 3:
651
+ _a.sent();
652
+ return [3 /*break*/, 1];
653
+ case 4: throw new Error('Server failed to start within timeout');
654
+ }
655
+ });
656
+ });
657
+ };
430
658
  /**
431
659
  * Wait for process to exit
432
660
  */
433
- async waitForExit(timeout) {
434
- if (!this.process)
435
- return;
436
- return new Promise((resolve) => {
437
- const timer = setTimeout(() => {
438
- resolve();
439
- }, timeout);
440
- this.process.once('exit', () => {
441
- clearTimeout(timer);
442
- resolve();
661
+ MCPServerManager.prototype.waitForExit = function (timeout) {
662
+ return __awaiter(this, void 0, Promise, function () {
663
+ var _this = this;
664
+ return __generator(this, function (_a) {
665
+ if (!this.process)
666
+ return [2 /*return*/];
667
+ return [2 /*return*/, new Promise(function (resolve) {
668
+ var timer = setTimeout(function () {
669
+ resolve();
670
+ }, timeout);
671
+ _this.process.once('exit', function () {
672
+ clearTimeout(timer);
673
+ resolve();
674
+ });
675
+ })];
443
676
  });
444
677
  });
445
- }
678
+ };
446
679
  /**
447
680
  * Start health monitoring
448
681
  */
449
- startHealthMonitoring() {
450
- this.healthCheckInterval = setInterval(async () => {
451
- try {
452
- const health = await this.checkHealth();
453
- this.emit('health', health);
454
- if (!health.healthy) {
455
- this.emit('unhealthy', health);
682
+ MCPServerManager.prototype.startHealthMonitoring = function () {
683
+ var _this = this;
684
+ this.healthCheckInterval = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
685
+ var health, error_7;
686
+ return __generator(this, function (_a) {
687
+ switch (_a.label) {
688
+ case 0:
689
+ _a.trys.push([0, 2, , 3]);
690
+ return [4 /*yield*/, this.checkHealth()];
691
+ case 1:
692
+ health = _a.sent();
693
+ this.emit('health', health);
694
+ if (!health.healthy) {
695
+ this.emit('unhealthy', health);
696
+ }
697
+ return [3 /*break*/, 3];
698
+ case 2:
699
+ error_7 = _a.sent();
700
+ this.emit('health-error', error_7);
701
+ return [3 /*break*/, 3];
702
+ case 3: return [2 /*return*/];
456
703
  }
457
- }
458
- catch (error) {
459
- this.emit('health-error', error);
460
- }
461
- }, 30000);
462
- }
704
+ });
705
+ }); }, 30000);
706
+ this.healthCheckInterval.unref();
707
+ };
463
708
  /**
464
709
  * Write PID file
465
710
  */
466
- async writePidFile() {
467
- const pid = this.process?.pid || process.pid;
468
- await fs.promises.writeFile(this.options.pidFile, String(pid), 'utf8');
469
- }
711
+ MCPServerManager.prototype.writePidFile = function () {
712
+ var _a;
713
+ return __awaiter(this, void 0, Promise, function () {
714
+ var pid;
715
+ return __generator(this, function (_b) {
716
+ switch (_b.label) {
717
+ case 0:
718
+ pid = ((_a = this.process) === null || _a === void 0 ? void 0 : _a.pid) || process.pid;
719
+ return [4 /*yield*/, fs.promises.writeFile(this.options.pidFile, String(pid), 'utf8')];
720
+ case 1:
721
+ _b.sent();
722
+ return [2 /*return*/];
723
+ }
724
+ });
725
+ });
726
+ };
470
727
  /**
471
728
  * Read PID file
472
729
  */
473
- async readPidFile() {
474
- try {
475
- const content = await fs.promises.readFile(this.options.pidFile, 'utf8');
476
- const pid = parseInt(content.trim(), 10);
477
- return isNaN(pid) ? null : pid;
478
- }
479
- catch {
480
- return null;
481
- }
482
- }
730
+ MCPServerManager.prototype.readPidFile = function () {
731
+ return __awaiter(this, void 0, Promise, function () {
732
+ var content, pid, _a;
733
+ return __generator(this, function (_b) {
734
+ switch (_b.label) {
735
+ case 0:
736
+ _b.trys.push([0, 2, , 3]);
737
+ return [4 /*yield*/, fs.promises.readFile(this.options.pidFile, 'utf8')];
738
+ case 1:
739
+ content = _b.sent();
740
+ pid = parseInt(content.trim(), 10);
741
+ return [2 /*return*/, isNaN(pid) ? null : pid];
742
+ case 2:
743
+ _a = _b.sent();
744
+ return [2 /*return*/, null];
745
+ case 3: return [2 /*return*/];
746
+ }
747
+ });
748
+ });
749
+ };
483
750
  /**
484
751
  * Remove PID file
485
752
  */
486
- async removePidFile() {
487
- try {
488
- await fs.promises.unlink(this.options.pidFile);
489
- }
490
- catch {
491
- // Ignore errors
492
- }
493
- }
753
+ MCPServerManager.prototype.removePidFile = function () {
754
+ return __awaiter(this, void 0, Promise, function () {
755
+ var _a;
756
+ return __generator(this, function (_b) {
757
+ switch (_b.label) {
758
+ case 0:
759
+ _b.trys.push([0, 2, , 3]);
760
+ return [4 /*yield*/, fs.promises.unlink(this.options.pidFile)];
761
+ case 1:
762
+ _b.sent();
763
+ return [3 /*break*/, 3];
764
+ case 2:
765
+ _a = _b.sent();
766
+ return [3 /*break*/, 3];
767
+ case 3: return [2 /*return*/];
768
+ }
769
+ });
770
+ });
771
+ };
494
772
  /**
495
773
  * Check if process is running
496
774
  */
497
- isProcessRunning(pid) {
775
+ MCPServerManager.prototype.isProcessRunning = function (pid) {
498
776
  try {
499
777
  process.kill(pid, 0);
500
778
  return true;
501
779
  }
502
- catch {
780
+ catch (_a) {
503
781
  return false;
504
782
  }
505
- }
783
+ };
506
784
  /**
507
785
  * Make HTTP request
508
786
  */
509
- async httpRequest(url, method, timeout) {
510
- return new Promise((resolve, reject) => {
511
- const urlObj = new URL(url);
512
- const http = require('http');
513
- const req = http.request({
514
- hostname: urlObj.hostname,
515
- port: urlObj.port,
516
- path: urlObj.pathname,
517
- method,
518
- timeout,
519
- }, (res) => {
520
- let data = '';
521
- res.on('data', (chunk) => {
522
- data += chunk;
523
- });
524
- res.on('end', () => {
525
- try {
526
- resolve(JSON.parse(data));
527
- }
528
- catch {
529
- resolve({ status: res.statusCode === 200 ? 'ok' : 'error' });
530
- }
531
- });
532
- });
533
- req.on('error', reject);
534
- req.on('timeout', () => {
535
- req.destroy();
536
- reject(new Error('Request timeout'));
787
+ MCPServerManager.prototype.httpRequest = function (url, method, timeout) {
788
+ return __awaiter(this, void 0, Promise, function () {
789
+ return __generator(this, function (_a) {
790
+ return [2 /*return*/, new Promise(function (resolve, reject) {
791
+ var urlObj = new URL(url);
792
+ var http = require('http');
793
+ var req = http.request({
794
+ hostname: urlObj.hostname,
795
+ port: urlObj.port,
796
+ path: urlObj.pathname,
797
+ method: method,
798
+ timeout: timeout
799
+ }, function (res) {
800
+ var data = '';
801
+ res.on('data', function (chunk) {
802
+ data += chunk;
803
+ });
804
+ res.on('end', function () {
805
+ try {
806
+ resolve(JSON.parse(data));
807
+ }
808
+ catch (_a) {
809
+ resolve({ status: res.statusCode === 200 ? 'ok' : 'error' });
810
+ }
811
+ });
812
+ });
813
+ req.on('error', reject);
814
+ req.on('timeout', function () {
815
+ req.destroy();
816
+ reject(new Error('Request timeout'));
817
+ });
818
+ req.end();
819
+ })];
537
820
  });
538
- req.end();
539
821
  });
540
- }
822
+ };
541
823
  /**
542
824
  * Sleep utility
543
825
  */
544
- sleep(ms) {
545
- return new Promise((resolve) => setTimeout(resolve, ms));
546
- }
547
- }
826
+ MCPServerManager.prototype.sleep = function (ms) {
827
+ return new Promise(function (resolve) { return setTimeout(resolve, ms); });
828
+ };
829
+ return MCPServerManager;
830
+ }(EventEmitter));
831
+ export { MCPServerManager };
548
832
  /**
549
833
  * Create MCP server manager
550
834
  */
@@ -554,8 +838,8 @@ export function createMCPServerManager(options) {
554
838
  /**
555
839
  * Singleton server manager instance
556
840
  */
557
- let serverManager = null;
558
- let currentTransport = undefined;
841
+ var serverManager = null;
842
+ var currentTransport = undefined;
559
843
  /**
560
844
  * Get or create server manager singleton
561
845
  *
@@ -563,7 +847,7 @@ let currentTransport = undefined;
563
847
  * Previously, once created with stdio (default), HTTP options were ignored
564
848
  */
565
849
  export function getServerManager(options) {
566
- const requestedTransport = options?.transport;
850
+ var requestedTransport = options === null || options === void 0 ? void 0 : options.transport;
567
851
  // Recreate if transport type changes (fixes HTTP transport not working)
568
852
  if (serverManager && requestedTransport && requestedTransport !== currentTransport) {
569
853
  serverManager = new MCPServerManager(options);
@@ -571,31 +855,60 @@ export function getServerManager(options) {
571
855
  }
572
856
  if (!serverManager) {
573
857
  serverManager = new MCPServerManager(options);
574
- currentTransport = options?.transport;
858
+ currentTransport = options === null || options === void 0 ? void 0 : options.transport;
575
859
  }
576
860
  return serverManager;
577
861
  }
578
862
  /**
579
863
  * Quick start MCP server
580
864
  */
581
- export async function startMCPServer(options) {
582
- const manager = getServerManager(options);
583
- return await manager.start();
865
+ export function startMCPServer(options) {
866
+ return __awaiter(this, void 0, Promise, function () {
867
+ var manager;
868
+ return __generator(this, function (_a) {
869
+ switch (_a.label) {
870
+ case 0:
871
+ manager = getServerManager(options);
872
+ return [4 /*yield*/, manager.start()];
873
+ case 1: return [2 /*return*/, _a.sent()];
874
+ }
875
+ });
876
+ });
584
877
  }
585
878
  /**
586
879
  * Quick stop MCP server
587
880
  */
588
- export async function stopMCPServer(force = false) {
589
- if (serverManager) {
590
- await serverManager.stop(force);
591
- }
881
+ export function stopMCPServer(force) {
882
+ if (force === void 0) { force = false; }
883
+ return __awaiter(this, void 0, Promise, function () {
884
+ return __generator(this, function (_a) {
885
+ switch (_a.label) {
886
+ case 0:
887
+ if (!serverManager) return [3 /*break*/, 2];
888
+ return [4 /*yield*/, serverManager.stop(force)];
889
+ case 1:
890
+ _a.sent();
891
+ _a.label = 2;
892
+ case 2: return [2 /*return*/];
893
+ }
894
+ });
895
+ });
592
896
  }
593
897
  /**
594
898
  * Get MCP server status
595
899
  */
596
- export async function getMCPServerStatus() {
597
- const manager = getServerManager();
598
- return await manager.getStatus();
900
+ export function getMCPServerStatus() {
901
+ return __awaiter(this, void 0, Promise, function () {
902
+ var manager;
903
+ return __generator(this, function (_a) {
904
+ switch (_a.label) {
905
+ case 0:
906
+ manager = getServerManager();
907
+ return [4 /*yield*/, manager.getStatus()];
908
+ case 1: return [2 /*return*/, _a.sent()];
909
+ }
910
+ });
911
+ });
599
912
  }
600
913
  export default MCPServerManager;
601
914
  //# sourceMappingURL=mcp-server.js.map