kynjal-cli 4.0.0 → 4.0.1

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
@@ -8,59 +8,12 @@
8
8
  * - No actual distributed coordination
9
9
  * - Useful for single-machine workflow orchestration
10
10
  */
11
- var __assign = (this && this.__assign) || function () {
12
- __assign = Object.assign || function(t) {
13
- for (var s, i = 1, n = arguments.length; i < n; i++) {
14
- s = arguments[i];
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
16
- t[p] = s[p];
17
- }
18
- return t;
19
- };
20
- return __assign.apply(this, arguments);
21
- };
22
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
23
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
24
- return new (P || (P = Promise))(function (resolve, reject) {
25
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
26
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
27
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
28
- step((generator = generator.apply(thisArg, _arguments || [])).next());
29
- });
30
- };
31
- var __generator = (this && this.__generator) || function (thisArg, body) {
32
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
33
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
34
- function verb(n) { return function (v) { return step([n, v]); }; }
35
- function step(op) {
36
- if (f) throw new TypeError("Generator is already executing.");
37
- while (_) try {
38
- 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;
39
- if (y = 0, t) op = [op[0] & 2, t.value];
40
- switch (op[0]) {
41
- case 0: case 1: t = op; break;
42
- case 4: _.label++; return { value: op[1], done: false };
43
- case 5: _.label++; y = op[1]; op = [0]; continue;
44
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
45
- default:
46
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
47
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
48
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
49
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
50
- if (t[2]) _.ops.pop();
51
- _.trys.pop(); continue;
52
- }
53
- op = body.call(thisArg, _);
54
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
55
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
56
- }
57
- };
58
11
  import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
59
12
  import { join } from 'node:path';
60
13
  // Storage paths
61
- var STORAGE_DIR = '.claude-flow';
62
- var COORD_DIR = 'coordination';
63
- var COORD_FILE = 'store.json';
14
+ const STORAGE_DIR = '.claude-flow';
15
+ const COORD_DIR = 'coordination';
16
+ const COORD_FILE = 'store.json';
64
17
  function getCoordDir() {
65
18
  return join(process.cwd(), STORAGE_DIR, COORD_DIR);
66
19
  }
@@ -68,19 +21,19 @@ function getCoordPath() {
68
21
  return join(getCoordDir(), COORD_FILE);
69
22
  }
70
23
  function ensureCoordDir() {
71
- var dir = getCoordDir();
24
+ const dir = getCoordDir();
72
25
  if (!existsSync(dir)) {
73
26
  mkdirSync(dir, { recursive: true });
74
27
  }
75
28
  }
76
29
  function loadCoordStore() {
77
30
  try {
78
- var path = getCoordPath();
31
+ const path = getCoordPath();
79
32
  if (existsSync(path)) {
80
33
  return JSON.parse(readFileSync(path, 'utf-8'));
81
34
  }
82
35
  }
83
- catch (_a) {
36
+ catch {
84
37
  // Return default store
85
38
  }
86
39
  return {
@@ -88,28 +41,28 @@ function loadCoordStore() {
88
41
  type: 'hierarchical',
89
42
  maxNodes: 15,
90
43
  redundancy: 2,
91
- consensusAlgorithm: 'raft'
44
+ consensusAlgorithm: 'raft',
92
45
  },
93
46
  loadBalance: {
94
47
  algorithm: 'adaptive',
95
48
  weights: {},
96
- healthCheck: true
49
+ healthCheck: true,
97
50
  },
98
51
  sync: {
99
52
  lastSync: new Date().toISOString(),
100
53
  syncCount: 0,
101
54
  conflicts: 0,
102
- pendingChanges: 0
55
+ pendingChanges: 0,
103
56
  },
104
57
  nodes: {},
105
- version: '3.0.0'
58
+ version: '3.0.0',
106
59
  };
107
60
  }
108
61
  function saveCoordStore(store) {
109
62
  ensureCoordDir();
110
63
  writeFileSync(getCoordPath(), JSON.stringify(store, null, 2), 'utf-8');
111
64
  }
112
- export var coordinationTools = [
65
+ export const coordinationTools = [
113
66
  {
114
67
  name: 'coordination_topology',
115
68
  description: 'Configure swarm topology',
@@ -117,69 +70,67 @@ export var coordinationTools = [
117
70
  inputSchema: {
118
71
  type: 'object',
119
72
  properties: {
120
- action: { type: 'string', "enum": ['get', 'set', 'optimize'], description: 'Action to perform' },
121
- type: { type: 'string', "enum": ['mesh', 'hierarchical', 'ring', 'star', 'hybrid', 'hierarchical-mesh'], description: 'Topology type' },
73
+ action: { type: 'string', enum: ['get', 'set', 'optimize'], description: 'Action to perform' },
74
+ type: { type: 'string', enum: ['mesh', 'hierarchical', 'ring', 'star', 'hybrid', 'hierarchical-mesh'], description: 'Topology type' },
122
75
  maxNodes: { type: 'number', description: 'Maximum nodes' },
123
76
  redundancy: { type: 'number', description: 'Redundancy level' },
124
- consensusAlgorithm: { type: 'string', "enum": ['raft', 'byzantine', 'gossip', 'crdt'], description: 'Consensus algorithm' }
125
- }
77
+ consensusAlgorithm: { type: 'string', enum: ['raft', 'byzantine', 'gossip', 'crdt'], description: 'Consensus algorithm' },
78
+ },
126
79
  },
127
- handler: function (input) { return __awaiter(void 0, void 0, void 0, function () {
128
- var store, action, nodeCount, recommended;
129
- return __generator(this, function (_a) {
130
- store = loadCoordStore();
131
- action = input.action || 'get';
132
- if (action === 'get') {
133
- return [2 /*return*/, {
134
- success: true,
135
- topology: store.topology,
136
- nodes: Object.keys(store.nodes).length,
137
- status: 'active'
138
- }];
139
- }
140
- if (action === 'set') {
141
- if (input.type)
142
- store.topology.type = input.type;
143
- if (input.maxNodes)
144
- store.topology.maxNodes = input.maxNodes;
145
- if (input.redundancy)
146
- store.topology.redundancy = input.redundancy;
147
- if (input.consensusAlgorithm)
148
- store.topology.consensusAlgorithm = input.consensusAlgorithm;
149
- saveCoordStore(store);
150
- return [2 /*return*/, {
151
- success: true,
152
- action: 'updated',
153
- topology: store.topology
154
- }];
80
+ handler: async (input) => {
81
+ const store = loadCoordStore();
82
+ const action = input.action || 'get';
83
+ if (action === 'get') {
84
+ return {
85
+ success: true,
86
+ topology: store.topology,
87
+ nodes: Object.keys(store.nodes).length,
88
+ status: 'active',
89
+ };
90
+ }
91
+ if (action === 'set') {
92
+ if (input.type)
93
+ store.topology.type = input.type;
94
+ if (input.maxNodes)
95
+ store.topology.maxNodes = input.maxNodes;
96
+ if (input.redundancy)
97
+ store.topology.redundancy = input.redundancy;
98
+ if (input.consensusAlgorithm)
99
+ store.topology.consensusAlgorithm = input.consensusAlgorithm;
100
+ saveCoordStore(store);
101
+ return {
102
+ success: true,
103
+ action: 'updated',
104
+ topology: store.topology,
105
+ };
106
+ }
107
+ if (action === 'optimize') {
108
+ // Analyze current state and suggest optimal topology
109
+ const nodeCount = Object.keys(store.nodes).length;
110
+ let recommended = 'hierarchical';
111
+ if (nodeCount <= 5) {
112
+ recommended = 'mesh';
155
113
  }
156
- if (action === 'optimize') {
157
- nodeCount = Object.keys(store.nodes).length;
114
+ else if (nodeCount <= 15) {
158
115
  recommended = 'hierarchical';
159
- if (nodeCount <= 5) {
160
- recommended = 'mesh';
161
- }
162
- else if (nodeCount <= 15) {
163
- recommended = 'hierarchical';
164
- }
165
- else {
166
- recommended = 'hybrid';
167
- }
168
- return [2 /*return*/, {
169
- success: true,
170
- action: 'optimize',
171
- current: store.topology.type,
172
- recommended: recommended,
173
- reason: nodeCount <= 5
174
- ? 'Small cluster benefits from full mesh connectivity'
175
- : nodeCount <= 15
176
- ? 'Medium cluster works well with hierarchical coordination'
177
- : 'Large cluster needs hybrid approach for scalability'
178
- }];
179
116
  }
180
- return [2 /*return*/, { success: false, error: 'Unknown action' }];
181
- });
182
- }); }
117
+ else {
118
+ recommended = 'hybrid';
119
+ }
120
+ return {
121
+ success: true,
122
+ action: 'optimize',
123
+ current: store.topology.type,
124
+ recommended,
125
+ reason: nodeCount <= 5
126
+ ? 'Small cluster benefits from full mesh connectivity'
127
+ : nodeCount <= 15
128
+ ? 'Medium cluster works well with hierarchical coordination'
129
+ : 'Large cluster needs hybrid approach for scalability',
130
+ };
131
+ }
132
+ return { success: false, error: 'Unknown action' };
133
+ },
183
134
  },
184
135
  {
185
136
  name: 'coordination_load_balance',
@@ -188,79 +139,77 @@ export var coordinationTools = [
188
139
  inputSchema: {
189
140
  type: 'object',
190
141
  properties: {
191
- action: { type: 'string', "enum": ['get', 'set', 'distribute'], description: 'Action to perform' },
192
- algorithm: { type: 'string', "enum": ['round-robin', 'least-connections', 'weighted', 'adaptive'], description: 'Algorithm' },
142
+ action: { type: 'string', enum: ['get', 'set', 'distribute'], description: 'Action to perform' },
143
+ algorithm: { type: 'string', enum: ['round-robin', 'least-connections', 'weighted', 'adaptive'], description: 'Algorithm' },
193
144
  weights: { type: 'object', description: 'Node weights' },
194
- task: { type: 'string', description: 'Task to distribute' }
195
- }
145
+ task: { type: 'string', description: 'Task to distribute' },
146
+ },
196
147
  },
197
- handler: function (input) { return __awaiter(void 0, void 0, void 0, function () {
198
- var store, action, nodes, avgLoad, task, nodes, selectedNode, algorithm, weights_1;
199
- return __generator(this, function (_a) {
200
- store = loadCoordStore();
201
- action = input.action || 'get';
202
- if (action === 'get') {
203
- nodes = Object.values(store.nodes);
204
- avgLoad = nodes.length > 0
205
- ? nodes.reduce(function (sum, n) { return sum + n.load; }, 0) / nodes.length
206
- : 0;
207
- return [2 /*return*/, {
208
- success: true,
209
- loadBalance: store.loadBalance,
210
- metrics: {
211
- nodeCount: nodes.length,
212
- avgLoad: avgLoad,
213
- maxLoad: nodes.length > 0 ? Math.max.apply(Math, nodes.map(function (n) { return n.load; })) : 0,
214
- minLoad: nodes.length > 0 ? Math.min.apply(Math, nodes.map(function (n) { return n.load; })) : 0
215
- }
216
- }];
148
+ handler: async (input) => {
149
+ const store = loadCoordStore();
150
+ const action = input.action || 'get';
151
+ if (action === 'get') {
152
+ const nodes = Object.values(store.nodes);
153
+ const avgLoad = nodes.length > 0
154
+ ? nodes.reduce((sum, n) => sum + n.load, 0) / nodes.length
155
+ : 0;
156
+ return {
157
+ success: true,
158
+ loadBalance: store.loadBalance,
159
+ metrics: {
160
+ nodeCount: nodes.length,
161
+ avgLoad,
162
+ maxLoad: nodes.length > 0 ? Math.max(...nodes.map(n => n.load)) : 0,
163
+ minLoad: nodes.length > 0 ? Math.min(...nodes.map(n => n.load)) : 0,
164
+ },
165
+ };
166
+ }
167
+ if (action === 'set') {
168
+ if (input.algorithm)
169
+ store.loadBalance.algorithm = input.algorithm;
170
+ if (input.weights)
171
+ store.loadBalance.weights = input.weights;
172
+ saveCoordStore(store);
173
+ return {
174
+ success: true,
175
+ action: 'updated',
176
+ loadBalance: store.loadBalance,
177
+ };
178
+ }
179
+ if (action === 'distribute') {
180
+ const task = input.task;
181
+ const nodes = Object.values(store.nodes).filter(n => n.status === 'active');
182
+ if (nodes.length === 0) {
183
+ return { success: false, error: 'No active nodes available' };
217
184
  }
218
- if (action === 'set') {
219
- if (input.algorithm)
220
- store.loadBalance.algorithm = input.algorithm;
221
- if (input.weights)
222
- store.loadBalance.weights = input.weights;
223
- saveCoordStore(store);
224
- return [2 /*return*/, {
225
- success: true,
226
- action: 'updated',
227
- loadBalance: store.loadBalance
228
- }];
185
+ // Select node based on algorithm
186
+ let selectedNode;
187
+ const algorithm = store.loadBalance.algorithm;
188
+ if (algorithm === 'least-connections' || algorithm === 'adaptive') {
189
+ selectedNode = nodes.reduce((min, n) => n.load < min.load ? n : min);
229
190
  }
230
- if (action === 'distribute') {
231
- task = input.task;
232
- nodes = Object.values(store.nodes).filter(function (n) { return n.status === 'active'; });
233
- if (nodes.length === 0) {
234
- return [2 /*return*/, { success: false, error: 'No active nodes available' }];
235
- }
236
- selectedNode = void 0;
237
- algorithm = store.loadBalance.algorithm;
238
- if (algorithm === 'least-connections' || algorithm === 'adaptive') {
239
- selectedNode = nodes.reduce(function (min, n) { return n.load < min.load ? n : min; });
240
- }
241
- else if (algorithm === 'weighted') {
242
- weights_1 = store.loadBalance.weights;
243
- selectedNode = nodes.reduce(function (max, n) { return (weights_1[n.id] || 1) > (weights_1[max.id] || 1) ? n : max; });
244
- }
245
- else {
246
- // Round robin - just pick first active
247
- selectedNode = nodes[0];
248
- }
249
- // Update load
250
- selectedNode.load += 1;
251
- saveCoordStore(store);
252
- return [2 /*return*/, {
253
- success: true,
254
- action: 'distributed',
255
- task: task,
256
- assignedTo: selectedNode.id,
257
- algorithm: algorithm,
258
- nodeLoad: selectedNode.load
259
- }];
191
+ else if (algorithm === 'weighted') {
192
+ const weights = store.loadBalance.weights;
193
+ selectedNode = nodes.reduce((max, n) => (weights[n.id] || 1) > (weights[max.id] || 1) ? n : max);
260
194
  }
261
- return [2 /*return*/, { success: false, error: 'Unknown action' }];
262
- });
263
- }); }
195
+ else {
196
+ // Round robin - just pick first active
197
+ selectedNode = nodes[0];
198
+ }
199
+ // Update load
200
+ selectedNode.load += 1;
201
+ saveCoordStore(store);
202
+ return {
203
+ success: true,
204
+ action: 'distributed',
205
+ task,
206
+ assignedTo: selectedNode.id,
207
+ algorithm,
208
+ nodeLoad: selectedNode.load,
209
+ };
210
+ }
211
+ return { success: false, error: 'Unknown action' };
212
+ },
264
213
  },
265
214
  {
266
215
  name: 'coordination_sync',
@@ -269,68 +218,59 @@ export var coordinationTools = [
269
218
  inputSchema: {
270
219
  type: 'object',
271
220
  properties: {
272
- action: { type: 'string', "enum": ['status', 'trigger', 'resolve'], description: 'Action to perform' },
221
+ action: { type: 'string', enum: ['status', 'trigger', 'resolve'], description: 'Action to perform' },
273
222
  force: { type: 'boolean', description: 'Force synchronization' },
274
- conflictResolution: { type: 'string', "enum": ['latest', 'merge', 'manual'], description: 'Conflict resolution strategy' }
275
- }
223
+ conflictResolution: { type: 'string', enum: ['latest', 'merge', 'manual'], description: 'Conflict resolution strategy' },
224
+ },
276
225
  },
277
- handler: function (input) { return __awaiter(void 0, void 0, void 0, function () {
278
- var store, action, timeSinceSync, strategy, resolved;
279
- return __generator(this, function (_a) {
280
- switch (_a.label) {
281
- case 0:
282
- store = loadCoordStore();
283
- action = input.action || 'status';
284
- if (action === 'status') {
285
- timeSinceSync = Date.now() - new Date(store.sync.lastSync).getTime();
286
- return [2 /*return*/, {
287
- success: true,
288
- sync: store.sync,
289
- timeSinceSync: Math.floor(timeSinceSync / 1000) + "s",
290
- status: store.sync.conflicts > 0 ? 'conflicts' : store.sync.pendingChanges > 0 ? 'pending' : 'synced'
291
- }];
292
- }
293
- if (!(action === 'trigger')) return [3 /*break*/, 2];
294
- store.sync.syncCount++;
295
- store.sync.lastSync = new Date().toISOString();
296
- store.sync.pendingChanges = 0;
297
- // Simulate sync
298
- return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 50); })];
299
- case 1:
300
- // Simulate sync
301
- _a.sent();
302
- saveCoordStore(store);
303
- return [2 /*return*/, {
304
- success: true,
305
- action: 'synchronized',
306
- syncCount: store.sync.syncCount,
307
- syncedAt: store.sync.lastSync,
308
- nodesSync: Object.keys(store.nodes).length
309
- }];
310
- case 2:
311
- if (action === 'resolve') {
312
- strategy = input.conflictResolution || 'latest';
313
- if (store.sync.conflicts > 0) {
314
- resolved = store.sync.conflicts;
315
- store.sync.conflicts = 0;
316
- saveCoordStore(store);
317
- return [2 /*return*/, {
318
- success: true,
319
- action: 'resolved',
320
- strategy: strategy,
321
- conflictsResolved: resolved
322
- }];
323
- }
324
- return [2 /*return*/, {
325
- success: true,
326
- action: 'resolve',
327
- message: 'No conflicts to resolve'
328
- }];
329
- }
330
- return [2 /*return*/, { success: false, error: 'Unknown action' }];
226
+ handler: async (input) => {
227
+ const store = loadCoordStore();
228
+ const action = input.action || 'status';
229
+ if (action === 'status') {
230
+ const timeSinceSync = Date.now() - new Date(store.sync.lastSync).getTime();
231
+ return {
232
+ success: true,
233
+ sync: store.sync,
234
+ timeSinceSync: `${Math.floor(timeSinceSync / 1000)}s`,
235
+ status: store.sync.conflicts > 0 ? 'conflicts' : store.sync.pendingChanges > 0 ? 'pending' : 'synced',
236
+ };
237
+ }
238
+ if (action === 'trigger') {
239
+ store.sync.syncCount++;
240
+ store.sync.lastSync = new Date().toISOString();
241
+ store.sync.pendingChanges = 0;
242
+ // Simulate sync
243
+ await new Promise(resolve => setTimeout(resolve, 50));
244
+ saveCoordStore(store);
245
+ return {
246
+ success: true,
247
+ action: 'synchronized',
248
+ syncCount: store.sync.syncCount,
249
+ syncedAt: store.sync.lastSync,
250
+ nodesSync: Object.keys(store.nodes).length,
251
+ };
252
+ }
253
+ if (action === 'resolve') {
254
+ const strategy = input.conflictResolution || 'latest';
255
+ if (store.sync.conflicts > 0) {
256
+ const resolved = store.sync.conflicts;
257
+ store.sync.conflicts = 0;
258
+ saveCoordStore(store);
259
+ return {
260
+ success: true,
261
+ action: 'resolved',
262
+ strategy,
263
+ conflictsResolved: resolved,
264
+ };
331
265
  }
332
- });
333
- }); }
266
+ return {
267
+ success: true,
268
+ action: 'resolve',
269
+ message: 'No conflicts to resolve',
270
+ };
271
+ }
272
+ return { success: false, error: 'Unknown action' };
273
+ },
334
274
  },
335
275
  {
336
276
  name: 'coordination_node',
@@ -339,77 +279,74 @@ export var coordinationTools = [
339
279
  inputSchema: {
340
280
  type: 'object',
341
281
  properties: {
342
- action: { type: 'string', "enum": ['list', 'add', 'remove', 'heartbeat'], description: 'Action to perform' },
282
+ action: { type: 'string', enum: ['list', 'add', 'remove', 'heartbeat'], description: 'Action to perform' },
343
283
  nodeId: { type: 'string', description: 'Node ID' },
344
- status: { type: 'string', description: 'Node status' }
345
- }
284
+ status: { type: 'string', description: 'Node status' },
285
+ },
346
286
  },
347
- handler: function (input) { return __awaiter(void 0, void 0, void 0, function () {
348
- var store, action, nodes, nodeId, nodeId, nodeId;
349
- return __generator(this, function (_a) {
350
- store = loadCoordStore();
351
- action = input.action || 'list';
352
- if (action === 'list') {
353
- nodes = Object.values(store.nodes);
354
- return [2 /*return*/, {
355
- success: true,
356
- nodes: nodes.map(function (n) { return ({
357
- id: n.id,
358
- status: n.status,
359
- load: n.load,
360
- lastHeartbeat: n.lastHeartbeat
361
- }); }),
362
- total: nodes.length,
363
- active: nodes.filter(function (n) { return n.status === 'active'; }).length
364
- }];
365
- }
366
- if (action === 'add') {
367
- nodeId = input.nodeId || "node-" + Date.now();
368
- store.nodes[nodeId] = {
369
- id: nodeId,
370
- status: 'active',
371
- load: 0,
372
- lastHeartbeat: new Date().toISOString()
373
- };
374
- saveCoordStore(store);
375
- return [2 /*return*/, {
376
- success: true,
377
- action: 'added',
378
- nodeId: nodeId,
379
- totalNodes: Object.keys(store.nodes).length
380
- }];
287
+ handler: async (input) => {
288
+ const store = loadCoordStore();
289
+ const action = input.action || 'list';
290
+ if (action === 'list') {
291
+ const nodes = Object.values(store.nodes);
292
+ return {
293
+ success: true,
294
+ nodes: nodes.map(n => ({
295
+ id: n.id,
296
+ status: n.status,
297
+ load: n.load,
298
+ lastHeartbeat: n.lastHeartbeat,
299
+ })),
300
+ total: nodes.length,
301
+ active: nodes.filter(n => n.status === 'active').length,
302
+ };
303
+ }
304
+ if (action === 'add') {
305
+ const nodeId = input.nodeId || `node-${Date.now()}`;
306
+ store.nodes[nodeId] = {
307
+ id: nodeId,
308
+ status: 'active',
309
+ load: 0,
310
+ lastHeartbeat: new Date().toISOString(),
311
+ };
312
+ saveCoordStore(store);
313
+ return {
314
+ success: true,
315
+ action: 'added',
316
+ nodeId,
317
+ totalNodes: Object.keys(store.nodes).length,
318
+ };
319
+ }
320
+ if (action === 'remove') {
321
+ const nodeId = input.nodeId;
322
+ if (!store.nodes[nodeId]) {
323
+ return { success: false, error: 'Node not found' };
381
324
  }
382
- if (action === 'remove') {
383
- nodeId = input.nodeId;
384
- if (!store.nodes[nodeId]) {
385
- return [2 /*return*/, { success: false, error: 'Node not found' }];
386
- }
387
- delete store.nodes[nodeId];
325
+ delete store.nodes[nodeId];
326
+ saveCoordStore(store);
327
+ return {
328
+ success: true,
329
+ action: 'removed',
330
+ nodeId,
331
+ totalNodes: Object.keys(store.nodes).length,
332
+ };
333
+ }
334
+ if (action === 'heartbeat') {
335
+ const nodeId = input.nodeId;
336
+ if (store.nodes[nodeId]) {
337
+ store.nodes[nodeId].lastHeartbeat = new Date().toISOString();
338
+ store.nodes[nodeId].status = 'active';
388
339
  saveCoordStore(store);
389
- return [2 /*return*/, {
390
- success: true,
391
- action: 'removed',
392
- nodeId: nodeId,
393
- totalNodes: Object.keys(store.nodes).length
394
- }];
395
- }
396
- if (action === 'heartbeat') {
397
- nodeId = input.nodeId;
398
- if (store.nodes[nodeId]) {
399
- store.nodes[nodeId].lastHeartbeat = new Date().toISOString();
400
- store.nodes[nodeId].status = 'active';
401
- saveCoordStore(store);
402
- }
403
- return [2 /*return*/, {
404
- success: true,
405
- action: 'heartbeat',
406
- nodeId: nodeId,
407
- timestamp: new Date().toISOString()
408
- }];
409
340
  }
410
- return [2 /*return*/, { success: false, error: 'Unknown action' }];
411
- });
412
- }); }
341
+ return {
342
+ success: true,
343
+ action: 'heartbeat',
344
+ nodeId,
345
+ timestamp: new Date().toISOString(),
346
+ };
347
+ }
348
+ return { success: false, error: 'Unknown action' };
349
+ },
413
350
  },
414
351
  {
415
352
  name: 'coordination_consensus',
@@ -418,17 +355,26 @@ export var coordinationTools = [
418
355
  inputSchema: {
419
356
  type: 'object',
420
357
  properties: {
421
- action: { type: 'string', "enum": ['status', 'propose', 'vote', 'commit'], description: 'Action to perform' },
358
+ action: { type: 'string', enum: ['status', 'propose', 'vote', 'commit'], description: 'Action to perform' },
422
359
  proposal: { type: 'object', description: 'Proposal data (for propose)' },
423
360
  proposalId: { type: 'string', description: 'Proposal ID (for vote/commit/status)' },
424
- vote: { type: 'string', "enum": ['accept', 'reject'], description: 'Vote' },
361
+ vote: { type: 'string', enum: ['accept', 'reject'], description: 'Vote' },
425
362
  voterId: { type: 'string', description: 'Voter node ID' },
426
- strategy: { type: 'string', "enum": ['bft', 'raft', 'quorum'], description: 'Consensus strategy (default: raft)' },
427
- quorumPreset: { type: 'string', "enum": ['unanimous', 'majority', 'supermajority'], description: 'Quorum threshold preset (default: majority)' },
428
- term: { type: 'number', description: 'Term number (for raft strategy)' }
429
- }
363
+ strategy: { type: 'string', enum: ['bft', 'raft', 'quorum'], description: 'Consensus strategy (default: raft)' },
364
+ quorumPreset: { type: 'string', enum: ['unanimous', 'majority', 'supermajority'], description: 'Quorum threshold preset (default: majority)' },
365
+ term: { type: 'number', description: 'Term number (for raft strategy)' },
366
+ },
430
367
  },
431
- handler: function (input) { return __awaiter(void 0, void 0, void 0, function () {
368
+ handler: async (input) => {
369
+ const store = loadCoordStore();
370
+ const action = input.action || 'status';
371
+ const strategy = input.strategy || 'raft';
372
+ const nodeCount = Object.keys(store.nodes).length || 1;
373
+ // Initialize consensus storage in the coordination store if missing
374
+ if (!store.consensus) {
375
+ store.consensus = { pending: [], history: [] };
376
+ }
377
+ const consensus = store.consensus;
432
378
  function calcRequired(strat, total, preset) {
433
379
  if (total <= 0)
434
380
  return 1;
@@ -442,211 +388,199 @@ export var coordinationTools = [
442
388
  }
443
389
  return Math.floor(total / 2) + 1;
444
390
  }
445
- var store, action, strategy, nodeCount, consensus, p, votesFor, votesAgainst, h, quorum, proposalId, quorumPreset, term_1, required, existing, p_1, voterId, voteValue, pStrategy, required, _i, _a, other, votesFor, votesAgainst, resolved, result, h;
446
- var _b;
447
- return __generator(this, function (_c) {
448
- store = loadCoordStore();
449
- action = input.action || 'status';
450
- strategy = input.strategy || 'raft';
451
- nodeCount = Object.keys(store.nodes).length || 1;
452
- // Initialize consensus storage in the coordination store if missing
453
- if (!store.consensus) {
454
- store.consensus = { pending: [], history: [] };
391
+ if (action === 'status') {
392
+ if (input.proposalId) {
393
+ // Status for specific proposal
394
+ const p = consensus.pending.find(x => x.proposalId === input.proposalId);
395
+ if (p) {
396
+ const votesFor = Object.values(p.votes).filter(v => v).length;
397
+ const votesAgainst = Object.values(p.votes).filter(v => !v).length;
398
+ return {
399
+ success: true,
400
+ proposalId: p.proposalId,
401
+ strategy: p.strategy,
402
+ status: p.status,
403
+ votesFor,
404
+ votesAgainst,
405
+ required: calcRequired(p.strategy, nodeCount, p.quorumPreset),
406
+ totalNodes: nodeCount,
407
+ resolved: false,
408
+ };
409
+ }
410
+ const h = consensus.history.find(x => x.proposalId === input.proposalId);
411
+ if (h)
412
+ return { success: true, ...h, resolved: true, historical: true };
413
+ return { success: false, error: 'Proposal not found' };
455
414
  }
456
- consensus = store.consensus;
457
- if (action === 'status') {
458
- if (input.proposalId) {
459
- p = consensus.pending.find(function (x) { return x.proposalId === input.proposalId; });
460
- if (p) {
461
- votesFor = Object.values(p.votes).filter(function (v) { return v; }).length;
462
- votesAgainst = Object.values(p.votes).filter(function (v) { return !v; }).length;
463
- return [2 /*return*/, {
464
- success: true,
465
- proposalId: p.proposalId,
466
- strategy: p.strategy,
467
- status: p.status,
468
- votesFor: votesFor,
469
- votesAgainst: votesAgainst,
470
- required: calcRequired(p.strategy, nodeCount, p.quorumPreset),
471
- totalNodes: nodeCount,
472
- resolved: false
473
- }];
474
- }
475
- h = consensus.history.find(function (x) { return x.proposalId === input.proposalId; });
476
- if (h)
477
- return [2 /*return*/, __assign(__assign({ success: true }, h), { resolved: true, historical: true })];
478
- return [2 /*return*/, { success: false, error: 'Proposal not found' }];
415
+ const quorum = calcRequired(strategy, nodeCount);
416
+ return {
417
+ success: true,
418
+ algorithm: store.topology.consensusAlgorithm,
419
+ strategy,
420
+ nodes: nodeCount,
421
+ quorum,
422
+ pendingProposals: consensus.pending.length,
423
+ resolvedProposals: consensus.history.length,
424
+ status: nodeCount >= quorum ? 'operational' : 'degraded',
425
+ };
426
+ }
427
+ if (action === 'propose') {
428
+ const proposalId = `proposal-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
429
+ const quorumPreset = input.quorumPreset || 'majority';
430
+ const term = input.term || 1;
431
+ const required = calcRequired(strategy, nodeCount, quorumPreset);
432
+ // Raft: one pending proposal per term
433
+ if (strategy === 'raft') {
434
+ const existing = consensus.pending.find(p => p.strategy === 'raft' && p.term === term);
435
+ if (existing) {
436
+ return {
437
+ success: false,
438
+ error: `Raft term ${term} already has pending proposal: ${existing.proposalId}`,
439
+ existingProposalId: existing.proposalId,
440
+ };
479
441
  }
480
- quorum = calcRequired(strategy, nodeCount);
481
- return [2 /*return*/, {
482
- success: true,
483
- algorithm: store.topology.consensusAlgorithm,
484
- strategy: strategy,
485
- nodes: nodeCount,
486
- quorum: quorum,
487
- pendingProposals: consensus.pending.length,
488
- resolvedProposals: consensus.history.length,
489
- status: nodeCount >= quorum ? 'operational' : 'degraded'
490
- }];
491
442
  }
492
- if (action === 'propose') {
493
- proposalId = "proposal-" + Date.now() + "-" + Math.random().toString(36).slice(2, 8);
494
- quorumPreset = input.quorumPreset || 'majority';
495
- term_1 = input.term || 1;
496
- required = calcRequired(strategy, nodeCount, quorumPreset);
497
- // Raft: one pending proposal per term
498
- if (strategy === 'raft') {
499
- existing = consensus.pending.find(function (p) { return p.strategy === 'raft' && p.term === term_1; });
500
- if (existing) {
501
- return [2 /*return*/, {
502
- success: false,
503
- error: "Raft term " + term_1 + " already has pending proposal: " + existing.proposalId,
504
- existingProposalId: existing.proposalId
505
- }];
506
- }
443
+ consensus.pending.push({
444
+ proposalId,
445
+ type: 'coordination',
446
+ proposal: input.proposal,
447
+ proposedBy: input.voterId || 'system',
448
+ proposedAt: new Date().toISOString(),
449
+ votes: {},
450
+ status: 'pending',
451
+ strategy,
452
+ term: strategy === 'raft' ? term : undefined,
453
+ quorumPreset: strategy === 'quorum' ? quorumPreset : undefined,
454
+ byzantineVoters: strategy === 'bft' ? [] : undefined,
455
+ });
456
+ saveCoordStore(store);
457
+ return {
458
+ success: true,
459
+ action: 'proposed',
460
+ proposalId,
461
+ proposal: input.proposal,
462
+ strategy,
463
+ status: 'pending',
464
+ required,
465
+ totalNodes: nodeCount,
466
+ term: strategy === 'raft' ? term : undefined,
467
+ };
468
+ }
469
+ if (action === 'vote') {
470
+ const p = consensus.pending.find(x => x.proposalId === input.proposalId);
471
+ if (!p)
472
+ return { success: false, error: 'Proposal not found or already resolved' };
473
+ const voterId = input.voterId;
474
+ if (!voterId)
475
+ return { success: false, error: 'voterId is required' };
476
+ const voteValue = input.vote === 'accept';
477
+ const pStrategy = p.strategy || 'raft';
478
+ const required = calcRequired(pStrategy, nodeCount, p.quorumPreset);
479
+ // Double-vote prevention
480
+ if (voterId in p.votes) {
481
+ if (pStrategy === 'bft' && p.votes[voterId] !== voteValue) {
482
+ if (!p.byzantineVoters)
483
+ p.byzantineVoters = [];
484
+ if (!p.byzantineVoters.includes(voterId))
485
+ p.byzantineVoters.push(voterId);
486
+ delete p.votes[voterId];
487
+ saveCoordStore(store);
488
+ return {
489
+ success: false,
490
+ byzantineDetected: true,
491
+ message: `Byzantine behavior: voter ${voterId} attempted conflicting vote. Vote invalidated.`,
492
+ byzantineVoters: p.byzantineVoters,
493
+ };
507
494
  }
508
- consensus.pending.push({
509
- proposalId: proposalId,
510
- type: 'coordination',
511
- proposal: input.proposal,
512
- proposedBy: input.voterId || 'system',
513
- proposedAt: new Date().toISOString(),
514
- votes: {},
515
- status: 'pending',
516
- strategy: strategy,
517
- term: strategy === 'raft' ? term_1 : undefined,
518
- quorumPreset: strategy === 'quorum' ? quorumPreset : undefined,
519
- byzantineVoters: strategy === 'bft' ? [] : undefined
520
- });
521
- saveCoordStore(store);
522
- return [2 /*return*/, {
523
- success: true,
524
- action: 'proposed',
525
- proposalId: proposalId,
526
- proposal: input.proposal,
527
- strategy: strategy,
528
- status: 'pending',
529
- required: required,
530
- totalNodes: nodeCount,
531
- term: strategy === 'raft' ? term_1 : undefined
532
- }];
495
+ return { success: false, error: `Voter ${voterId} has already voted on this proposal` };
533
496
  }
534
- if (action === 'vote') {
535
- p_1 = consensus.pending.find(function (x) { return x.proposalId === input.proposalId; });
536
- if (!p_1)
537
- return [2 /*return*/, { success: false, error: 'Proposal not found or already resolved' }];
538
- voterId = input.voterId;
539
- if (!voterId)
540
- return [2 /*return*/, { success: false, error: 'voterId is required' }];
541
- voteValue = input.vote === 'accept';
542
- pStrategy = p_1.strategy || 'raft';
543
- required = calcRequired(pStrategy, nodeCount, p_1.quorumPreset);
544
- // Double-vote prevention
545
- if (voterId in p_1.votes) {
546
- if (pStrategy === 'bft' && p_1.votes[voterId] !== voteValue) {
547
- if (!p_1.byzantineVoters)
548
- p_1.byzantineVoters = [];
549
- if (!p_1.byzantineVoters.includes(voterId))
550
- p_1.byzantineVoters.push(voterId);
551
- delete p_1.votes[voterId];
497
+ // BFT cross-proposal conflict check
498
+ if (pStrategy === 'bft') {
499
+ for (const other of consensus.pending) {
500
+ if (other.proposalId === p.proposalId)
501
+ continue;
502
+ if (voterId in other.votes && other.votes[voterId] !== voteValue) {
503
+ if (!p.byzantineVoters)
504
+ p.byzantineVoters = [];
505
+ if (!p.byzantineVoters.includes(voterId))
506
+ p.byzantineVoters.push(voterId);
552
507
  saveCoordStore(store);
553
- return [2 /*return*/, {
554
- success: false,
555
- byzantineDetected: true,
556
- message: "Byzantine behavior: voter " + voterId + " attempted conflicting vote. Vote invalidated.",
557
- byzantineVoters: p_1.byzantineVoters
558
- }];
559
- }
560
- return [2 /*return*/, { success: false, error: "Voter " + voterId + " has already voted on this proposal" }];
561
- }
562
- // BFT cross-proposal conflict check
563
- if (pStrategy === 'bft') {
564
- for (_i = 0, _a = consensus.pending; _i < _a.length; _i++) {
565
- other = _a[_i];
566
- if (other.proposalId === p_1.proposalId)
567
- continue;
568
- if (voterId in other.votes && other.votes[voterId] !== voteValue) {
569
- if (!p_1.byzantineVoters)
570
- p_1.byzantineVoters = [];
571
- if (!p_1.byzantineVoters.includes(voterId))
572
- p_1.byzantineVoters.push(voterId);
573
- saveCoordStore(store);
574
- return [2 /*return*/, {
575
- success: false,
576
- byzantineDetected: true,
577
- message: "Byzantine behavior: voter " + voterId + " cast conflicting votes across proposals.",
578
- byzantineVoters: p_1.byzantineVoters
579
- }];
580
- }
508
+ return {
509
+ success: false,
510
+ byzantineDetected: true,
511
+ message: `Byzantine behavior: voter ${voterId} cast conflicting votes across proposals.`,
512
+ byzantineVoters: p.byzantineVoters,
513
+ };
581
514
  }
582
515
  }
583
- p_1.votes[voterId] = voteValue;
584
- votesFor = Object.values(p_1.votes).filter(function (v) { return v; }).length;
585
- votesAgainst = Object.values(p_1.votes).filter(function (v) { return !v; }).length;
586
- resolved = false;
587
- result = void 0;
588
- if (votesFor >= required) {
589
- resolved = true;
590
- result = 'approved';
591
- }
592
- else if (votesAgainst >= required) {
593
- resolved = true;
594
- result = 'rejected';
595
- }
596
- else if (pStrategy === 'quorum' && p_1.quorumPreset === 'unanimous' && votesAgainst > 0) {
597
- resolved = true;
598
- result = 'rejected';
599
- }
600
- if (resolved && result) {
601
- p_1.status = result;
602
- consensus.history.push({
603
- proposalId: p_1.proposalId,
604
- result: result,
605
- votes: { "for": votesFor, against: votesAgainst },
606
- decidedAt: new Date().toISOString(),
607
- strategy: pStrategy,
608
- term: p_1.term,
609
- byzantineDetected: ((_b = p_1.byzantineVoters) === null || _b === void 0 ? void 0 : _b.length) ? p_1.byzantineVoters : undefined
610
- });
611
- consensus.pending = consensus.pending.filter(function (x) { return x.proposalId !== p_1.proposalId; });
612
- }
613
- saveCoordStore(store);
614
- return [2 /*return*/, {
615
- success: true,
616
- action: 'voted',
617
- proposalId: p_1.proposalId,
618
- voterId: voterId,
619
- vote: input.vote,
620
- strategy: pStrategy,
621
- votesFor: votesFor,
622
- votesAgainst: votesAgainst,
623
- required: required,
624
- totalNodes: nodeCount,
625
- resolved: resolved,
626
- result: resolved ? result : undefined,
627
- status: p_1.status
628
- }];
629
516
  }
630
- if (action === 'commit') {
631
- // Commit is a no-op confirmation for already-resolved proposals
632
- if (input.proposalId) {
633
- h = consensus.history.find(function (x) { return x.proposalId === input.proposalId; });
634
- if (h) {
635
- return [2 /*return*/, {
636
- success: true,
637
- action: 'committed',
638
- proposalId: input.proposalId,
639
- result: h.result,
640
- committedAt: new Date().toISOString()
641
- }];
642
- }
643
- return [2 /*return*/, { success: false, error: 'Proposal not found in resolved history. Vote must reach quorum first.' }];
517
+ p.votes[voterId] = voteValue;
518
+ const votesFor = Object.values(p.votes).filter(v => v).length;
519
+ const votesAgainst = Object.values(p.votes).filter(v => !v).length;
520
+ // Resolution check
521
+ let resolved = false;
522
+ let result;
523
+ if (votesFor >= required) {
524
+ resolved = true;
525
+ result = 'approved';
526
+ }
527
+ else if (votesAgainst >= required) {
528
+ resolved = true;
529
+ result = 'rejected';
530
+ }
531
+ else if (pStrategy === 'quorum' && p.quorumPreset === 'unanimous' && votesAgainst > 0) {
532
+ resolved = true;
533
+ result = 'rejected';
534
+ }
535
+ if (resolved && result) {
536
+ p.status = result;
537
+ consensus.history.push({
538
+ proposalId: p.proposalId,
539
+ result,
540
+ votes: { for: votesFor, against: votesAgainst },
541
+ decidedAt: new Date().toISOString(),
542
+ strategy: pStrategy,
543
+ term: p.term,
544
+ byzantineDetected: p.byzantineVoters?.length ? p.byzantineVoters : undefined,
545
+ });
546
+ consensus.pending = consensus.pending.filter(x => x.proposalId !== p.proposalId);
547
+ }
548
+ saveCoordStore(store);
549
+ return {
550
+ success: true,
551
+ action: 'voted',
552
+ proposalId: p.proposalId,
553
+ voterId,
554
+ vote: input.vote,
555
+ strategy: pStrategy,
556
+ votesFor,
557
+ votesAgainst,
558
+ required,
559
+ totalNodes: nodeCount,
560
+ resolved,
561
+ result: resolved ? result : undefined,
562
+ status: p.status,
563
+ };
564
+ }
565
+ if (action === 'commit') {
566
+ // Commit is a no-op confirmation for already-resolved proposals
567
+ if (input.proposalId) {
568
+ const h = consensus.history.find(x => x.proposalId === input.proposalId);
569
+ if (h) {
570
+ return {
571
+ success: true,
572
+ action: 'committed',
573
+ proposalId: input.proposalId,
574
+ result: h.result,
575
+ committedAt: new Date().toISOString(),
576
+ };
644
577
  }
645
- return [2 /*return*/, { success: false, error: 'proposalId is required for commit' }];
578
+ return { success: false, error: 'Proposal not found in resolved history. Vote must reach quorum first.' };
646
579
  }
647
- return [2 /*return*/, { success: false, error: 'Unknown action' }];
648
- });
649
- }); }
580
+ return { success: false, error: 'proposalId is required for commit' };
581
+ }
582
+ return { success: false, error: 'Unknown action' };
583
+ },
650
584
  },
651
585
  {
652
586
  name: 'coordination_orchestrate',
@@ -657,31 +591,28 @@ export var coordinationTools = [
657
591
  properties: {
658
592
  task: { type: 'string', description: 'Task to orchestrate' },
659
593
  agents: { type: 'array', items: { type: 'string' }, description: 'Agent IDs to coordinate' },
660
- strategy: { type: 'string', "enum": ['parallel', 'sequential', 'pipeline', 'broadcast'], description: 'Orchestration strategy' },
661
- timeout: { type: 'number', description: 'Timeout in ms' }
594
+ strategy: { type: 'string', enum: ['parallel', 'sequential', 'pipeline', 'broadcast'], description: 'Orchestration strategy' },
595
+ timeout: { type: 'number', description: 'Timeout in ms' },
662
596
  },
663
- required: ['task']
597
+ required: ['task'],
598
+ },
599
+ handler: async (input) => {
600
+ const store = loadCoordStore();
601
+ const task = input.task;
602
+ const agents = input.agents || Object.keys(store.nodes);
603
+ const strategy = input.strategy || 'parallel';
604
+ const orchestrationId = `orch-${Date.now()}`;
605
+ return {
606
+ success: true,
607
+ orchestrationId,
608
+ task,
609
+ strategy,
610
+ agents,
611
+ status: 'initiated',
612
+ topology: store.topology.type,
613
+ estimatedCompletion: `${agents.length * (strategy === 'sequential' ? 100 : 50)}ms`,
614
+ };
664
615
  },
665
- handler: function (input) { return __awaiter(void 0, void 0, void 0, function () {
666
- var store, task, agents, strategy, orchestrationId;
667
- return __generator(this, function (_a) {
668
- store = loadCoordStore();
669
- task = input.task;
670
- agents = input.agents || Object.keys(store.nodes);
671
- strategy = input.strategy || 'parallel';
672
- orchestrationId = "orch-" + Date.now();
673
- return [2 /*return*/, {
674
- success: true,
675
- orchestrationId: orchestrationId,
676
- task: task,
677
- strategy: strategy,
678
- agents: agents,
679
- status: 'initiated',
680
- topology: store.topology.type,
681
- estimatedCompletion: agents.length * (strategy === 'sequential' ? 100 : 50) + "ms"
682
- }];
683
- });
684
- }); }
685
616
  },
686
617
  {
687
618
  name: 'coordination_metrics',
@@ -690,48 +621,45 @@ export var coordinationTools = [
690
621
  inputSchema: {
691
622
  type: 'object',
692
623
  properties: {
693
- metric: { type: 'string', "enum": ['all', 'latency', 'throughput', 'availability'], description: 'Metric type' },
694
- timeRange: { type: 'string', description: 'Time range' }
624
+ metric: { type: 'string', enum: ['all', 'latency', 'throughput', 'availability'], description: 'Metric type' },
625
+ timeRange: { type: 'string', description: 'Time range' },
626
+ },
627
+ },
628
+ handler: async (input) => {
629
+ const store = loadCoordStore();
630
+ const metric = input.metric || 'all';
631
+ const nodes = Object.values(store.nodes);
632
+ const activeNodes = nodes.filter(n => n.status === 'active');
633
+ const metrics = {
634
+ latency: {
635
+ avg: 25 + Math.random() * 20,
636
+ p50: 20 + Math.random() * 15,
637
+ p95: 50 + Math.random() * 30,
638
+ p99: 100 + Math.random() * 50,
639
+ unit: 'ms',
640
+ },
641
+ throughput: {
642
+ current: Math.floor(Math.random() * 1000) + 500,
643
+ peak: Math.floor(Math.random() * 2000) + 1000,
644
+ avg: Math.floor(Math.random() * 800) + 400,
645
+ unit: 'ops/s',
646
+ },
647
+ availability: {
648
+ uptime: 99.9 + Math.random() * 0.09,
649
+ activeNodes: activeNodes.length,
650
+ totalNodes: nodes.length,
651
+ syncStatus: store.sync.conflicts === 0 ? 'healthy' : 'conflicts',
652
+ },
653
+ };
654
+ if (metric === 'all') {
655
+ return { success: true, metrics };
695
656
  }
657
+ return {
658
+ success: true,
659
+ metric,
660
+ data: metrics[metric],
661
+ };
696
662
  },
697
- handler: function (input) { return __awaiter(void 0, void 0, void 0, function () {
698
- var store, metric, nodes, activeNodes, metrics;
699
- return __generator(this, function (_a) {
700
- store = loadCoordStore();
701
- metric = input.metric || 'all';
702
- nodes = Object.values(store.nodes);
703
- activeNodes = nodes.filter(function (n) { return n.status === 'active'; });
704
- metrics = {
705
- latency: {
706
- avg: 25 + Math.random() * 20,
707
- p50: 20 + Math.random() * 15,
708
- p95: 50 + Math.random() * 30,
709
- p99: 100 + Math.random() * 50,
710
- unit: 'ms'
711
- },
712
- throughput: {
713
- current: Math.floor(Math.random() * 1000) + 500,
714
- peak: Math.floor(Math.random() * 2000) + 1000,
715
- avg: Math.floor(Math.random() * 800) + 400,
716
- unit: 'ops/s'
717
- },
718
- availability: {
719
- uptime: 99.9 + Math.random() * 0.09,
720
- activeNodes: activeNodes.length,
721
- totalNodes: nodes.length,
722
- syncStatus: store.sync.conflicts === 0 ? 'healthy' : 'conflicts'
723
- }
724
- };
725
- if (metric === 'all') {
726
- return [2 /*return*/, { success: true, metrics: metrics }];
727
- }
728
- return [2 /*return*/, {
729
- success: true,
730
- metric: metric,
731
- data: metrics[metric]
732
- }];
733
- });
734
- }); }
735
663
  },
736
664
  ];
737
665
  //# sourceMappingURL=coordination-tools.js.map