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
|
@@ -9,62 +9,72 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @module @claude-flow/cli/production/rate-limiter
|
|
11
11
|
*/
|
|
12
|
+
var __assign = (this && this.__assign) || function () {
|
|
13
|
+
__assign = Object.assign || function(t) {
|
|
14
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
15
|
+
s = arguments[i];
|
|
16
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
17
|
+
t[p] = s[p];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
return __assign.apply(this, arguments);
|
|
22
|
+
};
|
|
12
23
|
// ============================================================================
|
|
13
24
|
// Rate Limiter
|
|
14
25
|
// ============================================================================
|
|
15
|
-
|
|
26
|
+
var DEFAULT_CONFIG = {
|
|
16
27
|
maxRequests: 100,
|
|
17
|
-
windowMs: 60000,
|
|
28
|
+
windowMs: 60000,
|
|
18
29
|
burstMultiplier: 1.5,
|
|
19
30
|
whitelist: [],
|
|
20
31
|
operationLimits: {},
|
|
21
32
|
perUserLimits: true,
|
|
22
|
-
maxTrackedUsers: 10000
|
|
33
|
+
maxTrackedUsers: 10000
|
|
23
34
|
};
|
|
24
|
-
|
|
25
|
-
config
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
35
|
+
var RateLimiter = /** @class */ (function () {
|
|
36
|
+
function RateLimiter(config) {
|
|
37
|
+
if (config === void 0) { config = {}; }
|
|
38
|
+
this.buckets = new Map();
|
|
39
|
+
this.config = __assign(__assign({}, DEFAULT_CONFIG), config);
|
|
30
40
|
this.globalBucket = this.createBucket();
|
|
31
41
|
}
|
|
32
42
|
/**
|
|
33
43
|
* Check if a request is allowed
|
|
34
44
|
*/
|
|
35
|
-
check(operation, userId) {
|
|
45
|
+
RateLimiter.prototype.check = function (operation, userId) {
|
|
36
46
|
// Check whitelist
|
|
37
47
|
if (this.config.whitelist.includes(operation)) {
|
|
38
48
|
return { allowed: true, remaining: Infinity, resetAt: 0 };
|
|
39
49
|
}
|
|
40
50
|
// Get limits for this operation
|
|
41
|
-
|
|
42
|
-
|
|
51
|
+
var limits = this.getLimits(operation);
|
|
52
|
+
var now = Date.now();
|
|
43
53
|
// Get or create bucket
|
|
44
|
-
|
|
45
|
-
?
|
|
46
|
-
:
|
|
47
|
-
|
|
54
|
+
var bucketKey = userId && this.config.perUserLimits
|
|
55
|
+
? operation + ":" + userId
|
|
56
|
+
: "global:" + operation;
|
|
57
|
+
var bucket = this.buckets.get(bucketKey);
|
|
48
58
|
if (!bucket) {
|
|
49
59
|
bucket = this.createBucket();
|
|
50
60
|
this.buckets.set(bucketKey, bucket);
|
|
51
61
|
this.cleanupBuckets();
|
|
52
62
|
}
|
|
53
63
|
// Clean old requests from sliding window
|
|
54
|
-
bucket.requests = bucket.requests.filter(t
|
|
64
|
+
bucket.requests = bucket.requests.filter(function (t) { return t > now - limits.windowMs; });
|
|
55
65
|
// Calculate remaining
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
var maxWithBurst = Math.floor(limits.maxRequests * this.config.burstMultiplier);
|
|
67
|
+
var remaining = maxWithBurst - bucket.requests.length;
|
|
58
68
|
if (remaining <= 0) {
|
|
59
69
|
// Rate limited
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
70
|
+
var oldestRequest = bucket.requests[0];
|
|
71
|
+
var resetAt = oldestRequest + limits.windowMs;
|
|
72
|
+
var retryAfterMs = resetAt - now;
|
|
63
73
|
return {
|
|
64
74
|
allowed: false,
|
|
65
75
|
remaining: 0,
|
|
66
|
-
resetAt,
|
|
67
|
-
retryAfterMs: Math.max(0, retryAfterMs)
|
|
76
|
+
resetAt: resetAt,
|
|
77
|
+
retryAfterMs: Math.max(0, retryAfterMs)
|
|
68
78
|
};
|
|
69
79
|
}
|
|
70
80
|
// Allow request
|
|
@@ -72,122 +82,131 @@ export class RateLimiter {
|
|
|
72
82
|
return {
|
|
73
83
|
allowed: true,
|
|
74
84
|
remaining: remaining - 1,
|
|
75
|
-
resetAt: now + limits.windowMs
|
|
85
|
+
resetAt: now + limits.windowMs
|
|
76
86
|
};
|
|
77
|
-
}
|
|
87
|
+
};
|
|
78
88
|
/**
|
|
79
89
|
* Consume a token (use after successful request)
|
|
80
90
|
*/
|
|
81
|
-
consume(operation, userId) {
|
|
82
|
-
|
|
91
|
+
RateLimiter.prototype.consume = function (operation, userId) {
|
|
92
|
+
var result = this.check(operation, userId);
|
|
83
93
|
return result.allowed;
|
|
84
|
-
}
|
|
94
|
+
};
|
|
85
95
|
/**
|
|
86
96
|
* Get current rate limit status
|
|
87
97
|
*/
|
|
88
|
-
getStatus(operation, userId) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
?
|
|
92
|
-
:
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
RateLimiter.prototype.getStatus = function (operation, userId) {
|
|
99
|
+
var limits = this.getLimits(operation);
|
|
100
|
+
var bucketKey = userId && this.config.perUserLimits
|
|
101
|
+
? operation + ":" + userId
|
|
102
|
+
: "global:" + operation;
|
|
103
|
+
var bucket = this.buckets.get(bucketKey);
|
|
104
|
+
var now = Date.now();
|
|
95
105
|
if (!bucket) {
|
|
96
106
|
return {
|
|
97
107
|
current: 0,
|
|
98
108
|
limit: limits.maxRequests,
|
|
99
109
|
remaining: limits.maxRequests,
|
|
100
|
-
resetAt: now + limits.windowMs
|
|
110
|
+
resetAt: now + limits.windowMs
|
|
101
111
|
};
|
|
102
112
|
}
|
|
103
113
|
// Clean old requests
|
|
104
|
-
|
|
114
|
+
var validRequests = bucket.requests.filter(function (t) { return t > now - limits.windowMs; });
|
|
105
115
|
return {
|
|
106
116
|
current: validRequests.length,
|
|
107
117
|
limit: limits.maxRequests,
|
|
108
118
|
remaining: Math.max(0, limits.maxRequests - validRequests.length),
|
|
109
119
|
resetAt: validRequests.length > 0
|
|
110
120
|
? validRequests[0] + limits.windowMs
|
|
111
|
-
: now + limits.windowMs
|
|
121
|
+
: now + limits.windowMs
|
|
112
122
|
};
|
|
113
|
-
}
|
|
123
|
+
};
|
|
114
124
|
/**
|
|
115
125
|
* Reset limits for a specific key
|
|
116
126
|
*/
|
|
117
|
-
reset(operation, userId) {
|
|
118
|
-
|
|
119
|
-
?
|
|
120
|
-
:
|
|
121
|
-
this.buckets
|
|
122
|
-
}
|
|
127
|
+
RateLimiter.prototype.reset = function (operation, userId) {
|
|
128
|
+
var bucketKey = userId && this.config.perUserLimits
|
|
129
|
+
? operation + ":" + userId
|
|
130
|
+
: "global:" + operation;
|
|
131
|
+
this.buckets["delete"](bucketKey);
|
|
132
|
+
};
|
|
123
133
|
/**
|
|
124
134
|
* Reset all limits
|
|
125
135
|
*/
|
|
126
|
-
resetAll() {
|
|
136
|
+
RateLimiter.prototype.resetAll = function () {
|
|
127
137
|
this.buckets.clear();
|
|
128
138
|
this.globalBucket = this.createBucket();
|
|
129
|
-
}
|
|
139
|
+
};
|
|
130
140
|
/**
|
|
131
141
|
* Get statistics
|
|
132
142
|
*/
|
|
133
|
-
getStats() {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
for (
|
|
137
|
-
|
|
143
|
+
RateLimiter.prototype.getStats = function () {
|
|
144
|
+
var operationCounts = new Map();
|
|
145
|
+
var users = new Set();
|
|
146
|
+
for (var _i = 0, _a = this.buckets; _i < _a.length; _i++) {
|
|
147
|
+
var _b = _a[_i], key = _b[0], bucket = _b[1];
|
|
148
|
+
var _c = key.split(':'), operation = _c[0], userId = _c[1];
|
|
138
149
|
if (userId)
|
|
139
150
|
users.add(userId);
|
|
140
|
-
|
|
151
|
+
var current = operationCounts.get(operation) || 0;
|
|
141
152
|
operationCounts.set(operation, current + bucket.requests.length);
|
|
142
153
|
}
|
|
143
|
-
|
|
144
|
-
.map((
|
|
145
|
-
|
|
154
|
+
var mostLimited = Array.from(operationCounts.entries())
|
|
155
|
+
.map(function (_a) {
|
|
156
|
+
var operation = _a[0], requests = _a[1];
|
|
157
|
+
return ({ operation: operation, requests: requests });
|
|
158
|
+
})
|
|
159
|
+
.sort(function (a, b) { return b.requests - a.requests; })
|
|
146
160
|
.slice(0, 10);
|
|
147
161
|
return {
|
|
148
162
|
totalBuckets: this.buckets.size,
|
|
149
163
|
activeUsers: users.size,
|
|
150
|
-
mostLimitedOperations: mostLimited
|
|
164
|
+
mostLimitedOperations: mostLimited
|
|
151
165
|
};
|
|
152
|
-
}
|
|
166
|
+
};
|
|
153
167
|
// ============================================================================
|
|
154
168
|
// Private Methods
|
|
155
169
|
// ============================================================================
|
|
156
|
-
getLimits(operation) {
|
|
170
|
+
RateLimiter.prototype.getLimits = function (operation) {
|
|
157
171
|
return this.config.operationLimits[operation] || {
|
|
158
172
|
maxRequests: this.config.maxRequests,
|
|
159
|
-
windowMs: this.config.windowMs
|
|
173
|
+
windowMs: this.config.windowMs
|
|
160
174
|
};
|
|
161
|
-
}
|
|
162
|
-
createBucket() {
|
|
175
|
+
};
|
|
176
|
+
RateLimiter.prototype.createBucket = function () {
|
|
163
177
|
return {
|
|
164
178
|
tokens: this.config.maxRequests,
|
|
165
179
|
lastRefill: Date.now(),
|
|
166
|
-
requests: []
|
|
180
|
+
requests: []
|
|
167
181
|
};
|
|
168
|
-
}
|
|
169
|
-
cleanupBuckets() {
|
|
182
|
+
};
|
|
183
|
+
RateLimiter.prototype.cleanupBuckets = function () {
|
|
184
|
+
var _this = this;
|
|
170
185
|
// Limit number of tracked buckets
|
|
171
186
|
if (this.buckets.size > this.config.maxTrackedUsers) {
|
|
172
|
-
|
|
173
|
-
|
|
187
|
+
var now_1 = Date.now();
|
|
188
|
+
var toDelete = [];
|
|
174
189
|
// Find buckets with no recent requests
|
|
175
|
-
for (
|
|
176
|
-
|
|
190
|
+
for (var _i = 0, _a = this.buckets; _i < _a.length; _i++) {
|
|
191
|
+
var _b = _a[_i], key = _b[0], bucket = _b[1];
|
|
192
|
+
var recent = bucket.requests.filter(function (t) { return t > now_1 - _this.config.windowMs * 2; });
|
|
177
193
|
if (recent.length === 0) {
|
|
178
194
|
toDelete.push(key);
|
|
179
195
|
}
|
|
180
196
|
}
|
|
181
197
|
// Delete stale buckets
|
|
182
|
-
for (
|
|
183
|
-
|
|
198
|
+
for (var _c = 0, toDelete_1 = toDelete; _c < toDelete_1.length; _c++) {
|
|
199
|
+
var key = toDelete_1[_c];
|
|
200
|
+
this.buckets["delete"](key);
|
|
184
201
|
if (this.buckets.size <= this.config.maxTrackedUsers * 0.8) {
|
|
185
202
|
break;
|
|
186
203
|
}
|
|
187
204
|
}
|
|
188
205
|
}
|
|
189
|
-
}
|
|
190
|
-
|
|
206
|
+
};
|
|
207
|
+
return RateLimiter;
|
|
208
|
+
}());
|
|
209
|
+
export { RateLimiter };
|
|
191
210
|
// ============================================================================
|
|
192
211
|
// Convenience Functions
|
|
193
212
|
// ============================================================================
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limiter.js","sourceRoot":"","sources":["../../../src/production/rate-limiter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG
|
|
1
|
+
{"version":3,"file":"rate-limiter.js","sourceRoot":"","sources":["../../../src/production/rate-limiter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;;;;;;;;;;;;AAoCH,+EAA+E;AAC/E,eAAe;AACf,+EAA+E;AAE/E,IAAM,cAAc,GAAsB;IACxC,WAAW,EAAE,GAAG;IAChB,QAAQ,EAAE,KAAK;IACf,eAAe,EAAE,GAAG;IACpB,SAAS,EAAE,EAAE;IACb,eAAe,EAAE,EAAE;IACnB,aAAa,EAAE,IAAI;IACnB,eAAe,EAAE,KAAK;CACvB,CAAC;AAEF;IAKE,qBAAY,MAAuC;QAAvC,uBAAA,EAAA,WAAuC;QAH3C,YAAO,GAA6B,IAAI,GAAG,EAAE,CAAC;QAIpD,IAAI,CAAC,MAAM,yBAAQ,cAAc,GAAK,MAAM,CAAE,CAAC;QAC/C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,2BAAK,GAAL,UACE,SAAiB,EACjB,MAAe;QAEf,kBAAkB;QAClB,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;YAC7C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;SAC3D;QAED,gCAAgC;QAChC,IAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QACzC,IAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEvB,uBAAuB;QACvB,IAAM,SAAS,GAAG,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa;YACnD,CAAC,CAAI,SAAS,SAAI,MAA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B,UAAY,EAAZ,KAAA,IAAI,CAAC,OAAO,EAAZ,cAAY,EAAZ,IAAY,EAAE;gBAA/B,IAAA,WAAa,EAAZ,GAAG,QAAA,EAAE,MAAM,QAAA;gBACrB,IAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,GAAG,KAAG,GAAG,KAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,EAAlC,CAAkC,CAAC,CAAC;gBAC/E,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;oBACvB,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;iBACpB;aACF;YAED,uBAAuB;YACvB,KAAkB,UAAQ,EAAR,qBAAQ,EAAR,sBAAQ,EAAR,IAAQ,EAAE;gBAAvB,IAAM,GAAG,iBAAA;gBACZ,IAAI,CAAC,OAAO,CAAC,QAAM,CAAA,CAAC,GAAG,CAAC,CAAC;gBACzB,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,GAAG,EAAE;oBAC1D,MAAM;iBACP;aACF;SACF;IACH,CAAC;IACH,kBAAC;AAAD,CAAC,AAhND,IAgNC;;AAED,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAmC;IACnE,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -9,10 +9,57 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @module @claude-flow/cli/production/retry
|
|
11
11
|
*/
|
|
12
|
+
var __assign = (this && this.__assign) || function () {
|
|
13
|
+
__assign = Object.assign || function(t) {
|
|
14
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
15
|
+
s = arguments[i];
|
|
16
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
17
|
+
t[p] = s[p];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
return __assign.apply(this, arguments);
|
|
22
|
+
};
|
|
23
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
24
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
25
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
26
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
27
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
28
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
29
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
33
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
34
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
35
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
36
|
+
function step(op) {
|
|
37
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
38
|
+
while (_) try {
|
|
39
|
+
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;
|
|
40
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
41
|
+
switch (op[0]) {
|
|
42
|
+
case 0: case 1: t = op; break;
|
|
43
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
44
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
45
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
46
|
+
default:
|
|
47
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
48
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
49
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
50
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
51
|
+
if (t[2]) _.ops.pop();
|
|
52
|
+
_.trys.pop(); continue;
|
|
53
|
+
}
|
|
54
|
+
op = body.call(thisArg, _);
|
|
55
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
56
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
57
|
+
}
|
|
58
|
+
};
|
|
12
59
|
// ============================================================================
|
|
13
60
|
// Default Configuration
|
|
14
61
|
// ============================================================================
|
|
15
|
-
|
|
62
|
+
var DEFAULT_CONFIG = {
|
|
16
63
|
maxAttempts: 3,
|
|
17
64
|
initialDelayMs: 1000,
|
|
18
65
|
maxDelayMs: 30000,
|
|
@@ -23,7 +70,7 @@ const DEFAULT_CONFIG = {
|
|
|
23
70
|
'authentication',
|
|
24
71
|
'authorization',
|
|
25
72
|
'not_found',
|
|
26
|
-
]
|
|
73
|
+
]
|
|
27
74
|
};
|
|
28
75
|
// ============================================================================
|
|
29
76
|
// Retry Implementation
|
|
@@ -31,8 +78,9 @@ const DEFAULT_CONFIG = {
|
|
|
31
78
|
/**
|
|
32
79
|
* Calculate delay for a given attempt
|
|
33
80
|
*/
|
|
34
|
-
function calculateDelay(attempt, config, strategy
|
|
35
|
-
|
|
81
|
+
function calculateDelay(attempt, config, strategy) {
|
|
82
|
+
if (strategy === void 0) { strategy = 'exponential'; }
|
|
83
|
+
var delay;
|
|
36
84
|
switch (strategy) {
|
|
37
85
|
case 'linear':
|
|
38
86
|
delay = config.initialDelayMs * attempt;
|
|
@@ -51,7 +99,7 @@ function calculateDelay(attempt, config, strategy = 'exponential') {
|
|
|
51
99
|
delay = Math.min(delay, config.maxDelayMs);
|
|
52
100
|
// Apply jitter
|
|
53
101
|
if (config.jitter > 0) {
|
|
54
|
-
|
|
102
|
+
var jitterRange = delay * config.jitter;
|
|
55
103
|
delay += (Math.random() - 0.5) * 2 * jitterRange;
|
|
56
104
|
}
|
|
57
105
|
return Math.round(Math.max(0, delay));
|
|
@@ -60,11 +108,12 @@ function calculateDelay(attempt, config, strategy = 'exponential') {
|
|
|
60
108
|
* Fibonacci helper for fibonacci backoff
|
|
61
109
|
*/
|
|
62
110
|
function fibonacci(n) {
|
|
111
|
+
var _a;
|
|
63
112
|
if (n <= 1)
|
|
64
113
|
return 1;
|
|
65
|
-
|
|
66
|
-
for (
|
|
67
|
-
[
|
|
114
|
+
var a = 1, b = 1;
|
|
115
|
+
for (var i = 2; i <= n; i++) {
|
|
116
|
+
_a = [b, a + b], a = _a[0], b = _a[1];
|
|
68
117
|
}
|
|
69
118
|
return b;
|
|
70
119
|
}
|
|
@@ -77,8 +126,9 @@ function shouldRetryError(error, attempt, config) {
|
|
|
77
126
|
return config.shouldRetry(error, attempt);
|
|
78
127
|
}
|
|
79
128
|
// Check non-retryable error patterns
|
|
80
|
-
|
|
81
|
-
for (
|
|
129
|
+
var message = error.message.toLowerCase();
|
|
130
|
+
for (var _i = 0, _a = config.nonRetryableErrors; _i < _a.length; _i++) {
|
|
131
|
+
var pattern = _a[_i];
|
|
82
132
|
if (message.includes(pattern.toLowerCase())) {
|
|
83
133
|
return false;
|
|
84
134
|
}
|
|
@@ -90,87 +140,129 @@ function shouldRetryError(error, attempt, config) {
|
|
|
90
140
|
* Sleep for a given number of milliseconds
|
|
91
141
|
*/
|
|
92
142
|
function sleep(ms) {
|
|
93
|
-
return new Promise(resolve
|
|
143
|
+
return new Promise(function (resolve) { return setTimeout(resolve, ms); });
|
|
94
144
|
}
|
|
95
145
|
/**
|
|
96
146
|
* Execute a function with retry logic
|
|
97
147
|
*/
|
|
98
|
-
export
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
148
|
+
export function withRetry(fn, config, strategy) {
|
|
149
|
+
if (config === void 0) { config = {}; }
|
|
150
|
+
if (strategy === void 0) { strategy = 'exponential'; }
|
|
151
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
152
|
+
var finalConfig, startTime, retryHistory, lastError, attempt, result, error_1, delay;
|
|
153
|
+
return __generator(this, function (_a) {
|
|
154
|
+
switch (_a.label) {
|
|
155
|
+
case 0:
|
|
156
|
+
finalConfig = __assign(__assign({}, DEFAULT_CONFIG), config);
|
|
157
|
+
startTime = Date.now();
|
|
158
|
+
retryHistory = [];
|
|
159
|
+
attempt = 0;
|
|
160
|
+
_a.label = 1;
|
|
161
|
+
case 1:
|
|
162
|
+
if (!(attempt < finalConfig.maxAttempts)) return [3 /*break*/, 8];
|
|
163
|
+
attempt++;
|
|
164
|
+
_a.label = 2;
|
|
165
|
+
case 2:
|
|
166
|
+
_a.trys.push([2, 4, , 7]);
|
|
167
|
+
return [4 /*yield*/, fn()];
|
|
168
|
+
case 3:
|
|
169
|
+
result = _a.sent();
|
|
170
|
+
return [2 /*return*/, {
|
|
171
|
+
success: true,
|
|
172
|
+
result: result,
|
|
173
|
+
attempts: attempt,
|
|
174
|
+
totalTimeMs: Date.now() - startTime,
|
|
175
|
+
retryHistory: retryHistory
|
|
176
|
+
}];
|
|
177
|
+
case 4:
|
|
178
|
+
error_1 = _a.sent();
|
|
179
|
+
lastError = error_1;
|
|
180
|
+
// Check if we should retry
|
|
181
|
+
if (!shouldRetryError(lastError, attempt, finalConfig)) {
|
|
182
|
+
return [2 /*return*/, {
|
|
183
|
+
success: false,
|
|
184
|
+
error: lastError,
|
|
185
|
+
attempts: attempt,
|
|
186
|
+
totalTimeMs: Date.now() - startTime,
|
|
187
|
+
retryHistory: retryHistory
|
|
188
|
+
}];
|
|
189
|
+
}
|
|
190
|
+
delay = calculateDelay(attempt, finalConfig, strategy);
|
|
191
|
+
// Record retry
|
|
192
|
+
retryHistory.push({
|
|
193
|
+
attempt: attempt,
|
|
194
|
+
error: lastError.message,
|
|
195
|
+
delayMs: delay
|
|
196
|
+
});
|
|
197
|
+
// Call retry callback
|
|
198
|
+
if (finalConfig.onRetry) {
|
|
199
|
+
finalConfig.onRetry(lastError, attempt, delay);
|
|
200
|
+
}
|
|
201
|
+
if (!(attempt < finalConfig.maxAttempts)) return [3 /*break*/, 6];
|
|
202
|
+
return [4 /*yield*/, sleep(delay)];
|
|
203
|
+
case 5:
|
|
204
|
+
_a.sent();
|
|
205
|
+
_a.label = 6;
|
|
206
|
+
case 6: return [3 /*break*/, 7];
|
|
207
|
+
case 7: return [3 /*break*/, 1];
|
|
208
|
+
case 8: return [2 /*return*/, {
|
|
209
|
+
success: false,
|
|
210
|
+
error: lastError,
|
|
211
|
+
attempts: attempt,
|
|
212
|
+
totalTimeMs: Date.now() - startTime,
|
|
213
|
+
retryHistory: retryHistory
|
|
214
|
+
}];
|
|
127
215
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
// Record retry
|
|
131
|
-
retryHistory.push({
|
|
132
|
-
attempt,
|
|
133
|
-
error: lastError.message,
|
|
134
|
-
delayMs: delay,
|
|
135
|
-
});
|
|
136
|
-
// Call retry callback
|
|
137
|
-
if (finalConfig.onRetry) {
|
|
138
|
-
finalConfig.onRetry(lastError, attempt, delay);
|
|
139
|
-
}
|
|
140
|
-
// Wait before retrying
|
|
141
|
-
if (attempt < finalConfig.maxAttempts) {
|
|
142
|
-
await sleep(delay);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return {
|
|
147
|
-
success: false,
|
|
148
|
-
error: lastError,
|
|
149
|
-
attempts: attempt,
|
|
150
|
-
totalTimeMs: Date.now() - startTime,
|
|
151
|
-
retryHistory,
|
|
152
|
-
};
|
|
216
|
+
});
|
|
217
|
+
});
|
|
153
218
|
}
|
|
154
219
|
/**
|
|
155
220
|
* Create a retryable version of a function
|
|
156
221
|
*/
|
|
157
|
-
export function makeRetryable(fn, config
|
|
158
|
-
|
|
159
|
-
|
|
222
|
+
export function makeRetryable(fn, config, strategy) {
|
|
223
|
+
var _this = this;
|
|
224
|
+
if (config === void 0) { config = {}; }
|
|
225
|
+
if (strategy === void 0) { strategy = 'exponential'; }
|
|
226
|
+
return function () {
|
|
227
|
+
var args = [];
|
|
228
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
229
|
+
args[_i] = arguments[_i];
|
|
230
|
+
}
|
|
231
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
232
|
+
return __generator(this, function (_a) {
|
|
233
|
+
return [2 /*return*/, withRetry(function () { return fn.apply(void 0, args); }, config, strategy)];
|
|
234
|
+
});
|
|
235
|
+
});
|
|
160
236
|
};
|
|
161
237
|
}
|
|
162
238
|
/**
|
|
163
239
|
* Retry decorator for class methods
|
|
164
240
|
*/
|
|
165
|
-
export function Retryable(config
|
|
241
|
+
export function Retryable(config, strategy) {
|
|
242
|
+
if (config === void 0) { config = {}; }
|
|
243
|
+
if (strategy === void 0) { strategy = 'exponential'; }
|
|
166
244
|
return function (_target, _propertyKey, descriptor) {
|
|
167
|
-
|
|
168
|
-
descriptor.value =
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
245
|
+
var originalMethod = descriptor.value;
|
|
246
|
+
descriptor.value = function () {
|
|
247
|
+
var args = [];
|
|
248
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
249
|
+
args[_i] = arguments[_i];
|
|
172
250
|
}
|
|
173
|
-
|
|
251
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
252
|
+
var result;
|
|
253
|
+
var _this = this;
|
|
254
|
+
return __generator(this, function (_a) {
|
|
255
|
+
switch (_a.label) {
|
|
256
|
+
case 0: return [4 /*yield*/, withRetry(function () { return originalMethod.apply(_this, args); }, config, strategy)];
|
|
257
|
+
case 1:
|
|
258
|
+
result = _a.sent();
|
|
259
|
+
if (result.success) {
|
|
260
|
+
return [2 /*return*/, result.result];
|
|
261
|
+
}
|
|
262
|
+
throw result.error;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
});
|
|
174
266
|
};
|
|
175
267
|
return descriptor;
|
|
176
268
|
};
|