agentdb 3.0.0-alpha.2 → 3.0.0-alpha.4
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 +978 -2342
- package/dist/agentdb.browser.js +1492 -0
- package/dist/agentdb.browser.js.map +7 -0
- package/dist/agentdb.browser.min.js +3 -0
- package/dist/agentdb.browser.min.js.map +7 -0
- package/dist/agentdb.wasm-loader.js +207 -0
- package/dist/schemas/frontier-schema.sql +0 -7
- package/dist/schemas/schema.sql +0 -7
- 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 +8 -8
- package/dist/src/backends/GraphBackend.d.ts.map +1 -1
- package/dist/src/backends/GraphBackend.js +15 -16
- package/dist/src/backends/GraphBackend.js.map +1 -1
- package/dist/src/backends/LearningBackend.d.ts +2 -2
- package/dist/src/backends/LearningBackend.d.ts.map +1 -1
- package/dist/src/backends/LearningBackend.js +10 -11
- package/dist/src/backends/LearningBackend.js.map +1 -1
- package/dist/src/backends/VectorBackend.d.ts +6 -31
- package/dist/src/backends/VectorBackend.d.ts.map +1 -1
- package/dist/src/backends/detector.d.ts +3 -25
- package/dist/src/backends/detector.d.ts.map +1 -1
- package/dist/src/backends/detector.js +15 -119
- package/dist/src/backends/detector.js.map +1 -1
- package/dist/src/backends/factory.d.ts +32 -16
- package/dist/src/backends/factory.d.ts.map +1 -1
- package/dist/src/backends/factory.js +70 -133
- package/dist/src/backends/factory.js.map +1 -1
- package/dist/src/backends/graph/GraphDatabaseAdapter.d.ts +1 -1
- package/dist/src/backends/graph/GraphDatabaseAdapter.d.ts.map +1 -1
- package/dist/src/backends/graph/GraphDatabaseAdapter.js +1 -5
- package/dist/src/backends/graph/GraphDatabaseAdapter.js.map +1 -1
- package/dist/src/backends/hnswlib/HNSWLibBackend.d.ts +2 -2
- package/dist/src/backends/hnswlib/HNSWLibBackend.d.ts.map +1 -1
- package/dist/src/backends/hnswlib/HNSWLibBackend.js +13 -49
- package/dist/src/backends/hnswlib/HNSWLibBackend.js.map +1 -1
- package/dist/src/backends/index.d.ts +3 -25
- package/dist/src/backends/index.d.ts.map +1 -1
- package/dist/src/backends/index.js +1 -23
- package/dist/src/backends/index.js.map +1 -1
- package/dist/src/backends/ruvector/GuardedVectorBackend.d.ts +93 -0
- package/dist/src/backends/ruvector/GuardedVectorBackend.d.ts.map +1 -0
- package/dist/src/backends/ruvector/GuardedVectorBackend.js +182 -0
- package/dist/src/backends/ruvector/GuardedVectorBackend.js.map +1 -0
- package/dist/src/backends/ruvector/RuVectorBackend.d.ts +16 -187
- package/dist/src/backends/ruvector/RuVectorBackend.d.ts.map +1 -1
- package/dist/src/backends/ruvector/RuVectorBackend.js +94 -576
- package/dist/src/backends/ruvector/RuVectorBackend.js.map +1 -1
- package/dist/src/backends/ruvector/RuVectorLearning.d.ts +4 -0
- package/dist/src/backends/ruvector/RuVectorLearning.d.ts.map +1 -1
- package/dist/src/backends/ruvector/RuVectorLearning.js +11 -10
- package/dist/src/backends/ruvector/RuVectorLearning.js.map +1 -1
- 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.map +1 -1
- package/dist/src/browser/AdvancedFeatures.js +10 -3
- package/dist/src/browser/AdvancedFeatures.js.map +1 -1
- package/dist/src/browser/AttentionBrowser.d.ts.map +1 -1
- package/dist/src/browser/AttentionBrowser.js +12 -5
- package/dist/src/browser/AttentionBrowser.js.map +1 -1
- package/dist/src/browser/HNSWIndex.d.ts +1 -31
- package/dist/src/browser/HNSWIndex.d.ts.map +1 -1
- package/dist/src/browser/HNSWIndex.js +18 -136
- package/dist/src/browser/HNSWIndex.js.map +1 -1
- package/dist/src/browser/ProductQuantization.d.ts.map +1 -1
- package/dist/src/browser/ProductQuantization.js +1 -0
- package/dist/src/browser/ProductQuantization.js.map +1 -1
- package/dist/src/browser/index.d.ts +3 -3
- package/dist/src/browser/index.d.ts.map +1 -1
- package/dist/src/browser/index.js +1 -2
- package/dist/src/browser/index.js.map +1 -1
- package/dist/src/cli/agentdb-cli.d.ts +2 -16
- package/dist/src/cli/agentdb-cli.d.ts.map +1 -1
- package/dist/src/cli/agentdb-cli.js +216 -853
- package/dist/src/cli/agentdb-cli.js.map +1 -1
- package/dist/src/cli/commands/attention.js +3 -3
- package/dist/src/cli/commands/attention.js.map +1 -1
- package/dist/src/cli/commands/doctor.d.ts +0 -2
- package/dist/src/cli/commands/doctor.d.ts.map +1 -1
- package/dist/src/cli/commands/doctor.js +1 -106
- package/dist/src/cli/commands/doctor.js.map +1 -1
- package/dist/src/cli/commands/init.d.ts +1 -2
- package/dist/src/cli/commands/init.d.ts.map +1 -1
- package/dist/src/cli/commands/init.js +7 -30
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/commands/install-embeddings.d.ts.map +1 -1
- package/dist/src/cli/commands/install-embeddings.js.map +1 -1
- package/dist/src/cli/commands/migrate.d.ts +0 -15
- package/dist/src/cli/commands/migrate.d.ts.map +1 -1
- package/dist/src/cli/commands/migrate.js +5 -164
- package/dist/src/cli/commands/migrate.js.map +1 -1
- package/dist/src/cli/commands/simulate-report.js.map +1 -1
- package/dist/src/cli/commands/simulate-wizard.js.map +1 -1
- 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.js +1 -5
- package/dist/src/cli/commands/status.js.map +1 -1
- package/dist/src/cli/lib/attention-config.d.ts +2 -2
- package/dist/src/cli/lib/attention-config.d.ts.map +1 -1
- package/dist/src/cli/lib/attention-config.js +1 -2
- package/dist/src/cli/lib/attention-config.js.map +1 -1
- 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 +1 -1
- package/dist/src/cli/lib/config-validator.d.ts.map +1 -1
- 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/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 +352 -0
- package/dist/src/cli/lib/history-tracker.js.map +1 -0
- package/dist/src/cli/lib/report-store.d.ts +1 -2
- package/dist/src/cli/lib/report-store.d.ts.map +1 -1
- package/dist/src/cli/lib/report-store.js +65 -87
- package/dist/src/cli/lib/report-store.js.map +1 -1
- package/dist/src/cli/lib/simulation-registry.d.ts +1 -1
- package/dist/src/cli/lib/simulation-registry.d.ts.map +1 -1
- package/dist/src/cli/lib/simulation-registry.js +0 -1
- package/dist/src/cli/lib/simulation-registry.js.map +1 -1
- package/dist/src/cli/lib/simulation-runner.d.ts +4 -41
- package/dist/src/cli/lib/simulation-runner.d.ts.map +1 -1
- package/dist/src/cli/lib/simulation-runner.js +6 -251
- package/dist/src/cli/lib/simulation-runner.js.map +1 -1
- package/dist/src/controllers/AttentionService.d.ts.map +1 -1
- package/dist/src/controllers/AttentionService.js +5 -3
- package/dist/src/controllers/AttentionService.js.map +1 -1
- package/dist/src/controllers/CausalMemoryGraph.d.ts +8 -33
- package/dist/src/controllers/CausalMemoryGraph.d.ts.map +1 -1
- package/dist/src/controllers/CausalMemoryGraph.js +16 -93
- package/dist/src/controllers/CausalMemoryGraph.js.map +1 -1
- package/dist/src/controllers/CausalRecall.d.ts +3 -6
- package/dist/src/controllers/CausalRecall.d.ts.map +1 -1
- package/dist/src/controllers/CausalRecall.js +8 -14
- package/dist/src/controllers/CausalRecall.js.map +1 -1
- package/dist/src/controllers/ContextSynthesizer.d.ts +1 -1
- package/dist/src/controllers/ContextSynthesizer.d.ts.map +1 -1
- package/dist/src/controllers/EmbeddingService.d.ts.map +1 -1
- package/dist/src/controllers/EmbeddingService.js +3 -10
- package/dist/src/controllers/EmbeddingService.js.map +1 -1
- package/dist/src/controllers/EnhancedEmbeddingService.d.ts +0 -4
- package/dist/src/controllers/EnhancedEmbeddingService.d.ts.map +1 -1
- package/dist/src/controllers/EnhancedEmbeddingService.js +3 -10
- package/dist/src/controllers/EnhancedEmbeddingService.js.map +1 -1
- package/dist/src/controllers/ExplainableRecall.d.ts +6 -5
- package/dist/src/controllers/ExplainableRecall.d.ts.map +1 -1
- package/dist/src/controllers/ExplainableRecall.js +13 -21
- package/dist/src/controllers/ExplainableRecall.js.map +1 -1
- package/dist/src/controllers/HNSWIndex.d.ts +7 -24
- package/dist/src/controllers/HNSWIndex.d.ts.map +1 -1
- package/dist/src/controllers/HNSWIndex.js +10 -89
- package/dist/src/controllers/HNSWIndex.js.map +1 -1
- package/dist/src/controllers/LearningSystem.d.ts +10 -106
- package/dist/src/controllers/LearningSystem.d.ts.map +1 -1
- package/dist/src/controllers/LearningSystem.js +14 -39
- package/dist/src/controllers/LearningSystem.js.map +1 -1
- package/dist/src/controllers/MMRDiversityRanker.d.ts +1 -1
- package/dist/src/controllers/MMRDiversityRanker.d.ts.map +1 -1
- package/dist/src/controllers/MetadataFilter.d.ts +3 -3
- package/dist/src/controllers/MetadataFilter.d.ts.map +1 -1
- package/dist/src/controllers/MetadataFilter.js +6 -9
- package/dist/src/controllers/MetadataFilter.js.map +1 -1
- package/dist/src/controllers/NightlyLearner.d.ts +4 -9
- package/dist/src/controllers/NightlyLearner.d.ts.map +1 -1
- package/dist/src/controllers/NightlyLearner.js +9 -28
- package/dist/src/controllers/NightlyLearner.js.map +1 -1
- package/dist/src/controllers/QUICClient.d.ts +2 -50
- package/dist/src/controllers/QUICClient.d.ts.map +1 -1
- package/dist/src/controllers/QUICClient.js +3 -193
- package/dist/src/controllers/QUICClient.js.map +1 -1
- package/dist/src/controllers/QUICServer.d.ts +4 -4
- package/dist/src/controllers/QUICServer.d.ts.map +1 -1
- package/dist/src/controllers/QUICServer.js +14 -22
- package/dist/src/controllers/QUICServer.js.map +1 -1
- package/dist/src/controllers/ReasoningBank.d.ts +4 -14
- package/dist/src/controllers/ReasoningBank.d.ts.map +1 -1
- package/dist/src/controllers/ReasoningBank.js +46 -59
- package/dist/src/controllers/ReasoningBank.js.map +1 -1
- package/dist/src/controllers/ReflexionMemory.d.ts +7 -80
- package/dist/src/controllers/ReflexionMemory.d.ts.map +1 -1
- package/dist/src/controllers/ReflexionMemory.js +214 -372
- package/dist/src/controllers/ReflexionMemory.js.map +1 -1
- package/dist/src/controllers/SkillLibrary.d.ts +7 -37
- package/dist/src/controllers/SkillLibrary.d.ts.map +1 -1
- package/dist/src/controllers/SkillLibrary.js +96 -212
- package/dist/src/controllers/SkillLibrary.js.map +1 -1
- package/dist/src/controllers/SyncCoordinator.d.ts +3 -2
- package/dist/src/controllers/SyncCoordinator.d.ts.map +1 -1
- package/dist/src/controllers/SyncCoordinator.js +5 -117
- package/dist/src/controllers/SyncCoordinator.js.map +1 -1
- package/dist/src/controllers/WASMVectorSearch.d.ts +9 -20
- package/dist/src/controllers/WASMVectorSearch.d.ts.map +1 -1
- package/dist/src/controllers/WASMVectorSearch.js +29 -154
- package/dist/src/controllers/WASMVectorSearch.js.map +1 -1
- 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 +17 -8
- package/dist/src/controllers/index.d.ts.map +1 -1
- package/dist/src/controllers/index.js +12 -6
- package/dist/src/controllers/index.js.map +1 -1
- package/dist/src/core/AgentDB.d.ts +25 -57
- package/dist/src/core/AgentDB.d.ts.map +1 -1
- package/dist/src/core/AgentDB.js +115 -137
- package/dist/src/core/AgentDB.js.map +1 -1
- package/dist/src/db-fallback.d.ts +1 -10
- package/dist/src/db-fallback.d.ts.map +1 -1
- package/dist/src/db-fallback.js +4 -171
- package/dist/src/db-fallback.js.map +1 -1
- 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 +12 -38
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +11 -46
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/agentdb-mcp-server.js +63 -219
- package/dist/src/mcp/agentdb-mcp-server.js.map +1 -1
- 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 +5 -52
- package/dist/src/optimizations/BatchOperations.d.ts.map +1 -1
- package/dist/src/optimizations/BatchOperations.js +33 -186
- package/dist/src/optimizations/BatchOperations.js.map +1 -1
- package/dist/src/optimizations/QueryOptimizer.d.ts +4 -4
- package/dist/src/optimizations/QueryOptimizer.d.ts.map +1 -1
- package/dist/src/optimizations/QueryOptimizer.js +1 -3
- package/dist/src/optimizations/QueryOptimizer.js.map +1 -1
- package/dist/src/optimizations/ToolCache.d.ts +4 -4
- package/dist/src/optimizations/ToolCache.d.ts.map +1 -1
- package/dist/src/optimizations/ToolCache.js.map +1 -1
- package/dist/src/optimizations/index.d.ts +1 -1
- package/dist/src/optimizations/index.d.ts.map +1 -1
- package/dist/src/security/AttestationLog.d.ts +70 -0
- package/dist/src/security/AttestationLog.d.ts.map +1 -0
- package/dist/src/security/AttestationLog.js +174 -0
- package/dist/src/security/AttestationLog.js.map +1 -0
- package/dist/src/security/MutationGuard.d.ts +83 -0
- package/dist/src/security/MutationGuard.d.ts.map +1 -0
- package/dist/src/security/MutationGuard.js +379 -0
- package/dist/src/security/MutationGuard.js.map +1 -0
- package/dist/src/security/index.d.ts +15 -0
- package/dist/src/security/index.d.ts.map +1 -0
- package/dist/src/security/index.js +18 -0
- package/dist/src/security/index.js.map +1 -0
- package/dist/src/security/input-validation.d.ts +12 -12
- package/dist/src/security/input-validation.d.ts.map +1 -1
- package/dist/src/security/input-validation.js +0 -1
- package/dist/src/security/input-validation.js.map +1 -1
- 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/GraphTransformerService.d.ts +79 -0
- package/dist/src/services/GraphTransformerService.d.ts.map +1 -0
- package/dist/src/services/GraphTransformerService.js +331 -0
- package/dist/src/services/GraphTransformerService.js.map +1 -0
- package/dist/src/services/LLMRouter.d.ts +7 -61
- package/dist/src/services/LLMRouter.d.ts.map +1 -1
- package/dist/src/services/LLMRouter.js +25 -295
- package/dist/src/services/LLMRouter.js.map +1 -1
- package/dist/src/services/SemanticRouter.d.ts +78 -0
- package/dist/src/services/SemanticRouter.d.ts.map +1 -0
- package/dist/src/services/SemanticRouter.js +149 -0
- package/dist/src/services/SemanticRouter.js.map +1 -0
- package/dist/src/services/SonaTrajectoryService.d.ts +100 -0
- package/dist/src/services/SonaTrajectoryService.d.ts.map +1 -0
- package/dist/src/services/SonaTrajectoryService.js +231 -0
- package/dist/src/services/SonaTrajectoryService.js.map +1 -0
- package/dist/src/types/attention.d.ts +249 -0
- package/dist/src/types/attention.d.ts.map +1 -0
- package/dist/src/types/attention.js +43 -0
- package/dist/src/types/attention.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/LegacyAttentionAdapter.d.ts +93 -0
- package/dist/src/utils/LegacyAttentionAdapter.d.ts.map +1 -0
- package/dist/src/utils/LegacyAttentionAdapter.js +241 -0
- package/dist/src/utils/LegacyAttentionAdapter.js.map +1 -0
- package/dist/src/utils/attention-metrics.d.ts +76 -0
- package/dist/src/utils/attention-metrics.d.ts.map +1 -0
- package/dist/src/utils/attention-metrics.js +178 -0
- package/dist/src/utils/attention-metrics.js.map +1 -0
- package/dist/src/utils/vector-math.d.ts +29 -0
- package/dist/src/utils/vector-math.d.ts.map +1 -0
- package/dist/src/utils/vector-math.js +66 -0
- package/dist/src/utils/vector-math.js.map +1 -0
- package/examples/README.md +105 -0
- package/examples/browser/attention-demo.html +499 -0
- package/examples/browser/flash-consolidation.html +598 -0
- package/examples/browser/hyperbolic-hierarchy.html +497 -0
- package/examples/quickstart.js +43 -0
- package/package.json +53 -56
- package/simulation/.claude-flow/metrics/agent-metrics.json +1 -0
- package/simulation/.claude-flow/metrics/performance.json +87 -0
- package/simulation/.claude-flow/metrics/task-metrics.json +10 -0
- package/simulation/COMPLETION-STATUS.md +139 -0
- package/simulation/FINAL-RESULTS.md +414 -0
- package/simulation/FINAL-STATUS.md +281 -0
- package/simulation/INTEGRATION-COMPLETE.md +452 -0
- package/simulation/MIGRATION-STATUS.md +231 -0
- package/simulation/OPTIMIZATION-RESULTS.md +397 -0
- package/simulation/PHASE1-COMPLETE.md +163 -0
- package/simulation/README.md +848 -0
- package/simulation/SIMULATION-RESULTS.md +239 -0
- package/simulation/cli.ts +78 -0
- package/simulation/configs/default.json +37 -0
- package/simulation/data/advanced/aidefence.graph +0 -0
- package/simulation/data/advanced/bmssp.graph +0 -0
- package/simulation/data/advanced/consciousness.graph +0 -0
- package/simulation/data/advanced/goalie.graph +0 -0
- package/simulation/data/advanced/psycho-symbolic.graph +0 -0
- package/simulation/data/advanced/research-swarm.graph +0 -0
- package/simulation/data/advanced/sublinear.graph +0 -0
- package/simulation/data/advanced/temporal.graph +0 -0
- package/simulation/data/causal.graph +0 -0
- package/simulation/data/graph-traversal.graph +0 -0
- package/simulation/data/lean-agentic.graph +0 -0
- package/simulation/data/reflexion.graph +0 -0
- package/simulation/data/skills.graph +0 -0
- package/simulation/data/stock-market.graph +0 -0
- package/simulation/data/strange-loops.graph +0 -0
- package/simulation/data/swarm.graph +0 -0
- package/simulation/data/voting-consensus.graph +0 -0
- package/simulation/docs/CLI-INTEGRATION-PLAN.md +1038 -0
- package/simulation/docs/COMPREHENSIVE-LATENT-SPACE-COMPLETION.md +354 -0
- package/simulation/docs/DOCUMENTATION-INDEX.md +226 -0
- package/simulation/docs/IMPLEMENTATION-COMPLETE.md +521 -0
- package/simulation/docs/OPTIMIZATION-SUMMARY.md +279 -0
- package/simulation/docs/README.md +229 -0
- package/simulation/docs/SWARM-5-INTEGRATION-SUMMARY.md +528 -0
- package/simulation/docs/TESTING-SUMMARY.md +304 -0
- package/simulation/docs/architecture/EXTENSION-API.md +868 -0
- package/simulation/docs/architecture/INTEGRATION-ARCHITECTURE.md +1138 -0
- package/simulation/docs/architecture/OPTIMIZATION-STRATEGY.md +778 -0
- package/simulation/docs/architecture/SIMULATION-ARCHITECTURE.md +892 -0
- package/simulation/docs/guides/CLI-REFERENCE.md +896 -0
- package/simulation/docs/guides/CUSTOM-SIMULATIONS.md +931 -0
- package/simulation/docs/guides/DEPLOYMENT.md +832 -0
- package/simulation/docs/guides/IMPLEMENTATION-SUMMARY.md +544 -0
- package/simulation/docs/guides/MIGRATION-GUIDE.md +591 -0
- package/simulation/docs/guides/QUICK-START.md +361 -0
- package/simulation/docs/guides/README.md +736 -0
- package/simulation/docs/guides/TROUBLESHOOTING.md +817 -0
- package/simulation/docs/guides/WIZARD-GUIDE.md +869 -0
- package/simulation/docs/reports/latent-space/MASTER-SYNTHESIS.md +345 -0
- package/simulation/docs/reports/latent-space/README.md +132 -0
- package/simulation/docs/reports/latent-space/attention-analysis-RESULTS.md +238 -0
- package/simulation/docs/reports/latent-space/clustering-analysis-RESULTS.md +210 -0
- package/simulation/docs/reports/latent-space/hnsw-exploration-RESULTS.md +332 -0
- package/simulation/docs/reports/latent-space/hypergraph-exploration-RESULTS.md +37 -0
- package/simulation/docs/reports/latent-space/neural-augmentation-RESULTS.md +69 -0
- package/simulation/docs/reports/latent-space/quantum-hybrid-RESULTS.md +91 -0
- package/simulation/docs/reports/latent-space/self-organizing-hnsw-RESULTS.md +51 -0
- package/simulation/docs/reports/latent-space/traversal-optimization-RESULTS.md +238 -0
- package/simulation/reports/README.md +397 -0
- package/simulation/reports/advanced-simulations-performance.md +1241 -0
- package/simulation/reports/aidefence-integration-2025-11-30T01-36-53-486Z.json +30 -0
- package/simulation/reports/architecture-analysis.md +1396 -0
- package/simulation/reports/basic-scenarios-performance.md +1840 -0
- package/simulation/reports/bmssp-integration-2025-11-30T01-36-27-193Z.json +30 -0
- package/simulation/reports/bmssp-integration-2025-11-30T03-38-12-887Z.json +30 -0
- package/simulation/reports/causal-reasoning-2025-11-29T23-35-21-795Z.json +36 -0
- package/simulation/reports/causal-reasoning-2025-11-30T00-58-42-862Z.json +30 -0
- package/simulation/reports/causal-reasoning-2025-11-30T00-59-12-546Z.json +40 -0
- package/simulation/reports/consciousness-explorer-2025-11-30T01-36-51-269Z.json +31 -0
- package/simulation/reports/core-benchmarks.md +727 -0
- package/simulation/reports/goalie-integration-2025-11-30T01-36-52-377Z.json +30 -0
- package/simulation/reports/graph-traversal-2025-11-29T23-35-35-279Z.json +78 -0
- package/simulation/reports/graph-traversal-2025-11-29T23-37-36-697Z.json +30 -0
- package/simulation/reports/graph-traversal-2025-11-30T01-03-59-716Z.json +30 -0
- package/simulation/reports/graph-traversal-2025-11-30T01-05-10-984Z.json +30 -0
- package/simulation/reports/graph-traversal-2025-11-30T01-06-16-334Z.json +30 -0
- package/simulation/reports/graph-traversal-2025-11-30T01-06-53-312Z.json +30 -0
- package/simulation/reports/graph-traversal-2025-11-30T01-07-51-075Z.json +24 -0
- package/simulation/reports/graph-traversal-2025-11-30T01-08-22-179Z.json +42 -0
- package/simulation/reports/lean-agentic-swarm-2025-11-29T23-37-23-804Z.json +148 -0
- package/simulation/reports/lean-agentic-swarm-2025-11-30T01-31-24-401Z.json +31 -0
- package/simulation/reports/lean-agentic-swarm-2025-11-30T03-38-01-470Z.json +31 -0
- package/simulation/reports/multi-agent-swarm-2025-11-29T23-35-28-093Z.json +78 -0
- package/simulation/reports/multi-agent-swarm-2025-11-30T01-03-54-062Z.json +42 -0
- package/simulation/reports/multi-agent-swarm-2025-11-30T01-05-06-092Z.json +42 -0
- package/simulation/reports/psycho-symbolic-reasoner-2025-11-30T01-36-50-180Z.json +30 -0
- package/simulation/reports/quality-metrics.md +727 -0
- package/simulation/reports/reflexion-learning-2025-11-29T23-35-09-774Z.json +48 -0
- package/simulation/reports/reflexion-learning-2025-11-29T23-37-16-934Z.json +36 -0
- package/simulation/reports/reflexion-learning-2025-11-30T00-07-49-259Z.json +30 -0
- package/simulation/reports/reflexion-learning-2025-11-30T00-09-29-319Z.json +51 -0
- package/simulation/reports/reflexion-learning-2025-11-30T00-28-37-659Z.json +51 -0
- package/simulation/reports/reflexion-learning-2025-11-30T01-31-30-690Z.json +29 -0
- package/simulation/reports/reflexion-learning-2025-11-30T03-38-06-937Z.json +29 -0
- package/simulation/reports/research-foundations.md +2004 -0
- package/simulation/reports/research-swarm-2025-11-30T01-36-54-647Z.json +30 -0
- package/simulation/reports/scalability-deployment.md +2404 -0
- package/simulation/reports/skill-evolution-2025-11-29T23-35-15-945Z.json +36 -0
- package/simulation/reports/skill-evolution-2025-11-30T01-03-17-995Z.json +30 -0
- package/simulation/reports/skill-evolution-2025-11-30T01-03-48-441Z.json +30 -0
- package/simulation/reports/skill-evolution-2025-11-30T01-05-00-554Z.json +30 -0
- package/simulation/reports/skill-evolution-2025-11-30T01-06-11-436Z.json +30 -0
- package/simulation/reports/skill-evolution-2025-11-30T01-06-51-979Z.json +30 -0
- package/simulation/reports/skill-evolution-2025-11-30T01-07-32-695Z.json +40 -0
- package/simulation/reports/stock-market-emergence-2025-11-30T00-11-43-865Z.json +56 -0
- package/simulation/reports/stock-market-emergence-2025-11-30T00-28-57-495Z.json +56 -0
- package/simulation/reports/strange-loops-2025-11-29T23-37-30-621Z.json +78 -0
- package/simulation/reports/strange-loops-2025-11-30T00-07-55-415Z.json +30 -0
- package/simulation/reports/strange-loops-2025-11-30T00-09-35-133Z.json +30 -0
- package/simulation/reports/strange-loops-2025-11-30T00-48-50-744Z.json +24 -0
- package/simulation/reports/strange-loops-2025-11-30T00-54-48-044Z.json +24 -0
- package/simulation/reports/strange-loops-2025-11-30T00-57-27-633Z.json +24 -0
- package/simulation/reports/strange-loops-2025-11-30T00-57-59-135Z.json +42 -0
- package/simulation/reports/sublinear-solver-2025-11-30T01-36-33-134Z.json +30 -0
- package/simulation/reports/temporal-lead-solver-2025-11-30T01-36-38-628Z.json +30 -0
- package/simulation/reports/use-cases-applications.md +2212 -0
- package/simulation/reports/voting-system-consensus-2025-11-30T00-11-37-199Z.json +58 -0
- package/simulation/reports/voting-system-consensus-2025-11-30T00-28-47-735Z.json +58 -0
- package/simulation/runner.ts +300 -0
- package/simulation/scenarios/README-advanced/aidefence-integration.md +63 -0
- package/simulation/scenarios/README-advanced/bmssp-integration.md +58 -0
- package/simulation/scenarios/README-advanced/consciousness-explorer.md +53 -0
- package/simulation/scenarios/README-advanced/goalie-integration.md +61 -0
- package/simulation/scenarios/README-advanced/psycho-symbolic-reasoner.md +55 -0
- package/simulation/scenarios/README-advanced/research-swarm.md +63 -0
- package/simulation/scenarios/README-advanced/sublinear-solver.md +58 -0
- package/simulation/scenarios/README-advanced/temporal-lead-solver.md +55 -0
- package/simulation/scenarios/README-basic/causal-reasoning.md +39 -0
- package/simulation/scenarios/README-basic/graph-traversal.md +41 -0
- package/simulation/scenarios/README-basic/lean-agentic-swarm.md +122 -0
- package/simulation/scenarios/README-basic/multi-agent-swarm.md +34 -0
- package/simulation/scenarios/README-basic/reflexion-learning.md +41 -0
- package/simulation/scenarios/README-basic/skill-evolution.md +38 -0
- package/simulation/scenarios/README-basic/stock-market-emergence.md +28 -0
- package/simulation/scenarios/README-basic/strange-loops.md +36 -0
- package/simulation/scenarios/README-basic/voting-system-consensus.md +28 -0
- package/simulation/scenarios/README.md +438 -0
- package/simulation/scenarios/aidefence-integration.ts +165 -0
- package/simulation/scenarios/bmssp-integration.ts +137 -0
- package/simulation/scenarios/causal-reasoning.ts +143 -0
- package/simulation/scenarios/consciousness-explorer.ts +139 -0
- package/simulation/scenarios/domain-examples/.claude-flow/metrics/agent-metrics.json +1 -0
- package/simulation/scenarios/domain-examples/.claude-flow/metrics/performance.json +87 -0
- package/simulation/scenarios/domain-examples/.claude-flow/metrics/task-metrics.json +10 -0
- package/simulation/scenarios/domain-examples/README.md +525 -0
- package/simulation/scenarios/domain-examples/e-commerce-recommendations.ts +220 -0
- package/simulation/scenarios/domain-examples/index.ts +81 -0
- package/simulation/scenarios/domain-examples/iot-sensor-networks.ts +290 -0
- package/simulation/scenarios/domain-examples/medical-imaging.ts +181 -0
- package/simulation/scenarios/domain-examples/robotics-navigation.ts +214 -0
- package/simulation/scenarios/domain-examples/scientific-research.ts +250 -0
- package/simulation/scenarios/domain-examples/trading-systems.ts +138 -0
- package/simulation/scenarios/goalie-integration.ts +161 -0
- package/simulation/scenarios/graph-traversal.ts +129 -0
- package/simulation/scenarios/latent-space/OPTIMIZATION-COMPLETE.md +287 -0
- package/simulation/scenarios/latent-space/README-attention-analysis.md +170 -0
- package/simulation/scenarios/latent-space/README-clustering-analysis.md +239 -0
- package/simulation/scenarios/latent-space/README-hnsw-exploration.md +199 -0
- package/simulation/scenarios/latent-space/README-hypergraph-exploration.md +279 -0
- package/simulation/scenarios/latent-space/README-neural-augmentation.md +267 -0
- package/simulation/scenarios/latent-space/README-quantum-hybrid.md +276 -0
- package/simulation/scenarios/latent-space/README-self-organizing-hnsw.md +244 -0
- package/simulation/scenarios/latent-space/README-traversal-optimization.md +212 -0
- package/simulation/scenarios/latent-space/attention-analysis.ts +598 -0
- package/simulation/scenarios/latent-space/clustering-analysis.ts +796 -0
- package/simulation/scenarios/latent-space/hnsw-exploration.ts +526 -0
- package/simulation/scenarios/latent-space/hypergraph-exploration.ts +706 -0
- package/simulation/scenarios/latent-space/index.ts +47 -0
- package/simulation/scenarios/latent-space/neural-augmentation.ts +604 -0
- package/simulation/scenarios/latent-space/quantum-hybrid.ts +508 -0
- package/simulation/scenarios/latent-space/self-organizing-hnsw.ts +680 -0
- package/simulation/scenarios/latent-space/traversal-optimization.ts +782 -0
- package/simulation/scenarios/lean-agentic-swarm.ts +182 -0
- package/simulation/scenarios/multi-agent-swarm.ts +146 -0
- package/simulation/scenarios/psycho-symbolic-reasoner.ts +136 -0
- package/simulation/scenarios/reflexion-learning.ts +132 -0
- package/simulation/scenarios/research-swarm.ts +187 -0
- package/simulation/scenarios/skill-evolution.ts +135 -0
- package/simulation/scenarios/stock-market-emergence.ts +323 -0
- package/simulation/scenarios/strange-loops.ts +175 -0
- package/simulation/scenarios/sublinear-solver.ts +108 -0
- package/simulation/scenarios/temporal-lead-solver.ts +121 -0
- package/simulation/scenarios/voting-system-consensus.ts +251 -0
- package/simulation/tests/latent-space/attention-analysis.test.ts +204 -0
- package/simulation/tests/latent-space/clustering-analysis.test.ts +281 -0
- package/simulation/tests/latent-space/hnsw-exploration.test.ts +253 -0
- package/simulation/tests/latent-space/hypergraph-exploration.test.ts +295 -0
- package/simulation/tests/latent-space/neural-augmentation.test.ts +326 -0
- package/simulation/tests/latent-space/quantum-hybrid.test.ts +307 -0
- package/simulation/tests/latent-space/self-organizing-hnsw.test.ts +291 -0
- package/simulation/tests/latent-space/traversal-optimization.test.ts +261 -0
- package/simulation/types.ts +177 -0
- package/simulation/utils/PerformanceOptimizer.ts +269 -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 +147 -0
- package/src/backends/detector.ts +283 -0
- package/src/backends/factory.ts +279 -0
- package/src/backends/graph/GraphDatabaseAdapter.ts +334 -0
- package/src/backends/hnswlib/HNSWLibBackend.ts +419 -0
- package/src/backends/hnswlib/index.ts +7 -0
- package/src/backends/index.ts +32 -0
- package/src/backends/ruvector/GuardedVectorBackend.ts +219 -0
- package/src/backends/ruvector/RuVectorBackend.ts +343 -0
- package/src/backends/ruvector/RuVectorLearning.ts +254 -0
- package/src/backends/ruvector/index.ts +9 -0
- package/src/benchmarks/wasm-vector-benchmark.ts +250 -0
- package/src/browser/AdvancedFeatures.ts +565 -0
- package/src/browser/AttentionBrowser.ts +387 -0
- package/src/browser/HNSWIndex.ts +494 -0
- package/src/browser/ProductQuantization.ts +419 -0
- package/src/browser/index.ts +317 -0
- package/src/cli/agentdb-cli.ts +2712 -0
- package/src/cli/attention-cli-integration.ts +91 -0
- package/src/cli/commands/attention.ts +656 -0
- package/src/cli/commands/doctor.ts +322 -0
- package/src/cli/commands/init.ts +176 -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/examples.sh +83 -0
- package/src/cli/lib/attention-config.ts +326 -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 +503 -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 +503 -0
- package/src/cli/lib/simulation-runner.ts +291 -0
- package/src/cli/tests/agentdb-cli.test.ts +58 -0
- package/src/cli/tests/attention-cli.test.ts +335 -0
- package/src/controllers/AttentionService.ts +770 -0
- package/src/controllers/CausalMemoryGraph.ts +773 -0
- package/src/controllers/CausalRecall.ts +484 -0
- package/src/controllers/ContextSynthesizer.ts +285 -0
- package/src/controllers/EmbeddingService.ts +161 -0
- package/src/controllers/EnhancedEmbeddingService.ts +143 -0
- package/src/controllers/ExplainableRecall.ts +746 -0
- package/src/controllers/HNSWIndex.ts +495 -0
- package/src/controllers/LearningSystem.ts +1270 -0
- package/src/controllers/MMRDiversityRanker.ts +187 -0
- package/src/controllers/MetadataFilter.ts +280 -0
- package/src/controllers/NightlyLearner.ts +647 -0
- package/src/controllers/QUICClient.ts +413 -0
- package/src/controllers/QUICServer.ts +498 -0
- package/src/controllers/ReasoningBank.ts +665 -0
- package/src/controllers/ReflexionMemory.ts +872 -0
- package/src/controllers/SkillLibrary.ts +795 -0
- package/src/controllers/SyncCoordinator.ts +597 -0
- package/src/controllers/WASMVectorSearch.ts +292 -0
- package/src/controllers/frontier-index.ts +35 -0
- package/src/controllers/index.ts +57 -0
- package/src/coordination/MultiDatabaseCoordinator.ts +1107 -0
- package/src/coordination/index.ts +24 -0
- package/src/core/AgentDB.ts +211 -0
- package/src/db-fallback.ts +296 -0
- package/src/db-test.ts +59 -0
- package/src/db-unified.ts +327 -0
- package/src/examples/quic-sync-example.ts +198 -0
- package/src/examples/wasm-vector-usage.ts +245 -0
- package/src/index.ts +69 -0
- package/src/mcp/agentdb-mcp-server.ts +2318 -0
- package/src/mcp/attention-mcp-integration.ts +145 -0
- package/src/mcp/attention-tools-handlers.ts +586 -0
- package/src/mcp/learning-tools-handlers.ts +106 -0
- package/src/optimizations/BatchOperations.ts +594 -0
- package/src/optimizations/QueryOptimizer.ts +297 -0
- package/src/optimizations/ToolCache.ts +355 -0
- package/src/optimizations/index.ts +11 -0
- package/src/schemas/frontier-schema.sql +378 -0
- package/src/schemas/schema.sql +382 -0
- package/src/security/AttestationLog.ts +252 -0
- package/src/security/MutationGuard.ts +420 -0
- package/src/security/index.ts +52 -0
- package/src/security/input-validation.ts +543 -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/GraphTransformerService.ts +389 -0
- package/src/services/LLMRouter.ts +380 -0
- package/src/services/SemanticRouter.ts +169 -0
- package/src/services/SonaTrajectoryService.ts +264 -0
- package/src/tests/attention-service.test.ts +492 -0
- package/src/tests/wasm-vector-search.test.ts +240 -0
- package/src/types/attention.ts +392 -0
- package/src/types/quic.ts +772 -0
- package/src/utils/LegacyAttentionAdapter.ts +393 -0
- package/src/utils/NodeIdMapper.ts +64 -0
- package/src/utils/attention-metrics.ts +253 -0
- package/src/utils/vector-math.ts +71 -0
- package/LICENSE +0 -21
- package/dist/src/backends/rvf/AdaptiveIndexTuner.d.ts +0 -175
- package/dist/src/backends/rvf/AdaptiveIndexTuner.d.ts.map +0 -1
- package/dist/src/backends/rvf/AdaptiveIndexTuner.js +0 -559
- package/dist/src/backends/rvf/AdaptiveIndexTuner.js.map +0 -1
- package/dist/src/backends/rvf/ContrastiveTrainer.d.ts +0 -148
- package/dist/src/backends/rvf/ContrastiveTrainer.d.ts.map +0 -1
- package/dist/src/backends/rvf/ContrastiveTrainer.js +0 -438
- package/dist/src/backends/rvf/ContrastiveTrainer.js.map +0 -1
- package/dist/src/backends/rvf/FederatedSessionManager.d.ts +0 -211
- package/dist/src/backends/rvf/FederatedSessionManager.d.ts.map +0 -1
- package/dist/src/backends/rvf/FederatedSessionManager.js +0 -389
- package/dist/src/backends/rvf/FederatedSessionManager.js.map +0 -1
- package/dist/src/backends/rvf/FilterBuilder.d.ts +0 -136
- package/dist/src/backends/rvf/FilterBuilder.d.ts.map +0 -1
- package/dist/src/backends/rvf/FilterBuilder.js +0 -157
- package/dist/src/backends/rvf/FilterBuilder.js.map +0 -1
- package/dist/src/backends/rvf/NativeAccelerator.d.ts +0 -140
- package/dist/src/backends/rvf/NativeAccelerator.d.ts.map +0 -1
- package/dist/src/backends/rvf/NativeAccelerator.js +0 -630
- package/dist/src/backends/rvf/NativeAccelerator.js.map +0 -1
- package/dist/src/backends/rvf/RvfBackend.d.ts +0 -194
- package/dist/src/backends/rvf/RvfBackend.d.ts.map +0 -1
- package/dist/src/backends/rvf/RvfBackend.js +0 -607
- package/dist/src/backends/rvf/RvfBackend.js.map +0 -1
- package/dist/src/backends/rvf/RvfSolver.d.ts +0 -175
- package/dist/src/backends/rvf/RvfSolver.d.ts.map +0 -1
- package/dist/src/backends/rvf/RvfSolver.js +0 -176
- package/dist/src/backends/rvf/RvfSolver.js.map +0 -1
- package/dist/src/backends/rvf/SelfLearningRvfBackend.d.ts +0 -143
- package/dist/src/backends/rvf/SelfLearningRvfBackend.d.ts.map +0 -1
- package/dist/src/backends/rvf/SelfLearningRvfBackend.js +0 -569
- package/dist/src/backends/rvf/SelfLearningRvfBackend.js.map +0 -1
- package/dist/src/backends/rvf/SemanticQueryRouter.d.ts +0 -128
- package/dist/src/backends/rvf/SemanticQueryRouter.d.ts.map +0 -1
- package/dist/src/backends/rvf/SemanticQueryRouter.js +0 -415
- package/dist/src/backends/rvf/SemanticQueryRouter.js.map +0 -1
- package/dist/src/backends/rvf/SimdFallbacks.d.ts +0 -25
- package/dist/src/backends/rvf/SimdFallbacks.d.ts.map +0 -1
- package/dist/src/backends/rvf/SimdFallbacks.js +0 -287
- package/dist/src/backends/rvf/SimdFallbacks.js.map +0 -1
- package/dist/src/backends/rvf/SolverBandit.d.ts +0 -100
- package/dist/src/backends/rvf/SolverBandit.d.ts.map +0 -1
- package/dist/src/backends/rvf/SolverBandit.js +0 -216
- package/dist/src/backends/rvf/SolverBandit.js.map +0 -1
- package/dist/src/backends/rvf/SonaLearningBackend.d.ts +0 -157
- package/dist/src/backends/rvf/SonaLearningBackend.d.ts.map +0 -1
- package/dist/src/backends/rvf/SonaLearningBackend.js +0 -283
- package/dist/src/backends/rvf/SonaLearningBackend.js.map +0 -1
- package/dist/src/backends/rvf/SqlJsRvfBackend.d.ts +0 -77
- package/dist/src/backends/rvf/SqlJsRvfBackend.d.ts.map +0 -1
- package/dist/src/backends/rvf/SqlJsRvfBackend.js +0 -382
- package/dist/src/backends/rvf/SqlJsRvfBackend.js.map +0 -1
- package/dist/src/backends/rvf/WasmStoreBridge.d.ts +0 -27
- package/dist/src/backends/rvf/WasmStoreBridge.d.ts.map +0 -1
- package/dist/src/backends/rvf/WasmStoreBridge.js +0 -87
- package/dist/src/backends/rvf/WasmStoreBridge.js.map +0 -1
- package/dist/src/backends/rvf/validation.d.ts +0 -20
- package/dist/src/backends/rvf/validation.d.ts.map +0 -1
- package/dist/src/backends/rvf/validation.js +0 -78
- package/dist/src/backends/rvf/validation.js.map +0 -1
- package/dist/src/benchmark/BenchmarkSuite.d.ts +0 -318
- package/dist/src/benchmark/BenchmarkSuite.d.ts.map +0 -1
- package/dist/src/benchmark/BenchmarkSuite.js +0 -986
- package/dist/src/benchmark/BenchmarkSuite.js.map +0 -1
- package/dist/src/benchmark/index.d.ts +0 -29
- package/dist/src/benchmark/index.d.ts.map +0 -1
- package/dist/src/benchmark/index.js +0 -39
- package/dist/src/benchmark/index.js.map +0 -1
- package/dist/src/cli/commands/hyperbolic.d.ts +0 -11
- package/dist/src/cli/commands/hyperbolic.d.ts.map +0 -1
- package/dist/src/cli/commands/hyperbolic.js +0 -428
- package/dist/src/cli/commands/hyperbolic.js.map +0 -1
- package/dist/src/cli/commands/learn.d.ts +0 -11
- package/dist/src/cli/commands/learn.d.ts.map +0 -1
- package/dist/src/cli/commands/learn.js +0 -404
- package/dist/src/cli/commands/learn.js.map +0 -1
- package/dist/src/cli/commands/route.d.ts +0 -11
- package/dist/src/cli/commands/route.d.ts.map +0 -1
- package/dist/src/cli/commands/route.js +0 -414
- package/dist/src/cli/commands/route.js.map +0 -1
- package/dist/src/cli/commands/rvf.d.ts +0 -21
- package/dist/src/cli/commands/rvf.d.ts.map +0 -1
- package/dist/src/cli/commands/rvf.js +0 -448
- package/dist/src/cli/commands/rvf.js.map +0 -1
- package/dist/src/cli/tests/agentdb-cli.test.d.ts +0 -8
- package/dist/src/cli/tests/agentdb-cli.test.d.ts.map +0 -1
- package/dist/src/cli/tests/agentdb-cli.test.js +0 -50
- package/dist/src/cli/tests/agentdb-cli.test.js.map +0 -1
- package/dist/src/cli/tests/attention-cli.test.d.ts +0 -5
- package/dist/src/cli/tests/attention-cli.test.d.ts.map +0 -1
- package/dist/src/cli/tests/attention-cli.test.js +0 -257
- package/dist/src/cli/tests/attention-cli.test.js.map +0 -1
- package/dist/src/compatibility/DeprecationWarnings.d.ts +0 -54
- package/dist/src/compatibility/DeprecationWarnings.d.ts.map +0 -1
- package/dist/src/compatibility/DeprecationWarnings.js +0 -131
- package/dist/src/compatibility/DeprecationWarnings.js.map +0 -1
- package/dist/src/compatibility/MigrationUtilities.d.ts +0 -30
- package/dist/src/compatibility/MigrationUtilities.d.ts.map +0 -1
- package/dist/src/compatibility/MigrationUtilities.js +0 -184
- package/dist/src/compatibility/MigrationUtilities.js.map +0 -1
- package/dist/src/compatibility/V1toV2Adapter.d.ts +0 -76
- package/dist/src/compatibility/V1toV2Adapter.d.ts.map +0 -1
- package/dist/src/compatibility/V1toV2Adapter.js +0 -198
- package/dist/src/compatibility/V1toV2Adapter.js.map +0 -1
- package/dist/src/compatibility/VersionDetector.d.ts +0 -32
- package/dist/src/compatibility/VersionDetector.d.ts.map +0 -1
- package/dist/src/compatibility/VersionDetector.js +0 -144
- package/dist/src/compatibility/VersionDetector.js.map +0 -1
- package/dist/src/compatibility/index.d.ts +0 -11
- package/dist/src/compatibility/index.d.ts.map +0 -1
- package/dist/src/compatibility/index.js +0 -10
- package/dist/src/compatibility/index.js.map +0 -1
- package/dist/src/compatibility/types.d.ts +0 -103
- package/dist/src/compatibility/types.d.ts.map +0 -1
- package/dist/src/compatibility/types.js +0 -5
- package/dist/src/compatibility/types.js.map +0 -1
- package/dist/src/controllers/MemoryController.d.ts +0 -161
- package/dist/src/controllers/MemoryController.d.ts.map +0 -1
- package/dist/src/controllers/MemoryController.js +0 -290
- package/dist/src/controllers/MemoryController.js.map +0 -1
- package/dist/src/controllers/attention/CrossAttentionController.d.ts +0 -141
- package/dist/src/controllers/attention/CrossAttentionController.d.ts.map +0 -1
- package/dist/src/controllers/attention/CrossAttentionController.js +0 -325
- package/dist/src/controllers/attention/CrossAttentionController.js.map +0 -1
- package/dist/src/controllers/attention/MultiHeadAttentionController.d.ts +0 -137
- package/dist/src/controllers/attention/MultiHeadAttentionController.d.ts.map +0 -1
- package/dist/src/controllers/attention/MultiHeadAttentionController.js +0 -339
- package/dist/src/controllers/attention/MultiHeadAttentionController.js.map +0 -1
- package/dist/src/controllers/attention/SelfAttentionController.d.ts +0 -117
- package/dist/src/controllers/attention/SelfAttentionController.d.ts.map +0 -1
- package/dist/src/controllers/attention/SelfAttentionController.js +0 -205
- package/dist/src/controllers/attention/SelfAttentionController.js.map +0 -1
- package/dist/src/controllers/attention/index.d.ts +0 -15
- package/dist/src/controllers/attention/index.d.ts.map +0 -1
- package/dist/src/controllers/attention/index.js +0 -12
- package/dist/src/controllers/attention/index.js.map +0 -1
- package/dist/src/core/QueryCache.d.ts +0 -138
- package/dist/src/core/QueryCache.d.ts.map +0 -1
- package/dist/src/core/QueryCache.js +0 -313
- package/dist/src/core/QueryCache.js.map +0 -1
- package/dist/src/observability/index.d.ts +0 -8
- package/dist/src/observability/index.d.ts.map +0 -1
- package/dist/src/observability/index.js +0 -8
- package/dist/src/observability/index.js.map +0 -1
- package/dist/src/observability/integration.d.ts +0 -32
- package/dist/src/observability/integration.d.ts.map +0 -1
- package/dist/src/observability/integration.js +0 -157
- package/dist/src/observability/integration.js.map +0 -1
- package/dist/src/observability/telemetry.d.ts +0 -137
- package/dist/src/observability/telemetry.d.ts.map +0 -1
- package/dist/src/observability/telemetry.js +0 -420
- package/dist/src/observability/telemetry.js.map +0 -1
- package/dist/src/quantization/index.d.ts +0 -7
- package/dist/src/quantization/index.d.ts.map +0 -1
- package/dist/src/quantization/index.js +0 -15
- package/dist/src/quantization/index.js.map +0 -1
- package/dist/src/quantization/vector-quantization.d.ts +0 -388
- package/dist/src/quantization/vector-quantization.d.ts.map +0 -1
- package/dist/src/quantization/vector-quantization.js +0 -1136
- package/dist/src/quantization/vector-quantization.js.map +0 -1
- package/dist/src/search/HybridSearch.d.ts +0 -311
- package/dist/src/search/HybridSearch.d.ts.map +0 -1
- package/dist/src/search/HybridSearch.js +0 -712
- package/dist/src/search/HybridSearch.js.map +0 -1
- package/dist/src/search/index.d.ts +0 -12
- package/dist/src/search/index.d.ts.map +0 -1
- package/dist/src/search/index.js +0 -16
- package/dist/src/search/index.js.map +0 -1
- package/dist/src/services/AttentionService.d.ts +0 -303
- package/dist/src/services/AttentionService.d.ts.map +0 -1
- package/dist/src/services/AttentionService.js +0 -1167
- package/dist/src/services/AttentionService.js.map +0 -1
- package/dist/src/simd/index.d.ts +0 -9
- package/dist/src/simd/index.d.ts.map +0 -1
- package/dist/src/simd/index.js +0 -27
- package/dist/src/simd/index.js.map +0 -1
- package/dist/src/simd/simd-vector-ops.d.ts +0 -332
- package/dist/src/simd/simd-vector-ops.d.ts.map +0 -1
- package/dist/src/simd/simd-vector-ops.js +0 -947
- package/dist/src/simd/simd-vector-ops.js.map +0 -1
- package/dist/src/tests/attention-service.test.d.ts +0 -7
- package/dist/src/tests/attention-service.test.d.ts.map +0 -1
- package/dist/src/tests/attention-service.test.js +0 -401
- package/dist/src/tests/attention-service.test.js.map +0 -1
- package/dist/src/tests/integration/compatibility/backwards-compat.integration.test.d.ts +0 -7
- package/dist/src/tests/integration/compatibility/backwards-compat.integration.test.d.ts.map +0 -1
- package/dist/src/tests/integration/compatibility/backwards-compat.integration.test.js +0 -283
- package/dist/src/tests/integration/compatibility/backwards-compat.integration.test.js.map +0 -1
- package/dist/src/tests/query-cache.test.d.ts +0 -7
- package/dist/src/tests/query-cache.test.d.ts.map +0 -1
- package/dist/src/tests/query-cache.test.js +0 -343
- package/dist/src/tests/query-cache.test.js.map +0 -1
- package/dist/src/tests/ruvector-integration.test.d.ts +0 -14
- package/dist/src/tests/ruvector-integration.test.d.ts.map +0 -1
- package/dist/src/tests/ruvector-integration.test.js +0 -1156
- package/dist/src/tests/ruvector-integration.test.js.map +0 -1
- package/dist/src/tests/unit/auth/crypto.utils.test.d.ts +0 -6
- package/dist/src/tests/unit/auth/crypto.utils.test.d.ts.map +0 -1
- package/dist/src/tests/unit/auth/crypto.utils.test.js +0 -310
- package/dist/src/tests/unit/auth/crypto.utils.test.js.map +0 -1
- package/dist/src/tests/unit/compatibility/deprecation-warnings.test.d.ts +0 -5
- package/dist/src/tests/unit/compatibility/deprecation-warnings.test.d.ts.map +0 -1
- package/dist/src/tests/unit/compatibility/deprecation-warnings.test.js +0 -207
- package/dist/src/tests/unit/compatibility/deprecation-warnings.test.js.map +0 -1
- package/dist/src/tests/unit/compatibility/migration-utils.test.d.ts +0 -5
- package/dist/src/tests/unit/compatibility/migration-utils.test.d.ts.map +0 -1
- package/dist/src/tests/unit/compatibility/migration-utils.test.js +0 -264
- package/dist/src/tests/unit/compatibility/migration-utils.test.js.map +0 -1
- package/dist/src/tests/unit/compatibility/v1-adapter.test.d.ts +0 -7
- package/dist/src/tests/unit/compatibility/v1-adapter.test.d.ts.map +0 -1
- package/dist/src/tests/unit/compatibility/v1-adapter.test.js +0 -228
- package/dist/src/tests/unit/compatibility/v1-adapter.test.js.map +0 -1
- package/dist/src/tests/unit/compatibility/version-detector.test.d.ts +0 -10
- package/dist/src/tests/unit/compatibility/version-detector.test.d.ts.map +0 -1
- package/dist/src/tests/unit/compatibility/version-detector.test.js +0 -162
- package/dist/src/tests/unit/compatibility/version-detector.test.js.map +0 -1
- package/dist/src/tests/vector-quantization.test.d.ts +0 -5
- package/dist/src/tests/vector-quantization.test.d.ts.map +0 -1
- package/dist/src/tests/vector-quantization.test.js +0 -338
- package/dist/src/tests/vector-quantization.test.js.map +0 -1
- package/dist/src/tests/wasm-vector-search.test.d.ts +0 -7
- package/dist/src/tests/wasm-vector-search.test.d.ts.map +0 -1
- package/dist/src/tests/wasm-vector-search.test.js +0 -193
- package/dist/src/tests/wasm-vector-search.test.js.map +0 -1
- package/dist/src/types/database.types.d.ts +0 -275
- package/dist/src/types/database.types.d.ts.map +0 -1
- package/dist/src/types/database.types.js +0 -57
- package/dist/src/types/database.types.js.map +0 -1
- package/dist/src/utils/chalk-fallback.d.ts +0 -3
- package/dist/src/utils/chalk-fallback.d.ts.map +0 -1
- package/dist/src/utils/chalk-fallback.js +0 -20
- package/dist/src/utils/chalk-fallback.js.map +0 -1
- package/dist/src/utils/crypto.utils.d.ts +0 -122
- package/dist/src/utils/crypto.utils.d.ts.map +0 -1
- package/dist/src/utils/crypto.utils.js +0 -296
- package/dist/src/utils/crypto.utils.js.map +0 -1
- package/dist/src/utils/similarity.d.ts +0 -11
- package/dist/src/utils/similarity.d.ts.map +0 -1
- package/dist/src/utils/similarity.js +0 -25
- package/dist/src/utils/similarity.js.map +0 -1
- package/dist/src/wasm-loader.d.ts +0 -67
- package/dist/src/wasm-loader.d.ts.map +0 -1
- package/dist/src/wasm-loader.js +0 -78
- package/dist/src/wasm-loader.js.map +0 -1
- package/dist/src/wrappers/agentdb-fast.d.ts +0 -139
- package/dist/src/wrappers/agentdb-fast.d.ts.map +0 -1
- package/dist/src/wrappers/agentdb-fast.js +0 -316
- package/dist/src/wrappers/agentdb-fast.js.map +0 -1
- package/dist/src/wrappers/attention-fallbacks.d.ts +0 -351
- package/dist/src/wrappers/attention-fallbacks.d.ts.map +0 -1
- package/dist/src/wrappers/attention-fallbacks.js +0 -1487
- package/dist/src/wrappers/attention-fallbacks.js.map +0 -1
- package/dist/src/wrappers/embedding-service.d.ts +0 -117
- package/dist/src/wrappers/embedding-service.d.ts.map +0 -1
- package/dist/src/wrappers/embedding-service.js +0 -376
- package/dist/src/wrappers/embedding-service.js.map +0 -1
- package/dist/src/wrappers/gnn-wrapper.d.ts +0 -71
- package/dist/src/wrappers/gnn-wrapper.d.ts.map +0 -1
- package/dist/src/wrappers/gnn-wrapper.js +0 -240
- package/dist/src/wrappers/gnn-wrapper.js.map +0 -1
- package/dist/src/wrappers/index.d.ts +0 -48
- package/dist/src/wrappers/index.d.ts.map +0 -1
- package/dist/src/wrappers/index.js +0 -83
- package/dist/src/wrappers/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,329 +1,56 @@
|
|
|
1
1
|
# AgentDB v3
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> **Proof-gated graph intelligence for AI agents — every mutation requires cryptographic proof**
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/agentdb)
|
|
6
6
|
[](https://www.npmjs.com/package/agentdb)
|
|
7
7
|
[](LICENSE)
|
|
8
8
|
[](https://www.typescriptlang.org/)
|
|
9
|
-
[](tests/)
|
|
10
|
+
[](docs/MCP_TOOL_OPTIMIZATION_GUIDE.md)
|
|
11
|
+
[](docs/DEEP-REVIEW-V2-LATENT-SPACE.md)
|
|
12
|
+
[](simulation/README.md)
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## What is AgentDB?
|
|
14
|
-
|
|
15
|
-
**AgentDB is a vector database that gets smarter every time you use it.**
|
|
16
|
-
|
|
17
|
-
Most vector databases store and retrieve embeddings. AgentDB does that too — 150x faster — but it also watches which results your AI agent actually used, learns from that feedback, and returns better results next time. Search quality improves by up to **36% automatically**, with zero manual tuning.
|
|
18
|
-
|
|
19
|
-
Everything lives in a **single Cognitive Container** (`.rvf` file) — vectors, indexes, learning state, and a cryptographic audit trail. No external services. No API keys. No monthly bills.
|
|
20
|
-
|
|
21
|
-
> **3 lines to self-learning search:**
|
|
22
|
-
> ```typescript
|
|
23
|
-
> const backend = await SelfLearningRvfBackend.create({ learning: true, storagePath: './my.rvf' });
|
|
24
|
-
> const results = await backend.searchAsync(query, 10); // search
|
|
25
|
-
> backend.recordFeedback('q1', 0.9); // learn — next search is smarter
|
|
26
|
-
> ```
|
|
27
|
-
|
|
28
|
-
### Who is it for?
|
|
29
|
-
|
|
30
|
-
| If you're building... | AgentDB gives you... |
|
|
31
|
-
| --- | --- |
|
|
32
|
-
| **A RAG chatbot** | Search that learns which documents actually answer user questions |
|
|
33
|
-
| **A code review agent** | Pattern memory that remembers what worked across 1000s of reviews |
|
|
34
|
-
| **A research assistant** | Skill library that builds reusable tools from successful strategies |
|
|
35
|
-
| **An RL-powered agent** | 9 algorithms from Q-Learning to PPO, with bandit-guided algorithm selection and transfer learning |
|
|
36
|
-
| **A Claude Code / MCP tool** | 41 tools that plug in with one command |
|
|
37
|
-
| **An offline or edge app** | Full vector DB in the browser via WASM — no server needed |
|
|
38
|
-
| **An enterprise platform** | JWT auth, API key rotation, Argon2id hashing, SOC2/GDPR audit logs |
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## Features
|
|
43
|
-
|
|
44
|
-
### Intelligence
|
|
45
|
-
|
|
46
|
-
| | |
|
|
47
|
-
| --- | --- |
|
|
48
|
-
| **Self-Learning Search** | Gets 36% better over time — learns from feedback, no manual tuning |
|
|
49
|
-
| **Cognitive Memory** | 6 human-inspired patterns: learn from mistakes, build reusable skills, discover what causes what |
|
|
50
|
-
| **Decision Intelligence** | Thompson Sampling bandit auto-tunes skill selection, pattern ranking, compression tiers, and RL algorithm choice |
|
|
51
|
-
| **9 RL Algorithms** | Q-Learning, SARSA, DQN, PPO, Actor-Critic, Policy Gradient, Decision Transformer, MCTS, Model-Based RL |
|
|
52
|
-
| **Hybrid Search** | BM25 keyword + vector with Reciprocal Rank Fusion — exact matches + semantic understanding |
|
|
53
|
-
| **Graph Intelligence** | Cypher queries, causal reasoning, GNN 8-head attention (+12.4% recall) |
|
|
54
|
-
|
|
55
|
-
### Performance
|
|
56
|
-
|
|
57
|
-
| | |
|
|
58
|
-
| --- | --- |
|
|
59
|
-
| **150x Faster** | 61us search with Rust+SIMD — 800x faster than Pinecone, 160x faster than Chroma |
|
|
60
|
-
| **4 Backends** | Auto-selects best available: RuVector (Rust) > RVF > HNSWLib (C++) > sql.js (WASM) |
|
|
61
|
-
| **Runs Anywhere** | Node.js, browsers (WASM), edge functions, fully offline |
|
|
62
|
-
| **AgentDBFast** | 50-200x faster programmatic API — skip CLI overhead for production workloads |
|
|
63
|
-
|
|
64
|
-
### Storage & Data
|
|
14
|
+
AgentDB is the first vector database built specifically for autonomous AI agents. v3 introduces **proof-gated mutations** — every state-changing operation requires a cryptographic proof before the backend will execute it. Powered by `@ruvector/graph-transformer` with 8 verified graph modules, native Rust performance via NAPI-RS, and 82-byte attestations.
|
|
65
15
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
16
|
+
**What's new in v3:**
|
|
17
|
+
- Proof-gated mutations via MutationGuard — bad inputs never reach the native addon
|
|
18
|
+
- 8 graph-transformer modules: sublinear attention, verified training, causal attention, Granger extraction, Hamiltonian dynamics, spiking attention, game-theoretic equilibrium, product manifold distance
|
|
19
|
+
- Re-enabled vectorBackend (was disabled in v2 due to unhandled native addon errors)
|
|
20
|
+
- All 21 controllers wired and active
|
|
21
|
+
- Complete barrel exports for controllers and security primitives
|
|
72
22
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
| | |
|
|
76
|
-
| --- | --- |
|
|
77
|
-
| **41 MCP Tools** | One command to connect to Claude Code, Cursor, or any MCP-compatible assistant |
|
|
78
|
-
| **Chat UI** | `@agentdb/chat` — deploy a self-learning RAG chatbot in one line |
|
|
79
|
-
| **LLM Router** | Auto-selects best provider: RuvLLM (local), OpenRouter (200+ models), Gemini, Claude, ONNX |
|
|
80
|
-
| **Real-Time Sync** | QUIC transport, multi-instance replication, 4 conflict resolution strategies |
|
|
81
|
-
|
|
82
|
-
### Enterprise & Security
|
|
83
|
-
|
|
84
|
-
| | |
|
|
85
|
-
| --- | --- |
|
|
86
|
-
| **Auth & Audit** | JWT tokens, Argon2id hashing, API key rotation, SOC2/GDPR/HIPAA logging |
|
|
87
|
-
| **Security** | Input validation, XSS/injection prevention, Cypher sanitization, witness chain verification |
|
|
88
|
-
| **Observability** | OpenTelemetry traces, Prometheus metrics, structured logging |
|
|
89
|
-
| **Benchmarking** | 5 built-in benchmarks, custom benchmark classes, Markdown/JSON reports |
|
|
90
|
-
|
|
91
|
-
> **Zero config, zero cost.** `npm install agentdb` and go — fully local, no API keys, no cloud fees.
|
|
92
|
-
|
|
93
|
-
### Install
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
npm install agentdb # Latest stable (v2)
|
|
97
|
-
npm install agentdb@alpha # Latest alpha (v3 — unified .rvf, self-learning, SolverBandit)
|
|
98
|
-
```
|
|
23
|
+
**Perfect for:** LangChain agents, AutoGPT, Claude Code tools, custom AI assistants, RAG systems, or any application where AI needs to remember, learn, and improve.
|
|
99
24
|
|
|
100
25
|
---
|
|
101
26
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
> **61 microseconds.** That's 800x faster than Pinecone, 160x faster than Chroma, and the only vector database that learns from your usage and gets better over time.
|
|
105
|
-
|
|
106
|
-
### vs. Other Vector Databases
|
|
107
|
-
|
|
108
|
-
#### Intelligence
|
|
109
|
-
|
|
110
|
-
| Feature | AgentDB v3 | Pinecone | Chroma | Weaviate | pgvector |
|
|
111
|
-
| --- | --- | --- | --- | --- | --- |
|
|
112
|
-
| Self-learning pipeline | SONA + contrastive + federated + bandit | No | No | No | No |
|
|
113
|
-
| Reinforcement learning | 9 algorithms (Q-Learning to MCTS) | No | No | No | No |
|
|
114
|
-
| Cognitive memory | 6 patterns | No | No | No | No |
|
|
115
|
-
| Hybrid search | BM25 + vector (RRF fusion) | No | No | BM25 only | No |
|
|
116
|
-
| Graph queries | Cypher | No | No | GraphQL | No |
|
|
117
|
-
|
|
118
|
-
#### Performance & Deployment
|
|
119
|
-
|
|
120
|
-
| Feature | AgentDB v3 | Pinecone | Chroma | Weaviate | pgvector |
|
|
121
|
-
| --- | --- | --- | --- | --- | --- |
|
|
122
|
-
| Search latency | **61us** | ~50ms | ~10ms | ~5ms | ~2ms |
|
|
123
|
-
| Runs offline | Full | No | Yes | Yes | Yes |
|
|
124
|
-
| Browser (WASM) | Yes | No | No | No | No |
|
|
125
|
-
|
|
126
|
-
#### Storage
|
|
127
|
-
|
|
128
|
-
| Feature | AgentDB v3 | Pinecone | Chroma | Weaviate | pgvector |
|
|
129
|
-
| --- | --- | --- | --- | --- | --- |
|
|
130
|
-
| Cognitive Container | Single `.rvf` file + COW branching | No | No | No | No |
|
|
131
|
-
| Monthly cost | **$0** | $70+ | $0 | $0+ | $0+ |
|
|
27
|
+
> **v3.0 Alpha Available!** `npm install agentdb@v3` (or `agentdb@alpha` once promoted). Production users should use `npm install agentdb@latest` for the stable v2 release.
|
|
132
28
|
|
|
133
|
-
|
|
29
|
+
## Key Features
|
|
134
30
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
| **RuVector** (Rust + SIMD) | 61us | 96.8% | Yes | Production, high throughput |
|
|
146
|
-
| **Cognitive Container** (RVF) | ~100us | 96.8% | Yes | Portable, branching, lineage |
|
|
147
|
-
| **HNSWLib** (C++) | ~500us | 95%+ | Yes | Compatibility |
|
|
148
|
-
| **sql.js** (WASM) | ~5ms | 90%+ | No | Zero-dependency fallback |
|
|
149
|
-
|
|
150
|
-
AgentDB auto-selects the best available: RuVector > Cognitive Container (RVF) > HNSWLib > sql.js
|
|
151
|
-
|
|
152
|
-
---
|
|
31
|
+
- **Proof-Gated Mutations** — Every insert/search/remove requires a MutationProof with structural hash and attestation token
|
|
32
|
+
- **8 Graph-Transformer Modules** — Native Rust via @ruvector/graph-transformer with JS fallback
|
|
33
|
+
- **21 Active Controllers** — Reflexion, Skills, ReasoningBank, CausalGraph, CausalRecall, LearningSystem, ExplainableRecall, NightlyLearner, and more
|
|
34
|
+
- **150x Faster Vector Search** — RuVector Rust backend with SIMD (61us p50 latency)
|
|
35
|
+
- **AttestationLog** — Append-only audit log for every proof and denial
|
|
36
|
+
- **GuardedVectorBackend** — Drop-in VectorBackend wrapper that enforces proof gates
|
|
37
|
+
- **Six Cognitive Memory Patterns** — Reflexion, Skills, Causal Memory, Explainable Recall, Utility Ranking, Nightly Learner
|
|
38
|
+
- **Runs Anywhere** — Node.js, browsers, edge functions, MCP tools
|
|
39
|
+
- **Zero Configuration** — Auto-selects optimal backend (RuVector -> HNSWLib -> sql.js)
|
|
40
|
+
- **$0 Cost** — Fully local, no API keys, no cloud fees
|
|
153
41
|
|
|
154
42
|
## Quick Start
|
|
155
43
|
|
|
156
|
-
|
|
157
|
-
npm install agentdb
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
### Unified AgentDB (recommended)
|
|
161
|
-
|
|
162
|
-
The `AgentDB` class is the simplest way to use AgentDB. Everything — vectors, relational data, learning state — lives in a single `.rvf` file:
|
|
163
|
-
|
|
164
|
-
```typescript
|
|
165
|
-
import { AgentDB } from 'agentdb';
|
|
166
|
-
|
|
167
|
-
const db = new AgentDB({ dbPath: './knowledge.rvf' });
|
|
168
|
-
await db.initialize();
|
|
169
|
-
|
|
170
|
-
// All controllers are ready — reflexion memory, skill library, causal graph
|
|
171
|
-
const reflexion = db.getController('reflexion');
|
|
172
|
-
const skills = db.getController('skills');
|
|
173
|
-
const causal = db.getController('causal');
|
|
174
|
-
|
|
175
|
-
// Store an episode
|
|
176
|
-
await reflexion.storeEpisode({
|
|
177
|
-
sessionId: 'session-1',
|
|
178
|
-
task: 'Fix auth bug',
|
|
179
|
-
reward: 0.95,
|
|
180
|
-
success: true,
|
|
181
|
-
critique: 'OAuth2 PKCE was the right approach',
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
// Create a reusable skill
|
|
185
|
-
await skills.createSkill({
|
|
186
|
-
name: 'jwt_auth',
|
|
187
|
-
description: 'JWT authentication with refresh tokens',
|
|
188
|
-
code: 'implementation...',
|
|
189
|
-
successRate: 0.92,
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
// Save everything to one file and close
|
|
193
|
-
await db.save();
|
|
194
|
-
await db.close();
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
**Configuration options:**
|
|
198
|
-
|
|
199
|
-
| Option | Default | Description |
|
|
200
|
-
| --- | --- | --- |
|
|
201
|
-
| `dbPath` | `':memory:'` | Path to `.rvf` file (or `.db` for legacy mode) |
|
|
202
|
-
| `vectorBackend` | `'rvf'` | Backend: `'rvf'` (unified), `'auto'`, `'ruvector'`, `'hnswlib'` |
|
|
203
|
-
| `vectorDimension` | `384` | Embedding dimension (384 for MiniLM, 768 for bge-base) |
|
|
204
|
-
| `forceWasm` | `false` | Force sql.js WASM even if better-sqlite3 is available |
|
|
205
|
-
| `enableAttention` | `false` | Enable GNN attention mechanisms |
|
|
206
|
-
|
|
207
|
-
**Controllers:** `db.getController('reflexion')` (ReflexionMemory), `db.getController('skills')` (SkillLibrary), `db.getController('causal')` (CausalMemoryGraph)
|
|
208
|
-
|
|
209
|
-
### CLI — try it in 10 seconds
|
|
210
|
-
|
|
211
|
-
```bash
|
|
212
|
-
npx agentdb init # Initialize a new database
|
|
213
|
-
npx agentdb doctor # Check system health
|
|
214
|
-
npx agentdb rvf status ./store.rvf # Inspect a Cognitive Container
|
|
215
|
-
npx agentdb rvf derive ./prod.rvf ./experiment.rvf # Branch for experiments (instant, COW)
|
|
216
|
-
npx agentdb mcp start # Start MCP server (41 tools)
|
|
217
|
-
npx @agentdb/chat serve --rvf ./kb.rvf --port 3000 # Launch chat UI
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
<details>
|
|
221
|
-
<summary><strong>Complete CLI Reference</strong> — 60+ commands across 8 categories</summary>
|
|
222
|
-
|
|
223
|
-
#### Core
|
|
224
|
-
|
|
225
|
-
```bash
|
|
226
|
-
npx agentdb init # Initialize database
|
|
227
|
-
npx agentdb status # System status and diagnostics
|
|
228
|
-
npx agentdb doctor [--fix] [--verbose] # Health check with auto-fix
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
#### Cognitive Container (RVF) Management
|
|
232
|
-
|
|
233
|
-
```bash
|
|
234
|
-
npx agentdb rvf status ./store.rvf # Container statistics
|
|
235
|
-
npx agentdb rvf compact ./store.rvf # Reclaim space
|
|
236
|
-
npx agentdb rvf derive ./src.rvf ./dst.rvf # COW branch
|
|
237
|
-
npx agentdb rvf segments ./store.rvf # Segment introspection
|
|
238
|
-
npx agentdb rvf detect # SDK availability
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
#### Learning & Training
|
|
242
|
-
|
|
243
|
-
```bash
|
|
244
|
-
npx agentdb learn --session <id> --train # Train a learning session
|
|
245
|
-
npx agentdb learn --status # Learning system status
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
#### Routing
|
|
249
|
-
|
|
250
|
-
```bash
|
|
251
|
-
npx agentdb route --query "search term" # Test semantic routing
|
|
252
|
-
npx agentdb route --list # Show learned intents
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
#### Attention & Hyperbolic
|
|
256
|
-
|
|
257
|
-
```bash
|
|
258
|
-
npx agentdb attention --benchmark # Attention performance test
|
|
259
|
-
npx agentdb hyperbolic --test # Hyperbolic embedding test
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
#### Simulation
|
|
263
|
-
|
|
264
|
-
```bash
|
|
265
|
-
npx agentdb simulate hnsw --iterations 3 # HNSW optimization
|
|
266
|
-
npx agentdb simulate attention --iterations 3 # GNN attention
|
|
267
|
-
npx agentdb simulate self-organizing --days 30 # Self-healing
|
|
268
|
-
npx agentdb simulate --wizard # Interactive wizard
|
|
269
|
-
npx agentdb simulate --custom ./my-scenario.json # Custom simulation
|
|
270
|
-
npx agentdb simulate --report ./output.md # Generate report
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
#### Migration & Import
|
|
274
|
-
|
|
275
|
-
```bash
|
|
276
|
-
npx agentdb migrate --source ./old.db --target ./new.db # Full v1→v2 migration
|
|
277
|
-
npx agentdb migrate --source ./v2.db --to v3 --rvf-path ./unified.rvf # v2→v3 unified .rvf
|
|
278
|
-
npx agentdb migrate --to rvf --rvf-path ./out.rvf # Export to Cognitive Container
|
|
279
|
-
npx agentdb migrate --dry-run --verbose # Preview changes
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
#### MCP Server
|
|
44
|
+
Get started in 60 seconds:
|
|
283
45
|
|
|
284
46
|
```bash
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
```
|
|
47
|
+
# Install v3 Alpha (proof-gated graph intelligence)
|
|
48
|
+
npm install agentdb@v3
|
|
288
49
|
|
|
289
|
-
|
|
50
|
+
# Or install Stable (current production v2)
|
|
51
|
+
npm install agentdb@latest
|
|
290
52
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
Most vector databases return the same results no matter how many times you query them. AgentDB closes the loop: after every search, you tell it which results were actually useful. A contrastive trainer (InfoNCE + hard-negative mining) adjusts a lightweight LoRA adapter in under 1 ms, and EWC++ consolidation keeps old knowledge intact. Over 500 feedback cycles, recall jumps from 54% to 90% — automatically.
|
|
294
|
-
|
|
295
|
-
```typescript
|
|
296
|
-
import { SelfLearningRvfBackend } from 'agentdb/backends/rvf/SelfLearningRvfBackend';
|
|
297
|
-
|
|
298
|
-
// Create a self-learning Cognitive Container
|
|
299
|
-
const backend = await SelfLearningRvfBackend.create({
|
|
300
|
-
dimension: 384,
|
|
301
|
-
metric: 'cosine',
|
|
302
|
-
storagePath: './knowledge.rvf',
|
|
303
|
-
learning: true, // enable the learning pipeline
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
// Insert documents
|
|
307
|
-
await backend.insertAsync('doc-1', embedding, { title: 'Auth Guide' });
|
|
308
|
-
await backend.insertAsync('doc-2', embedding2, { title: 'API Reference' });
|
|
309
|
-
|
|
310
|
-
// Search — automatically routed through the learning pipeline
|
|
311
|
-
const results = await backend.searchAsync(queryEmbedding, 10);
|
|
312
|
-
|
|
313
|
-
// Tell AgentDB which results were useful — this drives learning
|
|
314
|
-
backend.recordFeedback('query-1', 0.95); // great result
|
|
315
|
-
backend.recordFeedback('query-2', 0.2); // poor result
|
|
316
|
-
|
|
317
|
-
// Run a learning tick — trains the model, updates adapters
|
|
318
|
-
await backend.tick();
|
|
319
|
-
// Next search will be smarter based on your feedback
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
### Cognitive Memory (pattern learning)
|
|
323
|
-
|
|
324
|
-
Store and retrieve reasoning patterns — your agent remembers what worked:
|
|
325
|
-
|
|
326
|
-
```typescript
|
|
53
|
+
# Use in your code
|
|
327
54
|
import { createDatabase, ReasoningBank, EmbeddingService } from 'agentdb';
|
|
328
55
|
|
|
329
56
|
const db = await createDatabase('./agent-memory.db');
|
|
@@ -336,266 +63,157 @@ const reasoningBank = new ReasoningBank(db, embedder);
|
|
|
336
63
|
await reasoningBank.storePattern({
|
|
337
64
|
taskType: 'code_review',
|
|
338
65
|
approach: 'Security-first analysis',
|
|
339
|
-
successRate: 0.95
|
|
66
|
+
successRate: 0.95
|
|
340
67
|
});
|
|
341
68
|
|
|
342
|
-
// Find similar successful patterns
|
|
69
|
+
// Find similar successful patterns later (32.6M ops/sec!)
|
|
343
70
|
const patterns = await reasoningBank.searchPatterns({
|
|
344
71
|
task: 'security code review',
|
|
345
|
-
k: 10
|
|
72
|
+
k: 10
|
|
346
73
|
});
|
|
347
74
|
```
|
|
348
75
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
```typescript
|
|
354
|
-
import { AgentDB } from 'agentdb';
|
|
355
|
-
|
|
356
|
-
// Single-file mode is the default — no configuration needed
|
|
357
|
-
const db = new AgentDB({ dbPath: './agent.rvf' });
|
|
358
|
-
await db.initialize();
|
|
359
|
-
|
|
360
|
-
// Access the underlying database for advanced queries
|
|
361
|
-
const raw = db.database;
|
|
362
|
-
const stats = raw.prepare('SELECT COUNT(*) as c FROM episodes').get();
|
|
363
|
-
|
|
364
|
-
// Check mode
|
|
365
|
-
console.log(db.isUnifiedMode); // true — everything in one .rvf file
|
|
366
|
-
console.log(db.vectorBackendName); // 'rvf'
|
|
367
|
-
|
|
368
|
-
// Save and reopen — all data persists in agent.rvf
|
|
369
|
-
await db.save();
|
|
370
|
-
await db.close();
|
|
76
|
+
**For Claude Code / MCP Integration** (zero-code setup):
|
|
77
|
+
```bash
|
|
78
|
+
# v3 Alpha
|
|
79
|
+
claude mcp add agentdb npx agentdb@v3 mcp start
|
|
371
80
|
|
|
372
|
-
|
|
373
|
-
|
|
81
|
+
# Or stable version
|
|
82
|
+
claude mcp add agentdb npx agentdb@latest mcp start
|
|
374
83
|
```
|
|
375
84
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
Deploy a self-learning RAG chatbot over any Cognitive Container:
|
|
379
|
-
|
|
85
|
+
**Run latent space simulations** (validate 8.2x speedup):
|
|
380
86
|
```bash
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
---
|
|
385
|
-
|
|
386
|
-
## How the Learning Loop Works
|
|
387
|
-
|
|
388
|
-
Every search automatically triggers a learning cycle. No configuration needed — just call `recordFeedback()` after using results:
|
|
389
|
-
|
|
390
|
-
```mermaid
|
|
391
|
-
graph LR
|
|
392
|
-
A["Your Query"] --> B["Semantic Router<br/>classifies intent"]
|
|
393
|
-
B --> C["Embedding Adapter<br/>adjusts in <1ms"]
|
|
394
|
-
C --> D["HNSW Search<br/>61us, 96.8% recall"]
|
|
395
|
-
D --> E["Results"]
|
|
396
|
-
E --> F["Your Feedback<br/>0.0 - 1.0"]
|
|
397
|
-
F --> G["Contrastive Trainer<br/>learns what's good"]
|
|
398
|
-
G --> C
|
|
399
|
-
style G fill:#2d6,stroke:#1a4,color:#fff
|
|
400
|
-
style A fill:#36f,stroke:#24d,color:#fff
|
|
87
|
+
agentdb simulate hnsw --iterations 3 # HNSW optimization
|
|
88
|
+
agentdb simulate attention --iterations 3 # GNN attention (8-head)
|
|
89
|
+
agentdb simulate --wizard # Interactive configuration
|
|
401
90
|
```
|
|
402
91
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
## Architecture
|
|
406
|
-
|
|
407
|
-
```mermaid
|
|
408
|
-
graph TD
|
|
409
|
-
A[Your Application] --> B[AgentDB Core]
|
|
410
|
-
B --> C[Cognitive Memory<br/>6 patterns]
|
|
411
|
-
B --> D[Self-Learning Pipeline<br/>SONA + Contrastive + Federated]
|
|
412
|
-
B --> E[Backend Auto-Selection]
|
|
413
|
-
E --> F[RuVector<br/>Rust+SIMD 61us]
|
|
414
|
-
E --> G[Cognitive Container<br/>RVF single-file COW]
|
|
415
|
-
E --> H[HNSWLib<br/>C++ HNSW]
|
|
416
|
-
E --> I[sql.js<br/>WASM fallback]
|
|
417
|
-
B --> J[NativeAccelerator<br/>15 capability groups]
|
|
418
|
-
B --> K[MCP Server<br/>41 tools]
|
|
419
|
-
B --> L[Graph Intelligence<br/>Cypher + GNN]
|
|
420
|
-
```
|
|
92
|
+
See [📖 Complete Tutorial](#-tutorial) below for step-by-step examples.
|
|
421
93
|
|
|
422
94
|
---
|
|
423
95
|
|
|
424
|
-
##
|
|
96
|
+
## 🎯 Embedding Models
|
|
425
97
|
|
|
426
|
-
|
|
98
|
+
AgentDB supports multiple embedding models with different tradeoffs:
|
|
427
99
|
|
|
428
|
-
|
|
100
|
+
### Quick Start (Default)
|
|
429
101
|
|
|
430
102
|
```bash
|
|
431
|
-
|
|
103
|
+
# Uses Xenova/all-MiniLM-L6-v2 (384 dimensions)
|
|
104
|
+
npx agentdb init
|
|
432
105
|
```
|
|
433
106
|
|
|
434
|
-
|
|
107
|
+
### Production Quality
|
|
435
108
|
|
|
436
|
-
```
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
"agentdb": {
|
|
440
|
-
"command": "npx",
|
|
441
|
-
"args": ["agentdb", "mcp", "start"],
|
|
442
|
-
"env": { "AGENTDB_PATH": "./agentdb.rvf" }
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
}
|
|
109
|
+
```bash
|
|
110
|
+
# Best quality for production RAG systems
|
|
111
|
+
npx agentdb init --dimension 768 --model "Xenova/bge-base-en-v1.5"
|
|
446
112
|
```
|
|
447
113
|
|
|
448
|
-
###
|
|
449
|
-
|
|
450
|
-
| Category | Tools | Examples |
|
|
451
|
-
| --- | --- | --- |
|
|
452
|
-
| **Core DB** | 6 | init, insert, batch insert, search, delete, stats |
|
|
453
|
-
| **Patterns** | 4 | store, search, batch store, statistics |
|
|
454
|
-
| **Memory** | 9 | reflexion store/retrieve/batch, skill create/search/batch, causal edges/queries, nightly learner |
|
|
455
|
-
| **Learning** | 10 | RL sessions, predictions, feedback, training, transfer learning, explainability |
|
|
456
|
-
| **Recall** | 2 | explainable recall with provenance certificates, cache management |
|
|
457
|
-
| **Solver** | 4 | solver train, acceptance testing, policy inspection, witness chain audit |
|
|
458
|
-
| **Admin** | 6 | diagnostics, migration, pruning, experience recording, reward signals, legacy stats |
|
|
459
|
-
|
|
460
|
-
All 41 tools support parallel execution markers, batch operations, intelligent caching, and format parameters for token reduction.
|
|
461
|
-
|
|
462
|
-
---
|
|
463
|
-
|
|
464
|
-
## Chat Ecosystem
|
|
465
|
-
|
|
466
|
-
The `@agentdb/chat` package provides a one-line chat UI with self-learning RAG built on top of AgentDB:
|
|
114
|
+
### Model Comparison
|
|
467
115
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
116
|
+
| Model | Dimension | Quality | Speed | Best For |
|
|
117
|
+
|-------|-----------|---------|-------|----------|
|
|
118
|
+
| **all-MiniLM-L6-v2** (default) | 384 | ⭐⭐⭐⭐ | ⚡⚡⚡⚡⚡ | Prototyping, demos |
|
|
119
|
+
| **bge-small-en-v1.5** | 384 | ⭐⭐⭐⭐⭐ | ⚡⚡⚡⚡ | Best 384-dim quality |
|
|
120
|
+
| **bge-base-en-v1.5** | 768 | ⭐⭐⭐⭐⭐ | ⚡⚡⚡ | Production systems |
|
|
121
|
+
| all-mpnet-base-v2 | 768 | ⭐⭐⭐⭐⭐ | ⚡⚡⚡ | All-around excellence |
|
|
122
|
+
| e5-base-v2 | 768 | ⭐⭐⭐⭐⭐ | ⚡⚡⚡ | Multilingual (100+ languages) |
|
|
472
123
|
|
|
473
|
-
|
|
124
|
+
### Usage Examples
|
|
474
125
|
|
|
475
126
|
```typescript
|
|
476
|
-
import {
|
|
127
|
+
import { AgentDB } from 'agentdb';
|
|
477
128
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
129
|
+
// Default (fast, 384-dim, proof-gated)
|
|
130
|
+
const db1 = new AgentDB({
|
|
131
|
+
dbPath: './fast.db',
|
|
132
|
+
dimension: 384 // Uses all-MiniLM-L6-v2
|
|
481
133
|
});
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
The chat ecosystem includes:
|
|
485
|
-
- **Chat Server** — streaming inference with any LLM provider
|
|
486
|
-
- **Chat Persistence** — conversation history stored in Cognitive Containers
|
|
487
|
-
- **MCP Bridge** — expose all 37 AgentDB tools through chat
|
|
488
|
-
- **Chat UI** (`@agentdb/chat-ui`) — SvelteKit frontend with real-time tool invocation
|
|
489
|
-
|
|
490
|
-
See the [@agentdb/chat README](../agentdb-chat/README.md) for full documentation.
|
|
491
|
-
|
|
492
|
-
---
|
|
493
|
-
|
|
494
|
-
## Deep Dives
|
|
495
|
-
|
|
496
|
-
> Expand any section below for code examples, configuration, and architecture details.
|
|
497
|
-
|
|
498
|
-
**Getting Started** | [Guides](#guides) | [Tutorials](#tutorials) | [Advanced Usage](#advanced-usage)
|
|
499
|
-
|
|
500
|
-
**Intelligence & Learning** | [Self-Learning Pipeline](#self-learning-pipeline) | [Cognitive Memory](#cognitive-memory-patterns) | [Reinforcement Learning](#reinforcement-learning) | [Hybrid Search](#hybrid-search) | [Graph Intelligence](#graph-intelligence) | [Query Lifecycle](#query-lifecycle)
|
|
501
|
-
|
|
502
|
-
**Performance & Architecture** | [SIMD Acceleration](#simd--native-acceleration) | [Browser & WASM](#browser--wasm-deployment) | [Benchmarks](#performance--benchmarks) | [AgentDBFast](#agentdbfast) | [Benchmark Suite](#benchmark-suite)
|
|
134
|
+
await db1.initialize();
|
|
503
135
|
|
|
504
|
-
|
|
136
|
+
// Access controllers
|
|
137
|
+
const reflexion = db1.getController('reflexion');
|
|
138
|
+
const reasoning = db1.getController('reasoning');
|
|
139
|
+
const graphTransformer = db1.getGraphTransformer();
|
|
505
140
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
---
|
|
511
|
-
|
|
512
|
-
### Getting Started
|
|
513
|
-
|
|
514
|
-
Step-by-step guides, tutorials, and advanced configuration for every skill level.
|
|
515
|
-
|
|
516
|
-
<details>
|
|
517
|
-
<summary><strong>Guides</strong> — backend selection, migration, health checks, federated learning</summary>
|
|
518
|
-
|
|
519
|
-
#### Backend Selection
|
|
520
|
-
|
|
521
|
-
```bash
|
|
522
|
-
# Auto-detect best backend (recommended)
|
|
523
|
-
npx agentdb init --backend auto
|
|
524
|
-
|
|
525
|
-
# Force RuVector (fastest, requires native bindings)
|
|
526
|
-
npx agentdb init --backend ruvector
|
|
527
|
-
|
|
528
|
-
# Force Cognitive Container (single-file, portable)
|
|
529
|
-
npx agentdb init --backend rvf --rvf-path ./vectors.rvf
|
|
530
|
-
|
|
531
|
-
# Force HNSWLib (C++ HNSW)
|
|
532
|
-
npx agentdb init --backend hnswlib
|
|
141
|
+
// Check proof engine status
|
|
142
|
+
const guard = db1.getMutationGuard();
|
|
143
|
+
console.log(guard?.getStats().engineType); // 'native' | 'wasm' | 'js'
|
|
533
144
|
```
|
|
534
145
|
|
|
535
|
-
|
|
146
|
+
**📖 Complete guide**: See [docs/EMBEDDING-MODELS-GUIDE.md](docs/EMBEDDING-MODELS-GUIDE.md) for:
|
|
147
|
+
- 7+ recommended models with benchmarks
|
|
148
|
+
- OpenAI API integration
|
|
149
|
+
- Model selection guide by use case
|
|
150
|
+
- Storage/memory calculations
|
|
151
|
+
- Migration instructions
|
|
536
152
|
|
|
537
|
-
|
|
538
|
-
# Migrate v1 → v2
|
|
539
|
-
npx agentdb migrate --source ./old.db --target ./new.db
|
|
540
|
-
|
|
541
|
-
# Migrate v2 → v3 unified .rvf (same schemas, data copy)
|
|
542
|
-
npx agentdb migrate --source ./v2.db --to v3 --rvf-path ./unified.rvf
|
|
153
|
+
**No API key needed** - All Xenova models run locally via Transformers.js! 🚀
|
|
543
154
|
|
|
544
|
-
|
|
545
|
-
npx agentdb migrate --to rvf --rvf-path ./vectors.rvf
|
|
546
|
-
|
|
547
|
-
# Dry-run migration
|
|
548
|
-
npx agentdb migrate --dry-run --verbose
|
|
549
|
-
```
|
|
155
|
+
---
|
|
550
156
|
|
|
551
|
-
|
|
157
|
+
## What's New in v3.0
|
|
552
158
|
|
|
553
|
-
|
|
554
|
-
# Full diagnostic
|
|
555
|
-
npx agentdb doctor --verbose
|
|
159
|
+
AgentDB v3 introduces **proof-gated graph intelligence** — a fundamental security and reliability upgrade where every state mutation requires cryptographic proof before execution.
|
|
556
160
|
|
|
557
|
-
|
|
558
|
-
|
|
161
|
+
**Proof-Gated Mutations (ADR-060):**
|
|
162
|
+
- MutationGuard validates every insert, search, remove, save, and load
|
|
163
|
+
- Structural hash + attestation token for each operation
|
|
164
|
+
- AttestationLog provides append-only audit trail
|
|
165
|
+
- GuardedVectorBackend wraps any backend with proof enforcement
|
|
166
|
+
- Native proofs via @ruvector/graph-transformer (sub-ms), JS fallback for all environments
|
|
559
167
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
168
|
+
**8 Graph-Transformer Modules:**
|
|
169
|
+
- Sublinear Attention — O(n log n) attention replacing O(n^2) JS fallback
|
|
170
|
+
- Verified Training — SGD with cryptographic proof of each step
|
|
171
|
+
- Causal Attention — temporal-decay weighted attention for CausalRecall
|
|
172
|
+
- Granger Extract — time-series causal discovery
|
|
173
|
+
- Hamiltonian Step — physics-informed agent trajectory modeling
|
|
174
|
+
- Spiking Attention — biological integrate-and-fire for ReflexionMemory
|
|
175
|
+
- Game-Theoretic Attention — Nash equilibrium for multi-agent routing
|
|
176
|
+
- Product Manifold Distance — curved-space similarity for ReasoningBank
|
|
563
177
|
|
|
564
|
-
|
|
178
|
+
**All 21 Controllers Active:**
|
|
179
|
+
- ReflexionMemory, SkillLibrary, ReasoningBank, CausalMemoryGraph
|
|
180
|
+
- CausalRecall, LearningSystem, ExplainableRecall, NightlyLearner
|
|
181
|
+
- EmbeddingService, EnhancedEmbeddingService, WASMVectorSearch, HNSWIndex
|
|
182
|
+
- AttentionService, MMRDiversityRanker, ContextSynthesizer, MetadataFilter
|
|
183
|
+
- QUICServer, QUICClient, SyncCoordinator, GraphTransformerService, MutationGuard
|
|
565
184
|
|
|
566
|
-
|
|
185
|
+
### 🔬 Performance Highlights
|
|
567
186
|
|
|
568
|
-
|
|
569
|
-
import { FederatedLearningCoordinator, EphemeralLearningAgent } from 'agentdb/services/federated-learning';
|
|
187
|
+
**Why this matters:** Unlike synthetic benchmarks that test artificial workloads, these are **real-world performance metrics** from production-representative scenarios. Every number below was validated through multiple iterations and represents actual performance your agents will experience — not theoretical maximums.
|
|
570
188
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
189
|
+
**Core Operations:**
|
|
190
|
+
- Pattern search: **32.6M ops/sec** (ultra-fast with caching)
|
|
191
|
+
- Pattern storage: **388K ops/sec** (excellent)
|
|
192
|
+
- Batch operations: **3-4x faster** (5,556-7,692 ops/sec)
|
|
193
|
+
- Super-linear scaling: **4,536 patterns/sec** @ 5k items
|
|
576
194
|
|
|
577
|
-
|
|
578
|
-
agentId: 'session-agent-1',
|
|
579
|
-
qualityFiltering: true,
|
|
580
|
-
});
|
|
195
|
+
**Latent Space Validation** (25 scenarios, 98.2% reproducibility):
|
|
581
196
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
197
|
+
*These simulations empirically validate every optimization in AgentDB v2.0. Instead of guessing optimal configurations, we systematically explored the latent space of possible designs, running 24 iterations per scenario to discover what actually works best. The results aren't just faster — they're **provably optimal** for real-world agent workloads.*
|
|
198
|
+
- **HNSW**: 61μs p50 latency, 96.8% recall@10, 8.2x faster than hnswlib
|
|
199
|
+
- **GNN Attention**: +12.4% recall, 3.8ms forward pass, 91% transferability
|
|
200
|
+
- **Self-Healing**: 97.9% degradation prevention, <100ms automatic repair
|
|
201
|
+
- **Neural Augmentation**: +29.4% total improvement, -32% memory, -52% hops
|
|
586
202
|
|
|
587
|
-
|
|
203
|
+
See [OPTIMIZATION-REPORT.md](OPTIMIZATION-REPORT.md) for detailed benchmarks and [simulation/README.md](simulation/README.md) for all 25 simulation scenarios.
|
|
588
204
|
|
|
589
205
|
---
|
|
590
206
|
|
|
591
|
-
|
|
592
|
-
|
|
207
|
+
## 📖 Tutorial
|
|
208
|
+
|
|
209
|
+
**Learn by doing:** These examples show real-world use cases where AgentDB's cognitive memory patterns make agents genuinely intelligent. Each example is production-ready code you can adapt for your own applications.
|
|
593
210
|
|
|
594
|
-
|
|
211
|
+
### Example 1: Build a Learning Code Review Agent
|
|
595
212
|
|
|
596
213
|
```typescript
|
|
597
214
|
import { createDatabase, ReasoningBank, ReflexionMemory, EmbeddingService } from 'agentdb';
|
|
598
215
|
|
|
216
|
+
// Setup
|
|
599
217
|
const db = await createDatabase('./code-reviewer.db');
|
|
600
218
|
const embedder = new EmbeddingService({ model: 'Xenova/all-MiniLM-L6-v2' });
|
|
601
219
|
await embedder.initialize();
|
|
@@ -603,2096 +221,1114 @@ await embedder.initialize();
|
|
|
603
221
|
const reasoningBank = new ReasoningBank(db, embedder);
|
|
604
222
|
const reflexion = new ReflexionMemory(db, embedder);
|
|
605
223
|
|
|
224
|
+
// 1. Store successful review patterns
|
|
606
225
|
await reasoningBank.storePattern({
|
|
607
226
|
taskType: 'code_review',
|
|
608
|
-
approach: 'Security scan
|
|
227
|
+
approach: 'Security scan → Type safety → Code quality → Performance',
|
|
609
228
|
successRate: 0.94,
|
|
229
|
+
tags: ['security', 'typescript']
|
|
610
230
|
});
|
|
611
231
|
|
|
612
|
-
|
|
232
|
+
// 2. Review code and learn from it
|
|
233
|
+
const reviewResult = await performCodeReview(codeToReview);
|
|
234
|
+
|
|
613
235
|
await reflexion.storeEpisode({
|
|
614
|
-
sessionId: 'review-1',
|
|
236
|
+
sessionId: 'review-session-1',
|
|
615
237
|
task: 'Review authentication PR',
|
|
616
|
-
reward:
|
|
238
|
+
reward: reviewResult.issuesFound > 0 ? 0.9 : 0.6,
|
|
617
239
|
success: true,
|
|
618
|
-
critique: 'Found SQL injection
|
|
619
|
-
input:
|
|
620
|
-
output:
|
|
240
|
+
critique: 'Found SQL injection vulnerability - security checks work!',
|
|
241
|
+
input: codeToReview,
|
|
242
|
+
output: reviewResult.findings,
|
|
243
|
+
latencyMs: reviewResult.timeMs,
|
|
244
|
+
tokensUsed: reviewResult.tokensUsed
|
|
621
245
|
});
|
|
622
246
|
|
|
623
|
-
|
|
247
|
+
// 3. Next time, find similar successful reviews (32.6M ops/sec!)
|
|
248
|
+
const similarReviews = await reflexion.retrieveRelevant({
|
|
624
249
|
task: 'authentication code review',
|
|
625
250
|
k: 5,
|
|
626
|
-
onlySuccesses: true
|
|
627
|
-
});
|
|
628
|
-
```
|
|
629
|
-
|
|
630
|
-
#### Tutorial 2: RAG with Self-Learning Skills
|
|
631
|
-
|
|
632
|
-
```typescript
|
|
633
|
-
import { createDatabase, SkillLibrary, EmbeddingService } from 'agentdb';
|
|
634
|
-
|
|
635
|
-
const db = await createDatabase('./rag-system.db');
|
|
636
|
-
const embedder = new EmbeddingService({ model: 'Xenova/all-MiniLM-L6-v2' });
|
|
637
|
-
await embedder.initialize();
|
|
638
|
-
|
|
639
|
-
const skills = new SkillLibrary(db, embedder);
|
|
640
|
-
|
|
641
|
-
await skills.createSkill({
|
|
642
|
-
name: 'expand_query',
|
|
643
|
-
description: 'Expand user query with domain-specific synonyms',
|
|
644
|
-
signature: { inputs: { query: 'string' }, outputs: { expanded: 'string[]' } },
|
|
645
|
-
code: `const map = { 'bug': ['issue', 'defect', 'error'] }; ...`,
|
|
646
|
-
successRate: 0.92,
|
|
647
|
-
});
|
|
648
|
-
|
|
649
|
-
const applicable = await skills.searchSkills({ task: 'find technical documentation', k: 10 });
|
|
650
|
-
```
|
|
651
|
-
|
|
652
|
-
#### Tutorial 3: Run Latent Space Simulations
|
|
653
|
-
|
|
654
|
-
```bash
|
|
655
|
-
npx agentdb simulate hnsw --iterations 3
|
|
656
|
-
npx agentdb simulate attention --iterations 3
|
|
657
|
-
npx agentdb simulate self-organizing --days 30
|
|
658
|
-
npx agentdb simulate --wizard
|
|
659
|
-
```
|
|
660
|
-
|
|
661
|
-
#### Tutorial 4: Cognitive Container Branching
|
|
662
|
-
|
|
663
|
-
```typescript
|
|
664
|
-
import { RvfBackend } from 'agentdb/backends/rvf/RvfBackend';
|
|
665
|
-
|
|
666
|
-
const main = new RvfBackend({ dimension: 384, metric: 'cosine', storagePath: './main.rvf' });
|
|
667
|
-
await main.initialize();
|
|
668
|
-
await main.insertAsync('doc-1', embedding1, { source: 'production' });
|
|
669
|
-
await main.flush();
|
|
670
|
-
|
|
671
|
-
// Branch for experiment (copy-on-write, near-instant)
|
|
672
|
-
const experiment = await main.derive('./experiment.rvf');
|
|
673
|
-
await experiment.insertAsync('doc-exp-1', experimentEmbedding);
|
|
674
|
-
console.log(`Lineage depth: ${await experiment.lineageDepth()}`);
|
|
675
|
-
```
|
|
676
|
-
|
|
677
|
-
#### Tutorial 5: Self-Learning RAG Pipeline
|
|
678
|
-
|
|
679
|
-
```typescript
|
|
680
|
-
import { SelfLearningRvfBackend } from 'agentdb/backends/rvf/SelfLearningRvfBackend';
|
|
681
|
-
|
|
682
|
-
const backend = await SelfLearningRvfBackend.create({
|
|
683
|
-
dimension: 384, metric: 'cosine', storagePath: './rag-vectors.rvf',
|
|
684
|
-
learning: true, federated: true,
|
|
685
|
-
});
|
|
686
|
-
|
|
687
|
-
for (const doc of documents) {
|
|
688
|
-
await backend.insertAsync(doc.id, doc.embedding, { title: doc.title });
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
const results = await backend.searchAsync(queryEmbedding, 10);
|
|
692
|
-
backend.recordFeedback('query-1', 0.95);
|
|
693
|
-
await backend.tick();
|
|
694
|
-
```
|
|
695
|
-
|
|
696
|
-
#### Tutorial 6: Chat UI with Custom Knowledge Base
|
|
697
|
-
|
|
698
|
-
```bash
|
|
699
|
-
npx agentdb init --backend rvf --rvf-path ./docs.rvf
|
|
700
|
-
npx agentdb import ./docs/ --rvf-path ./docs.rvf
|
|
701
|
-
npx @agentdb/chat serve --rvf ./docs.rvf --port 3000
|
|
702
|
-
```
|
|
703
|
-
|
|
704
|
-
</details>
|
|
705
|
-
|
|
706
|
-
---
|
|
707
|
-
|
|
708
|
-
<details>
|
|
709
|
-
<summary><strong>Advanced Usage</strong> — batch ops, caching, solver tuning, GNN training, context synthesis</summary>
|
|
710
|
-
|
|
711
|
-
#### Batch Operations
|
|
712
|
-
|
|
713
|
-
```typescript
|
|
714
|
-
import { BatchOperations } from 'agentdb/optimizations/BatchOperations';
|
|
715
|
-
|
|
716
|
-
const batchOps = new BatchOperations(db, embedder, {
|
|
717
|
-
batchSize: 100, parallelism: 4,
|
|
718
|
-
progressCallback: (done, total) => console.log(`${done}/${total}`),
|
|
251
|
+
onlySuccesses: true
|
|
719
252
|
});
|
|
720
253
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
```
|
|
725
|
-
|
|
726
|
-
#### Custom Backend Selection
|
|
727
|
-
|
|
728
|
-
```typescript
|
|
729
|
-
import { createBackend, detectBackends } from 'agentdb/backends/factory';
|
|
730
|
-
|
|
731
|
-
const detection = await detectBackends();
|
|
732
|
-
// { ruvector: { available, native, gnn }, rvf: { sdk, node, wasm }, hnswlib: { available } }
|
|
733
|
-
|
|
734
|
-
const backend = await createBackend({ type: 'rvf', dimension: 384, metric: 'cosine', storagePath: './vectors.rvf' });
|
|
735
|
-
```
|
|
736
|
-
|
|
737
|
-
#### Adaptive Index Tuning
|
|
738
|
-
|
|
739
|
-
```typescript
|
|
740
|
-
import { AgentDBSolver } from 'agentdb/backends/rvf/RvfSolver';
|
|
741
|
-
|
|
742
|
-
const solver = await AgentDBSolver.create();
|
|
743
|
-
const trainResult = solver.train({ count: 50, minDifficulty: 1, maxDifficulty: 10 });
|
|
744
|
-
const policy = solver.policy();
|
|
745
|
-
// 18 context buckets (3 range x 3 distractor x 2 noise)
|
|
746
|
-
```
|
|
747
|
-
|
|
748
|
-
#### Federated Session Manager
|
|
749
|
-
|
|
750
|
-
```typescript
|
|
751
|
-
import { FederatedLearningCoordinator, EphemeralLearningAgent } from 'agentdb/services/federated-learning';
|
|
752
|
-
|
|
753
|
-
const coordinator = new FederatedLearningCoordinator({ agentId: 'coord-main', minQuality: 0.7, maxAgents: 100 });
|
|
754
|
-
const sessionAgent = new EphemeralLearningAgent({ agentId: `session-${Date.now()}`, qualityFiltering: true });
|
|
755
|
-
|
|
756
|
-
await sessionAgent.processTask(embedding, 0.9);
|
|
757
|
-
const state = sessionAgent.exportState();
|
|
758
|
-
await coordinator.aggregate(state);
|
|
759
|
-
const merged = await coordinator.consolidate();
|
|
760
|
-
```
|
|
761
|
-
|
|
762
|
-
#### Context Synthesizer
|
|
763
|
-
|
|
764
|
-
```typescript
|
|
765
|
-
import { ContextSynthesizer } from 'agentdb/controllers/ContextSynthesizer';
|
|
766
|
-
|
|
767
|
-
const synthesizer = new ContextSynthesizer();
|
|
768
|
-
const context = await synthesizer.synthesize(memories);
|
|
769
|
-
// { summary, patterns, successRate, averageReward, recommendations, keyInsights }
|
|
770
|
-
```
|
|
771
|
-
|
|
772
|
-
#### GNN Learning Backend
|
|
773
|
-
|
|
774
|
-
```typescript
|
|
775
|
-
import { LearningBackend } from 'agentdb/backends/LearningBackend';
|
|
776
|
-
|
|
777
|
-
const learner = new LearningBackend({ dimension: 384 });
|
|
778
|
-
const enhanced = learner.enhance(queryEmbedding, neighborEmbeddings, weights);
|
|
779
|
-
learner.addSample(embedding, 'positive', 1.0, { source: 'feedback' });
|
|
780
|
-
const result = await learner.train(10);
|
|
781
|
-
// { epochs: 10, finalLoss: 0.023, improvement: 15.2, durationMs: 340 }
|
|
782
|
-
```
|
|
783
|
-
|
|
784
|
-
</details>
|
|
785
|
-
|
|
786
|
-
---
|
|
787
|
-
|
|
788
|
-
### Intelligence & Learning
|
|
789
|
-
|
|
790
|
-
How AgentDB learns, reasons, and improves over time — from self-learning search to reinforcement learning and causal graphs.
|
|
791
|
-
|
|
792
|
-
<details>
|
|
793
|
-
<summary><strong>Self-Learning Pipeline</strong> — how search improves 36% automatically</summary>
|
|
794
|
-
|
|
795
|
-
AgentDB's self-learning pipeline continuously improves search quality through a six-phase cycle:
|
|
796
|
-
|
|
797
|
-
```mermaid
|
|
798
|
-
flowchart LR
|
|
799
|
-
Q[Query] --> R[Semantic Router]
|
|
800
|
-
R --> S[SONA Enhancement]
|
|
801
|
-
S --> T[HNSW Search]
|
|
802
|
-
T --> U[Results]
|
|
803
|
-
U --> V[Feedback]
|
|
804
|
-
V --> W[Contrastive Trainer<br/>InfoNCE + Hard Negatives]
|
|
805
|
-
W --> X[Micro-LoRA Update]
|
|
806
|
-
X --> Y[EWC++ Consolidation]
|
|
807
|
-
Y --> Z[Federated Aggregation]
|
|
808
|
-
```
|
|
809
|
-
|
|
810
|
-
### 1. Semantic Query Routing
|
|
811
|
-
|
|
812
|
-
The `SemanticQueryRouter` classifies query intent by comparing against learned intent centroids using efficient min-heap top-k selection (O(n log k)). It lazily loads `@ruvector/router` for sub-millisecond HNSW routing and falls back to brute-force cosine with pre-computed norms when native bindings aren't available.
|
|
813
|
-
|
|
814
|
-
The router also selects the adaptive ef-search arm for the query. Four ef-search levels (50, 100, 200, 400) are chosen based on the solver's Thompson Sampling policy for the matching context bucket.
|
|
815
|
-
|
|
816
|
-
```typescript
|
|
817
|
-
// Router learns intents from usage patterns
|
|
818
|
-
router.addIntent('technical_search', embedding); // up to 100 exemplars per intent
|
|
819
|
-
router.addIntent('conversational', embedding);
|
|
820
|
-
const { intent, confidence } = await router.route(queryEmbedding, k);
|
|
821
|
-
|
|
822
|
-
// Router state persists across restarts (debounced 5s save)
|
|
823
|
-
// Max 1,000 intents, JSON fallback or native persistence
|
|
824
|
-
```
|
|
825
|
-
|
|
826
|
-
### 2. SONA Enhancement
|
|
827
|
-
|
|
828
|
-
Context enrichment from trajectory history. The SONA engine (`@ruvector/sona`) tracks query trajectories and enriches embeddings with session context before search. SONA also applies the base LoRA adapter to the query embedding, adjusting it in sub-millisecond time based on learned patterns.
|
|
829
|
-
|
|
830
|
-
### 3. Contrastive Training
|
|
831
|
-
|
|
832
|
-
InfoNCE contrastive loss with hard negative mining inspired by NV-Retriever's positive-aware filtering:
|
|
833
|
-
|
|
834
|
-
- **Loss function:** `L = -log(exp(sim(anchor, positive) / τ) / Σ exp(sim(anchor, negative_i) / τ))`
|
|
835
|
-
- **Hard negative filtering:** Rejects candidates where `sim(candidate, positive) > 0.85`, eliminating ~70% of false negatives
|
|
836
|
-
- **3-stage curriculum:** Progressively increases difficulty — negatives per sample (4 → 8 → 16), hardness threshold (0.5 → 0.3 → 0.1), 100 batches per stage
|
|
837
|
-
- **AdamW optimizer:** β1=0.9, β2=0.999, decoupled weight decay, full bias correction
|
|
838
|
-
- **Temperature:** Bounded 0.01-1.0 (default: 0.07)
|
|
839
|
-
|
|
840
|
-
```typescript
|
|
841
|
-
// ContrastiveTrainer handles hard negative mining automatically
|
|
842
|
-
const result = trainer.trainBatch([
|
|
843
|
-
{ anchor: queryEmb, positive: goodResultEmb, negatives: [badResult1, badResult2] },
|
|
844
|
-
]);
|
|
845
|
-
// result: { loss, gradients, batchSize }
|
|
846
|
-
```
|
|
847
|
-
|
|
848
|
-
When native SIMD is available, cosine similarity and AdamW steps delegate to the NativeAccelerator for hardware-accelerated computation.
|
|
849
|
-
|
|
850
|
-
### 4. Micro-LoRA Adaptation
|
|
851
|
-
|
|
852
|
-
Sub-millisecond embedding adjustment per query. A lightweight projection matrix (W: d×d + bias: d) is applied to the query embedding before search, specializing for each user's query patterns without modifying the base model. LoRA adapters are updated after each contrastive training batch.
|
|
853
|
-
|
|
854
|
-
### 5. EWC++ Consolidation
|
|
855
|
-
|
|
856
|
-
Elastic Weight Consolidation prevents catastrophic forgetting by penalizing changes to important parameters. The Fisher information matrix is updated incrementally via the NativeAccelerator's `ewcUpdateFisher()` and penalty is computed via `ewcPenalty()`, ensuring previously learned patterns survive new training.
|
|
857
|
-
|
|
858
|
-
### 6. Federated Session Aggregation
|
|
859
|
-
|
|
860
|
-
Cross-session LoRA merging for continuous improvement. Lightweight `EphemeralLearningAgent` instances (~5MB each) export their state to a `FederatedLearningCoordinator` for quality-filtered aggregation (minimum quality threshold: 0.7, up to 100 agents).
|
|
861
|
-
|
|
862
|
-
### How `tick()` Works
|
|
863
|
-
|
|
864
|
-
Each learning tick performs these steps in sequence:
|
|
865
|
-
|
|
866
|
-
1. **Flush SONA** — persist trajectory context
|
|
867
|
-
2. **Train contrastive batch** — 32 samples from recorded feedback
|
|
868
|
-
3. **Train solver** — 50 puzzles to update Thompson Sampling policy
|
|
869
|
-
4. **Decay access frequencies** — multiply by 0.99, prune entries below 0.001 (every 50 ticks)
|
|
870
|
-
5. **Update temporal compressor** — adjust compression tiers
|
|
871
|
-
6. **Assess health** — latency tracking via health monitor
|
|
872
|
-
7. **Consolidate federated state** — merge distributed agent states
|
|
873
|
-
8. **Acceptance check** — every 100 ticks, run A/B/C ablation (mode A: fixed heuristic, mode B: compiler-suggested, mode C: learned Thompson Sampling) to validate adaptive ef-search
|
|
874
|
-
|
|
875
|
-
### Full Example
|
|
876
|
-
|
|
877
|
-
```typescript
|
|
878
|
-
import { SelfLearningRvfBackend } from 'agentdb/backends/rvf/SelfLearningRvfBackend';
|
|
879
|
-
|
|
880
|
-
const backend = await SelfLearningRvfBackend.create({
|
|
881
|
-
dimension: 384,
|
|
882
|
-
metric: 'cosine',
|
|
883
|
-
storagePath: './vectors.rvf',
|
|
884
|
-
learning: true,
|
|
885
|
-
federated: true,
|
|
886
|
-
positiveThreshold: 0.7,
|
|
887
|
-
negativeThreshold: 0.3,
|
|
888
|
-
trainingBatchSize: 32,
|
|
889
|
-
tickIntervalMs: 5000,
|
|
890
|
-
});
|
|
891
|
-
|
|
892
|
-
// Insert vectors
|
|
893
|
-
await backend.insertAsync('doc-1', embedding, { source: 'docs' });
|
|
894
|
-
|
|
895
|
-
// Search (automatically enhanced by SONA + router)
|
|
896
|
-
const results = await backend.searchAsync(queryEmbedding, 10);
|
|
897
|
-
|
|
898
|
-
// Record feedback to drive learning
|
|
899
|
-
backend.recordFeedback('query-123', 0.9); // high quality result
|
|
900
|
-
|
|
901
|
-
// Run a learning tick (contrastive training + LoRA update + EWC consolidation)
|
|
902
|
-
await backend.tick();
|
|
903
|
-
|
|
904
|
-
// Check learning progress
|
|
905
|
-
const stats = backend.getLearningStats();
|
|
906
|
-
console.log(`Trajectories: ${stats.trajectoryCount}, LoRA rank: ${stats.loraRank}`);
|
|
907
|
-
```
|
|
908
|
-
|
|
909
|
-
</details>
|
|
910
|
-
|
|
911
|
-
---
|
|
912
|
-
|
|
913
|
-
<details>
|
|
914
|
-
<summary><strong>Cognitive Memory Patterns</strong> — 6 ways your agent learns like a human</summary>
|
|
915
|
-
|
|
916
|
-
AgentDB implements six cognitive memory patterns inspired by how humans learn:
|
|
917
|
-
|
|
918
|
-
### 1. ReasoningBank — Pattern Learning
|
|
919
|
-
|
|
920
|
-
Store successful reasoning patterns and retrieve them by semantic similarity. The system learns which approaches work best for different task types.
|
|
921
|
-
|
|
922
|
-
```typescript
|
|
923
|
-
await reasoningBank.storePattern({
|
|
924
|
-
taskType: 'bug_investigation',
|
|
925
|
-
approach: 'Check logs > Reproduce > Binary search for root cause',
|
|
926
|
-
successRate: 0.92,
|
|
927
|
-
tags: ['debugging', 'systematic'],
|
|
928
|
-
});
|
|
929
|
-
|
|
930
|
-
const patterns = await reasoningBank.searchPatterns({
|
|
931
|
-
task: 'debug memory leak',
|
|
932
|
-
k: 10,
|
|
933
|
-
threshold: 0.7,
|
|
934
|
-
});
|
|
935
|
-
```
|
|
936
|
-
|
|
937
|
-
### 2. Reflexion Memory — Learn from Experience
|
|
938
|
-
|
|
939
|
-
Store complete task episodes with self-generated critiques, then replay them to improve future performance. Based on Shinn et al., 2023.
|
|
940
|
-
|
|
941
|
-
```typescript
|
|
942
|
-
await reflexion.storeEpisode({
|
|
943
|
-
sessionId: 'session-1',
|
|
944
|
-
task: 'Fix authentication bug',
|
|
945
|
-
reward: 0.95,
|
|
946
|
-
success: true,
|
|
947
|
-
critique: 'OAuth2 PKCE flow was more secure than basic flow',
|
|
948
|
-
input: 'Users cannot log in',
|
|
949
|
-
output: 'Working OAuth2 implementation',
|
|
950
|
-
latencyMs: 1200,
|
|
951
|
-
tokensUsed: 500,
|
|
952
|
-
});
|
|
953
|
-
|
|
954
|
-
const similar = await reflexion.retrieveRelevant({
|
|
955
|
-
task: 'authentication issues',
|
|
956
|
-
k: 10,
|
|
957
|
-
onlySuccesses: true,
|
|
958
|
-
});
|
|
959
|
-
```
|
|
960
|
-
|
|
961
|
-
### 3. Skill Library — Lifelong Learning
|
|
962
|
-
|
|
963
|
-
Transform successful patterns into reusable, composable skills that improve over time.
|
|
964
|
-
|
|
965
|
-
```typescript
|
|
966
|
-
await skills.createSkill({
|
|
967
|
-
name: 'jwt_authentication',
|
|
968
|
-
description: 'Generate and validate JWT tokens',
|
|
969
|
-
signature: { inputs: { userId: 'string' }, outputs: { token: 'string' } },
|
|
970
|
-
code: 'implementation...',
|
|
971
|
-
successRate: 0.92,
|
|
972
|
-
});
|
|
973
|
-
|
|
974
|
-
const applicable = await skills.searchSkills({
|
|
975
|
-
task: 'user authentication',
|
|
976
|
-
k: 5,
|
|
977
|
-
minSuccessRate: 0.7,
|
|
978
|
-
});
|
|
979
|
-
```
|
|
980
|
-
|
|
981
|
-
### 4. Causal Memory Graph — Intervention Causality
|
|
982
|
-
|
|
983
|
-
Track `p(y|do(x))` using doubly robust estimation. Learn what interventions cause what outcomes.
|
|
984
|
-
|
|
985
|
-
```typescript
|
|
986
|
-
import { CausalMemoryGraph } from 'agentdb';
|
|
987
|
-
|
|
988
|
-
const causalGraph = new CausalMemoryGraph(db);
|
|
989
|
-
|
|
990
|
-
const experimentId = causalGraph.createExperiment({
|
|
991
|
-
name: 'test_error_handling',
|
|
992
|
-
hypothesis: 'Try-catch reduces crash rate',
|
|
993
|
-
treatmentId: 123,
|
|
994
|
-
treatmentType: 'episode',
|
|
995
|
-
controlId: 124,
|
|
996
|
-
startTime: Date.now(),
|
|
997
|
-
sampleSize: 0,
|
|
998
|
-
status: 'running',
|
|
999
|
-
});
|
|
1000
|
-
|
|
1001
|
-
const { uplift, pValue } = causalGraph.calculateUplift(experimentId);
|
|
1002
|
-
```
|
|
1003
|
-
|
|
1004
|
-
### 5. Explainable Recall — Provenance Certificates
|
|
1005
|
-
|
|
1006
|
-
Every retrieval comes with a cryptographic Merkle proof explaining why specific memories were selected.
|
|
1007
|
-
|
|
1008
|
-
```typescript
|
|
1009
|
-
const result = await causalRecall.recall(
|
|
1010
|
-
'query-123',
|
|
1011
|
-
'How to optimize API response time',
|
|
1012
|
-
12,
|
|
1013
|
-
['performance'],
|
|
1014
|
-
'internal',
|
|
1015
|
-
);
|
|
1016
|
-
|
|
1017
|
-
console.log(`Certificate: ${result.certificate.id}`);
|
|
1018
|
-
console.log(`Completeness: ${result.certificate.completenessScore}`);
|
|
1019
|
-
```
|
|
1020
|
-
|
|
1021
|
-
### 6. Nightly Learner — Automated Discovery
|
|
1022
|
-
|
|
1023
|
-
Background process that discovers causal patterns, consolidates skills, and prunes low-quality data automatically.
|
|
1024
|
-
|
|
1025
|
-
```typescript
|
|
1026
|
-
const learner = new NightlyLearner(db, embedder);
|
|
1027
|
-
const discovered = await learner.discover({
|
|
1028
|
-
minAttempts: 3,
|
|
1029
|
-
minSuccessRate: 0.6,
|
|
1030
|
-
minConfidence: 0.7,
|
|
1031
|
-
dryRun: false,
|
|
1032
|
-
});
|
|
1033
|
-
```
|
|
1034
|
-
|
|
1035
|
-
</details>
|
|
1036
|
-
|
|
1037
|
-
---
|
|
1038
|
-
|
|
1039
|
-
### Storage & Data
|
|
1040
|
-
|
|
1041
|
-
How AgentDB stores vectors, manages compression tiers, and provides MongoDB-style filtering — all in a single Cognitive Container.
|
|
1042
|
-
|
|
1043
|
-
<details>
|
|
1044
|
-
<summary><strong>Cognitive Container (RVF Format)</strong> — single-file storage with crash safety and branching</summary>
|
|
1045
|
-
|
|
1046
|
-
The **Cognitive Container** is AgentDB's native storage format (`.rvf` — RuVector Format). It packs vectors, indexes, learning state, and a cryptographic witness chain into a single file with crash safety, progressive indexing, and full lineage tracking.
|
|
1047
|
-
|
|
1048
|
-
### Structure
|
|
1049
|
-
|
|
1050
|
-
```mermaid
|
|
1051
|
-
graph TB
|
|
1052
|
-
subgraph "store.rvf"
|
|
1053
|
-
H[Header + Magic Bytes]
|
|
1054
|
-
S1[Segment 1<br/>Vectors + Metadata]
|
|
1055
|
-
S2[Segment 2]
|
|
1056
|
-
IX[HNSW Index<br/>Progressive]
|
|
1057
|
-
WC[Witness Chain<br/>SHAKE-256]
|
|
1058
|
-
LN[Lineage Record<br/>Parent ID + Depth]
|
|
1059
|
-
end
|
|
1060
|
-
H --> S1
|
|
1061
|
-
S1 --> S2
|
|
1062
|
-
S2 --> IX
|
|
1063
|
-
IX --> WC
|
|
1064
|
-
WC --> LN
|
|
1065
|
-
```
|
|
1066
|
-
|
|
1067
|
-
### Key Capabilities
|
|
1068
|
-
|
|
1069
|
-
| Feature | Description |
|
|
1070
|
-
| --- | --- |
|
|
1071
|
-
| **Single-file** | Everything in one Cognitive Container (`.rvf`) — vectors, index, metadata |
|
|
1072
|
-
| **Crash-safe** | Append-only log with checksums, safe concurrent access |
|
|
1073
|
-
| **COW Branching** | Create copy-on-write branches for experiments (near-instant) |
|
|
1074
|
-
| **Lineage Tracking** | `fileId()`, `parentId()`, `lineageDepth()` for file-level provenance |
|
|
1075
|
-
| **Progressive Indexing** | 3-layer HNSW quality tiers, index builds incrementally as data arrives |
|
|
1076
|
-
| **Witness Chains** | SHAKE-256 cryptographic verification (73 bytes per entry) |
|
|
1077
|
-
| **Filter Expressions** | 11 operators for metadata filtering, max 64 depth |
|
|
1078
|
-
| **Auto-Compaction** | `compact()` reclaims space, reports segments compacted & bytes reclaimed |
|
|
1079
|
-
| **Readonly Mode** | `openReadonly()` for concurrent readers without locks |
|
|
1080
|
-
| **Segment Introspection** | `segments()` returns id, type, and payload length per segment |
|
|
1081
|
-
| **Kernel Embedding** | Embed unikernel images directly into Cognitive Containers |
|
|
1082
|
-
| **eBPF Embedding** | Embed and extract eBPF bytecode for programmable queries |
|
|
1083
|
-
|
|
1084
|
-
### Configuration
|
|
1085
|
-
|
|
1086
|
-
```typescript
|
|
1087
|
-
const backend = new RvfBackend({
|
|
1088
|
-
dimension: 384,
|
|
1089
|
-
metric: 'cosine', // 'cosine' | 'l2' | 'dotproduct'
|
|
1090
|
-
storagePath: './vectors.rvf',
|
|
1091
|
-
rvfBackend: 'auto', // 'auto' | 'node' (N-API) | 'wasm' (browser)
|
|
1092
|
-
batchThreshold: 100, // Auto-flush after N sync inserts (1-10,000)
|
|
1093
|
-
compression: 'none', // 'none' (fp32) | 'scalar' (int8) | 'product' (PQ)
|
|
1094
|
-
hardwareProfile: 0, // 0=Generic | 1=Core | 2=Hot | 3=Full
|
|
1095
|
-
enableStats: true, // Track insert/search/flush/compaction timing
|
|
1096
|
-
});
|
|
1097
|
-
```
|
|
1098
|
-
|
|
1099
|
-
**Hardware profiles** tune internal parameters for your deployment:
|
|
1100
|
-
|
|
1101
|
-
| Profile | Level | Best For |
|
|
1102
|
-
| --- | --- | --- |
|
|
1103
|
-
| Generic (0) | Conservative defaults | Unknown hardware |
|
|
1104
|
-
| Core (1) | Balanced throughput/latency | Developer machines |
|
|
1105
|
-
| Hot (2) | Aggressive caching | High-throughput servers |
|
|
1106
|
-
| Full (3) | Maximum parallelism | Dedicated vector search |
|
|
1107
|
-
|
|
1108
|
-
### Witness Chains
|
|
1109
|
-
|
|
1110
|
-
Every mutation is recorded in a tamper-evident SHAKE-256 witness chain (73 bytes per entry). This provides cryptographic proof that data has not been modified after the fact:
|
|
1111
|
-
|
|
1112
|
-
```typescript
|
|
1113
|
-
const result = backend.verifyWitnessChain();
|
|
1114
|
-
// { valid: true, entries: 1042, algorithm: 'SHAKE-256' }
|
|
1115
|
-
|
|
1116
|
-
// Verification uses @ruvector/rvf-wasm: rvf_witness_verify(), rvf_witness_count()
|
|
1117
|
-
```
|
|
1118
|
-
|
|
1119
|
-
### Filter Expressions
|
|
1120
|
-
|
|
1121
|
-
RVF supports 11 filter operators for metadata-filtered search. Filters are serialized to a compact field-ID format with a maximum depth of 64 expressions for security:
|
|
1122
|
-
|
|
1123
|
-
```typescript
|
|
1124
|
-
import { FilterBuilder } from 'agentdb/backends/rvf/FilterBuilder';
|
|
1125
|
-
|
|
1126
|
-
const filter = new FilterBuilder()
|
|
1127
|
-
.eq('status', 'active')
|
|
1128
|
-
.gt('score', 0.5)
|
|
1129
|
-
.range('timestamp', startDate, endDate)
|
|
1130
|
-
.in('category', ['research', 'engineering'])
|
|
1131
|
-
.build();
|
|
1132
|
-
|
|
1133
|
-
const results = await backend.searchAsync(queryVector, 10, { filter });
|
|
1134
|
-
|
|
1135
|
-
// Also supports filter-based deletion
|
|
1136
|
-
await backend.deleteByFilter(filter);
|
|
1137
|
-
```
|
|
1138
|
-
|
|
1139
|
-
**Available operators:** `eq`, `ne`, `lt`, `le`, `gt`, `ge`, `in`, `range`, `and`, `or`, `not`
|
|
1140
|
-
|
|
1141
|
-
### Performance Stats
|
|
1142
|
-
|
|
1143
|
-
The RVF backend tracks detailed performance counters:
|
|
1144
|
-
|
|
1145
|
-
```typescript
|
|
1146
|
-
const stats = backend.getPerformanceStats();
|
|
1147
|
-
// {
|
|
1148
|
-
// insertCount: 10432, insertTotalMs: 521.6, avgInsertMs: 0.05,
|
|
1149
|
-
// searchCount: 8891, searchTotalMs: 178.2, avgSearchMs: 0.02,
|
|
1150
|
-
// flushCount: 104, compactionCount: 3
|
|
1151
|
-
// }
|
|
1152
|
-
```
|
|
1153
|
-
|
|
1154
|
-
### Kernel & eBPF Embedding
|
|
1155
|
-
|
|
1156
|
-
Cognitive Containers can embed unikernel images and eBPF bytecode directly, enabling self-contained deployable artifacts:
|
|
1157
|
-
|
|
1158
|
-
```typescript
|
|
1159
|
-
// Embed a kernel image into the Cognitive Container
|
|
1160
|
-
await backend.embedKernel({
|
|
1161
|
-
arch: 'x86_64', // 'x86_64' | 'aarch64' | 'riscv64'
|
|
1162
|
-
type: 'firecracker', // 'firecracker' | 'qemu' | 'cloud-hypervisor'
|
|
1163
|
-
flags: 0,
|
|
1164
|
-
image: kernelBuffer,
|
|
1165
|
-
apiPort: 8080,
|
|
1166
|
-
cmdline: 'console=ttyS0',
|
|
1167
|
-
});
|
|
1168
|
-
|
|
1169
|
-
// Extract it later
|
|
1170
|
-
const kernel = await backend.extractKernel();
|
|
1171
|
-
// { header: { arch, type, ... }, image: Uint8Array }
|
|
1172
|
-
|
|
1173
|
-
// eBPF bytecode for programmable query filters
|
|
1174
|
-
await backend.embedEbpf(ebpfBytecode);
|
|
1175
|
-
const ebpf = await backend.extractEbpf();
|
|
1176
|
-
```
|
|
1177
|
-
|
|
1178
|
-
### CLI Commands
|
|
1179
|
-
|
|
1180
|
-
```bash
|
|
1181
|
-
# Show store status
|
|
1182
|
-
npx agentdb rvf status ./store.rvf
|
|
1183
|
-
|
|
1184
|
-
# Compact to reclaim space
|
|
1185
|
-
npx agentdb rvf compact ./store.rvf
|
|
1186
|
-
|
|
1187
|
-
# Create a branch (copy-on-write)
|
|
1188
|
-
npx agentdb rvf derive ./parent.rvf ./experiment.rvf
|
|
1189
|
-
|
|
1190
|
-
# List segments
|
|
1191
|
-
npx agentdb rvf segments ./store.rvf
|
|
1192
|
-
|
|
1193
|
-
# Detect SDK availability
|
|
1194
|
-
npx agentdb rvf detect
|
|
1195
|
-
```
|
|
1196
|
-
|
|
1197
|
-
### Programmatic Usage
|
|
1198
|
-
|
|
1199
|
-
```typescript
|
|
1200
|
-
import { RvfBackend } from 'agentdb/backends/rvf/RvfBackend';
|
|
1201
|
-
|
|
1202
|
-
const backend = new RvfBackend({
|
|
1203
|
-
dimension: 384,
|
|
1204
|
-
metric: 'cosine',
|
|
1205
|
-
storagePath: './vectors.rvf',
|
|
1206
|
-
rvfBackend: 'auto', // 'node' for N-API, 'wasm' for browser
|
|
1207
|
-
});
|
|
1208
|
-
await backend.initialize();
|
|
1209
|
-
|
|
1210
|
-
// Async operations (native)
|
|
1211
|
-
await backend.insertAsync('vec-1', embedding, { tag: 'example' });
|
|
1212
|
-
const results = await backend.searchAsync(queryVector, 10);
|
|
1213
|
-
await backend.flush();
|
|
1214
|
-
|
|
1215
|
-
// COW branching
|
|
1216
|
-
const branch = await backend.derive('./experiment.rvf');
|
|
1217
|
-
const lineage = await backend.lineageDepth();
|
|
1218
|
-
```
|
|
1219
|
-
|
|
1220
|
-
### Backend Selection
|
|
1221
|
-
|
|
1222
|
-
```bash
|
|
1223
|
-
# Initialize with RVF backend
|
|
1224
|
-
npx agentdb init --backend rvf --rvf-path ./vectors.rvf
|
|
1225
|
-
|
|
1226
|
-
# Migrate v2 database to v3 unified .rvf
|
|
1227
|
-
npx agentdb migrate --source ./v2.db --to v3 --rvf-path ./unified.rvf
|
|
1228
|
-
|
|
1229
|
-
# Migrate existing data to RVF
|
|
1230
|
-
npx agentdb migrate --to rvf --rvf-path ./vectors.rvf
|
|
1231
|
-
|
|
1232
|
-
# Check RVF in diagnostics
|
|
1233
|
-
npx agentdb doctor --rvf-path ./vectors.rvf
|
|
1234
|
-
```
|
|
1235
|
-
|
|
1236
|
-
</details>
|
|
1237
|
-
|
|
1238
|
-
---
|
|
1239
|
-
|
|
1240
|
-
### Performance & Architecture
|
|
1241
|
-
|
|
1242
|
-
The engine behind AgentDB's speed — SIMD acceleration, graph intelligence, browser WASM, and benchmarking.
|
|
1243
|
-
|
|
1244
|
-
<details>
|
|
1245
|
-
<summary><strong>SIMD & Native Acceleration</strong> — 15 capability groups with automatic fallbacks</summary>
|
|
1246
|
-
|
|
1247
|
-
The `NativeAccelerator` provides 15 capability groups bridging 11 `@ruvector` packages, with pure-JS fallbacks for every operation via `SimdFallbacks`.
|
|
1248
|
-
|
|
1249
|
-
### Capability Groups
|
|
1250
|
-
|
|
1251
|
-
| Group | Operations | Package |
|
|
1252
|
-
| --- | --- | --- |
|
|
1253
|
-
| **Vector Distance & Math** | cosine, dot, L2, hamming, add, mul, scale, normalize | `ruvector` |
|
|
1254
|
-
| **Activations** | softmax, relu, gelu, sigmoid, layerNorm | `@ruvector/ruvllm` |
|
|
1255
|
-
| **Loss Functions** | InfoNCE (contrastive) | `@ruvector/sona` |
|
|
1256
|
-
| **Optimizers** | AdamW step | `@ruvector/sona` |
|
|
1257
|
-
| **Quantization** | scalar 8-bit/4-bit, product quantization | `@ruvector/rvf` |
|
|
1258
|
-
| **WASM Store** | create, ingest, query, export, close | `@ruvector/rvf-wasm` |
|
|
1259
|
-
| **Verification** | witness chain, segment header | `@ruvector/rvf-node` |
|
|
1260
|
-
| **Graph Transactions** | begin, commit, rollback | `@ruvector/graph-node` |
|
|
1261
|
-
| **Graph Batch Insert** | high-throughput node/edge ingestion | `@ruvector/graph-node` |
|
|
1262
|
-
| **Graph Cypher** | pattern matching, path queries | `@ruvector/graph-node` |
|
|
1263
|
-
| **Core Batch Insert** | native vector batch ingestion | `ruvector` |
|
|
1264
|
-
| **EWC Memory** | penalty calculation, Fisher update | `@ruvector/sona` |
|
|
1265
|
-
| **Router** | save/load state persistence | `@ruvector/router` |
|
|
1266
|
-
| **SONA** | context addition, flush, base LoRA | `@ruvector/sona` |
|
|
1267
|
-
| **Compression** | tensor compress/decompress | `@ruvector/rvf` |
|
|
1268
|
-
|
|
1269
|
-
### Auto-Detection
|
|
1270
|
-
|
|
1271
|
-
Each capability group is lazily loaded — only the packages actually installed on the system are loaded, and each load is tried independently so a missing package never blocks others:
|
|
1272
|
-
|
|
1273
|
-
```typescript
|
|
1274
|
-
import { NativeAccelerator } from 'agentdb/backends/rvf/NativeAccelerator';
|
|
1275
|
-
|
|
1276
|
-
const accel = new NativeAccelerator();
|
|
1277
|
-
const stats = await accel.initialize();
|
|
1278
|
-
|
|
1279
|
-
console.log(stats);
|
|
1280
|
-
// AcceleratorStats:
|
|
1281
|
-
// {
|
|
1282
|
-
// simdAvailable: true, // Vector distance + element-wise math
|
|
1283
|
-
// simdActivationsAvailable: true, // softmax, relu, gelu, sigmoid, layerNorm
|
|
1284
|
-
// wasmVerifyAvailable: true, // Witness chain & header verification
|
|
1285
|
-
// wasmStoreAvailable: true, // In-browser HNSW store
|
|
1286
|
-
// wasmQuantizationAvailable: true, // Scalar/product quantization ops
|
|
1287
|
-
// nativeInfoNceAvailable: true, // Hardware-accelerated InfoNCE loss
|
|
1288
|
-
// nativeAdamWAvailable: true, // Hardware-accelerated AdamW optimizer
|
|
1289
|
-
// nativeTensorCompressAvailable: true, // SVD tensor compression
|
|
1290
|
-
// routerPersistAvailable: true, // Semantic router state persistence
|
|
1291
|
-
// sonaExtendedAvailable: true, // SONA trajectory context & base LoRA
|
|
1292
|
-
// }
|
|
1293
|
-
// Additional capabilities (probed separately):
|
|
1294
|
-
// accel.graphTxAvailable // Graph transactions
|
|
1295
|
-
// accel.graphBatchInsertAvailable // Graph batch insert
|
|
1296
|
-
// accel.graphCypherAvailable // Cypher query engine
|
|
1297
|
-
// accel.coreBatchInsertAvailable // Native vector batch insert
|
|
1298
|
-
// accel.ewcManagerAvailable // EWC++ memory consolidation
|
|
1299
|
-
```
|
|
1300
|
-
|
|
1301
|
-
### Pure-JS Fallbacks
|
|
1302
|
-
|
|
1303
|
-
Every SIMD operation has a pure-JS fallback with 4-wide loop unrolling for reasonable performance even without native bindings:
|
|
1304
|
-
|
|
1305
|
-
```typescript
|
|
1306
|
-
import { SimdFallbacks } from 'agentdb/backends/rvf/SimdFallbacks';
|
|
1307
|
-
|
|
1308
|
-
// Same API as native, ~10-50x slower but always available
|
|
1309
|
-
const similarity = SimdFallbacks.jsCosineSimilarity(vecA, vecB);
|
|
1310
|
-
const loss = SimdFallbacks.jsInfoNceLoss(anchor, positive, negatives, temperature);
|
|
1311
|
-
const result = SimdFallbacks.jsAdamWStep(params, grads, m, v, lr, beta1, beta2, weightDecay, t);
|
|
1312
|
-
```
|
|
1313
|
-
|
|
1314
|
-
### Additional SIMD Operations
|
|
1315
|
-
|
|
1316
|
-
The `SIMDVectorOps` class provides batch operations and platform-specific detection:
|
|
1317
|
-
|
|
1318
|
-
```typescript
|
|
1319
|
-
import { SIMDVectorOps, detectSIMDSupport } from 'agentdb/simd';
|
|
1320
|
-
|
|
1321
|
-
const simd = new SIMDVectorOps();
|
|
1322
|
-
const support = detectSIMDSupport();
|
|
1323
|
-
// { wasm: true, x64: false, avx2: false, neon: false }
|
|
1324
|
-
|
|
1325
|
-
const similarities = simd.batchCosineSimilarity(query, [vec1, vec2, vec3]);
|
|
1326
|
-
```
|
|
1327
|
-
|
|
1328
|
-
</details>
|
|
1329
|
-
|
|
1330
|
-
---
|
|
1331
|
-
|
|
1332
|
-
<details>
|
|
1333
|
-
<summary><strong>Graph Intelligence</strong> — Cypher queries, causal reasoning, GNN attention</summary>
|
|
1334
|
-
|
|
1335
|
-
AgentDB integrates `@ruvector/graph-node` for a full graph database with Cypher query support, transactional batch inserts, and GNN-powered attention.
|
|
1336
|
-
|
|
1337
|
-
### Cypher Queries
|
|
1338
|
-
|
|
1339
|
-
Full Neo4j-compatible Cypher syntax including MATCH, RETURN, WHERE, ORDER BY, LIMIT, relationship patterns, and graph traversal:
|
|
1340
|
-
|
|
1341
|
-
```typescript
|
|
1342
|
-
import { GraphDatabaseAdapter } from 'agentdb/backends/graph/GraphDatabaseAdapter';
|
|
1343
|
-
|
|
1344
|
-
const graph = new GraphDatabaseAdapter({
|
|
1345
|
-
storagePath: './graph.db',
|
|
1346
|
-
dimensions: 384,
|
|
1347
|
-
distanceMetric: 'Cosine', // 'Cosine' | 'Euclidean' | 'DotProduct' | 'Manhattan'
|
|
1348
|
-
});
|
|
1349
|
-
await graph.initialize();
|
|
1350
|
-
|
|
1351
|
-
// Create nodes and edges
|
|
1352
|
-
await graph.storeEpisode(episode, embedding);
|
|
1353
|
-
await graph.storeSkill(skill, embedding);
|
|
1354
|
-
await graph.createCausalEdge(edge, embedding);
|
|
1355
|
-
|
|
1356
|
-
// Cypher queries
|
|
1357
|
-
const results = await graph.query(`
|
|
1358
|
-
MATCH (e:Episode)-[:CAUSED]->(s:Skill)
|
|
1359
|
-
WHERE e.reward > 0.8
|
|
1360
|
-
RETURN e, s
|
|
1361
|
-
ORDER BY e.reward DESC
|
|
1362
|
-
LIMIT 10
|
|
1363
|
-
`);
|
|
1364
|
-
```
|
|
1365
|
-
|
|
1366
|
-
### Graph Traversal
|
|
1367
|
-
|
|
1368
|
-
Traverse relationships with direction control, depth limits, and label filtering:
|
|
1369
|
-
|
|
1370
|
-
```typescript
|
|
1371
|
-
const paths = await graph.traverse({
|
|
1372
|
-
startNodeId: 'episode-42',
|
|
1373
|
-
pattern: '()-[:RELATES_TO]->(:Skill)',
|
|
1374
|
-
direction: 'outgoing', // 'outgoing' | 'incoming' | 'both'
|
|
1375
|
-
maxDepth: 3,
|
|
1376
|
-
relationshipTypes: ['CAUSED', 'RELATES_TO'],
|
|
1377
|
-
nodeLabels: ['Episode', 'Skill'],
|
|
1378
|
-
});
|
|
1379
|
-
```
|
|
1380
|
-
|
|
1381
|
-
### Hybrid Vector + Graph Search
|
|
1382
|
-
|
|
1383
|
-
Combine vector similarity with graph context filtering — find semantically similar nodes that are also connected in the knowledge graph:
|
|
1384
|
-
|
|
1385
|
-
```typescript
|
|
1386
|
-
// Vector similarity within graph structure
|
|
1387
|
-
const results = await graph.vectorSearch(queryEmbedding, 10);
|
|
1388
|
-
// Returns nodes ranked by embedding similarity with graph context
|
|
1389
|
-
|
|
1390
|
-
// Nodes support multi-label classification
|
|
1391
|
-
await graph.createNode({
|
|
1392
|
-
id: 'analysis-1',
|
|
1393
|
-
label: ['Episode', 'Analyzed', 'Security'],
|
|
1394
|
-
properties: { reward: 0.95, task: 'auth review' },
|
|
1395
|
-
embedding: embeddingVector,
|
|
1396
|
-
});
|
|
1397
|
-
```
|
|
1398
|
-
|
|
1399
|
-
### Transactional Batch Inserts
|
|
1400
|
-
|
|
1401
|
-
ACID-guaranteed batch operations with rollback support:
|
|
1402
|
-
|
|
1403
|
-
```typescript
|
|
1404
|
-
const txId = await graph.beginTransaction();
|
|
1405
|
-
try {
|
|
1406
|
-
await graph.batchInsert(
|
|
1407
|
-
nodes.map(n => ({ id: n.id, label: n.type, properties: n.data })),
|
|
1408
|
-
edges.map(e => ({ from: e.source, to: e.target, label: e.type, properties: e.data })),
|
|
1409
|
-
);
|
|
1410
|
-
await graph.commitTransaction(txId);
|
|
1411
|
-
} catch (err) {
|
|
1412
|
-
await graph.rollbackTransaction(txId);
|
|
1413
|
-
}
|
|
1414
|
-
```
|
|
1415
|
-
|
|
1416
|
-
### GNN 8-Head Attention
|
|
1417
|
-
|
|
1418
|
-
The GNN attention mechanism improves recall by +12.4% with a 3.8ms forward pass and 91% transfer learning retention. Three attention types are available:
|
|
1419
|
-
|
|
1420
|
-
| Type | Algorithm | Best For |
|
|
1421
|
-
| --- | --- | --- |
|
|
1422
|
-
| `gat` | Graph Attention Network | Weighted neighbor aggregation |
|
|
1423
|
-
| `gcn` | Graph Convolutional Network | Uniform message passing |
|
|
1424
|
-
| `sage` | GraphSAGE | Inductive learning on unseen nodes |
|
|
1425
|
-
|
|
1426
|
-
```typescript
|
|
1427
|
-
import { AttentionService } from 'agentdb/controllers/AttentionService';
|
|
1428
|
-
|
|
1429
|
-
const attention = new AttentionService({
|
|
1430
|
-
numHeads: 8,
|
|
1431
|
-
dimension: 384,
|
|
1432
|
-
attentionType: 'gat', // 'gat' | 'gcn' | 'sage'
|
|
1433
|
-
});
|
|
1434
|
-
const enhanced = await attention.forward(queryEmbedding, neighborEmbeddings);
|
|
1435
|
-
```
|
|
1436
|
-
|
|
1437
|
-
### Causal Memory Graph
|
|
1438
|
-
|
|
1439
|
-
Track interventions with `p(y|do(x))` doubly robust estimation and optional Poincare embeddings for hierarchical relationships:
|
|
1440
|
-
|
|
1441
|
-
```typescript
|
|
1442
|
-
import { CausalMemoryGraph } from 'agentdb';
|
|
1443
|
-
|
|
1444
|
-
const causal = new CausalMemoryGraph(db, graph, embedder, {
|
|
1445
|
-
ENABLE_HYPERBOLIC_ATTENTION: true, // Poincaré ball distance for hierarchies
|
|
1446
|
-
});
|
|
1447
|
-
|
|
1448
|
-
await causal.addCausalEdge({
|
|
1449
|
-
fromMemoryId: 'episode-1',
|
|
1450
|
-
toMemoryType: 'skill', // 'episode' | 'skill' | 'note' | 'fact'
|
|
1451
|
-
uplift: 0.15, // E[y|do(x)] - E[y]
|
|
1452
|
-
confidence: 0.92,
|
|
1453
|
-
mechanism: 'error-handling improvement',
|
|
1454
|
-
sampleSize: 50,
|
|
1455
|
-
confounderScore: 0.03,
|
|
1456
|
-
});
|
|
1457
|
-
```
|
|
1458
|
-
|
|
1459
|
-
</details>
|
|
1460
|
-
|
|
1461
|
-
---
|
|
1462
|
-
|
|
1463
|
-
<details>
|
|
1464
|
-
<summary><strong>Browser & WASM Deployment</strong> — full vector DB in the browser, no server needed</summary>
|
|
1465
|
-
|
|
1466
|
-
AgentDB runs fully in the browser with WASM-backed vector storage, GNN attention, product quantization, and pure-JS fallbacks.
|
|
1467
|
-
|
|
1468
|
-
### WasmStoreBridge
|
|
1469
|
-
|
|
1470
|
-
The `WasmStoreBridge` provides a full HNSW vector database in the browser by wrapping `@ruvector/rvf-wasm`:
|
|
1471
|
-
|
|
1472
|
-
```typescript
|
|
1473
|
-
import { WasmStoreBridge } from 'agentdb/backends/rvf/WasmStoreBridge';
|
|
1474
|
-
|
|
1475
|
-
const bridge = new WasmStoreBridge();
|
|
1476
|
-
await bridge.initialize();
|
|
1477
|
-
|
|
1478
|
-
// Create an in-browser vector store
|
|
1479
|
-
const handle = bridge.wasmStoreCreate(384, 0); // 384 dims, cosine metric
|
|
1480
|
-
|
|
1481
|
-
// Ingest vectors
|
|
1482
|
-
bridge.wasmStoreIngest(handle, vectors, ids, count);
|
|
1483
|
-
|
|
1484
|
-
// Query
|
|
1485
|
-
const results = bridge.wasmStoreQuery(handle, queryVector, 10, 0);
|
|
1486
|
-
// [{ id: 42, distance: 0.12 }, ...]
|
|
1487
|
-
|
|
1488
|
-
// Export to transferable binary (share between tabs/workers)
|
|
1489
|
-
const bytes = bridge.wasmStoreExport(handle);
|
|
1490
|
-
|
|
1491
|
-
bridge.wasmStoreClose(handle);
|
|
1492
|
-
```
|
|
1493
|
-
|
|
1494
|
-
### Browser Attention Mechanisms
|
|
1495
|
-
|
|
1496
|
-
The `AttentionBrowser` provides three advanced attention types compiled to WASM:
|
|
1497
|
-
|
|
1498
|
-
```typescript
|
|
1499
|
-
import { AttentionBrowser } from 'agentdb/browser/AttentionBrowser';
|
|
1500
|
-
|
|
1501
|
-
const attention = new AttentionBrowser({ numHeads: 8 });
|
|
1502
|
-
// Loading states: 'idle' → 'loading' → 'loaded' | 'error'
|
|
1503
|
-
|
|
1504
|
-
// Standard multi-head attention
|
|
1505
|
-
const enhanced = await attention.forward(query, neighbors);
|
|
1506
|
-
|
|
1507
|
-
// Flash Attention — O(N) memory instead of O(N²)
|
|
1508
|
-
const flash = await attention.flashAttention(query, keys, values);
|
|
1509
|
-
|
|
1510
|
-
// Hyperbolic Attention — Poincaré ball distance for hierarchical data
|
|
1511
|
-
const hyper = await attention.hyperbolicAttention(query, neighbors);
|
|
1512
|
-
|
|
1513
|
-
// Memory Consolidation — agglomerative clustering to merge similar memories
|
|
1514
|
-
const consolidated = await attention.consolidateMemories(memories, {
|
|
1515
|
-
threshold: 0.85,
|
|
1516
|
-
minClusterSize: 3,
|
|
1517
|
-
});
|
|
1518
|
-
```
|
|
1519
|
-
|
|
1520
|
-
### Product Quantization (Browser)
|
|
1521
|
-
|
|
1522
|
-
Memory-efficient vector storage with three PQ compression levels:
|
|
1523
|
-
|
|
1524
|
-
| Variant | Compression | Subvectors | Centroids | Best For |
|
|
1525
|
-
| --- | --- | --- | --- | --- |
|
|
1526
|
-
| **PQ8** | 4x | 8 | 256 | Balanced quality/memory |
|
|
1527
|
-
| **PQ16** | 8x | 16 | 256 | Medium datasets |
|
|
1528
|
-
| **PQ32** | 16x | 32 | 256 | Maximum compression |
|
|
1529
|
-
|
|
1530
|
-
```typescript
|
|
1531
|
-
import { createProductQuantizedStore, createScalar8BitStore } from 'agentdb/browser/ProductQuantization';
|
|
1532
|
-
|
|
1533
|
-
// Product quantization with asymmetric distance computation (ADC)
|
|
1534
|
-
const pq = createProductQuantizedStore(384, {
|
|
1535
|
-
numSubvectors: 16,
|
|
1536
|
-
bitsPerCode: 8,
|
|
1537
|
-
// Uses K-means++ initialization for codebook training
|
|
1538
|
-
});
|
|
1539
|
-
pq.add('doc-1', embedding);
|
|
1540
|
-
const results = pq.search(query, 10);
|
|
1541
|
-
```
|
|
1542
|
-
|
|
1543
|
-
### Browser Configuration Presets
|
|
1544
|
-
|
|
1545
|
-
Pre-tuned configurations for common scenarios:
|
|
1546
|
-
|
|
1547
|
-
| Preset | Features | Target |
|
|
1548
|
-
| --- | --- | --- |
|
|
1549
|
-
| `SMALL_DATASET` | GNN only | <1K vectors |
|
|
1550
|
-
| `MEDIUM_DATASET` | HNSW + PQ8 | 1K-10K vectors |
|
|
1551
|
-
| `LARGE_DATASET` | Aggressive compression + HNSW | 10K-100K vectors |
|
|
1552
|
-
| `MEMORY_OPTIMIZED` | PQ32 + SVD (dim 64) | Memory-constrained |
|
|
1553
|
-
| `SPEED_OPTIMIZED` | HNSW max quality | Latency-critical |
|
|
1554
|
-
| `QUALITY_OPTIMIZED` | No compression, max attention heads | Accuracy-critical |
|
|
1555
|
-
|
|
1556
|
-
### Maximal Marginal Relevance (MMR)
|
|
1557
|
-
|
|
1558
|
-
Diversify search results to avoid returning near-duplicate items:
|
|
1559
|
-
|
|
1560
|
-
```typescript
|
|
1561
|
-
import { MMRDiversityRanker } from 'agentdb/controllers/MMRDiversityRanker';
|
|
1562
|
-
|
|
1563
|
-
const ranker = new MMRDiversityRanker({
|
|
1564
|
-
lambda: 0.7, // 0=max diversity, 1=max relevance
|
|
1565
|
-
metric: 'cosine', // 'cosine' | 'euclidean' | 'dot'
|
|
1566
|
-
});
|
|
1567
|
-
|
|
1568
|
-
// Rerank results: MMR = λ × Sim(Di,Q) - (1-λ) × max Sim(Di,Dj)
|
|
1569
|
-
const diverse = ranker.rerank(queryEmbedding, candidates, 10);
|
|
1570
|
-
const score = ranker.diversityScore(diverse); // average pairwise distance
|
|
1571
|
-
```
|
|
1572
|
-
|
|
1573
|
-
### Browser Bundle
|
|
1574
|
-
|
|
1575
|
-
```typescript
|
|
1576
|
-
import { AgentDB } from 'agentdb/browser';
|
|
1577
|
-
|
|
1578
|
-
const db = new AgentDB({ dimension: 384 });
|
|
1579
|
-
await db.initialize();
|
|
1580
|
-
|
|
1581
|
-
await db.insert('doc-1', embedding, { title: 'Getting Started' });
|
|
1582
|
-
const results = await db.search(queryEmbedding, 5);
|
|
1583
|
-
```
|
|
1584
|
-
|
|
1585
|
-
### sql.js & SIMD Fallbacks
|
|
1586
|
-
|
|
1587
|
-
For zero-dependency environments, AgentDB falls back to `sql.js` (SQLite compiled to WASM) automatically. Non-WASM browsers get pure-JS implementations with 4-wide loop unrolling (~10-50x slower than native SIMD but fully functional):
|
|
1588
|
-
|
|
1589
|
-
```typescript
|
|
1590
|
-
import { createDatabase } from 'agentdb';
|
|
1591
|
-
import { detectSIMDSupport } from 'agentdb/simd';
|
|
1592
|
-
|
|
1593
|
-
// In browsers, automatically uses sql.js WASM backend
|
|
1594
|
-
const db = await createDatabase(':memory:');
|
|
1595
|
-
|
|
1596
|
-
const support = detectSIMDSupport();
|
|
1597
|
-
// { wasm: true, x64: false, avx2: false, neon: false }
|
|
1598
|
-
```
|
|
1599
|
-
|
|
1600
|
-
</details>
|
|
1601
|
-
|
|
1602
|
-
---
|
|
1603
|
-
|
|
1604
|
-
<details>
|
|
1605
|
-
<summary><strong>Performance & Benchmarks</strong> — 61us latency, 96.8% recall, 32.6M ops/sec</summary>
|
|
1606
|
-
|
|
1607
|
-
### Core Operations
|
|
1608
|
-
|
|
1609
|
-
| Operation | Throughput | Latency |
|
|
1610
|
-
| --- | --- | --- |
|
|
1611
|
-
| Pattern search | 32.6M ops/sec | <1ms |
|
|
1612
|
-
| Pattern storage | 388K ops/sec | ~2.5us |
|
|
1613
|
-
| Episode retrieval | 957 ops/sec | ~1ms |
|
|
1614
|
-
| Skill search | 694 ops/sec | ~1.4ms |
|
|
1615
|
-
| Batch insert | 5,556-7,692 ops/sec | 3-4x faster than sequential |
|
|
1616
|
-
|
|
1617
|
-
### Scaling Behavior
|
|
1618
|
-
|
|
1619
|
-
```
|
|
1620
|
-
500 patterns: 1,475/sec, 2MB memory
|
|
1621
|
-
2,000 patterns: 3,818/sec, 0MB delta
|
|
1622
|
-
5,000 patterns: 4,536/sec, 4MB memory (super-linear)
|
|
1623
|
-
```
|
|
1624
|
-
|
|
1625
|
-
### Self-Learning Improvement
|
|
1626
|
-
|
|
1627
|
-
```
|
|
1628
|
-
Adaptive Learning (10 sessions, 50 episodes each)
|
|
1629
|
-
Initial success rate: 54%
|
|
1630
|
-
Final success rate: 90%
|
|
1631
|
-
Improvement: +36%
|
|
1632
|
-
```
|
|
1633
|
-
|
|
1634
|
-
### Latent Space Validation (31 scenarios, 98.2% reproducibility)
|
|
1635
|
-
|
|
1636
|
-
| Scenario | Result |
|
|
1637
|
-
| --- | --- |
|
|
1638
|
-
| HNSW Optimization | 61us p50, 96.8% recall@10, 8.2x vs hnswlib |
|
|
1639
|
-
| GNN Attention | +12.4% recall, 3.8ms forward pass, 91% transfer |
|
|
1640
|
-
| Self-Healing | 97.9% degradation prevention, <100ms repair |
|
|
1641
|
-
| Neural Augmentation | +29.4% improvement, -32% memory, -52% hops |
|
|
1642
|
-
|
|
1643
|
-
### Adaptive Solver (Thompson Sampling)
|
|
1644
|
-
|
|
1645
|
-
The solver uses 18 context-bucketed bandits (3 range x 3 distractor x 2 noise levels) to dynamically tune search parameters:
|
|
1646
|
-
|
|
1647
|
-
```typescript
|
|
1648
|
-
const solver = await AgentDBSolver.create();
|
|
1649
|
-
|
|
1650
|
-
// Train the solver with puzzles of varying difficulty
|
|
1651
|
-
const result = solver.train({ count: 50, minDifficulty: 1, maxDifficulty: 10 });
|
|
1652
|
-
|
|
1653
|
-
// Inspect the policy — shows Thompson Sampling alpha/beta per context bucket
|
|
1654
|
-
const policy = solver.policy();
|
|
1655
|
-
console.log(policy.contextStats);
|
|
1656
|
-
// { '0_0_0': { alphaSafety: 12.5, betaSafety: 2.1, costEma: 0.03 }, ... }
|
|
1657
|
-
|
|
1658
|
-
// A/B/C acceptance testing
|
|
1659
|
-
const manifest = solver.acceptance({ holdoutSize: 100, cycles: 3 });
|
|
1660
|
-
console.log(`Passed: ${manifest.passed}, Score: ${manifest.score}`);
|
|
1661
|
-
|
|
1662
|
-
// SHAKE-256 witness chain for audit
|
|
1663
|
-
const chain = solver.witnessChain();
|
|
1664
|
-
```
|
|
1665
|
-
|
|
1666
|
-
Three-loop architecture:
|
|
1667
|
-
1. **Fast loop** — constraint propagation (~0.1ms)
|
|
1668
|
-
2. **Medium loop** — PolicyKernel with Thompson Sampling (~1ms)
|
|
1669
|
-
3. **Slow loop** — KnowledgeCompiler for long-term patterns (~10ms)
|
|
1670
|
-
|
|
1671
|
-
### SolverBandit — Decision Intelligence Across Controllers (ADR-010)
|
|
1672
|
-
|
|
1673
|
-
The `SolverBandit` is a general-purpose Thompson Sampling bandit that provides explore/exploit decisions for any context-dependent selection problem. It powers adaptive decision-making in 5 AgentDB controllers:
|
|
1674
|
-
|
|
1675
|
-
| Controller | What the Bandit Decides | Context Key |
|
|
1676
|
-
| --- | --- | --- |
|
|
1677
|
-
| **SkillLibrary** | Rerank retrieved skills by task type | `taskType` string |
|
|
1678
|
-
| **ReasoningBank** | Rerank matching patterns by task type | query text |
|
|
1679
|
-
| **NightlyLearner** | Prioritize experiment candidates | `'experiment'` |
|
|
1680
|
-
| **LearningSystem** | Select best RL algorithm (9 options) | task description |
|
|
1681
|
-
| **TemporalCompressor** | Choose compression tier (none/half/pq8/pq4/binary) | `hot`/`warm`/`cold` |
|
|
1682
|
-
|
|
1683
|
-
Each controller uses the bandit optionally — when no bandit is provided, behavior is unchanged from v2. When present, the bandit reranks results using Thompson-sampled Beta distributions, and controllers feed outcomes back via `recordReward()`.
|
|
1684
|
-
|
|
1685
|
-
```typescript
|
|
1686
|
-
import { SolverBandit } from 'agentdb/backends/rvf/SolverBandit';
|
|
1687
|
-
|
|
1688
|
-
const bandit = new SolverBandit();
|
|
1689
|
-
|
|
1690
|
-
// Select best arm for a context
|
|
1691
|
-
const skill = bandit.selectArm('code_review', ['lint_first', 'test_first', 'security_scan']);
|
|
1692
|
-
|
|
1693
|
-
// Record outcome
|
|
1694
|
-
bandit.recordReward('code_review', skill, 0.85, /* latencyMs */ 120);
|
|
1695
|
-
|
|
1696
|
-
// Rerank candidates by learned performance
|
|
1697
|
-
const ranked = bandit.rerank('code_review', ['lint_first', 'test_first', 'security_scan']);
|
|
1698
|
-
|
|
1699
|
-
// Serialize for cross-session persistence
|
|
1700
|
-
const state = bandit.serialize(); // JSON-safe
|
|
1701
|
-
const restored = SolverBandit.deserialize(state);
|
|
1702
|
-
```
|
|
1703
|
-
|
|
1704
|
-
**Performance:** 100K `selectArm` calls in <200ms, 100K `recordReward` calls in <100ms.
|
|
1705
|
-
|
|
1706
|
-
**Wire into AgentDB controllers:**
|
|
1707
|
-
|
|
1708
|
-
```typescript
|
|
1709
|
-
import { SolverBandit, SkillLibrary, ReasoningBank, LearningSystem } from 'agentdb';
|
|
1710
|
-
|
|
1711
|
-
const bandit = new SolverBandit({ costWeight: 0.01, explorationBonus: 0.1 });
|
|
1712
|
-
|
|
1713
|
-
// Pass as optional last parameter to any controller
|
|
1714
|
-
const skills = new SkillLibrary(db, embedder, undefined, bandit);
|
|
1715
|
-
const patterns = new ReasoningBank(db, embedder, undefined, bandit);
|
|
1716
|
-
const learning = new LearningSystem(db, undefined, bandit);
|
|
1717
|
-
|
|
1718
|
-
// Controllers automatically rerank results and accept feedback
|
|
1719
|
-
const algorithm = learning.recommendAlgorithm('navigation task');
|
|
1720
|
-
learning.recordAlgorithmOutcome('navigation task', algorithm, 0.92, 340);
|
|
1721
|
-
```
|
|
1722
|
-
|
|
1723
|
-
</details>
|
|
1724
|
-
|
|
1725
|
-
---
|
|
1726
|
-
|
|
1727
|
-
### Enterprise & Security
|
|
1728
|
-
|
|
1729
|
-
Production-ready authentication, audit logging, and defense-in-depth security with cryptographic verification.
|
|
1730
|
-
|
|
1731
|
-
<details>
|
|
1732
|
-
<summary><strong>Security</strong> — defense-in-depth with cryptographic audit trails</summary>
|
|
1733
|
-
|
|
1734
|
-
AgentDB provides defense-in-depth security with validation at every system boundary.
|
|
1735
|
-
|
|
1736
|
-
### Input Validation
|
|
1737
|
-
|
|
1738
|
-
```typescript
|
|
1739
|
-
import {
|
|
1740
|
-
validateVector,
|
|
1741
|
-
validateVectorId,
|
|
1742
|
-
validateSearchOptions,
|
|
1743
|
-
validateHNSWParams,
|
|
1744
|
-
sanitizeMetadata,
|
|
1745
|
-
validateCypherParams,
|
|
1746
|
-
validateLabel,
|
|
1747
|
-
validateBatchSize,
|
|
1748
|
-
} from 'agentdb/security/validation';
|
|
1749
|
-
|
|
1750
|
-
// Vector validation — prevents NaN/Infinity injection
|
|
1751
|
-
validateVector(embedding, 384, 'embedding');
|
|
1752
|
-
|
|
1753
|
-
// ID validation — prevents path traversal (../, etc.)
|
|
1754
|
-
validateVectorId('doc-123', 'id');
|
|
1755
|
-
|
|
1756
|
-
// Search bounds — k, threshold, efSearch range checking
|
|
1757
|
-
validateSearchOptions({ k: 10, threshold: 0.7 });
|
|
1758
|
-
|
|
1759
|
-
// HNSW parameter validation — M, efConstruction, efSearch
|
|
1760
|
-
validateHNSWParams({ M: 16, efConstruction: 200, efSearch: 100 });
|
|
1761
|
-
|
|
1762
|
-
// Metadata sanitization — strips password, token, key, apiKey, auth fields
|
|
1763
|
-
const safe = sanitizeMetadata(userInput);
|
|
1764
|
-
|
|
1765
|
-
// Cypher injection prevention
|
|
1766
|
-
validateCypherParams(params);
|
|
1767
|
-
```
|
|
1768
|
-
|
|
1769
|
-
### XSS & Injection Prevention
|
|
1770
|
-
|
|
1771
|
-
```typescript
|
|
1772
|
-
import {
|
|
1773
|
-
validateTaskString,
|
|
1774
|
-
validateNumericRange,
|
|
1775
|
-
validateEnum,
|
|
1776
|
-
} from 'agentdb/security/input-validation';
|
|
1777
|
-
|
|
1778
|
-
const task = validateTaskString(input, 'task'); // XSS pattern detection
|
|
1779
|
-
const k = validateNumericRange(kVal, 'k', 1, 100);
|
|
1780
|
-
const format = validateEnum(fmt, 'format', ['json', 'concise', 'detailed']);
|
|
1781
|
-
```
|
|
1782
|
-
|
|
1783
|
-
### Security Limits
|
|
1784
|
-
|
|
1785
|
-
| Parameter | Limit |
|
|
1786
|
-
| --- | --- |
|
|
1787
|
-
| Max vectors | 10,000,000 |
|
|
1788
|
-
| Max dimension | 4,096 |
|
|
1789
|
-
| Max batch size | 10,000 |
|
|
1790
|
-
| Max k | 10,000 |
|
|
1791
|
-
| Max metadata size | 64 KB |
|
|
1792
|
-
| Max ID length | 256 chars |
|
|
1793
|
-
| Filter expression depth | 64 |
|
|
1794
|
-
| ef-search range | 1 - 1,000 |
|
|
1795
|
-
| ef-construction range | 4 - 500 |
|
|
1796
|
-
| M range | 2 - 64 |
|
|
1797
|
-
|
|
1798
|
-
### Witness Chain Verification
|
|
1799
|
-
|
|
1800
|
-
SHAKE-256 cryptographic witness chains provide tamper-evident audit trails:
|
|
1801
|
-
|
|
1802
|
-
```typescript
|
|
1803
|
-
const result = backend.verifyWitnessChain();
|
|
1804
|
-
if (!result.valid) {
|
|
1805
|
-
console.error('Data integrity compromised!');
|
|
1806
|
-
}
|
|
1807
|
-
```
|
|
1808
|
-
|
|
1809
|
-
### Provenance Certificates (Explainable Recall)
|
|
1810
|
-
|
|
1811
|
-
Every search result can include a Merkle proof explaining why it was selected:
|
|
1812
|
-
|
|
1813
|
-
```typescript
|
|
1814
|
-
const { results, certificate } = await causalRecall.recall(
|
|
1815
|
-
'query-id',
|
|
1816
|
-
'optimization strategies',
|
|
1817
|
-
10,
|
|
1818
|
-
['performance'],
|
|
1819
|
-
'internal',
|
|
1820
|
-
);
|
|
1821
|
-
console.log(`Certificate ID: ${certificate.id}`);
|
|
1822
|
-
console.log(`Completeness: ${certificate.completenessScore}`);
|
|
1823
|
-
```
|
|
1824
|
-
|
|
1825
|
-
</details>
|
|
254
|
+
console.log(`Found ${similarReviews.length} successful reviews to learn from`);
|
|
255
|
+
console.log(`Best approach: ${similarReviews[0].critique}`);
|
|
256
|
+
```
|
|
1826
257
|
|
|
1827
|
-
|
|
258
|
+
### Example 2: RAG System with Self-Learning
|
|
1828
259
|
|
|
1829
|
-
|
|
1830
|
-
|
|
260
|
+
```typescript
|
|
261
|
+
import { createDatabase, ReasoningBank, SkillLibrary, EmbeddingService } from 'agentdb';
|
|
1831
262
|
|
|
1832
|
-
|
|
263
|
+
const db = await createDatabase('./rag-system.db');
|
|
264
|
+
const embedder = new EmbeddingService({ model: 'Xenova/all-MiniLM-L6-v2' });
|
|
265
|
+
await embedder.initialize();
|
|
1833
266
|
|
|
1834
|
-
|
|
267
|
+
const reasoningBank = new ReasoningBank(db, embedder);
|
|
268
|
+
const skills = new SkillLibrary(db, embedder);
|
|
1835
269
|
|
|
1836
|
-
|
|
270
|
+
// Store document retrieval patterns
|
|
271
|
+
await reasoningBank.storePattern({
|
|
272
|
+
taskType: 'document_retrieval',
|
|
273
|
+
approach: 'Expand query with synonyms → Semantic search → Re-rank by relevance',
|
|
274
|
+
successRate: 0.88,
|
|
275
|
+
tags: ['rag', 'retrieval']
|
|
276
|
+
});
|
|
1837
277
|
|
|
1838
|
-
|
|
1839
|
-
|
|
278
|
+
// Create reusable query expansion skill
|
|
279
|
+
await skills.createSkill({
|
|
280
|
+
name: 'expand_query',
|
|
281
|
+
description: 'Expand user query with domain-specific synonyms',
|
|
282
|
+
signature: { inputs: { query: 'string' }, outputs: { expanded: 'string[]' } },
|
|
283
|
+
code: `
|
|
284
|
+
const synonymMap = { 'bug': ['issue', 'defect', 'error'], ... };
|
|
285
|
+
return query.split(' ').flatMap(word => synonymMap[word] || [word]);
|
|
286
|
+
`,
|
|
287
|
+
successRate: 0.92
|
|
288
|
+
});
|
|
1840
289
|
|
|
1841
|
-
//
|
|
1842
|
-
const
|
|
1843
|
-
|
|
1844
|
-
|
|
290
|
+
// Search for retrieval patterns (learns which work best)
|
|
291
|
+
const patterns = await reasoningBank.searchPatterns({
|
|
292
|
+
task: 'find technical documentation',
|
|
293
|
+
k: 10
|
|
294
|
+
});
|
|
1845
295
|
|
|
1846
|
-
//
|
|
1847
|
-
const
|
|
1848
|
-
|
|
1849
|
-
const results = storePQ.search(query, 10);
|
|
296
|
+
// Apply best pattern
|
|
297
|
+
const bestPattern = patterns[0];
|
|
298
|
+
console.log(`Using approach: ${bestPattern.approach}`);
|
|
1850
299
|
```
|
|
1851
300
|
|
|
1852
|
-
###
|
|
301
|
+
### Example 3: Run Latent Space Simulations
|
|
1853
302
|
|
|
1854
|
-
|
|
303
|
+
Validate AgentDB's optimizations through empirical simulations:
|
|
1855
304
|
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
| **Cool** | PQ-8 | ~12% | ~95% | Older data |
|
|
1861
|
-
| **Cold** | PQ-4 | ~6% | ~90% | Rarely accessed |
|
|
1862
|
-
| **Archive** | Binary | ~3% | ~80% | Archival storage |
|
|
305
|
+
```bash
|
|
306
|
+
# Test HNSW graph optimization (validates 8.2x speedup)
|
|
307
|
+
agentdb simulate hnsw --iterations 3
|
|
308
|
+
# Output: ✅ 61μs p50 latency, 96.8% recall@10, M=32 optimal
|
|
1863
309
|
|
|
1864
|
-
|
|
310
|
+
# Test 8-head GNN attention mechanism
|
|
311
|
+
agentdb simulate attention --iterations 3
|
|
312
|
+
# Output: ✅ +12.4% recall improvement, 3.8ms forward pass
|
|
1865
313
|
|
|
1866
|
-
|
|
314
|
+
# Test 30-day self-healing with MPC adaptation
|
|
315
|
+
agentdb simulate self-organizing --days 30
|
|
316
|
+
# Output: ✅ 97.9% degradation prevention, <100ms healing
|
|
1867
317
|
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
const truncated = embedding.slice(0, 128);
|
|
318
|
+
# Interactive wizard for custom simulations
|
|
319
|
+
agentdb simulate --wizard
|
|
320
|
+
# Guides you through 6-step configuration with 25+ components
|
|
1872
321
|
```
|
|
1873
322
|
|
|
1874
|
-
|
|
323
|
+
See [simulation/README.md](simulation/README.md) for 25 available scenarios and complete documentation.
|
|
1875
324
|
|
|
1876
|
-
|
|
325
|
+
### Example 4: MCP Integration (Claude Code)
|
|
1877
326
|
|
|
1878
|
-
|
|
1879
|
-
const accel = new NativeAccelerator();
|
|
1880
|
-
await accel.initialize();
|
|
327
|
+
Zero-code integration with AI coding assistants:
|
|
1881
328
|
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
329
|
+
```bash
|
|
330
|
+
# One-command setup
|
|
331
|
+
claude mcp add agentdb npx agentdb@latest mcp start
|
|
1885
332
|
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
333
|
+
# Now Claude Code can:
|
|
334
|
+
# - Store reasoning patterns automatically
|
|
335
|
+
# - Search 32.6M patterns/sec for relevant approaches
|
|
336
|
+
# - Learn from successful task completions
|
|
337
|
+
# - Build reusable skills over time
|
|
338
|
+
# - Run latent space simulations
|
|
1889
339
|
```
|
|
1890
340
|
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
341
|
+
**Manual setup** (add to `~/.config/claude/claude_desktop_config.json`):
|
|
342
|
+
```json
|
|
343
|
+
{
|
|
344
|
+
"mcpServers": {
|
|
345
|
+
"agentdb": {
|
|
346
|
+
"command": "npx",
|
|
347
|
+
"args": ["agentdb@latest", "mcp", "start"],
|
|
348
|
+
"env": { "AGENTDB_PATH": "./agentdb.db" }
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
```
|
|
1894
353
|
|
|
1895
|
-
###
|
|
354
|
+
### Advanced Usage
|
|
1896
355
|
|
|
1897
|
-
|
|
356
|
+
```typescript
|
|
357
|
+
import {
|
|
358
|
+
createDatabase,
|
|
359
|
+
ReasoningBank,
|
|
360
|
+
ReflexionMemory,
|
|
361
|
+
SkillLibrary,
|
|
362
|
+
EmbeddingService,
|
|
363
|
+
BatchOperations
|
|
364
|
+
} from 'agentdb';
|
|
365
|
+
|
|
366
|
+
// Initialize database
|
|
367
|
+
const db = await createDatabase('./agent-memory.db');
|
|
1898
368
|
|
|
1899
|
-
|
|
1900
|
-
|
|
369
|
+
// Initialize embedding service
|
|
370
|
+
const embedder = new EmbeddingService({
|
|
371
|
+
model: 'Xenova/all-MiniLM-L6-v2',
|
|
372
|
+
dimension: 384,
|
|
373
|
+
provider: 'transformers'
|
|
374
|
+
});
|
|
375
|
+
await embedder.initialize();
|
|
1901
376
|
|
|
1902
|
-
|
|
377
|
+
// ReasoningBank - Pattern learning and adaptive memory
|
|
378
|
+
const reasoningBank = new ReasoningBank(db, embedder);
|
|
1903
379
|
|
|
1904
|
-
|
|
380
|
+
// Store reasoning pattern (388K ops/sec)
|
|
381
|
+
const patternId = await reasoningBank.storePattern({
|
|
382
|
+
taskType: 'code_review',
|
|
383
|
+
approach: 'Security-first analysis followed by code quality checks',
|
|
384
|
+
successRate: 0.95,
|
|
385
|
+
tags: ['security', 'code-quality'],
|
|
386
|
+
metadata: { language: 'typescript' }
|
|
387
|
+
});
|
|
1905
388
|
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
389
|
+
// Search patterns (32.6M ops/sec - ultra-fast)
|
|
390
|
+
const patterns = await reasoningBank.searchPatterns({
|
|
391
|
+
task: 'security code review',
|
|
392
|
+
k: 10,
|
|
393
|
+
threshold: 0.7,
|
|
394
|
+
filters: { taskType: 'code_review' }
|
|
395
|
+
});
|
|
1913
396
|
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
npx agentdb init
|
|
397
|
+
// Reflexion Memory - Learn from experience
|
|
398
|
+
const reflexion = new ReflexionMemory(db, embedder);
|
|
1917
399
|
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
400
|
+
// Store episode with self-critique
|
|
401
|
+
const episodeId = await reflexion.storeEpisode({
|
|
402
|
+
sessionId: 'session-1',
|
|
403
|
+
task: 'Implement OAuth2 authentication',
|
|
404
|
+
reward: 0.95,
|
|
405
|
+
success: true,
|
|
406
|
+
critique: 'PKCE flow provided better security than basic flow',
|
|
407
|
+
input: 'Authentication requirements',
|
|
408
|
+
output: 'Working OAuth2 implementation',
|
|
409
|
+
latencyMs: 1200,
|
|
410
|
+
tokensUsed: 500
|
|
411
|
+
});
|
|
1921
412
|
|
|
1922
|
-
|
|
413
|
+
// Retrieve similar episodes (957 ops/sec)
|
|
414
|
+
const episodes = await reflexion.retrieveRelevant({
|
|
415
|
+
task: 'authentication implementation',
|
|
416
|
+
k: 5,
|
|
417
|
+
onlySuccesses: true
|
|
418
|
+
});
|
|
1923
419
|
|
|
1924
|
-
|
|
420
|
+
// Skill Library - Lifelong learning
|
|
421
|
+
const skills = new SkillLibrary(db, embedder);
|
|
1925
422
|
|
|
1926
|
-
|
|
1927
|
-
|
|
423
|
+
// Create reusable skill
|
|
424
|
+
const skillId = await skills.createSkill({
|
|
425
|
+
name: 'jwt_authentication',
|
|
426
|
+
description: 'Generate and validate JWT tokens',
|
|
427
|
+
signature: { inputs: { userId: 'string' }, outputs: { token: 'string' } },
|
|
428
|
+
code: 'implementation code here...',
|
|
429
|
+
successRate: 0.92,
|
|
430
|
+
uses: 0,
|
|
431
|
+
avgReward: 0.0,
|
|
432
|
+
avgLatencyMs: 0.0
|
|
433
|
+
});
|
|
1928
434
|
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
435
|
+
// Search for applicable skills (694 ops/sec)
|
|
436
|
+
const applicableSkills = await skills.searchSkills({
|
|
437
|
+
task: 'user authentication',
|
|
438
|
+
k: 10,
|
|
439
|
+
minSuccessRate: 0.7
|
|
440
|
+
});
|
|
1933
441
|
|
|
1934
|
-
|
|
442
|
+
// Batch Operations - 3-4x faster (NEW v2.0)
|
|
443
|
+
const batchOps = new BatchOperations(db, embedder, {
|
|
444
|
+
batchSize: 100,
|
|
445
|
+
parallelism: 4
|
|
446
|
+
});
|
|
1935
447
|
|
|
1936
|
-
|
|
448
|
+
// Batch create skills (1,539 → 5,556 ops/sec - 3.6x faster)
|
|
449
|
+
const skillIds = await batchOps.insertSkills([
|
|
450
|
+
{ name: 'skill-1', description: 'First skill', successRate: 0.8 },
|
|
451
|
+
{ name: 'skill-2', description: 'Second skill', successRate: 0.9 },
|
|
452
|
+
// ... up to 100 skills
|
|
453
|
+
]);
|
|
1937
454
|
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
455
|
+
// Batch store episodes (2,273 → 7,692 ops/sec - 3.4x faster)
|
|
456
|
+
const episodeIds = await batchOps.insertEpisodes([
|
|
457
|
+
{ sessionId: 'session-1', task: 'debug-1', reward: 0.85, success: true },
|
|
458
|
+
{ sessionId: 'session-2', task: 'optimize-1', reward: 0.90, success: true },
|
|
459
|
+
// ... up to 100 episodes
|
|
460
|
+
]);
|
|
1941
461
|
|
|
1942
|
-
|
|
1943
|
-
|
|
462
|
+
// Prune old data (NEW v2.0)
|
|
463
|
+
const pruneResults = await batchOps.pruneData({
|
|
464
|
+
maxAge: 90, // Keep data from last 90 days
|
|
465
|
+
minReward: 0.3, // Keep episodes with reward >= 0.3
|
|
466
|
+
minSuccessRate: 0.5, // Keep skills/patterns with >= 50% success
|
|
467
|
+
maxRecords: 100000, // Max 100k records per table
|
|
468
|
+
dryRun: false // Actually delete (use true to preview)
|
|
469
|
+
});
|
|
1944
470
|
|
|
1945
|
-
|
|
1946
|
-
|
|
471
|
+
console.log(`Pruned ${pruneResults.episodesPruned} episodes`);
|
|
472
|
+
console.log(`Saved ${pruneResults.spaceSaved} bytes`);
|
|
1947
473
|
```
|
|
1948
474
|
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
Export a WASM store to a transferable binary for sharing between browser tabs or workers:
|
|
475
|
+
---
|
|
1952
476
|
|
|
1953
|
-
|
|
1954
|
-
const bytes = bridge.wasmStoreExport(handle); // Uint8Array
|
|
1955
|
-
// Transfer to another worker or save to IndexedDB
|
|
1956
|
-
```
|
|
477
|
+
## 🧠 Frontier Memory Features
|
|
1957
478
|
|
|
1958
|
-
|
|
479
|
+
### 1. 🔄 ReasoningBank — Pattern Learning & Adaptive Memory
|
|
1959
480
|
|
|
1960
|
-
|
|
481
|
+
**The cognitive layer that makes agents smarter over time**
|
|
1961
482
|
|
|
1962
|
-
|
|
1963
|
-
<summary><strong>Query Lifecycle</strong> — what happens when you call searchAsync()</summary>
|
|
1964
|
-
|
|
1965
|
-
The full lifecycle of a query through AgentDB's self-learning pipeline:
|
|
1966
|
-
|
|
1967
|
-
```mermaid
|
|
1968
|
-
sequenceDiagram
|
|
1969
|
-
participant App
|
|
1970
|
-
participant Router as Semantic Router
|
|
1971
|
-
participant SONA
|
|
1972
|
-
participant HNSW as HNSW Index
|
|
1973
|
-
participant Trainer as Contrastive Trainer
|
|
1974
|
-
|
|
1975
|
-
App->>Router: query(embedding)
|
|
1976
|
-
Router->>Router: classify intent
|
|
1977
|
-
Router->>SONA: enhance(embedding, trajectories)
|
|
1978
|
-
SONA->>SONA: apply micro-LoRA
|
|
1979
|
-
SONA->>HNSW: searchAsync(enhanced, k, ef)
|
|
1980
|
-
HNSW-->>App: results[]
|
|
1981
|
-
App->>Trainer: recordFeedback(quality)
|
|
1982
|
-
Trainer->>Trainer: InfoNCE + hard negatives
|
|
1983
|
-
Trainer->>SONA: updateLoRA(gradients)
|
|
1984
|
-
Note over SONA: EWC++ consolidation<br/>prevents forgetting
|
|
1985
|
-
```
|
|
483
|
+
Store successful reasoning patterns and retrieve them using semantic similarity. ReasoningBank learns which approaches work best for different types of tasks.
|
|
1986
484
|
|
|
1987
|
-
|
|
485
|
+
```typescript
|
|
486
|
+
// Store a pattern
|
|
487
|
+
await reasoningBank.storePattern({
|
|
488
|
+
taskType: 'bug_investigation',
|
|
489
|
+
approach: 'Check logs → Reproduce issue → Binary search for root cause',
|
|
490
|
+
successRate: 0.92,
|
|
491
|
+
tags: ['debugging', 'systematic'],
|
|
492
|
+
metadata: { avgTimeMs: 3000 }
|
|
493
|
+
});
|
|
1988
494
|
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
8. **Consolidation** — EWC++ prevents catastrophic forgetting of previously learned patterns
|
|
495
|
+
// Search patterns (32.6M ops/sec - ultra-fast)
|
|
496
|
+
const patterns = await reasoningBank.searchPatterns({
|
|
497
|
+
task: 'debug memory leak',
|
|
498
|
+
k: 10,
|
|
499
|
+
threshold: 0.7,
|
|
500
|
+
filters: { taskType: 'bug_investigation' }
|
|
501
|
+
});
|
|
1997
502
|
|
|
1998
|
-
|
|
503
|
+
// Get pattern statistics
|
|
504
|
+
const stats = reasoningBank.getPatternStats();
|
|
505
|
+
console.log(`Total patterns: ${stats.totalPatterns}`);
|
|
506
|
+
console.log(`Avg success rate: ${stats.avgSuccessRate}`);
|
|
507
|
+
```
|
|
1999
508
|
|
|
2000
|
-
|
|
509
|
+
**Performance:**
|
|
510
|
+
- Pattern storage: 388K ops/sec
|
|
511
|
+
- Pattern search: 32.6M ops/sec (ultra-fast with caching)
|
|
512
|
+
- Super-linear scaling: 4,536 patterns/sec @ 5k items
|
|
2001
513
|
|
|
2002
|
-
|
|
514
|
+
**Use Cases:**
|
|
515
|
+
- Learn debugging strategies that work
|
|
516
|
+
- Discover code patterns that prevent bugs
|
|
517
|
+
- Build institutional knowledge automatically
|
|
2003
518
|
|
|
2004
|
-
|
|
519
|
+
### 2. 🔄 Reflexion Memory — Learn from Experience
|
|
2005
520
|
|
|
2006
|
-
|
|
2007
|
-
<summary><strong>Multi-Database Coordination</strong> — distributed sync with conflict resolution</summary>
|
|
521
|
+
**Episodic replay with self-critique for continuous improvement**
|
|
2008
522
|
|
|
2009
|
-
|
|
523
|
+
Store complete task episodes with self-generated critiques, then replay them to improve future performance. Based on the Reflexion paper (Shinn et al., 2023).
|
|
2010
524
|
|
|
2011
525
|
```typescript
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
526
|
+
// Store episode with self-critique
|
|
527
|
+
const episodeId = await reflexion.storeEpisode({
|
|
528
|
+
sessionId: 'debug-session-1',
|
|
529
|
+
task: 'Fix authentication bug',
|
|
530
|
+
reward: 0.95,
|
|
531
|
+
success: true,
|
|
532
|
+
critique: 'OAuth2 PKCE flow was more secure than basic flow. Should always check token expiration.',
|
|
533
|
+
input: 'Users can\'t log in',
|
|
534
|
+
output: 'Working OAuth2 implementation with refresh tokens',
|
|
535
|
+
latencyMs: 1200,
|
|
536
|
+
tokensUsed: 500
|
|
2020
537
|
});
|
|
2021
538
|
|
|
2022
|
-
//
|
|
2023
|
-
await
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
await coordinator.registerInstance({
|
|
2029
|
-
id: 'replica-1',
|
|
2030
|
-
url: 'file:///data/replica-1.rvf',
|
|
2031
|
-
role: 'replica',
|
|
539
|
+
// Retrieve similar episodes (957 ops/sec)
|
|
540
|
+
const similar = await reflexion.retrieveRelevant({
|
|
541
|
+
task: 'authentication issues',
|
|
542
|
+
k: 10,
|
|
543
|
+
onlySuccesses: true, // Learn from what worked
|
|
544
|
+
minReward: 0.7
|
|
2032
545
|
});
|
|
2033
546
|
|
|
2034
|
-
//
|
|
2035
|
-
const
|
|
2036
|
-
console.log(`
|
|
2037
|
-
|
|
2038
|
-
// Broadcast operations to all instances
|
|
2039
|
-
await coordinator.broadcast('insertAsync', ['doc-1', embedding, { source: 'api' }]);
|
|
2040
|
-
|
|
2041
|
-
// Monitor instance status
|
|
2042
|
-
coordinator.onStatusChange((instanceId, status) => {
|
|
2043
|
-
console.log(`${instanceId}: ${status.state}`); // 'healthy' | 'degraded' | 'offline'
|
|
2044
|
-
});
|
|
547
|
+
// Get task-specific statistics
|
|
548
|
+
const stats = await reflexion.getTaskStats('debug-session-1');
|
|
549
|
+
console.log(`Success rate: ${stats.successRate}`);
|
|
550
|
+
console.log(`Avg reward: ${stats.avgReward}`);
|
|
2045
551
|
```
|
|
2046
552
|
|
|
2047
|
-
|
|
553
|
+
**Benefits:**
|
|
554
|
+
- Learn from successes and failures
|
|
555
|
+
- Build expertise over time
|
|
556
|
+
- Avoid repeating mistakes
|
|
557
|
+
- Self-improvement through critique
|
|
2048
558
|
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
</details>
|
|
559
|
+
**CLI:**
|
|
560
|
+
```bash
|
|
561
|
+
# Store episode
|
|
562
|
+
agentdb reflexion store "session-1" "fix_auth_bug" 0.95 true \
|
|
563
|
+
"OAuth2 PKCE worked perfectly" "login failing" "fixed tokens" 1200 500
|
|
2056
564
|
|
|
2057
|
-
|
|
565
|
+
# Retrieve similar
|
|
566
|
+
agentdb reflexion retrieve "authentication issues" 10 0.8
|
|
2058
567
|
|
|
2059
|
-
|
|
2060
|
-
|
|
568
|
+
# Get critique summary
|
|
569
|
+
agentdb reflexion critique "fix_auth_bug" 10 0.5
|
|
570
|
+
```
|
|
2061
571
|
|
|
2062
|
-
|
|
572
|
+
### 3. 🎓 Skill Library — Lifelong Learning
|
|
2063
573
|
|
|
2064
|
-
|
|
574
|
+
**Transform successful patterns into reusable, composable skills**
|
|
2065
575
|
|
|
2066
|
-
|
|
576
|
+
Automatically consolidate repeated successful task executions into parameterized skills that can be composed and reused.
|
|
2067
577
|
|
|
2068
578
|
```typescript
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
bytesPerMin: 10_000_000,
|
|
579
|
+
// Create skill manually
|
|
580
|
+
const skillId = await skills.createSkill({
|
|
581
|
+
name: 'jwt_authentication',
|
|
582
|
+
description: 'Generate and validate JWT tokens with refresh flow',
|
|
583
|
+
signature: {
|
|
584
|
+
inputs: { userId: 'string', permissions: 'array' },
|
|
585
|
+
outputs: { accessToken: 'string', refreshToken: 'string' }
|
|
2077
586
|
},
|
|
2078
|
-
|
|
587
|
+
code: 'implementation code...',
|
|
588
|
+
successRate: 0.92
|
|
2079
589
|
});
|
|
2080
590
|
|
|
2081
|
-
//
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
High-level bidirectional sync with conflict resolution, progress tracking, and auto-sync:
|
|
2089
|
-
|
|
2090
|
-
```typescript
|
|
2091
|
-
import { SyncCoordinator } from 'agentdb/controllers/SyncCoordinator';
|
|
591
|
+
// Search for applicable skills (694 ops/sec)
|
|
592
|
+
const applicable = await skills.searchSkills({
|
|
593
|
+
task: 'user authentication with tokens',
|
|
594
|
+
k: 5,
|
|
595
|
+
minSuccessRate: 0.7
|
|
596
|
+
});
|
|
2092
597
|
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
598
|
+
// Auto-consolidate from successful episodes
|
|
599
|
+
const consolidated = await skills.consolidateFromEpisodes({
|
|
600
|
+
minAttempts: 3, // Need 3+ successful executions
|
|
601
|
+
minSuccessRate: 0.7, // With 70%+ success rate
|
|
602
|
+
lookbackDays: 7 // In the last 7 days
|
|
2097
603
|
});
|
|
2098
604
|
|
|
2099
|
-
//
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
// itemsPulled: 8,
|
|
2107
|
-
// conflictsResolved: 2,
|
|
2108
|
-
// bytesTransferred: 48200,
|
|
2109
|
-
// errors: [],
|
|
2110
|
-
// }
|
|
2111
|
-
|
|
2112
|
-
// Progress tracking through 5 phases:
|
|
2113
|
-
// detecting → pushing → pulling → resolving → applying
|
|
2114
|
-
|
|
2115
|
-
// Sync state persists across restarts
|
|
2116
|
-
await sync.saveSyncState();
|
|
2117
|
-
// Tracks: lastSyncAt, lastEpisodeSync, lastSkillSync, lastEdgeSync,
|
|
2118
|
-
// totalItemsSynced, totalBytesSynced, syncCount
|
|
605
|
+
// Update skill after use
|
|
606
|
+
await skills.updateSkillStats(skillId, {
|
|
607
|
+
uses: 1,
|
|
608
|
+
successRate: 0.95,
|
|
609
|
+
success: true,
|
|
610
|
+
latencyMs: 1200
|
|
611
|
+
});
|
|
2119
612
|
```
|
|
2120
613
|
|
|
2121
|
-
|
|
614
|
+
**Features:**
|
|
615
|
+
- Automatic skill extraction from episodes
|
|
616
|
+
- Semantic search for skill discovery
|
|
617
|
+
- Usage tracking and success rate monitoring
|
|
618
|
+
- Skill composition and chaining
|
|
2122
619
|
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
| `merge` | Quality-weighted merge of both versions |
|
|
620
|
+
**CLI:**
|
|
621
|
+
```bash
|
|
622
|
+
# Create skill
|
|
623
|
+
agentdb skill create "jwt_auth" "Generate JWT tokens" \
|
|
624
|
+
'{"inputs": {"user": "object"}}' "code..." 1
|
|
2129
625
|
|
|
2130
|
-
|
|
626
|
+
# Search skills
|
|
627
|
+
agentdb skill search "authentication" 5 0.5
|
|
2131
628
|
|
|
2132
|
-
|
|
629
|
+
# Auto-consolidate from episodes
|
|
630
|
+
agentdb skill consolidate 3 0.7 7
|
|
2133
631
|
|
|
2134
|
-
|
|
2135
|
-
|
|
632
|
+
# Update skill stats
|
|
633
|
+
agentdb skill update 1 1 0.95 true 1200
|
|
634
|
+
```
|
|
2136
635
|
|
|
2137
|
-
|
|
636
|
+
### 4. 🔗 Causal Memory Graph — Intervention-Based Causality
|
|
2138
637
|
|
|
2139
|
-
|
|
638
|
+
**Learn what interventions cause what outcomes, not just correlations**
|
|
2140
639
|
|
|
2141
|
-
|
|
640
|
+
Track `p(y|do(x))` using doubly robust estimation and instrumental variables. Understand which actions lead to which results.
|
|
2142
641
|
|
|
2143
642
|
```typescript
|
|
2144
|
-
import {
|
|
643
|
+
import { CausalMemoryGraph } from 'agentdb/controllers/CausalMemoryGraph';
|
|
2145
644
|
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
645
|
+
const causalGraph = new CausalMemoryGraph(db);
|
|
646
|
+
|
|
647
|
+
// Create causal experiment (A/B test)
|
|
648
|
+
const experimentId = causalGraph.createExperiment({
|
|
649
|
+
name: 'test_error_handling_approach',
|
|
650
|
+
hypothesis: 'Try-catch reduces crash rate',
|
|
651
|
+
treatmentId: 123, // Episode ID with error handling
|
|
652
|
+
treatmentType: 'episode',
|
|
653
|
+
controlId: 124, // Episode ID without
|
|
654
|
+
startTime: Date.now(),
|
|
655
|
+
sampleSize: 0,
|
|
656
|
+
status: 'running'
|
|
2149
657
|
});
|
|
2150
658
|
|
|
2151
|
-
//
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
659
|
+
// Record observations
|
|
660
|
+
causalGraph.recordObservation({
|
|
661
|
+
experimentId,
|
|
662
|
+
episodeId: 123,
|
|
663
|
+
isTreatment: true,
|
|
664
|
+
outcomeValue: 0.95, // Success rate
|
|
665
|
+
outcomeType: 'success'
|
|
666
|
+
});
|
|
2156
667
|
|
|
2157
|
-
|
|
668
|
+
// Calculate causal uplift
|
|
669
|
+
const { uplift, pValue, confidenceInterval } =
|
|
670
|
+
causalGraph.calculateUplift(experimentId);
|
|
671
|
+
|
|
672
|
+
console.log(`Causal uplift: ${uplift}`);
|
|
673
|
+
console.log(`p-value: ${pValue}`);
|
|
674
|
+
console.log(`95% CI: [${confidenceInterval[0]}, ${confidenceInterval[1]}]`);
|
|
675
|
+
|
|
676
|
+
// Add causal edge
|
|
677
|
+
const edgeId = causalGraph.addCausalEdge({
|
|
678
|
+
fromMemoryId: 123,
|
|
679
|
+
fromMemoryType: 'episode',
|
|
680
|
+
toMemoryId: 125,
|
|
681
|
+
toMemoryType: 'episode',
|
|
682
|
+
similarity: 0.85,
|
|
683
|
+
uplift: 0.15, // 15% improvement
|
|
684
|
+
confidence: 0.95,
|
|
685
|
+
sampleSize: 50
|
|
686
|
+
});
|
|
2158
687
|
|
|
2159
|
-
|
|
688
|
+
// Query causal effects
|
|
689
|
+
const effects = causalGraph.queryCausalEffects({
|
|
690
|
+
interventionMemoryId: 123,
|
|
691
|
+
interventionMemoryType: 'episode',
|
|
692
|
+
minConfidence: 0.8,
|
|
693
|
+
minUplift: 0.1
|
|
694
|
+
});
|
|
695
|
+
```
|
|
2160
696
|
|
|
2161
|
-
|
|
2162
|
-
-
|
|
2163
|
-
-
|
|
2164
|
-
-
|
|
2165
|
-
-
|
|
697
|
+
**Use Cases:**
|
|
698
|
+
- Discover which debugging strategies fix bugs
|
|
699
|
+
- Learn what code patterns improve performance
|
|
700
|
+
- Understand what approaches lead to success
|
|
701
|
+
- A/B test different agent strategies
|
|
2166
702
|
|
|
2167
|
-
|
|
703
|
+
### 5. 📜 Explainable Recall — Provenance Certificates
|
|
2168
704
|
|
|
2169
|
-
|
|
705
|
+
**Every retrieval comes with a cryptographic proof explaining why**
|
|
2170
706
|
|
|
2171
|
-
|
|
707
|
+
Understand exactly why memories were selected with Merkle proof certificates that verify completeness and relevance.
|
|
2172
708
|
|
|
2173
|
-
|
|
709
|
+
```typescript
|
|
710
|
+
import { CausalRecall } from 'agentdb/controllers/CausalRecall';
|
|
2174
711
|
|
|
2175
|
-
|
|
2176
|
-
|
|
712
|
+
const causalRecall = new CausalRecall(db, embedder, vectorBackend, {
|
|
713
|
+
alpha: 0.7, // Similarity weight
|
|
714
|
+
beta: 0.2, // Causal uplift weight
|
|
715
|
+
gamma: 0.1 // Latency penalty
|
|
716
|
+
});
|
|
2177
717
|
|
|
2178
|
-
|
|
718
|
+
// Retrieve with certificate
|
|
719
|
+
const result = await causalRecall.recall(
|
|
720
|
+
'query-123',
|
|
721
|
+
'How to optimize API response time',
|
|
722
|
+
12, // k results
|
|
723
|
+
['performance', 'optimization'], // requirements
|
|
724
|
+
'internal' // access level
|
|
725
|
+
);
|
|
2179
726
|
|
|
2180
|
-
|
|
727
|
+
console.log(`Retrieved ${result.candidates.length} results`);
|
|
728
|
+
console.log(`Certificate ID: ${result.certificate.id}`);
|
|
729
|
+
console.log(`Completeness: ${result.certificate.completenessScore}`);
|
|
730
|
+
console.log(`Redundancy: ${result.certificate.redundancyRatio}`);
|
|
2181
731
|
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
| **Decision Transformer** | Sequence-based | Offline RL from logged trajectories |
|
|
2191
|
-
| **Monte Carlo Tree Search** | Planning | Game-like decision trees, look-ahead planning |
|
|
2192
|
-
| **Model-Based RL** | Model-based | Sample-efficient learning with world models |
|
|
732
|
+
// Certificate includes:
|
|
733
|
+
// - Query ID and text
|
|
734
|
+
// - Retrieved chunk IDs with relevance scores
|
|
735
|
+
// - Completeness score (% requirements met)
|
|
736
|
+
// - Redundancy ratio (duplicate coverage)
|
|
737
|
+
// - Merkle root hash (cryptographic proof)
|
|
738
|
+
// - Access level and timestamp
|
|
739
|
+
```
|
|
2193
740
|
|
|
2194
|
-
|
|
741
|
+
**Benefits:**
|
|
742
|
+
- Understand why specific memories were selected
|
|
743
|
+
- Verify retrieval completeness
|
|
744
|
+
- Debug agent decision-making
|
|
745
|
+
- Build trust through transparency
|
|
746
|
+
- Audit trail for compliance
|
|
2195
747
|
|
|
2196
|
-
|
|
2197
|
-
import { LearningSystem } from 'agentdb';
|
|
748
|
+
### 6. 🎯 Causal Recall — Utility-Based Reranking
|
|
2198
749
|
|
|
2199
|
-
|
|
2200
|
-
algorithm: 'ppo', // any of the 9 algorithms
|
|
2201
|
-
learningRate: 0.001,
|
|
2202
|
-
discountFactor: 0.99,
|
|
2203
|
-
explorationRate: 0.1,
|
|
2204
|
-
});
|
|
750
|
+
**Retrieve what actually works, not just what's similar**
|
|
2205
751
|
|
|
2206
|
-
|
|
2207
|
-
const session = await learner.createSession({
|
|
2208
|
-
task: 'optimize_api_responses',
|
|
2209
|
-
maxEpisodes: 100,
|
|
2210
|
-
});
|
|
752
|
+
Standard vector search returns similar memories. Causal Recall reranks by actual utility:
|
|
2211
753
|
|
|
2212
|
-
|
|
2213
|
-
const prediction = await learner.predict(session.id, currentState);
|
|
2214
|
-
// { action, confidence, explorationUsed }
|
|
754
|
+
**Formula:** `U = α·similarity + β·uplift − γ·latency`
|
|
2215
755
|
|
|
2216
|
-
|
|
2217
|
-
|
|
756
|
+
- **α·similarity**: Semantic relevance (how related is this memory?)
|
|
757
|
+
- **β·uplift**: Causal impact (did this approach actually help?)
|
|
758
|
+
- **γ·latency**: Performance cost (how long did this take?)
|
|
2218
759
|
|
|
2219
|
-
|
|
2220
|
-
|
|
760
|
+
```typescript
|
|
761
|
+
// Utility-based retrieval (built into causalRecall.recall)
|
|
762
|
+
const result = await causalRecall.recall(
|
|
763
|
+
'query-456',
|
|
764
|
+
'Optimize database query performance',
|
|
765
|
+
10,
|
|
766
|
+
undefined,
|
|
767
|
+
'internal'
|
|
768
|
+
);
|
|
2221
769
|
|
|
2222
|
-
//
|
|
2223
|
-
|
|
770
|
+
// Results ranked by utility, not just similarity
|
|
771
|
+
result.candidates.forEach((candidate, i) => {
|
|
772
|
+
console.log(`${i + 1}. Utility: ${candidate.utilityScore.toFixed(3)}`);
|
|
773
|
+
console.log(` Similarity: ${candidate.similarity.toFixed(3)}`);
|
|
774
|
+
console.log(` Uplift: ${candidate.uplift?.toFixed(3) || 'N/A'}`);
|
|
775
|
+
console.log(` Latency: ${candidate.latencyMs}ms`);
|
|
776
|
+
});
|
|
2224
777
|
```
|
|
2225
778
|
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
-
|
|
2230
|
-
-
|
|
2231
|
-
- `agentdb_rl_record_reward` — record outcome feedback
|
|
2232
|
-
- `agentdb_rl_train` — trigger training round
|
|
2233
|
-
- `agentdb_rl_transfer` — transfer learned policy to new task
|
|
2234
|
-
- `agentdb_rl_explain` — explain why a prediction was made
|
|
779
|
+
**Why It Matters:**
|
|
780
|
+
- Retrieves what works, not just what's similar
|
|
781
|
+
- Balances relevance with effectiveness
|
|
782
|
+
- Accounts for performance costs
|
|
783
|
+
- Learns from causal relationships
|
|
2235
784
|
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
---
|
|
785
|
+
### 7. 🌙 Nightly Learner — Automated Pattern Discovery
|
|
2239
786
|
|
|
2240
|
-
|
|
2241
|
-
<summary><strong>Hybrid Search</strong> — BM25 keyword + vector fusion for best-of-both-worlds retrieval</summary>
|
|
787
|
+
**Background process that discovers patterns while you sleep**
|
|
2242
788
|
|
|
2243
|
-
|
|
789
|
+
Runs automated causal discovery on episode history, finding patterns you didn't explicitly program.
|
|
2244
790
|
|
|
2245
791
|
```typescript
|
|
2246
|
-
import {
|
|
792
|
+
import { NightlyLearner } from 'agentdb/controllers/NightlyLearner';
|
|
2247
793
|
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
794
|
+
const learner = new NightlyLearner(db, embedder);
|
|
795
|
+
|
|
796
|
+
// Discover patterns (dry-run first to preview)
|
|
797
|
+
const discovered = await learner.discover({
|
|
798
|
+
minAttempts: 3, // Need 3+ attempts to detect pattern
|
|
799
|
+
minSuccessRate: 0.6, // With 60%+ success rate
|
|
800
|
+
minConfidence: 0.7, // 70% statistical confidence
|
|
801
|
+
dryRun: true // Preview without saving
|
|
2253
802
|
});
|
|
2254
803
|
|
|
2255
|
-
|
|
2256
|
-
keywordIndex.add('doc-1', 'JWT authentication with refresh token rotation');
|
|
2257
|
-
keywordIndex.add('doc-2', 'OAuth2 PKCE flow for mobile applications');
|
|
804
|
+
console.log(`Would create ${discovered.length} causal edges`);
|
|
2258
805
|
|
|
2259
|
-
//
|
|
2260
|
-
const
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
806
|
+
// Run for real (creates edges + consolidates skills)
|
|
807
|
+
const created = await learner.discover({
|
|
808
|
+
minAttempts: 3,
|
|
809
|
+
minSuccessRate: 0.6,
|
|
810
|
+
minConfidence: 0.7,
|
|
811
|
+
dryRun: false // Actually create
|
|
2264
812
|
});
|
|
2265
813
|
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
814
|
+
console.log(`Created ${created.length} causal edges`);
|
|
815
|
+
|
|
816
|
+
// Prune low-quality edges
|
|
817
|
+
const pruned = await learner.pruneEdges({
|
|
818
|
+
minConfidence: 0.5,
|
|
819
|
+
minUplift: 0.05,
|
|
820
|
+
maxAgeDays: 90
|
|
2271
821
|
});
|
|
2272
|
-
|
|
822
|
+
|
|
823
|
+
console.log(`Pruned ${pruned} low-quality edges`);
|
|
2273
824
|
```
|
|
2274
825
|
|
|
2275
|
-
|
|
826
|
+
**Features:**
|
|
827
|
+
- Asynchronous execution (runs in background)
|
|
828
|
+
- Discovers causal edges automatically
|
|
829
|
+
- Auto-consolidates successful patterns into skills
|
|
830
|
+
- Prunes low-quality patterns
|
|
831
|
+
- Doubly robust estimation for causal inference
|
|
2276
832
|
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
| **Max** | `max(keyword_score, vector_score)` — takes highest signal | When either source is sufficient |
|
|
833
|
+
**CLI:**
|
|
834
|
+
```bash
|
|
835
|
+
# Discover patterns (dry-run)
|
|
836
|
+
agentdb learner run 3 0.6 0.7 true
|
|
2282
837
|
|
|
2283
|
-
|
|
838
|
+
# Create patterns for real
|
|
839
|
+
agentdb learner run 3 0.6 0.7 false
|
|
2284
840
|
|
|
2285
|
-
|
|
841
|
+
# Prune low-quality edges
|
|
842
|
+
agentdb learner prune 0.5 0.05 90
|
|
843
|
+
```
|
|
2286
844
|
|
|
2287
845
|
---
|
|
2288
846
|
|
|
2289
|
-
|
|
2290
|
-
|
|
847
|
+
## ⚡ Performance Optimizations (v2.0)
|
|
848
|
+
|
|
849
|
+
### Batch Operations — 3-4x Faster
|
|
2291
850
|
|
|
2292
|
-
|
|
851
|
+
**Process multiple items efficiently with parallel embeddings and SQL transactions**
|
|
2293
852
|
|
|
2294
853
|
```typescript
|
|
2295
|
-
import {
|
|
2296
|
-
|
|
2297
|
-
const router = new LLMRouter({
|
|
2298
|
-
providers: {
|
|
2299
|
-
ruvllm: { enabled: true }, // Local, SIMD-optimized, free
|
|
2300
|
-
openrouter: { apiKey: process.env.OPENROUTER_KEY }, // 200+ models, 99% cost savings
|
|
2301
|
-
gemini: { apiKey: process.env.GEMINI_KEY }, // Free tier available
|
|
2302
|
-
anthropic: { apiKey: process.env.ANTHROPIC_KEY }, // Claude models
|
|
2303
|
-
onnx: { enabled: true }, // Local models via transformers.js
|
|
2304
|
-
},
|
|
2305
|
-
strategy: 'auto', // auto-selects based on constraints below
|
|
2306
|
-
constraints: {
|
|
2307
|
-
maxCostPerQuery: 0.001, // max $0.001 per query
|
|
2308
|
-
minQuality: 0.8, // minimum quality score
|
|
2309
|
-
preferLocal: true, // prefer local models when possible
|
|
2310
|
-
requirePrivacy: false, // if true, only uses local providers
|
|
2311
|
-
},
|
|
2312
|
-
});
|
|
854
|
+
import { BatchOperations } from 'agentdb/optimizations/BatchOperations';
|
|
2313
855
|
|
|
2314
|
-
const
|
|
2315
|
-
|
|
2316
|
-
|
|
856
|
+
const batchOps = new BatchOperations(db, embedder, {
|
|
857
|
+
batchSize: 100, // Process 100 items per batch
|
|
858
|
+
parallelism: 4, // 4 concurrent embedding generations
|
|
859
|
+
progressCallback: (completed, total) => {
|
|
860
|
+
console.log(`Progress: ${completed}/${total}`);
|
|
861
|
+
}
|
|
2317
862
|
});
|
|
2318
|
-
```
|
|
2319
863
|
|
|
2320
|
-
|
|
864
|
+
// Batch create skills (304 → 900 ops/sec = 3x faster)
|
|
865
|
+
const skillIds = await batchOps.insertSkills([
|
|
866
|
+
{ name: 'skill-1', description: 'First skill', successRate: 0.8 },
|
|
867
|
+
{ name: 'skill-2', description: 'Second skill', successRate: 0.9 },
|
|
868
|
+
// ... 50 more skills
|
|
869
|
+
]);
|
|
2321
870
|
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
| **Anthropic** | ~1s | $0.003+ | Cloud | Claude Opus, Sonnet, Haiku |
|
|
871
|
+
// Batch store patterns (4x faster than sequential)
|
|
872
|
+
const patternIds = await batchOps.insertPatterns([
|
|
873
|
+
{ taskType: 'debugging', approach: 'Binary search', successRate: 0.85 },
|
|
874
|
+
{ taskType: 'optimization', approach: 'Profile first', successRate: 0.90 },
|
|
875
|
+
// ... 500 patterns
|
|
876
|
+
]);
|
|
2329
877
|
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
//
|
|
2335
|
-
|
|
878
|
+
// Batch store episodes (152 → 500 ops/sec = 3.3x faster)
|
|
879
|
+
const episodeCount = await batchOps.insertEpisodes([
|
|
880
|
+
{ sessionId: 's1', task: 'Task 1', reward: 0.9, success: true },
|
|
881
|
+
{ sessionId: 's1', task: 'Task 2', reward: 0.85, success: true },
|
|
882
|
+
// ... 200 episodes
|
|
883
|
+
]);
|
|
2336
884
|
```
|
|
2337
885
|
|
|
2338
|
-
|
|
886
|
+
**Performance:**
|
|
887
|
+
- Skills: 304 → 900 ops/sec (3x faster)
|
|
888
|
+
- Patterns: 4x faster than sequential
|
|
889
|
+
- Episodes: 152 → 500 ops/sec (3.3x faster)
|
|
890
|
+
- Parallel embedding generation
|
|
891
|
+
- SQL transaction optimization
|
|
2339
892
|
|
|
2340
|
-
|
|
893
|
+
### Intelligent Caching — 8.8x Faster Stats
|
|
2341
894
|
|
|
2342
|
-
|
|
2343
|
-
<summary><strong>Auth & Audit</strong> — JWT, API keys, Argon2id, and compliance-ready logging</summary>
|
|
895
|
+
**TTL-based caching with LRU eviction for frequently accessed data**
|
|
2344
896
|
|
|
2345
|
-
|
|
897
|
+
```typescript
|
|
898
|
+
import { ToolCache, MCPToolCaches } from 'agentdb/optimizations/ToolCache';
|
|
2346
899
|
|
|
2347
|
-
|
|
900
|
+
// Specialized caches for different tool types
|
|
901
|
+
const mcpCaches = new MCPToolCaches();
|
|
902
|
+
// - stats: 60s TTL (agentdb_stats, db_stats)
|
|
903
|
+
// - patterns: 30s TTL (pattern/skill searches)
|
|
904
|
+
// - searches: 15s TTL (episode retrieval)
|
|
905
|
+
// - metrics: 120s TTL (expensive computations)
|
|
2348
906
|
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
const auth = new AuthService(db, {
|
|
2353
|
-
jwtSecret: process.env.JWT_SECRET,
|
|
2354
|
-
accessTokenTTL: '15m',
|
|
2355
|
-
refreshTokenTTL: '7d',
|
|
2356
|
-
maxLoginAttempts: 5, // account lockout after 5 failures
|
|
2357
|
-
lockoutDuration: '30m',
|
|
2358
|
-
});
|
|
907
|
+
// Custom cache
|
|
908
|
+
const customCache = new ToolCache<any>(1000, 60000);
|
|
2359
909
|
|
|
2360
|
-
//
|
|
2361
|
-
|
|
910
|
+
// Set cache entry
|
|
911
|
+
customCache.set('stats:detailed', statsResult, 60000);
|
|
2362
912
|
|
|
2363
|
-
//
|
|
2364
|
-
const
|
|
913
|
+
// Get cached value (returns null if expired)
|
|
914
|
+
const cached = customCache.get('stats:detailed');
|
|
2365
915
|
|
|
2366
|
-
//
|
|
2367
|
-
|
|
916
|
+
// Pattern-based clearing
|
|
917
|
+
customCache.clear('stats:*'); // Clear all stats caches
|
|
2368
918
|
|
|
2369
|
-
//
|
|
2370
|
-
const
|
|
2371
|
-
|
|
919
|
+
// Get cache statistics
|
|
920
|
+
const stats = customCache.getStats();
|
|
921
|
+
console.log(`Hit rate: ${(stats.hitRate * 100).toFixed(1)}%`);
|
|
922
|
+
console.log(`Size: ${stats.size}/${stats.maxSize}`);
|
|
2372
923
|
```
|
|
2373
924
|
|
|
2374
|
-
|
|
925
|
+
**Performance Impact:**
|
|
926
|
+
- agentdb_stats: 176ms → ~20ms (8.8x faster)
|
|
927
|
+
- pattern_stats: Similar improvement
|
|
928
|
+
- learning_metrics: 120s TTL for expensive computations
|
|
929
|
+
- Hit rates: 80%+ for frequently accessed data
|
|
2375
930
|
|
|
2376
|
-
|
|
2377
|
-
|
|
931
|
+
### Data Pruning — Maintain Database Hygiene
|
|
932
|
+
|
|
933
|
+
**Intelligent cleanup preserving causal relationships**
|
|
2378
934
|
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
935
|
+
```typescript
|
|
936
|
+
// Prune old/low-quality data
|
|
937
|
+
const results = await batchOps.pruneData({
|
|
938
|
+
maxAge: 90, // Keep data from last 90 days
|
|
939
|
+
minReward: 0.3, // Keep episodes with reward >= 0.3
|
|
940
|
+
minSuccessRate: 0.5, // Keep skills/patterns with >= 50% success
|
|
941
|
+
maxRecords: 100000, // Max 100k records per table
|
|
942
|
+
dryRun: false // Actually delete (use true to preview)
|
|
2383
943
|
});
|
|
2384
944
|
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
// - rate_limit_exceeded, sensitive_data_access
|
|
2390
|
-
// - data_export, data_deletion
|
|
945
|
+
console.log(`Pruned ${results.episodesPruned} episodes`);
|
|
946
|
+
console.log(`Pruned ${results.skillsPruned} skills`);
|
|
947
|
+
console.log(`Pruned ${results.patternsPruned} patterns`);
|
|
948
|
+
console.log(`Saved ${results.spaceSaved} bytes`);
|
|
2391
949
|
```
|
|
2392
950
|
|
|
2393
|
-
|
|
951
|
+
**Features:**
|
|
952
|
+
- Age-based pruning (default: 90 days)
|
|
953
|
+
- Quality-based pruning (min reward/success rate)
|
|
954
|
+
- Max records enforcement (keeps best performing)
|
|
955
|
+
- Preserves causal relationships (won't delete referenced episodes)
|
|
956
|
+
- Dry-run mode for preview
|
|
957
|
+
- Space reclamation via VACUUM
|
|
2394
958
|
|
|
2395
|
-
|
|
2396
|
-
|
|
959
|
+
**CLI:**
|
|
960
|
+
```bash
|
|
961
|
+
# Preview what would be deleted
|
|
962
|
+
agentdb prune --max-age 90 --min-reward 0.3 --dry-run
|
|
2397
963
|
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
const key = generateApiKey(); // cryptographically random
|
|
964
|
+
# Actually prune
|
|
965
|
+
agentdb prune --max-age 90 --min-reward 0.3 --min-success-rate 0.5 --max-records 100000
|
|
2401
966
|
```
|
|
2402
967
|
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
---
|
|
2406
|
-
|
|
2407
|
-
<details>
|
|
2408
|
-
<summary><strong>Metadata Filtering</strong> — 10 MongoDB-style query operators</summary>
|
|
968
|
+
### Enhanced Validation — Security & Developer Experience
|
|
2409
969
|
|
|
2410
|
-
|
|
970
|
+
**6 new validators with XSS/injection detection**
|
|
2411
971
|
|
|
2412
972
|
```typescript
|
|
2413
|
-
import {
|
|
973
|
+
import {
|
|
974
|
+
validateTaskString,
|
|
975
|
+
validateNumericRange,
|
|
976
|
+
validateArrayLength,
|
|
977
|
+
validateObject,
|
|
978
|
+
validateBoolean,
|
|
979
|
+
validateEnum,
|
|
980
|
+
ValidationError
|
|
981
|
+
} from 'agentdb/security/input-validation';
|
|
2414
982
|
|
|
2415
|
-
|
|
983
|
+
try {
|
|
984
|
+
// String validation (length + XSS detection)
|
|
985
|
+
const task = validateTaskString(userInput, 'task');
|
|
2416
986
|
|
|
2417
|
-
//
|
|
2418
|
-
const
|
|
2419
|
-
reward: { $gt: 0.8 },
|
|
2420
|
-
tags: { $contains: 'security' },
|
|
2421
|
-
status: { $in: ['success', 'partial'] },
|
|
2422
|
-
archived: { $exists: false },
|
|
2423
|
-
});
|
|
987
|
+
// Numeric range validation
|
|
988
|
+
const k = validateNumericRange(kValue, 'k', 1, 100);
|
|
2424
989
|
|
|
2425
|
-
//
|
|
2426
|
-
const
|
|
2427
|
-
successRate: { $gte: 0.7, $lte: 1.0 },
|
|
2428
|
-
taskType: { $ne: 'deprecated' },
|
|
2429
|
-
createdAt: { $gt: lastWeekTimestamp },
|
|
2430
|
-
});
|
|
2431
|
-
```
|
|
990
|
+
// Array length validation
|
|
991
|
+
const items = validateArrayLength(array, 'items', 1, 100);
|
|
2432
992
|
|
|
2433
|
-
|
|
993
|
+
// Enum validation
|
|
994
|
+
const format = validateEnum(formatValue, 'format', ['concise', 'detailed', 'json']);
|
|
2434
995
|
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
| `$in` | In array | `{ type: { $in: ['a', 'b'] } }` |
|
|
2444
|
-
| `$nin` | Not in array | `{ status: { $nin: ['deleted'] } }` |
|
|
2445
|
-
| `$contains` | Contains substring | `{ tags: { $contains: 'auth' } }` |
|
|
2446
|
-
| `$exists` | Field exists | `{ metadata: { $exists: true } }` |
|
|
996
|
+
} catch (error) {
|
|
997
|
+
if (error instanceof ValidationError) {
|
|
998
|
+
console.error(`Validation error: ${error.message}`);
|
|
999
|
+
console.error(`Code: ${error.code}`);
|
|
1000
|
+
console.error(`Field: ${error.field}`);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
```
|
|
2447
1004
|
|
|
2448
|
-
|
|
1005
|
+
**Security Features:**
|
|
1006
|
+
- XSS detection (`<script>`, `javascript:`, `onclick=`)
|
|
1007
|
+
- Injection detection (null bytes, malicious patterns)
|
|
1008
|
+
- Length limits (10k characters max)
|
|
1009
|
+
- Type validation with TypeScript types
|
|
1010
|
+
- Safe error messages (no sensitive data leakage)
|
|
2449
1011
|
|
|
2450
1012
|
---
|
|
2451
1013
|
|
|
2452
|
-
|
|
2453
|
-
<summary><strong>AgentDBFast</strong> — 50-200x faster programmatic API (skip the CLI overhead)</summary>
|
|
1014
|
+
## 🤖 MCP Tools (29 Total)
|
|
2454
1015
|
|
|
2455
|
-
|
|
1016
|
+
AgentDB provides 29 optimized MCP tools for zero-code integration with Claude Code, Cursor, and other AI coding assistants.
|
|
2456
1017
|
|
|
2457
|
-
|
|
2458
|
-
import { createFastAgentDB } from 'agentdb/wrappers/agentdb-fast';
|
|
1018
|
+
### Core Vector DB Tools (5)
|
|
2459
1019
|
|
|
2460
|
-
|
|
2461
|
-
path: './agent-memory.db',
|
|
2462
|
-
dimension: 384,
|
|
2463
|
-
model: 'Xenova/all-MiniLM-L6-v2',
|
|
2464
|
-
});
|
|
1020
|
+
**Basic vector database operations:**
|
|
2465
1021
|
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
1022
|
+
| Tool | Description | Performance |
|
|
1023
|
+
|------|-------------|-------------|
|
|
1024
|
+
| `agentdb_init` | Initialize database with schema | One-time setup |
|
|
1025
|
+
| `agentdb_insert` | Insert single vector | Standard |
|
|
1026
|
+
| `agentdb_insert_batch` | Batch insert (recommended) | 141x faster |
|
|
1027
|
+
| `agentdb_search` | Semantic k-NN search | Optimized |
|
|
1028
|
+
| `agentdb_delete` | Delete vectors by ID/filters | Standard |
|
|
2470
1029
|
|
|
2471
|
-
|
|
2472
|
-
// - Direct function calls (no CLI arg parsing)
|
|
2473
|
-
// - Pre-initialized connections (no startup cost per call)
|
|
2474
|
-
// - Batched operations
|
|
2475
|
-
// - Connection pooling
|
|
2476
|
-
```
|
|
1030
|
+
### Core AgentDB Tools (5 - NEW v2.0)
|
|
2477
1031
|
|
|
2478
|
-
|
|
1032
|
+
**Advanced database management:**
|
|
2479
1033
|
|
|
2480
|
-
|
|
|
2481
|
-
|
|
2482
|
-
|
|
|
2483
|
-
|
|
|
2484
|
-
|
|
|
1034
|
+
| Tool | Description | Performance |
|
|
1035
|
+
|------|-------------|-------------|
|
|
1036
|
+
| `agentdb_stats` | Comprehensive database statistics | 8.8x faster (cached) |
|
|
1037
|
+
| `agentdb_pattern_store` | Store reasoning patterns | 388K ops/sec |
|
|
1038
|
+
| `agentdb_pattern_search` | Search patterns semantically | 32.6M ops/sec |
|
|
1039
|
+
| `agentdb_pattern_stats` | Pattern analytics | Cached |
|
|
1040
|
+
| `agentdb_clear_cache` | Cache management | Instant |
|
|
2485
1041
|
|
|
2486
|
-
###
|
|
1042
|
+
### Frontier Memory Tools (9)
|
|
2487
1043
|
|
|
2488
|
-
|
|
1044
|
+
**Cognitive capabilities:**
|
|
2489
1045
|
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
const result = await flash.forward(query, keys, values);
|
|
2502
|
-
|
|
2503
|
-
// Mixture of Experts — routes to specialized attention heads
|
|
2504
|
-
const moe = new MoEAttention({ numExperts: 4, topK: 2 });
|
|
2505
|
-
const result = await moe.forward(query, keys, values);
|
|
2506
|
-
```
|
|
1046
|
+
| Tool | Description | Use Case |
|
|
1047
|
+
|------|-------------|----------|
|
|
1048
|
+
| `reflexion_store` | Store episode with self-critique | Learn from experience |
|
|
1049
|
+
| `reflexion_retrieve` | Retrieve similar episodes | Episodic replay |
|
|
1050
|
+
| `skill_create` | Create reusable skill | Lifelong learning |
|
|
1051
|
+
| `skill_search` | Search for applicable skills | Skill discovery |
|
|
1052
|
+
| `causal_add_edge` | Add causal relationship | Track causality |
|
|
1053
|
+
| `causal_query` | Query causal effects | Understand interventions |
|
|
1054
|
+
| `recall_with_certificate` | Utility-based retrieval | Explainable AI |
|
|
1055
|
+
| `learner_discover` | Automated pattern discovery | Background learning |
|
|
1056
|
+
| `db_stats` | Database statistics | Monitoring |
|
|
2507
1057
|
|
|
2508
|
-
###
|
|
1058
|
+
### Learning System Tools (10 - NEW v1.3.0)
|
|
2509
1059
|
|
|
2510
|
-
|
|
1060
|
+
**Reinforcement learning pipeline:**
|
|
2511
1061
|
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
1062
|
+
| Tool | Description | Algorithms |
|
|
1063
|
+
|------|-------------|-----------|
|
|
1064
|
+
| `learning_start_session` | Start RL session | 9 algorithms |
|
|
1065
|
+
| `learning_end_session` | End session & save policy | All |
|
|
1066
|
+
| `learning_predict` | Get AI recommendations | All |
|
|
1067
|
+
| `learning_feedback` | Submit action feedback | All |
|
|
1068
|
+
| `learning_train` | Batch policy training | All |
|
|
1069
|
+
| `learning_metrics` | Performance analytics | All |
|
|
1070
|
+
| `learning_transfer` | Transfer learning | All |
|
|
1071
|
+
| `learning_explain` | Explainable AI | All |
|
|
1072
|
+
| `experience_record` | Record tool execution | All |
|
|
1073
|
+
| `reward_signal` | Calculate rewards | All |
|
|
2518
1074
|
|
|
2519
|
-
|
|
2520
|
-
|
|
1075
|
+
**Supported RL Algorithms:**
|
|
1076
|
+
Q-Learning, SARSA, DQN, Policy Gradient, Actor-Critic, PPO, Decision Transformer, MCTS, Model-Based
|
|
2521
1077
|
|
|
2522
|
-
|
|
2523
|
-
const local = new TransformersEmbeddingService({ model: 'Xenova/all-MiniLM-L6-v2' });
|
|
1078
|
+
### MCP Tool Optimization Guide
|
|
2524
1079
|
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
1080
|
+
For comprehensive MCP tool optimization patterns, see:
|
|
1081
|
+
- [MCP Tool Optimization Guide](docs/MCP_TOOL_OPTIMIZATION_GUIDE.md) - 28KB guide with examples
|
|
1082
|
+
- [MCP Optimization Summary](MCP-OPTIMIZATION-SUMMARY.md) - Executive summary
|
|
2528
1083
|
|
|
2529
|
-
|
|
1084
|
+
**Key Optimizations:**
|
|
1085
|
+
- 🔄 Parallel execution markers for 3x speedup
|
|
1086
|
+
- 📦 Batch operations (3-4x faster)
|
|
1087
|
+
- 💾 Intelligent caching (8.8x faster stats)
|
|
1088
|
+
- 📊 Format parameter (60% token reduction)
|
|
1089
|
+
- ✅ Enhanced validation (security + DX)
|
|
2530
1090
|
|
|
2531
1091
|
---
|
|
2532
1092
|
|
|
2533
|
-
|
|
2534
|
-
<summary><strong>Benchmark Suite</strong> — 5 built-in benchmarks with custom benchmark support</summary>
|
|
2535
|
-
|
|
2536
|
-
Run performance benchmarks to validate your deployment:
|
|
1093
|
+
## 📊 Benchmarks & Performance
|
|
2537
1094
|
|
|
2538
|
-
|
|
2539
|
-
import { BenchmarkSuite, runBenchmarks, formatReportAsMarkdown } from 'agentdb';
|
|
2540
|
-
|
|
2541
|
-
// Run all built-in benchmarks
|
|
2542
|
-
const report = await runBenchmarks({
|
|
2543
|
-
dimension: 384,
|
|
2544
|
-
iterations: 100,
|
|
2545
|
-
warmup: 10,
|
|
2546
|
-
});
|
|
1095
|
+
### ReasoningBank Performance
|
|
2547
1096
|
|
|
2548
|
-
console.log(formatReportAsMarkdown(report));
|
|
2549
1097
|
```
|
|
1098
|
+
Pattern Storage Scalability
|
|
1099
|
+
Small (500): 1,475 patterns/sec, 2MB memory
|
|
1100
|
+
Medium (2,000): 3,818 patterns/sec, 0MB memory
|
|
1101
|
+
Large (5,000): 4,536 patterns/sec, 4MB memory
|
|
2550
1102
|
|
|
2551
|
-
|
|
1103
|
+
✨ Super-linear scaling (throughput increases with data size)
|
|
2552
1104
|
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
| **VectorSearchBenchmark** | Search performance | ops/sec, recall@k, latency distribution |
|
|
2557
|
-
| **MemoryUsageBenchmark** | RAM consumption | bytes per vector, total footprint |
|
|
2558
|
-
| **ConcurrencyBenchmark** | Parallel performance | throughput under load, contention |
|
|
2559
|
-
| **QuantizationBenchmark** | Compression tradeoffs | quality loss vs memory savings |
|
|
1105
|
+
Pattern Similarity Detection
|
|
1106
|
+
Threshold 0.5: 12.0 matches, 22.74ms avg search time
|
|
1107
|
+
Threshold 0.7: 10.2 matches, 22.62ms avg search time
|
|
2560
1108
|
|
|
2561
|
-
|
|
1109
|
+
Optimal threshold: 0.5 (best balance)
|
|
2562
1110
|
|
|
2563
|
-
|
|
2564
|
-
|
|
1111
|
+
Query Optimization
|
|
1112
|
+
Simple: 69.31ms
|
|
1113
|
+
Filtered: 15.76ms (4.4x faster)
|
|
1114
|
+
High threshold: 69.09ms
|
|
1115
|
+
Large k=100: 93.03ms
|
|
1116
|
+
```
|
|
2565
1117
|
|
|
2566
|
-
|
|
2567
|
-
name = 'my-custom-benchmark';
|
|
1118
|
+
### Self-Learning Performance
|
|
2568
1119
|
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
1120
|
+
```
|
|
1121
|
+
Adaptive Learning (10 sessions, 50 episodes each)
|
|
1122
|
+
Initial success rate: 54%
|
|
1123
|
+
Final success rate: 90%
|
|
1124
|
+
Improvement: 36%
|
|
1125
|
+
Avg session duration: 170ms
|
|
2573
1126
|
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
1127
|
+
Skill Evolution (3 skills, 5 versions each)
|
|
1128
|
+
Initial avg success: 0.60
|
|
1129
|
+
Final avg success: 0.85
|
|
1130
|
+
Improvement: 25%
|
|
2577
1131
|
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
1132
|
+
Causal Episode Linking
|
|
1133
|
+
5 episodes linked: 22ms
|
|
1134
|
+
Chain depth: 5 steps
|
|
1135
|
+
Causal relationship: Sequential debugging process
|
|
2581
1136
|
```
|
|
2582
1137
|
|
|
2583
|
-
###
|
|
1138
|
+
### MCP Tools Performance
|
|
2584
1139
|
|
|
2585
|
-
```bash
|
|
2586
|
-
npm run benchmark # Quick benchmark
|
|
2587
|
-
npm run benchmark:full # Full suite
|
|
2588
|
-
npm run benchmark:attention # Attention mechanism performance
|
|
2589
|
-
npm run benchmark:backends # Compare all backends
|
|
2590
|
-
npm run benchmark:ruvector # RuVector-specific benchmarks
|
|
2591
|
-
npm run benchmark:all # Everything
|
|
2592
1140
|
```
|
|
1141
|
+
Ultra-Fast (>1M ops/sec)
|
|
1142
|
+
pattern_search: 32.6M ops/sec
|
|
2593
1143
|
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
---
|
|
1144
|
+
Excellent (>100K ops/sec)
|
|
1145
|
+
pattern_store: 388K ops/sec
|
|
2597
1146
|
|
|
2598
|
-
|
|
1147
|
+
Very Good (>500 ops/sec)
|
|
1148
|
+
episode_retrieve: 957 ops/sec
|
|
1149
|
+
skill_search: 694 ops/sec
|
|
2599
1150
|
|
|
2600
|
-
|
|
2601
|
-
|
|
1151
|
+
Good (>100 ops/sec)
|
|
1152
|
+
skill_create: 304 ops/sec → 900 ops/sec (with batch)
|
|
2602
1153
|
|
|
2603
|
-
|
|
1154
|
+
Optimization Targets
|
|
1155
|
+
episode_store: 152 ops/sec → 500 ops/sec (with batch)
|
|
1156
|
+
```
|
|
2604
1157
|
|
|
2605
|
-
###
|
|
1158
|
+
### Memory Efficiency
|
|
2606
1159
|
|
|
2607
|
-
```
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
npm run test:ci # CI pipeline: browser tests + build + bundle verification
|
|
1160
|
+
```
|
|
1161
|
+
5,000 patterns: 4MB memory (0.8KB per pattern)
|
|
1162
|
+
Consistent low latency: 0.22-0.68ms per pattern
|
|
1163
|
+
Super-linear scaling: performance improves with data size
|
|
2612
1164
|
```
|
|
2613
1165
|
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
| Suite | Coverage | What it validates |
|
|
2617
|
-
| --- | --- | --- |
|
|
2618
|
-
| **Unit tests** | Core controllers, memory patterns, embedding service, quantization | All 6 cognitive memory patterns, 9 RL algorithms, filter expressions, security validators |
|
|
2619
|
-
| **Browser tests** | WASM store, attention mechanisms, product quantization, SIMD fallbacks | Full vector DB in browser, Flash/Hyperbolic/MoE attention, PQ8/PQ16/PQ32 compression |
|
|
2620
|
-
| **Integration tests** | End-to-end flows, backend auto-selection, MCP tool execution | Self-learning pipeline, Cognitive Container operations, federated aggregation |
|
|
2621
|
-
| **Performance tests** | Latency benchmarks, throughput, scaling behavior | 61us search target, 32.6M ops/sec pattern search, batch insert speedup |
|
|
2622
|
-
| **Security tests** | Input validation, injection prevention, witness chain verification | XSS patterns, SQL injection, path traversal, Cypher sanitization, SHAKE-256 |
|
|
1166
|
+
See [OPTIMIZATION-REPORT.md](OPTIMIZATION-REPORT.md) for comprehensive benchmarks.
|
|
2623
1167
|
|
|
2624
|
-
|
|
1168
|
+
---
|
|
2625
1169
|
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
1170
|
+
## 🏗️ Architecture
|
|
1171
|
+
|
|
1172
|
+
### Multi-Backend System
|
|
1173
|
+
|
|
1174
|
+
```
|
|
1175
|
+
┌─────────────────────────────────────────────────────────┐
|
|
1176
|
+
│ AgentDB v2.0 Core │
|
|
1177
|
+
├─────────────────────────────────────────────────────────┤
|
|
1178
|
+
│ Frontier Memory: │
|
|
1179
|
+
│ • ReasoningBank • Reflexion Memory │
|
|
1180
|
+
│ • Skill Library • Causal Memory Graph │
|
|
1181
|
+
│ • Causal Recall • Nightly Learner │
|
|
1182
|
+
├─────────────────────────────────────────────────────────┤
|
|
1183
|
+
│ Optimizations: │
|
|
1184
|
+
│ • BatchOperations • ToolCache (LRU + TTL) │
|
|
1185
|
+
│ • Enhanced Validation │
|
|
1186
|
+
├─────────────────────────────────────────────────────────┤
|
|
1187
|
+
│ Backend Auto-Selection (fastest → most compatible): │
|
|
1188
|
+
│ RuVector → HNSWLib → better-sqlite3 → sql.js (WASM) │
|
|
1189
|
+
└─────────────────────────────────────────────────────────┘
|
|
1190
|
+
↓ ↓ ↓
|
|
1191
|
+
┌─────────────────┐ ┌─────────────────┐ ┌──────────────┐
|
|
1192
|
+
│ RuVector │ │ HNSWLib │ │ SQLite │
|
|
1193
|
+
│ Rust + SIMD │ │ C++ HNSW │ │ better-sql3 │
|
|
1194
|
+
│ 150x faster │ │ 100x faster │ │ Native Node │
|
|
1195
|
+
│ (optional) │ │ (optional) │ │ (optional) │
|
|
1196
|
+
└─────────────────┘ └─────────────────┘ └──────────────┘
|
|
1197
|
+
↓
|
|
1198
|
+
┌──────────────┐
|
|
1199
|
+
│ sql.js WASM │
|
|
1200
|
+
│ Default │
|
|
1201
|
+
│ Zero deps │
|
|
1202
|
+
└──────────────┘
|
|
1203
|
+
```
|
|
1204
|
+
|
|
1205
|
+
### Data Flow
|
|
1206
|
+
|
|
1207
|
+
```
|
|
1208
|
+
User Input
|
|
1209
|
+
↓
|
|
1210
|
+
Input Validation (XSS/injection detection)
|
|
1211
|
+
↓
|
|
1212
|
+
ToolCache Check (LRU + TTL)
|
|
1213
|
+
├── Cache Hit → Return cached result (8.8x faster)
|
|
1214
|
+
└── Cache Miss → Continue
|
|
1215
|
+
↓
|
|
1216
|
+
Embedding Service
|
|
1217
|
+
(Transformers.js or mock)
|
|
1218
|
+
↓
|
|
1219
|
+
Vector Backend
|
|
1220
|
+
(Auto-selected: RuVector → HNSWLib → SQLite)
|
|
1221
|
+
↓
|
|
1222
|
+
Frontier Memory Layer
|
|
1223
|
+
(ReasoningBank, Reflexion, Skills, Causal)
|
|
1224
|
+
↓
|
|
1225
|
+
Result + Provenance Certificate
|
|
1226
|
+
↓
|
|
1227
|
+
Cache Result (with TTL)
|
|
1228
|
+
↓
|
|
1229
|
+
Return to User
|
|
2633
1230
|
```
|
|
2634
1231
|
|
|
2635
|
-
|
|
1232
|
+
---
|
|
2636
1233
|
|
|
2637
|
-
|
|
2638
|
-
1. **Browser bundle tests** — verifies WASM and JS fallbacks work
|
|
2639
|
-
2. **TypeScript build** — full `tsc` compilation
|
|
2640
|
-
3. **Bundle verification** — ensures all export paths resolve correctly
|
|
1234
|
+
## 🧪 Testing
|
|
2641
1235
|
|
|
2642
|
-
|
|
1236
|
+
AgentDB v2 includes comprehensive test coverage:
|
|
2643
1237
|
|
|
2644
|
-
```
|
|
2645
|
-
|
|
2646
|
-
|
|
1238
|
+
```bash
|
|
1239
|
+
# Run all tests
|
|
1240
|
+
npm test
|
|
1241
|
+
|
|
1242
|
+
# Run specific test suites
|
|
1243
|
+
npm run test:unit # Unit tests
|
|
1244
|
+
npm run test:integration # Integration tests
|
|
1245
|
+
npm run test:performance # Performance benchmarks
|
|
1246
|
+
npm run test:security # Security validation
|
|
1247
|
+
|
|
1248
|
+
# Docker validation (full CI/CD)
|
|
1249
|
+
npm run docker:build # 9-stage Docker build
|
|
1250
|
+
npm run docker:test # Run tests in container
|
|
1251
|
+
```
|
|
1252
|
+
|
|
1253
|
+
**Test Coverage:**
|
|
1254
|
+
- ✅ Core vector operations
|
|
1255
|
+
- ✅ Frontier memory features
|
|
1256
|
+
- ✅ Batch operations
|
|
1257
|
+
- ✅ Caching mechanisms
|
|
1258
|
+
- ✅ Input validation
|
|
1259
|
+
- ✅ MCP tool handlers
|
|
1260
|
+
- ✅ Security (XSS, injection)
|
|
1261
|
+
- ✅ Performance benchmarks
|
|
1262
|
+
- ✅ Backwards compatibility
|
|
2647
1263
|
|
|
2648
|
-
|
|
2649
|
-
it('stores and retrieves patterns', async () => {
|
|
2650
|
-
const db = await createDatabase(':memory:');
|
|
2651
|
-
const embedder = new EmbeddingService({ model: 'Xenova/all-MiniLM-L6-v2' });
|
|
2652
|
-
await embedder.initialize();
|
|
1264
|
+
---
|
|
2653
1265
|
|
|
2654
|
-
|
|
2655
|
-
await bank.storePattern({ taskType: 'test', approach: 'TDD', successRate: 0.95 });
|
|
1266
|
+
## 📚 Documentation
|
|
2656
1267
|
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
1268
|
+
**Core Documentation:**
|
|
1269
|
+
- [MCP Tool Optimization Guide](docs/MCP_TOOL_OPTIMIZATION_GUIDE.md) - Comprehensive optimization patterns (28KB)
|
|
1270
|
+
- [Deep Review v2.0 - Latent Space](docs/DEEP-REVIEW-V2-LATENT-SPACE.md) - Complete validation report (59 CLI commands, 32 MCP tools, zero regressions)
|
|
1271
|
+
- [MCP Tools Reference](docs/MCP_TOOLS.md) - All 32 tools documented
|
|
1272
|
+
- [Optimization Report](OPTIMIZATION-REPORT.md) - v2.0 performance benchmarks
|
|
1273
|
+
- [Optimization Summary](MCP-OPTIMIZATION-SUMMARY.md) - Executive summary
|
|
1274
|
+
- [Migration Guide v1.3.0](MIGRATION_v1.3.0.md) - Upgrade from v1.2.2
|
|
2662
1275
|
|
|
2663
|
-
|
|
1276
|
+
**Simulation Documentation:**
|
|
1277
|
+
- [Simulation System](simulation/README.md) - Complete simulation framework (25 scenarios, 848 lines)
|
|
1278
|
+
- [Wizard Guide](simulation/docs/guides/WIZARD-GUIDE.md) - Interactive CLI configuration
|
|
1279
|
+
- [Documentation Index](simulation/docs/DOCUMENTATION-INDEX.md) - 60+ guides organized by category
|
|
2664
1280
|
|
|
2665
1281
|
---
|
|
2666
1282
|
|
|
2667
|
-
##
|
|
1283
|
+
## 🤝 Contributing
|
|
1284
|
+
|
|
1285
|
+
We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
2668
1286
|
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
| [Chat Ecosystem](../agentdb-chat/README.md) | `@agentdb/chat` integration guide |
|
|
2676
|
-
| [ADR-010: Solver Integration](docs/adrs/ADR-010-rvf-solver-v014-deep-integration.md) | SolverBandit + rvf-solver deep integration |
|
|
1287
|
+
**Areas of Interest:**
|
|
1288
|
+
- Additional RL algorithms
|
|
1289
|
+
- Performance optimizations
|
|
1290
|
+
- New backend integrations
|
|
1291
|
+
- Documentation improvements
|
|
1292
|
+
- Test coverage expansion
|
|
2677
1293
|
|
|
2678
1294
|
---
|
|
2679
1295
|
|
|
2680
|
-
##
|
|
1296
|
+
## 📝 License
|
|
2681
1297
|
|
|
2682
|
-
|
|
1298
|
+
MIT OR Apache-2.0
|
|
1299
|
+
|
|
1300
|
+
See [LICENSE-MIT](LICENSE-MIT) and [LICENSE-APACHE](LICENSE-APACHE) for details.
|
|
2683
1301
|
|
|
2684
1302
|
---
|
|
2685
1303
|
|
|
2686
|
-
##
|
|
1304
|
+
## 🙏 Acknowledgments
|
|
2687
1305
|
|
|
2688
|
-
|
|
1306
|
+
AgentDB v2 builds on research from:
|
|
1307
|
+
- **RuVector** - Native Rust vector database with SIMD optimization (150x faster, 8.2x vs hnswlib)
|
|
1308
|
+
- **Latent Space Research** - Empirical validation of optimal HNSW configurations, GNN attention, self-healing MPC
|
|
1309
|
+
- **Reflexion** (Shinn et al., 2023) - Self-critique and episodic replay
|
|
1310
|
+
- **Causal Inference** (Pearl, Judea) - Intervention-based causality
|
|
1311
|
+
- **Decision Transformer** (Chen et al., 2021) - Offline RL
|
|
1312
|
+
- **HNSW** (Malkov & Yashunin, 2018) - Approximate nearest neighbor search
|
|
1313
|
+
- **Graph Neural Networks** - 8-head attention mechanism for navigation (+12.4% recall)
|
|
1314
|
+
- **Anthropic** - Advanced tool use patterns and MCP protocol
|
|
2689
1315
|
|
|
2690
1316
|
---
|
|
2691
1317
|
|
|
2692
|
-
|
|
1318
|
+
## 📊 Project Status
|
|
2693
1319
|
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
1320
|
+
**Version:** 3.0.0-alpha.1
|
|
1321
|
+
**Status:** Alpha Testing (Early Adopters)
|
|
1322
|
+
**MCP Tools:** 32 (optimized with latent space research)
|
|
1323
|
+
**CLI Commands:** 59 (including simulation suite)
|
|
1324
|
+
**Controllers:** 21 active (all wired with proof-gated vectorBackend)
|
|
1325
|
+
**Graph Modules:** 8 (via @ruvector/graph-transformer)
|
|
1326
|
+
**Performance:** 150x faster (RuVector), 8.2x faster than hnswlib
|
|
1327
|
+
**Proof Engine:** native (NAPI-RS) -> wasm -> JS fallback
|
|
1328
|
+
**Last Updated:** 2026-02-25
|
|
1329
|
+
|
|
1330
|
+
[Get Started](#-quick-start-60-seconds) | [Documentation](./docs/) | [GitHub](https://github.com/ruvnet/agentic-flow/tree/main/packages/agentdb) | [npm](https://www.npmjs.com/package/agentdb)
|
|
1331
|
+
|
|
1332
|
+
---
|
|
2697
1333
|
|
|
2698
|
-
|
|
1334
|
+
**Built with ❤️ for the agentic era**
|