kynjal-cli 4.0.0 → 4.0.2

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 (502) hide show
  1. package/dist/src/appliance/gguf-engine.d.ts +91 -0
  2. package/dist/src/appliance/gguf-engine.d.ts.map +1 -0
  3. package/dist/src/appliance/gguf-engine.js +286 -525
  4. package/dist/src/appliance/gguf-engine.js.map +1 -1
  5. package/dist/src/appliance/ruvllm-bridge.d.ts +102 -0
  6. package/dist/src/appliance/ruvllm-bridge.d.ts.map +1 -0
  7. package/dist/src/appliance/ruvllm-bridge.js +203 -403
  8. package/dist/src/appliance/ruvllm-bridge.js.map +1 -1
  9. package/dist/src/appliance/rvfa-builder.d.ts +44 -0
  10. package/dist/src/appliance/rvfa-builder.d.ts.map +1 -0
  11. package/dist/src/appliance/rvfa-builder.js +154 -208
  12. package/dist/src/appliance/rvfa-builder.js.map +1 -1
  13. package/dist/src/appliance/rvfa-distribution.d.ts +97 -0
  14. package/dist/src/appliance/rvfa-distribution.d.ts.map +1 -0
  15. package/dist/src/appliance/rvfa-distribution.js +260 -423
  16. package/dist/src/appliance/rvfa-distribution.js.map +1 -1
  17. package/dist/src/appliance/rvfa-format.d.ts +111 -0
  18. package/dist/src/appliance/rvfa-format.d.ts.map +1 -0
  19. package/dist/src/appliance/rvfa-format.js +128 -200
  20. package/dist/src/appliance/rvfa-format.js.map +1 -1
  21. package/dist/src/appliance/rvfa-runner.d.ts +69 -0
  22. package/dist/src/appliance/rvfa-runner.d.ts.map +1 -0
  23. package/dist/src/appliance/rvfa-runner.js +168 -304
  24. package/dist/src/appliance/rvfa-runner.js.map +1 -1
  25. package/dist/src/appliance/rvfa-signing.d.ts +123 -0
  26. package/dist/src/appliance/rvfa-signing.d.ts.map +1 -0
  27. package/dist/src/appliance/rvfa-signing.js +173 -295
  28. package/dist/src/appliance/rvfa-signing.js.map +1 -1
  29. package/dist/src/benchmarks/pretrain/index.d.ts +58 -0
  30. package/dist/src/benchmarks/pretrain/index.d.ts.map +1 -0
  31. package/dist/src/benchmarks/pretrain/index.js +331 -542
  32. package/dist/src/benchmarks/pretrain/index.js.map +1 -1
  33. package/dist/src/commands/agent.js +574 -697
  34. package/dist/src/commands/agent.js.map +1 -1
  35. package/dist/src/commands/analyze.js +1218 -1548
  36. package/dist/src/commands/analyze.js.map +1 -1
  37. package/dist/src/commands/appliance-advanced.js +158 -267
  38. package/dist/src/commands/appliance-advanced.js.map +1 -1
  39. package/dist/src/commands/appliance.js +318 -493
  40. package/dist/src/commands/appliance.js.map +1 -1
  41. package/dist/src/commands/benchmark.js +372 -523
  42. package/dist/src/commands/benchmark.js.map +1 -1
  43. package/dist/src/commands/claims.js +274 -364
  44. package/dist/src/commands/claims.js.map +1 -1
  45. package/dist/src/commands/cleanup.js +113 -157
  46. package/dist/src/commands/cleanup.js.map +1 -1
  47. package/dist/src/commands/completions.js +477 -118
  48. package/dist/src/commands/completions.js.map +1 -1
  49. package/dist/src/commands/config.js +237 -303
  50. package/dist/src/commands/config.js.map +1 -1
  51. package/dist/src/commands/daemon.js +487 -596
  52. package/dist/src/commands/daemon.js.map +1 -1
  53. package/dist/src/commands/deployment.js +194 -275
  54. package/dist/src/commands/deployment.js.map +1 -1
  55. package/dist/src/commands/doctor.js +504 -686
  56. package/dist/src/commands/doctor.js.map +1 -1
  57. package/dist/src/commands/embeddings.js +1293 -1543
  58. package/dist/src/commands/embeddings.js.map +1 -1
  59. package/dist/src/commands/guidance.js +449 -596
  60. package/dist/src/commands/guidance.js.map +1 -1
  61. package/dist/src/commands/hive-mind.js +854 -938
  62. package/dist/src/commands/hive-mind.js.map +1 -1
  63. package/dist/src/commands/hooks.js +3112 -3519
  64. package/dist/src/commands/hooks.js.map +1 -1
  65. package/dist/src/commands/index.d.ts +115 -0
  66. package/dist/src/commands/index.d.ts.map +1 -0
  67. package/dist/src/commands/index.js +126 -308
  68. package/dist/src/commands/index.js.map +1 -1
  69. package/dist/src/commands/init.js +788 -940
  70. package/dist/src/commands/init.js.map +1 -1
  71. package/dist/src/commands/issues.js +383 -558
  72. package/dist/src/commands/issues.js.map +1 -1
  73. package/dist/src/commands/mcp.js +493 -605
  74. package/dist/src/commands/mcp.js.map +1 -1
  75. package/dist/src/commands/memory.js +833 -1026
  76. package/dist/src/commands/memory.js.map +1 -1
  77. package/dist/src/commands/migrate.js +282 -347
  78. package/dist/src/commands/migrate.js.map +1 -1
  79. package/dist/src/commands/neural.js +1289 -1563
  80. package/dist/src/commands/neural.js.map +1 -1
  81. package/dist/src/commands/performance.js +497 -643
  82. package/dist/src/commands/performance.js.map +1 -1
  83. package/dist/src/commands/plugins.js +668 -841
  84. package/dist/src/commands/plugins.js.map +1 -1
  85. package/dist/src/commands/process.js +392 -447
  86. package/dist/src/commands/process.js.map +1 -1
  87. package/dist/src/commands/progress.js +162 -256
  88. package/dist/src/commands/progress.js.map +1 -1
  89. package/dist/src/commands/providers.js +150 -220
  90. package/dist/src/commands/providers.js.map +1 -1
  91. package/dist/src/commands/route.js +520 -665
  92. package/dist/src/commands/route.js.map +1 -1
  93. package/dist/src/commands/ruvector/backup.js +505 -651
  94. package/dist/src/commands/ruvector/backup.js.map +1 -1
  95. package/dist/src/commands/ruvector/benchmark.js +349 -401
  96. package/dist/src/commands/ruvector/benchmark.js.map +1 -1
  97. package/dist/src/commands/ruvector/import.js +224 -266
  98. package/dist/src/commands/ruvector/import.js.map +1 -1
  99. package/dist/src/commands/ruvector/index.js +37 -75
  100. package/dist/src/commands/ruvector/index.js.map +1 -1
  101. package/dist/src/commands/ruvector/init.js +336 -359
  102. package/dist/src/commands/ruvector/init.js.map +1 -1
  103. package/dist/src/commands/ruvector/migrate.js +335 -322
  104. package/dist/src/commands/ruvector/migrate.js.map +1 -1
  105. package/dist/src/commands/ruvector/optimize.js +375 -431
  106. package/dist/src/commands/ruvector/optimize.js.map +1 -1
  107. package/dist/src/commands/ruvector/setup.js +703 -117
  108. package/dist/src/commands/ruvector/setup.js.map +1 -1
  109. package/dist/src/commands/ruvector/status.js +364 -419
  110. package/dist/src/commands/ruvector/status.js.map +1 -1
  111. package/dist/src/commands/security.js +485 -608
  112. package/dist/src/commands/security.js.map +1 -1
  113. package/dist/src/commands/session.js +504 -626
  114. package/dist/src/commands/session.js.map +1 -1
  115. package/dist/src/commands/start.js +267 -364
  116. package/dist/src/commands/start.js.map +1 -1
  117. package/dist/src/commands/status.js +380 -486
  118. package/dist/src/commands/status.js.map +1 -1
  119. package/dist/src/commands/swarm.js +408 -488
  120. package/dist/src/commands/swarm.js.map +1 -1
  121. package/dist/src/commands/task.js +423 -538
  122. package/dist/src/commands/task.js.map +1 -1
  123. package/dist/src/commands/transfer-store.js +322 -412
  124. package/dist/src/commands/transfer-store.js.map +1 -1
  125. package/dist/src/commands/update.js +196 -291
  126. package/dist/src/commands/update.js.map +1 -1
  127. package/dist/src/commands/workflow.js +386 -486
  128. package/dist/src/commands/workflow.js.map +1 -1
  129. package/dist/src/config-adapter.d.ts +15 -0
  130. package/dist/src/config-adapter.d.ts.map +1 -0
  131. package/dist/src/config-adapter.js +38 -39
  132. package/dist/src/config-adapter.js.map +1 -1
  133. package/dist/src/index.d.ts +77 -0
  134. package/dist/src/index.d.ts.map +1 -0
  135. package/dist/src/index.js +309 -411
  136. package/dist/src/index.js.map +1 -1
  137. package/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
  138. package/dist/src/infrastructure/in-memory-repositories.d.ts.map +1 -0
  139. package/dist/src/infrastructure/in-memory-repositories.js +246 -507
  140. package/dist/src/infrastructure/in-memory-repositories.js.map +1 -1
  141. package/dist/src/init/claudemd-generator.d.ts +25 -0
  142. package/dist/src/init/claudemd-generator.d.ts.map +1 -0
  143. package/dist/src/init/claudemd-generator.js +368 -78
  144. package/dist/src/init/claudemd-generator.js.map +1 -1
  145. package/dist/src/init/executor.d.ts +41 -0
  146. package/dist/src/init/executor.d.ts.map +1 -0
  147. package/dist/src/init/executor.js +1307 -996
  148. package/dist/src/init/executor.js.map +1 -1
  149. package/dist/src/init/helpers-generator.d.ts +60 -0
  150. package/dist/src/init/helpers-generator.d.ts.map +1 -0
  151. package/dist/src/init/helpers-generator.js +657 -12
  152. package/dist/src/init/helpers-generator.js.map +1 -1
  153. package/dist/src/init/index.d.ts +1 -1
  154. package/dist/src/init/index.d.ts.map +1 -1
  155. package/dist/src/init/index.js +1 -1
  156. package/dist/src/init/index.js.map +1 -1
  157. package/dist/src/init/mcp-generator.js +33 -37
  158. package/dist/src/init/mcp-generator.js.map +1 -1
  159. package/dist/src/init/settings-generator.js +76 -77
  160. package/dist/src/init/settings-generator.js.map +1 -1
  161. package/dist/src/init/statusline-generator.js +801 -3
  162. package/dist/src/init/statusline-generator.js.map +1 -1
  163. package/dist/src/init/types.d.ts +1 -1
  164. package/dist/src/init/types.d.ts.map +1 -1
  165. package/dist/src/init/types.js +76 -59
  166. package/dist/src/init/types.js.map +1 -1
  167. package/dist/src/mcp-client.d.ts +92 -0
  168. package/dist/src/mcp-client.d.ts.map +1 -0
  169. package/dist/src/mcp-client.js +81 -125
  170. package/dist/src/mcp-client.js.map +1 -1
  171. package/dist/src/mcp-server.d.ts +161 -0
  172. package/dist/src/mcp-server.d.ts.map +1 -0
  173. package/dist/src/mcp-server.js +470 -757
  174. package/dist/src/mcp-server.js.map +1 -1
  175. package/dist/src/mcp-tools/agent-tools.js +391 -492
  176. package/dist/src/mcp-tools/agent-tools.js.map +1 -1
  177. package/dist/src/mcp-tools/agentdb-tools.js +332 -533
  178. package/dist/src/mcp-tools/agentdb-tools.js.map +1 -1
  179. package/dist/src/mcp-tools/analyze-tools.js +172 -236
  180. package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
  181. package/dist/src/mcp-tools/auto-install.d.ts +83 -0
  182. package/dist/src/mcp-tools/auto-install.d.ts.map +1 -0
  183. package/dist/src/mcp-tools/auto-install.js +80 -142
  184. package/dist/src/mcp-tools/auto-install.js.map +1 -1
  185. package/dist/src/mcp-tools/browser-tools.js +252 -375
  186. package/dist/src/mcp-tools/browser-tools.js.map +1 -1
  187. package/dist/src/mcp-tools/claims-tools.js +473 -565
  188. package/dist/src/mcp-tools/claims-tools.js.map +1 -1
  189. package/dist/src/mcp-tools/config-tools.js +197 -272
  190. package/dist/src/mcp-tools/config-tools.js.map +1 -1
  191. package/dist/src/mcp-tools/coordination-tools.js +500 -572
  192. package/dist/src/mcp-tools/coordination-tools.js.map +1 -1
  193. package/dist/src/mcp-tools/daa-tools.js +286 -364
  194. package/dist/src/mcp-tools/daa-tools.js.map +1 -1
  195. package/dist/src/mcp-tools/embeddings-tools.js +582 -693
  196. package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
  197. package/dist/src/mcp-tools/github-tools.js +260 -311
  198. package/dist/src/mcp-tools/github-tools.js.map +1 -1
  199. package/dist/src/mcp-tools/hive-mind-tools.js +573 -640
  200. package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
  201. package/dist/src/mcp-tools/hooks-tools.js +2215 -2648
  202. package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
  203. package/dist/src/mcp-tools/memory-tools.js +350 -505
  204. package/dist/src/mcp-tools/memory-tools.js.map +1 -1
  205. package/dist/src/mcp-tools/neural-tools.js +315 -412
  206. package/dist/src/mcp-tools/neural-tools.js.map +1 -1
  207. package/dist/src/mcp-tools/performance-tools.js +420 -480
  208. package/dist/src/mcp-tools/performance-tools.js.map +1 -1
  209. package/dist/src/mcp-tools/progress-tools.js +204 -278
  210. package/dist/src/mcp-tools/progress-tools.js.map +1 -1
  211. package/dist/src/mcp-tools/ruvllm-tools.js +163 -279
  212. package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -1
  213. package/dist/src/mcp-tools/security-tools.js +297 -429
  214. package/dist/src/mcp-tools/security-tools.js.map +1 -1
  215. package/dist/src/mcp-tools/session-tools.js +185 -234
  216. package/dist/src/mcp-tools/session-tools.js.map +1 -1
  217. package/dist/src/mcp-tools/swarm-tools.js +207 -260
  218. package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
  219. package/dist/src/mcp-tools/system-tools.js +276 -325
  220. package/dist/src/mcp-tools/system-tools.js.map +1 -1
  221. package/dist/src/mcp-tools/task-tools.js +270 -336
  222. package/dist/src/mcp-tools/task-tools.js.map +1 -1
  223. package/dist/src/mcp-tools/terminal-tools.js +148 -196
  224. package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
  225. package/dist/src/mcp-tools/transfer-tools.js +186 -333
  226. package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
  227. package/dist/src/mcp-tools/types.d.ts +31 -0
  228. package/dist/src/mcp-tools/types.d.ts.map +1 -0
  229. package/dist/src/mcp-tools/wasm-agent-tools.js +133 -280
  230. package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -1
  231. package/dist/src/mcp-tools/workflow-tools.js +405 -450
  232. package/dist/src/mcp-tools/workflow-tools.js.map +1 -1
  233. package/dist/src/memory/ewc-consolidation.d.ts +295 -0
  234. package/dist/src/memory/ewc-consolidation.d.ts.map +1 -0
  235. package/dist/src/memory/ewc-consolidation.js +190 -303
  236. package/dist/src/memory/ewc-consolidation.js.map +1 -1
  237. package/dist/src/memory/intelligence.d.ts +338 -0
  238. package/dist/src/memory/intelligence.d.ts.map +1 -0
  239. package/dist/src/memory/intelligence.js +569 -794
  240. package/dist/src/memory/intelligence.js.map +1 -1
  241. package/dist/src/memory/memory-bridge.d.ts +407 -0
  242. package/dist/src/memory/memory-bridge.d.ts.map +1 -0
  243. package/dist/src/memory/memory-bridge.js +1170 -1640
  244. package/dist/src/memory/memory-bridge.js.map +1 -1
  245. package/dist/src/memory/memory-initializer.d.ts +412 -0
  246. package/dist/src/memory/memory-initializer.d.ts.map +1 -0
  247. package/dist/src/memory/memory-initializer.js +1836 -1851
  248. package/dist/src/memory/memory-initializer.js.map +1 -1
  249. package/dist/src/memory/sona-optimizer.d.ts +227 -0
  250. package/dist/src/memory/sona-optimizer.d.ts.map +1 -0
  251. package/dist/src/memory/sona-optimizer.js +199 -329
  252. package/dist/src/memory/sona-optimizer.js.map +1 -1
  253. package/dist/src/output.d.ts +2 -2
  254. package/dist/src/output.d.ts.map +1 -1
  255. package/dist/src/output.js +242 -272
  256. package/dist/src/output.js.map +1 -1
  257. package/dist/src/parser.d.ts +51 -0
  258. package/dist/src/parser.d.ts.map +1 -0
  259. package/dist/src/parser.js +140 -187
  260. package/dist/src/parser.js.map +1 -1
  261. package/dist/src/plugins/manager.d.ts +133 -0
  262. package/dist/src/plugins/manager.d.ts.map +1 -0
  263. package/dist/src/plugins/manager.js +285 -521
  264. package/dist/src/plugins/manager.js.map +1 -1
  265. package/dist/src/plugins/store/discovery.d.ts +88 -0
  266. package/dist/src/plugins/store/discovery.d.ts.map +1 -0
  267. package/dist/src/plugins/store/discovery.js +271 -358
  268. package/dist/src/plugins/store/discovery.js.map +1 -1
  269. package/dist/src/plugins/store/index.d.ts +76 -0
  270. package/dist/src/plugins/store/index.d.ts.map +1 -0
  271. package/dist/src/plugins/store/index.js +48 -105
  272. package/dist/src/plugins/store/index.js.map +1 -1
  273. package/dist/src/plugins/store/search.d.ts +46 -0
  274. package/dist/src/plugins/store/search.d.ts.map +1 -0
  275. package/dist/src/plugins/store/search.js +69 -107
  276. package/dist/src/plugins/store/search.js.map +1 -1
  277. package/dist/src/plugins/store/types.d.ts +274 -0
  278. package/dist/src/plugins/store/types.d.ts.map +1 -0
  279. package/dist/src/plugins/tests/demo-plugin-store.js +113 -160
  280. package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -1
  281. package/dist/src/plugins/tests/standalone-test.js +172 -223
  282. package/dist/src/plugins/tests/standalone-test.js.map +1 -1
  283. package/dist/src/plugins/tests/test-plugin-store.js +190 -228
  284. package/dist/src/plugins/tests/test-plugin-store.js.map +1 -1
  285. package/dist/src/production/circuit-breaker.d.ts +101 -0
  286. package/dist/src/production/circuit-breaker.d.ts.map +1 -0
  287. package/dist/src/production/circuit-breaker.js +62 -126
  288. package/dist/src/production/circuit-breaker.js.map +1 -1
  289. package/dist/src/production/error-handler.d.ts +92 -0
  290. package/dist/src/production/error-handler.d.ts.map +1 -0
  291. package/dist/src/production/error-handler.js +86 -156
  292. package/dist/src/production/error-handler.js.map +1 -1
  293. package/dist/src/production/monitoring.d.ts +161 -0
  294. package/dist/src/production/monitoring.d.ts.map +1 -0
  295. package/dist/src/production/monitoring.js +139 -220
  296. package/dist/src/production/monitoring.js.map +1 -1
  297. package/dist/src/production/rate-limiter.d.ts +80 -0
  298. package/dist/src/production/rate-limiter.d.ts.map +1 -0
  299. package/dist/src/production/rate-limiter.js +74 -93
  300. package/dist/src/production/rate-limiter.js.map +1 -1
  301. package/dist/src/production/retry.d.ts +48 -0
  302. package/dist/src/production/retry.d.ts.map +1 -0
  303. package/dist/src/production/retry.js +75 -167
  304. package/dist/src/production/retry.js.map +1 -1
  305. package/dist/src/prompt.d.ts +44 -0
  306. package/dist/src/prompt.d.ts.map +1 -0
  307. package/dist/src/prompt.js +436 -560
  308. package/dist/src/prompt.js.map +1 -1
  309. package/dist/src/runtime/headless.d.ts +60 -0
  310. package/dist/src/runtime/headless.d.ts.map +1 -0
  311. package/dist/src/runtime/headless.js +197 -286
  312. package/dist/src/runtime/headless.js.map +1 -1
  313. package/dist/src/ruvector/agent-wasm.d.ts +182 -0
  314. package/dist/src/ruvector/agent-wasm.d.ts.map +1 -0
  315. package/dist/src/ruvector/agent-wasm.js +156 -351
  316. package/dist/src/ruvector/agent-wasm.js.map +1 -1
  317. package/dist/src/ruvector/ast-analyzer.d.ts +67 -0
  318. package/dist/src/ruvector/ast-analyzer.d.ts.map +1 -0
  319. package/dist/src/ruvector/ast-analyzer.js +145 -232
  320. package/dist/src/ruvector/ast-analyzer.js.map +1 -1
  321. package/dist/src/ruvector/coverage-router.d.ts +160 -0
  322. package/dist/src/ruvector/coverage-router.d.ts.map +1 -0
  323. package/dist/src/ruvector/coverage-router.js +287 -419
  324. package/dist/src/ruvector/coverage-router.js.map +1 -1
  325. package/dist/src/ruvector/coverage-tools.js +56 -101
  326. package/dist/src/ruvector/coverage-tools.js.map +1 -1
  327. package/dist/src/ruvector/diff-classifier.d.ts +175 -0
  328. package/dist/src/ruvector/diff-classifier.d.ts.map +1 -0
  329. package/dist/src/ruvector/diff-classifier.js +324 -451
  330. package/dist/src/ruvector/diff-classifier.js.map +1 -1
  331. package/dist/src/ruvector/enhanced-model-router.d.ts +146 -0
  332. package/dist/src/ruvector/enhanced-model-router.d.ts.map +1 -0
  333. package/dist/src/ruvector/enhanced-model-router.js +260 -336
  334. package/dist/src/ruvector/enhanced-model-router.js.map +1 -1
  335. package/dist/src/ruvector/flash-attention.d.ts +195 -0
  336. package/dist/src/ruvector/flash-attention.d.ts.map +1 -0
  337. package/dist/src/ruvector/flash-attention.js +223 -254
  338. package/dist/src/ruvector/flash-attention.js.map +1 -1
  339. package/dist/src/ruvector/graph-analyzer.d.ts +187 -0
  340. package/dist/src/ruvector/graph-analyzer.d.ts.map +1 -0
  341. package/dist/src/ruvector/graph-analyzer.js +486 -680
  342. package/dist/src/ruvector/graph-analyzer.js.map +1 -1
  343. package/dist/src/ruvector/index.d.ts +40 -0
  344. package/dist/src/ruvector/index.d.ts.map +1 -0
  345. package/dist/src/ruvector/index.js +36 -106
  346. package/dist/src/ruvector/index.js.map +1 -1
  347. package/dist/src/ruvector/lora-adapter.d.ts +218 -0
  348. package/dist/src/ruvector/lora-adapter.d.ts.map +1 -0
  349. package/dist/src/ruvector/lora-adapter.js +155 -248
  350. package/dist/src/ruvector/lora-adapter.js.map +1 -1
  351. package/dist/src/ruvector/model-router.d.ts +220 -0
  352. package/dist/src/ruvector/model-router.d.ts.map +1 -0
  353. package/dist/src/ruvector/model-router.js +175 -248
  354. package/dist/src/ruvector/model-router.js.map +1 -1
  355. package/dist/src/ruvector/moe-router.d.ts +206 -0
  356. package/dist/src/ruvector/moe-router.d.ts.map +1 -0
  357. package/dist/src/ruvector/moe-router.js +228 -286
  358. package/dist/src/ruvector/moe-router.js.map +1 -1
  359. package/dist/src/ruvector/q-learning-router.d.ts +211 -0
  360. package/dist/src/ruvector/q-learning-router.d.ts.map +1 -0
  361. package/dist/src/ruvector/q-learning-router.js +257 -338
  362. package/dist/src/ruvector/q-learning-router.js.map +1 -1
  363. package/dist/src/ruvector/ruvllm-wasm.d.ts +179 -0
  364. package/dist/src/ruvector/ruvllm-wasm.d.ts.map +1 -0
  365. package/dist/src/ruvector/ruvllm-wasm.js +270 -434
  366. package/dist/src/ruvector/ruvllm-wasm.js.map +1 -1
  367. package/dist/src/ruvector/semantic-router.d.ts +77 -0
  368. package/dist/src/ruvector/semantic-router.d.ts.map +1 -0
  369. package/dist/src/ruvector/semantic-router.js +60 -67
  370. package/dist/src/ruvector/semantic-router.js.map +1 -1
  371. package/dist/src/ruvector/vector-db.d.ts +69 -0
  372. package/dist/src/ruvector/vector-db.d.ts.map +1 -0
  373. package/dist/src/ruvector/vector-db.js +119 -205
  374. package/dist/src/ruvector/vector-db.js.map +1 -1
  375. package/dist/src/services/agentic-flow-bridge.d.ts +50 -0
  376. package/dist/src/services/agentic-flow-bridge.d.ts.map +1 -0
  377. package/dist/src/services/agentic-flow-bridge.js +32 -105
  378. package/dist/src/services/agentic-flow-bridge.js.map +1 -1
  379. package/dist/src/services/claim-service.d.ts +204 -0
  380. package/dist/src/services/claim-service.d.ts.map +1 -0
  381. package/dist/src/services/claim-service.js +615 -940
  382. package/dist/src/services/claim-service.js.map +1 -1
  383. package/dist/src/services/container-worker-pool.d.ts +197 -0
  384. package/dist/src/services/container-worker-pool.d.ts.map +1 -0
  385. package/dist/src/services/container-worker-pool.js +398 -666
  386. package/dist/src/services/container-worker-pool.js.map +1 -1
  387. package/dist/src/services/headless-worker-executor.d.ts +304 -0
  388. package/dist/src/services/headless-worker-executor.d.ts.map +1 -0
  389. package/dist/src/services/headless-worker-executor.js +441 -467
  390. package/dist/src/services/headless-worker-executor.js.map +1 -1
  391. package/dist/src/services/index.d.ts +4 -4
  392. package/dist/src/services/index.d.ts.map +1 -1
  393. package/dist/src/services/index.js +4 -4
  394. package/dist/src/services/index.js.map +1 -1
  395. package/dist/src/services/registry-api.d.ts +58 -0
  396. package/dist/src/services/registry-api.d.ts.map +1 -0
  397. package/dist/src/services/registry-api.js +92 -200
  398. package/dist/src/services/registry-api.js.map +1 -1
  399. package/dist/src/services/ruvector-training.d.ts +222 -0
  400. package/dist/src/services/ruvector-training.d.ts.map +1 -0
  401. package/dist/src/services/ruvector-training.js +257 -337
  402. package/dist/src/services/ruvector-training.js.map +1 -1
  403. package/dist/src/services/worker-daemon.d.ts +228 -0
  404. package/dist/src/services/worker-daemon.d.ts.map +1 -0
  405. package/dist/src/services/worker-daemon.js +591 -849
  406. package/dist/src/services/worker-daemon.js.map +1 -1
  407. package/dist/src/services/worker-queue.d.ts +194 -0
  408. package/dist/src/services/worker-queue.d.ts.map +1 -0
  409. package/dist/src/services/worker-queue.js +331 -548
  410. package/dist/src/services/worker-queue.js.map +1 -1
  411. package/dist/src/suggest.d.ts +53 -0
  412. package/dist/src/suggest.d.ts.map +1 -0
  413. package/dist/src/suggest.js +45 -55
  414. package/dist/src/suggest.js.map +1 -1
  415. package/dist/src/transfer/anonymization/index.js +29 -37
  416. package/dist/src/transfer/anonymization/index.js.map +1 -1
  417. package/dist/src/transfer/deploy-seraphine.js +128 -155
  418. package/dist/src/transfer/deploy-seraphine.js.map +1 -1
  419. package/dist/src/transfer/export.d.ts +25 -0
  420. package/dist/src/transfer/export.d.ts.map +1 -0
  421. package/dist/src/transfer/export.js +84 -142
  422. package/dist/src/transfer/export.js.map +1 -1
  423. package/dist/src/transfer/index.d.ts +1 -1
  424. package/dist/src/transfer/index.d.ts.map +1 -1
  425. package/dist/src/transfer/index.js +0 -2
  426. package/dist/src/transfer/index.js.map +1 -1
  427. package/dist/src/transfer/ipfs/client.d.ts +109 -0
  428. package/dist/src/transfer/ipfs/client.d.ts.map +1 -0
  429. package/dist/src/transfer/ipfs/client.js +187 -337
  430. package/dist/src/transfer/ipfs/client.js.map +1 -1
  431. package/dist/src/transfer/ipfs/upload.d.ts +95 -0
  432. package/dist/src/transfer/ipfs/upload.d.ts.map +1 -0
  433. package/dist/src/transfer/ipfs/upload.js +288 -434
  434. package/dist/src/transfer/ipfs/upload.js.map +1 -1
  435. package/dist/src/transfer/models/seraphine.d.ts +72 -0
  436. package/dist/src/transfer/models/seraphine.d.ts.map +1 -0
  437. package/dist/src/transfer/models/seraphine.js +55 -55
  438. package/dist/src/transfer/models/seraphine.js.map +1 -1
  439. package/dist/src/transfer/serialization/cfp.d.ts +49 -0
  440. package/dist/src/transfer/serialization/cfp.d.ts.map +1 -0
  441. package/dist/src/transfer/serialization/cfp.js +30 -31
  442. package/dist/src/transfer/serialization/cfp.js.map +1 -1
  443. package/dist/src/transfer/storage/gcs.d.ts +82 -0
  444. package/dist/src/transfer/storage/gcs.d.ts.map +1 -0
  445. package/dist/src/transfer/storage/gcs.js +165 -232
  446. package/dist/src/transfer/storage/gcs.js.map +1 -1
  447. package/dist/src/transfer/store/discovery.d.ts +84 -0
  448. package/dist/src/transfer/store/discovery.d.ts.map +1 -0
  449. package/dist/src/transfer/store/discovery.js +239 -349
  450. package/dist/src/transfer/store/discovery.js.map +1 -1
  451. package/dist/src/transfer/store/download.d.ts +70 -0
  452. package/dist/src/transfer/store/download.d.ts.map +1 -0
  453. package/dist/src/transfer/store/download.js +243 -365
  454. package/dist/src/transfer/store/download.js.map +1 -1
  455. package/dist/src/transfer/store/index.d.ts +84 -0
  456. package/dist/src/transfer/store/index.d.ts.map +1 -0
  457. package/dist/src/transfer/store/index.js +63 -130
  458. package/dist/src/transfer/store/index.js.map +1 -1
  459. package/dist/src/transfer/store/publish.d.ts +76 -0
  460. package/dist/src/transfer/store/publish.d.ts.map +1 -0
  461. package/dist/src/transfer/store/publish.js +184 -258
  462. package/dist/src/transfer/store/publish.js.map +1 -1
  463. package/dist/src/transfer/store/registry.js +50 -72
  464. package/dist/src/transfer/store/registry.js.map +1 -1
  465. package/dist/src/transfer/store/search.d.ts +54 -0
  466. package/dist/src/transfer/store/search.d.ts.map +1 -0
  467. package/dist/src/transfer/store/search.js +64 -96
  468. package/dist/src/transfer/store/search.js.map +1 -1
  469. package/dist/src/transfer/store/tests/standalone-test.js +174 -231
  470. package/dist/src/transfer/store/tests/standalone-test.js.map +1 -1
  471. package/dist/src/transfer/test-seraphine.js +95 -130
  472. package/dist/src/transfer/test-seraphine.js.map +1 -1
  473. package/dist/src/transfer/tests/test-store.js +194 -239
  474. package/dist/src/transfer/tests/test-store.js.map +1 -1
  475. package/dist/src/transfer/types.d.ts +245 -0
  476. package/dist/src/transfer/types.d.ts.map +1 -0
  477. package/dist/src/types.d.ts +198 -0
  478. package/dist/src/types.d.ts.map +1 -0
  479. package/dist/src/types.js +26 -55
  480. package/dist/src/types.js.map +1 -1
  481. package/dist/src/update/checker.d.ts +34 -0
  482. package/dist/src/update/checker.d.ts.map +1 -0
  483. package/dist/src/update/checker.js +106 -183
  484. package/dist/src/update/checker.js.map +1 -1
  485. package/dist/src/update/executor.d.ts +32 -0
  486. package/dist/src/update/executor.d.ts.map +1 -0
  487. package/dist/src/update/executor.js +135 -198
  488. package/dist/src/update/executor.js.map +1 -1
  489. package/dist/src/update/index.d.ts +33 -0
  490. package/dist/src/update/index.d.ts.map +1 -0
  491. package/dist/src/update/index.js +38 -85
  492. package/dist/src/update/index.js.map +1 -1
  493. package/dist/src/update/rate-limiter.d.ts +20 -0
  494. package/dist/src/update/rate-limiter.d.ts.map +1 -0
  495. package/dist/src/update/rate-limiter.js +19 -31
  496. package/dist/src/update/rate-limiter.js.map +1 -1
  497. package/dist/src/update/validator.d.ts +17 -0
  498. package/dist/src/update/validator.d.ts.map +1 -0
  499. package/dist/src/update/validator.js +38 -64
  500. package/dist/src/update/validator.js.map +1 -1
  501. package/dist/tsconfig.tsbuildinfo +1 -1
  502. package/package.json +1 -1
