claude-flow-novice 2.15.4 → 2.15.6
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/cfn-extras/.gs-api-quota.json +16 -0
- package/.claude/cfn-extras/.gs-progress-state.json +22 -0
- package/.claude/cfn-extras/GOOGLE_SHEETS_IMPLEMENTATION_SUMMARY.md +414 -0
- package/.claude/cfn-extras/agents/google-sheets/README.md +114 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-advanced-analytics-specialist.md +288 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-api-integrator.md +127 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-automation-scripting-specialist.md +195 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-business-validator.md +179 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-collaboration-security-specialist.md +240 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-coordinator.md +214 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-data-transformer.md +127 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-data-validation-quality-specialist.md +177 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-data-validator.md +119 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-data-visualization-specialist.md +135 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-design-layout-specialist.md +109 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-formula-engineer.md +127 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-formula-engineering-specialist.md +138 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-formula-validator.md +128 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-generalist.md +645 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-integration-api-specialist.md +258 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-performance-analyst.md +125 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-performance-optimization-specialist.md +211 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-schema-designer.md +130 -0
- package/.claude/cfn-extras/agents/google-sheets/google-sheets-template-architecture-specialist.md +259 -0
- package/.claude/cfn-extras/docs/GOOGLE_SHEETS_CFN_LOOP.md +617 -0
- package/.claude/cfn-extras/skills/GOOGLE_SHEETS_SKILLS_README.md +453 -0
- package/.claude/cfn-extras/skills/google-sheets-api-coordinator/SKILL.md +272 -0
- package/.claude/cfn-extras/skills/google-sheets-api-coordinator/api-call.sh +254 -0
- package/.claude/cfn-extras/skills/google-sheets-api-coordinator/test.sh +174 -0
- package/.claude/cfn-extras/skills/google-sheets-api-coordinator/validate.sh +98 -0
- package/.claude/cfn-extras/skills/google-sheets-decomposition/SKILL.md +269 -0
- package/.claude/cfn-extras/skills/google-sheets-decomposition/decompose.sh +313 -0
- package/.claude/cfn-extras/skills/google-sheets-formula-builder/SKILL.md +237 -0
- package/.claude/cfn-extras/skills/google-sheets-formula-builder/build-formula.sh +220 -0
- package/.claude/cfn-extras/skills/google-sheets-formula-builder/test.sh +172 -0
- package/.claude/cfn-extras/skills/google-sheets-formula-builder/validate.sh +98 -0
- package/.claude/cfn-extras/skills/google-sheets-progress/SKILL.md +287 -0
- package/.claude/cfn-extras/skills/google-sheets-progress/test.sh +385 -0
- package/.claude/cfn-extras/skills/google-sheets-progress/track-progress.sh +516 -0
- package/.claude/cfn-extras/skills/google-sheets-progress/validate.sh +119 -0
- package/.claude/cfn-extras/skills/google-sheets-sprint-order/SKILL.md +277 -0
- package/.claude/cfn-extras/skills/google-sheets-sprint-order/order-sprints.sh +233 -0
- package/.claude/cfn-extras/skills/google-sheets-validation/SKILL.md +352 -0
- package/.claude/cfn-extras/skills/google-sheets-validation/test.sh +355 -0
- package/.claude/cfn-extras/skills/google-sheets-validation/validate-state.sh +374 -0
- package/.claude/cfn-extras/skills/google-sheets-validation/validate.sh +128 -0
- package/.claude/commands/cfn-context.md +10 -0
- package/.claude/commands/cfn-loop-cli.md +44 -14
- package/.claude/commands/google-sheets/google-sheets-loop.md +289 -0
- package/.claude/skills/cfn-agent-selector/SKILL.md +143 -0
- package/.claude/skills/cfn-agent-selector/select-agents.sh +94 -0
- package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -2
- package/.claude/skills/cfn-docker-agent-spawning/spawn-agent.sh +21 -2
- package/.claude/skills/cfn-docker-loop-orchestration/orchestrate.sh +11 -5
- package/.claude/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +348 -0
- package/.claude/skills/cfn-docker-redis-coordination/README.md +294 -0
- package/.claude/skills/cfn-docker-redis-coordination/jest.config.js +37 -0
- package/.claude/skills/cfn-docker-redis-coordination/package-lock.json +5259 -0
- package/.claude/skills/cfn-docker-redis-coordination/package.json +40 -0
- package/.claude/skills/cfn-docker-redis-coordination/src/coordinator.ts +801 -0
- package/.claude/skills/cfn-docker-redis-coordination/src/index.ts +42 -0
- package/.claude/skills/cfn-docker-redis-coordination/src/types.ts +351 -0
- package/.claude/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +1464 -0
- package/.claude/skills/cfn-docker-redis-coordination/tsconfig.json +30 -0
- package/.claude/skills/cfn-loop-orchestration/.eslintrc.js +56 -0
- package/.claude/skills/cfn-loop-orchestration/.prettierrc.json +18 -0
- package/.claude/skills/cfn-loop-orchestration/README.md +149 -41
- package/.claude/skills/cfn-loop-orchestration/jest.config.js +67 -0
- package/.claude/skills/cfn-loop-orchestration/orchestrate-wrapper.sh +268 -0
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +147 -16
- package/.claude/skills/cfn-loop-orchestration/package-lock.json +5470 -0
- package/.claude/skills/cfn-loop-orchestration/package.json +49 -0
- package/.claude/skills/cfn-loop-orchestration/src/agent-spawner/agent-spawner.ts +34 -0
- package/.claude/skills/cfn-loop-orchestration/src/gate-checker/gate-checker.ts +36 -0
- package/.claude/skills/cfn-loop-orchestration/src/index.ts +14 -0
- package/.claude/skills/cfn-loop-orchestration/src/orchestrator/orchestrator.ts +31 -0
- package/.claude/skills/cfn-loop-orchestration/src/redis/redis-coordinator.ts +72 -0
- package/.claude/skills/cfn-loop-orchestration/src/types.ts +188 -0
- package/.claude/skills/cfn-loop-orchestration/src/utils/logger.ts +32 -0
- package/.claude/skills/cfn-loop-orchestration/tests/setup.ts +22 -0
- package/.claude/skills/cfn-loop-orchestration/tests/types.test.ts +132 -0
- package/.claude/skills/cfn-loop-orchestration/tsconfig.json +54 -0
- package/.claude/skills/cfn-redis-coordination/bash-wrappers/store-context.sh +23 -0
- package/.claude/skills/cfn-redis-coordination/dist/agent-logger.d.ts +92 -0
- package/.claude/skills/cfn-redis-coordination/dist/agent-logger.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/agent-logger.js +329 -0
- package/.claude/skills/cfn-redis-coordination/dist/agent-logger.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/agent-recovery.d.ts +75 -0
- package/.claude/skills/cfn-redis-coordination/dist/agent-recovery.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/agent-recovery.js +302 -0
- package/.claude/skills/cfn-redis-coordination/dist/agent-recovery.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/completion-reporter.d.ts +58 -0
- package/.claude/skills/cfn-redis-coordination/dist/completion-reporter.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/completion-reporter.js +237 -0
- package/.claude/skills/cfn-redis-coordination/dist/completion-reporter.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/context-manager.d.ts +63 -0
- package/.claude/skills/cfn-redis-coordination/dist/context-manager.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/context-manager.js +230 -0
- package/.claude/skills/cfn-redis-coordination/dist/context-manager.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/index.d.ts +45 -0
- package/.claude/skills/cfn-redis-coordination/dist/index.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/index.js +114 -0
- package/.claude/skills/cfn-redis-coordination/dist/index.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/mode-detector.d.ts +31 -0
- package/.claude/skills/cfn-redis-coordination/dist/mode-detector.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/mode-detector.js +185 -0
- package/.claude/skills/cfn-redis-coordination/dist/mode-detector.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/redis-client.d.ts +191 -0
- package/.claude/skills/cfn-redis-coordination/dist/redis-client.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/redis-client.js +509 -0
- package/.claude/skills/cfn-redis-coordination/dist/redis-client.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/result-collector.d.ts +75 -0
- package/.claude/skills/cfn-redis-coordination/dist/result-collector.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/result-collector.js +281 -0
- package/.claude/skills/cfn-redis-coordination/dist/result-collector.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/swarm-manager.d.ts +75 -0
- package/.claude/skills/cfn-redis-coordination/dist/swarm-manager.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/swarm-manager.js +354 -0
- package/.claude/skills/cfn-redis-coordination/dist/swarm-manager.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/task-analyzer.d.ts +62 -0
- package/.claude/skills/cfn-redis-coordination/dist/task-analyzer.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/task-analyzer.js +305 -0
- package/.claude/skills/cfn-redis-coordination/dist/task-analyzer.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/task-executor.d.ts +97 -0
- package/.claude/skills/cfn-redis-coordination/dist/task-executor.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/task-executor.js +283 -0
- package/.claude/skills/cfn-redis-coordination/dist/task-executor.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/types.d.ts +176 -0
- package/.claude/skills/cfn-redis-coordination/dist/types.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/types.js +81 -0
- package/.claude/skills/cfn-redis-coordination/dist/types.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/waiting-coordinator.d.ts +86 -0
- package/.claude/skills/cfn-redis-coordination/dist/waiting-coordinator.d.ts.map +1 -0
- package/.claude/skills/cfn-redis-coordination/dist/waiting-coordinator.js +419 -0
- package/.claude/skills/cfn-redis-coordination/dist/waiting-coordinator.js.map +1 -0
- package/.claude/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +553 -0
- package/.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh +3 -2
- package/.claude/skills/cfn-redis-coordination/jest.config.js +23 -0
- package/.claude/skills/cfn-redis-coordination/package-lock.json +5272 -0
- package/.claude/skills/cfn-redis-coordination/package.json +45 -0
- package/.claude/skills/cfn-redis-coordination/redis-cli-wrapper.sh +21 -8
- package/.claude/skills/cfn-redis-coordination/redis-functions.sh +3 -2
- package/.claude/skills/cfn-redis-coordination/src/agent-logger.ts +446 -0
- package/.claude/skills/cfn-redis-coordination/src/agent-recovery.ts +454 -0
- package/.claude/skills/cfn-redis-coordination/src/completion-reporter.ts +396 -0
- package/.claude/skills/cfn-redis-coordination/src/context-manager.ts +327 -0
- package/.claude/skills/cfn-redis-coordination/src/index.ts +82 -0
- package/.claude/skills/cfn-redis-coordination/src/mode-detector.ts +155 -0
- package/.claude/skills/cfn-redis-coordination/src/redis/redis-client.ts +305 -0
- package/.claude/skills/cfn-redis-coordination/src/redis/redis-functions.ts +283 -0
- package/.claude/skills/cfn-redis-coordination/src/redis-client.ts +654 -0
- package/.claude/skills/cfn-redis-coordination/src/result-collector.ts +437 -0
- package/.claude/skills/cfn-redis-coordination/src/swarm-manager.ts +494 -0
- package/.claude/skills/cfn-redis-coordination/src/task-analyzer.ts +404 -0
- package/.claude/skills/cfn-redis-coordination/src/task-executor.ts +423 -0
- package/.claude/skills/cfn-redis-coordination/src/types.ts +235 -0
- package/.claude/skills/cfn-redis-coordination/src/waiting-coordinator.ts +587 -0
- package/.claude/skills/cfn-redis-coordination/test-connection-attempts.js +70 -0
- package/.claude/skills/cfn-redis-coordination/test-mode-simple.js +121 -0
- package/.claude/skills/cfn-redis-coordination/test-redis-check.js +84 -0
- package/.claude/skills/cfn-redis-coordination/test-task-mode-redis.cjs +391 -0
- package/.claude/skills/cfn-redis-coordination/tests/coordination.test.ts +779 -0
- package/.claude/skills/cfn-redis-coordination/tsconfig.json +31 -0
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +172 -2
- package/claude-assets/agents/cfn-dev-team/testers/api-testing-specialist.md +1 -1
- package/claude-assets/agents/custom/cfn-redis-operations.md +530 -0
- package/claude-assets/agents/custom/cfn-system-expert.md +77 -0
- package/claude-assets/cfn-extras/.gs-api-quota.json +16 -0
- package/claude-assets/cfn-extras/.gs-progress-state.json +22 -0
- package/claude-assets/cfn-extras/GOOGLE_SHEETS_IMPLEMENTATION_SUMMARY.md +414 -0
- package/claude-assets/cfn-extras/agents/google-sheets/README.md +114 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-advanced-analytics-specialist.md +288 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-api-integrator.md +127 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-automation-scripting-specialist.md +195 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-business-validator.md +179 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-collaboration-security-specialist.md +240 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-coordinator.md +214 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-data-transformer.md +127 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-data-validation-quality-specialist.md +177 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-data-validator.md +119 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-data-visualization-specialist.md +135 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-design-layout-specialist.md +109 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-formula-engineer.md +127 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-formula-engineering-specialist.md +138 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-formula-validator.md +128 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-generalist.md +645 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-integration-api-specialist.md +258 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-performance-analyst.md +125 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-performance-optimization-specialist.md +211 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-schema-designer.md +130 -0
- package/claude-assets/cfn-extras/agents/google-sheets/google-sheets-template-architecture-specialist.md +259 -0
- package/claude-assets/cfn-extras/docs/GOOGLE_SHEETS_CFN_LOOP.md +617 -0
- package/claude-assets/cfn-extras/skills/GOOGLE_SHEETS_SKILLS_README.md +453 -0
- package/claude-assets/cfn-extras/skills/google-sheets-api-coordinator/SKILL.md +272 -0
- package/claude-assets/cfn-extras/skills/google-sheets-api-coordinator/api-call.sh +254 -0
- package/claude-assets/cfn-extras/skills/google-sheets-api-coordinator/test.sh +174 -0
- package/claude-assets/cfn-extras/skills/google-sheets-api-coordinator/validate.sh +98 -0
- package/claude-assets/cfn-extras/skills/google-sheets-decomposition/SKILL.md +269 -0
- package/claude-assets/cfn-extras/skills/google-sheets-decomposition/decompose.sh +313 -0
- package/claude-assets/cfn-extras/skills/google-sheets-formula-builder/SKILL.md +237 -0
- package/claude-assets/cfn-extras/skills/google-sheets-formula-builder/build-formula.sh +220 -0
- package/claude-assets/cfn-extras/skills/google-sheets-formula-builder/test.sh +172 -0
- package/claude-assets/cfn-extras/skills/google-sheets-formula-builder/validate.sh +98 -0
- package/claude-assets/cfn-extras/skills/google-sheets-progress/SKILL.md +287 -0
- package/claude-assets/cfn-extras/skills/google-sheets-progress/test.sh +385 -0
- package/claude-assets/cfn-extras/skills/google-sheets-progress/track-progress.sh +516 -0
- package/claude-assets/cfn-extras/skills/google-sheets-progress/validate.sh +119 -0
- package/claude-assets/cfn-extras/skills/google-sheets-sprint-order/SKILL.md +277 -0
- package/claude-assets/cfn-extras/skills/google-sheets-sprint-order/order-sprints.sh +233 -0
- package/claude-assets/cfn-extras/skills/google-sheets-validation/SKILL.md +352 -0
- package/claude-assets/cfn-extras/skills/google-sheets-validation/test.sh +355 -0
- package/claude-assets/cfn-extras/skills/google-sheets-validation/validate-state.sh +374 -0
- package/claude-assets/cfn-extras/skills/google-sheets-validation/validate.sh +128 -0
- package/claude-assets/commands/cfn-context.md +10 -0
- package/claude-assets/commands/cfn-loop-cli.md +44 -14
- package/claude-assets/commands/google-sheets/google-sheets-loop.md +289 -0
- package/claude-assets/hooks/cfn-pre-execution/SESSION_START_README.md +87 -0
- package/claude-assets/hooks/cfn-pre-execution/TEST_SESSION_START.md +128 -0
- package/claude-assets/hooks/cfn-pre-execution/session-start-context.sh +111 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/INTEGRATION_EXAMPLE.md +209 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/README.md +130 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md +243 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/agent-mappings.json +142 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh +173 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh +71 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/test-agent-selection.sh +282 -0
- package/claude-assets/skills/cfn-agent-selector/SKILL.md +143 -0
- package/claude-assets/skills/cfn-agent-selector/select-agents.sh +94 -0
- package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -2
- package/claude-assets/skills/cfn-docker-agent-spawning/spawn-agent.sh +21 -2
- package/claude-assets/skills/cfn-docker-coordination/.eslintrc.json +33 -0
- package/claude-assets/skills/cfn-docker-coordination/README.md +349 -0
- package/claude-assets/skills/cfn-docker-coordination/docker-helpers.sh +433 -0
- package/claude-assets/skills/cfn-docker-coordination/jest.config.js +25 -0
- package/claude-assets/skills/cfn-docker-coordination/package-lock.json +6827 -0
- package/claude-assets/skills/cfn-docker-coordination/package.json +38 -0
- package/claude-assets/skills/cfn-docker-coordination/src/agent-container.ts +471 -0
- package/claude-assets/skills/cfn-docker-coordination/src/docker-client.ts +483 -0
- package/claude-assets/skills/cfn-docker-coordination/src/health-checker.ts +418 -0
- package/claude-assets/skills/cfn-docker-coordination/src/index.ts +45 -0
- package/claude-assets/skills/cfn-docker-coordination/src/network-manager.ts +377 -0
- package/claude-assets/skills/cfn-docker-coordination/src/types.ts +412 -0
- package/claude-assets/skills/cfn-docker-coordination/src/volume-manager.ts +389 -0
- package/claude-assets/skills/cfn-docker-coordination/tests/agent-container.test.ts +379 -0
- package/claude-assets/skills/cfn-docker-coordination/tests/docker-client.test.ts +345 -0
- package/claude-assets/skills/cfn-docker-coordination/tests/health-checker.test.ts +535 -0
- package/claude-assets/skills/cfn-docker-coordination/tests/integration.test.ts +193 -0
- package/claude-assets/skills/cfn-docker-coordination/tests/network-manager.test.ts +352 -0
- package/claude-assets/skills/cfn-docker-coordination/tests/setup.ts +36 -0
- package/claude-assets/skills/cfn-docker-coordination/tsconfig.json +29 -0
- package/claude-assets/skills/cfn-docker-logging/INTEGRATION.md +268 -0
- package/claude-assets/skills/cfn-docker-logging/SAMPLE_OUTPUTS.md +237 -0
- package/claude-assets/skills/cfn-docker-logging/SKILL.md +442 -0
- package/claude-assets/skills/cfn-docker-logging/capture-container-logs.sh +120 -0
- package/claude-assets/skills/cfn-docker-logging/enable-logging.sh +430 -0
- package/claude-assets/skills/cfn-docker-logging/init-hybrid-logging.sh +210 -0
- package/claude-assets/skills/cfn-docker-logging/queries/analytics-summary.sh +87 -0
- package/claude-assets/skills/cfn-docker-logging/queries/query-agent-timeline.sh +51 -0
- package/claude-assets/skills/cfn-docker-logging/queries/query-consensus-history.sh +56 -0
- package/claude-assets/skills/cfn-docker-logging/queries/query-coordination-timeline.sh +39 -0
- package/claude-assets/skills/cfn-docker-logging/queries/query-failed-containers.sh +40 -0
- package/claude-assets/skills/cfn-docker-logging/queries/query-gate-checks.sh +39 -0
- package/claude-assets/skills/cfn-docker-logging/schema.sql +111 -0
- package/claude-assets/skills/cfn-docker-logging/sqlite-helpers.sh +240 -0
- package/claude-assets/skills/cfn-docker-logging/test-hybrid-logging.sh +331 -0
- package/claude-assets/skills/cfn-docker-loop-orchestration/orchestrate.sh +11 -5
- package/claude-assets/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +348 -0
- package/claude-assets/skills/cfn-docker-redis-coordination/README.md +294 -0
- package/claude-assets/skills/cfn-docker-redis-coordination/jest.config.js +37 -0
- package/claude-assets/skills/cfn-docker-redis-coordination/package-lock.json +5259 -0
- package/claude-assets/skills/cfn-docker-redis-coordination/package.json +40 -0
- package/claude-assets/skills/cfn-docker-redis-coordination/src/coordinator.ts +801 -0
- package/claude-assets/skills/cfn-docker-redis-coordination/src/index.ts +42 -0
- package/claude-assets/skills/cfn-docker-redis-coordination/src/types.ts +351 -0
- package/claude-assets/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +1464 -0
- package/claude-assets/skills/cfn-docker-redis-coordination/tsconfig.json +30 -0
- package/claude-assets/skills/cfn-error-logging/.eslintrc.json +57 -0
- package/claude-assets/skills/cfn-error-logging/.prettierrc.json +10 -0
- package/claude-assets/skills/cfn-error-logging/MIGRATION_SUMMARY.md +485 -0
- package/claude-assets/skills/cfn-error-logging/package.json +47 -0
- package/claude-assets/skills/cfn-error-logging/src/error-logger.ts +1042 -0
- package/claude-assets/skills/cfn-error-logging/src/index.ts +12 -0
- package/claude-assets/skills/cfn-error-logging/src/types.ts +456 -0
- package/claude-assets/skills/cfn-error-logging/tests/error-logger.test.ts +1302 -0
- package/claude-assets/skills/cfn-error-logging/tsconfig.json +38 -0
- package/claude-assets/skills/cfn-loop-orchestration/.eslintrc.js +56 -0
- package/claude-assets/skills/cfn-loop-orchestration/.prettierrc.json +18 -0
- package/claude-assets/skills/cfn-loop-orchestration/README.md +149 -41
- package/claude-assets/skills/cfn-loop-orchestration/jest.config.js +67 -0
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate-wrapper.sh +268 -0
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +147 -16
- package/claude-assets/skills/cfn-loop-orchestration/package-lock.json +5470 -0
- package/claude-assets/skills/cfn-loop-orchestration/package.json +49 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/agent-spawner/agent-spawner.ts +34 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/gate-checker/gate-checker.ts +36 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/index.ts +14 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/orchestrator/orchestrator.ts +31 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/redis/redis-coordinator.ts +72 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/types.ts +188 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/utils/logger.ts +32 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/setup.ts +22 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/types.test.ts +132 -0
- package/claude-assets/skills/cfn-loop-orchestration/tsconfig.json +54 -0
- package/claude-assets/skills/cfn-redis-coordination/bash-wrappers/store-context.sh +23 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/agent-logger.d.ts +92 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/agent-logger.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/agent-logger.js +329 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/agent-logger.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/agent-recovery.d.ts +75 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/agent-recovery.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/agent-recovery.js +302 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/agent-recovery.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/completion-reporter.d.ts +58 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/completion-reporter.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/completion-reporter.js +237 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/completion-reporter.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/context-manager.d.ts +63 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/context-manager.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/context-manager.js +230 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/context-manager.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/index.d.ts +45 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/index.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/index.js +114 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/index.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/mode-detector.d.ts +31 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/mode-detector.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/mode-detector.js +185 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/mode-detector.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/redis-client.d.ts +191 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/redis-client.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/redis-client.js +509 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/redis-client.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/result-collector.d.ts +75 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/result-collector.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/result-collector.js +281 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/result-collector.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/swarm-manager.d.ts +75 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/swarm-manager.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/swarm-manager.js +354 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/swarm-manager.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/task-analyzer.d.ts +62 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/task-analyzer.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/task-analyzer.js +305 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/task-analyzer.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/task-executor.d.ts +97 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/task-executor.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/task-executor.js +283 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/task-executor.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/types.d.ts +176 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/types.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/types.js +81 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/types.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/waiting-coordinator.d.ts +86 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/waiting-coordinator.d.ts.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/waiting-coordinator.js +419 -0
- package/claude-assets/skills/cfn-redis-coordination/dist/waiting-coordinator.js.map +1 -0
- package/claude-assets/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +553 -0
- package/claude-assets/skills/cfn-redis-coordination/invoke-waiting-mode.sh +3 -2
- package/claude-assets/skills/cfn-redis-coordination/jest.config.js +23 -0
- package/claude-assets/skills/cfn-redis-coordination/package-lock.json +5272 -0
- package/claude-assets/skills/cfn-redis-coordination/package.json +45 -0
- package/claude-assets/skills/cfn-redis-coordination/redis-cli-wrapper.sh +21 -8
- package/claude-assets/skills/cfn-redis-coordination/redis-functions.sh +3 -2
- package/claude-assets/skills/cfn-redis-coordination/src/agent-logger.ts +446 -0
- package/claude-assets/skills/cfn-redis-coordination/src/agent-recovery.ts +454 -0
- package/claude-assets/skills/cfn-redis-coordination/src/completion-reporter.ts +396 -0
- package/claude-assets/skills/cfn-redis-coordination/src/context-manager.ts +327 -0
- package/claude-assets/skills/cfn-redis-coordination/src/index.ts +82 -0
- package/claude-assets/skills/cfn-redis-coordination/src/mode-detector.ts +155 -0
- package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-client.ts +305 -0
- package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-functions.ts +283 -0
- package/claude-assets/skills/cfn-redis-coordination/src/redis-client.ts +654 -0
- package/claude-assets/skills/cfn-redis-coordination/src/result-collector.ts +437 -0
- package/claude-assets/skills/cfn-redis-coordination/src/swarm-manager.ts +494 -0
- package/claude-assets/skills/cfn-redis-coordination/src/task-analyzer.ts +404 -0
- package/claude-assets/skills/cfn-redis-coordination/src/task-executor.ts +423 -0
- package/claude-assets/skills/cfn-redis-coordination/src/types.ts +235 -0
- package/claude-assets/skills/cfn-redis-coordination/src/waiting-coordinator.ts +587 -0
- package/claude-assets/skills/cfn-redis-coordination/test-connection-attempts.js +70 -0
- package/claude-assets/skills/cfn-redis-coordination/test-mode-simple.js +121 -0
- package/claude-assets/skills/cfn-redis-coordination/test-redis-check.js +84 -0
- package/claude-assets/skills/cfn-redis-coordination/test-task-mode-redis.cjs +391 -0
- package/claude-assets/skills/cfn-redis-coordination/tests/coordination.test.ts +779 -0
- package/claude-assets/skills/cfn-redis-coordination/tsconfig.json +31 -0
- package/claude-assets/skills/cfn-skill-propagation/README.md +233 -0
- package/claude-assets/skills/cfn-skill-propagation/package-lock.json +5174 -0
- package/claude-assets/skills/cfn-skill-propagation/package.json +52 -0
- package/claude-assets/skills/cfn-skill-propagation/propagate-skill-update.sh +32 -0
- package/claude-assets/skills/cfn-skill-propagation/src/cli.ts +75 -0
- package/claude-assets/skills/cfn-skill-propagation/src/database-adapter.ts +239 -0
- package/claude-assets/skills/cfn-skill-propagation/src/file-system-adapter.ts +113 -0
- package/claude-assets/skills/cfn-skill-propagation/src/index.ts +72 -0
- package/claude-assets/skills/cfn-skill-propagation/src/logger.ts +43 -0
- package/claude-assets/skills/cfn-skill-propagation/src/metadata-parser.ts +154 -0
- package/claude-assets/skills/cfn-skill-propagation/src/skill-propagator.ts +274 -0
- package/claude-assets/skills/cfn-skill-propagation/src/skill-validator.ts +179 -0
- package/claude-assets/skills/cfn-skill-propagation/src/types.ts +143 -0
- package/claude-assets/skills/cfn-skill-propagation/src/version-manager.ts +118 -0
- package/claude-assets/skills/cfn-skill-propagation/tests/file-system-adapter.test.ts +91 -0
- package/claude-assets/skills/cfn-skill-propagation/tests/metadata-parser.test.ts +176 -0
- package/claude-assets/skills/cfn-skill-propagation/tests/skill-propagator.test.ts +209 -0
- package/claude-assets/skills/cfn-skill-propagation/tests/skill-validator.test.ts +203 -0
- package/claude-assets/skills/cfn-skill-propagation/tests/version-manager.test.ts +115 -0
- package/claude-assets/skills/cfn-skill-propagation/tsconfig.json +34 -0
- package/claude-assets/skills/task-classifier/SKILL.md +81 -0
- package/claude-assets/skills/task-classifier/classify-task.sh +62 -0
- package/claude-assets/skills/workflow-codification/package-lock.json +5170 -0
- package/claude-assets/skills/workflow-codification/package.json +30 -0
- package/claude-assets/skills/workflow-codification/src/index.ts +24 -0
- package/claude-assets/skills/workflow-codification/src/pattern-analyzer.ts +537 -0
- package/claude-assets/skills/workflow-codification/src/types.ts +180 -0
- package/claude-assets/skills/workflow-codification/tests/pattern-analyzer.test.ts +960 -0
- package/claude-assets/skills/workflow-codification/tsconfig.json +34 -0
- package/claude-assets/skills/workflow-codification/workflow-codification.db +0 -0
- package/dist/agent-spawner/agent-spawner.js +448 -0
- package/dist/agent-spawner/agent-spawner.js.map +1 -0
- package/dist/agent-spawner/index.js +10 -0
- package/dist/agent-spawner/index.js.map +1 -0
- package/dist/agent-spawner/types.js +14 -0
- package/dist/agent-spawner/types.js.map +1 -0
- package/dist/cli/agent-executor.js +47 -1
- package/dist/cli/agent-executor.js.map +1 -1
- package/dist/cli/agent-spawn.js +4 -1
- package/dist/cli/agent-spawn.js.map +1 -1
- package/dist/cli/config-manager.js +109 -91
- package/dist/cli/config-manager.js.map +1 -1
- package/dist/cli/conversation-fork-cleanup.js +201 -0
- package/dist/cli/conversation-fork-cleanup.js.map +1 -0
- package/dist/cli/conversation-fork.js +16 -3
- package/dist/cli/conversation-fork.js.map +1 -1
- package/dist/cli/tool-executor.js +3 -1
- package/dist/cli/tool-executor.js.map +1 -1
- package/dist/gate-checker/gate-checker.js +292 -0
- package/dist/gate-checker/gate-checker.js.map +1 -0
- package/dist/gate-checker/types.js +94 -0
- package/dist/gate-checker/types.js.map +1 -0
- package/dist/lib/database-service/connection-pool-manager.js +2 -1
- package/dist/lib/database-service/connection-pool-manager.js.map +1 -1
- package/dist/orchestrator/index.js +10 -0
- package/dist/orchestrator/index.js.map +1 -0
- package/dist/orchestrator/orchestrate.js +496 -0
- package/dist/orchestrator/orchestrate.js.map +1 -0
- package/dist/orchestrator/types.js +58 -0
- package/dist/orchestrator/types.js.map +1 -0
- package/docs/BUG_19_MEMORY_LEAK_TASK_MODE.md +405 -0
- package/docs/MEMORY_CLEANUP_GUIDE.md +358 -0
- package/docs/MEMORY_LEAK_FIX_SUMMARY.md +322 -0
- package/docs/REDIS_CLEANUP_EXECUTIVE_SUMMARY.md +319 -0
- package/docs/REDIS_CLEANUP_VERIFICATION_REPORT.md +574 -0
- package/package.json +208 -201
- package/readme/README.md +34 -1
- package/scripts/switch-api.sh +142 -4
- package/scripts/verify-no-secrets.sh +6 -13
- package/scripts/verify-redis-cleanup.sh +173 -0
- package/tests/README.md +201 -0
- package/tests/test-memory-leak-task-mode.sh +435 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/database-service/connection-pool-manager.ts"],"sourcesContent":["/**\r\n * Connection Pool Manager\r\n *\r\n * Manages connection pools for database adapters with:\r\n * - Automatic initialization on service startup\r\n * - Connection health checks (ping every 30s)\r\n * - Automatic reconnection with exponential backoff\r\n * - Connection metrics (active, idle, pending)\r\n * - Graceful degradation on connection failures\r\n *\r\n * Part of Bug Fix: Connection Pool Initialization\r\n */\r\n\r\nimport sqlite3 from 'sqlite3';\r\nimport { open, Database } from 'sqlite';\r\nimport { createClient, RedisClientType } from 'redis';\r\nimport { Pool, PoolClient } from 'pg';\r\nimport {\r\n DatabaseConfig,\r\n DatabaseErrorCode,\r\n} from './types.js';\r\nimport { createDatabaseError } from './errors.js';\r\n\r\nexport interface ConnectionPoolStats {\r\n type: 'redis' | 'sqlite' | 'postgres';\r\n total: number;\r\n active: number;\r\n idle: number;\r\n pending: number;\r\n maxConnections: number;\r\n available: number;\r\n healthy: boolean;\r\n lastHealthCheck?: Date;\r\n healthCheckActive: boolean;\r\n reconnectAttempts: number;\r\n failedAttempts: number;\r\n uptime: number;\r\n}\r\n\r\nexport interface PoolOptions {\r\n minConnections?: number;\r\n maxConnections?: number;\r\n acquireTimeout?: number;\r\n idleTimeout?: number;\r\n healthCheckInterval?: number;\r\n maxReconnectAttempts?: number;\r\n reconnectBaseDelay?: number;\r\n}\r\n\r\n/**\r\n * Connection Pool Manager\r\n *\r\n * Manages connection lifecycle, health checks, and automatic recovery\r\n */\r\nexport class ConnectionPoolManager {\r\n private config: DatabaseConfig;\r\n private options: Required<PoolOptions>;\r\n private pool: any = null;\r\n private connections: Set<any> = new Set();\r\n private activeConnections: Set<any> = new Set();\r\n private pendingRequests: Array<{\r\n resolve: (connection: any) => void;\r\n reject: (error: Error) => void;\r\n timestamp: number;\r\n }> = [];\r\n private healthCheckInterval?: NodeJS.Timeout;\r\n private lastHealthCheck?: Date;\r\n private healthCheckActive: boolean = false;\r\n private reconnectAttempts: number = 0;\r\n private maxReconnectAttempts: number = 10;\r\n private failedAttempts: number = 0;\r\n private startTime: Date;\r\n private isShuttingDown: boolean = false;\r\n private cacheFallbackEnabled: boolean = false;\r\n private cache: Map<string, any> = new Map();\r\n\r\n constructor(config: DatabaseConfig, options: PoolOptions = {}) {\r\n this.config = config;\r\n this.options = {\r\n minConnections: options.minConnections ?? 2,\r\n maxConnections: options.maxConnections ?? config.poolSize ?? 10,\r\n acquireTimeout: options.acquireTimeout ?? config.timeout ?? 5000,\r\n idleTimeout: options.idleTimeout ?? 30000,\r\n healthCheckInterval: options.healthCheckInterval ?? 30000,\r\n maxReconnectAttempts: options.maxReconnectAttempts ?? 10,\r\n reconnectBaseDelay: options.reconnectBaseDelay ?? 1000,\r\n };\r\n this.maxReconnectAttempts = this.options.maxReconnectAttempts;\r\n this.startTime = new Date();\r\n }\r\n\r\n /**\r\n * Initialize connection pool\r\n */\r\n async initialize(): Promise<void> {\r\n try {\r\n switch (this.config.type) {\r\n case 'sqlite':\r\n await this.initializeSQLitePool();\r\n break;\r\n case 'redis':\r\n await this.initializeRedisPool();\r\n break;\r\n case 'postgres':\r\n await this.initializePostgresPool();\r\n break;\r\n default:\r\n throw new Error(`Unsupported database type: ${this.config.type}`);\r\n }\r\n\r\n // Initialize minimum connections\r\n await this.warmUpPool();\r\n } catch (err) {\r\n this.failedAttempts++;\r\n throw createDatabaseError(\r\n DatabaseErrorCode.CONNECTION_FAILED,\r\n `Failed to initialize ${this.config.type} connection pool`,\r\n err instanceof Error ? err : new Error(String(err)),\r\n { config: this.config }\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Initialize SQLite connection pool\r\n */\r\n private async initializeSQLitePool(): Promise<void> {\r\n const dbPath = this.config.database || this.config.connectionString || ':memory:';\r\n\r\n if (!dbPath || dbPath === '') {\r\n throw new Error('SQLite database path is required');\r\n }\r\n\r\n // Create connection pool for SQLite\r\n for (let i = 0; i < this.options.minConnections; i++) {\r\n const db = await open({\r\n filename: dbPath,\r\n driver: sqlite3.Database,\r\n });\r\n\r\n await db.run('PRAGMA foreign_keys = ON');\r\n await db.run(`PRAGMA busy_timeout = ${this.config.timeout || 5000}`);\r\n\r\n this.connections.add(db);\r\n }\r\n }\r\n\r\n /**\r\n * Initialize Redis connection pool\r\n */\r\n private async initializeRedisPool(): Promise<void> {\r\n let url = this.config.connectionString;\r\n\r\n if (!url) {\r\n // Build connection string with optional authentication\r\n const host = this.config.host || 'localhost';\r\n const port = this.config.port || 6379;\r\n\r\n if (this.config.password) {\r\n // Include password in connection string: redis://:password@host:port\r\n url = `redis://:${encodeURIComponent(this.config.password)}@${host}:${port}`;\r\n } else {\r\n url = `redis://${host}:${port}`;\r\n }\r\n }\r\n\r\n this.pool = createClient({\r\n url,\r\n socket: {\r\n connectTimeout: this.config.timeout || 5000,\r\n reconnectStrategy: (retries) => {\r\n if (retries > this.maxReconnectAttempts) {\r\n return false;\r\n }\r\n // Exponential backoff\r\n return Math.min(this.options.reconnectBaseDelay * Math.pow(2, retries), 30000);\r\n },\r\n },\r\n });\r\n\r\n // Set up event handlers\r\n this.pool.on('error', (err: Error) => {\r\n console.error('Redis connection error:', err);\r\n this.failedAttempts++;\r\n });\r\n\r\n this.pool.on('reconnecting', () => {\r\n this.reconnectAttempts++;\r\n });\r\n\r\n await this.pool.connect();\r\n }\r\n\r\n /**\r\n * Initialize PostgreSQL connection pool\r\n */\r\n private async initializePostgresPool(): Promise<void> {\r\n const connectionString = this.config.connectionString ||\r\n `postgresql://${this.config.username}:${this.config.password}@${this.config.host}:${this.config.port}/${this.config.database}`;\r\n\r\n this.pool = new Pool({\r\n connectionString,\r\n min: this.options.minConnections,\r\n max: this.options.maxConnections,\r\n idleTimeoutMillis: this.options.idleTimeout,\r\n connectionTimeoutMillis: this.options.acquireTimeout,\r\n });\r\n\r\n // Test connection\r\n const client = await this.pool.connect();\r\n await client.query('SELECT 1');\r\n client.release();\r\n }\r\n\r\n /**\r\n * Warm up pool by creating minimum connections\r\n */\r\n private async warmUpPool(): Promise<void> {\r\n if (this.config.type === 'sqlite') {\r\n // SQLite connections already created in initializeSQLitePool\r\n return;\r\n }\r\n\r\n // For Redis and Postgres, connections are managed by their libraries\r\n // We just need to verify connectivity\r\n if (this.config.type === 'redis') {\r\n await this.pool.ping();\r\n } else if (this.config.type === 'postgres') {\r\n const client = await this.pool.connect();\r\n await client.query('SELECT 1');\r\n client.release();\r\n }\r\n }\r\n\r\n /**\r\n * Acquire connection from pool\r\n */\r\n async acquire(): Promise<any> {\r\n if (this.isShuttingDown) {\r\n throw createDatabaseError(\r\n DatabaseErrorCode.CONNECTION_FAILED,\r\n 'Connection pool is shutting down',\r\n undefined,\r\n { type: this.config.type }\r\n );\r\n }\r\n\r\n const startTime = Date.now();\r\n\r\n try {\r\n switch (this.config.type) {\r\n case 'sqlite':\r\n return await this.acquireSQLiteConnection(startTime);\r\n case 'redis':\r\n return this.pool;\r\n case 'postgres':\r\n return await this.pool.connect();\r\n default:\r\n throw new Error(`Unsupported database type: ${this.config.type}`);\r\n }\r\n } catch (err) {\r\n throw createDatabaseError(\r\n DatabaseErrorCode.CONNECTION_FAILED,\r\n 'Failed to acquire connection',\r\n err instanceof Error ? err : new Error(String(err)),\r\n { type: this.config.type }\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Acquire SQLite connection from pool\r\n */\r\n private async acquireSQLiteConnection(startTime: number): Promise<Database> {\r\n // Check for available connection\r\n const availableConnection = Array.from(this.connections).find(\r\n conn => !this.activeConnections.has(conn)\r\n );\r\n\r\n if (availableConnection) {\r\n this.activeConnections.add(availableConnection);\r\n return availableConnection as Database;\r\n }\r\n\r\n // Check if we can create more connections\r\n if (this.connections.size < this.options.maxConnections) {\r\n const newConnection = await this.createSQLiteConnection();\r\n this.connections.add(newConnection);\r\n this.activeConnections.add(newConnection);\r\n return newConnection;\r\n }\r\n\r\n // Queue request\r\n return new Promise((resolve, reject) => {\r\n const timeoutId = setTimeout(() => {\r\n const index = this.pendingRequests.findIndex(req => req.resolve === resolve);\r\n if (index !== -1) {\r\n this.pendingRequests.splice(index, 1);\r\n }\r\n reject(createDatabaseError(\r\n DatabaseErrorCode.TIMEOUT,\r\n 'Connection acquisition timeout',\r\n undefined,\r\n { timeout: this.options.acquireTimeout }\r\n ));\r\n }, this.options.acquireTimeout);\r\n\r\n this.pendingRequests.push({\r\n resolve: (conn) => {\r\n clearTimeout(timeoutId);\r\n resolve(conn);\r\n },\r\n reject: (err) => {\r\n clearTimeout(timeoutId);\r\n reject(err);\r\n },\r\n timestamp: startTime,\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Create new SQLite connection\r\n */\r\n private async createSQLiteConnection(): Promise<Database> {\r\n const dbPath = this.config.database || this.config.connectionString || ':memory:';\r\n\r\n const db = await open({\r\n filename: dbPath,\r\n driver: sqlite3.Database,\r\n });\r\n\r\n await db.run('PRAGMA foreign_keys = ON');\r\n await db.run(`PRAGMA busy_timeout = ${this.config.timeout || 5000}`);\r\n\r\n return db;\r\n }\r\n\r\n /**\r\n * Release connection back to pool\r\n */\r\n async release(connection: any): Promise<void> {\r\n if (!connection) {\r\n return;\r\n }\r\n\r\n try {\r\n switch (this.config.type) {\r\n case 'sqlite':\r\n this.releaseSQLiteConnection(connection);\r\n break;\r\n case 'redis':\r\n // Redis client is shared, no release needed\r\n break;\r\n case 'postgres':\r\n if (connection && typeof connection.release === 'function') {\r\n connection.release();\r\n }\r\n break;\r\n }\r\n } catch (err) {\r\n console.error('Failed to release connection:', err);\r\n }\r\n }\r\n\r\n /**\r\n * Release SQLite connection\r\n */\r\n private releaseSQLiteConnection(connection: Database): void {\r\n this.activeConnections.delete(connection);\r\n\r\n // Process pending requests\r\n if (this.pendingRequests.length > 0) {\r\n const pending = this.pendingRequests.shift();\r\n if (pending) {\r\n this.activeConnections.add(connection);\r\n pending.resolve(connection);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Start periodic health checks\r\n */\r\n startHealthChecks(): void {\r\n if (this.healthCheckActive) {\r\n return;\r\n }\r\n\r\n this.healthCheckActive = true;\r\n this.healthCheckInterval = setInterval(async () => {\r\n try {\r\n const healthy = await this.performHealthCheck();\r\n this.lastHealthCheck = new Date();\r\n\r\n if (!healthy) {\r\n console.warn(`Health check failed for ${this.config.type} pool`);\r\n await this.attemptReconnection();\r\n }\r\n } catch (err) {\r\n console.error('Health check error:', err);\r\n }\r\n }, this.options.healthCheckInterval);\r\n }\r\n\r\n /**\r\n * Stop health checks\r\n */\r\n stopHealthChecks(): void {\r\n if (this.healthCheckInterval) {\r\n clearInterval(this.healthCheckInterval);\r\n this.healthCheckInterval = undefined;\r\n }\r\n this.healthCheckActive = false;\r\n }\r\n\r\n /**\r\n * Perform health check\r\n */\r\n private async performHealthCheck(): Promise<boolean> {\r\n try {\r\n switch (this.config.type) {\r\n case 'sqlite': {\r\n const connection = Array.from(this.connections)[0];\r\n if (connection) {\r\n await (connection as Database).get('SELECT 1');\r\n return true;\r\n }\r\n return false;\r\n }\r\n case 'redis':\r\n if (this.pool) {\r\n await this.pool.ping();\r\n return true;\r\n }\r\n return false;\r\n case 'postgres':\r\n if (this.pool) {\r\n const client = await this.pool.connect();\r\n await client.query('SELECT 1');\r\n client.release();\r\n return true;\r\n }\r\n return false;\r\n default:\r\n return false;\r\n }\r\n } catch (err) {\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Check if pool is healthy (exposed for testing)\r\n */\r\n private async isHealthy(): Promise<boolean> {\r\n return this.performHealthCheck();\r\n }\r\n\r\n /**\r\n * Attempt reconnection with exponential backoff\r\n */\r\n private async attemptReconnection(): Promise<void> {\r\n if (this.reconnectAttempts >= this.maxReconnectAttempts) {\r\n console.error(`Max reconnection attempts (${this.maxReconnectAttempts}) reached for ${this.config.type}`);\r\n return;\r\n }\r\n\r\n const delay = Math.min(\r\n this.options.reconnectBaseDelay * Math.pow(2, this.reconnectAttempts),\r\n 30000\r\n );\r\n\r\n this.reconnectAttempts++;\r\n\r\n await new Promise(resolve => setTimeout(resolve, delay));\r\n\r\n try {\r\n await this.initialize();\r\n console.log(`Reconnection successful for ${this.config.type}`);\r\n this.reconnectAttempts = 0;\r\n } catch (err) {\r\n console.error(`Reconnection failed for ${this.config.type}:`, err);\r\n }\r\n }\r\n\r\n /**\r\n * Get reconnection delays for testing\r\n */\r\n private getReconnectDelays(): number[] {\r\n const delays: number[] = [];\r\n for (let i = 0; i < 5; i++) {\r\n delays.push(\r\n Math.min(this.options.reconnectBaseDelay * Math.pow(2, i), 30000)\r\n );\r\n }\r\n return delays;\r\n }\r\n\r\n /**\r\n * Simulate disconnection (for testing)\r\n */\r\n private simulateDisconnection(): void {\r\n if (this.config.type === 'redis' && this.pool) {\r\n this.pool.disconnect();\r\n } else if (this.config.type === 'postgres' && this.pool) {\r\n this.pool.end();\r\n }\r\n }\r\n\r\n /**\r\n * Remove unhealthy connections (for testing)\r\n */\r\n private removeUnhealthyConnections(count: number): void {\r\n if (this.config.type === 'sqlite') {\r\n const connectionsToRemove = Array.from(this.connections).slice(0, count);\r\n connectionsToRemove.forEach(conn => {\r\n this.connections.delete(conn);\r\n this.activeConnections.delete(conn);\r\n (conn as Database).close();\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Enable cache fallback for graceful degradation\r\n */\r\n enableCacheFallback(enabled: boolean): void {\r\n this.cacheFallbackEnabled = enabled;\r\n }\r\n\r\n /**\r\n * Get data with cache fallback\r\n */\r\n async getWithFallback(key: string): Promise<any> {\r\n try {\r\n const connection = await this.acquire();\r\n // Actual data retrieval would happen here\r\n await this.release(connection);\r\n return null;\r\n } catch (err) {\r\n if (this.cacheFallbackEnabled && this.cache.has(key)) {\r\n console.warn(`Using cached data for key: ${key}`);\r\n return this.cache.get(key);\r\n }\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Get connection pool statistics\r\n */\r\n getStats(): ConnectionPoolStats {\r\n const now = Date.now();\r\n const uptime = now - this.startTime.getTime();\r\n\r\n switch (this.config.type) {\r\n case 'sqlite':\r\n return {\r\n type: 'sqlite',\r\n total: this.connections.size,\r\n active: this.activeConnections.size,\r\n idle: this.connections.size - this.activeConnections.size,\r\n pending: this.pendingRequests.length,\r\n maxConnections: this.options.maxConnections,\r\n available: this.connections.size - this.activeConnections.size,\r\n healthy: this.connections.size > 0,\r\n lastHealthCheck: this.lastHealthCheck,\r\n healthCheckActive: this.healthCheckActive,\r\n reconnectAttempts: this.reconnectAttempts,\r\n failedAttempts: this.failedAttempts,\r\n uptime,\r\n };\r\n\r\n case 'redis':\r\n return {\r\n type: 'redis',\r\n total: this.pool ? 1 : 0,\r\n active: this.pool?.isOpen ? 1 : 0,\r\n idle: 0,\r\n pending: 0,\r\n maxConnections: 1,\r\n available: this.pool?.isOpen ? 1 : 0,\r\n healthy: this.pool?.isOpen ?? false,\r\n lastHealthCheck: this.lastHealthCheck,\r\n healthCheckActive: this.healthCheckActive,\r\n reconnectAttempts: this.reconnectAttempts,\r\n failedAttempts: this.failedAttempts,\r\n uptime,\r\n };\r\n\r\n case 'postgres':\r\n return {\r\n type: 'postgres',\r\n total: this.pool?.totalCount ?? 0,\r\n active: (this.pool?.totalCount ?? 0) - (this.pool?.idleCount ?? 0),\r\n idle: this.pool?.idleCount ?? 0,\r\n pending: this.pool?.waitingCount ?? 0,\r\n maxConnections: this.options.maxConnections,\r\n available: this.pool?.idleCount ?? 0,\r\n healthy: this.pool !== null,\r\n lastHealthCheck: this.lastHealthCheck,\r\n healthCheckActive: this.healthCheckActive,\r\n reconnectAttempts: this.reconnectAttempts,\r\n failedAttempts: this.failedAttempts,\r\n uptime,\r\n };\r\n\r\n default:\r\n throw new Error(`Unsupported database type: ${this.config.type}`);\r\n }\r\n }\r\n\r\n /**\r\n * Shutdown connection pool\r\n */\r\n async shutdown(): Promise<void> {\r\n if (this.isShuttingDown) {\r\n return;\r\n }\r\n\r\n this.isShuttingDown = true;\r\n this.stopHealthChecks();\r\n\r\n // Reject all pending requests\r\n this.pendingRequests.forEach(req => {\r\n req.reject(createDatabaseError(\r\n DatabaseErrorCode.CONNECTION_FAILED,\r\n 'Connection pool is shutting down',\r\n undefined,\r\n { type: this.config.type }\r\n ));\r\n });\r\n this.pendingRequests = [];\r\n\r\n // Close all connections\r\n try {\r\n switch (this.config.type) {\r\n case 'sqlite':\r\n await Promise.all(\r\n Array.from(this.connections).map(conn => (conn as Database).close())\r\n );\r\n this.connections.clear();\r\n this.activeConnections.clear();\r\n break;\r\n\r\n case 'redis':\r\n if (this.pool) {\r\n await this.pool.quit();\r\n this.pool = null;\r\n }\r\n break;\r\n\r\n case 'postgres':\r\n if (this.pool) {\r\n await this.pool.end();\r\n this.pool = null;\r\n }\r\n break;\r\n }\r\n } catch (err) {\r\n console.error('Error during shutdown:', err);\r\n }\r\n }\r\n}\r\n"],"names":["sqlite3","open","createClient","Pool","DatabaseErrorCode","createDatabaseError","ConnectionPoolManager","config","options","pool","connections","Set","activeConnections","pendingRequests","healthCheckInterval","lastHealthCheck","healthCheckActive","reconnectAttempts","maxReconnectAttempts","failedAttempts","startTime","isShuttingDown","cacheFallbackEnabled","cache","Map","minConnections","maxConnections","poolSize","acquireTimeout","timeout","idleTimeout","reconnectBaseDelay","Date","initialize","type","initializeSQLitePool","initializeRedisPool","initializePostgresPool","Error","warmUpPool","err","CONNECTION_FAILED","String","dbPath","database","connectionString","i","db","filename","driver","Database","run","add","url","host","port","password","encodeURIComponent","socket","connectTimeout","reconnectStrategy","retries","Math","min","pow","on","console","error","connect","username","max","idleTimeoutMillis","connectionTimeoutMillis","client","query","release","ping","acquire","undefined","now","acquireSQLiteConnection","availableConnection","Array","from","find","conn","has","size","newConnection","createSQLiteConnection","Promise","resolve","reject","timeoutId","setTimeout","index","findIndex","req","splice","TIMEOUT","push","clearTimeout","timestamp","connection","releaseSQLiteConnection","delete","length","pending","shift","startHealthChecks","setInterval","healthy","performHealthCheck","warn","attemptReconnection","stopHealthChecks","clearInterval","get","isHealthy","delay","log","getReconnectDelays","delays","simulateDisconnection","disconnect","end","removeUnhealthyConnections","count","connectionsToRemove","slice","forEach","close","enableCacheFallback","enabled","getWithFallback","key","getStats","uptime","getTime","total","active","idle","available","isOpen","totalCount","idleCount","waitingCount","shutdown","all","map","clear","quit"],"mappings":"AAAA;;;;;;;;;;;CAWC,GAED,OAAOA,aAAa,UAAU;AAC9B,SAASC,IAAI,QAAkB,SAAS;AACxC,SAASC,YAAY,QAAyB,QAAQ;AACtD,SAASC,IAAI,QAAoB,KAAK;AACtC,SAEEC,iBAAiB,QACZ,aAAa;AACpB,SAASC,mBAAmB,QAAQ,cAAc;AA4BlD;;;;CAIC,GACD,OAAO,MAAMC;IACHC,OAAuB;IACvBC,QAA+B;IAC/BC,OAAY,KAAK;IACjBC,cAAwB,IAAIC,MAAM;IAClCC,oBAA8B,IAAID,MAAM;IACxCE,kBAIH,EAAE,CAAC;IACAC,oBAAqC;IACrCC,gBAAuB;IACvBC,oBAA6B,MAAM;IACnCC,oBAA4B,EAAE;IAC9BC,uBAA+B,GAAG;IAClCC,iBAAyB,EAAE;IAC3BC,UAAgB;IAChBC,iBAA0B,MAAM;IAChCC,uBAAgC,MAAM;IACtCC,QAA0B,IAAIC,MAAM;IAE5C,YAAYjB,MAAsB,EAAEC,UAAuB,CAAC,CAAC,CAAE;QAC7D,IAAI,CAACD,MAAM,GAAGA;QACd,IAAI,CAACC,OAAO,GAAG;YACbiB,gBAAgBjB,QAAQiB,cAAc,IAAI;YAC1CC,gBAAgBlB,QAAQkB,cAAc,IAAInB,OAAOoB,QAAQ,IAAI;YAC7DC,gBAAgBpB,QAAQoB,cAAc,IAAIrB,OAAOsB,OAAO,IAAI;YAC5DC,aAAatB,QAAQsB,WAAW,IAAI;YACpChB,qBAAqBN,QAAQM,mBAAmB,IAAI;YACpDI,sBAAsBV,QAAQU,oBAAoB,IAAI;YACtDa,oBAAoBvB,QAAQuB,kBAAkB,IAAI;QACpD;Q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F;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/database-service/connection-pool-manager.ts"],"sourcesContent":["/**\r\n * Connection Pool Manager\r\n *\r\n * Manages connection pools for database adapters with:\r\n * - Automatic initialization on service startup\r\n * - Connection health checks (ping every 30s)\r\n * - Automatic reconnection with exponential backoff\r\n * - Connection metrics (active, idle, pending)\r\n * - Graceful degradation on connection failures\r\n *\r\n * Part of Bug Fix: Connection Pool Initialization\r\n */\r\n\r\nimport sqlite3 from 'sqlite3';\r\nimport { open, Database } from 'sqlite';\r\nimport { createClient, RedisClientType } from 'redis';\r\nimport { Pool, PoolClient } from 'pg';\r\nimport {\r\n DatabaseConfig,\r\n DatabaseErrorCode,\r\n} from './types.js';\r\nimport { createDatabaseError } from './errors.js';\r\n\r\nexport interface ConnectionPoolStats {\r\n type: 'redis' | 'sqlite' | 'postgres';\r\n total: number;\r\n active: number;\r\n idle: number;\r\n pending: number;\r\n maxConnections: number;\r\n available: number;\r\n healthy: boolean;\r\n lastHealthCheck?: Date;\r\n healthCheckActive: boolean;\r\n reconnectAttempts: number;\r\n failedAttempts: number;\r\n uptime: number;\r\n}\r\n\r\nexport interface PoolOptions {\r\n minConnections?: number;\r\n maxConnections?: number;\r\n acquireTimeout?: number;\r\n idleTimeout?: number;\r\n healthCheckInterval?: number;\r\n maxReconnectAttempts?: number;\r\n reconnectBaseDelay?: number;\r\n}\r\n\r\n/**\r\n * Connection Pool Manager\r\n *\r\n * Manages connection lifecycle, health checks, and automatic recovery\r\n */\r\nexport class ConnectionPoolManager {\r\n private config: DatabaseConfig;\r\n private options: Required<PoolOptions>;\r\n private pool: any = null;\r\n private connections: Set<any> = new Set();\r\n private activeConnections: Set<any> = new Set();\r\n private pendingRequests: Array<{\r\n resolve: (connection: any) => void;\r\n reject: (error: Error) => void;\r\n timestamp: number;\r\n }> = [];\r\n private healthCheckInterval?: NodeJS.Timeout;\r\n private lastHealthCheck?: Date;\r\n private healthCheckActive: boolean = false;\r\n private reconnectAttempts: number = 0;\r\n private maxReconnectAttempts: number = 10;\r\n private failedAttempts: number = 0;\r\n private startTime: Date;\r\n private isShuttingDown: boolean = false;\r\n private cacheFallbackEnabled: boolean = false;\r\n private cache: Map<string, any> = new Map();\r\n\r\n constructor(config: DatabaseConfig, options: PoolOptions = {}) {\r\n this.config = config;\r\n this.options = {\r\n minConnections: options.minConnections ?? 2,\r\n maxConnections: options.maxConnections ?? config.poolSize ?? 10,\r\n acquireTimeout: options.acquireTimeout ?? config.timeout ?? 5000,\r\n idleTimeout: options.idleTimeout ?? 30000,\r\n healthCheckInterval: options.healthCheckInterval ?? 30000,\r\n maxReconnectAttempts: options.maxReconnectAttempts ?? 10,\r\n reconnectBaseDelay: options.reconnectBaseDelay ?? 1000,\r\n };\r\n this.maxReconnectAttempts = this.options.maxReconnectAttempts;\r\n this.startTime = new Date();\r\n }\r\n\r\n /**\r\n * Initialize connection pool\r\n */\r\n async initialize(): Promise<void> {\r\n try {\r\n switch (this.config.type) {\r\n case 'sqlite':\r\n await this.initializeSQLitePool();\r\n break;\r\n case 'redis':\r\n await this.initializeRedisPool();\r\n break;\r\n case 'postgres':\r\n await this.initializePostgresPool();\r\n break;\r\n default:\r\n throw new Error(`Unsupported database type: ${this.config.type}`);\r\n }\r\n\r\n // Initialize minimum connections\r\n await this.warmUpPool();\r\n } catch (err) {\r\n this.failedAttempts++;\r\n throw createDatabaseError(\r\n DatabaseErrorCode.CONNECTION_FAILED,\r\n `Failed to initialize ${this.config.type} connection pool`,\r\n err instanceof Error ? err : new Error(String(err)),\r\n { config: this.config }\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Initialize SQLite connection pool\r\n */\r\n private async initializeSQLitePool(): Promise<void> {\r\n const dbPath = this.config.database || this.config.connectionString || ':memory:';\r\n\r\n if (!dbPath || dbPath === '') {\r\n throw new Error('SQLite database path is required');\r\n }\r\n\r\n // Create connection pool for SQLite\r\n for (let i = 0; i < this.options.minConnections; i++) {\r\n const db = await open({\r\n filename: dbPath,\r\n driver: sqlite3.Database,\r\n });\r\n\r\n await db.run('PRAGMA foreign_keys = ON');\r\n await db.run(`PRAGMA busy_timeout = ${this.config.timeout || 5000}`);\r\n\r\n this.connections.add(db);\r\n }\r\n }\r\n\r\n /**\r\n * Initialize Redis connection pool\r\n */\r\n private async initializeRedisPool(): Promise<void> {\r\n let url = this.config.connectionString;\r\n\r\n if (!url) {\r\n // Build connection string with optional authentication\r\n const host = this.config.host || 'localhost';\r\n const port = this.config.port || 6379;\r\n\r\n if (this.config.password) {\r\n // Include password in connection string (credentials from environment)\r\n url = `redis://:${encodeURIComponent(this.config.password)}@${host}:${port}`;\r\n } else {\r\n url = `redis://${host}:${port}`;\r\n }\r\n }\r\n\r\n this.pool = createClient({\r\n url,\r\n socket: {\r\n connectTimeout: this.config.timeout || 5000,\r\n reconnectStrategy: (retries) => {\r\n if (retries > this.maxReconnectAttempts) {\r\n return false;\r\n }\r\n // Exponential backoff\r\n return Math.min(this.options.reconnectBaseDelay * Math.pow(2, retries), 30000);\r\n },\r\n },\r\n });\r\n\r\n // Set up event handlers\r\n this.pool.on('error', (err: Error) => {\r\n console.error('Redis connection error:', err);\r\n this.failedAttempts++;\r\n });\r\n\r\n this.pool.on('reconnecting', () => {\r\n this.reconnectAttempts++;\r\n });\r\n\r\n await this.pool.connect();\r\n }\r\n\r\n /**\r\n * Initialize PostgreSQL connection pool\r\n */\r\n private async initializePostgresPool(): Promise<void> {\r\n const connectionString = this.config.connectionString ||\r\n `postgresql://${this.config.username}:${this.config.password}@${this.config.host}:${this.config.port}/${this.config.database}`;\r\n // Note: credentials come from config object (typically loaded from environment variables)\r\n\r\n this.pool = new Pool({\r\n connectionString,\r\n min: this.options.minConnections,\r\n max: this.options.maxConnections,\r\n idleTimeoutMillis: this.options.idleTimeout,\r\n connectionTimeoutMillis: this.options.acquireTimeout,\r\n });\r\n\r\n // Test connection\r\n const client = await this.pool.connect();\r\n await client.query('SELECT 1');\r\n client.release();\r\n }\r\n\r\n /**\r\n * Warm up pool by creating minimum connections\r\n */\r\n private async warmUpPool(): Promise<void> {\r\n if (this.config.type === 'sqlite') {\r\n // SQLite connections already created in initializeSQLitePool\r\n return;\r\n }\r\n\r\n // For Redis and Postgres, connections are managed by their libraries\r\n // We just need to verify connectivity\r\n if (this.config.type === 'redis') {\r\n await this.pool.ping();\r\n } else if (this.config.type === 'postgres') {\r\n const client = await this.pool.connect();\r\n await client.query('SELECT 1');\r\n client.release();\r\n }\r\n }\r\n\r\n /**\r\n * Acquire connection from pool\r\n */\r\n async acquire(): Promise<any> {\r\n if (this.isShuttingDown) {\r\n throw createDatabaseError(\r\n DatabaseErrorCode.CONNECTION_FAILED,\r\n 'Connection pool is shutting down',\r\n undefined,\r\n { type: this.config.type }\r\n );\r\n }\r\n\r\n const startTime = Date.now();\r\n\r\n try {\r\n switch (this.config.type) {\r\n case 'sqlite':\r\n return await this.acquireSQLiteConnection(startTime);\r\n case 'redis':\r\n return this.pool;\r\n case 'postgres':\r\n return await this.pool.connect();\r\n default:\r\n throw new Error(`Unsupported database type: ${this.config.type}`);\r\n }\r\n } catch (err) {\r\n throw createDatabaseError(\r\n DatabaseErrorCode.CONNECTION_FAILED,\r\n 'Failed to acquire connection',\r\n err instanceof Error ? err : new Error(String(err)),\r\n { type: this.config.type }\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Acquire SQLite connection from pool\r\n */\r\n private async acquireSQLiteConnection(startTime: number): Promise<Database> {\r\n // Check for available connection\r\n const availableConnection = Array.from(this.connections).find(\r\n conn => !this.activeConnections.has(conn)\r\n );\r\n\r\n if (availableConnection) {\r\n this.activeConnections.add(availableConnection);\r\n return availableConnection as Database;\r\n }\r\n\r\n // Check if we can create more connections\r\n if (this.connections.size < this.options.maxConnections) {\r\n const newConnection = await this.createSQLiteConnection();\r\n this.connections.add(newConnection);\r\n this.activeConnections.add(newConnection);\r\n return newConnection;\r\n }\r\n\r\n // Queue request\r\n return new Promise((resolve, reject) => {\r\n const timeoutId = setTimeout(() => {\r\n const index = this.pendingRequests.findIndex(req => req.resolve === resolve);\r\n if (index !== -1) {\r\n this.pendingRequests.splice(index, 1);\r\n }\r\n reject(createDatabaseError(\r\n DatabaseErrorCode.TIMEOUT,\r\n 'Connection acquisition timeout',\r\n undefined,\r\n { timeout: this.options.acquireTimeout }\r\n ));\r\n }, this.options.acquireTimeout);\r\n\r\n this.pendingRequests.push({\r\n resolve: (conn) => {\r\n clearTimeout(timeoutId);\r\n resolve(conn);\r\n },\r\n reject: (err) => {\r\n clearTimeout(timeoutId);\r\n reject(err);\r\n },\r\n timestamp: startTime,\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Create new SQLite connection\r\n */\r\n private async createSQLiteConnection(): Promise<Database> {\r\n const dbPath = this.config.database || this.config.connectionString || ':memory:';\r\n\r\n const db = await open({\r\n filename: dbPath,\r\n driver: sqlite3.Database,\r\n });\r\n\r\n await db.run('PRAGMA foreign_keys = ON');\r\n await db.run(`PRAGMA busy_timeout = ${this.config.timeout || 5000}`);\r\n\r\n return db;\r\n }\r\n\r\n /**\r\n * Release connection back to pool\r\n */\r\n async release(connection: any): Promise<void> {\r\n if (!connection) {\r\n return;\r\n }\r\n\r\n try {\r\n switch (this.config.type) {\r\n case 'sqlite':\r\n this.releaseSQLiteConnection(connection);\r\n break;\r\n case 'redis':\r\n // Redis client is shared, no release needed\r\n break;\r\n case 'postgres':\r\n if (connection && typeof connection.release === 'function') {\r\n connection.release();\r\n }\r\n break;\r\n }\r\n } catch (err) {\r\n console.error('Failed to release connection:', err);\r\n }\r\n }\r\n\r\n /**\r\n * Release SQLite connection\r\n */\r\n private releaseSQLiteConnection(connection: Database): void {\r\n this.activeConnections.delete(connection);\r\n\r\n // Process pending requests\r\n if (this.pendingRequests.length > 0) {\r\n const pending = this.pendingRequests.shift();\r\n if (pending) {\r\n this.activeConnections.add(connection);\r\n pending.resolve(connection);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Start periodic health checks\r\n */\r\n startHealthChecks(): void {\r\n if (this.healthCheckActive) {\r\n return;\r\n }\r\n\r\n this.healthCheckActive = true;\r\n this.healthCheckInterval = setInterval(async () => {\r\n try {\r\n const healthy = await this.performHealthCheck();\r\n this.lastHealthCheck = new Date();\r\n\r\n if (!healthy) {\r\n console.warn(`Health check failed for ${this.config.type} pool`);\r\n await this.attemptReconnection();\r\n }\r\n } catch (err) {\r\n console.error('Health check error:', err);\r\n }\r\n }, this.options.healthCheckInterval);\r\n }\r\n\r\n /**\r\n * Stop health checks\r\n */\r\n stopHealthChecks(): void {\r\n if (this.healthCheckInterval) {\r\n clearInterval(this.healthCheckInterval);\r\n this.healthCheckInterval = undefined;\r\n }\r\n this.healthCheckActive = false;\r\n }\r\n\r\n /**\r\n * Perform health check\r\n */\r\n private async performHealthCheck(): Promise<boolean> {\r\n try {\r\n switch (this.config.type) {\r\n case 'sqlite': {\r\n const connection = Array.from(this.connections)[0];\r\n if (connection) {\r\n await (connection as Database).get('SELECT 1');\r\n return true;\r\n }\r\n return false;\r\n }\r\n case 'redis':\r\n if (this.pool) {\r\n await this.pool.ping();\r\n return true;\r\n }\r\n return false;\r\n case 'postgres':\r\n if (this.pool) {\r\n const client = await this.pool.connect();\r\n await client.query('SELECT 1');\r\n client.release();\r\n return true;\r\n }\r\n return false;\r\n default:\r\n return false;\r\n }\r\n } catch (err) {\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Check if pool is healthy (exposed for testing)\r\n */\r\n private async isHealthy(): Promise<boolean> {\r\n return this.performHealthCheck();\r\n }\r\n\r\n /**\r\n * Attempt reconnection with exponential backoff\r\n */\r\n private async attemptReconnection(): Promise<void> {\r\n if (this.reconnectAttempts >= this.maxReconnectAttempts) {\r\n console.error(`Max reconnection attempts (${this.maxReconnectAttempts}) reached for ${this.config.type}`);\r\n return;\r\n }\r\n\r\n const delay = Math.min(\r\n this.options.reconnectBaseDelay * Math.pow(2, this.reconnectAttempts),\r\n 30000\r\n );\r\n\r\n this.reconnectAttempts++;\r\n\r\n await new Promise(resolve => setTimeout(resolve, delay));\r\n\r\n try {\r\n await this.initialize();\r\n console.log(`Reconnection successful for ${this.config.type}`);\r\n this.reconnectAttempts = 0;\r\n } catch (err) {\r\n console.error(`Reconnection failed for ${this.config.type}:`, err);\r\n }\r\n }\r\n\r\n /**\r\n * Get reconnection delays for testing\r\n */\r\n private getReconnectDelays(): number[] {\r\n const delays: number[] = [];\r\n for (let i = 0; i < 5; i++) {\r\n delays.push(\r\n Math.min(this.options.reconnectBaseDelay * Math.pow(2, i), 30000)\r\n );\r\n }\r\n return delays;\r\n }\r\n\r\n /**\r\n * Simulate disconnection (for testing)\r\n */\r\n private simulateDisconnection(): void {\r\n if (this.config.type === 'redis' && this.pool) {\r\n this.pool.disconnect();\r\n } else if (this.config.type === 'postgres' && this.pool) {\r\n this.pool.end();\r\n }\r\n }\r\n\r\n /**\r\n * Remove unhealthy connections (for testing)\r\n */\r\n private removeUnhealthyConnections(count: number): void {\r\n if (this.config.type === 'sqlite') {\r\n const connectionsToRemove = Array.from(this.connections).slice(0, count);\r\n connectionsToRemove.forEach(conn => {\r\n this.connections.delete(conn);\r\n this.activeConnections.delete(conn);\r\n (conn as Database).close();\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Enable cache fallback for graceful degradation\r\n */\r\n enableCacheFallback(enabled: boolean): void {\r\n this.cacheFallbackEnabled = enabled;\r\n }\r\n\r\n /**\r\n * Get data with cache fallback\r\n */\r\n async getWithFallback(key: string): Promise<any> {\r\n try {\r\n const connection = await this.acquire();\r\n // Actual data retrieval would happen here\r\n await this.release(connection);\r\n return null;\r\n } catch (err) {\r\n if (this.cacheFallbackEnabled && this.cache.has(key)) {\r\n console.warn(`Using cached data for key: ${key}`);\r\n return this.cache.get(key);\r\n }\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Get connection pool statistics\r\n */\r\n getStats(): ConnectionPoolStats {\r\n const now = Date.now();\r\n const uptime = now - this.startTime.getTime();\r\n\r\n switch (this.config.type) {\r\n case 'sqlite':\r\n return {\r\n type: 'sqlite',\r\n total: this.connections.size,\r\n active: this.activeConnections.size,\r\n idle: this.connections.size - this.activeConnections.size,\r\n pending: this.pendingRequests.length,\r\n maxConnections: this.options.maxConnections,\r\n available: this.connections.size - this.activeConnections.size,\r\n healthy: this.connections.size > 0,\r\n lastHealthCheck: this.lastHealthCheck,\r\n healthCheckActive: this.healthCheckActive,\r\n reconnectAttempts: this.reconnectAttempts,\r\n failedAttempts: this.failedAttempts,\r\n uptime,\r\n };\r\n\r\n case 'redis':\r\n return {\r\n type: 'redis',\r\n total: this.pool ? 1 : 0,\r\n active: this.pool?.isOpen ? 1 : 0,\r\n idle: 0,\r\n pending: 0,\r\n maxConnections: 1,\r\n available: this.pool?.isOpen ? 1 : 0,\r\n healthy: this.pool?.isOpen ?? false,\r\n lastHealthCheck: this.lastHealthCheck,\r\n healthCheckActive: this.healthCheckActive,\r\n reconnectAttempts: this.reconnectAttempts,\r\n failedAttempts: this.failedAttempts,\r\n uptime,\r\n };\r\n\r\n case 'postgres':\r\n return {\r\n type: 'postgres',\r\n total: this.pool?.totalCount ?? 0,\r\n active: (this.pool?.totalCount ?? 0) - (this.pool?.idleCount ?? 0),\r\n idle: this.pool?.idleCount ?? 0,\r\n pending: this.pool?.waitingCount ?? 0,\r\n maxConnections: this.options.maxConnections,\r\n available: this.pool?.idleCount ?? 0,\r\n healthy: this.pool !== null,\r\n lastHealthCheck: this.lastHealthCheck,\r\n healthCheckActive: this.healthCheckActive,\r\n reconnectAttempts: this.reconnectAttempts,\r\n failedAttempts: this.failedAttempts,\r\n uptime,\r\n };\r\n\r\n default:\r\n throw new Error(`Unsupported database type: ${this.config.type}`);\r\n }\r\n }\r\n\r\n /**\r\n * Shutdown connection pool\r\n */\r\n async shutdown(): Promise<void> {\r\n if (this.isShuttingDown) {\r\n return;\r\n }\r\n\r\n this.isShuttingDown = true;\r\n this.stopHealthChecks();\r\n\r\n // Reject all pending requests\r\n this.pendingRequests.forEach(req => {\r\n req.reject(createDatabaseError(\r\n DatabaseErrorCode.CONNECTION_FAILED,\r\n 'Connection pool is shutting down',\r\n undefined,\r\n { type: this.config.type }\r\n ));\r\n });\r\n this.pendingRequests = [];\r\n\r\n // Close all connections\r\n try {\r\n switch (this.config.type) {\r\n case 'sqlite':\r\n await Promise.all(\r\n Array.from(this.connections).map(conn => (conn as Database).close())\r\n );\r\n this.connections.clear();\r\n this.activeConnections.clear();\r\n break;\r\n\r\n case 'redis':\r\n if (this.pool) {\r\n await this.pool.quit();\r\n this.pool = null;\r\n }\r\n break;\r\n\r\n case 'postgres':\r\n if (this.pool) {\r\n await this.pool.end();\r\n this.pool = null;\r\n }\r\n break;\r\n }\r\n } catch (err) {\r\n console.error('Error during shutdown:', err);\r\n }\r\n }\r\n}\r\n"],"names":["sqlite3","open","createClient","Pool","DatabaseErrorCode","createDatabaseError","ConnectionPoolManager","config","options","pool","connections","Set","activeConnections","pendingRequests","healthCheckInterval","lastHealthCheck","healthCheckActive","reconnectAttempts","maxReconnectAttempts","failedAttempts","startTime","isShuttingDown","cacheFallbackEnabled","cache","Map","minConnections","maxConnections","poolSize","acquireTimeout","timeout","idleTimeout","reconnectBaseDelay","Date","initialize","type","initializeSQLitePool","initializeRedisPool","initializePostgresPool","Error","warmUpPool","err","CONNECTION_FAILED","String","dbPath","database","connectionString","i","db","filename","driver","Database","run","add","url","host","port","password","encodeURIComponent","socket","connectTimeout","reconnectStrategy","retries","Math","min","pow","on","console","error","connect","username","max","idleTimeoutMillis","connectionTimeoutMillis","client","query","release","ping","acquire","undefined","now","acquireSQLiteConnection","availableConnection","Array","from","find","conn","has","size","newConnection","createSQLiteConnection","Promise","resolve","reject","timeoutId","setTimeout","index","findIndex","req","splice","TIMEOUT","push","clearTimeout","timestamp","connection","releaseSQLiteConnection","delete","length","pending","shift","startHealthChecks","setInterval","healthy","performHealthCheck","warn","attemptReconnection","stopHealthChecks","clearInterval","get","isHealthy","delay","log","getReconnectDelays","delays","simulateDisconnection","disconnect","end","removeUnhealthyConnections","count","connectionsToRemove","slice","forEach","close","enableCacheFallback","enabled","getWithFallback","key","getStats","uptime","getTime","total","active","idle","available","isOpen","totalCount","idleCount","waitingCount","shutdown","all","map","clear","quit"],"mappings":"AAAA;;;;;;;;;;;CAWC,GAED,OAAOA,aAAa,UAAU;AAC9B,SAASC,IAAI,QAAkB,SAAS;AACxC,SAASC,YAAY,QAAyB,QAAQ;AACtD,SAASC,IAAI,QAAoB,KAAK;AACtC,SAEEC,iBAAiB,QACZ,aAAa;AACpB,SAASC,mBAAmB,QAAQ,cAAc;AA4BlD;;;;CAIC,GACD,OAAO,MAAMC;IACHC,OAAuB;IACvBC,QAA+B;IAC/BC,OAAY,KAAK;IACjBC,cAAwB,IAAIC,MAAM;IAClCC,oBAA8B,IAAID,MAAM;IACxCE,kBAIH,EAAE,CAAC;IACAC,oBAAqC;IACrCC,gBAAuB;IACvBC,oBAA6B,MAAM;IACnCC,oBAA4B,EAAE;IAC9BC,uBAA+B,GAAG;IAClCC,iBAAyB,EAAE;IAC3BC,UAAgB;IAChBC,iBAA0B,MAAM;IAChCC,uBAAgC,MAAM;IACtCC,QAA0B,IAAIC,MAAM;IAE5C,YAAYjB,MAAsB,EAAEC,UAAuB,CAAC,CAAC,CAAE;QAC7D,IAAI,CAACD,MAAM,GAAGA;QACd,IAAI,CAACC,OAAO,GAAG;YACbiB,gBAAgBjB,QAAQiB,cAAc,IAAI;YAC1CC,gBAAgBlB,QAAQkB,cAAc,IAAInB,OAAOoB,QAAQ,IAAI;YAC7DC,gBAAgBpB,QAAQoB,cAAc,IAAIrB,OAAOsB,OAAO,IAAI;YAC5DC,aAAatB,QAAQsB,WAAW,IAAI;YACpChB,qBAAqBN,QAAQM,mBAAmB,IAAI;YACpDI,sBAAsBV,QAAQU,oBAAoB,IAAI;YACtDa,oBAAoBvB,QAAQuB,kBAAkB,IAAI;QACpD;QACA,IAAI,CAACb,oBAAoB,GAAG,IAAI,CAACV,OAAO,CAACU,oBAAoB;QA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3,"sources":["../../src/orchestrator/index.ts"],"sourcesContent":["/**\r\n * CFN Loop Orchestrator Module Exports\r\n *\r\n * Main exports for orchestration functionality.\r\n *\r\n * @module orchestrator\r\n */\r\n\r\nexport { CFNOrchestrator, default } from './orchestrate';\r\nexport * from './types';\r\n"],"names":["CFNOrchestrator","default"],"mappings":"AAAA;;;;;;CAMC,GAED,SAASA,eAAe,EAAEC,OAAO,QAAQ,gBAAgB;AACzD,cAAc,UAAU"}
|