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