@@ -16,68 +16,6 @@
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
- };
81
19
  import { EventEmitter } from 'events';
82
20
  import { randomUUID } from 'crypto';
83
21
  import * as path from 'path';
@@ -86,12 +24,12 @@ import * as os from 'os';
86
24
  import { fileURLToPath } from 'url';
87
25
  import { dirname } from 'path';
88
26
  // ESM-compatible __dirname
89
- var __filename = fileURLToPath(import.meta.url);
90
- var __dirname = dirname(__filename);
27
+ const __filename = fileURLToPath(import.meta.url);
28
+ const __dirname = dirname(__filename);
91
29
  /**
92
30
  * Default configuration
93
31
  */
94
- var DEFAULT_OPTIONS = {
32
+ const DEFAULT_OPTIONS = {
95
33
  transport: 'stdio',
96
34
  host: 'localhost',
97
35
  port: 3000,
@@ -99,736 +37,540 @@ var DEFAULT_OPTIONS = {
99
37
  logFile: path.join(os.tmpdir(), 'claude-flow-mcp.log'),
100
38
  tools: 'all',
101
39
  daemonize: false,
102
- timeout: 30000
40
+ timeout: 30000,
103
41
  };
104
42
  /**
105
43
  * MCP Server Manager
106
44
  *
107
45
  * Manages the lifecycle of the MCP server process
108
46
  */
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;
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 };
116
56
  }
