agentdb 3.0.0-alpha.10 → 3.0.0-alpha.12
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/LICENSE +21 -0
- package/README.md +2821 -225
- package/dist/src/backends/VectorBackend.d.ts +31 -6
- package/dist/src/backends/VectorBackend.d.ts.map +1 -1
- package/dist/src/backends/detector.js.map +1 -1
- package/dist/src/backends/factory.d.ts +16 -33
- package/dist/src/backends/factory.d.ts.map +1 -1
- package/dist/src/backends/factory.js +138 -108
- package/dist/src/backends/factory.js.map +1 -1
- package/dist/src/backends/hnswlib/HNSWLibBackend.d.ts.map +1 -1
- package/dist/src/backends/hnswlib/HNSWLibBackend.js +29 -2
- package/dist/src/backends/hnswlib/HNSWLibBackend.js.map +1 -1
- package/dist/src/backends/ruvector/RuVectorBackend.d.ts +198 -45
- package/dist/src/backends/ruvector/RuVectorBackend.d.ts.map +1 -1
- package/dist/src/backends/ruvector/RuVectorBackend.js +612 -277
- package/dist/src/backends/ruvector/RuVectorBackend.js.map +1 -1
- package/dist/src/backends/ruvector/RuVectorLearning.d.ts +0 -4
- package/dist/src/backends/ruvector/RuVectorLearning.d.ts.map +1 -1
- package/dist/src/backends/ruvector/RuVectorLearning.js +0 -6
- package/dist/src/backends/ruvector/RuVectorLearning.js.map +1 -1
- package/dist/src/backends/rvf/AdaptiveIndexTuner.d.ts +175 -0
- package/dist/src/backends/rvf/AdaptiveIndexTuner.d.ts.map +1 -0
- package/dist/src/backends/rvf/AdaptiveIndexTuner.js +559 -0
- package/dist/src/backends/rvf/AdaptiveIndexTuner.js.map +1 -0
- package/dist/src/backends/rvf/ContrastiveTrainer.d.ts +148 -0
- package/dist/src/backends/rvf/ContrastiveTrainer.d.ts.map +1 -0
- package/dist/src/backends/rvf/ContrastiveTrainer.js +438 -0
- package/dist/src/backends/rvf/ContrastiveTrainer.js.map +1 -0
- package/dist/src/backends/rvf/FederatedSessionManager.d.ts +211 -0
- package/dist/src/backends/rvf/FederatedSessionManager.d.ts.map +1 -0
- package/dist/src/backends/rvf/FederatedSessionManager.js +389 -0
- package/dist/src/backends/rvf/FederatedSessionManager.js.map +1 -0
- package/dist/src/backends/rvf/FilterBuilder.d.ts +136 -0
- package/dist/src/backends/rvf/FilterBuilder.d.ts.map +1 -0
- package/dist/src/backends/rvf/FilterBuilder.js +157 -0
- package/dist/src/backends/rvf/FilterBuilder.js.map +1 -0
- package/dist/src/backends/rvf/NativeAccelerator.d.ts +140 -0
- package/dist/src/backends/rvf/NativeAccelerator.d.ts.map +1 -0
- package/dist/src/backends/rvf/NativeAccelerator.js +630 -0
- package/dist/src/backends/rvf/NativeAccelerator.js.map +1 -0
- package/dist/src/backends/rvf/RvfBackend.d.ts +194 -0
- package/dist/src/backends/rvf/RvfBackend.d.ts.map +1 -0
- package/dist/src/backends/rvf/RvfBackend.js +607 -0
- package/dist/src/backends/rvf/RvfBackend.js.map +1 -0
- package/dist/src/backends/rvf/RvfSolver.d.ts +175 -0
- package/dist/src/backends/rvf/RvfSolver.d.ts.map +1 -0
- package/dist/src/backends/rvf/RvfSolver.js +176 -0
- package/dist/src/backends/rvf/RvfSolver.js.map +1 -0
- package/dist/src/backends/rvf/SelfLearningRvfBackend.d.ts +143 -0
- package/dist/src/backends/rvf/SelfLearningRvfBackend.d.ts.map +1 -0
- package/dist/src/backends/rvf/SelfLearningRvfBackend.js +569 -0
- package/dist/src/backends/rvf/SelfLearningRvfBackend.js.map +1 -0
- package/dist/src/backends/rvf/SemanticQueryRouter.d.ts +128 -0
- package/dist/src/backends/rvf/SemanticQueryRouter.d.ts.map +1 -0
- package/dist/src/backends/rvf/SemanticQueryRouter.js +415 -0
- package/dist/src/backends/rvf/SemanticQueryRouter.js.map +1 -0
- package/dist/src/backends/rvf/SimdFallbacks.d.ts +25 -0
- package/dist/src/backends/rvf/SimdFallbacks.d.ts.map +1 -0
- package/dist/src/backends/rvf/SimdFallbacks.js +287 -0
- package/dist/src/backends/rvf/SimdFallbacks.js.map +1 -0
- package/dist/src/backends/rvf/SolverBandit.d.ts +100 -0
- package/dist/src/backends/rvf/SolverBandit.d.ts.map +1 -0
- package/dist/src/backends/rvf/SolverBandit.js +216 -0
- package/dist/src/backends/rvf/SolverBandit.js.map +1 -0
- package/dist/src/backends/rvf/SonaLearningBackend.d.ts +157 -0
- package/dist/src/backends/rvf/SonaLearningBackend.d.ts.map +1 -0
- package/dist/src/backends/rvf/SonaLearningBackend.js +283 -0
- package/dist/src/backends/rvf/SonaLearningBackend.js.map +1 -0
- package/dist/src/backends/rvf/SqlJsRvfBackend.d.ts +77 -0
- package/dist/src/backends/rvf/SqlJsRvfBackend.d.ts.map +1 -0
- package/dist/src/backends/rvf/SqlJsRvfBackend.js +382 -0
- package/dist/src/backends/rvf/SqlJsRvfBackend.js.map +1 -0
- package/dist/src/backends/rvf/WasmStoreBridge.d.ts +27 -0
- package/dist/src/backends/rvf/WasmStoreBridge.d.ts.map +1 -0
- package/dist/src/backends/rvf/WasmStoreBridge.js +87 -0
- package/dist/src/backends/rvf/WasmStoreBridge.js.map +1 -0
- package/dist/src/backends/rvf/validation.d.ts +20 -0
- package/dist/src/backends/rvf/validation.d.ts.map +1 -0
- package/dist/src/backends/rvf/validation.js +78 -0
- package/dist/src/backends/rvf/validation.js.map +1 -0
- package/dist/src/benchmark/BenchmarkSuite.d.ts +318 -0
- package/dist/src/benchmark/BenchmarkSuite.d.ts.map +1 -0
- package/dist/src/benchmark/BenchmarkSuite.js +984 -0
- package/dist/src/benchmark/BenchmarkSuite.js.map +1 -0
- package/dist/src/benchmark/index.d.ts +29 -0
- package/dist/src/benchmark/index.d.ts.map +1 -0
- package/dist/src/benchmark/index.js +39 -0
- package/dist/src/benchmark/index.js.map +1 -0
- package/dist/src/browser/AttentionBrowser.d.ts.map +1 -1
- package/dist/src/browser/AttentionBrowser.js +1 -0
- package/dist/src/browser/AttentionBrowser.js.map +1 -1
- package/dist/src/cli/agentdb-cli.d.ts +13 -0
- package/dist/src/cli/agentdb-cli.d.ts.map +1 -1
- package/dist/src/cli/agentdb-cli.js +803 -94
- package/dist/src/cli/agentdb-cli.js.map +1 -1
- package/dist/src/cli/commands/hyperbolic.d.ts +11 -0
- package/dist/src/cli/commands/hyperbolic.d.ts.map +1 -0
- package/dist/src/cli/commands/hyperbolic.js +428 -0
- package/dist/src/cli/commands/hyperbolic.js.map +1 -0
- package/dist/src/cli/commands/learn.d.ts +11 -0
- package/dist/src/cli/commands/learn.d.ts.map +1 -0
- package/dist/src/cli/commands/learn.js +404 -0
- package/dist/src/cli/commands/learn.js.map +1 -0
- package/dist/src/cli/commands/migrate.d.ts +15 -0
- package/dist/src/cli/commands/migrate.d.ts.map +1 -1
- package/dist/src/cli/commands/migrate.js +176 -8
- package/dist/src/cli/commands/migrate.js.map +1 -1
- package/dist/src/cli/commands/route.d.ts +11 -0
- package/dist/src/cli/commands/route.d.ts.map +1 -0
- package/dist/src/cli/commands/route.js +414 -0
- package/dist/src/cli/commands/route.js.map +1 -0
- package/dist/src/cli/commands/rvf.d.ts +21 -0
- package/dist/src/cli/commands/rvf.d.ts.map +1 -0
- package/dist/src/cli/commands/rvf.js +448 -0
- package/dist/src/cli/commands/rvf.js.map +1 -0
- package/dist/src/cli/lib/report-store.d.ts +2 -1
- package/dist/src/cli/lib/report-store.d.ts.map +1 -1
- package/dist/src/cli/lib/report-store.js +85 -65
- package/dist/src/cli/lib/report-store.js.map +1 -1
- package/dist/src/cli/lib/simulation-runner.d.ts +40 -3
- package/dist/src/cli/lib/simulation-runner.d.ts.map +1 -1
- package/dist/src/cli/lib/simulation-runner.js +248 -6
- package/dist/src/cli/lib/simulation-runner.js.map +1 -1
- package/dist/src/compatibility/DeprecationWarnings.d.ts +54 -0
- package/dist/src/compatibility/DeprecationWarnings.d.ts.map +1 -0
- package/dist/src/compatibility/DeprecationWarnings.js +131 -0
- package/dist/src/compatibility/DeprecationWarnings.js.map +1 -0
- package/dist/src/compatibility/MigrationUtilities.d.ts +30 -0
- package/dist/src/compatibility/MigrationUtilities.d.ts.map +1 -0
- package/dist/src/compatibility/MigrationUtilities.js +184 -0
- package/dist/src/compatibility/MigrationUtilities.js.map +1 -0
- package/dist/src/compatibility/V1toV2Adapter.d.ts +76 -0
- package/dist/src/compatibility/V1toV2Adapter.d.ts.map +1 -0
- package/dist/src/compatibility/V1toV2Adapter.js +185 -0
- package/dist/src/compatibility/V1toV2Adapter.js.map +1 -0
- package/dist/src/compatibility/VersionDetector.d.ts +32 -0
- package/dist/src/compatibility/VersionDetector.d.ts.map +1 -0
- package/dist/src/compatibility/VersionDetector.js +144 -0
- package/dist/src/compatibility/VersionDetector.js.map +1 -0
- package/dist/src/compatibility/index.d.ts +14 -0
- package/dist/src/compatibility/index.d.ts.map +1 -0
- package/dist/src/compatibility/index.js +21 -0
- package/dist/src/compatibility/index.js.map +1 -0
- package/dist/src/compatibility/types.d.ts +103 -0
- package/dist/src/compatibility/types.d.ts.map +1 -0
- package/dist/src/compatibility/types.js +5 -0
- package/dist/src/compatibility/types.js.map +1 -0
- package/dist/src/controllers/AttentionService.d.ts +99 -202
- package/dist/src/controllers/AttentionService.d.ts.map +1 -1
- package/dist/src/controllers/AttentionService.js +450 -558
- package/dist/src/controllers/AttentionService.js.map +1 -1
- package/dist/src/controllers/CausalMemoryGraph.d.ts +30 -5
- package/dist/src/controllers/CausalMemoryGraph.d.ts.map +1 -1
- package/dist/src/controllers/CausalMemoryGraph.js +89 -13
- package/dist/src/controllers/CausalMemoryGraph.js.map +1 -1
- package/dist/src/controllers/CausalRecall.d.ts +4 -0
- package/dist/src/controllers/CausalRecall.d.ts.map +1 -1
- package/dist/src/controllers/CausalRecall.js +19 -2
- package/dist/src/controllers/CausalRecall.js.map +1 -1
- package/dist/src/controllers/EmbeddingService.d.ts.map +1 -1
- package/dist/src/controllers/EmbeddingService.js +28 -11
- package/dist/src/controllers/EmbeddingService.js.map +1 -1
- package/dist/src/controllers/EnhancedEmbeddingService.d.ts +4 -0
- package/dist/src/controllers/EnhancedEmbeddingService.d.ts.map +1 -1
- package/dist/src/controllers/EnhancedEmbeddingService.js +17 -3
- package/dist/src/controllers/EnhancedEmbeddingService.js.map +1 -1
- package/dist/src/controllers/ExplainableRecall.d.ts +1 -1
- package/dist/src/controllers/ExplainableRecall.d.ts.map +1 -1
- package/dist/src/controllers/ExplainableRecall.js +1 -1
- package/dist/src/controllers/ExplainableRecall.js.map +1 -1
- package/dist/src/controllers/HNSWIndex.d.ts +20 -2
- package/dist/src/controllers/HNSWIndex.d.ts.map +1 -1
- package/dist/src/controllers/HNSWIndex.js +82 -6
- package/dist/src/controllers/HNSWIndex.js.map +1 -1
- package/dist/src/controllers/LearningSystem.d.ts +1 -17
- package/dist/src/controllers/LearningSystem.d.ts.map +1 -1
- package/dist/src/controllers/LearningSystem.js +18 -135
- package/dist/src/controllers/LearningSystem.js.map +1 -1
- package/dist/src/controllers/MemoryController.d.ts +161 -0
- package/dist/src/controllers/MemoryController.d.ts.map +1 -0
- package/dist/src/controllers/MemoryController.js +303 -0
- package/dist/src/controllers/MemoryController.js.map +1 -0
- package/dist/src/controllers/MincutService.d.ts +92 -0
- package/dist/src/controllers/MincutService.d.ts.map +1 -0
- package/dist/src/controllers/MincutService.js +336 -0
- package/dist/src/controllers/MincutService.js.map +1 -0
- package/dist/src/controllers/NightlyLearner.d.ts +5 -1
- package/dist/src/controllers/NightlyLearner.d.ts.map +1 -1
- package/dist/src/controllers/NightlyLearner.js +17 -3
- package/dist/src/controllers/NightlyLearner.js.map +1 -1
- package/dist/src/controllers/QUICClient.d.ts +45 -0
- package/dist/src/controllers/QUICClient.d.ts.map +1 -1
- package/dist/src/controllers/QUICClient.js +190 -0
- package/dist/src/controllers/QUICClient.js.map +1 -1
- package/dist/src/controllers/ReasoningBank.d.ts +6 -3
- package/dist/src/controllers/ReasoningBank.d.ts.map +1 -1
- package/dist/src/controllers/ReasoningBank.js +47 -41
- package/dist/src/controllers/ReasoningBank.js.map +1 -1
- package/dist/src/controllers/ReflexionMemory.d.ts +115 -6
- package/dist/src/controllers/ReflexionMemory.d.ts.map +1 -1
- package/dist/src/controllers/ReflexionMemory.js +541 -213
- package/dist/src/controllers/ReflexionMemory.js.map +1 -1
- package/dist/src/controllers/SkillLibrary.d.ts +27 -3
- package/dist/src/controllers/SkillLibrary.d.ts.map +1 -1
- package/dist/src/controllers/SkillLibrary.js +187 -91
- package/dist/src/controllers/SkillLibrary.js.map +1 -1
- package/dist/src/controllers/SparsificationService.d.ts +151 -0
- package/dist/src/controllers/SparsificationService.d.ts.map +1 -0
- package/dist/src/controllers/SparsificationService.js +375 -0
- package/dist/src/controllers/SparsificationService.js.map +1 -0
- package/dist/src/controllers/SyncCoordinator.d.ts.map +1 -1
- package/dist/src/controllers/SyncCoordinator.js +115 -3
- package/dist/src/controllers/SyncCoordinator.js.map +1 -1
- package/dist/src/controllers/WASMVectorSearch.d.ts +12 -30
- package/dist/src/controllers/WASMVectorSearch.d.ts.map +1 -1
- package/dist/src/controllers/WASMVectorSearch.js +146 -93
- package/dist/src/controllers/WASMVectorSearch.js.map +1 -1
- package/dist/src/controllers/attention/AttentionCache.d.ts +38 -0
- package/dist/src/controllers/attention/AttentionCache.d.ts.map +1 -0
- package/dist/src/controllers/attention/AttentionCache.js +80 -0
- package/dist/src/controllers/attention/AttentionCache.js.map +1 -0
- package/dist/src/controllers/attention/AttentionConfig.d.ts +127 -0
- package/dist/src/controllers/attention/AttentionConfig.d.ts.map +1 -0
- package/dist/src/controllers/attention/AttentionConfig.js +124 -0
- package/dist/src/controllers/attention/AttentionConfig.js.map +1 -0
- package/dist/src/controllers/attention/AttentionCore.d.ts +89 -0
- package/dist/src/controllers/attention/AttentionCore.d.ts.map +1 -0
- package/dist/src/controllers/attention/AttentionCore.js +289 -0
- package/dist/src/controllers/attention/AttentionCore.js.map +1 -0
- package/dist/src/controllers/attention/AttentionHelpers.d.ts +55 -0
- package/dist/src/controllers/attention/AttentionHelpers.d.ts.map +1 -0
- package/dist/src/controllers/attention/AttentionHelpers.js +148 -0
- package/dist/src/controllers/attention/AttentionHelpers.js.map +1 -0
- package/dist/src/controllers/attention/AttentionMetrics.d.ts +55 -0
- package/dist/src/controllers/attention/AttentionMetrics.d.ts.map +1 -0
- package/dist/src/controllers/attention/AttentionMetrics.js +72 -0
- package/dist/src/controllers/attention/AttentionMetrics.js.map +1 -0
- package/dist/src/controllers/attention/AttentionWASM.d.ts +98 -0
- package/dist/src/controllers/attention/AttentionWASM.d.ts.map +1 -0
- package/dist/src/controllers/attention/AttentionWASM.js +147 -0
- package/dist/src/controllers/attention/AttentionWASM.js.map +1 -0
- package/dist/src/controllers/attention/CrossAttentionController.d.ts +141 -0
- package/dist/src/controllers/attention/CrossAttentionController.d.ts.map +1 -0
- package/dist/src/controllers/attention/CrossAttentionController.js +325 -0
- package/dist/src/controllers/attention/CrossAttentionController.js.map +1 -0
- package/dist/src/controllers/attention/MultiHeadAttentionController.d.ts +137 -0
- package/dist/src/controllers/attention/MultiHeadAttentionController.d.ts.map +1 -0
- package/dist/src/controllers/attention/MultiHeadAttentionController.js +336 -0
- package/dist/src/controllers/attention/MultiHeadAttentionController.js.map +1 -0
- package/dist/src/controllers/attention/SelfAttentionController.d.ts +117 -0
- package/dist/src/controllers/attention/SelfAttentionController.d.ts.map +1 -0
- package/dist/src/controllers/attention/SelfAttentionController.js +205 -0
- package/dist/src/controllers/attention/SelfAttentionController.js.map +1 -0
- package/dist/src/controllers/attention/index.d.ts +24 -0
- package/dist/src/controllers/attention/index.d.ts.map +1 -0
- package/dist/src/controllers/attention/index.js +20 -0
- package/dist/src/controllers/attention/index.js.map +1 -0
- package/dist/src/controllers/index.d.ts +14 -27
- package/dist/src/controllers/index.d.ts.map +1 -1
- package/dist/src/controllers/index.js +10 -18
- package/dist/src/controllers/index.js.map +1 -1
- package/dist/src/controllers/prerequisites.d.ts +76 -0
- package/dist/src/controllers/prerequisites.d.ts.map +1 -0
- package/dist/src/controllers/prerequisites.js +235 -0
- package/dist/src/controllers/prerequisites.js.map +1 -0
- package/dist/src/core/AgentDB.d.ts +27 -19
- package/dist/src/core/AgentDB.d.ts.map +1 -1
- package/dist/src/core/AgentDB.js +76 -124
- package/dist/src/core/AgentDB.js.map +1 -1
- package/dist/src/core/QueryCache.d.ts +138 -0
- package/dist/src/core/QueryCache.d.ts.map +1 -0
- package/dist/src/core/QueryCache.js +309 -0
- package/dist/src/core/QueryCache.js.map +1 -0
- package/dist/src/db-fallback.d.ts +10 -1
- package/dist/src/db-fallback.d.ts.map +1 -1
- package/dist/src/db-fallback.js +205 -28
- package/dist/src/db-fallback.js.map +1 -1
- package/dist/src/examples/quic-sync-example.js +2 -2
- package/dist/src/examples/quic-sync-example.js.map +1 -1
- package/dist/src/index.d.ts +15 -15
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +39 -11
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/agentdb-mcp-server.js +47 -2
- package/dist/src/mcp/agentdb-mcp-server.js.map +1 -1
- package/dist/src/model/ModelCacheLoader.d.ts +24 -0
- package/dist/src/model/ModelCacheLoader.d.ts.map +1 -0
- package/dist/src/model/ModelCacheLoader.js +121 -0
- package/dist/src/model/ModelCacheLoader.js.map +1 -0
- package/dist/src/observability/index.d.ts +8 -0
- package/dist/src/observability/index.d.ts.map +1 -0
- package/dist/src/observability/index.js +8 -0
- package/dist/src/observability/index.js.map +1 -0
- package/dist/src/observability/integration.d.ts +32 -0
- package/dist/src/observability/integration.d.ts.map +1 -0
- package/dist/src/observability/integration.js +159 -0
- package/dist/src/observability/integration.js.map +1 -0
- package/dist/src/observability/telemetry.d.ts +137 -0
- package/dist/src/observability/telemetry.d.ts.map +1 -0
- package/dist/src/observability/telemetry.js +416 -0
- package/dist/src/observability/telemetry.js.map +1 -0
- package/dist/src/optimizations/BatchOperations.d.ts +47 -0
- package/dist/src/optimizations/BatchOperations.d.ts.map +1 -1
- package/dist/src/optimizations/BatchOperations.js +183 -31
- package/dist/src/optimizations/BatchOperations.js.map +1 -1
- package/dist/src/optimizations/Quantization.d.ts +330 -0
- package/dist/src/optimizations/Quantization.d.ts.map +1 -0
- package/dist/src/optimizations/Quantization.js +793 -0
- package/dist/src/optimizations/Quantization.js.map +1 -0
- package/dist/src/optimizations/index.d.ts +1 -3
- package/dist/src/optimizations/index.d.ts.map +1 -1
- package/dist/src/optimizations/index.js +0 -1
- package/dist/src/optimizations/index.js.map +1 -1
- package/dist/src/quantization/index.d.ts +7 -0
- package/dist/src/quantization/index.d.ts.map +1 -0
- package/dist/src/quantization/index.js +15 -0
- package/dist/src/quantization/index.js.map +1 -0
- package/dist/src/quantization/vector-quantization.d.ts +388 -0
- package/dist/src/quantization/vector-quantization.d.ts.map +1 -0
- package/dist/src/quantization/vector-quantization.js +1132 -0
- package/dist/src/quantization/vector-quantization.js.map +1 -0
- package/dist/src/search/HybridSearch.d.ts +311 -0
- package/dist/src/search/HybridSearch.d.ts.map +1 -0
- package/dist/src/search/HybridSearch.js +712 -0
- package/dist/src/search/HybridSearch.js.map +1 -0
- package/dist/src/search/index.d.ts +12 -0
- package/dist/src/search/index.d.ts.map +1 -0
- package/dist/src/search/index.js +16 -0
- package/dist/src/search/index.js.map +1 -0
- package/dist/src/services/AttentionService.d.ts +303 -0
- package/dist/src/services/AttentionService.d.ts.map +1 -0
- package/dist/src/services/AttentionService.js +1165 -0
- package/dist/src/services/AttentionService.js.map +1 -0
- package/dist/src/services/LLMRouter.d.ts +61 -7
- package/dist/src/services/LLMRouter.d.ts.map +1 -1
- package/dist/src/services/LLMRouter.js +286 -22
- package/dist/src/services/LLMRouter.js.map +1 -1
- package/dist/src/services/audit-logger.service.d.ts +168 -0
- package/dist/src/services/audit-logger.service.d.ts.map +1 -0
- package/dist/src/services/audit-logger.service.js +331 -0
- package/dist/src/services/audit-logger.service.js.map +1 -0
- package/dist/src/services/enhanced-embeddings.d.ts +271 -0
- package/dist/src/services/enhanced-embeddings.d.ts.map +1 -0
- package/dist/src/services/enhanced-embeddings.js +1035 -0
- package/dist/src/services/enhanced-embeddings.js.map +1 -0
- package/dist/src/services/federated-learning.d.ts +172 -0
- package/dist/src/services/federated-learning.d.ts.map +1 -0
- package/dist/src/services/federated-learning.js +342 -0
- package/dist/src/services/federated-learning.js.map +1 -0
- package/dist/src/simd/index.d.ts +9 -0
- package/dist/src/simd/index.d.ts.map +1 -0
- package/dist/src/simd/index.js +27 -0
- package/dist/src/simd/index.js.map +1 -0
- package/dist/src/simd/simd-vector-ops.d.ts +332 -0
- package/dist/src/simd/simd-vector-ops.d.ts.map +1 -0
- package/dist/src/simd/simd-vector-ops.js +945 -0
- package/dist/src/simd/simd-vector-ops.js.map +1 -0
- package/dist/src/types/database.types.d.ts +275 -0
- package/dist/src/types/database.types.d.ts.map +1 -0
- package/dist/src/types/database.types.js +55 -0
- package/dist/src/types/database.types.js.map +1 -0
- package/dist/src/types/graph.d.ts +29 -0
- package/dist/src/types/graph.d.ts.map +1 -0
- package/dist/src/types/graph.js +8 -0
- package/dist/src/types/graph.js.map +1 -0
- package/dist/src/utils/chalk-fallback.d.ts +3 -0
- package/dist/src/utils/chalk-fallback.d.ts.map +1 -0
- package/dist/src/utils/chalk-fallback.js +20 -0
- package/dist/src/utils/chalk-fallback.js.map +1 -0
- package/dist/src/utils/similarity.d.ts +11 -0
- package/dist/src/utils/similarity.d.ts.map +1 -0
- package/dist/src/utils/similarity.js +25 -0
- package/dist/src/utils/similarity.js.map +1 -0
- package/dist/src/wasm-loader.d.ts +66 -0
- package/dist/src/wasm-loader.d.ts.map +1 -0
- package/dist/src/wasm-loader.js +76 -0
- package/dist/src/wasm-loader.js.map +1 -0
- package/dist/src/wrappers/agentdb-fast.d.ts +139 -0
- package/dist/src/wrappers/agentdb-fast.d.ts.map +1 -0
- package/dist/src/wrappers/agentdb-fast.js +307 -0
- package/dist/src/wrappers/agentdb-fast.js.map +1 -0
- package/dist/src/wrappers/attention-fallbacks.d.ts +343 -0
- package/dist/src/wrappers/attention-fallbacks.d.ts.map +1 -0
- package/dist/src/wrappers/attention-fallbacks.js +1484 -0
- package/dist/src/wrappers/attention-fallbacks.js.map +1 -0
- package/dist/src/wrappers/attention-native.d.ts +111 -0
- package/dist/src/wrappers/attention-native.d.ts.map +1 -0
- package/dist/src/wrappers/attention-native.js +273 -0
- package/dist/src/wrappers/attention-native.js.map +1 -0
- package/dist/src/wrappers/embedding-service.d.ts +117 -0
- package/dist/src/wrappers/embedding-service.d.ts.map +1 -0
- package/dist/src/wrappers/embedding-service.js +370 -0
- package/dist/src/wrappers/embedding-service.js.map +1 -0
- package/dist/src/wrappers/gnn-wrapper.d.ts +71 -0
- package/dist/src/wrappers/gnn-wrapper.d.ts.map +1 -0
- package/dist/src/wrappers/gnn-wrapper.js +236 -0
- package/dist/src/wrappers/gnn-wrapper.js.map +1 -0
- package/dist/src/wrappers/index.d.ts +48 -0
- package/dist/src/wrappers/index.d.ts.map +1 -0
- package/dist/src/wrappers/index.js +83 -0
- package/dist/src/wrappers/index.js.map +1 -0
- package/package.json +77 -76
- package/scripts/postinstall.cjs +13 -144
- package/dist/agentdb.browser.js +0 -1685
- package/dist/agentdb.browser.js.map +0 -7
- package/dist/agentdb.browser.min.js +0 -3
- package/dist/agentdb.browser.min.js.map +0 -7
- package/dist/agentdb.wasm-loader.js +0 -207
- package/dist/backends/VectorBackend.d.ts +0 -120
- package/dist/backends/VectorBackend.js +0 -14
- package/dist/backends/VectorBackend.js.map +0 -1
- package/dist/optimizations/RVFOptimizer.d.ts +0 -225
- package/dist/optimizations/RVFOptimizer.js +0 -541
- package/dist/optimizations/RVFOptimizer.js.map +0 -1
- package/dist/schemas/frontier-schema.sql +0 -378
- package/dist/schemas/schema.sql +0 -382
- package/dist/simulation/cli.d.ts +0 -9
- package/dist/simulation/cli.d.ts.map +0 -1
- package/dist/simulation/cli.js +0 -68
- package/dist/simulation/cli.js.map +0 -1
- package/dist/simulation/runner.d.ts +0 -21
- package/dist/simulation/runner.d.ts.map +0 -1
- package/dist/simulation/runner.js +0 -241
- package/dist/simulation/runner.js.map +0 -1
- package/dist/simulation/scenarios/aidefence-integration.d.ts +0 -24
- package/dist/simulation/scenarios/aidefence-integration.d.ts.map +0 -1
- package/dist/simulation/scenarios/aidefence-integration.js +0 -124
- package/dist/simulation/scenarios/aidefence-integration.js.map +0 -1
- package/dist/simulation/scenarios/bmssp-integration.d.ts +0 -23
- package/dist/simulation/scenarios/bmssp-integration.d.ts.map +0 -1
- package/dist/simulation/scenarios/bmssp-integration.js +0 -104
- package/dist/simulation/scenarios/bmssp-integration.js.map +0 -1
- package/dist/simulation/scenarios/causal-reasoning.d.ts +0 -16
- package/dist/simulation/scenarios/causal-reasoning.d.ts.map +0 -1
- package/dist/simulation/scenarios/causal-reasoning.js +0 -108
- package/dist/simulation/scenarios/causal-reasoning.js.map +0 -1
- package/dist/simulation/scenarios/consciousness-explorer.d.ts +0 -25
- package/dist/simulation/scenarios/consciousness-explorer.d.ts.map +0 -1
- package/dist/simulation/scenarios/consciousness-explorer.js +0 -108
- package/dist/simulation/scenarios/consciousness-explorer.js.map +0 -1
- package/dist/simulation/scenarios/domain-examples/e-commerce-recommendations.d.ts +0 -135
- package/dist/simulation/scenarios/domain-examples/e-commerce-recommendations.d.ts.map +0 -1
- package/dist/simulation/scenarios/domain-examples/e-commerce-recommendations.js +0 -158
- package/dist/simulation/scenarios/domain-examples/e-commerce-recommendations.js.map +0 -1
- package/dist/simulation/scenarios/domain-examples/index.d.ts +0 -14
- package/dist/simulation/scenarios/domain-examples/index.d.ts.map +0 -1
- package/dist/simulation/scenarios/domain-examples/index.js +0 -14
- package/dist/simulation/scenarios/domain-examples/index.js.map +0 -1
- package/dist/simulation/scenarios/domain-examples/iot-sensor-networks.d.ts +0 -178
- package/dist/simulation/scenarios/domain-examples/iot-sensor-networks.d.ts.map +0 -1
- package/dist/simulation/scenarios/domain-examples/iot-sensor-networks.js +0 -218
- package/dist/simulation/scenarios/domain-examples/iot-sensor-networks.js.map +0 -1
- package/dist/simulation/scenarios/domain-examples/medical-imaging.d.ts +0 -122
- package/dist/simulation/scenarios/domain-examples/medical-imaging.d.ts.map +0 -1
- package/dist/simulation/scenarios/domain-examples/medical-imaging.js +0 -129
- package/dist/simulation/scenarios/domain-examples/medical-imaging.js.map +0 -1
- package/dist/simulation/scenarios/domain-examples/robotics-navigation.d.ts +0 -166
- package/dist/simulation/scenarios/domain-examples/robotics-navigation.d.ts.map +0 -1
- package/dist/simulation/scenarios/domain-examples/robotics-navigation.js +0 -161
- package/dist/simulation/scenarios/domain-examples/robotics-navigation.js.map +0 -1
- package/dist/simulation/scenarios/domain-examples/scientific-research.d.ts +0 -151
- package/dist/simulation/scenarios/domain-examples/scientific-research.d.ts.map +0 -1
- package/dist/simulation/scenarios/domain-examples/scientific-research.js +0 -187
- package/dist/simulation/scenarios/domain-examples/scientific-research.js.map +0 -1
- package/dist/simulation/scenarios/domain-examples/trading-systems.d.ts +0 -102
- package/dist/simulation/scenarios/domain-examples/trading-systems.d.ts.map +0 -1
- package/dist/simulation/scenarios/domain-examples/trading-systems.js +0 -100
- package/dist/simulation/scenarios/domain-examples/trading-systems.js.map +0 -1
- package/dist/simulation/scenarios/goalie-integration.d.ts +0 -24
- package/dist/simulation/scenarios/goalie-integration.d.ts.map +0 -1
- package/dist/simulation/scenarios/goalie-integration.js +0 -121
- package/dist/simulation/scenarios/goalie-integration.js.map +0 -1
- package/dist/simulation/scenarios/graph-traversal.d.ts +0 -17
- package/dist/simulation/scenarios/graph-traversal.d.ts.map +0 -1
- package/dist/simulation/scenarios/graph-traversal.js +0 -101
- package/dist/simulation/scenarios/graph-traversal.js.map +0 -1
- package/dist/simulation/scenarios/latent-space/attention-analysis.d.ts +0 -45
- package/dist/simulation/scenarios/latent-space/attention-analysis.d.ts.map +0 -1
- package/dist/simulation/scenarios/latent-space/attention-analysis.js +0 -435
- package/dist/simulation/scenarios/latent-space/attention-analysis.js.map +0 -1
- package/dist/simulation/scenarios/latent-space/clustering-analysis.d.ts +0 -55
- package/dist/simulation/scenarios/latent-space/clustering-analysis.d.ts.map +0 -1
- package/dist/simulation/scenarios/latent-space/clustering-analysis.js +0 -606
- package/dist/simulation/scenarios/latent-space/clustering-analysis.js.map +0 -1
- package/dist/simulation/scenarios/latent-space/hnsw-exploration.d.ts +0 -74
- package/dist/simulation/scenarios/latent-space/hnsw-exploration.d.ts.map +0 -1
- package/dist/simulation/scenarios/latent-space/hnsw-exploration.js +0 -391
- package/dist/simulation/scenarios/latent-space/hnsw-exploration.js.map +0 -1
- package/dist/simulation/scenarios/latent-space/hypergraph-exploration.d.ts +0 -51
- package/dist/simulation/scenarios/latent-space/hypergraph-exploration.d.ts.map +0 -1
- package/dist/simulation/scenarios/latent-space/hypergraph-exploration.js +0 -536
- package/dist/simulation/scenarios/latent-space/hypergraph-exploration.js.map +0 -1
- package/dist/simulation/scenarios/latent-space/index.d.ts +0 -35
- package/dist/simulation/scenarios/latent-space/index.d.ts.map +0 -1
- package/dist/simulation/scenarios/latent-space/index.js +0 -35
- package/dist/simulation/scenarios/latent-space/index.js.map +0 -1
- package/dist/simulation/scenarios/latent-space/neural-augmentation.d.ts +0 -52
- package/dist/simulation/scenarios/latent-space/neural-augmentation.d.ts.map +0 -1
- package/dist/simulation/scenarios/latent-space/neural-augmentation.js +0 -472
- package/dist/simulation/scenarios/latent-space/neural-augmentation.js.map +0 -1
- package/dist/simulation/scenarios/latent-space/quantum-hybrid.d.ts +0 -53
- package/dist/simulation/scenarios/latent-space/quantum-hybrid.d.ts.map +0 -1
- package/dist/simulation/scenarios/latent-space/quantum-hybrid.js +0 -391
- package/dist/simulation/scenarios/latent-space/quantum-hybrid.js.map +0 -1
- package/dist/simulation/scenarios/latent-space/self-organizing-hnsw.d.ts +0 -52
- package/dist/simulation/scenarios/latent-space/self-organizing-hnsw.d.ts.map +0 -1
- package/dist/simulation/scenarios/latent-space/self-organizing-hnsw.js +0 -514
- package/dist/simulation/scenarios/latent-space/self-organizing-hnsw.js.map +0 -1
- package/dist/simulation/scenarios/latent-space/traversal-optimization.d.ts +0 -53
- package/dist/simulation/scenarios/latent-space/traversal-optimization.d.ts.map +0 -1
- package/dist/simulation/scenarios/latent-space/traversal-optimization.js +0 -595
- package/dist/simulation/scenarios/latent-space/traversal-optimization.js.map +0 -1
- package/dist/simulation/scenarios/lean-agentic-swarm.d.ts +0 -18
- package/dist/simulation/scenarios/lean-agentic-swarm.d.ts.map +0 -1
- package/dist/simulation/scenarios/lean-agentic-swarm.js +0 -132
- package/dist/simulation/scenarios/lean-agentic-swarm.js.map +0 -1
- package/dist/simulation/scenarios/multi-agent-swarm.d.ts +0 -17
- package/dist/simulation/scenarios/multi-agent-swarm.d.ts.map +0 -1
- package/dist/simulation/scenarios/multi-agent-swarm.js +0 -111
- package/dist/simulation/scenarios/multi-agent-swarm.js.map +0 -1
- package/dist/simulation/scenarios/psycho-symbolic-reasoner.d.ts +0 -23
- package/dist/simulation/scenarios/psycho-symbolic-reasoner.d.ts.map +0 -1
- package/dist/simulation/scenarios/psycho-symbolic-reasoner.js +0 -98
- package/dist/simulation/scenarios/psycho-symbolic-reasoner.js.map +0 -1
- package/dist/simulation/scenarios/reflexion-learning.d.ts +0 -16
- package/dist/simulation/scenarios/reflexion-learning.d.ts.map +0 -1
- package/dist/simulation/scenarios/reflexion-learning.js +0 -98
- package/dist/simulation/scenarios/reflexion-learning.js.map +0 -1
- package/dist/simulation/scenarios/research-swarm.d.ts +0 -24
- package/dist/simulation/scenarios/research-swarm.d.ts.map +0 -1
- package/dist/simulation/scenarios/research-swarm.js +0 -146
- package/dist/simulation/scenarios/research-swarm.js.map +0 -1
- package/dist/simulation/scenarios/skill-evolution.d.ts +0 -16
- package/dist/simulation/scenarios/skill-evolution.d.ts.map +0 -1
- package/dist/simulation/scenarios/skill-evolution.js +0 -109
- package/dist/simulation/scenarios/skill-evolution.js.map +0 -1
- package/dist/simulation/scenarios/stock-market-emergence.d.ts +0 -33
- package/dist/simulation/scenarios/stock-market-emergence.d.ts.map +0 -1
- package/dist/simulation/scenarios/stock-market-emergence.js +0 -246
- package/dist/simulation/scenarios/stock-market-emergence.js.map +0 -1
- package/dist/simulation/scenarios/strange-loops.d.ts +0 -18
- package/dist/simulation/scenarios/strange-loops.d.ts.map +0 -1
- package/dist/simulation/scenarios/strange-loops.js +0 -133
- package/dist/simulation/scenarios/strange-loops.js.map +0 -1
- package/dist/simulation/scenarios/sublinear-solver.d.ts +0 -22
- package/dist/simulation/scenarios/sublinear-solver.d.ts.map +0 -1
- package/dist/simulation/scenarios/sublinear-solver.js +0 -82
- package/dist/simulation/scenarios/sublinear-solver.js.map +0 -1
- package/dist/simulation/scenarios/temporal-lead-solver.d.ts +0 -23
- package/dist/simulation/scenarios/temporal-lead-solver.d.ts.map +0 -1
- package/dist/simulation/scenarios/temporal-lead-solver.js +0 -90
- package/dist/simulation/scenarios/temporal-lead-solver.js.map +0 -1
- package/dist/simulation/scenarios/voting-system-consensus.d.ts +0 -27
- package/dist/simulation/scenarios/voting-system-consensus.d.ts.map +0 -1
- package/dist/simulation/scenarios/voting-system-consensus.js +0 -175
- package/dist/simulation/scenarios/voting-system-consensus.js.map +0 -1
- package/dist/simulation/types.d.ts +0 -162
- package/dist/simulation/types.d.ts.map +0 -1
- package/dist/simulation/types.js +0 -5
- package/dist/simulation/types.js.map +0 -1
- package/dist/simulation/utils/PerformanceOptimizer.d.ts +0 -115
- package/dist/simulation/utils/PerformanceOptimizer.d.ts.map +0 -1
- package/dist/simulation/utils/PerformanceOptimizer.js +0 -223
- package/dist/simulation/utils/PerformanceOptimizer.js.map +0 -1
- package/dist/src/backends/index.cjs +0 -6
- package/dist/src/backends/ruvector/GuardedVectorBackend.d.ts +0 -93
- package/dist/src/backends/ruvector/GuardedVectorBackend.d.ts.map +0 -1
- package/dist/src/backends/ruvector/GuardedVectorBackend.js +0 -182
- package/dist/src/backends/ruvector/GuardedVectorBackend.js.map +0 -1
- package/dist/src/consensus/RaftConsensus.d.ts +0 -220
- package/dist/src/consensus/RaftConsensus.d.ts.map +0 -1
- package/dist/src/consensus/RaftConsensus.js +0 -762
- package/dist/src/consensus/RaftConsensus.js.map +0 -1
- package/dist/src/controllers/HierarchicalMemory.d.ts +0 -197
- package/dist/src/controllers/HierarchicalMemory.d.ts.map +0 -1
- package/dist/src/controllers/HierarchicalMemory.js +0 -519
- package/dist/src/controllers/HierarchicalMemory.js.map +0 -1
- package/dist/src/controllers/MemoryConsolidation.d.ts +0 -142
- package/dist/src/controllers/MemoryConsolidation.d.ts.map +0 -1
- package/dist/src/controllers/MemoryConsolidation.js +0 -479
- package/dist/src/controllers/MemoryConsolidation.js.map +0 -1
- package/dist/src/controllers/QUICConnection.d.ts +0 -122
- package/dist/src/controllers/QUICConnection.d.ts.map +0 -1
- package/dist/src/controllers/QUICConnection.js +0 -329
- package/dist/src/controllers/QUICConnection.js.map +0 -1
- package/dist/src/controllers/QUICConnectionPool.d.ts +0 -83
- package/dist/src/controllers/QUICConnectionPool.d.ts.map +0 -1
- package/dist/src/controllers/QUICConnectionPool.js +0 -256
- package/dist/src/controllers/QUICConnectionPool.js.map +0 -1
- package/dist/src/controllers/QUICStreamManager.d.ts +0 -114
- package/dist/src/controllers/QUICStreamManager.d.ts.map +0 -1
- package/dist/src/controllers/QUICStreamManager.js +0 -267
- package/dist/src/controllers/QUICStreamManager.js.map +0 -1
- package/dist/src/controllers/StreamingEmbeddingService.d.ts +0 -82
- package/dist/src/controllers/StreamingEmbeddingService.d.ts.map +0 -1
- package/dist/src/controllers/StreamingEmbeddingService.js +0 -243
- package/dist/src/controllers/StreamingEmbeddingService.js.map +0 -1
- package/dist/src/controllers/index.cjs +0 -6
- package/dist/src/coordination/MultiDatabaseCoordinator.d.ts +0 -348
- package/dist/src/coordination/MultiDatabaseCoordinator.d.ts.map +0 -1
- package/dist/src/coordination/MultiDatabaseCoordinator.js +0 -803
- package/dist/src/coordination/MultiDatabaseCoordinator.js.map +0 -1
- package/dist/src/coordination/index.d.ts +0 -10
- package/dist/src/coordination/index.d.ts.map +0 -1
- package/dist/src/coordination/index.js +0 -10
- package/dist/src/coordination/index.js.map +0 -1
- package/dist/src/index.cjs +0 -6
- package/dist/src/optimizations/RVFOptimizer.d.ts +0 -226
- package/dist/src/optimizations/RVFOptimizer.d.ts.map +0 -1
- package/dist/src/optimizations/RVFOptimizer.js +0 -541
- package/dist/src/optimizations/RVFOptimizer.js.map +0 -1
- package/dist/src/security/AttestationLog.d.ts +0 -70
- package/dist/src/security/AttestationLog.d.ts.map +0 -1
- package/dist/src/security/AttestationLog.js +0 -174
- package/dist/src/security/AttestationLog.js.map +0 -1
- package/dist/src/security/MutationGuard.d.ts +0 -83
- package/dist/src/security/MutationGuard.d.ts.map +0 -1
- package/dist/src/security/MutationGuard.js +0 -364
- package/dist/src/security/MutationGuard.js.map +0 -1
- package/dist/src/security/index.cjs +0 -6
- package/dist/src/security/index.d.ts +0 -15
- package/dist/src/security/index.d.ts.map +0 -1
- package/dist/src/security/index.js +0 -18
- package/dist/src/security/index.js.map +0 -1
- package/dist/src/services/GNNService.d.ts +0 -173
- package/dist/src/services/GNNService.d.ts.map +0 -1
- package/dist/src/services/GNNService.js +0 -639
- package/dist/src/services/GNNService.js.map +0 -1
- package/dist/src/services/GraphTransformerService.d.ts +0 -80
- package/dist/src/services/GraphTransformerService.d.ts.map +0 -1
- package/dist/src/services/GraphTransformerService.js +0 -369
- package/dist/src/services/GraphTransformerService.js.map +0 -1
- package/dist/src/services/SemanticRouter.d.ts +0 -83
- package/dist/src/services/SemanticRouter.d.ts.map +0 -1
- package/dist/src/services/SemanticRouter.js +0 -160
- package/dist/src/services/SemanticRouter.js.map +0 -1
- package/dist/src/services/SonaTrajectoryService.d.ts +0 -224
- package/dist/src/services/SonaTrajectoryService.d.ts.map +0 -1
- package/dist/src/services/SonaTrajectoryService.js +0 -539
- package/dist/src/services/SonaTrajectoryService.js.map +0 -1
- package/dist/src/utils/LegacyAttentionAdapter.d.ts +0 -93
- package/dist/src/utils/LegacyAttentionAdapter.d.ts.map +0 -1
- package/dist/src/utils/LegacyAttentionAdapter.js +0 -241
- package/dist/src/utils/LegacyAttentionAdapter.js.map +0 -1
- package/dist/src/utils/vector-math.d.ts +0 -29
- package/dist/src/utils/vector-math.d.ts.map +0 -1
- package/dist/src/utils/vector-math.js +0 -66
- package/dist/src/utils/vector-math.js.map +0 -1
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* QUICConnection - Enhanced QUIC Connection with 0-RTT, BBR, and Migration
|
|
3
|
-
*
|
|
4
|
-
* Implements an advanced QUIC connection with:
|
|
5
|
-
* - 0-RTT fast reconnect via session ticket caching
|
|
6
|
-
* - BBR congestion control for optimal throughput
|
|
7
|
-
* - Connection migration for resilient networking
|
|
8
|
-
* - Latency tracking and performance metrics
|
|
9
|
-
*/
|
|
10
|
-
export class QUICConnection {
|
|
11
|
-
config;
|
|
12
|
-
connected = false;
|
|
13
|
-
busy = false;
|
|
14
|
-
sessionTicket = null;
|
|
15
|
-
bbrState;
|
|
16
|
-
metrics;
|
|
17
|
-
createdAt;
|
|
18
|
-
lastActiveAt;
|
|
19
|
-
migrationCount = 0;
|
|
20
|
-
currentPath;
|
|
21
|
-
id;
|
|
22
|
-
// Static session ticket cache shared across connections for 0-RTT
|
|
23
|
-
static ticketCache = new Map();
|
|
24
|
-
static TICKET_LIFETIME_MS = 7 * 24 * 60 * 60 * 1000; // 7 days
|
|
25
|
-
constructor(config) {
|
|
26
|
-
this.config = {
|
|
27
|
-
endpoint: config.endpoint,
|
|
28
|
-
enableZeroRTT: config.enableZeroRTT ?? true,
|
|
29
|
-
enableMultipath: config.enableMultipath ?? false,
|
|
30
|
-
congestionControl: config.congestionControl ?? 'bbr',
|
|
31
|
-
maxIdleTimeoutMs: config.maxIdleTimeoutMs ?? 30000,
|
|
32
|
-
initialRttMs: config.initialRttMs ?? 100,
|
|
33
|
-
};
|
|
34
|
-
this.id = `quic-conn-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
35
|
-
this.createdAt = Date.now();
|
|
36
|
-
this.lastActiveAt = Date.now();
|
|
37
|
-
this.currentPath = config.endpoint;
|
|
38
|
-
this.bbrState = this.initBBR();
|
|
39
|
-
this.metrics = this.initMetrics();
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Connect to the QUIC endpoint.
|
|
43
|
-
* Uses 0-RTT if a cached session ticket is available.
|
|
44
|
-
*/
|
|
45
|
-
async connect() {
|
|
46
|
-
const startTime = performance.now();
|
|
47
|
-
if (this.connected) {
|
|
48
|
-
return { zeroRtt: false, handshakeMs: 0 };
|
|
49
|
-
}
|
|
50
|
-
// Check for cached session ticket for 0-RTT
|
|
51
|
-
const cachedTicket = QUICConnection.ticketCache.get(this.config.endpoint);
|
|
52
|
-
if (this.config.enableZeroRTT && cachedTicket && cachedTicket.expiresAt > Date.now()) {
|
|
53
|
-
// 0-RTT fast path: skip full handshake
|
|
54
|
-
const result = await this.connectWithZeroRTT(cachedTicket);
|
|
55
|
-
const handshakeMs = performance.now() - startTime;
|
|
56
|
-
this.metrics.handshakeTimeMs = handshakeMs;
|
|
57
|
-
this.metrics.zeroRttUsed = true;
|
|
58
|
-
this.connected = true;
|
|
59
|
-
this.lastActiveAt = Date.now();
|
|
60
|
-
return { zeroRtt: true, handshakeMs };
|
|
61
|
-
}
|
|
62
|
-
// Full TLS 1.3 handshake
|
|
63
|
-
await this.connectFull();
|
|
64
|
-
const handshakeMs = performance.now() - startTime;
|
|
65
|
-
this.metrics.handshakeTimeMs = handshakeMs;
|
|
66
|
-
this.metrics.zeroRttUsed = false;
|
|
67
|
-
// Store session ticket for future 0-RTT
|
|
68
|
-
this.sessionTicket = this.generateSessionTicket();
|
|
69
|
-
QUICConnection.ticketCache.set(this.config.endpoint, this.sessionTicket);
|
|
70
|
-
this.connected = true;
|
|
71
|
-
this.lastActiveAt = Date.now();
|
|
72
|
-
return { zeroRtt: false, handshakeMs };
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* 0-RTT connection using cached session ticket.
|
|
76
|
-
* Sends early data in the initial flight, eliminating 1 RTT.
|
|
77
|
-
*/
|
|
78
|
-
async connectWithZeroRTT(ticket) {
|
|
79
|
-
// Validate ticket
|
|
80
|
-
if (ticket.expiresAt < Date.now()) {
|
|
81
|
-
QUICConnection.ticketCache.delete(this.config.endpoint);
|
|
82
|
-
throw new Error('Session ticket expired, performing full handshake');
|
|
83
|
-
}
|
|
84
|
-
// 0-RTT: send ClientHello + early data in single flight
|
|
85
|
-
// Simulated timing: ~0.1x of full handshake
|
|
86
|
-
const delay = Math.max(1, this.config.initialRttMs * 0.1);
|
|
87
|
-
await this.sleep(delay);
|
|
88
|
-
// Update RTT estimate from 0-RTT
|
|
89
|
-
this.metrics.rttMs = delay;
|
|
90
|
-
this.updateSmoothedRtt(delay);
|
|
91
|
-
// Refresh the ticket for next time
|
|
92
|
-
this.sessionTicket = this.generateSessionTicket();
|
|
93
|
-
QUICConnection.ticketCache.set(this.config.endpoint, this.sessionTicket);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Full TLS 1.3 handshake (1-RTT).
|
|
97
|
-
*/
|
|
98
|
-
async connectFull() {
|
|
99
|
-
// Full handshake: 1 RTT
|
|
100
|
-
const delay = this.config.initialRttMs;
|
|
101
|
-
await this.sleep(delay);
|
|
102
|
-
this.metrics.rttMs = delay;
|
|
103
|
-
this.updateSmoothedRtt(delay);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Disconnect the connection.
|
|
107
|
-
*/
|
|
108
|
-
async disconnect() {
|
|
109
|
-
if (!this.connected)
|
|
110
|
-
return;
|
|
111
|
-
this.connected = false;
|
|
112
|
-
this.busy = false;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Send data over this connection using BBR pacing.
|
|
116
|
-
*/
|
|
117
|
-
async send(data) {
|
|
118
|
-
if (!this.connected) {
|
|
119
|
-
throw new Error('Connection not established');
|
|
120
|
-
}
|
|
121
|
-
this.busy = true;
|
|
122
|
-
this.lastActiveAt = Date.now();
|
|
123
|
-
const size = data.length;
|
|
124
|
-
this.metrics.packetsSent++;
|
|
125
|
-
this.metrics.bytesInFlight += size;
|
|
126
|
-
// BBR-paced sending
|
|
127
|
-
const pacingDelay = this.computeBBRPacingDelay(size);
|
|
128
|
-
await this.sleep(pacingDelay);
|
|
129
|
-
// Simulate ACK
|
|
130
|
-
this.metrics.bytesInFlight -= size;
|
|
131
|
-
this.metrics.packetsAcked++;
|
|
132
|
-
// Update BBR state with delivery sample
|
|
133
|
-
const measuredRtt = pacingDelay + Math.random() * 2; // slight jitter
|
|
134
|
-
this.updateBBR(size, measuredRtt);
|
|
135
|
-
this.updateSmoothedRtt(measuredRtt);
|
|
136
|
-
this.metrics.rttMs = measuredRtt;
|
|
137
|
-
this.busy = false;
|
|
138
|
-
return { bytesAcked: size, rttMs: measuredRtt };
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Migrate connection to a new network path.
|
|
142
|
-
* QUIC supports connection migration without re-handshake.
|
|
143
|
-
*/
|
|
144
|
-
async migrate(newEndpoint) {
|
|
145
|
-
if (!this.connected) {
|
|
146
|
-
throw new Error('Cannot migrate: not connected');
|
|
147
|
-
}
|
|
148
|
-
const previousPath = this.currentPath;
|
|
149
|
-
this.currentPath = newEndpoint;
|
|
150
|
-
this.migrationCount++;
|
|
151
|
-
// Path validation: probe the new path
|
|
152
|
-
const probeStart = performance.now();
|
|
153
|
-
await this.sleep(Math.max(1, this.metrics.smoothedRttMs * 0.5));
|
|
154
|
-
const probeRtt = performance.now() - probeStart;
|
|
155
|
-
// Reset congestion controller for new path (BBR probe_bw)
|
|
156
|
-
this.bbrState.mode = 'probe_bw';
|
|
157
|
-
this.bbrState.cycleIndex = 0;
|
|
158
|
-
this.metrics.congestionWindow = 10 * 1200; // 10 initial packets
|
|
159
|
-
this.updateSmoothedRtt(probeRtt);
|
|
160
|
-
this.lastActiveAt = Date.now();
|
|
161
|
-
return { success: true, previousPath };
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Compute BBR pacing delay for a given packet size.
|
|
165
|
-
*/
|
|
166
|
-
computeBBRPacingDelay(packetSize) {
|
|
167
|
-
const { btlBw, pacingGain } = this.bbrState;
|
|
168
|
-
if (btlBw <= 0) {
|
|
169
|
-
// No bandwidth estimate yet: use initial RTT / 10
|
|
170
|
-
return Math.max(0.5, this.config.initialRttMs / 10);
|
|
171
|
-
}
|
|
172
|
-
// Pacing interval = packetSize / (btlBw * pacingGain)
|
|
173
|
-
const pacingRate = btlBw * pacingGain;
|
|
174
|
-
const interval = (packetSize / pacingRate) * 1000; // convert to ms
|
|
175
|
-
return Math.max(0.1, interval);
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Update BBR state machine with a new delivery sample.
|
|
179
|
-
*/
|
|
180
|
-
updateBBR(bytesDelivered, rttSample) {
|
|
181
|
-
const now = Date.now();
|
|
182
|
-
// Update bottleneck bandwidth estimate
|
|
183
|
-
const deliveryRate = bytesDelivered / (rttSample / 1000);
|
|
184
|
-
this.metrics.deliveryRate = deliveryRate;
|
|
185
|
-
if (deliveryRate > this.bbrState.btlBw) {
|
|
186
|
-
this.bbrState.btlBw = deliveryRate;
|
|
187
|
-
}
|
|
188
|
-
// Update min RTT (rt_prop)
|
|
189
|
-
if (rttSample < this.bbrState.rtProp || now > this.bbrState.rtPropExpiry) {
|
|
190
|
-
this.bbrState.rtProp = rttSample;
|
|
191
|
-
this.bbrState.rtPropExpiry = now + 10000; // 10s window
|
|
192
|
-
}
|
|
193
|
-
// State machine transitions
|
|
194
|
-
switch (this.bbrState.mode) {
|
|
195
|
-
case 'startup':
|
|
196
|
-
this.bbrState.pacingGain = 2.885;
|
|
197
|
-
this.bbrState.cwndGain = 2.0;
|
|
198
|
-
if (deliveryRate <= this.bbrState.lastBw * 1.25) {
|
|
199
|
-
this.bbrState.fullBwCount++;
|
|
200
|
-
if (this.bbrState.fullBwCount >= 3) {
|
|
201
|
-
this.bbrState.fullBwReached = true;
|
|
202
|
-
this.bbrState.mode = 'drain';
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
this.bbrState.fullBwCount = 0;
|
|
207
|
-
this.bbrState.lastBw = deliveryRate;
|
|
208
|
-
}
|
|
209
|
-
break;
|
|
210
|
-
case 'drain':
|
|
211
|
-
this.bbrState.pacingGain = 1 / 2.885;
|
|
212
|
-
this.bbrState.cwndGain = 2.0;
|
|
213
|
-
if (this.metrics.bytesInFlight <= this.computeBDP()) {
|
|
214
|
-
this.bbrState.mode = 'probe_bw';
|
|
215
|
-
this.bbrState.cycleIndex = 0;
|
|
216
|
-
}
|
|
217
|
-
break;
|
|
218
|
-
case 'probe_bw': {
|
|
219
|
-
const pacingGains = [1.25, 0.75, 1, 1, 1, 1, 1, 1];
|
|
220
|
-
this.bbrState.pacingGain = pacingGains[this.bbrState.cycleIndex % pacingGains.length];
|
|
221
|
-
this.bbrState.cwndGain = 2.0;
|
|
222
|
-
this.bbrState.cycleIndex++;
|
|
223
|
-
break;
|
|
224
|
-
}
|
|
225
|
-
case 'probe_rtt':
|
|
226
|
-
this.bbrState.cwndGain = 1.0;
|
|
227
|
-
this.bbrState.pacingGain = 1.0;
|
|
228
|
-
if (now > this.bbrState.rtPropExpiry) {
|
|
229
|
-
this.bbrState.mode = 'probe_bw';
|
|
230
|
-
}
|
|
231
|
-
break;
|
|
232
|
-
}
|
|
233
|
-
// Update congestion window
|
|
234
|
-
this.metrics.congestionWindow = Math.max(4 * 1200, // minimum 4 packets
|
|
235
|
-
this.computeBDP() * this.bbrState.cwndGain);
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Compute Bandwidth-Delay Product.
|
|
239
|
-
*/
|
|
240
|
-
computeBDP() {
|
|
241
|
-
return this.bbrState.btlBw * (this.bbrState.rtProp / 1000);
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Update smoothed RTT using exponential weighted moving average.
|
|
245
|
-
*/
|
|
246
|
-
updateSmoothedRtt(sample) {
|
|
247
|
-
const alpha = 0.125;
|
|
248
|
-
const beta = 0.25;
|
|
249
|
-
if (this.metrics.smoothedRttMs === 0) {
|
|
250
|
-
this.metrics.smoothedRttMs = sample;
|
|
251
|
-
this.metrics.rttVariance = sample / 2;
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
this.metrics.rttVariance = (1 - beta) * this.metrics.rttVariance +
|
|
255
|
-
beta * Math.abs(this.metrics.smoothedRttMs - sample);
|
|
256
|
-
this.metrics.smoothedRttMs = (1 - alpha) * this.metrics.smoothedRttMs +
|
|
257
|
-
alpha * sample;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
generateSessionTicket() {
|
|
261
|
-
return {
|
|
262
|
-
data: new Uint8Array(32).map(() => Math.floor(Math.random() * 256)),
|
|
263
|
-
issuedAt: Date.now(),
|
|
264
|
-
expiresAt: Date.now() + QUICConnection.TICKET_LIFETIME_MS,
|
|
265
|
-
serverName: this.config.endpoint,
|
|
266
|
-
alpn: 'h3',
|
|
267
|
-
maxEarlyData: 16384,
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
initBBR() {
|
|
271
|
-
return {
|
|
272
|
-
mode: 'startup',
|
|
273
|
-
btlBw: 0,
|
|
274
|
-
rtProp: Infinity,
|
|
275
|
-
rtPropExpiry: 0,
|
|
276
|
-
cwndGain: 2.0,
|
|
277
|
-
pacingGain: 2.885,
|
|
278
|
-
cycleIndex: 0,
|
|
279
|
-
fullBwReached: false,
|
|
280
|
-
fullBwCount: 0,
|
|
281
|
-
lastBw: 0,
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
initMetrics() {
|
|
285
|
-
return {
|
|
286
|
-
rttMs: 0,
|
|
287
|
-
smoothedRttMs: 0,
|
|
288
|
-
rttVariance: 0,
|
|
289
|
-
bytesInFlight: 0,
|
|
290
|
-
congestionWindow: 10 * 1200,
|
|
291
|
-
deliveryRate: 0,
|
|
292
|
-
packetsLost: 0,
|
|
293
|
-
packetsSent: 0,
|
|
294
|
-
packetsAcked: 0,
|
|
295
|
-
zeroRttUsed: false,
|
|
296
|
-
handshakeTimeMs: 0,
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
// -- Accessors --
|
|
300
|
-
getId() { return this.id; }
|
|
301
|
-
isConnected() { return this.connected; }
|
|
302
|
-
isBusy() { return this.busy; }
|
|
303
|
-
getEndpoint() { return this.config.endpoint; }
|
|
304
|
-
getCurrentPath() { return this.currentPath; }
|
|
305
|
-
getCreatedAt() { return this.createdAt; }
|
|
306
|
-
getLastActiveAt() { return this.lastActiveAt; }
|
|
307
|
-
getMigrationCount() { return this.migrationCount; }
|
|
308
|
-
getMetrics() { return { ...this.metrics }; }
|
|
309
|
-
getBBRMode() { return this.bbrState.mode; }
|
|
310
|
-
hasSessionTicket() {
|
|
311
|
-
return QUICConnection.ticketCache.has(this.config.endpoint);
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Clear session ticket cache (for testing or security reset).
|
|
315
|
-
*/
|
|
316
|
-
static clearTicketCache() {
|
|
317
|
-
QUICConnection.ticketCache.clear();
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Get the number of cached session tickets.
|
|
321
|
-
*/
|
|
322
|
-
static getTicketCacheSize() {
|
|
323
|
-
return QUICConnection.ticketCache.size;
|
|
324
|
-
}
|
|
325
|
-
sleep(ms) {
|
|
326
|
-
return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
//# sourceMappingURL=QUICConnection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QUICConnection.js","sourceRoot":"","sources":["../../../src/controllers/QUICConnection.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA+CH,MAAM,OAAO,cAAc;IACjB,MAAM,CAAiC;IACvC,SAAS,GAAY,KAAK,CAAC;IAC3B,IAAI,GAAY,KAAK,CAAC;IACtB,aA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maximum pool size of 10 connections per endpoint
|
|
6
|
-
* - Connection reuse with idle detection
|
|
7
|
-
* - Automatic cleanup of stale/expired connections
|
|
8
|
-
* - Pool-level statistics and health monitoring
|
|
9
|
-
* - Graceful drain and shutdown
|
|
10
|
-
*/
|
|
11
|
-
import { QUICConnection } from './QUICConnection.js';
|
|
12
|
-
export interface PoolConfig {
|
|
13
|
-
maxPoolSize?: number;
|
|
14
|
-
maxIdleTimeMs?: number;
|
|
15
|
-
acquireTimeoutMs?: number;
|
|
16
|
-
enableZeroRTT?: boolean;
|
|
17
|
-
congestionControl?: 'bbr' | 'cubic' | 'reno';
|
|
18
|
-
healthCheckIntervalMs?: number;
|
|
19
|
-
}
|
|
20
|
-
export interface PoolStats {
|
|
21
|
-
endpoint: string;
|
|
22
|
-
totalConnections: number;
|
|
23
|
-
activeConnections: number;
|
|
24
|
-
idleConnections: number;
|
|
25
|
-
totalAcquired: number;
|
|
26
|
-
totalReleased: number;
|
|
27
|
-
totalCreated: number;
|
|
28
|
-
totalDestroyed: number;
|
|
29
|
-
avgAcquireTimeMs: number;
|
|
30
|
-
avgRttMs: number;
|
|
31
|
-
zeroRttHits: number;
|
|
32
|
-
zeroRttMisses: number;
|
|
33
|
-
}
|
|
34
|
-
export declare class QUICConnectionPool {
|
|
35
|
-
private pools;
|
|
36
|
-
private config;
|
|
37
|
-
private stats;
|
|
38
|
-
private cleanupTimer;
|
|
39
|
-
constructor(config?: PoolConfig);
|
|
40
|
-
/**
|
|
41
|
-
* Acquire a connection from the pool.
|
|
42
|
-
* Reuses idle connections or creates new ones up to maxPoolSize.
|
|
43
|
-
*/
|
|
44
|
-
getConnection(endpoint: string): Promise<QUICConnection>;
|
|
45
|
-
/**
|
|
46
|
-
* Release a connection back to the pool (mark as not busy).
|
|
47
|
-
* The connection stays in the pool for reuse.
|
|
48
|
-
*/
|
|
49
|
-
releaseConnection(conn: QUICConnection): void;
|
|
50
|
-
/**
|
|
51
|
-
* Remove a specific connection from the pool and disconnect it.
|
|
52
|
-
*/
|
|
53
|
-
removeConnection(conn: QUICConnection): Promise<void>;
|
|
54
|
-
/**
|
|
55
|
-
* Get pool statistics for a specific endpoint.
|
|
56
|
-
*/
|
|
57
|
-
getPoolStats(endpoint: string): PoolStats;
|
|
58
|
-
/**
|
|
59
|
-
* Get stats for all endpoints.
|
|
60
|
-
*/
|
|
61
|
-
getAllPoolStats(): PoolStats[];
|
|
62
|
-
/**
|
|
63
|
-
* Get total number of connections across all pools.
|
|
64
|
-
*/
|
|
65
|
-
getTotalConnections(): number;
|
|
66
|
-
/**
|
|
67
|
-
* Drain and close all connections for an endpoint.
|
|
68
|
-
*/
|
|
69
|
-
drainEndpoint(endpoint: string): Promise<number>;
|
|
70
|
-
/**
|
|
71
|
-
* Drain and close ALL connections.
|
|
72
|
-
*/
|
|
73
|
-
shutdown(): Promise<number>;
|
|
74
|
-
/**
|
|
75
|
-
* Remove idle connections that exceed maxIdleTimeMs.
|
|
76
|
-
*/
|
|
77
|
-
cleanup(): Promise<number>;
|
|
78
|
-
private createConnection;
|
|
79
|
-
private waitForAvailableConnection;
|
|
80
|
-
private ensureStats;
|
|
81
|
-
private startCleanup;
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=QUICConnectionPool.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QUICConnectionPool.d.ts","sourceRoot":"","sources":["../../../src/controllers/QUICConnectionPool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,cAAc,EAA2C,MAAM,qBAAqB,CAAC;AAE9F,MAAM,WAAW,UAAU;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iBAAiB,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;IAC7C,qBAAqB,CAA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IAcnB,OAAO,CAAC,YAAY;CAUrB"}
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* QUICConnectionPool - Connection Pooling for QUIC Protocol
|
|
3
|
-
*
|
|
4
|
-
* Manages a pool of QUICConnection instances for efficient reuse:
|
|
5
|
-
* - Maximum pool size of 10 connections per endpoint
|
|
6
|
-
* - Connection reuse with idle detection
|
|
7
|
-
* - Automatic cleanup of stale/expired connections
|
|
8
|
-
* - Pool-level statistics and health monitoring
|
|
9
|
-
* - Graceful drain and shutdown
|
|
10
|
-
*/
|
|
11
|
-
import { QUICConnection } from './QUICConnection.js';
|
|
12
|
-
export class QUICConnectionPool {
|
|
13
|
-
pools = new Map();
|
|
14
|
-
config;
|
|
15
|
-
stats = new Map();
|
|
16
|
-
cleanupTimer = null;
|
|
17
|
-
constructor(config) {
|
|
18
|
-
this.config = {
|
|
19
|
-
maxPoolSize: config?.maxPoolSize ?? 10,
|
|
20
|
-
maxIdleTimeMs: config?.maxIdleTimeMs ?? 60000,
|
|
21
|
-
acquireTimeoutMs: config?.acquireTimeoutMs ?? 10000,
|
|
22
|
-
enableZeroRTT: config?.enableZeroRTT ?? true,
|
|
23
|
-
congestionControl: config?.congestionControl ?? 'bbr',
|
|
24
|
-
healthCheckIntervalMs: config?.healthCheckIntervalMs ?? 30000,
|
|
25
|
-
};
|
|
26
|
-
this.startCleanup();
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Acquire a connection from the pool.
|
|
30
|
-
* Reuses idle connections or creates new ones up to maxPoolSize.
|
|
31
|
-
*/
|
|
32
|
-
async getConnection(endpoint) {
|
|
33
|
-
const startTime = performance.now();
|
|
34
|
-
this.ensureStats(endpoint);
|
|
35
|
-
const poolStats = this.stats.get(endpoint);
|
|
36
|
-
const pool = this.pools.get(endpoint) || [];
|
|
37
|
-
this.pools.set(endpoint, pool);
|
|
38
|
-
// Try to reuse an idle connection
|
|
39
|
-
for (const conn of pool) {
|
|
40
|
-
if (!conn.isBusy() && conn.isConnected()) {
|
|
41
|
-
poolStats.totalAcquired++;
|
|
42
|
-
poolStats.acquireTimesMs.push(performance.now() - startTime);
|
|
43
|
-
return conn;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
// Create a new connection if pool is not full
|
|
47
|
-
if (pool.length < this.config.maxPoolSize) {
|
|
48
|
-
const conn = await this.createConnection(endpoint);
|
|
49
|
-
pool.push(conn);
|
|
50
|
-
poolStats.totalCreated++;
|
|
51
|
-
poolStats.totalAcquired++;
|
|
52
|
-
// Track 0-RTT usage
|
|
53
|
-
const metrics = conn.getMetrics();
|
|
54
|
-
if (metrics.zeroRttUsed) {
|
|
55
|
-
poolStats.zeroRttHits++;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
poolStats.zeroRttMisses++;
|
|
59
|
-
}
|
|
60
|
-
poolStats.acquireTimesMs.push(performance.now() - startTime);
|
|
61
|
-
return conn;
|
|
62
|
-
}
|
|
63
|
-
// Pool is full: wait for an available connection
|
|
64
|
-
return this.waitForAvailableConnection(endpoint, startTime);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Release a connection back to the pool (mark as not busy).
|
|
68
|
-
* The connection stays in the pool for reuse.
|
|
69
|
-
*/
|
|
70
|
-
releaseConnection(conn) {
|
|
71
|
-
const endpoint = conn.getEndpoint();
|
|
72
|
-
this.ensureStats(endpoint);
|
|
73
|
-
this.stats.get(endpoint).totalReleased++;
|
|
74
|
-
// Connection automatically becomes non-busy after send completes
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Remove a specific connection from the pool and disconnect it.
|
|
78
|
-
*/
|
|
79
|
-
async removeConnection(conn) {
|
|
80
|
-
const endpoint = conn.getEndpoint();
|
|
81
|
-
const pool = this.pools.get(endpoint);
|
|
82
|
-
if (!pool)
|
|
83
|
-
return;
|
|
84
|
-
const idx = pool.indexOf(conn);
|
|
85
|
-
if (idx !== -1) {
|
|
86
|
-
pool.splice(idx, 1);
|
|
87
|
-
await conn.disconnect();
|
|
88
|
-
this.ensureStats(endpoint);
|
|
89
|
-
this.stats.get(endpoint).totalDestroyed++;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Get pool statistics for a specific endpoint.
|
|
94
|
-
*/
|
|
95
|
-
getPoolStats(endpoint) {
|
|
96
|
-
const pool = this.pools.get(endpoint) || [];
|
|
97
|
-
this.ensureStats(endpoint);
|
|
98
|
-
const s = this.stats.get(endpoint);
|
|
99
|
-
const activeConnections = pool.filter(c => c.isBusy()).length;
|
|
100
|
-
const idleConnections = pool.filter(c => !c.isBusy() && c.isConnected()).length;
|
|
101
|
-
const avgAcquire = s.acquireTimesMs.length > 0
|
|
102
|
-
? s.acquireTimesMs.reduce((a, b) => a + b, 0) / s.acquireTimesMs.length
|
|
103
|
-
: 0;
|
|
104
|
-
const rttValues = pool
|
|
105
|
-
.filter(c => c.isConnected())
|
|
106
|
-
.map(c => c.getMetrics().smoothedRttMs)
|
|
107
|
-
.filter(r => r > 0);
|
|
108
|
-
const avgRtt = rttValues.length > 0
|
|
109
|
-
? rttValues.reduce((a, b) => a + b, 0) / rttValues.length
|
|
110
|
-
: 0;
|
|
111
|
-
return {
|
|
112
|
-
endpoint,
|
|
113
|
-
totalConnections: pool.length,
|
|
114
|
-
activeConnections,
|
|
115
|
-
idleConnections,
|
|
116
|
-
totalAcquired: s.totalAcquired,
|
|
117
|
-
totalReleased: s.totalReleased,
|
|
118
|
-
totalCreated: s.totalCreated,
|
|
119
|
-
totalDestroyed: s.totalDestroyed,
|
|
120
|
-
avgAcquireTimeMs: Number(avgAcquire.toFixed(3)),
|
|
121
|
-
avgRttMs: Number(avgRtt.toFixed(3)),
|
|
122
|
-
zeroRttHits: s.zeroRttHits,
|
|
123
|
-
zeroRttMisses: s.zeroRttMisses,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Get stats for all endpoints.
|
|
128
|
-
*/
|
|
129
|
-
getAllPoolStats() {
|
|
130
|
-
return Array.from(this.pools.keys()).map(ep => this.getPoolStats(ep));
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Get total number of connections across all pools.
|
|
134
|
-
*/
|
|
135
|
-
getTotalConnections() {
|
|
136
|
-
let total = 0;
|
|
137
|
-
for (const pool of this.pools.values()) {
|
|
138
|
-
total += pool.length;
|
|
139
|
-
}
|
|
140
|
-
return total;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Drain and close all connections for an endpoint.
|
|
144
|
-
*/
|
|
145
|
-
async drainEndpoint(endpoint) {
|
|
146
|
-
const pool = this.pools.get(endpoint);
|
|
147
|
-
if (!pool)
|
|
148
|
-
return 0;
|
|
149
|
-
let closed = 0;
|
|
150
|
-
for (const conn of pool) {
|
|
151
|
-
await conn.disconnect();
|
|
152
|
-
closed++;
|
|
153
|
-
}
|
|
154
|
-
this.pools.delete(endpoint);
|
|
155
|
-
this.ensureStats(endpoint);
|
|
156
|
-
this.stats.get(endpoint).totalDestroyed += closed;
|
|
157
|
-
return closed;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Drain and close ALL connections.
|
|
161
|
-
*/
|
|
162
|
-
async shutdown() {
|
|
163
|
-
let total = 0;
|
|
164
|
-
for (const endpoint of Array.from(this.pools.keys())) {
|
|
165
|
-
total += await this.drainEndpoint(endpoint);
|
|
166
|
-
}
|
|
167
|
-
if (this.cleanupTimer) {
|
|
168
|
-
clearInterval(this.cleanupTimer);
|
|
169
|
-
this.cleanupTimer = null;
|
|
170
|
-
}
|
|
171
|
-
return total;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Remove idle connections that exceed maxIdleTimeMs.
|
|
175
|
-
*/
|
|
176
|
-
async cleanup() {
|
|
177
|
-
const now = Date.now();
|
|
178
|
-
let cleaned = 0;
|
|
179
|
-
for (const [endpoint, pool] of this.pools.entries()) {
|
|
180
|
-
const toRemove = [];
|
|
181
|
-
for (const conn of pool) {
|
|
182
|
-
if (!conn.isBusy() && (now - conn.getLastActiveAt()) > this.config.maxIdleTimeMs) {
|
|
183
|
-
toRemove.push(conn);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
for (const conn of toRemove) {
|
|
187
|
-
const idx = pool.indexOf(conn);
|
|
188
|
-
if (idx !== -1) {
|
|
189
|
-
pool.splice(idx, 1);
|
|
190
|
-
await conn.disconnect();
|
|
191
|
-
cleaned++;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
this.ensureStats(endpoint);
|
|
195
|
-
this.stats.get(endpoint).totalDestroyed += toRemove.length;
|
|
196
|
-
// Remove empty pools
|
|
197
|
-
if (pool.length === 0) {
|
|
198
|
-
this.pools.delete(endpoint);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return cleaned;
|
|
202
|
-
}
|
|
203
|
-
// -- Private helpers --
|
|
204
|
-
async createConnection(endpoint) {
|
|
205
|
-
const connConfig = {
|
|
206
|
-
endpoint,
|
|
207
|
-
enableZeroRTT: this.config.enableZeroRTT,
|
|
208
|
-
enableMultipath: false,
|
|
209
|
-
congestionControl: this.config.congestionControl,
|
|
210
|
-
};
|
|
211
|
-
const conn = new QUICConnection(connConfig);
|
|
212
|
-
await conn.connect();
|
|
213
|
-
return conn;
|
|
214
|
-
}
|
|
215
|
-
async waitForAvailableConnection(endpoint, startTime) {
|
|
216
|
-
const deadline = startTime + this.config.acquireTimeoutMs;
|
|
217
|
-
while (performance.now() < deadline) {
|
|
218
|
-
const pool = this.pools.get(endpoint) || [];
|
|
219
|
-
for (const conn of pool) {
|
|
220
|
-
if (!conn.isBusy() && conn.isConnected()) {
|
|
221
|
-
this.ensureStats(endpoint);
|
|
222
|
-
const s = this.stats.get(endpoint);
|
|
223
|
-
s.totalAcquired++;
|
|
224
|
-
s.acquireTimesMs.push(performance.now() - startTime);
|
|
225
|
-
return conn;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
await new Promise(resolve => setTimeout(resolve, 5));
|
|
229
|
-
}
|
|
230
|
-
throw new Error(`Connection pool exhausted for ${endpoint} ` +
|
|
231
|
-
`(max: ${this.config.maxPoolSize}, timeout: ${this.config.acquireTimeoutMs}ms)`);
|
|
232
|
-
}
|
|
233
|
-
ensureStats(endpoint) {
|
|
234
|
-
if (!this.stats.has(endpoint)) {
|
|
235
|
-
this.stats.set(endpoint, {
|
|
236
|
-
totalAcquired: 0,
|
|
237
|
-
totalReleased: 0,
|
|
238
|
-
totalCreated: 0,
|
|
239
|
-
totalDestroyed: 0,
|
|
240
|
-
acquireTimesMs: [],
|
|
241
|
-
zeroRttHits: 0,
|
|
242
|
-
zeroRttMisses: 0,
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
startCleanup() {
|
|
247
|
-
this.cleanupTimer = setInterval(() => {
|
|
248
|
-
this.cleanup().catch(() => { });
|
|
249
|
-
}, this.config.healthCheckIntervalMs);
|
|
250
|
-
// Avoid keeping the process alive just for cleanup
|
|
251
|
-
if (this.cleanupTimer && typeof this.cleanupTimer === 'object' && 'unref' in this.cleanupTimer) {
|
|
252
|
-
this.cleanupTimer.unref();
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
//# sourceMappingURL=QUICConnectionPool.js.map
|