agentdb 1.6.0 → 2.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1098 -350
- package/dist/agentdb-advanced.js +2110 -0
- package/dist/agentdb-advanced.min.js +1 -0
- package/dist/agentdb.min.js +4 -4
- package/dist/backends/GraphBackend.d.ts +196 -0
- package/dist/backends/GraphBackend.d.ts.map +1 -0
- package/dist/backends/GraphBackend.js +33 -0
- package/dist/backends/GraphBackend.js.map +1 -0
- package/dist/backends/LearningBackend.d.ts +148 -0
- package/dist/backends/LearningBackend.d.ts.map +1 -0
- package/dist/backends/LearningBackend.js +27 -0
- package/dist/backends/LearningBackend.js.map +1 -0
- package/dist/backends/VectorBackend.d.ts +119 -0
- package/dist/backends/VectorBackend.d.ts.map +1 -0
- package/dist/backends/VectorBackend.js +14 -0
- package/dist/backends/VectorBackend.js.map +1 -0
- package/dist/backends/detector.d.ts +81 -0
- package/dist/backends/detector.d.ts.map +1 -0
- package/dist/backends/detector.js +192 -0
- package/dist/backends/detector.js.map +1 -0
- package/dist/backends/factory.d.ts +50 -0
- package/dist/backends/factory.d.ts.map +1 -0
- package/dist/backends/factory.js +161 -0
- package/dist/backends/factory.js.map +1 -0
- package/dist/backends/graph/GraphDatabaseAdapter.d.ts +139 -0
- package/dist/backends/graph/GraphDatabaseAdapter.d.ts.map +1 -0
- package/dist/backends/graph/GraphDatabaseAdapter.js +194 -0
- package/dist/backends/graph/GraphDatabaseAdapter.js.map +1 -0
- package/dist/backends/hnswlib/HNSWLibBackend.d.ts +92 -0
- package/dist/backends/hnswlib/HNSWLibBackend.d.ts.map +1 -0
- package/dist/backends/hnswlib/HNSWLibBackend.js +316 -0
- package/dist/backends/hnswlib/HNSWLibBackend.js.map +1 -0
- package/dist/backends/hnswlib/index.d.ts +7 -0
- package/dist/backends/hnswlib/index.d.ts.map +1 -0
- package/dist/backends/hnswlib/index.js +7 -0
- package/dist/backends/hnswlib/index.js.map +1 -0
- package/dist/backends/index.d.ts +14 -0
- package/dist/backends/index.d.ts.map +1 -0
- package/dist/backends/index.js +13 -0
- package/dist/backends/index.js.map +1 -0
- package/dist/backends/ruvector/RuVectorBackend.d.ts +75 -0
- package/dist/backends/ruvector/RuVectorBackend.d.ts.map +1 -0
- package/dist/backends/ruvector/RuVectorBackend.js +198 -0
- package/dist/backends/ruvector/RuVectorBackend.js.map +1 -0
- package/dist/backends/ruvector/RuVectorLearning.d.ts +104 -0
- package/dist/backends/ruvector/RuVectorLearning.d.ts.map +1 -0
- package/dist/backends/ruvector/RuVectorLearning.js +177 -0
- package/dist/backends/ruvector/RuVectorLearning.js.map +1 -0
- package/dist/backends/ruvector/index.d.ts +9 -0
- package/dist/backends/ruvector/index.d.ts.map +1 -0
- package/dist/backends/ruvector/index.js +8 -0
- package/dist/backends/ruvector/index.js.map +1 -0
- package/dist/browser/AdvancedFeatures.d.ts +144 -0
- package/dist/browser/AdvancedFeatures.d.ts.map +1 -0
- package/dist/browser/AdvancedFeatures.js +430 -0
- package/dist/browser/AdvancedFeatures.js.map +1 -0
- package/dist/browser/HNSWIndex.d.ts +117 -0
- package/dist/browser/HNSWIndex.d.ts.map +1 -0
- package/dist/browser/HNSWIndex.js +402 -0
- package/dist/browser/HNSWIndex.js.map +1 -0
- package/dist/browser/ProductQuantization.d.ts +107 -0
- package/dist/browser/ProductQuantization.d.ts.map +1 -0
- package/dist/browser/ProductQuantization.js +337 -0
- package/dist/browser/ProductQuantization.js.map +1 -0
- package/dist/browser/browser/AdvancedFeatures.d.ts +144 -0
- package/dist/browser/browser/AdvancedFeatures.d.ts.map +1 -0
- package/dist/browser/browser/AdvancedFeatures.js +427 -0
- package/dist/browser/browser/HNSWIndex.d.ts +117 -0
- package/dist/browser/browser/HNSWIndex.d.ts.map +1 -0
- package/dist/browser/browser/HNSWIndex.js +402 -0
- package/dist/browser/browser/ProductQuantization.d.ts +107 -0
- package/dist/browser/browser/ProductQuantization.d.ts.map +1 -0
- package/dist/browser/browser/ProductQuantization.js +348 -0
- package/dist/browser/browser/index.d.ts +223 -0
- package/dist/browser/browser/index.d.ts.map +1 -0
- package/dist/browser/browser/index.js +233 -0
- package/dist/browser/index.d.ts +223 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +225 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/cli/agentdb-cli.d.ts.map +1 -1
- package/dist/cli/agentdb-cli.js +130 -8
- package/dist/cli/agentdb-cli.js.map +1 -1
- package/dist/cli/agentdb.db +0 -0
- package/dist/cli/commands/init.d.ts +12 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +115 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/install-embeddings.d.ts +10 -0
- package/dist/cli/commands/install-embeddings.d.ts.map +1 -0
- package/dist/cli/commands/install-embeddings.js +68 -0
- package/dist/cli/commands/install-embeddings.js.map +1 -0
- package/dist/cli/commands/migrate.d.ts +15 -0
- package/dist/cli/commands/migrate.d.ts.map +1 -0
- package/dist/cli/commands/migrate.js +425 -0
- package/dist/cli/commands/migrate.js.map +1 -0
- package/dist/cli/commands/status.d.ts +10 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +129 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/controllers/CausalRecall.d.ts +3 -1
- package/dist/controllers/CausalRecall.d.ts.map +1 -1
- package/dist/controllers/CausalRecall.js +35 -4
- package/dist/controllers/CausalRecall.js.map +1 -1
- package/dist/controllers/ExplainableRecall.d.ts +24 -0
- package/dist/controllers/ExplainableRecall.d.ts.map +1 -1
- package/dist/controllers/ExplainableRecall.js +102 -5
- package/dist/controllers/ExplainableRecall.js.map +1 -1
- package/dist/controllers/HNSWIndex.d.ts +128 -0
- package/dist/controllers/HNSWIndex.d.ts.map +1 -0
- package/dist/controllers/HNSWIndex.js +361 -0
- package/dist/controllers/HNSWIndex.js.map +1 -0
- package/dist/controllers/NightlyLearner.d.ts.map +1 -1
- package/dist/controllers/NightlyLearner.js +7 -4
- package/dist/controllers/NightlyLearner.js.map +1 -1
- package/dist/controllers/ReasoningBank.d.ts +101 -2
- package/dist/controllers/ReasoningBank.d.ts.map +1 -1
- package/dist/controllers/ReasoningBank.js +196 -4
- package/dist/controllers/ReasoningBank.js.map +1 -1
- package/dist/controllers/ReflexionMemory.d.ts +41 -1
- package/dist/controllers/ReflexionMemory.d.ts.map +1 -1
- package/dist/controllers/ReflexionMemory.js +282 -5
- package/dist/controllers/ReflexionMemory.js.map +1 -1
- package/dist/controllers/SkillLibrary.d.ts +27 -9
- package/dist/controllers/SkillLibrary.d.ts.map +1 -1
- package/dist/controllers/SkillLibrary.js +136 -47
- package/dist/controllers/SkillLibrary.js.map +1 -1
- package/dist/controllers/index.d.ts +2 -0
- package/dist/controllers/index.d.ts.map +1 -1
- package/dist/controllers/index.js +1 -0
- package/dist/controllers/index.js.map +1 -1
- package/dist/db-fallback.d.ts.map +1 -1
- package/dist/db-fallback.js +100 -29
- package/dist/db-fallback.js.map +1 -1
- package/dist/db-test.d.ts +13 -0
- package/dist/db-test.d.ts.map +1 -0
- package/dist/db-test.js +55 -0
- package/dist/db-test.js.map +1 -0
- package/dist/db-unified.d.ts +76 -0
- package/dist/db-unified.d.ts.map +1 -0
- package/dist/db-unified.js +278 -0
- package/dist/db-unified.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/malp/core/ccc.d.ts +99 -0
- package/dist/malp/core/ccc.d.ts.map +1 -0
- package/dist/malp/core/ccc.js +181 -0
- package/dist/malp/core/ccc.js.map +1 -0
- package/dist/malp/core/index.d.ts +9 -0
- package/dist/malp/core/index.d.ts.map +1 -0
- package/dist/malp/core/index.js +9 -0
- package/dist/malp/core/index.js.map +1 -0
- package/dist/malp/core/linalg.d.ts +101 -0
- package/dist/malp/core/linalg.d.ts.map +1 -0
- package/dist/malp/core/linalg.js +278 -0
- package/dist/malp/core/linalg.js.map +1 -0
- package/dist/malp/core/optimizer.d.ts +68 -0
- package/dist/malp/core/optimizer.d.ts.map +1 -0
- package/dist/malp/core/optimizer.js +160 -0
- package/dist/malp/core/optimizer.js.map +1 -0
- package/dist/malp/index.d.ts +33 -0
- package/dist/malp/index.d.ts.map +1 -0
- package/dist/malp/index.js +37 -0
- package/dist/malp/index.js.map +1 -0
- package/dist/malp/metrics/agreement.d.ts +106 -0
- package/dist/malp/metrics/agreement.d.ts.map +1 -0
- package/dist/malp/metrics/agreement.js +199 -0
- package/dist/malp/metrics/agreement.js.map +1 -0
- package/dist/malp/metrics/comparison.d.ts +93 -0
- package/dist/malp/metrics/comparison.d.ts.map +1 -0
- package/dist/malp/metrics/comparison.js +256 -0
- package/dist/malp/metrics/comparison.js.map +1 -0
- package/dist/malp/metrics/index.d.ts +8 -0
- package/dist/malp/metrics/index.d.ts.map +1 -0
- package/dist/malp/metrics/index.js +8 -0
- package/dist/malp/metrics/index.js.map +1 -0
- package/dist/malp/metrics/performance.d.ts +61 -0
- package/dist/malp/metrics/performance.d.ts.map +1 -0
- package/dist/malp/metrics/performance.js +190 -0
- package/dist/malp/metrics/performance.js.map +1 -0
- package/dist/malp/models/index.d.ts +7 -0
- package/dist/malp/models/index.d.ts.map +1 -0
- package/dist/malp/models/index.js +7 -0
- package/dist/malp/models/index.js.map +1 -0
- package/dist/malp/models/malp.d.ts +116 -0
- package/dist/malp/models/malp.d.ts.map +1 -0
- package/dist/malp/models/malp.js +206 -0
- package/dist/malp/models/malp.js.map +1 -0
- package/dist/malp/models/regressor.d.ts +80 -0
- package/dist/malp/models/regressor.d.ts.map +1 -0
- package/dist/malp/models/regressor.js +229 -0
- package/dist/malp/models/regressor.js.map +1 -0
- package/dist/malp/reasoningbank_validator.d.ts +187 -0
- package/dist/malp/reasoningbank_validator.d.ts.map +1 -0
- package/dist/malp/reasoningbank_validator.js +246 -0
- package/dist/malp/reasoningbank_validator.js.map +1 -0
- package/dist/malp/wasm_bindings.d.ts +344 -0
- package/dist/malp/wasm_bindings.d.ts.map +1 -0
- package/dist/malp/wasm_bindings.js +9 -0
- package/dist/malp/wasm_bindings.js.map +1 -0
- package/dist/mcp/agentdb-mcp-server.js +512 -33
- package/dist/mcp/agentdb-mcp-server.js.map +1 -1
- package/dist/optimizations/BatchOperations.d.ts +42 -0
- package/dist/optimizations/BatchOperations.d.ts.map +1 -1
- package/dist/optimizations/BatchOperations.js +181 -0
- package/dist/optimizations/BatchOperations.js.map +1 -1
- package/dist/optimizations/ToolCache.d.ts +137 -0
- package/dist/optimizations/ToolCache.d.ts.map +1 -0
- package/dist/optimizations/ToolCache.js +281 -0
- package/dist/optimizations/ToolCache.js.map +1 -0
- package/dist/security/input-validation.d.ts +24 -0
- package/dist/security/input-validation.d.ts.map +1 -1
- package/dist/security/input-validation.js +106 -0
- package/dist/security/input-validation.js.map +1 -1
- package/dist/security/limits.d.ts +150 -0
- package/dist/security/limits.d.ts.map +1 -0
- package/dist/security/limits.js +288 -0
- package/dist/security/limits.js.map +1 -0
- package/dist/security/path-security.d.ts +100 -0
- package/dist/security/path-security.d.ts.map +1 -0
- package/dist/security/path-security.js +337 -0
- package/dist/security/path-security.js.map +1 -0
- package/dist/security/validation.d.ts +95 -0
- package/dist/security/validation.d.ts.map +1 -0
- package/dist/security/validation.js +315 -0
- package/dist/security/validation.js.map +1 -0
- package/dist/simulation/cli.d.ts +9 -0
- package/dist/simulation/cli.d.ts.map +1 -0
- package/dist/simulation/cli.js +68 -0
- package/dist/simulation/cli.js.map +1 -0
- package/dist/simulation/runner.d.ts +21 -0
- package/dist/simulation/runner.d.ts.map +1 -0
- package/dist/simulation/runner.js +241 -0
- package/dist/simulation/runner.js.map +1 -0
- package/dist/simulation/scenarios/aidefence-integration.d.ts +24 -0
- package/dist/simulation/scenarios/aidefence-integration.d.ts.map +1 -0
- package/dist/simulation/scenarios/aidefence-integration.js +124 -0
- package/dist/simulation/scenarios/aidefence-integration.js.map +1 -0
- package/dist/simulation/scenarios/bmssp-integration.d.ts +23 -0
- package/dist/simulation/scenarios/bmssp-integration.d.ts.map +1 -0
- package/dist/simulation/scenarios/bmssp-integration.js +104 -0
- package/dist/simulation/scenarios/bmssp-integration.js.map +1 -0
- package/dist/simulation/scenarios/causal-reasoning.d.ts +16 -0
- package/dist/simulation/scenarios/causal-reasoning.d.ts.map +1 -0
- package/dist/simulation/scenarios/causal-reasoning.js +108 -0
- package/dist/simulation/scenarios/causal-reasoning.js.map +1 -0
- package/dist/simulation/scenarios/consciousness-explorer.d.ts +25 -0
- package/dist/simulation/scenarios/consciousness-explorer.d.ts.map +1 -0
- package/dist/simulation/scenarios/consciousness-explorer.js +108 -0
- package/dist/simulation/scenarios/consciousness-explorer.js.map +1 -0
- package/dist/simulation/scenarios/domain-examples/e-commerce-recommendations.d.ts +135 -0
- package/dist/simulation/scenarios/domain-examples/e-commerce-recommendations.d.ts.map +1 -0
- package/dist/simulation/scenarios/domain-examples/e-commerce-recommendations.js +158 -0
- package/dist/simulation/scenarios/domain-examples/e-commerce-recommendations.js.map +1 -0
- package/dist/simulation/scenarios/domain-examples/index.d.ts +14 -0
- package/dist/simulation/scenarios/domain-examples/index.d.ts.map +1 -0
- package/dist/simulation/scenarios/domain-examples/index.js +14 -0
- package/dist/simulation/scenarios/domain-examples/index.js.map +1 -0
- package/dist/simulation/scenarios/domain-examples/iot-sensor-networks.d.ts +178 -0
- package/dist/simulation/scenarios/domain-examples/iot-sensor-networks.d.ts.map +1 -0
- package/dist/simulation/scenarios/domain-examples/iot-sensor-networks.js +218 -0
- package/dist/simulation/scenarios/domain-examples/iot-sensor-networks.js.map +1 -0
- package/dist/simulation/scenarios/domain-examples/medical-imaging.d.ts +122 -0
- package/dist/simulation/scenarios/domain-examples/medical-imaging.d.ts.map +1 -0
- package/dist/simulation/scenarios/domain-examples/medical-imaging.js +129 -0
- package/dist/simulation/scenarios/domain-examples/medical-imaging.js.map +1 -0
- package/dist/simulation/scenarios/domain-examples/robotics-navigation.d.ts +166 -0
- package/dist/simulation/scenarios/domain-examples/robotics-navigation.d.ts.map +1 -0
- package/dist/simulation/scenarios/domain-examples/robotics-navigation.js +161 -0
- package/dist/simulation/scenarios/domain-examples/robotics-navigation.js.map +1 -0
- package/dist/simulation/scenarios/domain-examples/scientific-research.d.ts +151 -0
- package/dist/simulation/scenarios/domain-examples/scientific-research.d.ts.map +1 -0
- package/dist/simulation/scenarios/domain-examples/scientific-research.js +187 -0
- package/dist/simulation/scenarios/domain-examples/scientific-research.js.map +1 -0
- package/dist/simulation/scenarios/domain-examples/trading-systems.d.ts +102 -0
- package/dist/simulation/scenarios/domain-examples/trading-systems.d.ts.map +1 -0
- package/dist/simulation/scenarios/domain-examples/trading-systems.js +100 -0
- package/dist/simulation/scenarios/domain-examples/trading-systems.js.map +1 -0
- package/dist/simulation/scenarios/goalie-integration.d.ts +24 -0
- package/dist/simulation/scenarios/goalie-integration.d.ts.map +1 -0
- package/dist/simulation/scenarios/goalie-integration.js +121 -0
- package/dist/simulation/scenarios/goalie-integration.js.map +1 -0
- package/dist/simulation/scenarios/graph-traversal.d.ts +17 -0
- package/dist/simulation/scenarios/graph-traversal.d.ts.map +1 -0
- package/dist/simulation/scenarios/graph-traversal.js +101 -0
- package/dist/simulation/scenarios/graph-traversal.js.map +1 -0
- package/dist/simulation/scenarios/latent-space/attention-analysis.d.ts +45 -0
- package/dist/simulation/scenarios/latent-space/attention-analysis.d.ts.map +1 -0
- package/dist/simulation/scenarios/latent-space/attention-analysis.js +435 -0
- package/dist/simulation/scenarios/latent-space/attention-analysis.js.map +1 -0
- package/dist/simulation/scenarios/latent-space/clustering-analysis.d.ts +55 -0
- package/dist/simulation/scenarios/latent-space/clustering-analysis.d.ts.map +1 -0
- package/dist/simulation/scenarios/latent-space/clustering-analysis.js +606 -0
- package/dist/simulation/scenarios/latent-space/clustering-analysis.js.map +1 -0
- package/dist/simulation/scenarios/latent-space/hnsw-exploration.d.ts +74 -0
- package/dist/simulation/scenarios/latent-space/hnsw-exploration.d.ts.map +1 -0
- package/dist/simulation/scenarios/latent-space/hnsw-exploration.js +391 -0
- package/dist/simulation/scenarios/latent-space/hnsw-exploration.js.map +1 -0
- package/dist/simulation/scenarios/latent-space/hypergraph-exploration.d.ts +51 -0
- package/dist/simulation/scenarios/latent-space/hypergraph-exploration.d.ts.map +1 -0
- package/dist/simulation/scenarios/latent-space/hypergraph-exploration.js +536 -0
- package/dist/simulation/scenarios/latent-space/hypergraph-exploration.js.map +1 -0
- package/dist/simulation/scenarios/latent-space/index.d.ts +35 -0
- package/dist/simulation/scenarios/latent-space/index.d.ts.map +1 -0
- package/dist/simulation/scenarios/latent-space/index.js +35 -0
- package/dist/simulation/scenarios/latent-space/index.js.map +1 -0
- package/dist/simulation/scenarios/latent-space/neural-augmentation.d.ts +52 -0
- package/dist/simulation/scenarios/latent-space/neural-augmentation.d.ts.map +1 -0
- package/dist/simulation/scenarios/latent-space/neural-augmentation.js +472 -0
- package/dist/simulation/scenarios/latent-space/neural-augmentation.js.map +1 -0
- package/dist/simulation/scenarios/latent-space/quantum-hybrid.d.ts +53 -0
- package/dist/simulation/scenarios/latent-space/quantum-hybrid.d.ts.map +1 -0
- package/dist/simulation/scenarios/latent-space/quantum-hybrid.js +391 -0
- package/dist/simulation/scenarios/latent-space/quantum-hybrid.js.map +1 -0
- package/dist/simulation/scenarios/latent-space/self-organizing-hnsw.d.ts +52 -0
- package/dist/simulation/scenarios/latent-space/self-organizing-hnsw.d.ts.map +1 -0
- package/dist/simulation/scenarios/latent-space/self-organizing-hnsw.js +514 -0
- package/dist/simulation/scenarios/latent-space/self-organizing-hnsw.js.map +1 -0
- package/dist/simulation/scenarios/latent-space/traversal-optimization.d.ts +53 -0
- package/dist/simulation/scenarios/latent-space/traversal-optimization.d.ts.map +1 -0
- package/dist/simulation/scenarios/latent-space/traversal-optimization.js +595 -0
- package/dist/simulation/scenarios/latent-space/traversal-optimization.js.map +1 -0
- package/dist/simulation/scenarios/lean-agentic-swarm.d.ts +18 -0
- package/dist/simulation/scenarios/lean-agentic-swarm.d.ts.map +1 -0
- package/dist/simulation/scenarios/lean-agentic-swarm.js +132 -0
- package/dist/simulation/scenarios/lean-agentic-swarm.js.map +1 -0
- package/dist/simulation/scenarios/multi-agent-swarm.d.ts +17 -0
- package/dist/simulation/scenarios/multi-agent-swarm.d.ts.map +1 -0
- package/dist/simulation/scenarios/multi-agent-swarm.js +111 -0
- package/dist/simulation/scenarios/multi-agent-swarm.js.map +1 -0
- package/dist/simulation/scenarios/psycho-symbolic-reasoner.d.ts +23 -0
- package/dist/simulation/scenarios/psycho-symbolic-reasoner.d.ts.map +1 -0
- package/dist/simulation/scenarios/psycho-symbolic-reasoner.js +98 -0
- package/dist/simulation/scenarios/psycho-symbolic-reasoner.js.map +1 -0
- package/dist/simulation/scenarios/reflexion-learning.d.ts +16 -0
- package/dist/simulation/scenarios/reflexion-learning.d.ts.map +1 -0
- package/dist/simulation/scenarios/reflexion-learning.js +98 -0
- package/dist/simulation/scenarios/reflexion-learning.js.map +1 -0
- package/dist/simulation/scenarios/research-swarm.d.ts +24 -0
- package/dist/simulation/scenarios/research-swarm.d.ts.map +1 -0
- package/dist/simulation/scenarios/research-swarm.js +146 -0
- package/dist/simulation/scenarios/research-swarm.js.map +1 -0
- package/dist/simulation/scenarios/skill-evolution.d.ts +16 -0
- package/dist/simulation/scenarios/skill-evolution.d.ts.map +1 -0
- package/dist/simulation/scenarios/skill-evolution.js +109 -0
- package/dist/simulation/scenarios/skill-evolution.js.map +1 -0
- package/dist/simulation/scenarios/stock-market-emergence.d.ts +33 -0
- package/dist/simulation/scenarios/stock-market-emergence.d.ts.map +1 -0
- package/dist/simulation/scenarios/stock-market-emergence.js +246 -0
- package/dist/simulation/scenarios/stock-market-emergence.js.map +1 -0
- package/dist/simulation/scenarios/strange-loops.d.ts +18 -0
- package/dist/simulation/scenarios/strange-loops.d.ts.map +1 -0
- package/dist/simulation/scenarios/strange-loops.js +133 -0
- package/dist/simulation/scenarios/strange-loops.js.map +1 -0
- package/dist/simulation/scenarios/sublinear-solver.d.ts +22 -0
- package/dist/simulation/scenarios/sublinear-solver.d.ts.map +1 -0
- package/dist/simulation/scenarios/sublinear-solver.js +82 -0
- package/dist/simulation/scenarios/sublinear-solver.js.map +1 -0
- package/dist/simulation/scenarios/temporal-lead-solver.d.ts +23 -0
- package/dist/simulation/scenarios/temporal-lead-solver.d.ts.map +1 -0
- package/dist/simulation/scenarios/temporal-lead-solver.js +90 -0
- package/dist/simulation/scenarios/temporal-lead-solver.js.map +1 -0
- package/dist/simulation/scenarios/voting-system-consensus.d.ts +27 -0
- package/dist/simulation/scenarios/voting-system-consensus.d.ts.map +1 -0
- package/dist/simulation/scenarios/voting-system-consensus.js +175 -0
- package/dist/simulation/scenarios/voting-system-consensus.js.map +1 -0
- package/dist/simulation/types.d.ts +162 -0
- package/dist/simulation/types.d.ts.map +1 -0
- package/dist/simulation/types.js +5 -0
- package/dist/simulation/types.js.map +1 -0
- package/dist/simulation/utils/PerformanceOptimizer.d.ts +115 -0
- package/dist/simulation/utils/PerformanceOptimizer.d.ts.map +1 -0
- package/dist/simulation/utils/PerformanceOptimizer.js +223 -0
- package/dist/simulation/utils/PerformanceOptimizer.js.map +1 -0
- package/dist/src/backends/GraphBackend.d.ts +196 -0
- package/dist/src/backends/GraphBackend.d.ts.map +1 -0
- package/dist/src/backends/GraphBackend.js +33 -0
- package/dist/src/backends/GraphBackend.js.map +1 -0
- package/dist/src/backends/LearningBackend.d.ts +148 -0
- package/dist/src/backends/LearningBackend.d.ts.map +1 -0
- package/dist/src/backends/LearningBackend.js +27 -0
- package/dist/src/backends/LearningBackend.js.map +1 -0
- package/dist/src/backends/VectorBackend.d.ts +119 -0
- package/dist/src/backends/VectorBackend.d.ts.map +1 -0
- package/dist/src/backends/VectorBackend.js +14 -0
- package/dist/src/backends/VectorBackend.js.map +1 -0
- package/dist/src/backends/detector.d.ts +81 -0
- package/dist/src/backends/detector.d.ts.map +1 -0
- package/dist/src/backends/detector.js +192 -0
- package/dist/src/backends/detector.js.map +1 -0
- package/dist/src/backends/factory.d.ts +50 -0
- package/dist/src/backends/factory.d.ts.map +1 -0
- package/dist/src/backends/factory.js +161 -0
- package/dist/src/backends/factory.js.map +1 -0
- package/dist/src/backends/graph/GraphDatabaseAdapter.d.ts +151 -0
- package/dist/src/backends/graph/GraphDatabaseAdapter.d.ts.map +1 -0
- package/dist/src/backends/graph/GraphDatabaseAdapter.js +224 -0
- package/dist/src/backends/graph/GraphDatabaseAdapter.js.map +1 -0
- package/dist/src/backends/hnswlib/HNSWLibBackend.d.ts +92 -0
- package/dist/src/backends/hnswlib/HNSWLibBackend.d.ts.map +1 -0
- package/dist/src/backends/hnswlib/HNSWLibBackend.js +316 -0
- package/dist/src/backends/hnswlib/HNSWLibBackend.js.map +1 -0
- package/dist/src/backends/hnswlib/index.d.ts +7 -0
- package/dist/src/backends/hnswlib/index.d.ts.map +1 -0
- package/dist/src/backends/hnswlib/index.js +7 -0
- package/dist/src/backends/hnswlib/index.js.map +1 -0
- package/dist/src/backends/index.d.ts +14 -0
- package/dist/src/backends/index.d.ts.map +1 -0
- package/dist/src/backends/index.js +13 -0
- package/dist/src/backends/index.js.map +1 -0
- package/dist/src/backends/ruvector/RuVectorBackend.d.ts +75 -0
- package/dist/src/backends/ruvector/RuVectorBackend.d.ts.map +1 -0
- package/dist/src/backends/ruvector/RuVectorBackend.js +198 -0
- package/dist/src/backends/ruvector/RuVectorBackend.js.map +1 -0
- package/dist/src/backends/ruvector/RuVectorLearning.d.ts +104 -0
- package/dist/src/backends/ruvector/RuVectorLearning.d.ts.map +1 -0
- package/dist/src/backends/ruvector/RuVectorLearning.js +177 -0
- package/dist/src/backends/ruvector/RuVectorLearning.js.map +1 -0
- package/dist/src/backends/ruvector/index.d.ts +9 -0
- package/dist/src/backends/ruvector/index.d.ts.map +1 -0
- package/dist/src/backends/ruvector/index.js +8 -0
- package/dist/src/backends/ruvector/index.js.map +1 -0
- package/dist/src/benchmarks/wasm-vector-benchmark.d.ts +10 -0
- package/dist/src/benchmarks/wasm-vector-benchmark.d.ts.map +1 -0
- package/dist/src/benchmarks/wasm-vector-benchmark.js +196 -0
- package/dist/src/benchmarks/wasm-vector-benchmark.js.map +1 -0
- package/dist/src/browser/AdvancedFeatures.d.ts +144 -0
- package/dist/src/browser/AdvancedFeatures.d.ts.map +1 -0
- package/dist/src/browser/AdvancedFeatures.js +430 -0
- package/dist/src/browser/AdvancedFeatures.js.map +1 -0
- package/dist/src/browser/HNSWIndex.d.ts +117 -0
- package/dist/src/browser/HNSWIndex.d.ts.map +1 -0
- package/dist/src/browser/HNSWIndex.js +402 -0
- package/dist/src/browser/HNSWIndex.js.map +1 -0
- package/dist/src/browser/ProductQuantization.d.ts +107 -0
- package/dist/src/browser/ProductQuantization.d.ts.map +1 -0
- package/dist/src/browser/ProductQuantization.js +337 -0
- package/dist/src/browser/ProductQuantization.js.map +1 -0
- package/dist/src/browser/index.d.ts +223 -0
- package/dist/src/browser/index.d.ts.map +1 -0
- package/dist/src/browser/index.js +225 -0
- package/dist/src/browser/index.js.map +1 -0
- package/dist/src/cli/agentdb-cli.d.ts +154 -0
- package/dist/src/cli/agentdb-cli.d.ts.map +1 -0
- package/dist/src/cli/agentdb-cli.js +2273 -0
- package/dist/src/cli/agentdb-cli.js.map +1 -0
- package/dist/src/cli/commands/init.d.ts +12 -0
- package/dist/src/cli/commands/init.d.ts.map +1 -0
- package/dist/src/cli/commands/init.js +115 -0
- package/dist/src/cli/commands/init.js.map +1 -0
- package/dist/src/cli/commands/install-embeddings.d.ts +10 -0
- package/dist/src/cli/commands/install-embeddings.d.ts.map +1 -0
- package/dist/src/cli/commands/install-embeddings.js +68 -0
- package/dist/src/cli/commands/install-embeddings.js.map +1 -0
- package/dist/src/cli/commands/migrate.d.ts +15 -0
- package/dist/src/cli/commands/migrate.d.ts.map +1 -0
- package/dist/src/cli/commands/migrate.js +425 -0
- package/dist/src/cli/commands/migrate.js.map +1 -0
- package/dist/src/cli/commands/simulate-custom.d.ts +26 -0
- package/dist/src/cli/commands/simulate-custom.d.ts.map +1 -0
- package/dist/src/cli/commands/simulate-custom.js +207 -0
- package/dist/src/cli/commands/simulate-custom.js.map +1 -0
- package/dist/src/cli/commands/simulate-report.d.ts +15 -0
- package/dist/src/cli/commands/simulate-report.d.ts.map +1 -0
- package/dist/src/cli/commands/simulate-report.js +136 -0
- package/dist/src/cli/commands/simulate-report.js.map +1 -0
- package/dist/src/cli/commands/simulate-wizard.d.ts +6 -0
- package/dist/src/cli/commands/simulate-wizard.d.ts.map +1 -0
- package/dist/src/cli/commands/simulate-wizard.js +352 -0
- package/dist/src/cli/commands/simulate-wizard.js.map +1 -0
- package/dist/src/cli/commands/simulate.d.ts +7 -0
- package/dist/src/cli/commands/simulate.d.ts.map +1 -0
- package/dist/src/cli/commands/simulate.js +100 -0
- package/dist/src/cli/commands/simulate.js.map +1 -0
- package/dist/src/cli/commands/status.d.ts +10 -0
- package/dist/src/cli/commands/status.d.ts.map +1 -0
- package/dist/src/cli/commands/status.js +129 -0
- package/dist/src/cli/commands/status.js.map +1 -0
- package/dist/src/cli/lib/config-manager.d.ts +110 -0
- package/dist/src/cli/lib/config-manager.d.ts.map +1 -0
- package/dist/src/cli/lib/config-manager.js +512 -0
- package/dist/src/cli/lib/config-manager.js.map +1 -0
- package/dist/src/cli/lib/config-validator.d.ts +43 -0
- package/dist/src/cli/lib/config-validator.d.ts.map +1 -0
- package/dist/src/cli/lib/config-validator.js +217 -0
- package/dist/src/cli/lib/config-validator.js.map +1 -0
- package/dist/src/cli/lib/health-monitor.d.ts +149 -0
- package/dist/src/cli/lib/health-monitor.d.ts.map +1 -0
- package/dist/src/cli/lib/health-monitor.js +380 -0
- package/dist/src/cli/lib/health-monitor.js.map +1 -0
- package/dist/src/cli/lib/help-formatter.d.ts +38 -0
- package/dist/src/cli/lib/help-formatter.d.ts.map +1 -0
- package/dist/src/cli/lib/help-formatter.js +357 -0
- package/dist/src/cli/lib/help-formatter.js.map +1 -0
- package/dist/src/cli/lib/history-tracker.d.ts +103 -0
- package/dist/src/cli/lib/history-tracker.d.ts.map +1 -0
- package/dist/src/cli/lib/history-tracker.js +346 -0
- package/dist/src/cli/lib/history-tracker.js.map +1 -0
- package/dist/src/cli/lib/report-generator.d.ts +24 -0
- package/dist/src/cli/lib/report-generator.d.ts.map +1 -0
- package/dist/src/cli/lib/report-generator.js +417 -0
- package/dist/src/cli/lib/report-generator.js.map +1 -0
- package/dist/src/cli/lib/report-store.d.ts +116 -0
- package/dist/src/cli/lib/report-store.d.ts.map +1 -0
- package/dist/src/cli/lib/report-store.js +464 -0
- package/dist/src/cli/lib/report-store.js.map +1 -0
- package/dist/src/cli/lib/simulation-registry.d.ts +165 -0
- package/dist/src/cli/lib/simulation-registry.d.ts.map +1 -0
- package/dist/src/cli/lib/simulation-registry.js +332 -0
- package/dist/src/cli/lib/simulation-registry.js.map +1 -0
- package/dist/src/cli/lib/simulation-runner.d.ts +90 -0
- package/dist/src/cli/lib/simulation-runner.d.ts.map +1 -0
- package/dist/src/cli/lib/simulation-runner.js +211 -0
- package/dist/src/cli/lib/simulation-runner.js.map +1 -0
- package/dist/src/controllers/CausalMemoryGraph.d.ts +127 -0
- package/dist/src/controllers/CausalMemoryGraph.d.ts.map +1 -0
- package/dist/src/controllers/CausalMemoryGraph.js +354 -0
- package/dist/src/controllers/CausalMemoryGraph.js.map +1 -0
- package/dist/src/controllers/CausalRecall.d.ts +139 -0
- package/dist/src/controllers/CausalRecall.d.ts.map +1 -0
- package/dist/src/controllers/CausalRecall.js +356 -0
- package/dist/src/controllers/CausalRecall.js.map +1 -0
- package/dist/src/controllers/ContextSynthesizer.d.ts +65 -0
- package/dist/src/controllers/ContextSynthesizer.d.ts.map +1 -0
- package/dist/src/controllers/ContextSynthesizer.js +208 -0
- package/dist/src/controllers/ContextSynthesizer.js.map +1 -0
- package/dist/src/controllers/EmbeddingService.d.ts +37 -0
- package/dist/src/controllers/EmbeddingService.d.ts.map +1 -0
- package/dist/src/controllers/EmbeddingService.js +136 -0
- package/dist/src/controllers/EmbeddingService.js.map +1 -0
- package/dist/src/controllers/EnhancedEmbeddingService.d.ts +50 -0
- package/dist/src/controllers/EnhancedEmbeddingService.d.ts.map +1 -0
- package/dist/src/controllers/EnhancedEmbeddingService.js +119 -0
- package/dist/src/controllers/EnhancedEmbeddingService.js.map +1 -0
- package/dist/src/controllers/ExplainableRecall.d.ts +163 -0
- package/dist/src/controllers/ExplainableRecall.d.ts.map +1 -0
- package/dist/src/controllers/ExplainableRecall.js +485 -0
- package/dist/src/controllers/ExplainableRecall.js.map +1 -0
- package/dist/src/controllers/HNSWIndex.d.ts +128 -0
- package/dist/src/controllers/HNSWIndex.d.ts.map +1 -0
- package/dist/src/controllers/HNSWIndex.js +361 -0
- package/dist/src/controllers/HNSWIndex.js.map +1 -0
- package/dist/src/controllers/LearningSystem.d.ts +195 -0
- package/dist/src/controllers/LearningSystem.d.ts.map +1 -0
- package/dist/src/controllers/LearningSystem.js +929 -0
- package/dist/src/controllers/LearningSystem.js.map +1 -0
- package/dist/src/controllers/MMRDiversityRanker.d.ts +50 -0
- package/dist/src/controllers/MMRDiversityRanker.d.ts.map +1 -0
- package/dist/src/controllers/MMRDiversityRanker.js +130 -0
- package/dist/src/controllers/MMRDiversityRanker.js.map +1 -0
- package/dist/src/controllers/MetadataFilter.d.ts +70 -0
- package/dist/src/controllers/MetadataFilter.d.ts.map +1 -0
- package/dist/src/controllers/MetadataFilter.js +243 -0
- package/dist/src/controllers/MetadataFilter.js.map +1 -0
- package/dist/src/controllers/NightlyLearner.d.ts +114 -0
- package/dist/src/controllers/NightlyLearner.d.ts.map +1 -0
- package/dist/src/controllers/NightlyLearner.js +394 -0
- package/dist/src/controllers/NightlyLearner.js.map +1 -0
- package/dist/src/controllers/QUICClient.d.ts +109 -0
- package/dist/src/controllers/QUICClient.d.ts.map +1 -0
- package/dist/src/controllers/QUICClient.js +299 -0
- package/dist/src/controllers/QUICClient.js.map +1 -0
- package/dist/src/controllers/QUICServer.d.ts +121 -0
- package/dist/src/controllers/QUICServer.d.ts.map +1 -0
- package/dist/src/controllers/QUICServer.js +383 -0
- package/dist/src/controllers/QUICServer.js.map +1 -0
- package/dist/src/controllers/ReasoningBank.d.ts +196 -0
- package/dist/src/controllers/ReasoningBank.d.ts.map +1 -0
- package/dist/src/controllers/ReasoningBank.js +494 -0
- package/dist/src/controllers/ReasoningBank.js.map +1 -0
- package/dist/src/controllers/ReflexionMemory.d.ts +125 -0
- package/dist/src/controllers/ReflexionMemory.d.ts.map +1 -0
- package/dist/src/controllers/ReflexionMemory.js +654 -0
- package/dist/src/controllers/ReflexionMemory.js.map +1 -0
- package/dist/src/controllers/SkillLibrary.d.ts +150 -0
- package/dist/src/controllers/SkillLibrary.d.ts.map +1 -0
- package/dist/src/controllers/SkillLibrary.js +608 -0
- package/dist/src/controllers/SkillLibrary.js.map +1 -0
- package/dist/src/controllers/SyncCoordinator.d.ts +120 -0
- package/dist/src/controllers/SyncCoordinator.d.ts.map +1 -0
- package/dist/src/controllers/SyncCoordinator.js +441 -0
- package/dist/src/controllers/SyncCoordinator.js.map +1 -0
- package/dist/src/controllers/WASMVectorSearch.d.ts +89 -0
- package/dist/src/controllers/WASMVectorSearch.d.ts.map +1 -0
- package/dist/src/controllers/WASMVectorSearch.js +234 -0
- package/dist/src/controllers/WASMVectorSearch.js.map +1 -0
- package/dist/src/controllers/frontier-index.d.ts +14 -0
- package/dist/src/controllers/frontier-index.d.ts.map +1 -0
- package/dist/src/controllers/frontier-index.js +10 -0
- package/dist/src/controllers/frontier-index.js.map +1 -0
- package/dist/src/controllers/index.d.ts +30 -0
- package/dist/src/controllers/index.d.ts.map +1 -0
- package/dist/src/controllers/index.js +18 -0
- package/dist/src/controllers/index.js.map +1 -0
- package/dist/src/db-fallback.d.ts +26 -0
- package/dist/src/db-fallback.d.ts.map +1 -0
- package/dist/src/db-fallback.js +264 -0
- package/dist/src/db-fallback.js.map +1 -0
- package/dist/src/db-test.d.ts +13 -0
- package/dist/src/db-test.d.ts.map +1 -0
- package/dist/src/db-test.js +55 -0
- package/dist/src/db-test.js.map +1 -0
- package/dist/src/db-unified.d.ts +76 -0
- package/dist/src/db-unified.d.ts.map +1 -0
- package/dist/src/db-unified.js +279 -0
- package/dist/src/db-unified.js.map +1 -0
- package/dist/src/examples/quic-sync-example.d.ts +9 -0
- package/dist/src/examples/quic-sync-example.d.ts.map +1 -0
- package/dist/src/examples/quic-sync-example.js +169 -0
- package/dist/src/examples/quic-sync-example.js.map +1 -0
- package/dist/src/examples/wasm-vector-usage.d.ts +12 -0
- package/dist/src/examples/wasm-vector-usage.d.ts.map +1 -0
- package/dist/src/examples/wasm-vector-usage.js +190 -0
- package/dist/src/examples/wasm-vector-usage.js.map +1 -0
- package/dist/src/index.d.ts +28 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +35 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/mcp/agentdb-mcp-server.d.ts +8 -0
- package/dist/src/mcp/agentdb-mcp-server.d.ts.map +1 -0
- package/dist/src/mcp/agentdb-mcp-server.js +2116 -0
- package/dist/src/mcp/agentdb-mcp-server.js.map +1 -0
- package/dist/src/mcp/learning-tools-handlers.d.ts +16 -0
- package/dist/src/mcp/learning-tools-handlers.d.ts.map +1 -0
- package/dist/src/mcp/learning-tools-handlers.js +105 -0
- package/dist/src/mcp/learning-tools-handlers.js.map +1 -0
- package/dist/src/optimizations/BatchOperations.d.ts +109 -0
- package/dist/src/optimizations/BatchOperations.d.ts.map +1 -0
- package/dist/src/optimizations/BatchOperations.js +407 -0
- package/dist/src/optimizations/BatchOperations.js.map +1 -0
- package/dist/src/optimizations/QueryOptimizer.d.ts +83 -0
- package/dist/src/optimizations/QueryOptimizer.d.ts.map +1 -0
- package/dist/src/optimizations/QueryOptimizer.js +228 -0
- package/dist/src/optimizations/QueryOptimizer.js.map +1 -0
- package/dist/src/optimizations/ToolCache.d.ts +137 -0
- package/dist/src/optimizations/ToolCache.d.ts.map +1 -0
- package/dist/src/optimizations/ToolCache.js +281 -0
- package/dist/src/optimizations/ToolCache.js.map +1 -0
- package/dist/src/optimizations/index.d.ts +10 -0
- package/dist/src/optimizations/index.d.ts.map +1 -0
- package/dist/src/optimizations/index.js +8 -0
- package/dist/src/optimizations/index.js.map +1 -0
- package/dist/src/security/input-validation.d.ts +109 -0
- package/dist/src/security/input-validation.d.ts.map +1 -0
- package/dist/src/security/input-validation.js +398 -0
- package/dist/src/security/input-validation.js.map +1 -0
- package/dist/src/security/limits.d.ts +150 -0
- package/dist/src/security/limits.d.ts.map +1 -0
- package/dist/src/security/limits.js +288 -0
- package/dist/src/security/limits.js.map +1 -0
- package/dist/src/security/path-security.d.ts +100 -0
- package/dist/src/security/path-security.d.ts.map +1 -0
- package/dist/src/security/path-security.js +337 -0
- package/dist/src/security/path-security.js.map +1 -0
- package/dist/src/security/validation.d.ts +95 -0
- package/dist/src/security/validation.d.ts.map +1 -0
- package/dist/src/security/validation.js +315 -0
- package/dist/src/security/validation.js.map +1 -0
- package/dist/src/services/LLMRouter.d.ts +84 -0
- package/dist/src/services/LLMRouter.d.ts.map +1 -0
- package/dist/src/services/LLMRouter.js +329 -0
- package/dist/src/services/LLMRouter.js.map +1 -0
- package/dist/src/types/quic.d.ts +518 -0
- package/dist/src/types/quic.d.ts.map +1 -0
- package/dist/src/types/quic.js +272 -0
- package/dist/src/types/quic.js.map +1 -0
- package/dist/src/utils/NodeIdMapper.d.ts +38 -0
- package/dist/src/utils/NodeIdMapper.d.ts.map +1 -0
- package/dist/src/utils/NodeIdMapper.js +57 -0
- package/dist/src/utils/NodeIdMapper.js.map +1 -0
- package/package.json +15 -3
- package/scripts/README.md +314 -0
- package/src/backends/GraphBackend.ts +290 -0
- package/src/backends/LearningBackend.ts +210 -0
- package/src/backends/README.md +389 -0
- package/src/backends/VectorBackend.ts +145 -0
- package/src/backends/detector.ts +283 -0
- package/src/backends/factory.ts +193 -0
- package/src/backends/graph/GraphDatabaseAdapter.ts +334 -0
- package/src/backends/hnswlib/HNSWLibBackend.ts +413 -0
- package/src/backends/hnswlib/index.ts +7 -0
- package/src/backends/index.ts +32 -0
- package/src/backends/ruvector/RuVectorBackend.ts +232 -0
- package/src/backends/ruvector/RuVectorLearning.ts +242 -0
- package/src/backends/ruvector/index.ts +9 -0
- package/src/backends/ruvector/types.d.ts +64 -0
- package/src/browser/AdvancedFeatures.ts +565 -0
- package/src/browser/HNSWIndex.ts +494 -0
- package/src/browser/ProductQuantization.ts +419 -0
- package/src/browser/index.ts +301 -0
- package/src/cli/agentdb-cli.ts +131 -8
- package/src/cli/commands/init.ts +148 -0
- package/src/cli/commands/install-embeddings.ts +81 -0
- package/src/cli/commands/migrate.ts +545 -0
- package/src/cli/commands/simulate-custom.ts +232 -0
- package/src/cli/commands/simulate-report.ts +171 -0
- package/src/cli/commands/simulate-wizard.ts +379 -0
- package/src/cli/commands/simulate.ts +115 -0
- package/src/cli/commands/status.ts +156 -0
- package/src/cli/lib/config-manager.ts +627 -0
- package/src/cli/lib/config-validator.ts +261 -0
- package/src/cli/lib/health-monitor.ts +513 -0
- package/src/cli/lib/help-formatter.ts +406 -0
- package/src/cli/lib/history-tracker.ts +497 -0
- package/src/cli/lib/report-generator.ts +455 -0
- package/src/cli/lib/report-store.ts +582 -0
- package/src/cli/lib/simulation-registry.ts +502 -0
- package/src/cli/lib/simulation-runner.ts +291 -0
- package/src/cli/tests/agentdb-cli.test.ts +58 -0
- package/src/controllers/CausalMemoryGraph.ts +42 -2
- package/src/controllers/CausalRecall.ts +41 -4
- package/src/controllers/ExplainableRecall.ts +123 -5
- package/src/controllers/HNSWIndex.ts +495 -0
- package/src/controllers/NightlyLearner.ts +8 -4
- package/src/controllers/ReasoningBank.ts +268 -5
- package/src/controllers/ReflexionMemory.ts +531 -6
- package/src/controllers/SkillLibrary.ts +234 -60
- package/src/controllers/index.ts +2 -0
- package/src/db-fallback.ts +103 -35
- package/src/db-test.ts +59 -0
- package/src/db-unified.ts +327 -0
- package/src/index.ts +2 -1
- package/src/mcp/agentdb-mcp-server.ts +544 -38
- package/src/optimizations/BatchOperations.ts +270 -0
- package/src/optimizations/ToolCache.ts +355 -0
- package/src/security/input-validation.ts +166 -0
- package/src/security/limits.ts +375 -0
- package/src/security/path-security.ts +436 -0
- package/src/security/validation.ts +556 -0
- package/src/services/LLMRouter.ts +406 -0
- package/src/types/xenova-transformers.d.ts +26 -0
- package/src/utils/NodeIdMapper.ts +64 -0
|
@@ -85,6 +85,172 @@ export class ValidationError extends Error {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Validate task string (NEW - for MCP tool optimization)
|
|
90
|
+
*/
|
|
91
|
+
export function validateTaskString(task: unknown, fieldName: string = 'task'): string {
|
|
92
|
+
if (task === null || task === undefined) {
|
|
93
|
+
throw new ValidationError(`${fieldName} is required`, 'MISSING_REQUIRED_FIELD', fieldName);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (typeof task !== 'string') {
|
|
97
|
+
throw new ValidationError(`${fieldName} must be a string`, 'INVALID_TYPE', fieldName);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const trimmed = task.trim();
|
|
101
|
+
|
|
102
|
+
if (trimmed.length === 0) {
|
|
103
|
+
throw new ValidationError(`${fieldName} cannot be empty`, 'EMPTY_STRING', fieldName);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (trimmed.length > 10000) {
|
|
107
|
+
throw new ValidationError(`${fieldName} exceeds maximum length of 10000 characters`, 'STRING_TOO_LONG', fieldName);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Check for potentially malicious patterns
|
|
111
|
+
const suspiciousPatterns = [
|
|
112
|
+
/<script/i,
|
|
113
|
+
/javascript:/i,
|
|
114
|
+
/on\w+\s*=/i, // onclick=, onload=, etc.
|
|
115
|
+
/\x00/, // Null bytes
|
|
116
|
+
];
|
|
117
|
+
|
|
118
|
+
for (const pattern of suspiciousPatterns) {
|
|
119
|
+
if (pattern.test(trimmed)) {
|
|
120
|
+
throw new ValidationError(`${fieldName} contains potentially malicious content`, 'SUSPICIOUS_CONTENT', fieldName);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return trimmed;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Validate numeric range (NEW - for MCP tool optimization)
|
|
129
|
+
*/
|
|
130
|
+
export function validateNumericRange(
|
|
131
|
+
value: unknown,
|
|
132
|
+
fieldName: string,
|
|
133
|
+
min: number,
|
|
134
|
+
max: number
|
|
135
|
+
): number {
|
|
136
|
+
if (value === null || value === undefined) {
|
|
137
|
+
throw new ValidationError(`${fieldName} is required`, 'MISSING_REQUIRED_FIELD', fieldName);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (typeof value !== 'number' || isNaN(value) || !isFinite(value)) {
|
|
141
|
+
throw new ValidationError(`${fieldName} must be a valid number`, 'INVALID_NUMBER', fieldName);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (value < min || value > max) {
|
|
145
|
+
throw new ValidationError(
|
|
146
|
+
`${fieldName} must be between ${min} and ${max} (got ${value})`,
|
|
147
|
+
'OUT_OF_RANGE',
|
|
148
|
+
fieldName
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return value;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Validate array length (NEW - for MCP tool optimization)
|
|
157
|
+
*/
|
|
158
|
+
export function validateArrayLength<T>(
|
|
159
|
+
arr: unknown,
|
|
160
|
+
fieldName: string,
|
|
161
|
+
minLength: number,
|
|
162
|
+
maxLength: number
|
|
163
|
+
): T[] {
|
|
164
|
+
if (arr === null || arr === undefined) {
|
|
165
|
+
throw new ValidationError(`${fieldName} is required`, 'MISSING_REQUIRED_FIELD', fieldName);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (!Array.isArray(arr)) {
|
|
169
|
+
throw new ValidationError(`${fieldName} must be an array`, 'INVALID_ARRAY', fieldName);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (arr.length < minLength || arr.length > maxLength) {
|
|
173
|
+
throw new ValidationError(
|
|
174
|
+
`${fieldName} must contain between ${minLength} and ${maxLength} items (got ${arr.length})`,
|
|
175
|
+
'ARRAY_LENGTH_INVALID',
|
|
176
|
+
fieldName
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return arr as T[];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Validate object (NEW - for MCP tool optimization)
|
|
185
|
+
*/
|
|
186
|
+
export function validateObject(
|
|
187
|
+
obj: unknown,
|
|
188
|
+
fieldName: string,
|
|
189
|
+
required: boolean = true
|
|
190
|
+
): Record<string, any> {
|
|
191
|
+
if (obj === null || obj === undefined) {
|
|
192
|
+
if (required) {
|
|
193
|
+
throw new ValidationError(`${fieldName} is required`, 'MISSING_REQUIRED_FIELD', fieldName);
|
|
194
|
+
}
|
|
195
|
+
return {};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (typeof obj !== 'object' || Array.isArray(obj)) {
|
|
199
|
+
throw new ValidationError(`${fieldName} must be an object`, 'INVALID_OBJECT', fieldName);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return obj as Record<string, any>;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Validate boolean (NEW - for MCP tool optimization)
|
|
207
|
+
*/
|
|
208
|
+
export function validateBoolean(
|
|
209
|
+
value: unknown,
|
|
210
|
+
fieldName: string,
|
|
211
|
+
defaultValue?: boolean
|
|
212
|
+
): boolean {
|
|
213
|
+
if (value === null || value === undefined) {
|
|
214
|
+
if (defaultValue !== undefined) {
|
|
215
|
+
return defaultValue;
|
|
216
|
+
}
|
|
217
|
+
throw new ValidationError(`${fieldName} is required`, 'MISSING_REQUIRED_FIELD', fieldName);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (typeof value !== 'boolean') {
|
|
221
|
+
throw new ValidationError(`${fieldName} must be a boolean`, 'INVALID_BOOLEAN', fieldName);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return value;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Validate enum value (NEW - for MCP tool optimization)
|
|
229
|
+
*/
|
|
230
|
+
export function validateEnum<T extends string>(
|
|
231
|
+
value: unknown,
|
|
232
|
+
fieldName: string,
|
|
233
|
+
allowedValues: readonly T[]
|
|
234
|
+
): T {
|
|
235
|
+
if (value === null || value === undefined) {
|
|
236
|
+
throw new ValidationError(`${fieldName} is required`, 'MISSING_REQUIRED_FIELD', fieldName);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (typeof value !== 'string') {
|
|
240
|
+
throw new ValidationError(`${fieldName} must be a string`, 'INVALID_TYPE', fieldName);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (!allowedValues.includes(value as T)) {
|
|
244
|
+
throw new ValidationError(
|
|
245
|
+
`${fieldName} must be one of: ${allowedValues.join(', ')} (got "${value}")`,
|
|
246
|
+
'INVALID_ENUM_VALUE',
|
|
247
|
+
fieldName
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return value as T;
|
|
252
|
+
}
|
|
253
|
+
|
|
88
254
|
/**
|
|
89
255
|
* Validate table name against whitelist
|
|
90
256
|
*/
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentDB v2 Resource Limit Enforcement
|
|
3
|
+
*
|
|
4
|
+
* Prevents denial of service attacks by enforcing:
|
|
5
|
+
* - Memory usage limits
|
|
6
|
+
* - Query timeouts
|
|
7
|
+
* - Rate limiting
|
|
8
|
+
* - Resource caps
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { ValidationError } from './input-validation.js';
|
|
12
|
+
import { SECURITY_LIMITS } from './validation.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Resource usage tracker
|
|
16
|
+
*/
|
|
17
|
+
export class ResourceTracker {
|
|
18
|
+
private memoryUsageMB: number = 0;
|
|
19
|
+
private queryCount: number = 0;
|
|
20
|
+
private lastQueryTime: number = Date.now();
|
|
21
|
+
private queryTimes: number[] = [];
|
|
22
|
+
private readonly startTime: number = Date.now();
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Update memory usage estimate
|
|
26
|
+
*/
|
|
27
|
+
updateMemoryUsage(additionalMB: number): void {
|
|
28
|
+
this.memoryUsageMB += additionalMB;
|
|
29
|
+
|
|
30
|
+
if (this.memoryUsageMB > SECURITY_LIMITS.MAX_MEMORY_MB) {
|
|
31
|
+
throw new SecurityError(
|
|
32
|
+
`Memory limit exceeded: ${this.memoryUsageMB.toFixed(2)}MB > ${SECURITY_LIMITS.MAX_MEMORY_MB}MB`,
|
|
33
|
+
'MEMORY_LIMIT_EXCEEDED'
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Estimate memory for vectors
|
|
40
|
+
*/
|
|
41
|
+
estimateVectorMemory(numVectors: number, dimension: number): number {
|
|
42
|
+
// Float32Array: 4 bytes per value
|
|
43
|
+
// Plus overhead for object structure and metadata (~25%)
|
|
44
|
+
const bytesPerVector = dimension * 4 * 1.25;
|
|
45
|
+
const totalBytes = numVectors * bytesPerVector;
|
|
46
|
+
return totalBytes / (1024 * 1024); // Convert to MB
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Record query execution
|
|
51
|
+
*/
|
|
52
|
+
recordQuery(durationMs: number): void {
|
|
53
|
+
this.queryCount++;
|
|
54
|
+
this.lastQueryTime = Date.now();
|
|
55
|
+
this.queryTimes.push(durationMs);
|
|
56
|
+
|
|
57
|
+
// Keep only last 100 query times for stats
|
|
58
|
+
if (this.queryTimes.length > 100) {
|
|
59
|
+
this.queryTimes.shift();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Get resource usage statistics
|
|
65
|
+
*/
|
|
66
|
+
getStats(): ResourceStats {
|
|
67
|
+
const avgQueryTime = this.queryTimes.length > 0
|
|
68
|
+
? this.queryTimes.reduce((a, b) => a + b, 0) / this.queryTimes.length
|
|
69
|
+
: 0;
|
|
70
|
+
|
|
71
|
+
const uptimeSeconds = (Date.now() - this.startTime) / 1000;
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
memoryUsageMB: this.memoryUsageMB,
|
|
75
|
+
memoryLimitMB: SECURITY_LIMITS.MAX_MEMORY_MB,
|
|
76
|
+
memoryUtilization: (this.memoryUsageMB / SECURITY_LIMITS.MAX_MEMORY_MB) * 100,
|
|
77
|
+
queryCount: this.queryCount,
|
|
78
|
+
avgQueryTimeMs: avgQueryTime,
|
|
79
|
+
uptimeSeconds,
|
|
80
|
+
queriesPerSecond: this.queryCount / uptimeSeconds,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Reset tracker
|
|
86
|
+
*/
|
|
87
|
+
reset(): void {
|
|
88
|
+
this.memoryUsageMB = 0;
|
|
89
|
+
this.queryCount = 0;
|
|
90
|
+
this.queryTimes = [];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Resource statistics interface
|
|
96
|
+
*/
|
|
97
|
+
export interface ResourceStats {
|
|
98
|
+
memoryUsageMB: number;
|
|
99
|
+
memoryLimitMB: number;
|
|
100
|
+
memoryUtilization: number;
|
|
101
|
+
queryCount: number;
|
|
102
|
+
avgQueryTimeMs: number;
|
|
103
|
+
uptimeSeconds: number;
|
|
104
|
+
queriesPerSecond: number;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Query timeout wrapper
|
|
109
|
+
*/
|
|
110
|
+
export async function withTimeout<T>(
|
|
111
|
+
promise: Promise<T>,
|
|
112
|
+
timeoutMs: number = SECURITY_LIMITS.QUERY_TIMEOUT_MS,
|
|
113
|
+
operation: string = 'operation'
|
|
114
|
+
): Promise<T> {
|
|
115
|
+
const timeout = new Promise<never>((_, reject) => {
|
|
116
|
+
setTimeout(() => {
|
|
117
|
+
reject(new SecurityError(
|
|
118
|
+
`${operation} timeout after ${timeoutMs}ms`,
|
|
119
|
+
'QUERY_TIMEOUT'
|
|
120
|
+
));
|
|
121
|
+
}, timeoutMs);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
return Promise.race([promise, timeout]);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Rate limiter using token bucket algorithm
|
|
129
|
+
*/
|
|
130
|
+
export class RateLimiter {
|
|
131
|
+
private tokens: number;
|
|
132
|
+
private lastRefill: number;
|
|
133
|
+
|
|
134
|
+
constructor(
|
|
135
|
+
private maxTokens: number,
|
|
136
|
+
private refillRate: number, // tokens per second
|
|
137
|
+
) {
|
|
138
|
+
this.tokens = maxTokens;
|
|
139
|
+
this.lastRefill = Date.now();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Attempt to consume tokens
|
|
144
|
+
* @returns true if allowed, false if rate limited
|
|
145
|
+
*/
|
|
146
|
+
tryConsume(tokens: number = 1): boolean {
|
|
147
|
+
this.refill();
|
|
148
|
+
|
|
149
|
+
if (this.tokens >= tokens) {
|
|
150
|
+
this.tokens -= tokens;
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Consume tokens or throw error
|
|
159
|
+
*/
|
|
160
|
+
consume(tokens: number = 1, operation: string = 'operation'): void {
|
|
161
|
+
if (!this.tryConsume(tokens)) {
|
|
162
|
+
throw new SecurityError(
|
|
163
|
+
`Rate limit exceeded for ${operation}. Try again later.`,
|
|
164
|
+
'RATE_LIMIT_EXCEEDED'
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Refill tokens based on time elapsed
|
|
171
|
+
*/
|
|
172
|
+
private refill(): void {
|
|
173
|
+
const now = Date.now();
|
|
174
|
+
const elapsed = (now - this.lastRefill) / 1000; // seconds
|
|
175
|
+
const tokensToAdd = elapsed * this.refillRate;
|
|
176
|
+
|
|
177
|
+
this.tokens = Math.min(this.maxTokens, this.tokens + tokensToAdd);
|
|
178
|
+
this.lastRefill = now;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Get current token count
|
|
183
|
+
*/
|
|
184
|
+
getTokens(): number {
|
|
185
|
+
this.refill();
|
|
186
|
+
return this.tokens;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Reset limiter
|
|
191
|
+
*/
|
|
192
|
+
reset(): void {
|
|
193
|
+
this.tokens = this.maxTokens;
|
|
194
|
+
this.lastRefill = Date.now();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Security error class
|
|
200
|
+
*/
|
|
201
|
+
export class SecurityError extends Error {
|
|
202
|
+
constructor(
|
|
203
|
+
message: string,
|
|
204
|
+
public readonly code: string
|
|
205
|
+
) {
|
|
206
|
+
super(message);
|
|
207
|
+
this.name = 'SecurityError';
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Get safe error message for external consumption
|
|
212
|
+
*/
|
|
213
|
+
getSafeMessage(): string {
|
|
214
|
+
// Don't expose internal details in production
|
|
215
|
+
return 'A security constraint was violated. Please check your request.';
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Enforce resource limits on batch operations
|
|
221
|
+
*/
|
|
222
|
+
export function enforceBatchLimits(
|
|
223
|
+
batchSize: number,
|
|
224
|
+
dimension: number,
|
|
225
|
+
tracker: ResourceTracker
|
|
226
|
+
): void {
|
|
227
|
+
// Check batch size
|
|
228
|
+
if (batchSize > SECURITY_LIMITS.MAX_BATCH_SIZE) {
|
|
229
|
+
throw new SecurityError(
|
|
230
|
+
`Batch size ${batchSize} exceeds limit ${SECURITY_LIMITS.MAX_BATCH_SIZE}`,
|
|
231
|
+
'BATCH_TOO_LARGE'
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Estimate and check memory
|
|
236
|
+
const estimatedMemoryMB = tracker.estimateVectorMemory(batchSize, dimension);
|
|
237
|
+
|
|
238
|
+
if (estimatedMemoryMB > SECURITY_LIMITS.MAX_MEMORY_MB * 0.5) {
|
|
239
|
+
throw new SecurityError(
|
|
240
|
+
`Batch operation would use ${estimatedMemoryMB.toFixed(2)}MB (>50% of limit)`,
|
|
241
|
+
'BATCH_MEMORY_EXCESSIVE'
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
tracker.updateMemoryUsage(estimatedMemoryMB);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Circuit breaker for fault tolerance
|
|
250
|
+
*/
|
|
251
|
+
export class CircuitBreaker {
|
|
252
|
+
private failures: number = 0;
|
|
253
|
+
private lastFailureTime: number = 0;
|
|
254
|
+
private state: 'closed' | 'open' | 'half-open' = 'closed';
|
|
255
|
+
|
|
256
|
+
constructor(
|
|
257
|
+
private maxFailures: number = 5,
|
|
258
|
+
private resetTimeoutMs: number = 60000, // 1 minute
|
|
259
|
+
) {}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Execute operation with circuit breaker protection
|
|
263
|
+
*/
|
|
264
|
+
async execute<T>(
|
|
265
|
+
operation: () => Promise<T>,
|
|
266
|
+
operationName: string = 'operation'
|
|
267
|
+
): Promise<T> {
|
|
268
|
+
if (this.state === 'open') {
|
|
269
|
+
const timeSinceFailure = Date.now() - this.lastFailureTime;
|
|
270
|
+
|
|
271
|
+
if (timeSinceFailure > this.resetTimeoutMs) {
|
|
272
|
+
this.state = 'half-open';
|
|
273
|
+
} else {
|
|
274
|
+
throw new SecurityError(
|
|
275
|
+
`Circuit breaker open for ${operationName}. Service temporarily unavailable.`,
|
|
276
|
+
'CIRCUIT_BREAKER_OPEN'
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
try {
|
|
282
|
+
const result = await operation();
|
|
283
|
+
|
|
284
|
+
// Success - reset on half-open or keep closed
|
|
285
|
+
if (this.state === 'half-open') {
|
|
286
|
+
this.state = 'closed';
|
|
287
|
+
this.failures = 0;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
return result;
|
|
291
|
+
} catch (error) {
|
|
292
|
+
this.recordFailure();
|
|
293
|
+
throw error;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Record a failure
|
|
299
|
+
*/
|
|
300
|
+
private recordFailure(): void {
|
|
301
|
+
this.failures++;
|
|
302
|
+
this.lastFailureTime = Date.now();
|
|
303
|
+
|
|
304
|
+
if (this.failures >= this.maxFailures) {
|
|
305
|
+
this.state = 'open';
|
|
306
|
+
console.error(`[CircuitBreaker] Opened after ${this.failures} failures`);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Get circuit breaker status
|
|
312
|
+
*/
|
|
313
|
+
getStatus(): { state: string; failures: number; lastFailure?: number } {
|
|
314
|
+
return {
|
|
315
|
+
state: this.state,
|
|
316
|
+
failures: this.failures,
|
|
317
|
+
lastFailure: this.lastFailureTime || undefined,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Manually reset circuit breaker
|
|
323
|
+
*/
|
|
324
|
+
reset(): void {
|
|
325
|
+
this.state = 'closed';
|
|
326
|
+
this.failures = 0;
|
|
327
|
+
this.lastFailureTime = 0;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Global resource tracker instance
|
|
333
|
+
*/
|
|
334
|
+
export const globalResourceTracker = new ResourceTracker();
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Default rate limiters
|
|
338
|
+
*/
|
|
339
|
+
export const rateLimiters = {
|
|
340
|
+
// 100 inserts per second
|
|
341
|
+
insert: new RateLimiter(100, 100),
|
|
342
|
+
|
|
343
|
+
// 1000 searches per second
|
|
344
|
+
search: new RateLimiter(1000, 1000),
|
|
345
|
+
|
|
346
|
+
// 50 deletes per second
|
|
347
|
+
delete: new RateLimiter(50, 50),
|
|
348
|
+
|
|
349
|
+
// 10 batch operations per second
|
|
350
|
+
batch: new RateLimiter(10, 10),
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Monitor and log resource usage
|
|
355
|
+
*/
|
|
356
|
+
export function logResourceUsage(): void {
|
|
357
|
+
const stats = globalResourceTracker.getStats();
|
|
358
|
+
|
|
359
|
+
console.log('[ResourceMonitor]', {
|
|
360
|
+
memory: `${stats.memoryUsageMB.toFixed(2)}MB / ${stats.memoryLimitMB}MB (${stats.memoryUtilization.toFixed(1)}%)`,
|
|
361
|
+
queries: stats.queryCount,
|
|
362
|
+
avgQueryTime: `${stats.avgQueryTimeMs.toFixed(2)}ms`,
|
|
363
|
+
qps: stats.queriesPerSecond.toFixed(2),
|
|
364
|
+
uptime: `${stats.uptimeSeconds.toFixed(0)}s`,
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
// Warn if approaching limits
|
|
368
|
+
if (stats.memoryUtilization > 80) {
|
|
369
|
+
console.warn('[ResourceMonitor] WARNING: Memory usage above 80%');
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if (stats.avgQueryTimeMs > SECURITY_LIMITS.QUERY_TIMEOUT_MS * 0.5) {
|
|
373
|
+
console.warn('[ResourceMonitor] WARNING: Average query time approaching timeout');
|
|
374
|
+
}
|
|
375
|
+
}
|