117
57
  /**
118
58
  * Start the MCP server
119
59
  */
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
- }
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,
171
87
  });
172
- });
173
- };
88
+ return finalStatus;
89
+ }
90
+ catch (error) {
91
+ this.emit('error', error);
92
+ throw error;
93
+ }
94
+ }
174
95
  /**
175
96
  * Stop the MCP server
176
97
  */
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*/];
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);
236
115
  }
237
- });
238
- });
239
- };
116
+ // Force kill if still running
117
+ if (this.process && !this.process.killed) {
118
+ this.process.kill('SIGKILL');
119
+ }
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
+ }
240
138
  /**
241
139
  * Get server status
242
140
  */
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
- };
141
+ async getStatus() {
142
+ // Check PID file
143
+ const pid = await this.readPidFile();
144
+ if (!pid) {
145
+ // No PID file found. Detect if we are running in stdio mode
146
+ // (e.g., launched by Claude Code via `claude mcp add`).
147
+ const isStdio = !process.stdin.isTTY;
148
+ const envTransport = process.env.CLAUDE_FLOW_MCP_TRANSPORT;
149
+ if (isStdio || envTransport === 'stdio' || this.options.transport === 'stdio') {
150
+ return {
151
+ running: true,
152
+ pid: process.pid,
153
+ transport: 'stdio',
154
+ startedAt: this.startTime?.toISOString(),
155
+ uptime: this.startTime
156
+ ? Math.floor((Date.now() - this.startTime.getTime()) / 1000)
157
+ : undefined,
158
+ };
159
+ }
160
+ return { running: false };
161
+ }
162
+ // Check if process is running
163
+ const isRunning = this.isProcessRunning(pid);
164
+ if (!isRunning) {
165
+ // Clean up stale PID file
166
+ await this.removePidFile();
167
+ return { running: false };
168
+ }
169
+ // Build status
170
+ const status = {
171
+ running: true,
172
+ pid,
173
+ transport: this.options.transport,
174
+ host: this.options.host,
175
+ port: this.options.port,
176
+ startedAt: this.startTime?.toISOString(),
177
+ uptime: this.startTime
178
+ ? Math.floor((Date.now() - this.startTime.getTime()) / 1000)
179
+ : undefined,
180
+ };
181
+ // Get health status for HTTP transport
182
+ if (this.options.transport !== 'stdio') {
183
+ status.health = await this.checkHealth();
184
+ }
185
+ return status;
186
+ }
299
187
  /**
300
188
  * Check server health
301
189
  */
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
- };
190
+ async checkHealth() {
191
+ if (this.options.transport === 'stdio') {
192
+ // For stdio, check if process is running
193
+ const pid = await this.readPidFile();
194
+ if (pid === null) {
195
+ return { healthy: false, error: 'No PID file found' };
196
+ }
197
+ if (!this.isProcessRunning(pid)) {
198
+ // Clean up stale PID file
199
+ await this.removePidFile();
200
+ return { healthy: false, error: 'Process not running (cleaned up stale PID)' };
201
+ }
202
+ return { healthy: true };
203
+ }
204
+ // For HTTP/WebSocket, make health check request
205
+ try {
206
+ const response = await this.httpRequest(`http://${this.options.host}:${this.options.port}/health`, 'GET', this.options.timeout);
207
+ return {
208
+ healthy: response.status === 'ok',
209
+ metrics: {
210
+ connections: response.connections || 0,
211
+ },
212
+ };
213
+ }
214
+ catch (error) {
215
+ return {
216
+ healthy: false,
217
+ error: error instanceof Error ? error.message : 'Unknown error',
218
+ };
219
+ }
220
+ }
345
221
  /**
346
222
  * Restart the server
347
223
  */
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
- };
224
+ async restart() {
225
+ await this.stop();
226
+ return await this.start();
227
+ }
361
228
  /**
362
229
  * Start stdio server in-process
363
230
  * Handles stdin/stdout directly like V2 implementation
364
231
  */
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*/];
232
+ async startStdioServer() {
233
+ // Import the tool registry
234
+ const { listMCPTools, callMCPTool, hasTool } = await import('./mcp-client.js');
235
+ const VERSION = '3.0.0';
236
+ const sessionId = `mcp-${Date.now()}-${randomUUID().slice(0, 8)}`;
237
+ // Log to stderr to not corrupt stdout
238
+ console.error(`[${new Date().toISOString()}] INFO [claude-flow-mcp] (${sessionId}) Starting in stdio mode`);
239
+ console.error(JSON.stringify({
240
+ arch: process.arch,
241
+ mode: 'mcp-stdio',
242
+ nodeVersion: process.version,
243
+ pid: process.pid,
244
+ platform: process.platform,
245
+ protocol: 'stdio',
246
+ sessionId,
247
+ version: VERSION,
248
+ }));
249
+ // Send server initialization notification
250
+ console.log(JSON.stringify({
251
+ jsonrpc: '2.0',
252
+ method: 'server.initialized',
253
+ params: {
254
+ serverInfo: {
255
+ name: 'ruflo',
256
+ version: VERSION,
257
+ capabilities: {
258
+ tools: { listChanged: true },
259
+ resources: { subscribe: true, listChanged: true },
260
+ },
261
+ },
262
+ },
263
+ }));
264
+ // Handle stdin messages (S-5: bounded buffer to prevent OOM)
265
+ const MAX_BUFFER_SIZE = 10 * 1024 * 1024; // 10MB
266
+ let buffer = '';
267
+ process.stdin.on('data', async (chunk) => {
268
+ buffer += chunk.toString();
269
+ if (buffer.length > MAX_BUFFER_SIZE) {
270
+ console.error(`[${new Date().toISOString()}] ERROR [claude-flow-mcp] Buffer exceeded ${MAX_BUFFER_SIZE} bytes, rejecting`);
271
+ buffer = '';
272
+ console.log(JSON.stringify({
273
+ jsonrpc: '2.0',
274
+ error: { code: -32600, message: 'Request too large' },
275
+ }));
276
+ return;
277
+ }
278
+ // Process complete JSON messages
279
+ let lines = buffer.split('\n');
280
+ buffer = lines.pop() || ''; // Keep incomplete line in buffer
281
+ for (const line of lines) {
282
+ if (line.trim()) {
283
+ try {
284
+ const message = JSON.parse(line);
285
+ const response = await this.handleMCPMessage(message, sessionId);
286
+ if (response) {
287
+ console.log(JSON.stringify(response));
288
+ }
289
+ }
290
+ catch (error) {
291
+ console.error(`[${new Date().toISOString()}] ERROR [claude-flow-mcp] Failed to parse message:`, error instanceof Error ? error.message : String(error));
292
+ }
466
293
  }
467
- });
294
+ }
295
+ });
296
+ process.stdin.on('end', () => {
297
+ console.error(`[${new Date().toISOString()}] INFO [claude-flow-mcp] (${sessionId}) stdin closed, shutting down...`);
298
+ process.exit(0);
468
299
  });
