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.
- package/dist/src/appliance/gguf-engine.d.ts +91 -0
- package/dist/src/appliance/gguf-engine.d.ts.map +1 -0
- package/dist/src/appliance/gguf-engine.js +286 -525
- package/dist/src/appliance/gguf-engine.js.map +1 -1
- package/dist/src/appliance/ruvllm-bridge.d.ts +102 -0
- package/dist/src/appliance/ruvllm-bridge.d.ts.map +1 -0
- package/dist/src/appliance/ruvllm-bridge.js +203 -403
- package/dist/src/appliance/ruvllm-bridge.js.map +1 -1
- package/dist/src/appliance/rvfa-builder.d.ts +44 -0
- package/dist/src/appliance/rvfa-builder.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-builder.js +154 -208
- package/dist/src/appliance/rvfa-builder.js.map +1 -1
- package/dist/src/appliance/rvfa-distribution.d.ts +97 -0
- package/dist/src/appliance/rvfa-distribution.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-distribution.js +260 -423
- package/dist/src/appliance/rvfa-distribution.js.map +1 -1
- package/dist/src/appliance/rvfa-format.d.ts +111 -0
- package/dist/src/appliance/rvfa-format.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-format.js +128 -200
- package/dist/src/appliance/rvfa-format.js.map +1 -1
- package/dist/src/appliance/rvfa-runner.d.ts +69 -0
- package/dist/src/appliance/rvfa-runner.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-runner.js +168 -304
- package/dist/src/appliance/rvfa-runner.js.map +1 -1
- package/dist/src/appliance/rvfa-signing.d.ts +123 -0
- package/dist/src/appliance/rvfa-signing.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-signing.js +173 -295
- package/dist/src/appliance/rvfa-signing.js.map +1 -1
- package/dist/src/benchmarks/pretrain/index.d.ts +58 -0
- package/dist/src/benchmarks/pretrain/index.d.ts.map +1 -0
- package/dist/src/benchmarks/pretrain/index.js +331 -542
- package/dist/src/benchmarks/pretrain/index.js.map +1 -1
- package/dist/src/commands/agent.js +574 -697
- package/dist/src/commands/agent.js.map +1 -1
- package/dist/src/commands/analyze.js +1218 -1548
- package/dist/src/commands/analyze.js.map +1 -1
- package/dist/src/commands/appliance-advanced.js +158 -267
- package/dist/src/commands/appliance-advanced.js.map +1 -1
- package/dist/src/commands/appliance.js +318 -493
- package/dist/src/commands/appliance.js.map +1 -1
- package/dist/src/commands/benchmark.js +372 -523
- package/dist/src/commands/benchmark.js.map +1 -1
- package/dist/src/commands/claims.js +274 -364
- package/dist/src/commands/claims.js.map +1 -1
- package/dist/src/commands/cleanup.js +113 -157
- package/dist/src/commands/cleanup.js.map +1 -1
- package/dist/src/commands/completions.js +477 -118
- package/dist/src/commands/completions.js.map +1 -1
- package/dist/src/commands/config.js +237 -303
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/daemon.js +487 -596
- package/dist/src/commands/daemon.js.map +1 -1
- package/dist/src/commands/deployment.js +194 -275
- package/dist/src/commands/deployment.js.map +1 -1
- package/dist/src/commands/doctor.js +504 -686
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/embeddings.js +1293 -1543
- package/dist/src/commands/embeddings.js.map +1 -1
- package/dist/src/commands/guidance.js +449 -596
- package/dist/src/commands/guidance.js.map +1 -1
- package/dist/src/commands/hive-mind.js +854 -938
- package/dist/src/commands/hive-mind.js.map +1 -1
- package/dist/src/commands/hooks.js +3112 -3519
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.d.ts +115 -0
- package/dist/src/commands/index.d.ts.map +1 -0
- package/dist/src/commands/index.js +126 -308
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/init.js +788 -940
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/issues.js +383 -558
- package/dist/src/commands/issues.js.map +1 -1
- package/dist/src/commands/mcp.js +493 -605
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/memory.js +833 -1026
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/commands/migrate.js +282 -347
- package/dist/src/commands/migrate.js.map +1 -1
- package/dist/src/commands/neural.js +1289 -1563
- package/dist/src/commands/neural.js.map +1 -1
- package/dist/src/commands/performance.js +497 -643
- package/dist/src/commands/performance.js.map +1 -1
- package/dist/src/commands/plugins.js +668 -841
- package/dist/src/commands/plugins.js.map +1 -1
- package/dist/src/commands/process.js +392 -447
- package/dist/src/commands/process.js.map +1 -1
- package/dist/src/commands/progress.js +162 -256
- package/dist/src/commands/progress.js.map +1 -1
- package/dist/src/commands/providers.js +150 -220
- package/dist/src/commands/providers.js.map +1 -1
- package/dist/src/commands/route.js +520 -665
- package/dist/src/commands/route.js.map +1 -1
- package/dist/src/commands/ruvector/backup.js +505 -651
- package/dist/src/commands/ruvector/backup.js.map +1 -1
- package/dist/src/commands/ruvector/benchmark.js +349 -401
- package/dist/src/commands/ruvector/benchmark.js.map +1 -1
- package/dist/src/commands/ruvector/import.js +224 -266
- package/dist/src/commands/ruvector/import.js.map +1 -1
- package/dist/src/commands/ruvector/index.js +37 -75
- package/dist/src/commands/ruvector/index.js.map +1 -1
- package/dist/src/commands/ruvector/init.js +336 -359
- package/dist/src/commands/ruvector/init.js.map +1 -1
- package/dist/src/commands/ruvector/migrate.js +335 -322
- package/dist/src/commands/ruvector/migrate.js.map +1 -1
- package/dist/src/commands/ruvector/optimize.js +375 -431
- package/dist/src/commands/ruvector/optimize.js.map +1 -1
- package/dist/src/commands/ruvector/setup.js +703 -117
- package/dist/src/commands/ruvector/setup.js.map +1 -1
- package/dist/src/commands/ruvector/status.js +364 -419
- package/dist/src/commands/ruvector/status.js.map +1 -1
- package/dist/src/commands/security.js +485 -608
- package/dist/src/commands/security.js.map +1 -1
- package/dist/src/commands/session.js +504 -626
- package/dist/src/commands/session.js.map +1 -1
- package/dist/src/commands/start.js +267 -364
- package/dist/src/commands/start.js.map +1 -1
- package/dist/src/commands/status.js +380 -486
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/commands/swarm.js +408 -488
- package/dist/src/commands/swarm.js.map +1 -1
- package/dist/src/commands/task.js +423 -538
- package/dist/src/commands/task.js.map +1 -1
- package/dist/src/commands/transfer-store.js +322 -412
- package/dist/src/commands/transfer-store.js.map +1 -1
- package/dist/src/commands/update.js +196 -291
- package/dist/src/commands/update.js.map +1 -1
- package/dist/src/commands/workflow.js +386 -486
- package/dist/src/commands/workflow.js.map +1 -1
- package/dist/src/config-adapter.d.ts +15 -0
- package/dist/src/config-adapter.d.ts.map +1 -0
- package/dist/src/config-adapter.js +38 -39
- package/dist/src/config-adapter.js.map +1 -1
- package/dist/src/index.d.ts +77 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +309 -411
- package/dist/src/index.js.map +1 -1
- package/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
- package/dist/src/infrastructure/in-memory-repositories.d.ts.map +1 -0
- package/dist/src/infrastructure/in-memory-repositories.js +246 -507
- package/dist/src/infrastructure/in-memory-repositories.js.map +1 -1
- package/dist/src/init/claudemd-generator.d.ts +25 -0
- package/dist/src/init/claudemd-generator.d.ts.map +1 -0
- package/dist/src/init/claudemd-generator.js +368 -78
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/init/executor.d.ts +41 -0
- package/dist/src/init/executor.d.ts.map +1 -0
- package/dist/src/init/executor.js +1307 -996
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/helpers-generator.d.ts +60 -0
- package/dist/src/init/helpers-generator.d.ts.map +1 -0
- package/dist/src/init/helpers-generator.js +657 -12
- package/dist/src/init/helpers-generator.js.map +1 -1
- package/dist/src/init/index.d.ts +1 -1
- package/dist/src/init/index.d.ts.map +1 -1
- package/dist/src/init/index.js +1 -1
- package/dist/src/init/index.js.map +1 -1
- package/dist/src/init/mcp-generator.js +33 -37
- package/dist/src/init/mcp-generator.js.map +1 -1
- package/dist/src/init/settings-generator.js +76 -77
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/init/statusline-generator.js +801 -3
- package/dist/src/init/statusline-generator.js.map +1 -1
- package/dist/src/init/types.d.ts +1 -1
- package/dist/src/init/types.d.ts.map +1 -1
- package/dist/src/init/types.js +76 -59
- package/dist/src/init/types.js.map +1 -1
- package/dist/src/mcp-client.d.ts +92 -0
- package/dist/src/mcp-client.d.ts.map +1 -0
- package/dist/src/mcp-client.js +81 -125
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-server.d.ts +161 -0
- package/dist/src/mcp-server.d.ts.map +1 -0
- package/dist/src/mcp-server.js +470 -757
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +391 -492
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/agentdb-tools.js +332 -533
- package/dist/src/mcp-tools/agentdb-tools.js.map +1 -1
- package/dist/src/mcp-tools/analyze-tools.js +172 -236
- package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
- package/dist/src/mcp-tools/auto-install.d.ts +83 -0
- package/dist/src/mcp-tools/auto-install.d.ts.map +1 -0
- package/dist/src/mcp-tools/auto-install.js +80 -142
- package/dist/src/mcp-tools/auto-install.js.map +1 -1
- package/dist/src/mcp-tools/browser-tools.js +252 -375
- package/dist/src/mcp-tools/browser-tools.js.map +1 -1
- package/dist/src/mcp-tools/claims-tools.js +473 -565
- package/dist/src/mcp-tools/claims-tools.js.map +1 -1
- package/dist/src/mcp-tools/config-tools.js +197 -272
- package/dist/src/mcp-tools/config-tools.js.map +1 -1
- package/dist/src/mcp-tools/coordination-tools.js +500 -572
- package/dist/src/mcp-tools/coordination-tools.js.map +1 -1
- package/dist/src/mcp-tools/daa-tools.js +286 -364
- package/dist/src/mcp-tools/daa-tools.js.map +1 -1
- package/dist/src/mcp-tools/embeddings-tools.js +582 -693
- package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
- package/dist/src/mcp-tools/github-tools.js +260 -311
- package/dist/src/mcp-tools/github-tools.js.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.js +573 -640
- package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +2215 -2648
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +350 -505
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/neural-tools.js +315 -412
- package/dist/src/mcp-tools/neural-tools.js.map +1 -1
- package/dist/src/mcp-tools/performance-tools.js +420 -480
- package/dist/src/mcp-tools/performance-tools.js.map +1 -1
- package/dist/src/mcp-tools/progress-tools.js +204 -278
- package/dist/src/mcp-tools/progress-tools.js.map +1 -1
- package/dist/src/mcp-tools/ruvllm-tools.js +163 -279
- package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -1
- package/dist/src/mcp-tools/security-tools.js +297 -429
- package/dist/src/mcp-tools/security-tools.js.map +1 -1
- package/dist/src/mcp-tools/session-tools.js +185 -234
- package/dist/src/mcp-tools/session-tools.js.map +1 -1
- package/dist/src/mcp-tools/swarm-tools.js +207 -260
- package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
- package/dist/src/mcp-tools/system-tools.js +276 -325
- package/dist/src/mcp-tools/system-tools.js.map +1 -1
- package/dist/src/mcp-tools/task-tools.js +270 -336
- package/dist/src/mcp-tools/task-tools.js.map +1 -1
- package/dist/src/mcp-tools/terminal-tools.js +148 -196
- package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
- package/dist/src/mcp-tools/transfer-tools.js +186 -333
- package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
- package/dist/src/mcp-tools/types.d.ts +31 -0
- package/dist/src/mcp-tools/types.d.ts.map +1 -0
- package/dist/src/mcp-tools/wasm-agent-tools.js +133 -280
- package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/workflow-tools.js +405 -450
- package/dist/src/mcp-tools/workflow-tools.js.map +1 -1
- package/dist/src/memory/ewc-consolidation.d.ts +295 -0
- package/dist/src/memory/ewc-consolidation.d.ts.map +1 -0
- package/dist/src/memory/ewc-consolidation.js +190 -303
- package/dist/src/memory/ewc-consolidation.js.map +1 -1
- package/dist/src/memory/intelligence.d.ts +338 -0
- package/dist/src/memory/intelligence.d.ts.map +1 -0
- package/dist/src/memory/intelligence.js +569 -794
- package/dist/src/memory/intelligence.js.map +1 -1
- package/dist/src/memory/memory-bridge.d.ts +407 -0
- package/dist/src/memory/memory-bridge.d.ts.map +1 -0
- package/dist/src/memory/memory-bridge.js +1170 -1640
- package/dist/src/memory/memory-bridge.js.map +1 -1
- package/dist/src/memory/memory-initializer.d.ts +412 -0
- package/dist/src/memory/memory-initializer.d.ts.map +1 -0
- package/dist/src/memory/memory-initializer.js +1836 -1851
- package/dist/src/memory/memory-initializer.js.map +1 -1
- package/dist/src/memory/sona-optimizer.d.ts +227 -0
- package/dist/src/memory/sona-optimizer.d.ts.map +1 -0
- package/dist/src/memory/sona-optimizer.js +199 -329
- package/dist/src/memory/sona-optimizer.js.map +1 -1
- package/dist/src/output.d.ts +2 -2
- package/dist/src/output.d.ts.map +1 -1
- package/dist/src/output.js +242 -272
- package/dist/src/output.js.map +1 -1
- package/dist/src/parser.d.ts +51 -0
- package/dist/src/parser.d.ts.map +1 -0
- package/dist/src/parser.js +140 -187
- package/dist/src/parser.js.map +1 -1
- package/dist/src/plugins/manager.d.ts +133 -0
- package/dist/src/plugins/manager.d.ts.map +1 -0
- package/dist/src/plugins/manager.js +285 -521
- package/dist/src/plugins/manager.js.map +1 -1
- package/dist/src/plugins/store/discovery.d.ts +88 -0
- package/dist/src/plugins/store/discovery.d.ts.map +1 -0
- package/dist/src/plugins/store/discovery.js +271 -358
- package/dist/src/plugins/store/discovery.js.map +1 -1
- package/dist/src/plugins/store/index.d.ts +76 -0
- package/dist/src/plugins/store/index.d.ts.map +1 -0
- package/dist/src/plugins/store/index.js +48 -105
- package/dist/src/plugins/store/index.js.map +1 -1
- package/dist/src/plugins/store/search.d.ts +46 -0
- package/dist/src/plugins/store/search.d.ts.map +1 -0
- package/dist/src/plugins/store/search.js +69 -107
- package/dist/src/plugins/store/search.js.map +1 -1
- package/dist/src/plugins/store/types.d.ts +274 -0
- package/dist/src/plugins/store/types.d.ts.map +1 -0
- package/dist/src/plugins/tests/demo-plugin-store.js +113 -160
- package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -1
- package/dist/src/plugins/tests/standalone-test.js +172 -223
- package/dist/src/plugins/tests/standalone-test.js.map +1 -1
- package/dist/src/plugins/tests/test-plugin-store.js +190 -228
- package/dist/src/plugins/tests/test-plugin-store.js.map +1 -1
- package/dist/src/production/circuit-breaker.d.ts +101 -0
- package/dist/src/production/circuit-breaker.d.ts.map +1 -0
- package/dist/src/production/circuit-breaker.js +62 -126
- package/dist/src/production/circuit-breaker.js.map +1 -1
- package/dist/src/production/error-handler.d.ts +92 -0
- package/dist/src/production/error-handler.d.ts.map +1 -0
- package/dist/src/production/error-handler.js +86 -156
- package/dist/src/production/error-handler.js.map +1 -1
- package/dist/src/production/monitoring.d.ts +161 -0
- package/dist/src/production/monitoring.d.ts.map +1 -0
- package/dist/src/production/monitoring.js +139 -220
- package/dist/src/production/monitoring.js.map +1 -1
- package/dist/src/production/rate-limiter.d.ts +80 -0
- package/dist/src/production/rate-limiter.d.ts.map +1 -0
- package/dist/src/production/rate-limiter.js +74 -93
- package/dist/src/production/rate-limiter.js.map +1 -1
- package/dist/src/production/retry.d.ts +48 -0
- package/dist/src/production/retry.d.ts.map +1 -0
- package/dist/src/production/retry.js +75 -167
- package/dist/src/production/retry.js.map +1 -1
- package/dist/src/prompt.d.ts +44 -0
- package/dist/src/prompt.d.ts.map +1 -0
- package/dist/src/prompt.js +436 -560
- package/dist/src/prompt.js.map +1 -1
- package/dist/src/runtime/headless.d.ts +60 -0
- package/dist/src/runtime/headless.d.ts.map +1 -0
- package/dist/src/runtime/headless.js +197 -286
- package/dist/src/runtime/headless.js.map +1 -1
- package/dist/src/ruvector/agent-wasm.d.ts +182 -0
- package/dist/src/ruvector/agent-wasm.d.ts.map +1 -0
- package/dist/src/ruvector/agent-wasm.js +156 -351
- package/dist/src/ruvector/agent-wasm.js.map +1 -1
- package/dist/src/ruvector/ast-analyzer.d.ts +67 -0
- package/dist/src/ruvector/ast-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/ast-analyzer.js +145 -232
- package/dist/src/ruvector/ast-analyzer.js.map +1 -1
- package/dist/src/ruvector/coverage-router.d.ts +160 -0
- package/dist/src/ruvector/coverage-router.d.ts.map +1 -0
- package/dist/src/ruvector/coverage-router.js +287 -419
- package/dist/src/ruvector/coverage-router.js.map +1 -1
- package/dist/src/ruvector/coverage-tools.js +56 -101
- package/dist/src/ruvector/coverage-tools.js.map +1 -1
- package/dist/src/ruvector/diff-classifier.d.ts +175 -0
- package/dist/src/ruvector/diff-classifier.d.ts.map +1 -0
- package/dist/src/ruvector/diff-classifier.js +324 -451
- package/dist/src/ruvector/diff-classifier.js.map +1 -1
- package/dist/src/ruvector/enhanced-model-router.d.ts +146 -0
- package/dist/src/ruvector/enhanced-model-router.d.ts.map +1 -0
- package/dist/src/ruvector/enhanced-model-router.js +260 -336
- package/dist/src/ruvector/enhanced-model-router.js.map +1 -1
- package/dist/src/ruvector/flash-attention.d.ts +195 -0
- package/dist/src/ruvector/flash-attention.d.ts.map +1 -0
- package/dist/src/ruvector/flash-attention.js +223 -254
- package/dist/src/ruvector/flash-attention.js.map +1 -1
- package/dist/src/ruvector/graph-analyzer.d.ts +187 -0
- package/dist/src/ruvector/graph-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/graph-analyzer.js +486 -680
- package/dist/src/ruvector/graph-analyzer.js.map +1 -1
- package/dist/src/ruvector/index.d.ts +40 -0
- package/dist/src/ruvector/index.d.ts.map +1 -0
- package/dist/src/ruvector/index.js +36 -106
- package/dist/src/ruvector/index.js.map +1 -1
- package/dist/src/ruvector/lora-adapter.d.ts +218 -0
- package/dist/src/ruvector/lora-adapter.d.ts.map +1 -0
- package/dist/src/ruvector/lora-adapter.js +155 -248
- package/dist/src/ruvector/lora-adapter.js.map +1 -1
- package/dist/src/ruvector/model-router.d.ts +220 -0
- package/dist/src/ruvector/model-router.d.ts.map +1 -0
- package/dist/src/ruvector/model-router.js +175 -248
- package/dist/src/ruvector/model-router.js.map +1 -1
- package/dist/src/ruvector/moe-router.d.ts +206 -0
- package/dist/src/ruvector/moe-router.d.ts.map +1 -0
- package/dist/src/ruvector/moe-router.js +228 -286
- package/dist/src/ruvector/moe-router.js.map +1 -1
- package/dist/src/ruvector/q-learning-router.d.ts +211 -0
- package/dist/src/ruvector/q-learning-router.d.ts.map +1 -0
- package/dist/src/ruvector/q-learning-router.js +257 -338
- package/dist/src/ruvector/q-learning-router.js.map +1 -1
- package/dist/src/ruvector/ruvllm-wasm.d.ts +179 -0
- package/dist/src/ruvector/ruvllm-wasm.d.ts.map +1 -0
- package/dist/src/ruvector/ruvllm-wasm.js +270 -434
- package/dist/src/ruvector/ruvllm-wasm.js.map +1 -1
- package/dist/src/ruvector/semantic-router.d.ts +77 -0
- package/dist/src/ruvector/semantic-router.d.ts.map +1 -0
- package/dist/src/ruvector/semantic-router.js +60 -67
- package/dist/src/ruvector/semantic-router.js.map +1 -1
- package/dist/src/ruvector/vector-db.d.ts +69 -0
- package/dist/src/ruvector/vector-db.d.ts.map +1 -0
- package/dist/src/ruvector/vector-db.js +119 -205
- package/dist/src/ruvector/vector-db.js.map +1 -1
- package/dist/src/services/agentic-flow-bridge.d.ts +50 -0
- package/dist/src/services/agentic-flow-bridge.d.ts.map +1 -0
- package/dist/src/services/agentic-flow-bridge.js +32 -105
- package/dist/src/services/agentic-flow-bridge.js.map +1 -1
- package/dist/src/services/claim-service.d.ts +204 -0
- package/dist/src/services/claim-service.d.ts.map +1 -0
- package/dist/src/services/claim-service.js +615 -940
- package/dist/src/services/claim-service.js.map +1 -1
- package/dist/src/services/container-worker-pool.d.ts +197 -0
- package/dist/src/services/container-worker-pool.d.ts.map +1 -0
- package/dist/src/services/container-worker-pool.js +398 -666
- package/dist/src/services/container-worker-pool.js.map +1 -1
- package/dist/src/services/headless-worker-executor.d.ts +304 -0
- package/dist/src/services/headless-worker-executor.d.ts.map +1 -0
- package/dist/src/services/headless-worker-executor.js +441 -467
- package/dist/src/services/headless-worker-executor.js.map +1 -1
- package/dist/src/services/index.d.ts +4 -4
- package/dist/src/services/index.d.ts.map +1 -1
- package/dist/src/services/index.js +4 -4
- package/dist/src/services/index.js.map +1 -1
- package/dist/src/services/registry-api.d.ts +58 -0
- package/dist/src/services/registry-api.d.ts.map +1 -0
- package/dist/src/services/registry-api.js +92 -200
- package/dist/src/services/registry-api.js.map +1 -1
- package/dist/src/services/ruvector-training.d.ts +222 -0
- package/dist/src/services/ruvector-training.d.ts.map +1 -0
- package/dist/src/services/ruvector-training.js +257 -337
- package/dist/src/services/ruvector-training.js.map +1 -1
- package/dist/src/services/worker-daemon.d.ts +228 -0
- package/dist/src/services/worker-daemon.d.ts.map +1 -0
- package/dist/src/services/worker-daemon.js +591 -849
- package/dist/src/services/worker-daemon.js.map +1 -1
- package/dist/src/services/worker-queue.d.ts +194 -0
- package/dist/src/services/worker-queue.d.ts.map +1 -0
- package/dist/src/services/worker-queue.js +331 -548
- package/dist/src/services/worker-queue.js.map +1 -1
- package/dist/src/suggest.d.ts +53 -0
- package/dist/src/suggest.d.ts.map +1 -0
- package/dist/src/suggest.js +45 -55
- package/dist/src/suggest.js.map +1 -1
- package/dist/src/transfer/anonymization/index.js +29 -37
- package/dist/src/transfer/anonymization/index.js.map +1 -1
- package/dist/src/transfer/deploy-seraphine.js +128 -155
- package/dist/src/transfer/deploy-seraphine.js.map +1 -1
- package/dist/src/transfer/export.d.ts +25 -0
- package/dist/src/transfer/export.d.ts.map +1 -0
- package/dist/src/transfer/export.js +84 -142
- package/dist/src/transfer/export.js.map +1 -1
- package/dist/src/transfer/index.d.ts +1 -1
- package/dist/src/transfer/index.d.ts.map +1 -1
- package/dist/src/transfer/index.js +0 -2
- package/dist/src/transfer/index.js.map +1 -1
- package/dist/src/transfer/ipfs/client.d.ts +109 -0
- package/dist/src/transfer/ipfs/client.d.ts.map +1 -0
- package/dist/src/transfer/ipfs/client.js +187 -337
- package/dist/src/transfer/ipfs/client.js.map +1 -1
- package/dist/src/transfer/ipfs/upload.d.ts +95 -0
- package/dist/src/transfer/ipfs/upload.d.ts.map +1 -0
- package/dist/src/transfer/ipfs/upload.js +288 -434
- package/dist/src/transfer/ipfs/upload.js.map +1 -1
- package/dist/src/transfer/models/seraphine.d.ts +72 -0
- package/dist/src/transfer/models/seraphine.d.ts.map +1 -0
- package/dist/src/transfer/models/seraphine.js +55 -55
- package/dist/src/transfer/models/seraphine.js.map +1 -1
- package/dist/src/transfer/serialization/cfp.d.ts +49 -0
- package/dist/src/transfer/serialization/cfp.d.ts.map +1 -0
- package/dist/src/transfer/serialization/cfp.js +30 -31
- package/dist/src/transfer/serialization/cfp.js.map +1 -1
- package/dist/src/transfer/storage/gcs.d.ts +82 -0
- package/dist/src/transfer/storage/gcs.d.ts.map +1 -0
- package/dist/src/transfer/storage/gcs.js +165 -232
- package/dist/src/transfer/storage/gcs.js.map +1 -1
- package/dist/src/transfer/store/discovery.d.ts +84 -0
- package/dist/src/transfer/store/discovery.d.ts.map +1 -0
- package/dist/src/transfer/store/discovery.js +239 -349
- package/dist/src/transfer/store/discovery.js.map +1 -1
- package/dist/src/transfer/store/download.d.ts +70 -0
- package/dist/src/transfer/store/download.d.ts.map +1 -0
- package/dist/src/transfer/store/download.js +243 -365
- package/dist/src/transfer/store/download.js.map +1 -1
- package/dist/src/transfer/store/index.d.ts +84 -0
- package/dist/src/transfer/store/index.d.ts.map +1 -0
- package/dist/src/transfer/store/index.js +63 -130
- package/dist/src/transfer/store/index.js.map +1 -1
- package/dist/src/transfer/store/publish.d.ts +76 -0
- package/dist/src/transfer/store/publish.d.ts.map +1 -0
- package/dist/src/transfer/store/publish.js +184 -258
- package/dist/src/transfer/store/publish.js.map +1 -1
- package/dist/src/transfer/store/registry.js +50 -72
- package/dist/src/transfer/store/registry.js.map +1 -1
- package/dist/src/transfer/store/search.d.ts +54 -0
- package/dist/src/transfer/store/search.d.ts.map +1 -0
- package/dist/src/transfer/store/search.js +64 -96
- package/dist/src/transfer/store/search.js.map +1 -1
- package/dist/src/transfer/store/tests/standalone-test.js +174 -231
- package/dist/src/transfer/store/tests/standalone-test.js.map +1 -1
- package/dist/src/transfer/test-seraphine.js +95 -130
- package/dist/src/transfer/test-seraphine.js.map +1 -1
- package/dist/src/transfer/tests/test-store.js +194 -239
- package/dist/src/transfer/tests/test-store.js.map +1 -1
- package/dist/src/transfer/types.d.ts +245 -0
- package/dist/src/transfer/types.d.ts.map +1 -0
- package/dist/src/types.d.ts +198 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +26 -55
- package/dist/src/types.js.map +1 -1
- package/dist/src/update/checker.d.ts +34 -0
- package/dist/src/update/checker.d.ts.map +1 -0
- package/dist/src/update/checker.js +106 -183
- package/dist/src/update/checker.js.map +1 -1
- package/dist/src/update/executor.d.ts +32 -0
- package/dist/src/update/executor.d.ts.map +1 -0
- package/dist/src/update/executor.js +135 -198
- package/dist/src/update/executor.js.map +1 -1
- package/dist/src/update/index.d.ts +33 -0
- package/dist/src/update/index.d.ts.map +1 -0
- package/dist/src/update/index.js +38 -85
- package/dist/src/update/index.js.map +1 -1
- package/dist/src/update/rate-limiter.d.ts +20 -0
- package/dist/src/update/rate-limiter.d.ts.map +1 -0
- package/dist/src/update/rate-limiter.js +19 -31
- package/dist/src/update/rate-limiter.js.map +1 -1
- package/dist/src/update/validator.d.ts +17 -0
- package/dist/src/update/validator.d.ts.map +1 -0
- package/dist/src/update/validator.js +38 -64
- package/dist/src/update/validator.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- 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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
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
|
-
|
|
31
|
+
const path = getCoordPath();
|
|
79
32
|
if (existsSync(path)) {
|
|
80
33
|
return JSON.parse(readFileSync(path, 'utf-8'));
|
|
81
34
|
}
|
|
82
35
|
}
|
|
83
|
-
catch
|
|
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
|
|
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',
|
|
121
|
-
type: { type: 'string',
|
|
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',
|
|
125
|
-
}
|
|
77
|
+
consensusAlgorithm: { type: 'string', enum: ['raft', 'byzantine', 'gossip', 'crdt'], description: 'Consensus algorithm' },
|
|
78
|
+
},
|
|
126
79
|
},
|
|
127
|
-
handler:
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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 (
|
|
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
|
-
|
|
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',
|
|
192
|
-
algorithm: { type: 'string',
|
|
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:
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
nodes
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
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 (
|
|
231
|
-
|
|
232
|
-
|
|
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
|
-
|
|
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',
|
|
221
|
+
action: { type: 'string', enum: ['status', 'trigger', 'resolve'], description: 'Action to perform' },
|
|
273
222
|
force: { type: 'boolean', description: 'Force synchronization' },
|
|
274
|
-
conflictResolution: { type: 'string',
|
|
275
|
-
}
|
|
223
|
+
conflictResolution: { type: 'string', enum: ['latest', 'merge', 'manual'], description: 'Conflict resolution strategy' },
|
|
224
|
+
},
|
|
276
225
|
},
|
|
277
|
-
handler:
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
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',
|
|
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:
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
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
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
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
|
|
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',
|
|
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',
|
|
361
|
+
vote: { type: 'string', enum: ['accept', 'reject'], description: 'Vote' },
|
|
425
362
|
voterId: { type: 'string', description: 'Voter node ID' },
|
|
426
|
-
strategy: { type: 'string',
|
|
427
|
-
quorumPreset: { type: 'string',
|
|
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:
|
|
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
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
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
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
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
|
-
|
|
493
|
-
proposalId
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
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
|
-
|
|
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
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
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
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
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
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
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
|
|
578
|
+
return { success: false, error: 'Proposal not found in resolved history. Vote must reach quorum first.' };
|
|
646
579
|
}
|
|
647
|
-
return
|
|
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',
|
|
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',
|
|
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
|