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
|
@@ -15,28 +15,99 @@
|
|
|
15
15
|
* - Volume mounting for workspace access
|
|
16
16
|
* - Network isolation per worker type
|
|
17
17
|
*/
|
|
18
|
+
var __extends = (this && this.__extends) || (function () {
|
|
19
|
+
var extendStatics = function (d, b) {
|
|
20
|
+
extendStatics = Object.setPrototypeOf ||
|
|
21
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
22
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
23
|
+
return extendStatics(d, b);
|
|
24
|
+
};
|
|
25
|
+
return function (d, b) {
|
|
26
|
+
if (typeof b !== "function" && b !== null)
|
|
27
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
28
|
+
extendStatics(d, b);
|
|
29
|
+
function __() { this.constructor = d; }
|
|
30
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __assign = (this && this.__assign) || function () {
|
|
34
|
+
__assign = Object.assign || function(t) {
|
|
35
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
36
|
+
s = arguments[i];
|
|
37
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
38
|
+
t[p] = s[p];
|
|
39
|
+
}
|
|
40
|
+
return t;
|
|
41
|
+
};
|
|
42
|
+
return __assign.apply(this, arguments);
|
|
43
|
+
};
|
|
44
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
45
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
46
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
47
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
48
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
49
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
50
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
54
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
55
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
56
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
57
|
+
function step(op) {
|
|
58
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
59
|
+
while (_) try {
|
|
60
|
+
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;
|
|
61
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
62
|
+
switch (op[0]) {
|
|
63
|
+
case 0: case 1: t = op; break;
|
|
64
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
65
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
66
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
67
|
+
default:
|
|
68
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
69
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
70
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
71
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
72
|
+
if (t[2]) _.ops.pop();
|
|
73
|
+
_.trys.pop(); continue;
|
|
74
|
+
}
|
|
75
|
+
op = body.call(thisArg, _);
|
|
76
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
77
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
81
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
82
|
+
if (ar || !(i in from)) {
|
|
83
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
84
|
+
ar[i] = from[i];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
88
|
+
};
|
|
18
89
|
import { EventEmitter } from 'events';
|
|
19
90
|
import { spawn, exec } from 'child_process';
|
|
20
91
|
import { promisify } from 'util';
|
|
21
92
|
import { existsSync, mkdirSync } from 'fs';
|
|
22
93
|
import { join } from 'path';
|
|
23
|
-
|
|
94
|
+
var execAsync = promisify(exec);
|
|
24
95
|
// ============================================
|
|
25
96
|
// Constants
|
|
26
97
|
// ============================================
|
|
27
|
-
|
|
98
|
+
var DEFAULT_CONFIG = {
|
|
28
99
|
maxContainers: 3,
|
|
29
100
|
minContainers: 1,
|
|
30
|
-
image: 'ghcr.io/
|
|
101
|
+
image: 'ghcr.io/ruvnet/claude-flow-headless:latest',
|
|
31
102
|
resources: {
|
|
32
103
|
cpus: '2',
|
|
33
|
-
memory: '4g'
|
|
104
|
+
memory: '4g'
|
|
34
105
|
},
|
|
35
106
|
healthCheckIntervalMs: 30000,
|
|
36
|
-
idleTimeoutMs: 300000,
|
|
107
|
+
idleTimeoutMs: 300000,
|
|
37
108
|
workspacePath: '/workspace',
|
|
38
109
|
statePath: '.claude-flow/container-pool',
|
|
39
|
-
defaultSandbox: 'strict'
|
|
110
|
+
defaultSandbox: 'strict'
|
|
40
111
|
};
|
|
41
112
|
// ============================================
|
|
42
113
|
// ContainerWorkerPool Class
|
|
@@ -44,26 +115,24 @@ const DEFAULT_CONFIG = {
|
|
|
44
115
|
/**
|
|
45
116
|
* ContainerWorkerPool - Manages Docker containers for headless worker execution
|
|
46
117
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
projectRoot
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
super();
|
|
60
|
-
this.projectRoot = projectRoot;
|
|
61
|
-
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
118
|
+
var ContainerWorkerPool = /** @class */ (function (_super) {
|
|
119
|
+
__extends(ContainerWorkerPool, _super);
|
|
120
|
+
function ContainerWorkerPool(projectRoot, config) {
|
|
121
|
+
var _this = _super.call(this) || this;
|
|
122
|
+
_this.containers = new Map();
|
|
123
|
+
_this.taskQueue = [];
|
|
124
|
+
_this.dockerAvailable = null;
|
|
125
|
+
_this.initialized = false;
|
|
126
|
+
_this.isShuttingDown = false;
|
|
127
|
+
_this.exitHandlersRegistered = false;
|
|
128
|
+
_this.projectRoot = projectRoot;
|
|
129
|
+
_this.config = __assign(__assign({}, DEFAULT_CONFIG), config);
|
|
62
130
|
// Ensure state directory exists
|
|
63
|
-
|
|
131
|
+
var stateDir = join(projectRoot, _this.config.statePath);
|
|
64
132
|
if (!existsSync(stateDir)) {
|
|
65
133
|
mkdirSync(stateDir, { recursive: true });
|
|
66
134
|
}
|
|
135
|
+
return _this;
|
|
67
136
|
}
|
|
68
137
|
// ============================================
|
|
69
138
|
// Public API
|
|
@@ -71,382 +140,523 @@ export class ContainerWorkerPool extends EventEmitter {
|
|
|
71
140
|
/**
|
|
72
141
|
* Initialize the container pool
|
|
73
142
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
143
|
+
ContainerWorkerPool.prototype.initialize = function () {
|
|
144
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
145
|
+
var _a;
|
|
146
|
+
return __generator(this, function (_b) {
|
|
147
|
+
switch (_b.label) {
|
|
148
|
+
case 0:
|
|
149
|
+
if (this.initialized) {
|
|
150
|
+
return [2 /*return*/, true];
|
|
151
|
+
}
|
|
152
|
+
// Check Docker availability
|
|
153
|
+
_a = this;
|
|
154
|
+
return [4 /*yield*/, this.checkDockerAvailable()];
|
|
155
|
+
case 1:
|
|
156
|
+
// Check Docker availability
|
|
157
|
+
_a.dockerAvailable = _b.sent();
|
|
158
|
+
if (!this.dockerAvailable) {
|
|
159
|
+
this.emit('warning', { message: 'Docker not available - container pool disabled' });
|
|
160
|
+
return [2 /*return*/, false];
|
|
161
|
+
}
|
|
162
|
+
// Pull image if needed
|
|
163
|
+
return [4 /*yield*/, this.ensureImage()];
|
|
164
|
+
case 2:
|
|
165
|
+
// Pull image if needed
|
|
166
|
+
_b.sent();
|
|
167
|
+
// Create minimum containers
|
|
168
|
+
return [4 /*yield*/, this.scaleToMinimum()];
|
|
169
|
+
case 3:
|
|
170
|
+
// Create minimum containers
|
|
171
|
+
_b.sent();
|
|
172
|
+
// Start health check timer
|
|
173
|
+
this.startHealthChecks();
|
|
174
|
+
// Start idle check timer
|
|
175
|
+
this.startIdleChecks();
|
|
176
|
+
// Register exit handlers for cleanup
|
|
177
|
+
this.registerExitHandlers();
|
|
178
|
+
this.initialized = true;
|
|
179
|
+
this.emit('initialized', { containers: this.containers.size });
|
|
180
|
+
return [2 /*return*/, true];
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
};
|
|
98
185
|
/**
|
|
99
186
|
* Register process exit handlers to clean up containers
|
|
100
187
|
*/
|
|
101
|
-
registerExitHandlers() {
|
|
188
|
+
ContainerWorkerPool.prototype.registerExitHandlers = function () {
|
|
189
|
+
var _this = this;
|
|
102
190
|
if (this.exitHandlersRegistered)
|
|
103
191
|
return;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
192
|
+
var cleanup = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
193
|
+
return __generator(this, function (_a) {
|
|
194
|
+
switch (_a.label) {
|
|
195
|
+
case 0:
|
|
196
|
+
if (!!this.isShuttingDown) return [3 /*break*/, 2];
|
|
197
|
+
return [4 /*yield*/, this.shutdown()];
|
|
198
|
+
case 1:
|
|
199
|
+
_a.sent();
|
|
200
|
+
_a.label = 2;
|
|
201
|
+
case 2: return [2 /*return*/];
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}); };
|
|
109
205
|
process.once('SIGTERM', cleanup);
|
|
110
206
|
process.once('SIGINT', cleanup);
|
|
111
207
|
process.once('beforeExit', cleanup);
|
|
112
208
|
this.exitHandlersRegistered = true;
|
|
113
|
-
}
|
|
209
|
+
};
|
|
114
210
|
/**
|
|
115
211
|
* Execute a worker in a container
|
|
116
212
|
*/
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
213
|
+
ContainerWorkerPool.prototype.execute = function (options) {
|
|
214
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
215
|
+
var container, newContainer;
|
|
216
|
+
var _this = this;
|
|
217
|
+
return __generator(this, function (_a) {
|
|
218
|
+
switch (_a.label) {
|
|
219
|
+
case 0:
|
|
220
|
+
if (!!this.initialized) return [3 /*break*/, 2];
|
|
221
|
+
return [4 /*yield*/, this.initialize()];
|
|
222
|
+
case 1:
|
|
223
|
+
_a.sent();
|
|
224
|
+
_a.label = 2;
|
|
225
|
+
case 2:
|
|
226
|
+
if (!this.dockerAvailable) {
|
|
227
|
+
return [2 /*return*/, this.createErrorResult(options.workerType, 'Docker not available')];
|
|
228
|
+
}
|
|
229
|
+
container = this.getReadyContainer();
|
|
230
|
+
if (container) {
|
|
231
|
+
return [2 /*return*/, this.executeInContainer(container, options)];
|
|
232
|
+
}
|
|
233
|
+
if (!(this.containers.size < this.config.maxContainers)) return [3 /*break*/, 4];
|
|
234
|
+
return [4 /*yield*/, this.createContainer()];
|
|
235
|
+
case 3:
|
|
236
|
+
newContainer = _a.sent();
|
|
237
|
+
if (newContainer) {
|
|
238
|
+
return [2 /*return*/, this.executeInContainer(newContainer, options)];
|
|
239
|
+
}
|
|
240
|
+
_a.label = 4;
|
|
241
|
+
case 4:
|
|
242
|
+
// Queue the task
|
|
243
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
244
|
+
_this.taskQueue.push({
|
|
245
|
+
options: options,
|
|
246
|
+
resolve: resolve,
|
|
247
|
+
reject: reject,
|
|
248
|
+
queuedAt: new Date()
|
|
249
|
+
});
|
|
250
|
+
_this.emit('taskQueued', {
|
|
251
|
+
workerType: options.workerType,
|
|
252
|
+
queuePosition: _this.taskQueue.length
|
|
253
|
+
});
|
|
254
|
+
})];
|
|
255
|
+
}
|
|
147
256
|
});
|
|
148
257
|
});
|
|
149
|
-
}
|
|
258
|
+
};
|
|
150
259
|
/**
|
|
151
260
|
* Scale pool for batch execution
|
|
152
261
|
*/
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
262
|
+
ContainerWorkerPool.prototype.scaleForBatch = function (workerCount) {
|
|
263
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
264
|
+
var targetSize, currentSize, toCreate, createPromises, i;
|
|
265
|
+
return __generator(this, function (_a) {
|
|
266
|
+
switch (_a.label) {
|
|
267
|
+
case 0:
|
|
268
|
+
targetSize = Math.min(workerCount, this.config.maxContainers);
|
|
269
|
+
currentSize = this.containers.size;
|
|
270
|
+
if (!(targetSize > currentSize)) return [3 /*break*/, 2];
|
|
271
|
+
toCreate = targetSize - currentSize;
|
|
272
|
+
createPromises = [];
|
|
273
|
+
for (i = 0; i < toCreate; i++) {
|
|
274
|
+
createPromises.push(this.createContainer());
|
|
275
|
+
}
|
|
276
|
+
return [4 /*yield*/, Promise.all(createPromises)];
|
|
277
|
+
case 1:
|
|
278
|
+
_a.sent();
|
|
279
|
+
this.emit('scaled', { from: currentSize, to: this.containers.size });
|
|
280
|
+
_a.label = 2;
|
|
281
|
+
case 2: return [2 /*return*/];
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
};
|
|
166
286
|
/**
|
|
167
287
|
* Get pool status
|
|
168
288
|
*/
|
|
169
|
-
getStatus() {
|
|
170
|
-
|
|
289
|
+
ContainerWorkerPool.prototype.getStatus = function () {
|
|
290
|
+
var _a;
|
|
291
|
+
var containers = Array.from(this.containers.values());
|
|
171
292
|
return {
|
|
172
293
|
totalContainers: containers.length,
|
|
173
|
-
readyContainers: containers.filter(c
|
|
174
|
-
busyContainers: containers.filter(c
|
|
175
|
-
unhealthyContainers: containers.filter(c
|
|
294
|
+
readyContainers: containers.filter(function (c) { return c.state === 'ready'; }).length,
|
|
295
|
+
busyContainers: containers.filter(function (c) { return c.state === 'busy'; }).length,
|
|
296
|
+
unhealthyContainers: containers.filter(function (c) { return c.state === 'unhealthy'; }).length,
|
|
176
297
|
queuedTasks: this.taskQueue.length,
|
|
177
|
-
containers,
|
|
178
|
-
dockerAvailable: this.dockerAvailable
|
|
179
|
-
lastHealthCheck: undefined
|
|
298
|
+
containers: containers,
|
|
299
|
+
dockerAvailable: (_a = this.dockerAvailable) !== null && _a !== void 0 ? _a : false,
|
|
300
|
+
lastHealthCheck: undefined
|
|
180
301
|
};
|
|
181
|
-
}
|
|
302
|
+
};
|
|
182
303
|
/**
|
|
183
304
|
* Shutdown the pool
|
|
184
305
|
*/
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
306
|
+
ContainerWorkerPool.prototype.shutdown = function () {
|
|
307
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
308
|
+
var _i, _a, task, terminatePromises, _b, _c, id;
|
|
309
|
+
return __generator(this, function (_d) {
|
|
310
|
+
switch (_d.label) {
|
|
311
|
+
case 0:
|
|
312
|
+
if (this.isShuttingDown)
|
|
313
|
+
return [2 /*return*/];
|
|
314
|
+
this.isShuttingDown = true;
|
|
315
|
+
// Stop timers
|
|
316
|
+
if (this.healthCheckTimer) {
|
|
317
|
+
clearInterval(this.healthCheckTimer);
|
|
318
|
+
this.healthCheckTimer = undefined;
|
|
319
|
+
}
|
|
320
|
+
if (this.idleCheckTimer) {
|
|
321
|
+
clearInterval(this.idleCheckTimer);
|
|
322
|
+
this.idleCheckTimer = undefined;
|
|
323
|
+
}
|
|
324
|
+
// Reject queued tasks
|
|
325
|
+
for (_i = 0, _a = this.taskQueue; _i < _a.length; _i++) {
|
|
326
|
+
task = _a[_i];
|
|
327
|
+
task.reject(new Error('Pool shutting down'));
|
|
328
|
+
}
|
|
329
|
+
this.taskQueue = [];
|
|
330
|
+
terminatePromises = [];
|
|
331
|
+
for (_b = 0, _c = this.containers; _b < _c.length; _b++) {
|
|
332
|
+
id = _c[_b][0];
|
|
333
|
+
terminatePromises.push(this.terminateContainer(id)["catch"](function () {
|
|
334
|
+
// Ignore errors during shutdown
|
|
335
|
+
}));
|
|
336
|
+
}
|
|
337
|
+
// Wait for all containers with 30s timeout
|
|
338
|
+
return [4 /*yield*/, Promise.race([
|
|
339
|
+
Promise.all(terminatePromises),
|
|
340
|
+
new Promise(function (resolve) { return setTimeout(resolve, 30000); }),
|
|
341
|
+
])];
|
|
342
|
+
case 1:
|
|
343
|
+
// Wait for all containers with 30s timeout
|
|
344
|
+
_d.sent();
|
|
345
|
+
this.initialized = false;
|
|
346
|
+
this.emit('shutdown', {});
|
|
347
|
+
return [2 /*return*/];
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
};
|
|
218
352
|
// ============================================
|
|
219
353
|
// Private Methods - Container Lifecycle
|
|
220
354
|
// ============================================
|
|
221
355
|
/**
|
|
222
356
|
* Check if Docker is available (async)
|
|
223
357
|
*/
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
358
|
+
ContainerWorkerPool.prototype.checkDockerAvailable = function () {
|
|
359
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
360
|
+
var _a;
|
|
361
|
+
return __generator(this, function (_b) {
|
|
362
|
+
switch (_b.label) {
|
|
363
|
+
case 0:
|
|
364
|
+
_b.trys.push([0, 3, , 4]);
|
|
365
|
+
return [4 /*yield*/, execAsync('docker --version', { timeout: 5000 })];
|
|
366
|
+
case 1:
|
|
367
|
+
_b.sent();
|
|
368
|
+
return [4 /*yield*/, execAsync('docker info', { timeout: 10000 })];
|
|
369
|
+
case 2:
|
|
370
|
+
_b.sent();
|
|
371
|
+
return [2 /*return*/, true];
|
|
372
|
+
case 3:
|
|
373
|
+
_a = _b.sent();
|
|
374
|
+
return [2 /*return*/, false];
|
|
375
|
+
case 4: return [2 /*return*/];
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
};
|
|
234
380
|
/**
|
|
235
381
|
* Ensure the container image exists (async)
|
|
236
382
|
*/
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
383
|
+
ContainerWorkerPool.prototype.ensureImage = function () {
|
|
384
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
385
|
+
var _a, error_1;
|
|
386
|
+
return __generator(this, function (_b) {
|
|
387
|
+
switch (_b.label) {
|
|
388
|
+
case 0:
|
|
389
|
+
_b.trys.push([0, 2, , 7]);
|
|
390
|
+
return [4 /*yield*/, execAsync("docker image inspect " + this.config.image, { timeout: 10000 })];
|
|
391
|
+
case 1:
|
|
392
|
+
_b.sent();
|
|
393
|
+
return [3 /*break*/, 7];
|
|
394
|
+
case 2:
|
|
395
|
+
_a = _b.sent();
|
|
396
|
+
// Image not found, try to pull
|
|
397
|
+
this.emit('imagePull', { image: this.config.image });
|
|
398
|
+
_b.label = 3;
|
|
399
|
+
case 3:
|
|
400
|
+
_b.trys.push([3, 5, , 6]);
|
|
401
|
+
return [4 /*yield*/, execAsync("docker pull " + this.config.image, { timeout: 300000 })];
|
|
402
|
+
case 4:
|
|
403
|
+
_b.sent();
|
|
404
|
+
return [3 /*break*/, 6];
|
|
405
|
+
case 5:
|
|
406
|
+
error_1 = _b.sent();
|
|
407
|
+
this.emit('warning', { message: "Failed to pull image: " + error_1 });
|
|
408
|
+
return [3 /*break*/, 6];
|
|
409
|
+
case 6: return [3 /*break*/, 7];
|
|
410
|
+
case 7: return [2 /*return*/];
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
};
|
|
253
415
|
/**
|
|
254
416
|
* Create a new container
|
|
255
417
|
*/
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
418
|
+
ContainerWorkerPool.prototype.createContainer = function () {
|
|
419
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
420
|
+
var id, name, containerInfo, args, env, _i, _a, _b, key, value, stdout, containerId, error_2;
|
|
421
|
+
return __generator(this, function (_c) {
|
|
422
|
+
switch (_c.label) {
|
|
423
|
+
case 0:
|
|
424
|
+
id = "cf-worker-" + Date.now() + "-" + Math.random().toString(36).slice(2, 8);
|
|
425
|
+
name = "claude-flow-worker-" + id;
|
|
426
|
+
containerInfo = {
|
|
427
|
+
id: id,
|
|
428
|
+
name: name,
|
|
429
|
+
state: 'creating',
|
|
430
|
+
createdAt: new Date(),
|
|
431
|
+
executionCount: 0,
|
|
432
|
+
healthCheckFailures: 0
|
|
433
|
+
};
|
|
434
|
+
this.containers.set(id, containerInfo);
|
|
435
|
+
this.emit('containerCreating', { id: id, name: name });
|
|
436
|
+
_c.label = 1;
|
|
437
|
+
case 1:
|
|
438
|
+
_c.trys.push([1, 3, , 4]);
|
|
439
|
+
args = [
|
|
440
|
+
'run', '-d',
|
|
441
|
+
'--name', name,
|
|
442
|
+
'--cpus', this.config.resources.cpus,
|
|
443
|
+
'--memory', this.config.resources.memory,
|
|
444
|
+
'-v',
|
|
445
|
+
this.projectRoot + ":" + this.config.workspacePath + ":ro",
|
|
446
|
+
'-v',
|
|
447
|
+
join(this.projectRoot, this.config.statePath) + ":/root/.claude-flow",
|
|
448
|
+
'-w', this.config.workspacePath,
|
|
449
|
+
];
|
|
450
|
+
env = __assign(__assign({}, this.config.env), { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY || '', CLAUDE_CODE_HEADLESS: 'true', CLAUDE_CODE_SANDBOX_MODE: this.config.defaultSandbox });
|
|
451
|
+
for (_i = 0, _a = Object.entries(env); _i < _a.length; _i++) {
|
|
452
|
+
_b = _a[_i], key = _b[0], value = _b[1];
|
|
453
|
+
if (value) {
|
|
454
|
+
args.push('-e', key + "=" + value);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
// Add network if specified
|
|
458
|
+
if (this.config.network) {
|
|
459
|
+
args.push('--network', this.config.network);
|
|
460
|
+
}
|
|
461
|
+
// Add image and entrypoint to keep container running
|
|
462
|
+
args.push(this.config.image, 'tail', '-f', '/dev/null');
|
|
463
|
+
return [4 /*yield*/, execAsync("docker " + args.join(' '), { timeout: 60000 })];
|
|
464
|
+
case 2:
|
|
465
|
+
stdout = (_c.sent()).stdout;
|
|
466
|
+
containerId = stdout.trim();
|
|
467
|
+
containerInfo.state = 'ready';
|
|
468
|
+
this.emit('containerCreated', { id: id, name: name, containerId: containerId });
|
|
469
|
+
return [2 /*return*/, containerInfo];
|
|
470
|
+
case 3:
|
|
471
|
+
error_2 = _c.sent();
|
|
472
|
+
this.containers["delete"](id);
|
|
473
|
+
this.emit('containerError', { id: id, error: String(error_2) });
|
|
474
|
+
return [2 /*return*/, null];
|
|
475
|
+
case 4: return [2 /*return*/];
|
|
290
476
|
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
args.push('--network', this.config.network);
|
|
295
|
-
}
|
|
296
|
-
// Add image and entrypoint to keep container running
|
|
297
|
-
args.push(this.config.image, 'tail', '-f', '/dev/null');
|
|
298
|
-
// Create the container (async)
|
|
299
|
-
const { stdout } = await execAsync(`docker ${args.join(' ')}`, { timeout: 60000 });
|
|
300
|
-
const containerId = stdout.trim();
|
|
301
|
-
containerInfo.state = 'ready';
|
|
302
|
-
this.emit('containerCreated', { id, name, containerId });
|
|
303
|
-
return containerInfo;
|
|
304
|
-
}
|
|
305
|
-
catch (error) {
|
|
306
|
-
this.containers.delete(id);
|
|
307
|
-
this.emit('containerError', { id, error: String(error) });
|
|
308
|
-
return null;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
};
|
|
311
480
|
/**
|
|
312
481
|
* Terminate a container (async)
|
|
313
482
|
*/
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
return
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
483
|
+
ContainerWorkerPool.prototype.terminateContainer = function (id) {
|
|
484
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
485
|
+
var container, _a;
|
|
486
|
+
return __generator(this, function (_b) {
|
|
487
|
+
switch (_b.label) {
|
|
488
|
+
case 0:
|
|
489
|
+
container = this.containers.get(id);
|
|
490
|
+
if (!container)
|
|
491
|
+
return [2 /*return*/];
|
|
492
|
+
container.state = 'terminated';
|
|
493
|
+
_b.label = 1;
|
|
494
|
+
case 1:
|
|
495
|
+
_b.trys.push([1, 3, , 4]);
|
|
496
|
+
return [4 /*yield*/, execAsync("docker rm -f " + container.name, { timeout: 30000 })];
|
|
497
|
+
case 2:
|
|
498
|
+
_b.sent();
|
|
499
|
+
return [3 /*break*/, 4];
|
|
500
|
+
case 3:
|
|
501
|
+
_a = _b.sent();
|
|
502
|
+
return [3 /*break*/, 4];
|
|
503
|
+
case 4:
|
|
504
|
+
this.containers["delete"](id);
|
|
505
|
+
this.emit('containerTerminated', { id: id, name: container.name });
|
|
506
|
+
return [2 /*return*/];
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
};
|
|
328
511
|
/**
|
|
329
512
|
* Get a ready container
|
|
330
513
|
*/
|
|
331
|
-
getReadyContainer() {
|
|
332
|
-
for (
|
|
514
|
+
ContainerWorkerPool.prototype.getReadyContainer = function () {
|
|
515
|
+
for (var _i = 0, _a = this.containers.values(); _i < _a.length; _i++) {
|
|
516
|
+
var container = _a[_i];
|
|
333
517
|
if (container.state === 'ready') {
|
|
334
518
|
return container;
|
|
335
519
|
}
|
|
336
520
|
}
|
|
337
521
|
return null;
|
|
338
|
-
}
|
|
522
|
+
};
|
|
339
523
|
/**
|
|
340
524
|
* Scale to minimum containers
|
|
341
525
|
*/
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
526
|
+
ContainerWorkerPool.prototype.scaleToMinimum = function () {
|
|
527
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
528
|
+
var current, needed, createPromises, i;
|
|
529
|
+
return __generator(this, function (_a) {
|
|
530
|
+
switch (_a.label) {
|
|
531
|
+
case 0:
|
|
532
|
+
current = this.containers.size;
|
|
533
|
+
needed = this.config.minContainers - current;
|
|
534
|
+
if (!(needed > 0)) return [3 /*break*/, 2];
|
|
535
|
+
createPromises = [];
|
|
536
|
+
for (i = 0; i < needed; i++) {
|
|
537
|
+
createPromises.push(this.createContainer());
|
|
538
|
+
}
|
|
539
|
+
return [4 /*yield*/, Promise.all(createPromises)];
|
|
540
|
+
case 1:
|
|
541
|
+
_a.sent();
|
|
542
|
+
_a.label = 2;
|
|
543
|
+
case 2: return [2 /*return*/];
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
});
|
|
547
|
+
};
|
|
353
548
|
// ============================================
|
|
354
549
|
// Private Methods - Execution
|
|
355
550
|
// ============================================
|
|
356
551
|
/**
|
|
357
552
|
* Execute worker in a specific container
|
|
358
553
|
*/
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
554
|
+
ContainerWorkerPool.prototype.executeInContainer = function (container, options) {
|
|
555
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
556
|
+
var startTime, executionId, command, timeoutMs, output, result, error_3, result;
|
|
557
|
+
return __generator(this, function (_a) {
|
|
558
|
+
switch (_a.label) {
|
|
559
|
+
case 0:
|
|
560
|
+
startTime = Date.now();
|
|
561
|
+
executionId = options.workerType + "_" + startTime + "_" + Math.random().toString(36).slice(2, 8);
|
|
562
|
+
container.state = 'busy';
|
|
563
|
+
container.workerType = options.workerType;
|
|
564
|
+
container.lastUsedAt = new Date();
|
|
565
|
+
this.emit('executionStart', { executionId: executionId, containerId: container.id, workerType: options.workerType });
|
|
566
|
+
_a.label = 1;
|
|
567
|
+
case 1:
|
|
568
|
+
_a.trys.push([1, 3, , 4]);
|
|
569
|
+
command = this.buildWorkerCommand(options);
|
|
570
|
+
timeoutMs = options.timeoutMs || 300000;
|
|
571
|
+
return [4 /*yield*/, this.execInContainer(container.name, command, timeoutMs)];
|
|
572
|
+
case 2:
|
|
573
|
+
output = _a.sent();
|
|
574
|
+
container.state = 'ready';
|
|
575
|
+
container.executionCount++;
|
|
576
|
+
result = {
|
|
577
|
+
success: true,
|
|
578
|
+
output: output,
|
|
579
|
+
parsedOutput: this.tryParseJson(output),
|
|
580
|
+
durationMs: Date.now() - startTime,
|
|
581
|
+
model: options.model || 'sonnet',
|
|
582
|
+
sandboxMode: options.sandbox || this.config.defaultSandbox,
|
|
583
|
+
workerType: options.workerType,
|
|
584
|
+
timestamp: new Date(),
|
|
585
|
+
executionId: executionId
|
|
586
|
+
};
|
|
587
|
+
this.emit('executionComplete', result);
|
|
588
|
+
// Process queue
|
|
589
|
+
this.processQueue();
|
|
590
|
+
return [2 /*return*/, result];
|
|
591
|
+
case 3:
|
|
592
|
+
error_3 = _a.sent();
|
|
593
|
+
container.state = 'ready';
|
|
594
|
+
result = this.createErrorResult(options.workerType, error_3 instanceof Error ? error_3.message : String(error_3));
|
|
595
|
+
result.executionId = executionId;
|
|
596
|
+
result.durationMs = Date.now() - startTime;
|
|
597
|
+
this.emit('executionError', result);
|
|
598
|
+
// Process queue
|
|
599
|
+
this.processQueue();
|
|
600
|
+
return [2 /*return*/, result];
|
|
601
|
+
case 4: return [2 /*return*/];
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
});
|
|
605
|
+
};
|
|
401
606
|
/**
|
|
402
607
|
* Execute command in container
|
|
403
608
|
*/
|
|
404
|
-
|
|
405
|
-
return
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
609
|
+
ContainerWorkerPool.prototype.execInContainer = function (containerName, command, timeoutMs) {
|
|
610
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
611
|
+
return __generator(this, function (_a) {
|
|
612
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
613
|
+
var _a, _b;
|
|
614
|
+
var args = __spreadArray(['exec', containerName], command, true);
|
|
615
|
+
var child = spawn('docker', args, {
|
|
616
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
617
|
+
});
|
|
618
|
+
var stdout = '';
|
|
619
|
+
var stderr = '';
|
|
620
|
+
var timedOut = false;
|
|
621
|
+
var timeout = setTimeout(function () {
|
|
622
|
+
timedOut = true;
|
|
623
|
+
child.kill('SIGTERM');
|
|
624
|
+
setTimeout(function () {
|
|
625
|
+
if (!child.killed) {
|
|
626
|
+
child.kill('SIGKILL');
|
|
627
|
+
}
|
|
628
|
+
}, 5000);
|
|
629
|
+
}, timeoutMs);
|
|
630
|
+
(_a = child.stdout) === null || _a === void 0 ? void 0 : _a.on('data', function (data) {
|
|
631
|
+
stdout += data.toString();
|
|
632
|
+
});
|
|
633
|
+
(_b = child.stderr) === null || _b === void 0 ? void 0 : _b.on('data', function (data) {
|
|
634
|
+
stderr += data.toString();
|
|
635
|
+
});
|
|
636
|
+
child.on('close', function (code) {
|
|
637
|
+
clearTimeout(timeout);
|
|
638
|
+
if (timedOut) {
|
|
639
|
+
reject(new Error("Execution timed out after " + timeoutMs + "ms"));
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
if (code !== 0) {
|
|
643
|
+
reject(new Error(stderr || "Process exited with code " + code));
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
resolve(stdout);
|
|
647
|
+
});
|
|
648
|
+
child.on('error', function (error) {
|
|
649
|
+
clearTimeout(timeout);
|
|
650
|
+
reject(error);
|
|
651
|
+
});
|
|
652
|
+
})];
|
|
443
653
|
});
|
|
444
654
|
});
|
|
445
|
-
}
|
|
655
|
+
};
|
|
446
656
|
/**
|
|
447
657
|
* Build worker command for container execution
|
|
448
658
|
*/
|
|
449
|
-
buildWorkerCommand(options) {
|
|
659
|
+
ContainerWorkerPool.prototype.buildWorkerCommand = function (options) {
|
|
450
660
|
// Use npx to run claude-flow daemon trigger
|
|
451
661
|
return [
|
|
452
662
|
'npx', 'claude-flow@v3alpha',
|
|
@@ -454,128 +664,188 @@ export class ContainerWorkerPool extends EventEmitter {
|
|
|
454
664
|
'-w', options.workerType,
|
|
455
665
|
'--headless',
|
|
456
666
|
];
|
|
457
|
-
}
|
|
667
|
+
};
|
|
458
668
|
/**
|
|
459
669
|
* Process queued tasks
|
|
460
670
|
*/
|
|
461
|
-
processQueue() {
|
|
671
|
+
ContainerWorkerPool.prototype.processQueue = function () {
|
|
462
672
|
while (this.taskQueue.length > 0) {
|
|
463
|
-
|
|
673
|
+
var container = this.getReadyContainer();
|
|
464
674
|
if (!container)
|
|
465
675
|
break;
|
|
466
|
-
|
|
676
|
+
var task = this.taskQueue.shift();
|
|
467
677
|
if (task) {
|
|
468
678
|
this.executeInContainer(container, task.options)
|
|
469
|
-
.then(task.resolve)
|
|
470
|
-
.catch(task.reject);
|
|
679
|
+
.then(task.resolve)["catch"](task.reject);
|
|
471
680
|
}
|
|
472
681
|
}
|
|
473
|
-
}
|
|
682
|
+
};
|
|
474
683
|
// ============================================
|
|
475
684
|
// Private Methods - Health & Maintenance
|
|
476
685
|
// ============================================
|
|
477
686
|
/**
|
|
478
687
|
* Start health check timer
|
|
479
688
|
*/
|
|
480
|
-
startHealthChecks() {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
689
|
+
ContainerWorkerPool.prototype.startHealthChecks = function () {
|
|
690
|
+
var _this = this;
|
|
691
|
+
this.healthCheckTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
692
|
+
return __generator(this, function (_a) {
|
|
693
|
+
switch (_a.label) {
|
|
694
|
+
case 0: return [4 /*yield*/, this.runHealthChecks()];
|
|
695
|
+
case 1:
|
|
696
|
+
_a.sent();
|
|
697
|
+
return [2 /*return*/];
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
}); }, this.config.healthCheckIntervalMs);
|
|
701
|
+
this.healthCheckTimer.unref();
|
|
702
|
+
};
|
|
485
703
|
/**
|
|
486
704
|
* Run health checks on all containers
|
|
487
705
|
*/
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
706
|
+
ContainerWorkerPool.prototype.runHealthChecks = function () {
|
|
707
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
708
|
+
var _i, _a, _b, id, container, stdout, output, _c;
|
|
709
|
+
return __generator(this, function (_d) {
|
|
710
|
+
switch (_d.label) {
|
|
711
|
+
case 0:
|
|
712
|
+
_i = 0, _a = this.containers;
|
|
713
|
+
_d.label = 1;
|
|
714
|
+
case 1:
|
|
715
|
+
if (!(_i < _a.length)) return [3 /*break*/, 11];
|
|
716
|
+
_b = _a[_i], id = _b[0], container = _b[1];
|
|
717
|
+
if (container.state === 'terminated')
|
|
718
|
+
return [3 /*break*/, 10];
|
|
719
|
+
_d.label = 2;
|
|
720
|
+
case 2:
|
|
721
|
+
_d.trys.push([2, 9, , 10]);
|
|
722
|
+
return [4 /*yield*/, execAsync("docker inspect -f '{{.State.Running}}' " + container.name, { timeout: 10000 })];
|
|
723
|
+
case 3:
|
|
724
|
+
stdout = (_d.sent()).stdout;
|
|
725
|
+
output = stdout.trim();
|
|
726
|
+
if (!(output !== 'true')) return [3 /*break*/, 7];
|
|
727
|
+
container.healthCheckFailures++;
|
|
728
|
+
if (!(container.healthCheckFailures >= 3)) return [3 /*break*/, 6];
|
|
499
729
|
container.state = 'unhealthy';
|
|
500
|
-
this.emit('containerUnhealthy', { id, name: container.name });
|
|
730
|
+
this.emit('containerUnhealthy', { id: id, name: container.name });
|
|
501
731
|
// Remove and replace
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
732
|
+
return [4 /*yield*/, this.terminateContainer(id)];
|
|
733
|
+
case 4:
|
|
734
|
+
// Remove and replace
|
|
735
|
+
_d.sent();
|
|
736
|
+
if (!(this.containers.size < this.config.minContainers)) return [3 /*break*/, 6];
|
|
737
|
+
return [4 /*yield*/, this.createContainer()];
|
|
738
|
+
case 5:
|
|
739
|
+
_d.sent();
|
|
740
|
+
_d.label = 6;
|
|
741
|
+
case 6: return [3 /*break*/, 8];
|
|
742
|
+
case 7:
|
|
743
|
+
container.healthCheckFailures = 0;
|
|
744
|
+
_d.label = 8;
|
|
745
|
+
case 8: return [3 /*break*/, 10];
|
|
746
|
+
case 9:
|
|
747
|
+
_c = _d.sent();
|
|
748
|
+
container.healthCheckFailures++;
|
|
749
|
+
return [3 /*break*/, 10];
|
|
750
|
+
case 10:
|
|
751
|
+
_i++;
|
|
752
|
+
return [3 /*break*/, 1];
|
|
753
|
+
case 11:
|
|
754
|
+
this.emit('healthCheckComplete', { containers: this.containers.size });
|
|
755
|
+
return [2 /*return*/];
|
|
510
756
|
}
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
this.emit('healthCheckComplete', { containers: this.containers.size });
|
|
517
|
-
}
|
|
757
|
+
});
|
|
758
|
+
});
|
|
759
|
+
};
|
|
518
760
|
/**
|
|
519
761
|
* Start idle check timer
|
|
520
762
|
*/
|
|
521
|
-
startIdleChecks() {
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
763
|
+
ContainerWorkerPool.prototype.startIdleChecks = function () {
|
|
764
|
+
var _this = this;
|
|
765
|
+
this.idleCheckTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
766
|
+
return __generator(this, function (_a) {
|
|
767
|
+
switch (_a.label) {
|
|
768
|
+
case 0: return [4 /*yield*/, this.runIdleChecks()];
|
|
769
|
+
case 1:
|
|
770
|
+
_a.sent();
|
|
771
|
+
return [2 /*return*/];
|
|
772
|
+
}
|
|
773
|
+
});
|
|
774
|
+
}); }, 60000); // Check every minute
|
|
775
|
+
this.idleCheckTimer.unref();
|
|
776
|
+
};
|
|
526
777
|
/**
|
|
527
778
|
* Terminate idle containers above minimum
|
|
528
779
|
*/
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
780
|
+
ContainerWorkerPool.prototype.runIdleChecks = function () {
|
|
781
|
+
var _a;
|
|
782
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
783
|
+
var now, readyContainers, toTerminate, _i, toTerminate_1, container, lastUsed;
|
|
784
|
+
return __generator(this, function (_b) {
|
|
785
|
+
switch (_b.label) {
|
|
786
|
+
case 0:
|
|
787
|
+
now = Date.now();
|
|
788
|
+
readyContainers = Array.from(this.containers.values())
|
|
789
|
+
.filter(function (c) { return c.state === 'ready'; })
|
|
790
|
+
.sort(function (a, b) { var _a, _b; return (((_a = a.lastUsedAt) === null || _a === void 0 ? void 0 : _a.getTime()) || 0) - (((_b = b.lastUsedAt) === null || _b === void 0 ? void 0 : _b.getTime()) || 0); });
|
|
791
|
+
toTerminate = readyContainers.slice(this.config.minContainers);
|
|
792
|
+
_i = 0, toTerminate_1 = toTerminate;
|
|
793
|
+
_b.label = 1;
|
|
794
|
+
case 1:
|
|
795
|
+
if (!(_i < toTerminate_1.length)) return [3 /*break*/, 4];
|
|
796
|
+
container = toTerminate_1[_i];
|
|
797
|
+
lastUsed = ((_a = container.lastUsedAt) === null || _a === void 0 ? void 0 : _a.getTime()) || container.createdAt.getTime();
|
|
798
|
+
if (!(now - lastUsed > this.config.idleTimeoutMs)) return [3 /*break*/, 3];
|
|
799
|
+
return [4 /*yield*/, this.terminateContainer(container.id)];
|
|
800
|
+
case 2:
|
|
801
|
+
_b.sent();
|
|
802
|
+
this.emit('containerIdleTerminated', { id: container.id, name: container.name });
|
|
803
|
+
_b.label = 3;
|
|
804
|
+
case 3:
|
|
805
|
+
_i++;
|
|
806
|
+
return [3 /*break*/, 1];
|
|
807
|
+
case 4: return [2 /*return*/];
|
|
808
|
+
}
|
|
809
|
+
});
|
|
810
|
+
});
|
|
811
|
+
};
|
|
544
812
|
// ============================================
|
|
545
813
|
// Private Methods - Utilities
|
|
546
814
|
// ============================================
|
|
547
815
|
/**
|
|
548
816
|
* Try to parse JSON from output
|
|
549
817
|
*/
|
|
550
|
-
tryParseJson(output) {
|
|
818
|
+
ContainerWorkerPool.prototype.tryParseJson = function (output) {
|
|
551
819
|
try {
|
|
552
|
-
|
|
820
|
+
var jsonMatch = output.match(/\{[\s\S]*\}/);
|
|
553
821
|
if (jsonMatch) {
|
|
554
822
|
return JSON.parse(jsonMatch[0]);
|
|
555
823
|
}
|
|
556
824
|
return JSON.parse(output.trim());
|
|
557
825
|
}
|
|
558
|
-
catch {
|
|
826
|
+
catch (_a) {
|
|
559
827
|
return undefined;
|
|
560
828
|
}
|
|
561
|
-
}
|
|
829
|
+
};
|
|
562
830
|
/**
|
|
563
831
|
* Create an error result
|
|
564
832
|
*/
|
|
565
|
-
createErrorResult(workerType, error) {
|
|
833
|
+
ContainerWorkerPool.prototype.createErrorResult = function (workerType, error) {
|
|
566
834
|
return {
|
|
567
835
|
success: false,
|
|
568
836
|
output: '',
|
|
569
837
|
durationMs: 0,
|
|
570
838
|
model: 'unknown',
|
|
571
839
|
sandboxMode: this.config.defaultSandbox,
|
|
572
|
-
workerType,
|
|
840
|
+
workerType: workerType,
|
|
573
841
|
timestamp: new Date(),
|
|
574
|
-
executionId:
|
|
575
|
-
error
|
|
842
|
+
executionId: "error_" + Date.now(),
|
|
843
|
+
error: error
|
|
576
844
|
};
|
|
577
|
-
}
|
|
578
|
-
|
|
845
|
+
};
|
|
846
|
+
return ContainerWorkerPool;
|
|
847
|
+
}(EventEmitter));
|
|
848
|
+
export { ContainerWorkerPool };
|
|
579
849
|
// Export default
|
|
580
850
|
export default ContainerWorkerPool;
|
|
581
851
|
//# sourceMappingURL=container-worker-pool.js.map
|