kynjal-cli 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/appliance/gguf-engine.d.ts +91 -0
- package/dist/src/appliance/gguf-engine.d.ts.map +1 -0
- package/dist/src/appliance/gguf-engine.js +286 -525
- package/dist/src/appliance/gguf-engine.js.map +1 -1
- package/dist/src/appliance/ruvllm-bridge.d.ts +102 -0
- package/dist/src/appliance/ruvllm-bridge.d.ts.map +1 -0
- package/dist/src/appliance/ruvllm-bridge.js +203 -403
- package/dist/src/appliance/ruvllm-bridge.js.map +1 -1
- package/dist/src/appliance/rvfa-builder.d.ts +44 -0
- package/dist/src/appliance/rvfa-builder.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-builder.js +154 -208
- package/dist/src/appliance/rvfa-builder.js.map +1 -1
- package/dist/src/appliance/rvfa-distribution.d.ts +97 -0
- package/dist/src/appliance/rvfa-distribution.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-distribution.js +260 -423
- package/dist/src/appliance/rvfa-distribution.js.map +1 -1
- package/dist/src/appliance/rvfa-format.d.ts +111 -0
- package/dist/src/appliance/rvfa-format.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-format.js +128 -200
- package/dist/src/appliance/rvfa-format.js.map +1 -1
- package/dist/src/appliance/rvfa-runner.d.ts +69 -0
- package/dist/src/appliance/rvfa-runner.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-runner.js +168 -304
- package/dist/src/appliance/rvfa-runner.js.map +1 -1
- package/dist/src/appliance/rvfa-signing.d.ts +123 -0
- package/dist/src/appliance/rvfa-signing.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-signing.js +173 -295
- package/dist/src/appliance/rvfa-signing.js.map +1 -1
- package/dist/src/benchmarks/pretrain/index.d.ts +58 -0
- package/dist/src/benchmarks/pretrain/index.d.ts.map +1 -0
- package/dist/src/benchmarks/pretrain/index.js +331 -542
- package/dist/src/benchmarks/pretrain/index.js.map +1 -1
- package/dist/src/commands/agent.js +574 -697
- package/dist/src/commands/agent.js.map +1 -1
- package/dist/src/commands/analyze.js +1218 -1548
- package/dist/src/commands/analyze.js.map +1 -1
- package/dist/src/commands/appliance-advanced.js +158 -267
- package/dist/src/commands/appliance-advanced.js.map +1 -1
- package/dist/src/commands/appliance.js +318 -493
- package/dist/src/commands/appliance.js.map +1 -1
- package/dist/src/commands/benchmark.js +372 -523
- package/dist/src/commands/benchmark.js.map +1 -1
- package/dist/src/commands/claims.js +274 -364
- package/dist/src/commands/claims.js.map +1 -1
- package/dist/src/commands/cleanup.js +113 -157
- package/dist/src/commands/cleanup.js.map +1 -1
- package/dist/src/commands/completions.js +477 -118
- package/dist/src/commands/completions.js.map +1 -1
- package/dist/src/commands/config.js +237 -303
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/daemon.js +487 -596
- package/dist/src/commands/daemon.js.map +1 -1
- package/dist/src/commands/deployment.js +194 -275
- package/dist/src/commands/deployment.js.map +1 -1
- package/dist/src/commands/doctor.js +504 -686
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/embeddings.js +1293 -1543
- package/dist/src/commands/embeddings.js.map +1 -1
- package/dist/src/commands/guidance.js +449 -596
- package/dist/src/commands/guidance.js.map +1 -1
- package/dist/src/commands/hive-mind.js +854 -938
- package/dist/src/commands/hive-mind.js.map +1 -1
- package/dist/src/commands/hooks.js +3112 -3519
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.d.ts +115 -0
- package/dist/src/commands/index.d.ts.map +1 -0
- package/dist/src/commands/index.js +126 -308
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/init.js +788 -940
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/issues.js +383 -558
- package/dist/src/commands/issues.js.map +1 -1
- package/dist/src/commands/mcp.js +493 -605
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/memory.js +833 -1026
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/commands/migrate.js +282 -347
- package/dist/src/commands/migrate.js.map +1 -1
- package/dist/src/commands/neural.js +1289 -1563
- package/dist/src/commands/neural.js.map +1 -1
- package/dist/src/commands/performance.js +497 -643
- package/dist/src/commands/performance.js.map +1 -1
- package/dist/src/commands/plugins.js +668 -841
- package/dist/src/commands/plugins.js.map +1 -1
- package/dist/src/commands/process.js +392 -447
- package/dist/src/commands/process.js.map +1 -1
- package/dist/src/commands/progress.js +162 -256
- package/dist/src/commands/progress.js.map +1 -1
- package/dist/src/commands/providers.js +150 -220
- package/dist/src/commands/providers.js.map +1 -1
- package/dist/src/commands/route.js +520 -665
- package/dist/src/commands/route.js.map +1 -1
- package/dist/src/commands/ruvector/backup.js +505 -651
- package/dist/src/commands/ruvector/backup.js.map +1 -1
- package/dist/src/commands/ruvector/benchmark.js +349 -401
- package/dist/src/commands/ruvector/benchmark.js.map +1 -1
- package/dist/src/commands/ruvector/import.js +224 -266
- package/dist/src/commands/ruvector/import.js.map +1 -1
- package/dist/src/commands/ruvector/index.js +37 -75
- package/dist/src/commands/ruvector/index.js.map +1 -1
- package/dist/src/commands/ruvector/init.js +336 -359
- package/dist/src/commands/ruvector/init.js.map +1 -1
- package/dist/src/commands/ruvector/migrate.js +335 -322
- package/dist/src/commands/ruvector/migrate.js.map +1 -1
- package/dist/src/commands/ruvector/optimize.js +375 -431
- package/dist/src/commands/ruvector/optimize.js.map +1 -1
- package/dist/src/commands/ruvector/setup.js +703 -117
- package/dist/src/commands/ruvector/setup.js.map +1 -1
- package/dist/src/commands/ruvector/status.js +364 -419
- package/dist/src/commands/ruvector/status.js.map +1 -1
- package/dist/src/commands/security.js +485 -608
- package/dist/src/commands/security.js.map +1 -1
- package/dist/src/commands/session.js +504 -626
- package/dist/src/commands/session.js.map +1 -1
- package/dist/src/commands/start.js +267 -364
- package/dist/src/commands/start.js.map +1 -1
- package/dist/src/commands/status.js +380 -486
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/commands/swarm.js +408 -488
- package/dist/src/commands/swarm.js.map +1 -1
- package/dist/src/commands/task.js +423 -538
- package/dist/src/commands/task.js.map +1 -1
- package/dist/src/commands/transfer-store.js +322 -412
- package/dist/src/commands/transfer-store.js.map +1 -1
- package/dist/src/commands/update.js +196 -291
- package/dist/src/commands/update.js.map +1 -1
- package/dist/src/commands/workflow.js +386 -486
- package/dist/src/commands/workflow.js.map +1 -1
- package/dist/src/config-adapter.d.ts +15 -0
- package/dist/src/config-adapter.d.ts.map +1 -0
- package/dist/src/config-adapter.js +38 -39
- package/dist/src/config-adapter.js.map +1 -1
- package/dist/src/index.d.ts +77 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +309 -411
- package/dist/src/index.js.map +1 -1
- package/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
- package/dist/src/infrastructure/in-memory-repositories.d.ts.map +1 -0
- package/dist/src/infrastructure/in-memory-repositories.js +246 -507
- package/dist/src/infrastructure/in-memory-repositories.js.map +1 -1
- package/dist/src/init/claudemd-generator.d.ts +25 -0
- package/dist/src/init/claudemd-generator.d.ts.map +1 -0
- package/dist/src/init/claudemd-generator.js +368 -78
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/init/executor.d.ts +41 -0
- package/dist/src/init/executor.d.ts.map +1 -0
- package/dist/src/init/executor.js +1307 -996
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/helpers-generator.d.ts +60 -0
- package/dist/src/init/helpers-generator.d.ts.map +1 -0
- package/dist/src/init/helpers-generator.js +657 -12
- package/dist/src/init/helpers-generator.js.map +1 -1
- package/dist/src/init/index.d.ts +1 -1
- package/dist/src/init/index.d.ts.map +1 -1
- package/dist/src/init/index.js +1 -1
- package/dist/src/init/index.js.map +1 -1
- package/dist/src/init/mcp-generator.js +33 -37
- package/dist/src/init/mcp-generator.js.map +1 -1
- package/dist/src/init/settings-generator.js +76 -77
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/init/statusline-generator.js +801 -3
- package/dist/src/init/statusline-generator.js.map +1 -1
- package/dist/src/init/types.d.ts +1 -1
- package/dist/src/init/types.d.ts.map +1 -1
- package/dist/src/init/types.js +76 -59
- package/dist/src/init/types.js.map +1 -1
- package/dist/src/mcp-client.d.ts +92 -0
- package/dist/src/mcp-client.d.ts.map +1 -0
- package/dist/src/mcp-client.js +81 -125
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-server.d.ts +161 -0
- package/dist/src/mcp-server.d.ts.map +1 -0
- package/dist/src/mcp-server.js +470 -757
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +391 -492
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/agentdb-tools.js +332 -533
- package/dist/src/mcp-tools/agentdb-tools.js.map +1 -1
- package/dist/src/mcp-tools/analyze-tools.js +172 -236
- package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
- package/dist/src/mcp-tools/auto-install.d.ts +83 -0
- package/dist/src/mcp-tools/auto-install.d.ts.map +1 -0
- package/dist/src/mcp-tools/auto-install.js +80 -142
- package/dist/src/mcp-tools/auto-install.js.map +1 -1
- package/dist/src/mcp-tools/browser-tools.js +252 -375
- package/dist/src/mcp-tools/browser-tools.js.map +1 -1
- package/dist/src/mcp-tools/claims-tools.js +473 -565
- package/dist/src/mcp-tools/claims-tools.js.map +1 -1
- package/dist/src/mcp-tools/config-tools.js +197 -272
- package/dist/src/mcp-tools/config-tools.js.map +1 -1
- package/dist/src/mcp-tools/coordination-tools.js +500 -572
- package/dist/src/mcp-tools/coordination-tools.js.map +1 -1
- package/dist/src/mcp-tools/daa-tools.js +286 -364
- package/dist/src/mcp-tools/daa-tools.js.map +1 -1
- package/dist/src/mcp-tools/embeddings-tools.js +582 -693
- package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
- package/dist/src/mcp-tools/github-tools.js +260 -311
- package/dist/src/mcp-tools/github-tools.js.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.js +573 -640
- package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +2215 -2648
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +350 -505
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/neural-tools.js +315 -412
- package/dist/src/mcp-tools/neural-tools.js.map +1 -1
- package/dist/src/mcp-tools/performance-tools.js +420 -480
- package/dist/src/mcp-tools/performance-tools.js.map +1 -1
- package/dist/src/mcp-tools/progress-tools.js +204 -278
- package/dist/src/mcp-tools/progress-tools.js.map +1 -1
- package/dist/src/mcp-tools/ruvllm-tools.js +163 -279
- package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -1
- package/dist/src/mcp-tools/security-tools.js +297 -429
- package/dist/src/mcp-tools/security-tools.js.map +1 -1
- package/dist/src/mcp-tools/session-tools.js +185 -234
- package/dist/src/mcp-tools/session-tools.js.map +1 -1
- package/dist/src/mcp-tools/swarm-tools.js +207 -260
- package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
- package/dist/src/mcp-tools/system-tools.js +276 -325
- package/dist/src/mcp-tools/system-tools.js.map +1 -1
- package/dist/src/mcp-tools/task-tools.js +270 -336
- package/dist/src/mcp-tools/task-tools.js.map +1 -1
- package/dist/src/mcp-tools/terminal-tools.js +148 -196
- package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
- package/dist/src/mcp-tools/transfer-tools.js +186 -333
- package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
- package/dist/src/mcp-tools/types.d.ts +31 -0
- package/dist/src/mcp-tools/types.d.ts.map +1 -0
- package/dist/src/mcp-tools/wasm-agent-tools.js +133 -280
- package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/workflow-tools.js +405 -450
- package/dist/src/mcp-tools/workflow-tools.js.map +1 -1
- package/dist/src/memory/ewc-consolidation.d.ts +295 -0
- package/dist/src/memory/ewc-consolidation.d.ts.map +1 -0
- package/dist/src/memory/ewc-consolidation.js +190 -303
- package/dist/src/memory/ewc-consolidation.js.map +1 -1
- package/dist/src/memory/intelligence.d.ts +338 -0
- package/dist/src/memory/intelligence.d.ts.map +1 -0
- package/dist/src/memory/intelligence.js +569 -794
- package/dist/src/memory/intelligence.js.map +1 -1
- package/dist/src/memory/memory-bridge.d.ts +407 -0
- package/dist/src/memory/memory-bridge.d.ts.map +1 -0
- package/dist/src/memory/memory-bridge.js +1170 -1640
- package/dist/src/memory/memory-bridge.js.map +1 -1
- package/dist/src/memory/memory-initializer.d.ts +412 -0
- package/dist/src/memory/memory-initializer.d.ts.map +1 -0
- package/dist/src/memory/memory-initializer.js +1836 -1851
- package/dist/src/memory/memory-initializer.js.map +1 -1
- package/dist/src/memory/sona-optimizer.d.ts +227 -0
- package/dist/src/memory/sona-optimizer.d.ts.map +1 -0
- package/dist/src/memory/sona-optimizer.js +199 -329
- package/dist/src/memory/sona-optimizer.js.map +1 -1
- package/dist/src/output.d.ts +2 -2
- package/dist/src/output.d.ts.map +1 -1
- package/dist/src/output.js +242 -272
- package/dist/src/output.js.map +1 -1
- package/dist/src/parser.d.ts +51 -0
- package/dist/src/parser.d.ts.map +1 -0
- package/dist/src/parser.js +140 -187
- package/dist/src/parser.js.map +1 -1
- package/dist/src/plugins/manager.d.ts +133 -0
- package/dist/src/plugins/manager.d.ts.map +1 -0
- package/dist/src/plugins/manager.js +285 -521
- package/dist/src/plugins/manager.js.map +1 -1
- package/dist/src/plugins/store/discovery.d.ts +88 -0
- package/dist/src/plugins/store/discovery.d.ts.map +1 -0
- package/dist/src/plugins/store/discovery.js +271 -358
- package/dist/src/plugins/store/discovery.js.map +1 -1
- package/dist/src/plugins/store/index.d.ts +76 -0
- package/dist/src/plugins/store/index.d.ts.map +1 -0
- package/dist/src/plugins/store/index.js +48 -105
- package/dist/src/plugins/store/index.js.map +1 -1
- package/dist/src/plugins/store/search.d.ts +46 -0
- package/dist/src/plugins/store/search.d.ts.map +1 -0
- package/dist/src/plugins/store/search.js +69 -107
- package/dist/src/plugins/store/search.js.map +1 -1
- package/dist/src/plugins/store/types.d.ts +274 -0
- package/dist/src/plugins/store/types.d.ts.map +1 -0
- package/dist/src/plugins/tests/demo-plugin-store.js +113 -160
- package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -1
- package/dist/src/plugins/tests/standalone-test.js +172 -223
- package/dist/src/plugins/tests/standalone-test.js.map +1 -1
- package/dist/src/plugins/tests/test-plugin-store.js +190 -228
- package/dist/src/plugins/tests/test-plugin-store.js.map +1 -1
- package/dist/src/production/circuit-breaker.d.ts +101 -0
- package/dist/src/production/circuit-breaker.d.ts.map +1 -0
- package/dist/src/production/circuit-breaker.js +62 -126
- package/dist/src/production/circuit-breaker.js.map +1 -1
- package/dist/src/production/error-handler.d.ts +92 -0
- package/dist/src/production/error-handler.d.ts.map +1 -0
- package/dist/src/production/error-handler.js +86 -156
- package/dist/src/production/error-handler.js.map +1 -1
- package/dist/src/production/monitoring.d.ts +161 -0
- package/dist/src/production/monitoring.d.ts.map +1 -0
- package/dist/src/production/monitoring.js +139 -220
- package/dist/src/production/monitoring.js.map +1 -1
- package/dist/src/production/rate-limiter.d.ts +80 -0
- package/dist/src/production/rate-limiter.d.ts.map +1 -0
- package/dist/src/production/rate-limiter.js +74 -93
- package/dist/src/production/rate-limiter.js.map +1 -1
- package/dist/src/production/retry.d.ts +48 -0
- package/dist/src/production/retry.d.ts.map +1 -0
- package/dist/src/production/retry.js +75 -167
- package/dist/src/production/retry.js.map +1 -1
- package/dist/src/prompt.d.ts +44 -0
- package/dist/src/prompt.d.ts.map +1 -0
- package/dist/src/prompt.js +436 -560
- package/dist/src/prompt.js.map +1 -1
- package/dist/src/runtime/headless.d.ts +60 -0
- package/dist/src/runtime/headless.d.ts.map +1 -0
- package/dist/src/runtime/headless.js +197 -286
- package/dist/src/runtime/headless.js.map +1 -1
- package/dist/src/ruvector/agent-wasm.d.ts +182 -0
- package/dist/src/ruvector/agent-wasm.d.ts.map +1 -0
- package/dist/src/ruvector/agent-wasm.js +156 -351
- package/dist/src/ruvector/agent-wasm.js.map +1 -1
- package/dist/src/ruvector/ast-analyzer.d.ts +67 -0
- package/dist/src/ruvector/ast-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/ast-analyzer.js +145 -232
- package/dist/src/ruvector/ast-analyzer.js.map +1 -1
- package/dist/src/ruvector/coverage-router.d.ts +160 -0
- package/dist/src/ruvector/coverage-router.d.ts.map +1 -0
- package/dist/src/ruvector/coverage-router.js +287 -419
- package/dist/src/ruvector/coverage-router.js.map +1 -1
- package/dist/src/ruvector/coverage-tools.js +56 -101
- package/dist/src/ruvector/coverage-tools.js.map +1 -1
- package/dist/src/ruvector/diff-classifier.d.ts +175 -0
- package/dist/src/ruvector/diff-classifier.d.ts.map +1 -0
- package/dist/src/ruvector/diff-classifier.js +324 -451
- package/dist/src/ruvector/diff-classifier.js.map +1 -1
- package/dist/src/ruvector/enhanced-model-router.d.ts +146 -0
- package/dist/src/ruvector/enhanced-model-router.d.ts.map +1 -0
- package/dist/src/ruvector/enhanced-model-router.js +260 -336
- package/dist/src/ruvector/enhanced-model-router.js.map +1 -1
- package/dist/src/ruvector/flash-attention.d.ts +195 -0
- package/dist/src/ruvector/flash-attention.d.ts.map +1 -0
- package/dist/src/ruvector/flash-attention.js +223 -254
- package/dist/src/ruvector/flash-attention.js.map +1 -1
- package/dist/src/ruvector/graph-analyzer.d.ts +187 -0
- package/dist/src/ruvector/graph-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/graph-analyzer.js +486 -680
- package/dist/src/ruvector/graph-analyzer.js.map +1 -1
- package/dist/src/ruvector/index.d.ts +40 -0
- package/dist/src/ruvector/index.d.ts.map +1 -0
- package/dist/src/ruvector/index.js +36 -106
- package/dist/src/ruvector/index.js.map +1 -1
- package/dist/src/ruvector/lora-adapter.d.ts +218 -0
- package/dist/src/ruvector/lora-adapter.d.ts.map +1 -0
- package/dist/src/ruvector/lora-adapter.js +155 -248
- package/dist/src/ruvector/lora-adapter.js.map +1 -1
- package/dist/src/ruvector/model-router.d.ts +220 -0
- package/dist/src/ruvector/model-router.d.ts.map +1 -0
- package/dist/src/ruvector/model-router.js +175 -248
- package/dist/src/ruvector/model-router.js.map +1 -1
- package/dist/src/ruvector/moe-router.d.ts +206 -0
- package/dist/src/ruvector/moe-router.d.ts.map +1 -0
- package/dist/src/ruvector/moe-router.js +228 -286
- package/dist/src/ruvector/moe-router.js.map +1 -1
- package/dist/src/ruvector/q-learning-router.d.ts +211 -0
- package/dist/src/ruvector/q-learning-router.d.ts.map +1 -0
- package/dist/src/ruvector/q-learning-router.js +257 -338
- package/dist/src/ruvector/q-learning-router.js.map +1 -1
- package/dist/src/ruvector/ruvllm-wasm.d.ts +179 -0
- package/dist/src/ruvector/ruvllm-wasm.d.ts.map +1 -0
- package/dist/src/ruvector/ruvllm-wasm.js +270 -434
- package/dist/src/ruvector/ruvllm-wasm.js.map +1 -1
- package/dist/src/ruvector/semantic-router.d.ts +77 -0
- package/dist/src/ruvector/semantic-router.d.ts.map +1 -0
- package/dist/src/ruvector/semantic-router.js +60 -67
- package/dist/src/ruvector/semantic-router.js.map +1 -1
- package/dist/src/ruvector/vector-db.d.ts +69 -0
- package/dist/src/ruvector/vector-db.d.ts.map +1 -0
- package/dist/src/ruvector/vector-db.js +119 -205
- package/dist/src/ruvector/vector-db.js.map +1 -1
- package/dist/src/services/agentic-flow-bridge.d.ts +50 -0
- package/dist/src/services/agentic-flow-bridge.d.ts.map +1 -0
- package/dist/src/services/agentic-flow-bridge.js +32 -105
- package/dist/src/services/agentic-flow-bridge.js.map +1 -1
- package/dist/src/services/claim-service.d.ts +204 -0
- package/dist/src/services/claim-service.d.ts.map +1 -0
- package/dist/src/services/claim-service.js +615 -940
- package/dist/src/services/claim-service.js.map +1 -1
- package/dist/src/services/container-worker-pool.d.ts +197 -0
- package/dist/src/services/container-worker-pool.d.ts.map +1 -0
- package/dist/src/services/container-worker-pool.js +398 -666
- package/dist/src/services/container-worker-pool.js.map +1 -1
- package/dist/src/services/headless-worker-executor.d.ts +304 -0
- package/dist/src/services/headless-worker-executor.d.ts.map +1 -0
- package/dist/src/services/headless-worker-executor.js +441 -467
- package/dist/src/services/headless-worker-executor.js.map +1 -1
- package/dist/src/services/index.d.ts +4 -4
- package/dist/src/services/index.d.ts.map +1 -1
- package/dist/src/services/index.js +4 -4
- package/dist/src/services/index.js.map +1 -1
- package/dist/src/services/registry-api.d.ts +58 -0
- package/dist/src/services/registry-api.d.ts.map +1 -0
- package/dist/src/services/registry-api.js +92 -200
- package/dist/src/services/registry-api.js.map +1 -1
- package/dist/src/services/ruvector-training.d.ts +222 -0
- package/dist/src/services/ruvector-training.d.ts.map +1 -0
- package/dist/src/services/ruvector-training.js +257 -337
- package/dist/src/services/ruvector-training.js.map +1 -1
- package/dist/src/services/worker-daemon.d.ts +228 -0
- package/dist/src/services/worker-daemon.d.ts.map +1 -0
- package/dist/src/services/worker-daemon.js +591 -849
- package/dist/src/services/worker-daemon.js.map +1 -1
- package/dist/src/services/worker-queue.d.ts +194 -0
- package/dist/src/services/worker-queue.d.ts.map +1 -0
- package/dist/src/services/worker-queue.js +331 -548
- package/dist/src/services/worker-queue.js.map +1 -1
- package/dist/src/suggest.d.ts +53 -0
- package/dist/src/suggest.d.ts.map +1 -0
- package/dist/src/suggest.js +45 -55
- package/dist/src/suggest.js.map +1 -1
- package/dist/src/transfer/anonymization/index.js +29 -37
- package/dist/src/transfer/anonymization/index.js.map +1 -1
- package/dist/src/transfer/deploy-seraphine.js +128 -155
- package/dist/src/transfer/deploy-seraphine.js.map +1 -1
- package/dist/src/transfer/export.d.ts +25 -0
- package/dist/src/transfer/export.d.ts.map +1 -0
- package/dist/src/transfer/export.js +84 -142
- package/dist/src/transfer/export.js.map +1 -1
- package/dist/src/transfer/index.d.ts +1 -1
- package/dist/src/transfer/index.d.ts.map +1 -1
- package/dist/src/transfer/index.js +0 -2
- package/dist/src/transfer/index.js.map +1 -1
- package/dist/src/transfer/ipfs/client.d.ts +109 -0
- package/dist/src/transfer/ipfs/client.d.ts.map +1 -0
- package/dist/src/transfer/ipfs/client.js +187 -337
- package/dist/src/transfer/ipfs/client.js.map +1 -1
- package/dist/src/transfer/ipfs/upload.d.ts +95 -0
- package/dist/src/transfer/ipfs/upload.d.ts.map +1 -0
- package/dist/src/transfer/ipfs/upload.js +288 -434
- package/dist/src/transfer/ipfs/upload.js.map +1 -1
- package/dist/src/transfer/models/seraphine.d.ts +72 -0
- package/dist/src/transfer/models/seraphine.d.ts.map +1 -0
- package/dist/src/transfer/models/seraphine.js +55 -55
- package/dist/src/transfer/models/seraphine.js.map +1 -1
- package/dist/src/transfer/serialization/cfp.d.ts +49 -0
- package/dist/src/transfer/serialization/cfp.d.ts.map +1 -0
- package/dist/src/transfer/serialization/cfp.js +30 -31
- package/dist/src/transfer/serialization/cfp.js.map +1 -1
- package/dist/src/transfer/storage/gcs.d.ts +82 -0
- package/dist/src/transfer/storage/gcs.d.ts.map +1 -0
- package/dist/src/transfer/storage/gcs.js +165 -232
- package/dist/src/transfer/storage/gcs.js.map +1 -1
- package/dist/src/transfer/store/discovery.d.ts +84 -0
- package/dist/src/transfer/store/discovery.d.ts.map +1 -0
- package/dist/src/transfer/store/discovery.js +239 -349
- package/dist/src/transfer/store/discovery.js.map +1 -1
- package/dist/src/transfer/store/download.d.ts +70 -0
- package/dist/src/transfer/store/download.d.ts.map +1 -0
- package/dist/src/transfer/store/download.js +243 -365
- package/dist/src/transfer/store/download.js.map +1 -1
- package/dist/src/transfer/store/index.d.ts +84 -0
- package/dist/src/transfer/store/index.d.ts.map +1 -0
- package/dist/src/transfer/store/index.js +63 -130
- package/dist/src/transfer/store/index.js.map +1 -1
- package/dist/src/transfer/store/publish.d.ts +76 -0
- package/dist/src/transfer/store/publish.d.ts.map +1 -0
- package/dist/src/transfer/store/publish.js +184 -258
- package/dist/src/transfer/store/publish.js.map +1 -1
- package/dist/src/transfer/store/registry.js +50 -72
- package/dist/src/transfer/store/registry.js.map +1 -1
- package/dist/src/transfer/store/search.d.ts +54 -0
- package/dist/src/transfer/store/search.d.ts.map +1 -0
- package/dist/src/transfer/store/search.js +64 -96
- package/dist/src/transfer/store/search.js.map +1 -1
- package/dist/src/transfer/store/tests/standalone-test.js +174 -231
- package/dist/src/transfer/store/tests/standalone-test.js.map +1 -1
- package/dist/src/transfer/test-seraphine.js +95 -130
- package/dist/src/transfer/test-seraphine.js.map +1 -1
- package/dist/src/transfer/tests/test-store.js +194 -239
- package/dist/src/transfer/tests/test-store.js.map +1 -1
- package/dist/src/transfer/types.d.ts +245 -0
- package/dist/src/transfer/types.d.ts.map +1 -0
- package/dist/src/types.d.ts +198 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +26 -55
- package/dist/src/types.js.map +1 -1
- package/dist/src/update/checker.d.ts +34 -0
- package/dist/src/update/checker.d.ts.map +1 -0
- package/dist/src/update/checker.js +106 -183
- package/dist/src/update/checker.js.map +1 -1
- package/dist/src/update/executor.d.ts +32 -0
- package/dist/src/update/executor.d.ts.map +1 -0
- package/dist/src/update/executor.js +135 -198
- package/dist/src/update/executor.js.map +1 -1
- package/dist/src/update/index.d.ts +33 -0
- package/dist/src/update/index.d.ts.map +1 -0
- package/dist/src/update/index.js +38 -85
- package/dist/src/update/index.js.map +1 -1
- package/dist/src/update/rate-limiter.d.ts +20 -0
- package/dist/src/update/rate-limiter.d.ts.map +1 -0
- package/dist/src/update/rate-limiter.js +19 -31
- package/dist/src/update/rate-limiter.js.map +1 -1
- package/dist/src/update/validator.d.ts +17 -0
- package/dist/src/update/validator.d.ts.map +1 -0
- package/dist/src/update/validator.js +38 -64
- package/dist/src/update/validator.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -16,88 +16,26 @@
|
|
|
16
16
|
* - Result caching with TTL
|
|
17
17
|
* - Worker heartbeat monitoring
|
|
18
18
|
*/
|
|
19
|
-
var __extends = (this && this.__extends) || (function () {
|
|
20
|
-
var extendStatics = function (d, b) {
|
|
21
|
-
extendStatics = Object.setPrototypeOf ||
|
|
22
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
23
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
24
|
-
return extendStatics(d, b);
|
|
25
|
-
};
|
|
26
|
-
return function (d, b) {
|
|
27
|
-
if (typeof b !== "function" && b !== null)
|
|
28
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
29
|
-
extendStatics(d, b);
|
|
30
|
-
function __() { this.constructor = d; }
|
|
31
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
32
|
-
};
|
|
33
|
-
})();
|
|
34
|
-
var __assign = (this && this.__assign) || function () {
|
|
35
|
-
__assign = Object.assign || function(t) {
|
|
36
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
37
|
-
s = arguments[i];
|
|
38
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
39
|
-
t[p] = s[p];
|
|
40
|
-
}
|
|
41
|
-
return t;
|
|
42
|
-
};
|
|
43
|
-
return __assign.apply(this, arguments);
|
|
44
|
-
};
|
|
45
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
46
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
47
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
48
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
49
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
50
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
51
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
55
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
56
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
57
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
58
|
-
function step(op) {
|
|
59
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
60
|
-
while (_) try {
|
|
61
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
62
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
63
|
-
switch (op[0]) {
|
|
64
|
-
case 0: case 1: t = op; break;
|
|
65
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
66
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
67
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
68
|
-
default:
|
|
69
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
70
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
71
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
72
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
73
|
-
if (t[2]) _.ops.pop();
|
|
74
|
-
_.trys.pop(); continue;
|
|
75
|
-
}
|
|
76
|
-
op = body.call(thisArg, _);
|
|
77
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
78
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
19
|
import { EventEmitter } from 'events';
|
|
82
20
|
import { randomUUID } from 'crypto';
|
|
83
21
|
// ============================================
|
|
84
22
|
// Constants
|
|
85
23
|
// ============================================
|
|
86
|
-
|
|
24
|
+
const DEFAULT_CONFIG = {
|
|
87
25
|
redisUrl: 'redis://localhost:6379',
|
|
88
26
|
queuePrefix: 'claude-flow:queue',
|
|
89
|
-
defaultTimeoutMs: 300000,
|
|
27
|
+
defaultTimeoutMs: 300000, // 5 minutes
|
|
90
28
|
maxRetries: 3,
|
|
91
|
-
resultTtlSeconds: 86400,
|
|
92
|
-
heartbeatIntervalMs: 30000,
|
|
29
|
+
resultTtlSeconds: 86400, // 24 hours
|
|
30
|
+
heartbeatIntervalMs: 30000, // 30 seconds
|
|
93
31
|
deadLetterEnabled: true,
|
|
94
|
-
visibilityTimeoutMs: 60000
|
|
32
|
+
visibilityTimeoutMs: 60000, // 1 minute
|
|
95
33
|
};
|
|
96
|
-
|
|
34
|
+
const PRIORITY_SCORES = {
|
|
97
35
|
critical: 4,
|
|
98
36
|
high: 3,
|
|
99
37
|
normal: 2,
|
|
100
|
-
low: 1
|
|
38
|
+
low: 1,
|
|
101
39
|
};
|
|
102
40
|
// ============================================
|
|
103
41
|
// In-Memory Redis Simulation (for non-Redis environments)
|
|
@@ -106,49 +44,47 @@ var PRIORITY_SCORES = {
|
|
|
106
44
|
* Simple in-memory queue implementation for environments without Redis
|
|
107
45
|
* Production should use actual Redis connection
|
|
108
46
|
*/
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
47
|
+
class InMemoryStore {
|
|
48
|
+
tasks = new Map();
|
|
49
|
+
queues = new Map();
|
|
50
|
+
workers = new Map();
|
|
51
|
+
results = new Map();
|
|
52
|
+
cleanupTimer;
|
|
116
53
|
/**
|
|
117
54
|
* Start cleanup timer (called after initialization)
|
|
118
55
|
*/
|
|
119
|
-
|
|
120
|
-
var _this = this;
|
|
56
|
+
startCleanup() {
|
|
121
57
|
if (this.cleanupTimer)
|
|
122
58
|
return;
|
|
123
|
-
this.cleanupTimer = setInterval(
|
|
59
|
+
this.cleanupTimer = setInterval(() => this.cleanupExpired(), 60000);
|
|
124
60
|
this.cleanupTimer.unref();
|
|
125
|
-
}
|
|
61
|
+
}
|
|
126
62
|
/**
|
|
127
63
|
* Stop cleanup timer
|
|
128
64
|
*/
|
|
129
|
-
|
|
65
|
+
stopCleanup() {
|
|
130
66
|
if (this.cleanupTimer) {
|
|
131
67
|
clearInterval(this.cleanupTimer);
|
|
132
68
|
this.cleanupTimer = undefined;
|
|
133
69
|
}
|
|
134
|
-
}
|
|
70
|
+
}
|
|
135
71
|
// Task operations
|
|
136
|
-
|
|
72
|
+
setTask(id, task) {
|
|
137
73
|
this.tasks.set(id, task);
|
|
138
|
-
}
|
|
139
|
-
|
|
74
|
+
}
|
|
75
|
+
getTask(id) {
|
|
140
76
|
return this.tasks.get(id);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
this.tasks
|
|
144
|
-
}
|
|
77
|
+
}
|
|
78
|
+
deleteTask(id) {
|
|
79
|
+
this.tasks.delete(id);
|
|
80
|
+
}
|
|
145
81
|
// Queue operations
|
|
146
|
-
|
|
147
|
-
|
|
82
|
+
pushToQueue(queue, taskId, priority) {
|
|
83
|
+
const queueTasks = this.queues.get(queue) || [];
|
|
148
84
|
// Insert based on priority (higher priority = earlier in queue)
|
|
149
|
-
|
|
150
|
-
for (
|
|
151
|
-
|
|
85
|
+
let insertIndex = queueTasks.length;
|
|
86
|
+
for (let i = 0; i < queueTasks.length; i++) {
|
|
87
|
+
const task = this.tasks.get(queueTasks[i]);
|
|
152
88
|
if (task && PRIORITY_SCORES[task.priority] < priority) {
|
|
153
89
|
insertIndex = i;
|
|
154
90
|
break;
|
|
@@ -156,575 +92,422 @@ var InMemoryStore = /** @class */ (function () {
|
|
|
156
92
|
}
|
|
157
93
|
queueTasks.splice(insertIndex, 0, taskId);
|
|
158
94
|
this.queues.set(queue, queueTasks);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
95
|
+
}
|
|
96
|
+
popFromQueue(queue) {
|
|
97
|
+
const queueTasks = this.queues.get(queue) || [];
|
|
162
98
|
if (queueTasks.length === 0)
|
|
163
99
|
return null;
|
|
164
100
|
return queueTasks.shift() || null;
|
|
165
|
-
}
|
|
166
|
-
|
|
101
|
+
}
|
|
102
|
+
getQueueLength(queue) {
|
|
167
103
|
return (this.queues.get(queue) || []).length;
|
|
168
|
-
}
|
|
104
|
+
}
|
|
169
105
|
// Worker operations
|
|
170
|
-
|
|
106
|
+
setWorker(workerId, registration) {
|
|
171
107
|
this.workers.set(workerId, registration);
|
|
172
|
-
}
|
|
173
|
-
|
|
108
|
+
}
|
|
109
|
+
getWorker(workerId) {
|
|
174
110
|
return this.workers.get(workerId);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
this.workers
|
|
178
|
-
}
|
|
179
|
-
|
|
111
|
+
}
|
|
112
|
+
deleteWorker(workerId) {
|
|
113
|
+
this.workers.delete(workerId);
|
|
114
|
+
}
|
|
115
|
+
getAllWorkers() {
|
|
180
116
|
return Array.from(this.workers.values());
|
|
181
|
-
}
|
|
117
|
+
}
|
|
182
118
|
// Result operations
|
|
183
|
-
|
|
119
|
+
setResult(taskId, result, ttlSeconds) {
|
|
184
120
|
this.results.set(taskId, {
|
|
185
|
-
result
|
|
186
|
-
expiresAt: Date.now() + ttlSeconds * 1000
|
|
121
|
+
result,
|
|
122
|
+
expiresAt: Date.now() + ttlSeconds * 1000,
|
|
187
123
|
});
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
124
|
+
}
|
|
125
|
+
getResult(taskId) {
|
|
126
|
+
const entry = this.results.get(taskId);
|
|
191
127
|
if (!entry)
|
|
192
128
|
return undefined;
|
|
193
129
|
if (Date.now() > entry.expiresAt) {
|
|
194
|
-
this.results
|
|
130
|
+
this.results.delete(taskId);
|
|
195
131
|
return undefined;
|
|
196
132
|
}
|
|
197
133
|
return entry.result;
|
|
198
|
-
}
|
|
134
|
+
}
|
|
199
135
|
// Stats
|
|
200
|
-
|
|
136
|
+
getStats() {
|
|
201
137
|
return {
|
|
202
138
|
tasks: this.tasks.size,
|
|
203
139
|
workers: this.workers.size,
|
|
204
|
-
results: this.results.size
|
|
140
|
+
results: this.results.size,
|
|
205
141
|
};
|
|
206
|
-
}
|
|
142
|
+
}
|
|
207
143
|
// Cleanup
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
for (
|
|
211
|
-
var _b = _a[_i], id = _b[0], entry = _b[1];
|
|
144
|
+
cleanupExpired() {
|
|
145
|
+
const now = Date.now();
|
|
146
|
+
for (const [id, entry] of this.results) {
|
|
212
147
|
if (now > entry.expiresAt) {
|
|
213
|
-
this.results
|
|
148
|
+
this.results.delete(id);
|
|
214
149
|
}
|
|
215
150
|
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
}());
|
|
151
|
+
}
|
|
152
|
+
}
|
|
219
153
|
// ============================================
|
|
220
154
|
// WorkerQueue Class
|
|
221
155
|
// ============================================
|
|
222
156
|
/**
|
|
223
157
|
* WorkerQueue - Redis-based task queue for distributed worker execution
|
|
224
158
|
*/
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
159
|
+
export class WorkerQueue extends EventEmitter {
|
|
160
|
+
config;
|
|
161
|
+
store;
|
|
162
|
+
workerId;
|
|
163
|
+
heartbeatTimer;
|
|
164
|
+
processingTasks = new Set();
|
|
165
|
+
isShuttingDown = false;
|
|
166
|
+
maxConcurrent = 1;
|
|
167
|
+
initialized = false;
|
|
168
|
+
constructor(config) {
|
|
169
|
+
super();
|
|
170
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
171
|
+
this.store = new InMemoryStore();
|
|
172
|
+
this.workerId = `worker-${randomUUID().slice(0, 8)}`;
|
|
237
173
|
}
|
|
238
174
|
/**
|
|
239
175
|
* Initialize the queue (starts cleanup timers)
|
|
240
176
|
*/
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
return
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
this.emit('initialized', { workerId: this.workerId });
|
|
249
|
-
return [2 /*return*/];
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
};
|
|
177
|
+
async initialize() {
|
|
178
|
+
if (this.initialized)
|
|
179
|
+
return;
|
|
180
|
+
this.store.startCleanup();
|
|
181
|
+
this.initialized = true;
|
|
182
|
+
this.emit('initialized', { workerId: this.workerId });
|
|
183
|
+
}
|
|
253
184
|
// ============================================
|
|
254
185
|
// Public API - Task Management
|
|
255
186
|
// ============================================
|
|
256
187
|
/**
|
|
257
188
|
* Enqueue a new task
|
|
258
189
|
*/
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
if (
|
|
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
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
this.store.pushToQueue(queueName, taskId, PRIORITY_SCORES[priority]);
|
|
296
|
-
this.emit('taskEnqueued', { taskId: taskId, workerType: workerType, priority: priority });
|
|
297
|
-
return [2 /*return*/, taskId];
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
});
|
|
301
|
-
};
|
|
190
|
+
async enqueue(workerType, payload = {}, options) {
|
|
191
|
+
// Initialize if needed
|
|
192
|
+
if (!this.initialized) {
|
|
193
|
+
await this.initialize();
|
|
194
|
+
}
|
|
195
|
+
// Validate worker type
|
|
196
|
+
if (!workerType || typeof workerType !== 'string') {
|
|
197
|
+
throw new Error('Invalid worker type');
|
|
198
|
+
}
|
|
199
|
+
// Validate priority
|
|
200
|
+
const priority = options?.priority || 'normal';
|
|
201
|
+
if (!['critical', 'high', 'normal', 'low'].includes(priority)) {
|
|
202
|
+
throw new Error(`Invalid priority: ${priority}`);
|
|
203
|
+
}
|
|
204
|
+
const taskId = `task-${Date.now()}-${randomUUID().slice(0, 8)}`;
|
|
205
|
+
const task = {
|
|
206
|
+
id: taskId,
|
|
207
|
+
workerType,
|
|
208
|
+
priority,
|
|
209
|
+
payload: {
|
|
210
|
+
...payload,
|
|
211
|
+
timeoutMs: options?.timeoutMs || this.config.defaultTimeoutMs,
|
|
212
|
+
},
|
|
213
|
+
status: 'pending',
|
|
214
|
+
createdAt: new Date(),
|
|
215
|
+
retryCount: 0,
|
|
216
|
+
maxRetries: options?.maxRetries ?? this.config.maxRetries,
|
|
217
|
+
};
|
|
218
|
+
// Store task
|
|
219
|
+
this.store.setTask(taskId, task);
|
|
220
|
+
// Add to priority queue
|
|
221
|
+
const queueName = this.getQueueName(workerType);
|
|
222
|
+
this.store.pushToQueue(queueName, taskId, PRIORITY_SCORES[priority]);
|
|
223
|
+
this.emit('taskEnqueued', { taskId, workerType, priority });
|
|
224
|
+
return taskId;
|
|
225
|
+
}
|
|
302
226
|
/**
|
|
303
227
|
* Dequeue a task for processing
|
|
304
228
|
*/
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
this.store.setTask(taskId, task);
|
|
323
|
-
this.processingTasks.add(taskId);
|
|
324
|
-
this.emit('taskDequeued', { taskId: taskId, workerType: workerType });
|
|
325
|
-
return [2 /*return*/, task];
|
|
326
|
-
}
|
|
327
|
-
}
|
|
229
|
+
async dequeue(workerTypes) {
|
|
230
|
+
if (this.isShuttingDown)
|
|
231
|
+
return null;
|
|
232
|
+
// Check queues in priority order
|
|
233
|
+
for (const workerType of workerTypes) {
|
|
234
|
+
const queueName = this.getQueueName(workerType);
|
|
235
|
+
const taskId = this.store.popFromQueue(queueName);
|
|
236
|
+
if (taskId) {
|
|
237
|
+
const task = this.store.getTask(taskId);
|
|
238
|
+
if (task && task.status === 'pending') {
|
|
239
|
+
task.status = 'processing';
|
|
240
|
+
task.startedAt = new Date();
|
|
241
|
+
task.workerId = this.workerId;
|
|
242
|
+
this.store.setTask(taskId, task);
|
|
243
|
+
this.processingTasks.add(taskId);
|
|
244
|
+
this.emit('taskDequeued', { taskId, workerType });
|
|
245
|
+
return task;
|
|
328
246
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
333
251
|
/**
|
|
334
252
|
* Complete a task with result
|
|
335
253
|
*/
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
return
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
this.store.setResult(taskId, result, this.config.resultTtlSeconds);
|
|
352
|
-
this.processingTasks["delete"](taskId);
|
|
353
|
-
this.emit('taskCompleted', { taskId: taskId, result: result, duration: task.completedAt.getTime() - (((_a = task.startedAt) === null || _a === void 0 ? void 0 : _a.getTime()) || 0) });
|
|
354
|
-
return [2 /*return*/];
|
|
355
|
-
});
|
|
356
|
-
});
|
|
357
|
-
};
|
|
254
|
+
async complete(taskId, result) {
|
|
255
|
+
const task = this.store.getTask(taskId);
|
|
256
|
+
if (!task) {
|
|
257
|
+
this.emit('warning', { message: `Task ${taskId} not found for completion` });
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
task.status = 'completed';
|
|
261
|
+
task.completedAt = new Date();
|
|
262
|
+
task.result = result;
|
|
263
|
+
this.store.setTask(taskId, task);
|
|
264
|
+
// Store result with TTL
|
|
265
|
+
this.store.setResult(taskId, result, this.config.resultTtlSeconds);
|
|
266
|
+
this.processingTasks.delete(taskId);
|
|
267
|
+
this.emit('taskCompleted', { taskId, result, duration: task.completedAt.getTime() - (task.startedAt?.getTime() || 0) });
|
|
268
|
+
}
|
|
358
269
|
/**
|
|
359
270
|
* Fail a task with error
|
|
360
271
|
*/
|
|
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
|
-
this.emit('taskFailed', { taskId: taskId, error: error, retryCount: task.retryCount });
|
|
399
|
-
}
|
|
400
|
-
return [2 /*return*/];
|
|
401
|
-
});
|
|
402
|
-
});
|
|
403
|
-
};
|
|
272
|
+
async fail(taskId, error, retryable = true) {
|
|
273
|
+
const task = this.store.getTask(taskId);
|
|
274
|
+
if (!task) {
|
|
275
|
+
this.emit('warning', { message: `Task ${taskId} not found for failure` });
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
this.processingTasks.delete(taskId);
|
|
279
|
+
// Check if we should retry
|
|
280
|
+
if (retryable && task.retryCount < task.maxRetries) {
|
|
281
|
+
task.retryCount++;
|
|
282
|
+
task.status = 'pending';
|
|
283
|
+
task.startedAt = undefined;
|
|
284
|
+
task.workerId = undefined;
|
|
285
|
+
task.error = error;
|
|
286
|
+
this.store.setTask(taskId, task);
|
|
287
|
+
// Re-queue with delay (exponential backoff)
|
|
288
|
+
const delay = Math.min(30000, 1000 * Math.pow(2, task.retryCount));
|
|
289
|
+
setTimeout(() => {
|
|
290
|
+
const queueName = this.getQueueName(task.workerType);
|
|
291
|
+
this.store.pushToQueue(queueName, taskId, PRIORITY_SCORES[task.priority]);
|
|
292
|
+
}, delay);
|
|
293
|
+
this.emit('taskRetrying', { taskId, retryCount: task.retryCount, delay });
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
// Move to failed/dead letter
|
|
297
|
+
task.status = 'failed';
|
|
298
|
+
task.completedAt = new Date();
|
|
299
|
+
task.error = error;
|
|
300
|
+
this.store.setTask(taskId, task);
|
|
301
|
+
if (this.config.deadLetterEnabled) {
|
|
302
|
+
const dlqName = `${this.config.queuePrefix}:dlq`;
|
|
303
|
+
this.store.pushToQueue(dlqName, taskId, 0);
|
|
304
|
+
}
|
|
305
|
+
this.emit('taskFailed', { taskId, error, retryCount: task.retryCount });
|
|
306
|
+
}
|
|
307
|
+
}
|
|
404
308
|
/**
|
|
405
309
|
* Get task status
|
|
406
310
|
*/
|
|
407
|
-
|
|
408
|
-
return
|
|
409
|
-
|
|
410
|
-
return [2 /*return*/, this.store.getTask(taskId) || null];
|
|
411
|
-
});
|
|
412
|
-
});
|
|
413
|
-
};
|
|
311
|
+
async getTask(taskId) {
|
|
312
|
+
return this.store.getTask(taskId) || null;
|
|
313
|
+
}
|
|
414
314
|
/**
|
|
415
315
|
* Get task result
|
|
416
316
|
*/
|
|
417
|
-
|
|
418
|
-
return
|
|
419
|
-
|
|
420
|
-
return [2 /*return*/, this.store.getResult(taskId) || null];
|
|
421
|
-
});
|
|
422
|
-
});
|
|
423
|
-
};
|
|
317
|
+
async getResult(taskId) {
|
|
318
|
+
return this.store.getResult(taskId) || null;
|
|
319
|
+
}
|
|
424
320
|
/**
|
|
425
321
|
* Cancel a pending task
|
|
426
322
|
*/
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
return
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
this.emit('taskCancelled', { taskId: taskId });
|
|
439
|
-
return [2 /*return*/, true];
|
|
440
|
-
});
|
|
441
|
-
});
|
|
442
|
-
};
|
|
323
|
+
async cancel(taskId) {
|
|
324
|
+
const task = this.store.getTask(taskId);
|
|
325
|
+
if (!task || task.status !== 'pending') {
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
task.status = 'cancelled';
|
|
329
|
+
task.completedAt = new Date();
|
|
330
|
+
this.store.setTask(taskId, task);
|
|
331
|
+
this.emit('taskCancelled', { taskId });
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
443
334
|
// ============================================
|
|
444
335
|
// Public API - Worker Management
|
|
445
336
|
// ============================================
|
|
446
337
|
/**
|
|
447
338
|
* Register this instance as a worker
|
|
448
339
|
*/
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
};
|
|
476
|
-
this.store.setWorker(this.workerId, registration);
|
|
477
|
-
// Start heartbeat
|
|
478
|
-
this.startHeartbeat();
|
|
479
|
-
this.emit('workerRegistered', { workerId: this.workerId, workerTypes: workerTypes });
|
|
480
|
-
return [2 /*return*/, this.workerId];
|
|
481
|
-
}
|
|
482
|
-
});
|
|
483
|
-
});
|
|
484
|
-
};
|
|
340
|
+
async registerWorker(workerTypes, options) {
|
|
341
|
+
// Initialize if needed
|
|
342
|
+
if (!this.initialized) {
|
|
343
|
+
await this.initialize();
|
|
344
|
+
}
|
|
345
|
+
// Validate worker types
|
|
346
|
+
if (!Array.isArray(workerTypes) || workerTypes.length === 0) {
|
|
347
|
+
throw new Error('Worker types must be a non-empty array');
|
|
348
|
+
}
|
|
349
|
+
this.maxConcurrent = options?.maxConcurrent || 1;
|
|
350
|
+
const registration = {
|
|
351
|
+
workerId: this.workerId,
|
|
352
|
+
workerTypes,
|
|
353
|
+
maxConcurrent: this.maxConcurrent,
|
|
354
|
+
currentTasks: 0,
|
|
355
|
+
lastHeartbeat: new Date(),
|
|
356
|
+
registeredAt: new Date(),
|
|
357
|
+
hostname: options?.hostname,
|
|
358
|
+
containerId: options?.containerId,
|
|
359
|
+
};
|
|
360
|
+
this.store.setWorker(this.workerId, registration);
|
|
361
|
+
// Start heartbeat
|
|
362
|
+
this.startHeartbeat();
|
|
363
|
+
this.emit('workerRegistered', { workerId: this.workerId, workerTypes });
|
|
364
|
+
return this.workerId;
|
|
365
|
+
}
|
|
485
366
|
/**
|
|
486
367
|
* Unregister this worker
|
|
487
368
|
*/
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
this.emit('workerUnregistered', { workerId: this.workerId });
|
|
494
|
-
return [2 /*return*/];
|
|
495
|
-
});
|
|
496
|
-
});
|
|
497
|
-
};
|
|
369
|
+
async unregisterWorker() {
|
|
370
|
+
this.stopHeartbeat();
|
|
371
|
+
this.store.deleteWorker(this.workerId);
|
|
372
|
+
this.emit('workerUnregistered', { workerId: this.workerId });
|
|
373
|
+
}
|
|
498
374
|
/**
|
|
499
375
|
* Get all registered workers
|
|
500
376
|
*/
|
|
501
|
-
|
|
502
|
-
return
|
|
503
|
-
|
|
504
|
-
return [2 /*return*/, this.store.getAllWorkers()];
|
|
505
|
-
});
|
|
506
|
-
});
|
|
507
|
-
};
|
|
377
|
+
async getWorkers() {
|
|
378
|
+
return this.store.getAllWorkers();
|
|
379
|
+
}
|
|
508
380
|
// ============================================
|
|
509
381
|
// Public API - Statistics
|
|
510
382
|
// ============================================
|
|
511
383
|
/**
|
|
512
384
|
* Get queue statistics
|
|
513
385
|
*/
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
});
|
|
532
|
-
});
|
|
533
|
-
};
|
|
386
|
+
async getStats() {
|
|
387
|
+
const storeStats = this.store.getStats();
|
|
388
|
+
// This is a simplified implementation
|
|
389
|
+
// Full implementation would aggregate across all queues
|
|
390
|
+
const stats = {
|
|
391
|
+
pending: 0,
|
|
392
|
+
processing: this.processingTasks.size,
|
|
393
|
+
completed: 0,
|
|
394
|
+
failed: 0,
|
|
395
|
+
deadLetter: 0,
|
|
396
|
+
byPriority: { critical: 0, high: 0, normal: 0, low: 0 },
|
|
397
|
+
byWorkerType: {},
|
|
398
|
+
averageWaitTimeMs: 0,
|
|
399
|
+
averageProcessingTimeMs: 0,
|
|
400
|
+
};
|
|
401
|
+
return stats;
|
|
402
|
+
}
|
|
534
403
|
// ============================================
|
|
535
404
|
// Public API - Lifecycle
|
|
536
405
|
// ============================================
|
|
537
406
|
/**
|
|
538
407
|
* Start processing tasks
|
|
539
408
|
*/
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
_loop_1 = function () {
|
|
556
|
-
var task_1, error_1;
|
|
557
|
-
return __generator(this, function (_b) {
|
|
558
|
-
switch (_b.label) {
|
|
559
|
-
case 0:
|
|
560
|
-
_b.trys.push([0, 7, , 9]);
|
|
561
|
-
if (!(this_1.processingTasks.size >= this_1.maxConcurrent)) return [3 /*break*/, 2];
|
|
562
|
-
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })];
|
|
563
|
-
case 1:
|
|
564
|
-
_b.sent();
|
|
565
|
-
return [2 /*return*/, "continue"];
|
|
566
|
-
case 2: return [4 /*yield*/, this_1.dequeue(workerTypes)];
|
|
567
|
-
case 3:
|
|
568
|
-
task_1 = _b.sent();
|
|
569
|
-
if (!task_1) return [3 /*break*/, 4];
|
|
570
|
-
// Process task without blocking the loop (allows concurrency)
|
|
571
|
-
this_1.processTask(task_1, handler)["catch"](function (error) {
|
|
572
|
-
_this.emit('error', { taskId: task_1.id, error: String(error) });
|
|
573
|
-
});
|
|
574
|
-
return [3 /*break*/, 6];
|
|
575
|
-
case 4:
|
|
576
|
-
// No task available, wait before polling again
|
|
577
|
-
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1000); })];
|
|
578
|
-
case 5:
|
|
579
|
-
// No task available, wait before polling again
|
|
580
|
-
_b.sent();
|
|
581
|
-
_b.label = 6;
|
|
582
|
-
case 6: return [3 /*break*/, 9];
|
|
583
|
-
case 7:
|
|
584
|
-
error_1 = _b.sent();
|
|
585
|
-
this_1.emit('error', { error: error_1 instanceof Error ? error_1.message : String(error_1) });
|
|
586
|
-
// Wait before retrying to avoid tight error loop
|
|
587
|
-
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 5000); })];
|
|
588
|
-
case 8:
|
|
589
|
-
// Wait before retrying to avoid tight error loop
|
|
590
|
-
_b.sent();
|
|
591
|
-
return [3 /*break*/, 9];
|
|
592
|
-
case 9: return [2 /*return*/];
|
|
593
|
-
}
|
|
594
|
-
});
|
|
595
|
-
};
|
|
596
|
-
this_1 = this;
|
|
597
|
-
_a.label = 1;
|
|
598
|
-
case 1:
|
|
599
|
-
if (!!this.isShuttingDown) return [3 /*break*/, 3];
|
|
600
|
-
return [5 /*yield**/, _loop_1()];
|
|
601
|
-
case 2:
|
|
602
|
-
_a.sent();
|
|
603
|
-
return [3 /*break*/, 1];
|
|
604
|
-
case 3: return [2 /*return*/];
|
|
605
|
-
}
|
|
606
|
-
});
|
|
607
|
-
}); };
|
|
608
|
-
// Start processing
|
|
609
|
-
processLoop()["catch"](function (error) {
|
|
610
|
-
_this.emit('error', { error: error instanceof Error ? error.message : String(error) });
|
|
409
|
+
async start(workerTypes, handler, options) {
|
|
410
|
+
await this.registerWorker(workerTypes, { maxConcurrent: options?.maxConcurrent });
|
|
411
|
+
const processLoop = async () => {
|
|
412
|
+
while (!this.isShuttingDown) {
|
|
413
|
+
try {
|
|
414
|
+
// Respect concurrency limit
|
|
415
|
+
if (this.processingTasks.size >= this.maxConcurrent) {
|
|
416
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
const task = await this.dequeue(workerTypes);
|
|
420
|
+
if (task) {
|
|
421
|
+
// Process task without blocking the loop (allows concurrency)
|
|
422
|
+
this.processTask(task, handler).catch(error => {
|
|
423
|
+
this.emit('error', { taskId: task.id, error: String(error) });
|
|
611
424
|
});
|
|
612
|
-
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
// No task available, wait before polling again
|
|
428
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
429
|
+
}
|
|
613
430
|
}
|
|
614
|
-
|
|
431
|
+
catch (error) {
|
|
432
|
+
this.emit('error', { error: error instanceof Error ? error.message : String(error) });
|
|
433
|
+
// Wait before retrying to avoid tight error loop
|
|
434
|
+
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
// Start processing
|
|
439
|
+
processLoop().catch(error => {
|
|
440
|
+
this.emit('error', { error: error instanceof Error ? error.message : String(error) });
|
|
615
441
|
});
|
|
616
|
-
}
|
|
442
|
+
}
|
|
617
443
|
/**
|
|
618
444
|
* Process a single task
|
|
619
445
|
*/
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
result = _a.sent();
|
|
630
|
-
return [4 /*yield*/, this.complete(task.id, result)];
|
|
631
|
-
case 2:
|
|
632
|
-
_a.sent();
|
|
633
|
-
return [3 /*break*/, 5];
|
|
634
|
-
case 3:
|
|
635
|
-
error_2 = _a.sent();
|
|
636
|
-
return [4 /*yield*/, this.fail(task.id, error_2 instanceof Error ? error_2.message : String(error_2))];
|
|
637
|
-
case 4:
|
|
638
|
-
_a.sent();
|
|
639
|
-
return [3 /*break*/, 5];
|
|
640
|
-
case 5: return [2 /*return*/];
|
|
641
|
-
}
|
|
642
|
-
});
|
|
643
|
-
});
|
|
644
|
-
};
|
|
446
|
+
async processTask(task, handler) {
|
|
447
|
+
try {
|
|
448
|
+
const result = await handler(task);
|
|
449
|
+
await this.complete(task.id, result);
|
|
450
|
+
}
|
|
451
|
+
catch (error) {
|
|
452
|
+
await this.fail(task.id, error instanceof Error ? error.message : String(error));
|
|
453
|
+
}
|
|
454
|
+
}
|
|
645
455
|
/**
|
|
646
456
|
* Shutdown the queue gracefully
|
|
647
457
|
*/
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
_b.label = 4;
|
|
669
|
-
case 4:
|
|
670
|
-
if (!(_i < _a.length)) return [3 /*break*/, 7];
|
|
671
|
-
taskId = _a[_i];
|
|
672
|
-
return [4 /*yield*/, this.fail(taskId, 'Worker shutdown', false)];
|
|
673
|
-
case 5:
|
|
674
|
-
_b.sent();
|
|
675
|
-
_b.label = 6;
|
|
676
|
-
case 6:
|
|
677
|
-
_i++;
|
|
678
|
-
return [3 /*break*/, 4];
|
|
679
|
-
case 7:
|
|
680
|
-
// Stop store cleanup
|
|
681
|
-
this.store.stopCleanup();
|
|
682
|
-
return [4 /*yield*/, this.unregisterWorker()];
|
|
683
|
-
case 8:
|
|
684
|
-
_b.sent();
|
|
685
|
-
this.initialized = false;
|
|
686
|
-
this.emit('shutdown', {});
|
|
687
|
-
return [2 /*return*/];
|
|
688
|
-
}
|
|
689
|
-
});
|
|
690
|
-
});
|
|
691
|
-
};
|
|
458
|
+
async shutdown() {
|
|
459
|
+
if (this.isShuttingDown)
|
|
460
|
+
return;
|
|
461
|
+
this.isShuttingDown = true;
|
|
462
|
+
// Wait for processing tasks to complete (with timeout)
|
|
463
|
+
const timeout = 30000;
|
|
464
|
+
const start = Date.now();
|
|
465
|
+
while (this.processingTasks.size > 0 && Date.now() - start < timeout) {
|
|
466
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
467
|
+
}
|
|
468
|
+
// Force fail remaining tasks
|
|
469
|
+
for (const taskId of this.processingTasks) {
|
|
470
|
+
await this.fail(taskId, 'Worker shutdown', false);
|
|
471
|
+
}
|
|
472
|
+
// Stop store cleanup
|
|
473
|
+
this.store.stopCleanup();
|
|
474
|
+
await this.unregisterWorker();
|
|
475
|
+
this.initialized = false;
|
|
476
|
+
this.emit('shutdown', {});
|
|
477
|
+
}
|
|
692
478
|
// ============================================
|
|
693
479
|
// Private Methods
|
|
694
480
|
// ============================================
|
|
695
481
|
/**
|
|
696
482
|
* Get queue name for worker type
|
|
697
483
|
*/
|
|
698
|
-
|
|
699
|
-
return this.config.queuePrefix
|
|
700
|
-
}
|
|
484
|
+
getQueueName(workerType) {
|
|
485
|
+
return `${this.config.queuePrefix}:${workerType}`;
|
|
486
|
+
}
|
|
701
487
|
/**
|
|
702
488
|
* Start heartbeat timer
|
|
703
489
|
*/
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
var registration = _this.store.getWorker(_this.workerId);
|
|
490
|
+
startHeartbeat() {
|
|
491
|
+
this.heartbeatTimer = setInterval(() => {
|
|
492
|
+
const registration = this.store.getWorker(this.workerId);
|
|
708
493
|
if (registration) {
|
|
709
494
|
registration.lastHeartbeat = new Date();
|
|
710
|
-
registration.currentTasks =
|
|
711
|
-
|
|
495
|
+
registration.currentTasks = this.processingTasks.size;
|
|
496
|
+
this.store.setWorker(this.workerId, registration);
|
|
712
497
|
}
|
|
713
498
|
}, this.config.heartbeatIntervalMs);
|
|
714
499
|
this.heartbeatTimer.unref();
|
|
715
|
-
}
|
|
500
|
+
}
|
|
716
501
|
/**
|
|
717
502
|
* Stop heartbeat timer
|
|
718
503
|
*/
|
|
719
|
-
|
|
504
|
+
stopHeartbeat() {
|
|
720
505
|
if (this.heartbeatTimer) {
|
|
721
506
|
clearInterval(this.heartbeatTimer);
|
|
722
507
|
this.heartbeatTimer = undefined;
|
|
723
508
|
}
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
}(EventEmitter));
|
|
727
|
-
export { WorkerQueue };
|
|
509
|
+
}
|
|
510
|
+
}
|
|
728
511
|
// Export default
|
|
729
512
|
export default WorkerQueue;
|
|
730
513
|
//# sourceMappingURL=worker-queue.js.map
|