kynjal-cli 4.0.0 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/appliance/gguf-engine.d.ts +91 -0
- package/dist/src/appliance/gguf-engine.d.ts.map +1 -0
- package/dist/src/appliance/gguf-engine.js +286 -525
- package/dist/src/appliance/gguf-engine.js.map +1 -1
- package/dist/src/appliance/ruvllm-bridge.d.ts +102 -0
- package/dist/src/appliance/ruvllm-bridge.d.ts.map +1 -0
- package/dist/src/appliance/ruvllm-bridge.js +203 -403
- package/dist/src/appliance/ruvllm-bridge.js.map +1 -1
- package/dist/src/appliance/rvfa-builder.d.ts +44 -0
- package/dist/src/appliance/rvfa-builder.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-builder.js +154 -208
- package/dist/src/appliance/rvfa-builder.js.map +1 -1
- package/dist/src/appliance/rvfa-distribution.d.ts +97 -0
- package/dist/src/appliance/rvfa-distribution.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-distribution.js +260 -423
- package/dist/src/appliance/rvfa-distribution.js.map +1 -1
- package/dist/src/appliance/rvfa-format.d.ts +111 -0
- package/dist/src/appliance/rvfa-format.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-format.js +128 -200
- package/dist/src/appliance/rvfa-format.js.map +1 -1
- package/dist/src/appliance/rvfa-runner.d.ts +69 -0
- package/dist/src/appliance/rvfa-runner.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-runner.js +168 -304
- package/dist/src/appliance/rvfa-runner.js.map +1 -1
- package/dist/src/appliance/rvfa-signing.d.ts +123 -0
- package/dist/src/appliance/rvfa-signing.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-signing.js +173 -295
- package/dist/src/appliance/rvfa-signing.js.map +1 -1
- package/dist/src/benchmarks/pretrain/index.d.ts +58 -0
- package/dist/src/benchmarks/pretrain/index.d.ts.map +1 -0
- package/dist/src/benchmarks/pretrain/index.js +331 -542
- package/dist/src/benchmarks/pretrain/index.js.map +1 -1
- package/dist/src/commands/agent.js +574 -697
- package/dist/src/commands/agent.js.map +1 -1
- package/dist/src/commands/analyze.js +1218 -1548
- package/dist/src/commands/analyze.js.map +1 -1
- package/dist/src/commands/appliance-advanced.js +158 -267
- package/dist/src/commands/appliance-advanced.js.map +1 -1
- package/dist/src/commands/appliance.js +318 -493
- package/dist/src/commands/appliance.js.map +1 -1
- package/dist/src/commands/benchmark.js +372 -523
- package/dist/src/commands/benchmark.js.map +1 -1
- package/dist/src/commands/claims.js +274 -364
- package/dist/src/commands/claims.js.map +1 -1
- package/dist/src/commands/cleanup.js +113 -157
- package/dist/src/commands/cleanup.js.map +1 -1
- package/dist/src/commands/completions.js +477 -118
- package/dist/src/commands/completions.js.map +1 -1
- package/dist/src/commands/config.js +237 -303
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/daemon.js +487 -596
- package/dist/src/commands/daemon.js.map +1 -1
- package/dist/src/commands/deployment.js +194 -275
- package/dist/src/commands/deployment.js.map +1 -1
- package/dist/src/commands/doctor.js +504 -686
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/embeddings.js +1293 -1543
- package/dist/src/commands/embeddings.js.map +1 -1
- package/dist/src/commands/guidance.js +449 -596
- package/dist/src/commands/guidance.js.map +1 -1
- package/dist/src/commands/hive-mind.js +854 -938
- package/dist/src/commands/hive-mind.js.map +1 -1
- package/dist/src/commands/hooks.js +3112 -3519
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.d.ts +115 -0
- package/dist/src/commands/index.d.ts.map +1 -0
- package/dist/src/commands/index.js +126 -308
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/init.js +788 -940
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/issues.js +383 -558
- package/dist/src/commands/issues.js.map +1 -1
- package/dist/src/commands/mcp.js +493 -605
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/memory.js +833 -1026
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/commands/migrate.js +282 -347
- package/dist/src/commands/migrate.js.map +1 -1
- package/dist/src/commands/neural.js +1289 -1563
- package/dist/src/commands/neural.js.map +1 -1
- package/dist/src/commands/performance.js +497 -643
- package/dist/src/commands/performance.js.map +1 -1
- package/dist/src/commands/plugins.js +668 -841
- package/dist/src/commands/plugins.js.map +1 -1
- package/dist/src/commands/process.js +392 -447
- package/dist/src/commands/process.js.map +1 -1
- package/dist/src/commands/progress.js +162 -256
- package/dist/src/commands/progress.js.map +1 -1
- package/dist/src/commands/providers.js +150 -220
- package/dist/src/commands/providers.js.map +1 -1
- package/dist/src/commands/route.js +520 -665
- package/dist/src/commands/route.js.map +1 -1
- package/dist/src/commands/ruvector/backup.js +505 -651
- package/dist/src/commands/ruvector/backup.js.map +1 -1
- package/dist/src/commands/ruvector/benchmark.js +349 -401
- package/dist/src/commands/ruvector/benchmark.js.map +1 -1
- package/dist/src/commands/ruvector/import.js +224 -266
- package/dist/src/commands/ruvector/import.js.map +1 -1
- package/dist/src/commands/ruvector/index.js +37 -75
- package/dist/src/commands/ruvector/index.js.map +1 -1
- package/dist/src/commands/ruvector/init.js +336 -359
- package/dist/src/commands/ruvector/init.js.map +1 -1
- package/dist/src/commands/ruvector/migrate.js +335 -322
- package/dist/src/commands/ruvector/migrate.js.map +1 -1
- package/dist/src/commands/ruvector/optimize.js +375 -431
- package/dist/src/commands/ruvector/optimize.js.map +1 -1
- package/dist/src/commands/ruvector/setup.js +703 -117
- package/dist/src/commands/ruvector/setup.js.map +1 -1
- package/dist/src/commands/ruvector/status.js +364 -419
- package/dist/src/commands/ruvector/status.js.map +1 -1
- package/dist/src/commands/security.js +485 -608
- package/dist/src/commands/security.js.map +1 -1
- package/dist/src/commands/session.js +504 -626
- package/dist/src/commands/session.js.map +1 -1
- package/dist/src/commands/start.js +267 -364
- package/dist/src/commands/start.js.map +1 -1
- package/dist/src/commands/status.js +380 -486
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/commands/swarm.js +408 -488
- package/dist/src/commands/swarm.js.map +1 -1
- package/dist/src/commands/task.js +423 -538
- package/dist/src/commands/task.js.map +1 -1
- package/dist/src/commands/transfer-store.js +322 -412
- package/dist/src/commands/transfer-store.js.map +1 -1
- package/dist/src/commands/update.js +196 -291
- package/dist/src/commands/update.js.map +1 -1
- package/dist/src/commands/workflow.js +386 -486
- package/dist/src/commands/workflow.js.map +1 -1
- package/dist/src/config-adapter.d.ts +15 -0
- package/dist/src/config-adapter.d.ts.map +1 -0
- package/dist/src/config-adapter.js +38 -39
- package/dist/src/config-adapter.js.map +1 -1
- package/dist/src/index.d.ts +77 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +309 -411
- package/dist/src/index.js.map +1 -1
- package/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
- package/dist/src/infrastructure/in-memory-repositories.d.ts.map +1 -0
- package/dist/src/infrastructure/in-memory-repositories.js +246 -507
- package/dist/src/infrastructure/in-memory-repositories.js.map +1 -1
- package/dist/src/init/claudemd-generator.d.ts +25 -0
- package/dist/src/init/claudemd-generator.d.ts.map +1 -0
- package/dist/src/init/claudemd-generator.js +368 -78
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/init/executor.d.ts +41 -0
- package/dist/src/init/executor.d.ts.map +1 -0
- package/dist/src/init/executor.js +1307 -996
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/helpers-generator.d.ts +60 -0
- package/dist/src/init/helpers-generator.d.ts.map +1 -0
- package/dist/src/init/helpers-generator.js +657 -12
- package/dist/src/init/helpers-generator.js.map +1 -1
- package/dist/src/init/index.d.ts +1 -1
- package/dist/src/init/index.d.ts.map +1 -1
- package/dist/src/init/index.js +1 -1
- package/dist/src/init/index.js.map +1 -1
- package/dist/src/init/mcp-generator.js +33 -37
- package/dist/src/init/mcp-generator.js.map +1 -1
- package/dist/src/init/settings-generator.js +76 -77
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/init/statusline-generator.js +801 -3
- package/dist/src/init/statusline-generator.js.map +1 -1
- package/dist/src/init/types.d.ts +1 -1
- package/dist/src/init/types.d.ts.map +1 -1
- package/dist/src/init/types.js +76 -59
- package/dist/src/init/types.js.map +1 -1
- package/dist/src/mcp-client.d.ts +92 -0
- package/dist/src/mcp-client.d.ts.map +1 -0
- package/dist/src/mcp-client.js +81 -125
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-server.d.ts +161 -0
- package/dist/src/mcp-server.d.ts.map +1 -0
- package/dist/src/mcp-server.js +470 -757
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +391 -492
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/agentdb-tools.js +332 -533
- package/dist/src/mcp-tools/agentdb-tools.js.map +1 -1
- package/dist/src/mcp-tools/analyze-tools.js +172 -236
- package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
- package/dist/src/mcp-tools/auto-install.d.ts +83 -0
- package/dist/src/mcp-tools/auto-install.d.ts.map +1 -0
- package/dist/src/mcp-tools/auto-install.js +80 -142
- package/dist/src/mcp-tools/auto-install.js.map +1 -1
- package/dist/src/mcp-tools/browser-tools.js +252 -375
- package/dist/src/mcp-tools/browser-tools.js.map +1 -1
- package/dist/src/mcp-tools/claims-tools.js +473 -565
- package/dist/src/mcp-tools/claims-tools.js.map +1 -1
- package/dist/src/mcp-tools/config-tools.js +197 -272
- package/dist/src/mcp-tools/config-tools.js.map +1 -1
- package/dist/src/mcp-tools/coordination-tools.js +500 -572
- package/dist/src/mcp-tools/coordination-tools.js.map +1 -1
- package/dist/src/mcp-tools/daa-tools.js +286 -364
- package/dist/src/mcp-tools/daa-tools.js.map +1 -1
- package/dist/src/mcp-tools/embeddings-tools.js +582 -693
- package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
- package/dist/src/mcp-tools/github-tools.js +260 -311
- package/dist/src/mcp-tools/github-tools.js.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.js +573 -640
- package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +2215 -2648
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +350 -505
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/neural-tools.js +315 -412
- package/dist/src/mcp-tools/neural-tools.js.map +1 -1
- package/dist/src/mcp-tools/performance-tools.js +420 -480
- package/dist/src/mcp-tools/performance-tools.js.map +1 -1
- package/dist/src/mcp-tools/progress-tools.js +204 -278
- package/dist/src/mcp-tools/progress-tools.js.map +1 -1
- package/dist/src/mcp-tools/ruvllm-tools.js +163 -279
- package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -1
- package/dist/src/mcp-tools/security-tools.js +297 -429
- package/dist/src/mcp-tools/security-tools.js.map +1 -1
- package/dist/src/mcp-tools/session-tools.js +185 -234
- package/dist/src/mcp-tools/session-tools.js.map +1 -1
- package/dist/src/mcp-tools/swarm-tools.js +207 -260
- package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
- package/dist/src/mcp-tools/system-tools.js +276 -325
- package/dist/src/mcp-tools/system-tools.js.map +1 -1
- package/dist/src/mcp-tools/task-tools.js +270 -336
- package/dist/src/mcp-tools/task-tools.js.map +1 -1
- package/dist/src/mcp-tools/terminal-tools.js +148 -196
- package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
- package/dist/src/mcp-tools/transfer-tools.js +186 -333
- package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
- package/dist/src/mcp-tools/types.d.ts +31 -0
- package/dist/src/mcp-tools/types.d.ts.map +1 -0
- package/dist/src/mcp-tools/wasm-agent-tools.js +133 -280
- package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/workflow-tools.js +405 -450
- package/dist/src/mcp-tools/workflow-tools.js.map +1 -1
- package/dist/src/memory/ewc-consolidation.d.ts +295 -0
- package/dist/src/memory/ewc-consolidation.d.ts.map +1 -0
- package/dist/src/memory/ewc-consolidation.js +190 -303
- package/dist/src/memory/ewc-consolidation.js.map +1 -1
- package/dist/src/memory/intelligence.d.ts +338 -0
- package/dist/src/memory/intelligence.d.ts.map +1 -0
- package/dist/src/memory/intelligence.js +569 -794
- package/dist/src/memory/intelligence.js.map +1 -1
- package/dist/src/memory/memory-bridge.d.ts +407 -0
- package/dist/src/memory/memory-bridge.d.ts.map +1 -0
- package/dist/src/memory/memory-bridge.js +1170 -1640
- package/dist/src/memory/memory-bridge.js.map +1 -1
- package/dist/src/memory/memory-initializer.d.ts +412 -0
- package/dist/src/memory/memory-initializer.d.ts.map +1 -0
- package/dist/src/memory/memory-initializer.js +1836 -1851
- package/dist/src/memory/memory-initializer.js.map +1 -1
- package/dist/src/memory/sona-optimizer.d.ts +227 -0
- package/dist/src/memory/sona-optimizer.d.ts.map +1 -0
- package/dist/src/memory/sona-optimizer.js +199 -329
- package/dist/src/memory/sona-optimizer.js.map +1 -1
- package/dist/src/output.d.ts +2 -2
- package/dist/src/output.d.ts.map +1 -1
- package/dist/src/output.js +242 -272
- package/dist/src/output.js.map +1 -1
- package/dist/src/parser.d.ts +51 -0
- package/dist/src/parser.d.ts.map +1 -0
- package/dist/src/parser.js +140 -187
- package/dist/src/parser.js.map +1 -1
- package/dist/src/plugins/manager.d.ts +133 -0
- package/dist/src/plugins/manager.d.ts.map +1 -0
- package/dist/src/plugins/manager.js +285 -521
- package/dist/src/plugins/manager.js.map +1 -1
- package/dist/src/plugins/store/discovery.d.ts +88 -0
- package/dist/src/plugins/store/discovery.d.ts.map +1 -0
- package/dist/src/plugins/store/discovery.js +271 -358
- package/dist/src/plugins/store/discovery.js.map +1 -1
- package/dist/src/plugins/store/index.d.ts +76 -0
- package/dist/src/plugins/store/index.d.ts.map +1 -0
- package/dist/src/plugins/store/index.js +48 -105
- package/dist/src/plugins/store/index.js.map +1 -1
- package/dist/src/plugins/store/search.d.ts +46 -0
- package/dist/src/plugins/store/search.d.ts.map +1 -0
- package/dist/src/plugins/store/search.js +69 -107
- package/dist/src/plugins/store/search.js.map +1 -1
- package/dist/src/plugins/store/types.d.ts +274 -0
- package/dist/src/plugins/store/types.d.ts.map +1 -0
- package/dist/src/plugins/tests/demo-plugin-store.js +113 -160
- package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -1
- package/dist/src/plugins/tests/standalone-test.js +172 -223
- package/dist/src/plugins/tests/standalone-test.js.map +1 -1
- package/dist/src/plugins/tests/test-plugin-store.js +190 -228
- package/dist/src/plugins/tests/test-plugin-store.js.map +1 -1
- package/dist/src/production/circuit-breaker.d.ts +101 -0
- package/dist/src/production/circuit-breaker.d.ts.map +1 -0
- package/dist/src/production/circuit-breaker.js +62 -126
- package/dist/src/production/circuit-breaker.js.map +1 -1
- package/dist/src/production/error-handler.d.ts +92 -0
- package/dist/src/production/error-handler.d.ts.map +1 -0
- package/dist/src/production/error-handler.js +86 -156
- package/dist/src/production/error-handler.js.map +1 -1
- package/dist/src/production/monitoring.d.ts +161 -0
- package/dist/src/production/monitoring.d.ts.map +1 -0
- package/dist/src/production/monitoring.js +139 -220
- package/dist/src/production/monitoring.js.map +1 -1
- package/dist/src/production/rate-limiter.d.ts +80 -0
- package/dist/src/production/rate-limiter.d.ts.map +1 -0
- package/dist/src/production/rate-limiter.js +74 -93
- package/dist/src/production/rate-limiter.js.map +1 -1
- package/dist/src/production/retry.d.ts +48 -0
- package/dist/src/production/retry.d.ts.map +1 -0
- package/dist/src/production/retry.js +75 -167
- package/dist/src/production/retry.js.map +1 -1
- package/dist/src/prompt.d.ts +44 -0
- package/dist/src/prompt.d.ts.map +1 -0
- package/dist/src/prompt.js +436 -560
- package/dist/src/prompt.js.map +1 -1
- package/dist/src/runtime/headless.d.ts +60 -0
- package/dist/src/runtime/headless.d.ts.map +1 -0
- package/dist/src/runtime/headless.js +197 -286
- package/dist/src/runtime/headless.js.map +1 -1
- package/dist/src/ruvector/agent-wasm.d.ts +182 -0
- package/dist/src/ruvector/agent-wasm.d.ts.map +1 -0
- package/dist/src/ruvector/agent-wasm.js +156 -351
- package/dist/src/ruvector/agent-wasm.js.map +1 -1
- package/dist/src/ruvector/ast-analyzer.d.ts +67 -0
- package/dist/src/ruvector/ast-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/ast-analyzer.js +145 -232
- package/dist/src/ruvector/ast-analyzer.js.map +1 -1
- package/dist/src/ruvector/coverage-router.d.ts +160 -0
- package/dist/src/ruvector/coverage-router.d.ts.map +1 -0
- package/dist/src/ruvector/coverage-router.js +287 -419
- package/dist/src/ruvector/coverage-router.js.map +1 -1
- package/dist/src/ruvector/coverage-tools.js +56 -101
- package/dist/src/ruvector/coverage-tools.js.map +1 -1
- package/dist/src/ruvector/diff-classifier.d.ts +175 -0
- package/dist/src/ruvector/diff-classifier.d.ts.map +1 -0
- package/dist/src/ruvector/diff-classifier.js +324 -451
- package/dist/src/ruvector/diff-classifier.js.map +1 -1
- package/dist/src/ruvector/enhanced-model-router.d.ts +146 -0
- package/dist/src/ruvector/enhanced-model-router.d.ts.map +1 -0
- package/dist/src/ruvector/enhanced-model-router.js +260 -336
- package/dist/src/ruvector/enhanced-model-router.js.map +1 -1
- package/dist/src/ruvector/flash-attention.d.ts +195 -0
- package/dist/src/ruvector/flash-attention.d.ts.map +1 -0
- package/dist/src/ruvector/flash-attention.js +223 -254
- package/dist/src/ruvector/flash-attention.js.map +1 -1
- package/dist/src/ruvector/graph-analyzer.d.ts +187 -0
- package/dist/src/ruvector/graph-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/graph-analyzer.js +486 -680
- package/dist/src/ruvector/graph-analyzer.js.map +1 -1
- package/dist/src/ruvector/index.d.ts +40 -0
- package/dist/src/ruvector/index.d.ts.map +1 -0
- package/dist/src/ruvector/index.js +36 -106
- package/dist/src/ruvector/index.js.map +1 -1
- package/dist/src/ruvector/lora-adapter.d.ts +218 -0
- package/dist/src/ruvector/lora-adapter.d.ts.map +1 -0
- package/dist/src/ruvector/lora-adapter.js +155 -248
- package/dist/src/ruvector/lora-adapter.js.map +1 -1
- package/dist/src/ruvector/model-router.d.ts +220 -0
- package/dist/src/ruvector/model-router.d.ts.map +1 -0
- package/dist/src/ruvector/model-router.js +175 -248
- package/dist/src/ruvector/model-router.js.map +1 -1
- package/dist/src/ruvector/moe-router.d.ts +206 -0
- package/dist/src/ruvector/moe-router.d.ts.map +1 -0
- package/dist/src/ruvector/moe-router.js +228 -286
- package/dist/src/ruvector/moe-router.js.map +1 -1
- package/dist/src/ruvector/q-learning-router.d.ts +211 -0
- package/dist/src/ruvector/q-learning-router.d.ts.map +1 -0
- package/dist/src/ruvector/q-learning-router.js +257 -338
- package/dist/src/ruvector/q-learning-router.js.map +1 -1
- package/dist/src/ruvector/ruvllm-wasm.d.ts +179 -0
- package/dist/src/ruvector/ruvllm-wasm.d.ts.map +1 -0
- package/dist/src/ruvector/ruvllm-wasm.js +270 -434
- package/dist/src/ruvector/ruvllm-wasm.js.map +1 -1
- package/dist/src/ruvector/semantic-router.d.ts +77 -0
- package/dist/src/ruvector/semantic-router.d.ts.map +1 -0
- package/dist/src/ruvector/semantic-router.js +60 -67
- package/dist/src/ruvector/semantic-router.js.map +1 -1
- package/dist/src/ruvector/vector-db.d.ts +69 -0
- package/dist/src/ruvector/vector-db.d.ts.map +1 -0
- package/dist/src/ruvector/vector-db.js +119 -205
- package/dist/src/ruvector/vector-db.js.map +1 -1
- package/dist/src/services/agentic-flow-bridge.d.ts +50 -0
- package/dist/src/services/agentic-flow-bridge.d.ts.map +1 -0
- package/dist/src/services/agentic-flow-bridge.js +32 -105
- package/dist/src/services/agentic-flow-bridge.js.map +1 -1
- package/dist/src/services/claim-service.d.ts +204 -0
- package/dist/src/services/claim-service.d.ts.map +1 -0
- package/dist/src/services/claim-service.js +615 -940
- package/dist/src/services/claim-service.js.map +1 -1
- package/dist/src/services/container-worker-pool.d.ts +197 -0
- package/dist/src/services/container-worker-pool.d.ts.map +1 -0
- package/dist/src/services/container-worker-pool.js +398 -666
- package/dist/src/services/container-worker-pool.js.map +1 -1
- package/dist/src/services/headless-worker-executor.d.ts +304 -0
- package/dist/src/services/headless-worker-executor.d.ts.map +1 -0
- package/dist/src/services/headless-worker-executor.js +441 -467
- package/dist/src/services/headless-worker-executor.js.map +1 -1
- package/dist/src/services/index.d.ts +4 -4
- package/dist/src/services/index.d.ts.map +1 -1
- package/dist/src/services/index.js +4 -4
- package/dist/src/services/index.js.map +1 -1
- package/dist/src/services/registry-api.d.ts +58 -0
- package/dist/src/services/registry-api.d.ts.map +1 -0
- package/dist/src/services/registry-api.js +92 -200
- package/dist/src/services/registry-api.js.map +1 -1
- package/dist/src/services/ruvector-training.d.ts +222 -0
- package/dist/src/services/ruvector-training.d.ts.map +1 -0
- package/dist/src/services/ruvector-training.js +257 -337
- package/dist/src/services/ruvector-training.js.map +1 -1
- package/dist/src/services/worker-daemon.d.ts +228 -0
- package/dist/src/services/worker-daemon.d.ts.map +1 -0
- package/dist/src/services/worker-daemon.js +591 -849
- package/dist/src/services/worker-daemon.js.map +1 -1
- package/dist/src/services/worker-queue.d.ts +194 -0
- package/dist/src/services/worker-queue.d.ts.map +1 -0
- package/dist/src/services/worker-queue.js +331 -548
- package/dist/src/services/worker-queue.js.map +1 -1
- package/dist/src/suggest.d.ts +53 -0
- package/dist/src/suggest.d.ts.map +1 -0
- package/dist/src/suggest.js +45 -55
- package/dist/src/suggest.js.map +1 -1
- package/dist/src/transfer/anonymization/index.js +29 -37
- package/dist/src/transfer/anonymization/index.js.map +1 -1
- package/dist/src/transfer/deploy-seraphine.js +128 -155
- package/dist/src/transfer/deploy-seraphine.js.map +1 -1
- package/dist/src/transfer/export.d.ts +25 -0
- package/dist/src/transfer/export.d.ts.map +1 -0
- package/dist/src/transfer/export.js +84 -142
- package/dist/src/transfer/export.js.map +1 -1
- package/dist/src/transfer/index.d.ts +1 -1
- package/dist/src/transfer/index.d.ts.map +1 -1
- package/dist/src/transfer/index.js +0 -2
- package/dist/src/transfer/index.js.map +1 -1
- package/dist/src/transfer/ipfs/client.d.ts +109 -0
- package/dist/src/transfer/ipfs/client.d.ts.map +1 -0
- package/dist/src/transfer/ipfs/client.js +187 -337
- package/dist/src/transfer/ipfs/client.js.map +1 -1
- package/dist/src/transfer/ipfs/upload.d.ts +95 -0
- package/dist/src/transfer/ipfs/upload.d.ts.map +1 -0
- package/dist/src/transfer/ipfs/upload.js +288 -434
- package/dist/src/transfer/ipfs/upload.js.map +1 -1
- package/dist/src/transfer/models/seraphine.d.ts +72 -0
- package/dist/src/transfer/models/seraphine.d.ts.map +1 -0
- package/dist/src/transfer/models/seraphine.js +55 -55
- package/dist/src/transfer/models/seraphine.js.map +1 -1
- package/dist/src/transfer/serialization/cfp.d.ts +49 -0
- package/dist/src/transfer/serialization/cfp.d.ts.map +1 -0
- package/dist/src/transfer/serialization/cfp.js +30 -31
- package/dist/src/transfer/serialization/cfp.js.map +1 -1
- package/dist/src/transfer/storage/gcs.d.ts +82 -0
- package/dist/src/transfer/storage/gcs.d.ts.map +1 -0
- package/dist/src/transfer/storage/gcs.js +165 -232
- package/dist/src/transfer/storage/gcs.js.map +1 -1
- package/dist/src/transfer/store/discovery.d.ts +84 -0
- package/dist/src/transfer/store/discovery.d.ts.map +1 -0
- package/dist/src/transfer/store/discovery.js +239 -349
- package/dist/src/transfer/store/discovery.js.map +1 -1
- package/dist/src/transfer/store/download.d.ts +70 -0
- package/dist/src/transfer/store/download.d.ts.map +1 -0
- package/dist/src/transfer/store/download.js +243 -365
- package/dist/src/transfer/store/download.js.map +1 -1
- package/dist/src/transfer/store/index.d.ts +84 -0
- package/dist/src/transfer/store/index.d.ts.map +1 -0
- package/dist/src/transfer/store/index.js +63 -130
- package/dist/src/transfer/store/index.js.map +1 -1
- package/dist/src/transfer/store/publish.d.ts +76 -0
- package/dist/src/transfer/store/publish.d.ts.map +1 -0
- package/dist/src/transfer/store/publish.js +184 -258
- package/dist/src/transfer/store/publish.js.map +1 -1
- package/dist/src/transfer/store/registry.js +50 -72
- package/dist/src/transfer/store/registry.js.map +1 -1
- package/dist/src/transfer/store/search.d.ts +54 -0
- package/dist/src/transfer/store/search.d.ts.map +1 -0
- package/dist/src/transfer/store/search.js +64 -96
- package/dist/src/transfer/store/search.js.map +1 -1
- package/dist/src/transfer/store/tests/standalone-test.js +174 -231
- package/dist/src/transfer/store/tests/standalone-test.js.map +1 -1
- package/dist/src/transfer/test-seraphine.js +95 -130
- package/dist/src/transfer/test-seraphine.js.map +1 -1
- package/dist/src/transfer/tests/test-store.js +194 -239
- package/dist/src/transfer/tests/test-store.js.map +1 -1
- package/dist/src/transfer/types.d.ts +245 -0
- package/dist/src/transfer/types.d.ts.map +1 -0
- package/dist/src/types.d.ts +198 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +26 -55
- package/dist/src/types.js.map +1 -1
- package/dist/src/update/checker.d.ts +34 -0
- package/dist/src/update/checker.d.ts.map +1 -0
- package/dist/src/update/checker.js +106 -183
- package/dist/src/update/checker.js.map +1 -1
- package/dist/src/update/executor.d.ts +32 -0
- package/dist/src/update/executor.d.ts.map +1 -0
- package/dist/src/update/executor.js +135 -198
- package/dist/src/update/executor.js.map +1 -1
- package/dist/src/update/index.d.ts +33 -0
- package/dist/src/update/index.d.ts.map +1 -0
- package/dist/src/update/index.js +38 -85
- package/dist/src/update/index.js.map +1 -1
- package/dist/src/update/rate-limiter.d.ts +20 -0
- package/dist/src/update/rate-limiter.d.ts.map +1 -0
- package/dist/src/update/rate-limiter.js +19 -31
- package/dist/src/update/rate-limiter.js.map +1 -1
- package/dist/src/update/validator.d.ts +17 -0
- package/dist/src/update/validator.d.ts.map +1 -0
- package/dist/src/update/validator.js +38 -64
- package/dist/src/update/validator.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -2,62 +2,6 @@
|
|
|
2
2
|
* V3 CLI Daemon Command
|
|
3
3
|
* Manages background worker daemon (Node.js-based, similar to shell helpers)
|
|
4
4
|
*/
|
|
5
|
-
var __assign = (this && this.__assign) || function () {
|
|
6
|
-
__assign = Object.assign || function(t) {
|
|
7
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
-
s = arguments[i];
|
|
9
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
-
t[p] = s[p];
|
|
11
|
-
}
|
|
12
|
-
return t;
|
|
13
|
-
};
|
|
14
|
-
return __assign.apply(this, arguments);
|
|
15
|
-
};
|
|
16
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
27
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
-
function step(op) {
|
|
30
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
-
while (_) try {
|
|
32
|
-
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;
|
|
33
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
-
switch (op[0]) {
|
|
35
|
-
case 0: case 1: t = op; break;
|
|
36
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
-
default:
|
|
40
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
-
if (t[2]) _.ops.pop();
|
|
45
|
-
_.trys.pop(); continue;
|
|
46
|
-
}
|
|
47
|
-
op = body.call(thisArg, _);
|
|
48
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
53
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
54
|
-
if (ar || !(i in from)) {
|
|
55
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
56
|
-
ar[i] = from[i];
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
60
|
-
};
|
|
61
5
|
import { output } from '../output.js';
|
|
62
6
|
import { getDaemon, startDaemon, stopDaemon } from '../services/worker-daemon.js';
|
|
63
7
|
import { spawn } from 'child_process';
|
|
@@ -65,13 +9,13 @@ import { fileURLToPath } from 'url';
|
|
|
65
9
|
import { dirname, join, resolve } from 'path';
|
|
66
10
|
import * as fs from 'fs';
|
|
67
11
|
// Start daemon subcommand
|
|
68
|
-
|
|
12
|
+
const startCommand = {
|
|
69
13
|
name: 'start',
|
|
70
14
|
description: 'Start the worker daemon with all enabled background workers',
|
|
71
15
|
options: [
|
|
72
16
|
{ name: 'workers', short: 'w', type: 'string', description: 'Comma-separated list of workers to enable (default: map,audit,optimize,consolidate,testgaps)' },
|
|
73
17
|
{ name: 'quiet', short: 'Q', type: 'boolean', description: 'Suppress output' },
|
|
74
|
-
{ name: 'background', short: 'b', type: 'boolean', description: 'Run daemon in background (detached process)',
|
|
18
|
+
{ name: 'background', short: 'b', type: 'boolean', description: 'Run daemon in background (detached process)', default: true },
|
|
75
19
|
{ name: 'foreground', short: 'f', type: 'boolean', description: 'Run daemon in foreground (blocks terminal)' },
|
|
76
20
|
{ name: 'headless', type: 'boolean', description: 'Enable headless worker execution (E2B sandbox)' },
|
|
77
21
|
{ name: 'sandbox', type: 'string', description: 'Default sandbox mode for headless workers', choices: ['strict', 'permissive', 'disabled'] },
|
|
@@ -84,255 +28,248 @@ var startCommand = {
|
|
|
84
28
|
{ command: 'claude-flow daemon start -w map,audit,optimize', description: 'Start with specific workers' },
|
|
85
29
|
{ command: 'claude-flow daemon start --headless --sandbox strict', description: 'Start with headless workers in strict sandbox' },
|
|
86
30
|
],
|
|
87
|
-
action:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
fs.
|
|
151
|
-
|
|
152
|
-
try {
|
|
153
|
-
if (fs.existsSync(pidFile_1)) {
|
|
154
|
-
fs.unlinkSync(pidFile_1);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
catch ( /* ignore */_a) { /* ignore */ }
|
|
158
|
-
};
|
|
159
|
-
process.on('exit', cleanup_1);
|
|
160
|
-
process.on('SIGINT', function () { cleanup_1(); process.exit(0); });
|
|
161
|
-
process.on('SIGTERM', function () { cleanup_1(); process.exit(0); });
|
|
162
|
-
// Ignore SIGHUP on macOS/Linux — prevents daemon death when terminal closes (#1283)
|
|
163
|
-
if (process.platform !== 'win32') {
|
|
164
|
-
process.on('SIGHUP', function () { });
|
|
31
|
+
action: async (ctx) => {
|
|
32
|
+
const quiet = ctx.flags.quiet;
|
|
33
|
+
const foreground = ctx.flags.foreground;
|
|
34
|
+
const projectRoot = process.cwd();
|
|
35
|
+
const isDaemonProcess = process.env.CLAUDE_FLOW_DAEMON === '1';
|
|
36
|
+
// Parse resource threshold overrides from CLI flags
|
|
37
|
+
const config = {};
|
|
38
|
+
const rawMaxCpu = ctx.flags['max-cpu-load'];
|
|
39
|
+
const rawMinMem = ctx.flags['min-free-memory'];
|
|
40
|
+
// Strict numeric pattern to prevent command injection when forwarding to subprocess (S1)
|
|
41
|
+
const NUMERIC_RE = /^\d+(\.\d+)?$/;
|
|
42
|
+
const sanitize = (s) => s.replace(/[\x00-\x1f\x7f-\x9f]/g, '');
|
|
43
|
+
if (rawMaxCpu || rawMinMem) {
|
|
44
|
+
const thresholds = {};
|
|
45
|
+
if (rawMaxCpu) {
|
|
46
|
+
const val = parseFloat(rawMaxCpu);
|
|
47
|
+
if (NUMERIC_RE.test(rawMaxCpu) && isFinite(val) && val > 0 && val <= 1000) {
|
|
48
|
+
thresholds.maxCpuLoad = val;
|
|
49
|
+
}
|
|
50
|
+
else if (!quiet) {
|
|
51
|
+
output.printWarning(`Ignoring invalid --max-cpu-load value: ${sanitize(rawMaxCpu)}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (rawMinMem) {
|
|
55
|
+
const val = parseFloat(rawMinMem);
|
|
56
|
+
if (NUMERIC_RE.test(rawMinMem) && isFinite(val) && val >= 0 && val <= 100) {
|
|
57
|
+
thresholds.minFreeMemoryPercent = val;
|
|
58
|
+
}
|
|
59
|
+
else if (!quiet) {
|
|
60
|
+
output.printWarning(`Ignoring invalid --min-free-memory value: ${sanitize(rawMinMem)}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (thresholds.maxCpuLoad !== undefined || thresholds.minFreeMemoryPercent !== undefined) {
|
|
64
|
+
config.resourceThresholds = thresholds;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Check if background daemon already running (skip if we ARE the daemon process)
|
|
68
|
+
if (!isDaemonProcess) {
|
|
69
|
+
const bgPid = getBackgroundDaemonPid(projectRoot);
|
|
70
|
+
if (bgPid && isProcessRunning(bgPid)) {
|
|
71
|
+
if (!quiet) {
|
|
72
|
+
output.printWarning(`Daemon already running in background (PID: ${bgPid})`);
|
|
73
|
+
}
|
|
74
|
+
return { success: true };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Background mode (default): fork a detached process
|
|
78
|
+
if (!foreground) {
|
|
79
|
+
return startBackgroundDaemon(projectRoot, quiet, rawMaxCpu, rawMinMem);
|
|
80
|
+
}
|
|
81
|
+
// Foreground mode: run in current process (blocks terminal)
|
|
82
|
+
try {
|
|
83
|
+
const stateDir = join(projectRoot, '.claude-flow');
|
|
84
|
+
const pidFile = join(stateDir, 'daemon.pid');
|
|
85
|
+
// Ensure state directory exists
|
|
86
|
+
if (!fs.existsSync(stateDir)) {
|
|
87
|
+
fs.mkdirSync(stateDir, { recursive: true });
|
|
88
|
+
}
|
|
89
|
+
// Write PID file for foreground mode
|
|
90
|
+
fs.writeFileSync(pidFile, String(process.pid));
|
|
91
|
+
// Clean up PID file on exit
|
|
92
|
+
const cleanup = () => {
|
|
93
|
+
try {
|
|
94
|
+
if (fs.existsSync(pidFile)) {
|
|
95
|
+
fs.unlinkSync(pidFile);
|
|
165
96
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
_b.sent(); // Keep alive
|
|
230
|
-
_b.label = 7;
|
|
231
|
-
case 7: return [2 /*return*/, { success: true }];
|
|
232
|
-
case 8:
|
|
233
|
-
error_1 = _b.sent();
|
|
234
|
-
output.printError("Failed to start daemon: " + (error_1 instanceof Error ? error_1.message : String(error_1)));
|
|
235
|
-
return [2 /*return*/, { success: false, exitCode: 1 }];
|
|
236
|
-
case 9: return [2 /*return*/];
|
|
97
|
+
}
|
|
98
|
+
catch { /* ignore */ }
|
|
99
|
+
};
|
|
100
|
+
process.on('exit', cleanup);
|
|
101
|
+
process.on('SIGINT', () => { cleanup(); process.exit(0); });
|
|
102
|
+
process.on('SIGTERM', () => { cleanup(); process.exit(0); });
|
|
103
|
+
// Ignore SIGHUP on macOS/Linux — prevents daemon death when terminal closes (#1283)
|
|
104
|
+
if (process.platform !== 'win32') {
|
|
105
|
+
process.on('SIGHUP', () => { });
|
|
106
|
+
}
|
|
107
|
+
if (!quiet) {
|
|
108
|
+
const spinner = output.createSpinner({ text: 'Starting worker daemon...', spinner: 'dots' });
|
|
109
|
+
spinner.start();
|
|
110
|
+
const daemon = await startDaemon(projectRoot, config);
|
|
111
|
+
const status = daemon.getStatus();
|
|
112
|
+
spinner.succeed('Worker daemon started (foreground mode)');
|
|
113
|
+
output.writeln();
|
|
114
|
+
output.printBox([
|
|
115
|
+
`PID: ${status.pid}`,
|
|
116
|
+
`Started: ${status.startedAt?.toISOString()}`,
|
|
117
|
+
`Workers: ${status.config.workers.filter(w => w.enabled).length} enabled`,
|
|
118
|
+
`Max Concurrent: ${status.config.maxConcurrent}`,
|
|
119
|
+
`Max CPU Load: ${status.config.resourceThresholds.maxCpuLoad}`,
|
|
120
|
+
`Min Free Memory: ${status.config.resourceThresholds.minFreeMemoryPercent}%`,
|
|
121
|
+
].join('\n'), 'Daemon Status');
|
|
122
|
+
output.writeln();
|
|
123
|
+
output.writeln(output.bold('Scheduled Workers'));
|
|
124
|
+
output.printTable({
|
|
125
|
+
columns: [
|
|
126
|
+
{ key: 'type', header: 'Worker', width: 15 },
|
|
127
|
+
{ key: 'interval', header: 'Interval', width: 12 },
|
|
128
|
+
{ key: 'priority', header: 'Priority', width: 10 },
|
|
129
|
+
{ key: 'description', header: 'Description', width: 30 },
|
|
130
|
+
],
|
|
131
|
+
data: status.config.workers
|
|
132
|
+
.filter(w => w.enabled)
|
|
133
|
+
.map(w => ({
|
|
134
|
+
type: output.highlight(w.type),
|
|
135
|
+
interval: `${Math.round(w.intervalMs / 60000)}min`,
|
|
136
|
+
priority: w.priority === 'critical' ? output.error(w.priority) :
|
|
137
|
+
w.priority === 'high' ? output.warning(w.priority) :
|
|
138
|
+
output.dim(w.priority),
|
|
139
|
+
description: w.description,
|
|
140
|
+
})),
|
|
141
|
+
});
|
|
142
|
+
output.writeln();
|
|
143
|
+
output.writeln(output.dim('Press Ctrl+C to stop daemon'));
|
|
144
|
+
// Listen for worker events
|
|
145
|
+
daemon.on('worker:start', ({ type }) => {
|
|
146
|
+
output.writeln(output.dim(`[daemon] Worker starting: ${type}`));
|
|
147
|
+
});
|
|
148
|
+
daemon.on('worker:complete', ({ type, durationMs }) => {
|
|
149
|
+
output.writeln(output.success(`[daemon] Worker completed: ${type} (${durationMs}ms)`));
|
|
150
|
+
});
|
|
151
|
+
daemon.on('worker:error', ({ type, error }) => {
|
|
152
|
+
output.writeln(output.error(`[daemon] Worker failed: ${type} - ${error}`));
|
|
153
|
+
});
|
|
154
|
+
// Keep process alive
|
|
155
|
+
await new Promise(() => { }); // Never resolves - daemon runs until killed
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
await startDaemon(projectRoot, config);
|
|
159
|
+
await new Promise(() => { }); // Keep alive
|
|
237
160
|
}
|
|
238
|
-
|
|
239
|
-
|
|
161
|
+
return { success: true };
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
output.printError(`Failed to start daemon: ${error instanceof Error ? error.message : String(error)}`);
|
|
165
|
+
return { success: false, exitCode: 1 };
|
|
166
|
+
}
|
|
167
|
+
},
|
|
240
168
|
};
|
|
241
169
|
/**
|
|
242
170
|
* Validate path for security - prevents path traversal and injection
|
|
243
171
|
*/
|
|
244
172
|
function validatePath(path, label) {
|
|
245
173
|
// Must be absolute after resolution
|
|
246
|
-
|
|
174
|
+
const resolved = resolve(path);
|
|
247
175
|
// Check for null bytes (injection attack)
|
|
248
176
|
if (path.includes('\0')) {
|
|
249
|
-
throw new Error(label
|
|
177
|
+
throw new Error(`${label} contains null bytes`);
|
|
250
178
|
}
|
|
251
179
|
// Check for shell metacharacters in path components
|
|
252
180
|
if (/[;&|`$<>]/.test(path)) {
|
|
253
|
-
throw new Error(label
|
|
181
|
+
throw new Error(`${label} contains shell metacharacters`);
|
|
254
182
|
}
|
|
255
183
|
// Prevent path traversal outside expected directories
|
|
256
184
|
if (!resolved.includes('.claude-flow') && !resolved.includes('bin')) {
|
|
257
185
|
// Allow only paths within project structure
|
|
258
|
-
|
|
186
|
+
const cwd = process.cwd();
|
|
259
187
|
if (!resolved.startsWith(cwd)) {
|
|
260
|
-
throw new Error(label
|
|
188
|
+
throw new Error(`${label} escapes project directory`);
|
|
261
189
|
}
|
|
262
190
|
}
|
|
263
191
|
}
|
|
264
192
|
/**
|
|
265
193
|
* Start daemon as a detached background process
|
|
266
194
|
*/
|
|
267
|
-
function startBackgroundDaemon(projectRoot, quiet, maxCpuLoad, minFreeMemory) {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
195
|
+
async function startBackgroundDaemon(projectRoot, quiet, maxCpuLoad, minFreeMemory) {
|
|
196
|
+
// Validate and resolve project root
|
|
197
|
+
const resolvedRoot = resolve(projectRoot);
|
|
198
|
+
validatePath(resolvedRoot, 'Project root');
|
|
199
|
+
const stateDir = join(resolvedRoot, '.claude-flow');
|
|
200
|
+
const pidFile = join(stateDir, 'daemon.pid');
|
|
201
|
+
const logFile = join(stateDir, 'daemon.log');
|
|
202
|
+
// Validate all paths
|
|
203
|
+
validatePath(stateDir, 'State directory');
|
|
204
|
+
validatePath(pidFile, 'PID file');
|
|
205
|
+
validatePath(logFile, 'Log file');
|
|
206
|
+
// Ensure state directory exists
|
|
207
|
+
if (!fs.existsSync(stateDir)) {
|
|
208
|
+
fs.mkdirSync(stateDir, { recursive: true });
|
|
209
|
+
}
|
|
210
|
+
// Get path to CLI (from dist/src/commands/daemon.js -> bin/cli.js)
|
|
211
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
212
|
+
const __dirname = dirname(__filename);
|
|
213
|
+
// dist/src/commands -> dist/src -> dist -> package root -> bin/cli.js
|
|
214
|
+
const cliPath = resolve(join(__dirname, '..', '..', '..', 'bin', 'cli.js'));
|
|
215
|
+
validatePath(cliPath, 'CLI path');
|
|
216
|
+
// Verify CLI path exists
|
|
217
|
+
if (!fs.existsSync(cliPath)) {
|
|
218
|
+
output.printError(`CLI not found at: ${cliPath}`);
|
|
219
|
+
return { success: false, exitCode: 1 };
|
|
220
|
+
}
|
|
221
|
+
// Platform-aware spawn flags
|
|
222
|
+
const isWin = process.platform === 'win32';
|
|
223
|
+
const spawnOpts = {
|
|
224
|
+
cwd: resolvedRoot,
|
|
225
|
+
detached: !isWin, // detached is POSIX-only; Windows uses windowsHide
|
|
226
|
+
stdio: ['ignore', fs.openSync(logFile, 'a'), fs.openSync(logFile, 'a')],
|
|
227
|
+
env: {
|
|
228
|
+
...process.env,
|
|
229
|
+
CLAUDE_FLOW_DAEMON: '1',
|
|
230
|
+
// Prevent macOS SIGHUP kill when terminal closes
|
|
231
|
+
...(process.platform === 'darwin' ? { NOHUP: '1' } : {}),
|
|
232
|
+
},
|
|
233
|
+
...(isWin ? { shell: true, windowsHide: true } : {}),
|
|
234
|
+
};
|
|
235
|
+
// Use spawn with explicit arguments instead of shell string interpolation
|
|
236
|
+
// This prevents command injection via paths
|
|
237
|
+
const spawnArgs = [
|
|
238
|
+
cliPath,
|
|
239
|
+
'daemon', 'start', '--foreground', '--quiet',
|
|
240
|
+
];
|
|
241
|
+
// Forward resource threshold flags to the foreground child process
|
|
242
|
+
// Validate with strict numeric pattern to prevent shell injection on Windows (S1)
|
|
243
|
+
const SPAWN_NUMERIC_RE = /^\d+(\.\d+)?$/;
|
|
244
|
+
if (maxCpuLoad && SPAWN_NUMERIC_RE.test(maxCpuLoad)) {
|
|
245
|
+
spawnArgs.push('--max-cpu-load', maxCpuLoad);
|
|
246
|
+
}
|
|
247
|
+
if (minFreeMemory && SPAWN_NUMERIC_RE.test(minFreeMemory)) {
|
|
248
|
+
spawnArgs.push('--min-free-memory', minFreeMemory);
|
|
249
|
+
}
|
|
250
|
+
const child = spawn(process.execPath, spawnArgs, spawnOpts);
|
|
251
|
+
// Get PID from spawned process directly (no shell echo needed)
|
|
252
|
+
const pid = child.pid;
|
|
253
|
+
if (!pid || pid <= 0) {
|
|
254
|
+
output.printError('Failed to get daemon PID');
|
|
255
|
+
return { success: false, exitCode: 1 };
|
|
256
|
+
}
|
|
257
|
+
// Unref BEFORE writing PID file — prevents race where parent exits
|
|
258
|
+
// but child hasn't fully detached yet (fixes macOS daemon death #1283)
|
|
259
|
+
child.unref();
|
|
260
|
+
// Small delay to let the child process fully detach on macOS
|
|
261
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
262
|
+
// Save PID only after child is detached
|
|
263
|
+
fs.writeFileSync(pidFile, String(pid));
|
|
264
|
+
if (!quiet) {
|
|
265
|
+
output.printSuccess(`Daemon started in background (PID: ${pid})`);
|
|
266
|
+
output.printInfo(`Logs: ${logFile}`);
|
|
267
|
+
output.printInfo(`Stop with: claude-flow daemon stop`);
|
|
268
|
+
}
|
|
269
|
+
return { success: true };
|
|
333
270
|
}
|
|
334
271
|
// Stop daemon subcommand
|
|
335
|
-
|
|
272
|
+
const stopCommand = {
|
|
336
273
|
name: 'stop',
|
|
337
274
|
description: 'Stop the worker daemon and all background workers',
|
|
338
275
|
options: [
|
|
@@ -341,121 +278,93 @@ var stopCommand = {
|
|
|
341
278
|
examples: [
|
|
342
279
|
{ command: 'claude-flow daemon stop', description: 'Stop the daemon' },
|
|
343
280
|
],
|
|
344
|
-
action:
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
spinner.start();
|
|
357
|
-
// Try to stop in-process daemon first
|
|
358
|
-
return [4 /*yield*/, stopDaemon()];
|
|
359
|
-
case 2:
|
|
360
|
-
// Try to stop in-process daemon first
|
|
361
|
-
_a.sent();
|
|
362
|
-
return [4 /*yield*/, killBackgroundDaemon(projectRoot)];
|
|
363
|
-
case 3:
|
|
364
|
-
killed = _a.sent();
|
|
365
|
-
spinner.succeed(killed ? 'Worker daemon stopped' : 'Worker daemon was not running');
|
|
366
|
-
return [3 /*break*/, 7];
|
|
367
|
-
case 4: return [4 /*yield*/, stopDaemon()];
|
|
368
|
-
case 5:
|
|
369
|
-
_a.sent();
|
|
370
|
-
return [4 /*yield*/, killBackgroundDaemon(projectRoot)];
|
|
371
|
-
case 6:
|
|
372
|
-
_a.sent();
|
|
373
|
-
_a.label = 7;
|
|
374
|
-
case 7: return [2 /*return*/, { success: true }];
|
|
375
|
-
case 8:
|
|
376
|
-
error_2 = _a.sent();
|
|
377
|
-
output.printError("Failed to stop daemon: " + (error_2 instanceof Error ? error_2.message : String(error_2)));
|
|
378
|
-
return [2 /*return*/, { success: false, exitCode: 1 }];
|
|
379
|
-
case 9: return [2 /*return*/];
|
|
281
|
+
action: async (ctx) => {
|
|
282
|
+
const quiet = ctx.flags.quiet;
|
|
283
|
+
const projectRoot = process.cwd();
|
|
284
|
+
try {
|
|
285
|
+
if (!quiet) {
|
|
286
|
+
const spinner = output.createSpinner({ text: 'Stopping worker daemon...', spinner: 'dots' });
|
|
287
|
+
spinner.start();
|
|
288
|
+
// Try to stop in-process daemon first
|
|
289
|
+
await stopDaemon();
|
|
290
|
+
// Also kill any background daemon by PID
|
|
291
|
+
const killed = await killBackgroundDaemon(projectRoot);
|
|
292
|
+
spinner.succeed(killed ? 'Worker daemon stopped' : 'Worker daemon was not running');
|
|
380
293
|
}
|
|
381
|
-
|
|
382
|
-
|
|
294
|
+
else {
|
|
295
|
+
await stopDaemon();
|
|
296
|
+
await killBackgroundDaemon(projectRoot);
|
|
297
|
+
}
|
|
298
|
+
return { success: true };
|
|
299
|
+
}
|
|
300
|
+
catch (error) {
|
|
301
|
+
output.printError(`Failed to stop daemon: ${error instanceof Error ? error.message : String(error)}`);
|
|
302
|
+
return { success: false, exitCode: 1 };
|
|
303
|
+
}
|
|
304
|
+
},
|
|
383
305
|
};
|
|
384
306
|
/**
|
|
385
307
|
* Kill background daemon process using PID file
|
|
386
308
|
*/
|
|
387
|
-
function killBackgroundDaemon(projectRoot) {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
return
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
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
|
-
return [2 /*return*/, true];
|
|
434
|
-
case 3:
|
|
435
|
-
error_3 = _a.sent();
|
|
436
|
-
// Clean up PID file on any error
|
|
437
|
-
if (fs.existsSync(pidFile)) {
|
|
438
|
-
fs.unlinkSync(pidFile);
|
|
439
|
-
}
|
|
440
|
-
return [2 /*return*/, false];
|
|
441
|
-
case 4: return [2 /*return*/];
|
|
442
|
-
}
|
|
443
|
-
});
|
|
444
|
-
});
|
|
309
|
+
async function killBackgroundDaemon(projectRoot) {
|
|
310
|
+
const pidFile = join(projectRoot, '.claude-flow', 'daemon.pid');
|
|
311
|
+
if (!fs.existsSync(pidFile)) {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
try {
|
|
315
|
+
const pid = parseInt(fs.readFileSync(pidFile, 'utf-8').trim(), 10);
|
|
316
|
+
if (isNaN(pid)) {
|
|
317
|
+
fs.unlinkSync(pidFile);
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
// Check if process is running
|
|
321
|
+
try {
|
|
322
|
+
process.kill(pid, 0); // Signal 0 = check if alive
|
|
323
|
+
}
|
|
324
|
+
catch {
|
|
325
|
+
// Process not running, clean up stale PID file
|
|
326
|
+
fs.unlinkSync(pidFile);
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
// Kill the process
|
|
330
|
+
process.kill(pid, 'SIGTERM');
|
|
331
|
+
// Wait a moment then force kill if needed
|
|
332
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
333
|
+
try {
|
|
334
|
+
process.kill(pid, 0);
|
|
335
|
+
// Still alive, force kill
|
|
336
|
+
process.kill(pid, 'SIGKILL');
|
|
337
|
+
}
|
|
338
|
+
catch {
|
|
339
|
+
// Process terminated
|
|
340
|
+
}
|
|
341
|
+
// Clean up PID file
|
|
342
|
+
if (fs.existsSync(pidFile)) {
|
|
343
|
+
fs.unlinkSync(pidFile);
|
|
344
|
+
}
|
|
345
|
+
return true;
|
|
346
|
+
}
|
|
347
|
+
catch (error) {
|
|
348
|
+
// Clean up PID file on any error
|
|
349
|
+
if (fs.existsSync(pidFile)) {
|
|
350
|
+
fs.unlinkSync(pidFile);
|
|
351
|
+
}
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
445
354
|
}
|
|
446
355
|
/**
|
|
447
356
|
* Get PID of background daemon from PID file
|
|
448
357
|
*/
|
|
449
358
|
function getBackgroundDaemonPid(projectRoot) {
|
|
450
|
-
|
|
359
|
+
const pidFile = join(projectRoot, '.claude-flow', 'daemon.pid');
|
|
451
360
|
if (!fs.existsSync(pidFile)) {
|
|
452
361
|
return null;
|
|
453
362
|
}
|
|
454
363
|
try {
|
|
455
|
-
|
|
364
|
+
const pid = parseInt(fs.readFileSync(pidFile, 'utf-8').trim(), 10);
|
|
456
365
|
return isNaN(pid) ? null : pid;
|
|
457
366
|
}
|
|
458
|
-
catch
|
|
367
|
+
catch {
|
|
459
368
|
return null;
|
|
460
369
|
}
|
|
461
370
|
}
|
|
@@ -467,12 +376,12 @@ function isProcessRunning(pid) {
|
|
|
467
376
|
process.kill(pid, 0); // Signal 0 = check if alive
|
|
468
377
|
return true;
|
|
469
378
|
}
|
|
470
|
-
catch
|
|
379
|
+
catch {
|
|
471
380
|
return false;
|
|
472
381
|
}
|
|
473
382
|
}
|
|
474
383
|
// Status subcommand
|
|
475
|
-
|
|
384
|
+
const statusCommand = {
|
|
476
385
|
name: 'status',
|
|
477
386
|
description: 'Show daemon and worker status',
|
|
478
387
|
options: [
|
|
@@ -484,111 +393,109 @@ var statusCommand = {
|
|
|
484
393
|
{ command: 'claude-flow daemon status -v', description: 'Show detailed status' },
|
|
485
394
|
{ command: 'claude-flow daemon status --show-modes', description: 'Show worker execution modes' },
|
|
486
395
|
],
|
|
487
|
-
action:
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
396
|
+
action: async (ctx) => {
|
|
397
|
+
const verbose = ctx.flags.verbose;
|
|
398
|
+
const showModes = ctx.flags['show-modes'];
|
|
399
|
+
const projectRoot = process.cwd();
|
|
400
|
+
try {
|
|
401
|
+
const daemon = getDaemon(projectRoot);
|
|
402
|
+
const status = daemon.getStatus();
|
|
403
|
+
// Also check for background daemon
|
|
404
|
+
const bgPid = getBackgroundDaemonPid(projectRoot);
|
|
405
|
+
const bgRunning = bgPid ? isProcessRunning(bgPid) : false;
|
|
406
|
+
const isRunning = status.running || bgRunning;
|
|
407
|
+
const displayPid = bgPid || status.pid;
|
|
408
|
+
output.writeln();
|
|
409
|
+
// Daemon status box
|
|
410
|
+
const statusIcon = isRunning ? output.success('●') : output.error('○');
|
|
411
|
+
const statusText = isRunning ? output.success('RUNNING') : output.error('STOPPED');
|
|
412
|
+
const mode = bgRunning ? output.dim(' (background)') : status.running ? output.dim(' (foreground)') : '';
|
|
413
|
+
output.printBox([
|
|
414
|
+
`Status: ${statusIcon} ${statusText}${mode}`,
|
|
415
|
+
`PID: ${displayPid}`,
|
|
416
|
+
status.startedAt ? `Started: ${status.startedAt.toISOString()}` : '',
|
|
417
|
+
`Workers Enabled: ${status.config.workers.filter(w => w.enabled).length}`,
|
|
418
|
+
`Max Concurrent: ${status.config.maxConcurrent}`,
|
|
419
|
+
`Max CPU Load: ${status.config.resourceThresholds.maxCpuLoad}`,
|
|
420
|
+
`Min Free Memory: ${status.config.resourceThresholds.minFreeMemoryPercent}%`,
|
|
421
|
+
].filter(Boolean).join('\n'), 'RuFlo Daemon');
|
|
422
|
+
output.writeln();
|
|
423
|
+
output.writeln(output.bold('Worker Status'));
|
|
424
|
+
const workerData = status.config.workers.map(w => {
|
|
425
|
+
const state = status.workers.get(w.type);
|
|
426
|
+
// Check for headless mode from worker config or state
|
|
427
|
+
const isHeadless = w.headless || state?.headless || false;
|
|
428
|
+
const sandboxMode = w.sandbox || state?.sandbox || null;
|
|
429
|
+
return {
|
|
430
|
+
type: w.enabled ? output.highlight(w.type) : output.dim(w.type),
|
|
431
|
+
enabled: w.enabled ? output.success('✓') : output.dim('○'),
|
|
432
|
+
status: state?.isRunning ? output.warning('running') :
|
|
433
|
+
w.enabled ? output.success('idle') : output.dim('disabled'),
|
|
434
|
+
runs: state?.runCount ?? 0,
|
|
435
|
+
success: state ? `${Math.round((state.successCount / Math.max(state.runCount, 1)) * 100)}%` : '-',
|
|
436
|
+
lastRun: state?.lastRun ? formatTimeAgo(state.lastRun) : output.dim('never'),
|
|
437
|
+
nextRun: state?.nextRun && w.enabled ? formatTimeUntil(state.nextRun) : output.dim('-'),
|
|
438
|
+
mode: isHeadless ? output.highlight('headless') : output.dim('local'),
|
|
439
|
+
sandbox: isHeadless ? (sandboxMode || 'strict') : output.dim('-'),
|
|
440
|
+
};
|
|
441
|
+
});
|
|
442
|
+
// Build columns based on --show-modes flag
|
|
443
|
+
const baseColumns = [
|
|
444
|
+
{ key: 'type', header: 'Worker', width: 12 },
|
|
445
|
+
{ key: 'enabled', header: 'On', width: 4 },
|
|
446
|
+
{ key: 'status', header: 'Status', width: 10 },
|
|
447
|
+
{ key: 'runs', header: 'Runs', width: 6 },
|
|
448
|
+
{ key: 'success', header: 'Success', width: 8 },
|
|
449
|
+
{ key: 'lastRun', header: 'Last Run', width: 12 },
|
|
450
|
+
{ key: 'nextRun', header: 'Next Run', width: 12 },
|
|
451
|
+
];
|
|
452
|
+
const modeColumns = showModes ? [
|
|
453
|
+
{ key: 'mode', header: 'Mode', width: 10 },
|
|
454
|
+
{ key: 'sandbox', header: 'Sandbox', width: 12 },
|
|
455
|
+
] : [];
|
|
456
|
+
output.printTable({
|
|
457
|
+
columns: [...baseColumns, ...modeColumns],
|
|
458
|
+
data: workerData,
|
|
459
|
+
});
|
|
460
|
+
if (verbose) {
|
|
513
461
|
output.writeln();
|
|
514
|
-
output.writeln(output.bold('Worker
|
|
515
|
-
workerData = status_1.config.workers.map(function (w) {
|
|
516
|
-
var _a, _b, _c;
|
|
517
|
-
var state = status_1.workers.get(w.type);
|
|
518
|
-
// Check for headless mode from worker config or state
|
|
519
|
-
var isHeadless = w.headless || ((_a = state) === null || _a === void 0 ? void 0 : _a.headless) || false;
|
|
520
|
-
var sandboxMode = w.sandbox || ((_b = state) === null || _b === void 0 ? void 0 : _b.sandbox) || null;
|
|
521
|
-
return {
|
|
522
|
-
type: w.enabled ? output.highlight(w.type) : output.dim(w.type),
|
|
523
|
-
enabled: w.enabled ? output.success('✓') : output.dim('○'),
|
|
524
|
-
status: (state === null || state === void 0 ? void 0 : state.isRunning) ? output.warning('running') :
|
|
525
|
-
w.enabled ? output.success('idle') : output.dim('disabled'),
|
|
526
|
-
runs: (_c = state === null || state === void 0 ? void 0 : state.runCount) !== null && _c !== void 0 ? _c : 0,
|
|
527
|
-
success: state ? Math.round((state.successCount / Math.max(state.runCount, 1)) * 100) + "%" : '-',
|
|
528
|
-
lastRun: (state === null || state === void 0 ? void 0 : state.lastRun) ? formatTimeAgo(state.lastRun) : output.dim('never'),
|
|
529
|
-
nextRun: (state === null || state === void 0 ? void 0 : state.nextRun) && w.enabled ? formatTimeUntil(state.nextRun) : output.dim('-'),
|
|
530
|
-
mode: isHeadless ? output.highlight('headless') : output.dim('local'),
|
|
531
|
-
sandbox: isHeadless ? (sandboxMode || 'strict') : output.dim('-')
|
|
532
|
-
};
|
|
533
|
-
});
|
|
534
|
-
baseColumns = [
|
|
535
|
-
{ key: 'type', header: 'Worker', width: 12 },
|
|
536
|
-
{ key: 'enabled', header: 'On', width: 4 },
|
|
537
|
-
{ key: 'status', header: 'Status', width: 10 },
|
|
538
|
-
{ key: 'runs', header: 'Runs', width: 6 },
|
|
539
|
-
{ key: 'success', header: 'Success', width: 8 },
|
|
540
|
-
{ key: 'lastRun', header: 'Last Run', width: 12 },
|
|
541
|
-
{ key: 'nextRun', header: 'Next Run', width: 12 },
|
|
542
|
-
];
|
|
543
|
-
modeColumns = showModes ? [
|
|
544
|
-
{ key: 'mode', header: 'Mode', width: 10 },
|
|
545
|
-
{ key: 'sandbox', header: 'Sandbox', width: 12 },
|
|
546
|
-
] : [];
|
|
462
|
+
output.writeln(output.bold('Worker Configuration'));
|
|
547
463
|
output.printTable({
|
|
548
|
-
columns:
|
|
549
|
-
|
|
464
|
+
columns: [
|
|
465
|
+
{ key: 'type', header: 'Worker', width: 12 },
|
|
466
|
+
{ key: 'interval', header: 'Interval', width: 10 },
|
|
467
|
+
{ key: 'priority', header: 'Priority', width: 10 },
|
|
468
|
+
{ key: 'avgDuration', header: 'Avg Duration', width: 12 },
|
|
469
|
+
{ key: 'description', header: 'Description', width: 30 },
|
|
470
|
+
],
|
|
471
|
+
data: status.config.workers.map(w => {
|
|
472
|
+
const state = status.workers.get(w.type);
|
|
473
|
+
return {
|
|
474
|
+
type: w.type,
|
|
475
|
+
interval: `${Math.round(w.intervalMs / 60000)}min`,
|
|
476
|
+
priority: w.priority,
|
|
477
|
+
avgDuration: state?.averageDurationMs ? `${Math.round(state.averageDurationMs)}ms` : '-',
|
|
478
|
+
description: w.description,
|
|
479
|
+
};
|
|
480
|
+
}),
|
|
550
481
|
});
|
|
551
|
-
if (verbose) {
|
|
552
|
-
output.writeln();
|
|
553
|
-
output.writeln(output.bold('Worker Configuration'));
|
|
554
|
-
output.printTable({
|
|
555
|
-
columns: [
|
|
556
|
-
{ key: 'type', header: 'Worker', width: 12 },
|
|
557
|
-
{ key: 'interval', header: 'Interval', width: 10 },
|
|
558
|
-
{ key: 'priority', header: 'Priority', width: 10 },
|
|
559
|
-
{ key: 'avgDuration', header: 'Avg Duration', width: 12 },
|
|
560
|
-
{ key: 'description', header: 'Description', width: 30 },
|
|
561
|
-
],
|
|
562
|
-
data: status_1.config.workers.map(function (w) {
|
|
563
|
-
var state = status_1.workers.get(w.type);
|
|
564
|
-
return {
|
|
565
|
-
type: w.type,
|
|
566
|
-
interval: Math.round(w.intervalMs / 60000) + "min",
|
|
567
|
-
priority: w.priority,
|
|
568
|
-
avgDuration: (state === null || state === void 0 ? void 0 : state.averageDurationMs) ? Math.round(state.averageDurationMs) + "ms" : '-',
|
|
569
|
-
description: w.description
|
|
570
|
-
};
|
|
571
|
-
})
|
|
572
|
-
});
|
|
573
|
-
}
|
|
574
|
-
return [2 /*return*/, { success: true, data: status_1 }];
|
|
575
482
|
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
return
|
|
587
|
-
}
|
|
588
|
-
}
|
|
483
|
+
return { success: true, data: status };
|
|
484
|
+
}
|
|
485
|
+
catch (error) {
|
|
486
|
+
// Daemon not initialized
|
|
487
|
+
output.writeln();
|
|
488
|
+
output.printBox([
|
|
489
|
+
`Status: ${output.error('○')} ${output.error('NOT INITIALIZED')}`,
|
|
490
|
+
'',
|
|
491
|
+
'Run "claude-flow daemon start" to start the daemon',
|
|
492
|
+
].join('\n'), 'RuFlo Daemon');
|
|
493
|
+
return { success: true };
|
|
494
|
+
}
|
|
495
|
+
},
|
|
589
496
|
};
|
|
590
497
|
// Trigger subcommand - manually run a worker
|
|
591
|
-
|
|
498
|
+
const triggerCommand = {
|
|
592
499
|
name: 'trigger',
|
|
593
500
|
description: 'Manually trigger a specific worker',
|
|
594
501
|
options: [
|
|
@@ -600,50 +507,40 @@ var triggerCommand = {
|
|
|
600
507
|
{ command: 'claude-flow daemon trigger -w audit', description: 'Trigger security audit' },
|
|
601
508
|
{ command: 'claude-flow daemon trigger -w audit --headless', description: 'Trigger audit in headless sandbox' },
|
|
602
509
|
],
|
|
603
|
-
action:
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
if (result.output) {
|
|
627
|
-
output.writeln();
|
|
628
|
-
output.writeln(output.bold('Output'));
|
|
629
|
-
output.printJson(result.output);
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
else {
|
|
633
|
-
spinner.fail("Worker " + workerType + " failed: " + result.error);
|
|
634
|
-
}
|
|
635
|
-
return [2 /*return*/, { success: result.success, data: result }];
|
|
636
|
-
case 3:
|
|
637
|
-
error_4 = _a.sent();
|
|
638
|
-
output.printError("Failed to trigger worker: " + (error_4 instanceof Error ? error_4.message : String(error_4)));
|
|
639
|
-
return [2 /*return*/, { success: false, exitCode: 1 }];
|
|
640
|
-
case 4: return [2 /*return*/];
|
|
510
|
+
action: async (ctx) => {
|
|
511
|
+
const workerType = ctx.flags.worker;
|
|
512
|
+
if (!workerType) {
|
|
513
|
+
output.printError('Worker type is required. Use --worker or -w flag.');
|
|
514
|
+
output.writeln();
|
|
515
|
+
output.writeln('Available workers: map, audit, optimize, consolidate, testgaps, predict, document, ultralearn, refactor, benchmark, deepdive, preload');
|
|
516
|
+
return { success: false, exitCode: 1 };
|
|
517
|
+
}
|
|
518
|
+
try {
|
|
519
|
+
const daemon = getDaemon(process.cwd());
|
|
520
|
+
const spinner = output.createSpinner({ text: `Running ${workerType} worker...`, spinner: 'dots' });
|
|
521
|
+
spinner.start();
|
|
522
|
+
const result = await daemon.triggerWorker(workerType);
|
|
523
|
+
if (result.success) {
|
|
524
|
+
spinner.succeed(`Worker ${workerType} completed in ${result.durationMs}ms`);
|
|
525
|
+
if (result.output) {
|
|
526
|
+
output.writeln();
|
|
527
|
+
output.writeln(output.bold('Output'));
|
|
528
|
+
output.printJson(result.output);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
else {
|
|
532
|
+
spinner.fail(`Worker ${workerType} failed: ${result.error}`);
|
|
641
533
|
}
|
|
642
|
-
|
|
643
|
-
|
|
534
|
+
return { success: result.success, data: result };
|
|
535
|
+
}
|
|
536
|
+
catch (error) {
|
|
537
|
+
output.printError(`Failed to trigger worker: ${error instanceof Error ? error.message : String(error)}`);
|
|
538
|
+
return { success: false, exitCode: 1 };
|
|
539
|
+
}
|
|
540
|
+
},
|
|
644
541
|
};
|
|
645
542
|
// Enable/disable worker subcommand
|
|
646
|
-
|
|
543
|
+
const enableCommand = {
|
|
647
544
|
name: 'enable',
|
|
648
545
|
description: 'Enable or disable a specific worker',
|
|
649
546
|
options: [
|
|
@@ -654,54 +551,50 @@ var enableCommand = {
|
|
|
654
551
|
{ command: 'claude-flow daemon enable -w predict', description: 'Enable predict worker' },
|
|
655
552
|
{ command: 'claude-flow daemon enable -w document --disable', description: 'Disable document worker' },
|
|
656
553
|
],
|
|
657
|
-
action:
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
}
|
|
676
|
-
return [2 /*return*/];
|
|
677
|
-
});
|
|
678
|
-
}); }
|
|
554
|
+
action: async (ctx) => {
|
|
555
|
+
const workerType = ctx.flags.worker;
|
|
556
|
+
const disable = ctx.flags.disable;
|
|
557
|
+
if (!workerType) {
|
|
558
|
+
output.printError('Worker type is required. Use --worker or -w flag.');
|
|
559
|
+
return { success: false, exitCode: 1 };
|
|
560
|
+
}
|
|
561
|
+
try {
|
|
562
|
+
const daemon = getDaemon(process.cwd());
|
|
563
|
+
daemon.setWorkerEnabled(workerType, !disable);
|
|
564
|
+
output.printSuccess(`Worker ${workerType} ${disable ? 'disabled' : 'enabled'}`);
|
|
565
|
+
return { success: true };
|
|
566
|
+
}
|
|
567
|
+
catch (error) {
|
|
568
|
+
output.printError(`Failed to ${disable ? 'disable' : 'enable'} worker: ${error instanceof Error ? error.message : String(error)}`);
|
|
569
|
+
return { success: false, exitCode: 1 };
|
|
570
|
+
}
|
|
571
|
+
},
|
|
679
572
|
};
|
|
680
573
|
// Helper functions for time formatting
|
|
681
574
|
function formatTimeAgo(date) {
|
|
682
|
-
|
|
575
|
+
const seconds = Math.floor((Date.now() - date.getTime()) / 1000);
|
|
683
576
|
if (seconds < 60)
|
|
684
|
-
return seconds
|
|
577
|
+
return `${seconds}s ago`;
|
|
685
578
|
if (seconds < 3600)
|
|
686
|
-
return Math.floor(seconds / 60)
|
|
579
|
+
return `${Math.floor(seconds / 60)}m ago`;
|
|
687
580
|
if (seconds < 86400)
|
|
688
|
-
return Math.floor(seconds / 3600)
|
|
689
|
-
return Math.floor(seconds / 86400)
|
|
581
|
+
return `${Math.floor(seconds / 3600)}h ago`;
|
|
582
|
+
return `${Math.floor(seconds / 86400)}d ago`;
|
|
690
583
|
}
|
|
691
584
|
function formatTimeUntil(date) {
|
|
692
|
-
|
|
585
|
+
const seconds = Math.floor((date.getTime() - Date.now()) / 1000);
|
|
693
586
|
if (seconds < 0)
|
|
694
587
|
return 'now';
|
|
695
588
|
if (seconds < 60)
|
|
696
|
-
return
|
|
589
|
+
return `in ${seconds}s`;
|
|
697
590
|
if (seconds < 3600)
|
|
698
|
-
return
|
|
591
|
+
return `in ${Math.floor(seconds / 60)}m`;
|
|
699
592
|
if (seconds < 86400)
|
|
700
|
-
return
|
|
701
|
-
return
|
|
593
|
+
return `in ${Math.floor(seconds / 3600)}h`;
|
|
594
|
+
return `in ${Math.floor(seconds / 86400)}d`;
|
|
702
595
|
}
|
|
703
596
|
// Main daemon command
|
|
704
|
-
export
|
|
597
|
+
export const daemonCommand = {
|
|
705
598
|
name: 'daemon',
|
|
706
599
|
description: 'Manage background worker daemon (Node.js-based, auto-runs like shell helpers)',
|
|
707
600
|
subcommands: [
|
|
@@ -719,47 +612,45 @@ export var daemonCommand = {
|
|
|
719
612
|
{ command: 'claude-flow daemon stop', description: 'Stop the daemon' },
|
|
720
613
|
{ command: 'claude-flow daemon trigger -w audit', description: 'Run security audit' },
|
|
721
614
|
],
|
|
722
|
-
action:
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
output.
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
output.
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
});
|
|
762
|
-
}); }
|
|
615
|
+
action: async () => {
|
|
616
|
+
output.writeln();
|
|
617
|
+
output.writeln(output.bold('RuFlo Daemon - Background Task Management'));
|
|
618
|
+
output.writeln();
|
|
619
|
+
output.writeln('Node.js-based background worker system that auto-runs like shell daemons.');
|
|
620
|
+
output.writeln('Manages 12 specialized workers for continuous optimization and monitoring.');
|
|
621
|
+
output.writeln();
|
|
622
|
+
output.writeln(output.bold('Headless Mode'));
|
|
623
|
+
output.writeln('Workers can run in headless mode using E2B sandboxes for isolated execution.');
|
|
624
|
+
output.writeln('Use --headless flag with start/trigger commands. Sandbox modes: strict, permissive, disabled.');
|
|
625
|
+
output.writeln();
|
|
626
|
+
output.writeln(output.bold('Available Workers'));
|
|
627
|
+
output.printList([
|
|
628
|
+
`${output.highlight('map')} - Codebase mapping (5 min interval)`,
|
|
629
|
+
`${output.highlight('audit')} - Security analysis (10 min interval)`,
|
|
630
|
+
`${output.highlight('optimize')} - Performance optimization (15 min interval)`,
|
|
631
|
+
`${output.highlight('consolidate')} - Memory consolidation (30 min interval)`,
|
|
632
|
+
`${output.highlight('testgaps')} - Test coverage analysis (20 min interval)`,
|
|
633
|
+
`${output.highlight('predict')} - Predictive preloading (2 min, disabled by default)`,
|
|
634
|
+
`${output.highlight('document')} - Auto-documentation (60 min, disabled by default)`,
|
|
635
|
+
`${output.highlight('ultralearn')} - Deep knowledge acquisition (manual trigger)`,
|
|
636
|
+
`${output.highlight('refactor')} - Code refactoring suggestions (manual trigger)`,
|
|
637
|
+
`${output.highlight('benchmark')} - Performance benchmarking (manual trigger)`,
|
|
638
|
+
`${output.highlight('deepdive')} - Deep code analysis (manual trigger)`,
|
|
639
|
+
`${output.highlight('preload')} - Resource preloading (manual trigger)`,
|
|
640
|
+
]);
|
|
641
|
+
output.writeln();
|
|
642
|
+
output.writeln(output.bold('Subcommands'));
|
|
643
|
+
output.printList([
|
|
644
|
+
`${output.highlight('start')} - Start the daemon`,
|
|
645
|
+
`${output.highlight('stop')} - Stop the daemon`,
|
|
646
|
+
`${output.highlight('status')} - Show daemon status`,
|
|
647
|
+
`${output.highlight('trigger')} - Manually run a worker`,
|
|
648
|
+
`${output.highlight('enable')} - Enable/disable a worker`,
|
|
649
|
+
]);
|
|
650
|
+
output.writeln();
|
|
651
|
+
output.writeln('Run "claude-flow daemon <subcommand> --help" for details');
|
|
652
|
+
return { success: true };
|
|
653
|
+
},
|
|
763
654
|
};
|
|
764
655
|
export default daemonCommand;
|
|
765
656
|
//# sourceMappingURL=daemon.js.map
|