469
- };
300
+ // Handle process termination
301
+ process.on('SIGINT', () => {
302
+ console.error(`[${new Date().toISOString()}] INFO [claude-flow-mcp] (${sessionId}) Received SIGINT, shutting down...`);
303
+ process.exit(0);
304
+ });
305
+ process.on('SIGTERM', () => {
306
+ console.error(`[${new Date().toISOString()}] INFO [claude-flow-mcp] (${sessionId}) Received SIGTERM, shutting down...`);
307
+ process.exit(0);
308
+ });
309
+ // Mark as ready immediately for stdio
310
+ this.emit('ready');
311
+ }
470
312
  /**
471
313
  * Handle incoming MCP message
472
314
  */
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*/, {
315
+ async handleMCPMessage(message, sessionId) {
316
+ const { listMCPTools, callMCPTool, hasTool } = await import('./mcp-client.js');
317
+ if (!message.method) {
318
+ return {
319
+ jsonrpc: '2.0',
320
+ id: message.id,
321
+ error: { code: -32600, message: 'Invalid Request: missing method' },
322
+ };
323
+ }
324
+ const params = (message.params || {});
325
+ try {
326
+ switch (message.method) {
327
+ case 'initialize':
328
+ return {
329
+ jsonrpc: '2.0',
330
+ id: message.id,
331
+ result: {
332
+ protocolVersion: '2024-11-05',
333
+ serverInfo: { name: 'ruflo', version: '3.0.0' },
334
+ capabilities: {
335
+ tools: { listChanged: true },
336
+ resources: { subscribe: true, listChanged: true },
337
+ },
338
+ },
339
+ };
340
+ case 'tools/list':
341
+ const tools = listMCPTools();
342
+ return {
343
+ jsonrpc: '2.0',
344
+ id: message.id,
345
+ result: {
346
+ tools: tools.map(tool => ({
347
+ name: tool.name,
348
+ description: tool.description,
349
+ inputSchema: tool.inputSchema,
350
+ })),
351
+ },
352
+ };
353
+ case 'tools/call':
354
+ const toolName = params.name;
355
+ const toolParams = (params.arguments || {});
356
+ if (!hasTool(toolName)) {
357
+ return {
502
358
  jsonrpc: '2.0',
503
359
  id: message.id,
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*/, {
360
+ error: { code: -32601, message: `Tool not found: ${toolName}` },
361
+ };
362
+ }
363
+ try {
364
+ const result = await callMCPTool(toolName, toolParams, { sessionId });
365
+ return {
562
366
  jsonrpc: '2.0',
563
367
  id: message.id,
564
- result: {}
565
- }];
566
- case 11: return [2 /*return*/, {
368
+ result: { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] },
369
+ };
370
+ }
371
+ catch (error) {
372
+ return {
567
373
  jsonrpc: '2.0',
568
374
  id: message.id,
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
- };
375
+ error: {
376
+ code: -32603,
377
+ message: error instanceof Error ? error.message : 'Tool execution failed',
378
+ },
379
+ };
380
+ }
381
+ case 'notifications/initialized':
382
+ // Client notification - no response needed
383
+ console.error(`[${new Date().toISOString()}] INFO [claude-flow-mcp] (${sessionId}) Client initialized`);
384
+ return null;
385
+ case 'ping':
386
+ return {
387
+ jsonrpc: '2.0',
388
+ id: message.id,
389
+ result: {},
390
+ };
391
+ default:
392
+ return {
393
+ jsonrpc: '2.0',
394
+ id: message.id,
395
+ error: { code: -32601, message: `Method not found: ${message.method}` },
396
+ };
397
+ }
398
+ }
399
+ catch (error) {
400
+ console.error(`[${new Date().toISOString()}] ERROR [claude-flow-mcp] Error handling ${message.method}:`, error);
401
+ return {
402
+ jsonrpc: '2.0',
403
+ id: message.id,
404
+ error: {
405
+ code: -32603,
406
+ message: error instanceof Error ? error.message : 'Internal error',
407
+ },
408
+ };
409
+ }
410
+ }
588
411
  /**
589
412
  * Start HTTP server in-process
590
413
  */
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
- };
414
+ async startHttpServer() {
415
+ // Dynamically import the MCP server package
416
+ // FIX for issue #942: Use proper package import instead of broken relative path
417
+ const { createMCPServer } = await import('@claude-flow/mcp');
418
+ const logger = {
419
+ debug: (msg, data) => this.emit('log', { level: 'debug', msg, data }),
420
+ info: (msg, data) => this.emit('log', { level: 'info', msg, data }),
421
+ warn: (msg, data) => this.emit('log', { level: 'warn', msg, data }),
422
+ error: (msg, data) => this.emit('log', { level: 'error', msg, data }),
423
+ };
424
+ const mcpServer = createMCPServer({
425
+ name: 'Claude-Flow MCP Server V3',
426
+ version: '3.0.0',
427
+ transport: this.options.transport,
428
+ host: this.options.host,
429
+ port: this.options.port,
430
+ enableMetrics: true,
431
+ enableCaching: true,
432
+ }, logger);
433
+ await mcpServer.start();
434
+ // Store reference for stopping
435
+ this._mcpServer = mcpServer;
436
+ }
625
437
  /**
626
438
  * Wait for server to be ready
627
439
  */
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
- };
440
+ async waitForReady(timeout = 10000) {
441
+ // For stdio transport, we're ready immediately (in-process)
442
+ if (this.options.transport === 'stdio') {
443
+ return;
444
+ }
445
+ const startTime = Date.now();
446
+ while (Date.now() - startTime < timeout) {
447
+ const health = await this.checkHealth();
448
+ if (health.healthy) {
449
+ return;
450
+ }
451
+ await this.sleep(100);
452
+ }
453
+ throw new Error('Server failed to start within timeout');
454
+ }
658
455
  /**
659
456
  * Wait for process to exit
660
457
  */
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
- })];
458
+ async waitForExit(timeout) {
459
+ if (!this.process)
460
+ return;
461
+ return new Promise((resolve) => {
462
+ const timer = setTimeout(() => {
463
+ resolve();
464
+ }, timeout);
465
+ this.process.once('exit', () => {
466
+ clearTimeout(timer);
467
+ resolve();
676
468
  });
677
469
  });
678
- };
470
+ }
679
471
  /**
680
472
  * Start health monitoring
681
473
  */
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*/];
474
+ startHealthMonitoring() {
475
+ this.healthCheckInterval = setInterval(async () => {
476
+ try {
477
+ const health = await this.checkHealth();
478
+ this.emit('health', health);
479
+ if (!health.healthy) {
480
+ this.emit('unhealthy', health);
703
481
  }
704
- });
705
- }); }, 30000);
482
+ }
483
+ catch (error) {
484
+ this.emit('health-error', error);
485
+ }
486
+ }, 30000);
706
487
  this.healthCheckInterval.unref();
