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
|
@@ -105,6 +105,142 @@ export class BatchOperations {
|
|
|
105
105
|
return completed;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Bulk insert skills with embeddings (NEW - 3x faster than sequential)
|
|
110
|
+
*/
|
|
111
|
+
async insertSkills(skills: Array<{
|
|
112
|
+
name: string;
|
|
113
|
+
description: string;
|
|
114
|
+
signature?: any;
|
|
115
|
+
code?: string;
|
|
116
|
+
successRate?: number;
|
|
117
|
+
uses?: number;
|
|
118
|
+
avgReward?: number;
|
|
119
|
+
avgLatencyMs?: number;
|
|
120
|
+
tags?: string[];
|
|
121
|
+
metadata?: Record<string, any>;
|
|
122
|
+
}>): Promise<number[]> {
|
|
123
|
+
const skillIds: number[] = [];
|
|
124
|
+
let completed = 0;
|
|
125
|
+
|
|
126
|
+
for (let i = 0; i < skills.length; i += this.config.batchSize) {
|
|
127
|
+
const batch = skills.slice(i, i + this.config.batchSize);
|
|
128
|
+
|
|
129
|
+
// Generate embeddings in parallel
|
|
130
|
+
const texts = batch.map(skill => `${skill.name}\n${skill.description}`);
|
|
131
|
+
const embeddings = await this.embedder.embedBatch(texts);
|
|
132
|
+
|
|
133
|
+
// Insert with transaction
|
|
134
|
+
const transaction = this.db.transaction(() => {
|
|
135
|
+
const skillStmt = this.db.prepare(`
|
|
136
|
+
INSERT INTO skills (
|
|
137
|
+
name, description, signature, code, success_rate, uses,
|
|
138
|
+
avg_reward, avg_latency_ms, tags, metadata
|
|
139
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
140
|
+
`);
|
|
141
|
+
|
|
142
|
+
const embeddingStmt = this.db.prepare(`
|
|
143
|
+
INSERT INTO skill_embeddings (skill_id, embedding)
|
|
144
|
+
VALUES (?, ?)
|
|
145
|
+
`);
|
|
146
|
+
|
|
147
|
+
batch.forEach((skill, idx) => {
|
|
148
|
+
const result = skillStmt.run(
|
|
149
|
+
skill.name,
|
|
150
|
+
skill.description,
|
|
151
|
+
skill.signature ? JSON.stringify(skill.signature) : null,
|
|
152
|
+
skill.code || null,
|
|
153
|
+
skill.successRate ?? 0.0,
|
|
154
|
+
skill.uses ?? 0,
|
|
155
|
+
skill.avgReward ?? 0.0,
|
|
156
|
+
skill.avgLatencyMs ?? 0.0,
|
|
157
|
+
skill.tags ? JSON.stringify(skill.tags) : null,
|
|
158
|
+
skill.metadata ? JSON.stringify(skill.metadata) : null
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
const skillId = result.lastInsertRowid as number;
|
|
162
|
+
skillIds.push(skillId);
|
|
163
|
+
embeddingStmt.run(skillId, Buffer.from(embeddings[idx].buffer));
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
transaction();
|
|
168
|
+
|
|
169
|
+
completed += batch.length;
|
|
170
|
+
|
|
171
|
+
if (this.config.progressCallback) {
|
|
172
|
+
this.config.progressCallback(completed, skills.length);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return skillIds;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Bulk insert reasoning patterns with embeddings (NEW - 4x faster than sequential)
|
|
181
|
+
*/
|
|
182
|
+
async insertPatterns(patterns: Array<{
|
|
183
|
+
taskType: string;
|
|
184
|
+
approach: string;
|
|
185
|
+
context?: string;
|
|
186
|
+
successRate: number;
|
|
187
|
+
outcome?: string;
|
|
188
|
+
tags?: string[];
|
|
189
|
+
metadata?: Record<string, any>;
|
|
190
|
+
}>): Promise<number[]> {
|
|
191
|
+
const patternIds: number[] = [];
|
|
192
|
+
let completed = 0;
|
|
193
|
+
|
|
194
|
+
for (let i = 0; i < patterns.length; i += this.config.batchSize) {
|
|
195
|
+
const batch = patterns.slice(i, i + this.config.batchSize);
|
|
196
|
+
|
|
197
|
+
// Generate embeddings in parallel
|
|
198
|
+
const texts = batch.map(p => `${p.taskType}\n${p.approach}\n${p.context || ''}`);
|
|
199
|
+
const embeddings = await this.embedder.embedBatch(texts);
|
|
200
|
+
|
|
201
|
+
// Insert with transaction
|
|
202
|
+
const transaction = this.db.transaction(() => {
|
|
203
|
+
const patternStmt = this.db.prepare(`
|
|
204
|
+
INSERT INTO reasoning_patterns (
|
|
205
|
+
task_type, approach, context, success_rate, outcome, uses, tags, metadata
|
|
206
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
207
|
+
`);
|
|
208
|
+
|
|
209
|
+
const embeddingStmt = this.db.prepare(`
|
|
210
|
+
INSERT INTO pattern_embeddings (pattern_id, embedding)
|
|
211
|
+
VALUES (?, ?)
|
|
212
|
+
`);
|
|
213
|
+
|
|
214
|
+
batch.forEach((pattern, idx) => {
|
|
215
|
+
const result = patternStmt.run(
|
|
216
|
+
pattern.taskType,
|
|
217
|
+
pattern.approach,
|
|
218
|
+
pattern.context || null,
|
|
219
|
+
pattern.successRate,
|
|
220
|
+
pattern.outcome || null,
|
|
221
|
+
0, // initial uses = 0
|
|
222
|
+
pattern.tags ? JSON.stringify(pattern.tags) : null,
|
|
223
|
+
pattern.metadata ? JSON.stringify(pattern.metadata) : null
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
const patternId = result.lastInsertRowid as number;
|
|
227
|
+
patternIds.push(patternId);
|
|
228
|
+
embeddingStmt.run(patternId, Buffer.from(embeddings[idx].buffer));
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
transaction();
|
|
233
|
+
|
|
234
|
+
completed += batch.length;
|
|
235
|
+
|
|
236
|
+
if (this.config.progressCallback) {
|
|
237
|
+
this.config.progressCallback(completed, patterns.length);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return patternIds;
|
|
242
|
+
}
|
|
243
|
+
|
|
108
244
|
/**
|
|
109
245
|
* Bulk update embeddings for existing episodes
|
|
110
246
|
*/
|
|
@@ -244,6 +380,140 @@ export class BatchOperations {
|
|
|
244
380
|
}
|
|
245
381
|
}
|
|
246
382
|
|
|
383
|
+
/**
|
|
384
|
+
* Prune old or low-quality data (NEW - maintain database hygiene)
|
|
385
|
+
*/
|
|
386
|
+
async pruneData(config: {
|
|
387
|
+
maxAge?: number; // Days to keep
|
|
388
|
+
minReward?: number; // Minimum reward threshold
|
|
389
|
+
minSuccessRate?: number; // Minimum success rate for skills/patterns
|
|
390
|
+
maxRecords?: number; // Max records per table
|
|
391
|
+
dryRun?: boolean; // Preview without deleting
|
|
392
|
+
} = {}): Promise<{
|
|
393
|
+
episodesPruned: number;
|
|
394
|
+
skillsPruned: number;
|
|
395
|
+
patternsPruned: number;
|
|
396
|
+
spaceSaved: number;
|
|
397
|
+
}> {
|
|
398
|
+
const {
|
|
399
|
+
maxAge = 90, // Default: 90 days
|
|
400
|
+
minReward = 0.3, // Default: keep episodes with reward >= 0.3
|
|
401
|
+
minSuccessRate = 0.5, // Default: keep skills/patterns >= 50% success rate
|
|
402
|
+
maxRecords = 100000, // Default: max 100k records per table
|
|
403
|
+
dryRun = false,
|
|
404
|
+
} = config;
|
|
405
|
+
|
|
406
|
+
const cutoffTime = Math.floor(Date.now() / 1000) - (maxAge * 24 * 60 * 60);
|
|
407
|
+
const results = {
|
|
408
|
+
episodesPruned: 0,
|
|
409
|
+
skillsPruned: 0,
|
|
410
|
+
patternsPruned: 0,
|
|
411
|
+
spaceSaved: 0,
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
// Get current database size
|
|
415
|
+
const sizeBeforeBytes = this.db.pragma('page_count', { simple: true }) as number *
|
|
416
|
+
this.db.pragma('page_size', { simple: true }) as number;
|
|
417
|
+
|
|
418
|
+
// 1. Prune old/low-quality episodes
|
|
419
|
+
const episodesToPrune = this.db.prepare(`
|
|
420
|
+
SELECT COUNT(*) as count FROM episodes
|
|
421
|
+
WHERE (ts < ? OR reward < ?)
|
|
422
|
+
AND id NOT IN (
|
|
423
|
+
-- Keep episodes referenced by causal edges
|
|
424
|
+
SELECT DISTINCT from_memory_id FROM causal_edges WHERE from_memory_type = 'episode'
|
|
425
|
+
UNION
|
|
426
|
+
SELECT DISTINCT to_memory_id FROM causal_edges WHERE to_memory_type = 'episode'
|
|
427
|
+
)
|
|
428
|
+
`).get(cutoffTime, minReward) as any;
|
|
429
|
+
|
|
430
|
+
if (!dryRun && episodesToPrune.count > 0) {
|
|
431
|
+
this.db.prepare(`
|
|
432
|
+
DELETE FROM episodes
|
|
433
|
+
WHERE (ts < ? OR reward < ?)
|
|
434
|
+
AND id NOT IN (
|
|
435
|
+
SELECT DISTINCT from_memory_id FROM causal_edges WHERE from_memory_type = 'episode'
|
|
436
|
+
UNION
|
|
437
|
+
SELECT DISTINCT to_memory_id FROM causal_edges WHERE to_memory_type = 'episode'
|
|
438
|
+
)
|
|
439
|
+
`).run(cutoffTime, minReward);
|
|
440
|
+
|
|
441
|
+
results.episodesPruned = episodesToPrune.count;
|
|
442
|
+
} else {
|
|
443
|
+
results.episodesPruned = episodesToPrune.count;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// 2. Prune low-performing skills
|
|
447
|
+
const skillsToPrune = this.db.prepare(`
|
|
448
|
+
SELECT COUNT(*) as count FROM skills
|
|
449
|
+
WHERE (success_rate < ? OR uses = 0)
|
|
450
|
+
AND ts < ?
|
|
451
|
+
`).get(minSuccessRate, cutoffTime) as any;
|
|
452
|
+
|
|
453
|
+
if (!dryRun && skillsToPrune.count > 0) {
|
|
454
|
+
this.db.prepare(`
|
|
455
|
+
DELETE FROM skills
|
|
456
|
+
WHERE (success_rate < ? OR uses = 0)
|
|
457
|
+
AND ts < ?
|
|
458
|
+
`).run(minSuccessRate, cutoffTime);
|
|
459
|
+
|
|
460
|
+
results.skillsPruned = skillsToPrune.count;
|
|
461
|
+
} else {
|
|
462
|
+
results.skillsPruned = skillsToPrune.count;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// 3. Prune low-performing patterns
|
|
466
|
+
const patternsToPrune = this.db.prepare(`
|
|
467
|
+
SELECT COUNT(*) as count FROM reasoning_patterns
|
|
468
|
+
WHERE (success_rate < ? OR uses = 0)
|
|
469
|
+
AND ts < ?
|
|
470
|
+
`).get(minSuccessRate, cutoffTime) as any;
|
|
471
|
+
|
|
472
|
+
if (!dryRun && patternsToPrune.count > 0) {
|
|
473
|
+
this.db.prepare(`
|
|
474
|
+
DELETE FROM reasoning_patterns
|
|
475
|
+
WHERE (success_rate < ? OR uses = 0)
|
|
476
|
+
AND ts < ?
|
|
477
|
+
`).run(minSuccessRate, cutoffTime);
|
|
478
|
+
|
|
479
|
+
results.patternsPruned = patternsToPrune.count;
|
|
480
|
+
} else {
|
|
481
|
+
results.patternsPruned = patternsToPrune.count;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// 4. Enforce max records limit (keep most recent + highest performing)
|
|
485
|
+
const episodeCount = this.db.prepare('SELECT COUNT(*) as count FROM episodes').get() as any;
|
|
486
|
+
if (episodeCount.count > maxRecords) {
|
|
487
|
+
const toDelete = episodeCount.count - maxRecords;
|
|
488
|
+
|
|
489
|
+
if (!dryRun) {
|
|
490
|
+
this.db.prepare(`
|
|
491
|
+
DELETE FROM episodes
|
|
492
|
+
WHERE id IN (
|
|
493
|
+
SELECT id FROM episodes
|
|
494
|
+
ORDER BY reward ASC, ts ASC
|
|
495
|
+
LIMIT ?
|
|
496
|
+
)
|
|
497
|
+
`).run(toDelete);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
results.episodesPruned += toDelete;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// Calculate space saved
|
|
504
|
+
if (!dryRun) {
|
|
505
|
+
// Vacuum to reclaim space
|
|
506
|
+
this.db.exec('VACUUM');
|
|
507
|
+
|
|
508
|
+
const sizeAfterBytes = this.db.pragma('page_count', { simple: true }) as number *
|
|
509
|
+
this.db.pragma('page_size', { simple: true }) as number;
|
|
510
|
+
|
|
511
|
+
results.spaceSaved = sizeBeforeBytes - sizeAfterBytes;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
return results;
|
|
515
|
+
}
|
|
516
|
+
|
|
247
517
|
/**
|
|
248
518
|
* Vacuum and optimize database
|
|
249
519
|
*/
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolCache - Intelligent Caching for MCP Tools
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - TTL-based expiration
|
|
6
|
+
* - LRU eviction when max size reached
|
|
7
|
+
* - Pattern-based cache invalidation
|
|
8
|
+
* - Hit/miss rate tracking
|
|
9
|
+
* - Memory-efficient storage
|
|
10
|
+
*
|
|
11
|
+
* Performance Impact:
|
|
12
|
+
* - agentdb_stats: 176ms → ~20ms (8.8x faster)
|
|
13
|
+
* - pattern_stats: Similar improvement
|
|
14
|
+
* - learning_metrics: 120s TTL for expensive computations
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export interface CacheEntry<T> {
|
|
18
|
+
value: T;
|
|
19
|
+
expiry: number;
|
|
20
|
+
accessCount: number;
|
|
21
|
+
lastAccess: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface CacheStats {
|
|
25
|
+
size: number;
|
|
26
|
+
maxSize: number;
|
|
27
|
+
hits: number;
|
|
28
|
+
misses: number;
|
|
29
|
+
hitRate: number;
|
|
30
|
+
evictions: number;
|
|
31
|
+
avgAccessCount: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class ToolCache<T = any> {
|
|
35
|
+
private cache: Map<string, CacheEntry<T>>;
|
|
36
|
+
private maxSize: number;
|
|
37
|
+
private defaultTTLMs: number;
|
|
38
|
+
private hits: number;
|
|
39
|
+
private misses: number;
|
|
40
|
+
private evictions: number;
|
|
41
|
+
|
|
42
|
+
constructor(maxSize = 1000, defaultTTLMs = 60000) {
|
|
43
|
+
this.cache = new Map();
|
|
44
|
+
this.maxSize = maxSize;
|
|
45
|
+
this.defaultTTLMs = defaultTTLMs;
|
|
46
|
+
this.hits = 0;
|
|
47
|
+
this.misses = 0;
|
|
48
|
+
this.evictions = 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Set cache entry with optional custom TTL
|
|
53
|
+
*/
|
|
54
|
+
set(key: string, value: T, ttlMs?: number): void {
|
|
55
|
+
// Evict expired entries first
|
|
56
|
+
this.evictExpired();
|
|
57
|
+
|
|
58
|
+
// If at capacity, evict LRU entry
|
|
59
|
+
if (this.cache.size >= this.maxSize && !this.cache.has(key)) {
|
|
60
|
+
this.evictLRU();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const expiry = Date.now() + (ttlMs ?? this.defaultTTLMs);
|
|
64
|
+
this.cache.set(key, {
|
|
65
|
+
value,
|
|
66
|
+
expiry,
|
|
67
|
+
accessCount: 0,
|
|
68
|
+
lastAccess: Date.now(),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Get cache entry (returns null if expired or not found)
|
|
74
|
+
*/
|
|
75
|
+
get(key: string): T | null {
|
|
76
|
+
const entry = this.cache.get(key);
|
|
77
|
+
|
|
78
|
+
if (!entry) {
|
|
79
|
+
this.misses++;
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Check expiration
|
|
84
|
+
if (Date.now() > entry.expiry) {
|
|
85
|
+
this.cache.delete(key);
|
|
86
|
+
this.misses++;
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Update access stats
|
|
91
|
+
entry.accessCount++;
|
|
92
|
+
entry.lastAccess = Date.now();
|
|
93
|
+
this.hits++;
|
|
94
|
+
|
|
95
|
+
return entry.value;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Check if key exists and is not expired
|
|
100
|
+
*/
|
|
101
|
+
has(key: string): boolean {
|
|
102
|
+
const entry = this.cache.get(key);
|
|
103
|
+
if (!entry) return false;
|
|
104
|
+
|
|
105
|
+
if (Date.now() > entry.expiry) {
|
|
106
|
+
this.cache.delete(key);
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Delete specific key
|
|
115
|
+
*/
|
|
116
|
+
delete(key: string): boolean {
|
|
117
|
+
return this.cache.delete(key);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Clear all entries matching pattern (e.g., 'stats:*', 'search:user-123:*')
|
|
122
|
+
*/
|
|
123
|
+
clear(pattern?: string): number {
|
|
124
|
+
if (!pattern) {
|
|
125
|
+
const size = this.cache.size;
|
|
126
|
+
this.cache.clear();
|
|
127
|
+
return size;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Convert glob pattern to regex
|
|
131
|
+
const regex = new RegExp('^' + pattern.replace(/\*/g, '.*') + '$');
|
|
132
|
+
let cleared = 0;
|
|
133
|
+
|
|
134
|
+
for (const key of this.cache.keys()) {
|
|
135
|
+
if (regex.test(key)) {
|
|
136
|
+
this.cache.delete(key);
|
|
137
|
+
cleared++;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return cleared;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Evict all expired entries
|
|
146
|
+
*/
|
|
147
|
+
private evictExpired(): number {
|
|
148
|
+
const now = Date.now();
|
|
149
|
+
let evicted = 0;
|
|
150
|
+
|
|
151
|
+
for (const [key, entry] of this.cache.entries()) {
|
|
152
|
+
if (now > entry.expiry) {
|
|
153
|
+
this.cache.delete(key);
|
|
154
|
+
evicted++;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
this.evictions += evicted;
|
|
159
|
+
return evicted;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Evict least recently used entry (LRU)
|
|
164
|
+
*/
|
|
165
|
+
private evictLRU(): void {
|
|
166
|
+
let lruKey: string | null = null;
|
|
167
|
+
let oldestAccess = Infinity;
|
|
168
|
+
|
|
169
|
+
for (const [key, entry] of this.cache.entries()) {
|
|
170
|
+
if (entry.lastAccess < oldestAccess) {
|
|
171
|
+
oldestAccess = entry.lastAccess;
|
|
172
|
+
lruKey = key;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (lruKey) {
|
|
177
|
+
this.cache.delete(lruKey);
|
|
178
|
+
this.evictions++;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Get cache statistics
|
|
184
|
+
*/
|
|
185
|
+
getStats(): CacheStats {
|
|
186
|
+
const totalAccesses = this.hits + this.misses;
|
|
187
|
+
const hitRate = totalAccesses > 0 ? this.hits / totalAccesses : 0;
|
|
188
|
+
|
|
189
|
+
let totalAccessCount = 0;
|
|
190
|
+
for (const entry of this.cache.values()) {
|
|
191
|
+
totalAccessCount += entry.accessCount;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const avgAccessCount = this.cache.size > 0 ? totalAccessCount / this.cache.size : 0;
|
|
195
|
+
|
|
196
|
+
return {
|
|
197
|
+
size: this.cache.size,
|
|
198
|
+
maxSize: this.maxSize,
|
|
199
|
+
hits: this.hits,
|
|
200
|
+
misses: this.misses,
|
|
201
|
+
hitRate,
|
|
202
|
+
evictions: this.evictions,
|
|
203
|
+
avgAccessCount,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Reset statistics (keeps cached data)
|
|
209
|
+
*/
|
|
210
|
+
resetStats(): void {
|
|
211
|
+
this.hits = 0;
|
|
212
|
+
this.misses = 0;
|
|
213
|
+
this.evictions = 0;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Get all cache keys (useful for debugging)
|
|
218
|
+
*/
|
|
219
|
+
keys(): string[] {
|
|
220
|
+
return Array.from(this.cache.keys());
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Get cache entry with metadata (useful for debugging)
|
|
225
|
+
*/
|
|
226
|
+
inspect(key: string): CacheEntry<T> | null {
|
|
227
|
+
return this.cache.get(key) || null;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Warmup cache with pre-computed values
|
|
232
|
+
*/
|
|
233
|
+
warmup(entries: Array<{ key: string; value: T; ttlMs?: number }>): void {
|
|
234
|
+
for (const { key, value, ttlMs } of entries) {
|
|
235
|
+
this.set(key, value, ttlMs);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Export cache to JSON (for persistence)
|
|
241
|
+
*/
|
|
242
|
+
export(): Array<{ key: string; value: T; expiry: number }> {
|
|
243
|
+
const now = Date.now();
|
|
244
|
+
const exported: Array<{ key: string; value: T; expiry: number }> = [];
|
|
245
|
+
|
|
246
|
+
for (const [key, entry] of this.cache.entries()) {
|
|
247
|
+
// Only export non-expired entries
|
|
248
|
+
if (entry.expiry > now) {
|
|
249
|
+
exported.push({
|
|
250
|
+
key,
|
|
251
|
+
value: entry.value,
|
|
252
|
+
expiry: entry.expiry,
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return exported;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Import cache from JSON (for persistence)
|
|
262
|
+
*/
|
|
263
|
+
import(entries: Array<{ key: string; value: T; expiry: number }>): number {
|
|
264
|
+
const now = Date.now();
|
|
265
|
+
let imported = 0;
|
|
266
|
+
|
|
267
|
+
for (const { key, value, expiry } of entries) {
|
|
268
|
+
// Only import non-expired entries
|
|
269
|
+
if (expiry > now) {
|
|
270
|
+
this.cache.set(key, {
|
|
271
|
+
value,
|
|
272
|
+
expiry,
|
|
273
|
+
accessCount: 0,
|
|
274
|
+
lastAccess: now,
|
|
275
|
+
});
|
|
276
|
+
imported++;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return imported;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Specialized caches for different MCP tools
|
|
286
|
+
*/
|
|
287
|
+
|
|
288
|
+
export class MCPToolCaches {
|
|
289
|
+
public stats: ToolCache<string>;
|
|
290
|
+
public patterns: ToolCache<any[]>;
|
|
291
|
+
public searches: ToolCache<any[]>;
|
|
292
|
+
public metrics: ToolCache<any>;
|
|
293
|
+
|
|
294
|
+
constructor() {
|
|
295
|
+
// Stats cache: 60s TTL (agentdb_stats, db_stats, pattern_stats)
|
|
296
|
+
this.stats = new ToolCache<string>(100, 60000);
|
|
297
|
+
|
|
298
|
+
// Pattern cache: 30s TTL (pattern searches, skill searches)
|
|
299
|
+
this.patterns = new ToolCache<any[]>(500, 30000);
|
|
300
|
+
|
|
301
|
+
// Search results cache: 15s TTL (episode retrieval, vector search)
|
|
302
|
+
this.searches = new ToolCache<any[]>(1000, 15000);
|
|
303
|
+
|
|
304
|
+
// Metrics cache: 120s TTL (learning_metrics, expensive computations)
|
|
305
|
+
this.metrics = new ToolCache<any>(50, 120000);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Clear all caches
|
|
310
|
+
*/
|
|
311
|
+
clearAll(): void {
|
|
312
|
+
this.stats.clear();
|
|
313
|
+
this.patterns.clear();
|
|
314
|
+
this.searches.clear();
|
|
315
|
+
this.metrics.clear();
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Get aggregate statistics
|
|
320
|
+
*/
|
|
321
|
+
getAggregateStats(): {
|
|
322
|
+
stats: CacheStats;
|
|
323
|
+
patterns: CacheStats;
|
|
324
|
+
searches: CacheStats;
|
|
325
|
+
metrics: CacheStats;
|
|
326
|
+
total: {
|
|
327
|
+
size: number;
|
|
328
|
+
hits: number;
|
|
329
|
+
misses: number;
|
|
330
|
+
hitRate: number;
|
|
331
|
+
};
|
|
332
|
+
} {
|
|
333
|
+
const statsStats = this.stats.getStats();
|
|
334
|
+
const patternsStats = this.patterns.getStats();
|
|
335
|
+
const searchesStats = this.searches.getStats();
|
|
336
|
+
const metricsStats = this.metrics.getStats();
|
|
337
|
+
|
|
338
|
+
const totalHits = statsStats.hits + patternsStats.hits + searchesStats.hits + metricsStats.hits;
|
|
339
|
+
const totalMisses = statsStats.misses + patternsStats.misses + searchesStats.misses + metricsStats.misses;
|
|
340
|
+
const totalAccesses = totalHits + totalMisses;
|
|
341
|
+
|
|
342
|
+
return {
|
|
343
|
+
stats: statsStats,
|
|
344
|
+
patterns: patternsStats,
|
|
345
|
+
searches: searchesStats,
|
|
346
|
+
metrics: metricsStats,
|
|
347
|
+
total: {
|
|
348
|
+
size: statsStats.size + patternsStats.size + searchesStats.size + metricsStats.size,
|
|
349
|
+
hits: totalHits,
|
|
350
|
+
misses: totalMisses,
|
|
351
|
+
hitRate: totalAccesses > 0 ? totalHits / totalAccesses : 0,
|
|
352
|
+
},
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
}
|