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