707
- };
488
+ }
708
489
  /**
709
490
  * Write PID file
710
491
  */
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
- };
492
+ async writePidFile() {
493
+ const pid = this.process?.pid || process.pid;
494
+ await fs.promises.writeFile(this.options.pidFile, String(pid), 'utf8');
495
+ }
727
496
  /**
728
497
  * Read PID file
729
498
  */
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
- };
499
+ async readPidFile() {
500
+ try {
501
+ const content = await fs.promises.readFile(this.options.pidFile, 'utf8');
502
+ const pid = parseInt(content.trim(), 10);
503
+ return isNaN(pid) ? null : pid;
504
+ }
505
+ catch {
506
+ return null;
507
+ }
508
+ }
750
509
  /**
751
510
  * Remove PID file
752
511
  */
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
- };
512
+ async removePidFile() {
513
+ try {
514
+ await fs.promises.unlink(this.options.pidFile);
515
+ }
516
+ catch {
517
+ // Ignore errors
518
+ }
519
+ }
772
520
  /**
773
521
  * Check if process is running
774
522
  */
775
- MCPServerManager.prototype.isProcessRunning = function (pid) {
523
+ isProcessRunning(pid) {
776
524
  try {
777
525
  process.kill(pid, 0);
778
526
  return true;
779
527
  }
780
- catch (_a) {
528
+ catch {
781
529
  return false;
782
530
  }
783
- };
531
+ }
784
532
  /**
785
533
  * Make HTTP request
786
534
  */
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
- })];
535
+ async httpRequest(url, method, timeout) {
536
+ return new Promise((resolve, reject) => {
537
+ const urlObj = new URL(url);
538
+ const http = require('http');
539
+ const req = http.request({
540
+ hostname: urlObj.hostname,
541
+ port: urlObj.port,
542
+ path: urlObj.pathname,
543
+ method,
544
+ timeout,
545
+ }, (res) => {
546
+ let data = '';
547
+ res.on('data', (chunk) => {
548
+ data += chunk;
549
+ });
550
+ res.on('end', () => {
551
+ try {
552
+ resolve(JSON.parse(data));
553
+ }
554
+ catch {
555
+ resolve({ status: res.statusCode === 200 ? 'ok' : 'error' });
556
+ }
557
+ });
558
+ });
559
+ req.on('error', reject);
560
+ req.on('timeout', () => {
561
+ req.destroy();
562
+ reject(new Error('Request timeout'));
820
563
  });
564
+ req.end();
821
565
  });
822
- };
566
+ }
823
567
  /**
824
568
  * Sleep utility
825
569
  */
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 };
570
+ sleep(ms) {
571
+ return new Promise((resolve) => setTimeout(resolve, ms));
572
+ }
573
+ }
832
574
  /**
833
575
  * Create MCP server manager
834
576
  */
@@ -838,8 +580,8 @@ export function createMCPServerManager(options) {
838
580
  /**
839
581
  * Singleton server manager instance
840
582
  */
841
- var serverManager = null;
842
- var currentTransport = undefined;
583
+ let serverManager = null;
584
+ let currentTransport = undefined;
843
585
  /**
844
586
  * Get or create server manager singleton
845
587
  *
@@ -847,7 +589,7 @@ var currentTransport = undefined;
847
589
  * Previously, once created with stdio (default), HTTP options were ignored
848
590
  */
849
591
  export function getServerManager(options) {
850
- var requestedTransport = options === null || options === void 0 ? void 0 : options.transport;
592
+ const requestedTransport = options?.transport;
851
593
  // Recreate if transport type changes (fixes HTTP transport not working)
852
594
  if (serverManager && requestedTransport && requestedTransport !== currentTransport) {
853
595
  serverManager = new MCPServerManager(options);
@@ -855,60 +597,31 @@ export function getServerManager(options) {
855
597
  }
856
598
  if (!serverManager) {
857
599
  serverManager = new MCPServerManager(options);
858
- currentTransport = options === null || options === void 0 ? void 0 : options.transport;
600
+ currentTransport = options?.transport;
859
601
  }
860
602
  return serverManager;
861
603
  }
862
604
  /**
863
605
  * Quick start MCP server
864
606
  */
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
- });
607
+ export async function startMCPServer(options) {
608
+ const manager = getServerManager(options);
609
+ return await manager.start();
877
610
  }
878
611
  /**
879
612
  * Quick stop MCP server
880
613
  */
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
- });
614
+ export async function stopMCPServer(force = false) {
615
+ if (serverManager) {
616
+ await serverManager.stop(force);
617
+ }
896
618
  }
897
619
  /**
898
620
  * Get MCP server status
899
621
  */
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
- });
622
+ export async function getMCPServerStatus() {
623
+ const manager = getServerManager();
624
+ return await manager.getStatus();
912
625
  }
913
626
  export default MCPServerManager;
914
627
  //# sourceMappingURL=mcp-server.js.map