agentdb 1.6.0 → 2.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1098 -350
- package/dist/agentdb-advanced.js +2110 -0
- package/dist/agentdb-advanced.min.js +1 -0
- package/dist/agentdb.min.js +4 -4
- package/dist/backends/GraphBackend.d.ts +196 -0
- package/dist/backends/GraphBackend.d.ts.map +1 -0
- package/dist/backends/GraphBackend.js +33 -0
- package/dist/backends/GraphBackend.js.map +1 -0
- package/dist/backends/LearningBackend.d.ts +148 -0
- package/dist/backends/LearningBackend.d.ts.map +1 -0
- package/dist/backends/LearningBackend.js +27 -0
- package/dist/backends/LearningBackend.js.map +1 -0
- package/dist/backends/VectorBackend.d.ts +119 -0
- package/dist/backends/VectorBackend.d.ts.map +1 -0
- package/dist/backends/VectorBackend.js +14 -0
- package/dist/backends/VectorBackend.js.map +1 -0
- package/dist/backends/detector.d.ts +81 -0
- package/dist/backends/detector.d.ts.map +1 -0
- package/dist/backends/detector.js +192 -0
- package/dist/backends/detector.js.map +1 -0
- package/dist/backends/factory.d.ts +50 -0
- package/dist/backends/factory.d.ts.map +1 -0
- package/dist/backends/factory.js +161 -0
- package/dist/backends/factory.js.map +1 -0
- package/dist/backends/graph/GraphDatabaseAdapter.d.ts +139 -0
- package/dist/backends/graph/GraphDatabaseAdapter.d.ts.map +1 -0
- package/dist/backends/graph/GraphDatabaseAdapter.js +194 -0
- package/dist/backends/graph/GraphDatabaseAdapter.js.map +1 -0
- package/dist/backends/hnswlib/HNSWLibBackend.d.ts +92 -0
- package/dist/backends/hnswlib/HNSWLibBackend.d.ts.map +1 -0
- package/dist/backends/hnswlib/HNSWLibBackend.js +316 -0
- package/dist/backends/hnswlib/HNSWLibBackend.js.map +1 -0
- package/dist/backends/hnswlib/index.d.ts +7 -0
- package/dist/backends/hnswlib/index.d.ts.map +1 -0
- package/dist/backends/hnswlib/index.js +7 -0
- package/dist/backends/hnswlib/index.js.map +1 -0
- package/dist/backends/index.d.ts +14 -0
- package/dist/backends/index.d.ts.map +1 -0
- package/dist/backends/index.js +13 -0
- package/dist/backends/index.js.map +1 -0
- package/dist/backends/ruvector/RuVectorBackend.d.ts +75 -0
- package/dist/backends/ruvector/RuVectorBackend.d.ts.map +1 -0
- package/dist/backends/ruvector/RuVectorBackend.js +198 -0
- package/dist/backends/ruvector/RuVectorBackend.js.map +1 -0
- package/dist/backends/ruvector/RuVectorLearning.d.ts +104 -0
- package/dist/backends/ruvector/RuVectorLearning.d.ts.map +1 -0
- package/dist/backends/ruvector/RuVectorLearning.js +177 -0
- package/dist/backends/ruvector/RuVectorLearning.js.map +1 -0
- package/dist/backends/ruvector/index.d.ts +9 -0
- package/dist/backends/ruvector/index.d.ts.map +1 -0
- package/dist/backends/ruvector/index.js +8 -0
- package/dist/backends/ruvector/index.js.map +1 -0
- package/dist/browser/AdvancedFeatures.d.ts +144 -0
- package/dist/browser/AdvancedFeatures.d.ts.map +1 -0
- package/dist/browser/AdvancedFeatures.js +430 -0
- package/dist/browser/AdvancedFeatures.js.map +1 -0
- package/dist/browser/HNSWIndex.d.ts +117 -0
- package/dist/browser/HNSWIndex.d.ts.map +1 -0
- package/dist/browser/HNSWIndex.js +402 -0
- package/dist/browser/HNSWIndex.js.map +1 -0
- package/dist/browser/ProductQuantization.d.ts +107 -0
- package/dist/browser/ProductQuantization.d.ts.map +1 -0
- package/dist/browser/ProductQuantization.js +337 -0
- package/dist/browser/ProductQuantization.js.map +1 -0
- package/dist/browser/browser/AdvancedFeatures.d.ts +144 -0
- package/dist/browser/browser/AdvancedFeatures.d.ts.map +1 -0
- package/dist/browser/browser/AdvancedFeatures.js +427 -0
- package/dist/browser/browser/HNSWIndex.d.ts +117 -0
- package/dist/browser/browser/HNSWIndex.d.ts.map +1 -0
- package/dist/browser/browser/HNSWIndex.js +402 -0
- package/dist/browser/browser/ProductQuantization.d.ts +107 -0
- package/dist/browser/browser/ProductQuantization.d.ts.map +1 -0
- package/dist/browser/browser/ProductQuantization.js +348 -0
- package/dist/browser/browser/index.d.ts +223 -0
- package/dist/browser/browser/index.d.ts.map +1 -0
- package/dist/browser/browser/index.js +233 -0
- package/dist/browser/index.d.ts +223 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +225 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/cli/agentdb-cli.d.ts.map +1 -1
- package/dist/cli/agentdb-cli.js +130 -8
- package/dist/cli/agentdb-cli.js.map +1 -1
- package/dist/cli/agentdb.db +0 -0
- package/dist/cli/commands/init.d.ts +12 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +115 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/install-embeddings.d.ts +10 -0
- package/dist/cli/commands/install-embeddings.d.ts.map +1 -0
- package/dist/cli/commands/install-embeddings.js +68 -0
- package/dist/cli/commands/install-embeddings.js.map +1 -0
- package/dist/cli/commands/migrate.d.ts +15 -0
- package/dist/cli/commands/migrate.d.ts.map +1 -0
- package/dist/cli/commands/migrate.js +425 -0
- package/dist/cli/commands/migrate.js.map +1 -0
- package/dist/cli/commands/status.d.ts +10 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +129 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/controllers/CausalRecall.d.ts +3 -1
- package/dist/controllers/CausalRecall.d.ts.map +1 -1
- package/dist/controllers/CausalRecall.js +35 -4
- package/dist/controllers/CausalRecall.js.map +1 -1
- package/dist/controllers/ExplainableRecall.d.ts +24 -0
- package/dist/controllers/ExplainableRecall.d.ts.map +1 -1
- package/dist/controllers/ExplainableRecall.js +102 -5
- package/dist/controllers/ExplainableRecall.js.map +1 -1
- package/dist/controllers/HNSWIndex.d.ts +128 -0
- package/dist/controllers/HNSWIndex.d.ts.map +1 -0
- package/dist/controllers/HNSWIndex.js +361 -0
- package/dist/controllers/HNSWIndex.js.map +1 -0
- package/dist/controllers/NightlyLearner.d.ts.map +1 -1
- package/dist/controllers/NightlyLearner.js +7 -4
- package/dist/controllers/NightlyLearner.js.map +1 -1
- package/dist/controllers/ReasoningBank.d.ts +101 -2
- package/dist/controllers/ReasoningBank.d.ts.map +1 -1
- package/dist/controllers/ReasoningBank.js +196 -4
- package/dist/controllers/ReasoningBank.js.map +1 -1
- package/dist/controllers/ReflexionMemory.d.ts +41 -1
- package/dist/controllers/ReflexionMemory.d.ts.map +1 -1
- package/dist/controllers/ReflexionMemory.js +282 -5
- package/dist/controllers/ReflexionMemory.js.map +1 -1
- package/dist/controllers/SkillLibrary.d.ts +27 -9
- package/dist/controllers/SkillLibrary.d.ts.map +1 -1
- package/dist/controllers/SkillLibrary.js +136 -47
- package/dist/controllers/SkillLibrary.js.map +1 -1
- package/dist/controllers/index.d.ts +2 -0
- package/dist/controllers/index.d.ts.map +1 -1
- package/dist/controllers/index.js +1 -0
- package/dist/controllers/index.js.map +1 -1
- package/dist/db-fallback.d.ts.map +1 -1
- package/dist/db-fallback.js +100 -29
- package/dist/db-fallback.js.map +1 -1
- package/dist/db-test.d.ts +13 -0
- package/dist/db-test.d.ts.map +1 -0
- package/dist/db-test.js +55 -0
- package/dist/db-test.js.map +1 -0
- package/dist/db-unified.d.ts +76 -0
- package/dist/db-unified.d.ts.map +1 -0
- package/dist/db-unified.js +278 -0
- package/dist/db-unified.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/malp/core/ccc.d.ts +99 -0
- package/dist/malp/core/ccc.d.ts.map +1 -0
- package/dist/malp/core/ccc.js +181 -0
- package/dist/malp/core/ccc.js.map +1 -0
- package/dist/malp/core/index.d.ts +9 -0
- package/dist/malp/core/index.d.ts.map +1 -0
- package/dist/malp/core/index.js +9 -0
- package/dist/malp/core/index.js.map +1 -0
- package/dist/malp/core/linalg.d.ts +101 -0
- package/dist/malp/core/linalg.d.ts.map +1 -0
- package/dist/malp/core/linalg.js +278 -0
- package/dist/malp/core/linalg.js.map +1 -0
- package/dist/malp/core/optimizer.d.ts +68 -0
- package/dist/malp/core/optimizer.d.ts.map +1 -0
- package/dist/malp/core/optimizer.js +160 -0
- package/dist/malp/core/optimizer.js.map +1 -0
- package/dist/malp/index.d.ts +33 -0
- package/dist/malp/index.d.ts.map +1 -0
- package/dist/malp/index.js +37 -0
- package/dist/malp/index.js.map +1 -0
- package/dist/malp/metrics/agreement.d.ts +106 -0
- package/dist/malp/metrics/agreement.d.ts.map +1 -0
- package/dist/malp/metrics/agreement.js +199 -0
- package/dist/malp/metrics/agreement.js.map +1 -0
- package/dist/malp/metrics/comparison.d.ts +93 -0
- package/dist/malp/metrics/comparison.d.ts.map +1 -0
- package/dist/malp/metrics/comparison.js +256 -0
- package/dist/malp/metrics/comparison.js.map +1 -0
- package/dist/malp/metrics/index.d.ts +8 -0
- package/dist/malp/metrics/index.d.ts.map +1 -0
- package/dist/malp/metrics/index.js +8 -0
- package/dist/malp/metrics/index.js.map +1 -0
- package/dist/malp/metrics/performance.d.ts +61 -0
- package/dist/malp/metrics/performance.d.ts.map +1 -0
- package/dist/malp/metrics/performance.js +190 -0
- package/dist/malp/metrics/performance.js.map +1 -0
- package/dist/malp/models/index.d.ts +7 -0
- package/dist/malp/models/index.d.ts.map +1 -0
- package/dist/malp/models/index.js +7 -0
- package/dist/malp/models/index.js.map +1 -0
- package/dist/malp/models/malp.d.ts +116 -0
- package/dist/malp/models/malp.d.ts.map +1 -0
- package/dist/malp/models/malp.js +206 -0
- package/dist/malp/models/malp.js.map +1 -0
- package/dist/malp/models/regressor.d.ts +80 -0
- package/dist/malp/models/regressor.d.ts.map +1 -0
- package/dist/malp/models/regressor.js +229 -0
- package/dist/malp/models/regressor.js.map +1 -0
- package/dist/malp/reasoningbank_validator.d.ts +187 -0
- package/dist/malp/reasoningbank_validator.d.ts.map +1 -0
- package/dist/malp/reasoningbank_validator.js +246 -0
- package/dist/malp/reasoningbank_validator.js.map +1 -0
- package/dist/malp/wasm_bindings.d.ts +344 -0
- package/dist/malp/wasm_bindings.d.ts.map +1 -0
- package/dist/malp/wasm_bindings.js +9 -0
- package/dist/malp/wasm_bindings.js.map +1 -0
- package/dist/mcp/agentdb-mcp-server.js +512 -33
- package/dist/mcp/agentdb-mcp-server.js.map +1 -1
- package/dist/optimizations/BatchOperations.d.ts +42 -0
- package/dist/optimizations/BatchOperations.d.ts.map +1 -1
- package/dist/optimizations/BatchOperations.js +181 -0
- package/dist/optimizations/BatchOperations.js.map +1 -1
- package/dist/optimizations/ToolCache.d.ts +137 -0
- package/dist/optimizations/ToolCache.d.ts.map +1 -0
- package/dist/optimizations/ToolCache.js +281 -0
- package/dist/optimizations/ToolCache.js.map +1 -0
- package/dist/security/input-validation.d.ts +24 -0
- package/dist/security/input-validation.d.ts.map +1 -1
- package/dist/security/input-validation.js +106 -0
- package/dist/security/input-validation.js.map +1 -1
- package/dist/security/limits.d.ts +150 -0
- package/dist/security/limits.d.ts.map +1 -0
- package/dist/security/limits.js +288 -0
- package/dist/security/limits.js.map +1 -0
- package/dist/security/path-security.d.ts +100 -0
- package/dist/security/path-security.d.ts.map +1 -0
- package/dist/security/path-security.js +337 -0
- package/dist/security/path-security.js.map +1 -0
- package/dist/security/validation.d.ts +95 -0
- package/dist/security/validation.d.ts.map +1 -0
- package/dist/security/validation.js +315 -0
- package/dist/security/validation.js.map +1 -0
- package/dist/simulation/cli.d.ts +9 -0
- package/dist/simulation/cli.d.ts.map +1 -0
- package/dist/simulation/cli.js +68 -0
- package/dist/simulation/cli.js.map +1 -0
- package/dist/simulation/runner.d.ts +21 -0
- package/dist/simulation/runner.d.ts.map +1 -0
- package/dist/simulation/runner.js +241 -0
- package/dist/simulation/runner.js.map +1 -0
- package/dist/simulation/scenarios/aidefence-integration.d.ts +24 -0
- package/dist/simulation/scenarios/aidefence-integration.d.ts.map +1 -0
- package/dist/simulation/scenarios/aidefence-integration.js +124 -0
- package/dist/simulation/scenarios/aidefence-integration.js.map +1 -0
- package/dist/simulation/scenarios/bmssp-integration.d.ts +23 -0
- package/dist/simulation/scenarios/bmssp-integration.d.ts.map +1 -0
- package/dist/simulation/scenarios/bmssp-integration.js +104 -0
- package/dist/simulation/scenarios/bmssp-integration.js.map +1 -0
- package/dist/simulation/scenarios/causal-reasoning.d.ts +16 -0
- package/dist/simulation/scenarios/causal-reasoning.d.ts.map +1 -0
- package/dist/simulation/scenarios/causal-reasoning.js +108 -0
- package/dist/simulation/scenarios/causal-reasoning.js.map +1 -0
- package/dist/simulation/scenarios/consciousness-explorer.d.ts +25 -0
- package/dist/simulation/scenarios/consciousness-explorer.d.ts.map +1 -0
- package/dist/simulation/scenarios/consciousness-explorer.js +108 -0
- package/dist/simulation/scenarios/consciousness-explorer.js.map +1 -0
- package/dist/simulation/scenarios/domain-examples/e-commerce-recommendations.d.ts +135 -0
- package/dist/simulation/scenarios/domain-examples/e-commerce-recommendations.d.ts.map +1 -0
- package/dist/simulation/scenarios/domain-examples/e-commerce-recommendations.js +158 -0
- package/dist/simulation/scenarios/domain-examples/e-commerce-recommendations.js.map +1 -0
- package/dist/simulation/scenarios/domain-examples/index.d.ts +14 -0
- package/dist/simulation/scenarios/domain-examples/index.d.ts.map +1 -0
- package/dist/simulation/scenarios/domain-examples/index.js +14 -0
- package/dist/simulation/scenarios/domain-examples/index.js.map +1 -0
- package/dist/simulation/scenarios/domain-examples/iot-sensor-networks.d.ts +178 -0
- package/dist/simulation/scenarios/domain-examples/iot-sensor-networks.d.ts.map +1 -0
- package/dist/simulation/scenarios/domain-examples/iot-sensor-networks.js +218 -0
- package/dist/simulation/scenarios/domain-examples/iot-sensor-networks.js.map +1 -0
- package/dist/simulation/scenarios/domain-examples/medical-imaging.d.ts +122 -0
- package/dist/simulation/scenarios/domain-examples/medical-imaging.d.ts.map +1 -0
- package/dist/simulation/scenarios/domain-examples/medical-imaging.js +129 -0
- package/dist/simulation/scenarios/domain-examples/medical-imaging.js.map +1 -0
- package/dist/simulation/scenarios/domain-examples/robotics-navigation.d.ts +166 -0
- package/dist/simulation/scenarios/domain-examples/robotics-navigation.d.ts.map +1 -0
- package/dist/simulation/scenarios/domain-examples/robotics-navigation.js +161 -0
- package/dist/simulation/scenarios/domain-examples/robotics-navigation.js.map +1 -0
- package/dist/simulation/scenarios/domain-examples/scientific-research.d.ts +151 -0
- package/dist/simulation/scenarios/domain-examples/scientific-research.d.ts.map +1 -0
- package/dist/simulation/scenarios/domain-examples/scientific-research.js +187 -0
- package/dist/simulation/scenarios/domain-examples/scientific-research.js.map +1 -0
- package/dist/simulation/scenarios/domain-examples/trading-systems.d.ts +102 -0
- package/dist/simulation/scenarios/domain-examples/trading-systems.d.ts.map +1 -0
- package/dist/simulation/scenarios/domain-examples/trading-systems.js +100 -0
- package/dist/simulation/scenarios/domain-examples/trading-systems.js.map +1 -0
- package/dist/simulation/scenarios/goalie-integration.d.ts +24 -0
- package/dist/simulation/scenarios/goalie-integration.d.ts.map +1 -0
- package/dist/simulation/scenarios/goalie-integration.js +121 -0
- package/dist/simulation/scenarios/goalie-integration.js.map +1 -0
- package/dist/simulation/scenarios/graph-traversal.d.ts +17 -0
- package/dist/simulation/scenarios/graph-traversal.d.ts.map +1 -0
- package/dist/simulation/scenarios/graph-traversal.js +101 -0
- package/dist/simulation/scenarios/graph-traversal.js.map +1 -0
- package/dist/simulation/scenarios/latent-space/attention-analysis.d.ts +45 -0
- package/dist/simulation/scenarios/latent-space/attention-analysis.d.ts.map +1 -0
- package/dist/simulation/scenarios/latent-space/attention-analysis.js +435 -0
- package/dist/simulation/scenarios/latent-space/attention-analysis.js.map +1 -0
- package/dist/simulation/scenarios/latent-space/clustering-analysis.d.ts +55 -0
- package/dist/simulation/scenarios/latent-space/clustering-analysis.d.ts.map +1 -0
- package/dist/simulation/scenarios/latent-space/clustering-analysis.js +606 -0
- package/dist/simulation/scenarios/latent-space/clustering-analysis.js.map +1 -0
- package/dist/simulation/scenarios/latent-space/hnsw-exploration.d.ts +74 -0
- package/dist/simulation/scenarios/latent-space/hnsw-exploration.d.ts.map +1 -0
- package/dist/simulation/scenarios/latent-space/hnsw-exploration.js +391 -0
- package/dist/simulation/scenarios/latent-space/hnsw-exploration.js.map +1 -0
- package/dist/simulation/scenarios/latent-space/hypergraph-exploration.d.ts +51 -0
- package/dist/simulation/scenarios/latent-space/hypergraph-exploration.d.ts.map +1 -0
- package/dist/simulation/scenarios/latent-space/hypergraph-exploration.js +536 -0
- package/dist/simulation/scenarios/latent-space/hypergraph-exploration.js.map +1 -0
- package/dist/simulation/scenarios/latent-space/index.d.ts +35 -0
- package/dist/simulation/scenarios/latent-space/index.d.ts.map +1 -0
- package/dist/simulation/scenarios/latent-space/index.js +35 -0
- package/dist/simulation/scenarios/latent-space/index.js.map +1 -0
- package/dist/simulation/scenarios/latent-space/neural-augmentation.d.ts +52 -0
- package/dist/simulation/scenarios/latent-space/neural-augmentation.d.ts.map +1 -0
- package/dist/simulation/scenarios/latent-space/neural-augmentation.js +472 -0
- package/dist/simulation/scenarios/latent-space/neural-augmentation.js.map +1 -0
- package/dist/simulation/scenarios/latent-space/quantum-hybrid.d.ts +53 -0
- package/dist/simulation/scenarios/latent-space/quantum-hybrid.d.ts.map +1 -0
- package/dist/simulation/scenarios/latent-space/quantum-hybrid.js +391 -0
- package/dist/simulation/scenarios/latent-space/quantum-hybrid.js.map +1 -0
- package/dist/simulation/scenarios/latent-space/self-organizing-hnsw.d.ts +52 -0
- package/dist/simulation/scenarios/latent-space/self-organizing-hnsw.d.ts.map +1 -0
- package/dist/simulation/scenarios/latent-space/self-organizing-hnsw.js +514 -0
- package/dist/simulation/scenarios/latent-space/self-organizing-hnsw.js.map +1 -0
- package/dist/simulation/scenarios/latent-space/traversal-optimization.d.ts +53 -0
- package/dist/simulation/scenarios/latent-space/traversal-optimization.d.ts.map +1 -0
- package/dist/simulation/scenarios/latent-space/traversal-optimization.js +595 -0
- package/dist/simulation/scenarios/latent-space/traversal-optimization.js.map +1 -0
- package/dist/simulation/scenarios/lean-agentic-swarm.d.ts +18 -0
- package/dist/simulation/scenarios/lean-agentic-swarm.d.ts.map +1 -0
- package/dist/simulation/scenarios/lean-agentic-swarm.js +132 -0
- package/dist/simulation/scenarios/lean-agentic-swarm.js.map +1 -0
- package/dist/simulation/scenarios/multi-agent-swarm.d.ts +17 -0
- package/dist/simulation/scenarios/multi-agent-swarm.d.ts.map +1 -0
- package/dist/simulation/scenarios/multi-agent-swarm.js +111 -0
- package/dist/simulation/scenarios/multi-agent-swarm.js.map +1 -0
- package/dist/simulation/scenarios/psycho-symbolic-reasoner.d.ts +23 -0
- package/dist/simulation/scenarios/psycho-symbolic-reasoner.d.ts.map +1 -0
- package/dist/simulation/scenarios/psycho-symbolic-reasoner.js +98 -0
- package/dist/simulation/scenarios/psycho-symbolic-reasoner.js.map +1 -0
- package/dist/simulation/scenarios/reflexion-learning.d.ts +16 -0
- package/dist/simulation/scenarios/reflexion-learning.d.ts.map +1 -0
- package/dist/simulation/scenarios/reflexion-learning.js +98 -0
- package/dist/simulation/scenarios/reflexion-learning.js.map +1 -0
- package/dist/simulation/scenarios/research-swarm.d.ts +24 -0
- package/dist/simulation/scenarios/research-swarm.d.ts.map +1 -0
- package/dist/simulation/scenarios/research-swarm.js +146 -0
- package/dist/simulation/scenarios/research-swarm.js.map +1 -0
- package/dist/simulation/scenarios/skill-evolution.d.ts +16 -0
- package/dist/simulation/scenarios/skill-evolution.d.ts.map +1 -0
- package/dist/simulation/scenarios/skill-evolution.js +109 -0
- package/dist/simulation/scenarios/skill-evolution.js.map +1 -0
- package/dist/simulation/scenarios/stock-market-emergence.d.ts +33 -0
- package/dist/simulation/scenarios/stock-market-emergence.d.ts.map +1 -0
- package/dist/simulation/scenarios/stock-market-emergence.js +246 -0
- package/dist/simulation/scenarios/stock-market-emergence.js.map +1 -0
- package/dist/simulation/scenarios/strange-loops.d.ts +18 -0
- package/dist/simulation/scenarios/strange-loops.d.ts.map +1 -0
- package/dist/simulation/scenarios/strange-loops.js +133 -0
- package/dist/simulation/scenarios/strange-loops.js.map +1 -0
- package/dist/simulation/scenarios/sublinear-solver.d.ts +22 -0
- package/dist/simulation/scenarios/sublinear-solver.d.ts.map +1 -0
- package/dist/simulation/scenarios/sublinear-solver.js +82 -0
- package/dist/simulation/scenarios/sublinear-solver.js.map +1 -0
- package/dist/simulation/scenarios/temporal-lead-solver.d.ts +23 -0
- package/dist/simulation/scenarios/temporal-lead-solver.d.ts.map +1 -0
- package/dist/simulation/scenarios/temporal-lead-solver.js +90 -0
- package/dist/simulation/scenarios/temporal-lead-solver.js.map +1 -0
- package/dist/simulation/scenarios/voting-system-consensus.d.ts +27 -0
- package/dist/simulation/scenarios/voting-system-consensus.d.ts.map +1 -0
- package/dist/simulation/scenarios/voting-system-consensus.js +175 -0
- package/dist/simulation/scenarios/voting-system-consensus.js.map +1 -0
- package/dist/simulation/types.d.ts +162 -0
- package/dist/simulation/types.d.ts.map +1 -0
- package/dist/simulation/types.js +5 -0
- package/dist/simulation/types.js.map +1 -0
- package/dist/simulation/utils/PerformanceOptimizer.d.ts +115 -0
- package/dist/simulation/utils/PerformanceOptimizer.d.ts.map +1 -0
- package/dist/simulation/utils/PerformanceOptimizer.js +223 -0
- package/dist/simulation/utils/PerformanceOptimizer.js.map +1 -0
- package/dist/src/backends/GraphBackend.d.ts +196 -0
- package/dist/src/backends/GraphBackend.d.ts.map +1 -0
- package/dist/src/backends/GraphBackend.js +33 -0
- package/dist/src/backends/GraphBackend.js.map +1 -0
- package/dist/src/backends/LearningBackend.d.ts +148 -0
- package/dist/src/backends/LearningBackend.d.ts.map +1 -0
- package/dist/src/backends/LearningBackend.js +27 -0
- package/dist/src/backends/LearningBackend.js.map +1 -0
- package/dist/src/backends/VectorBackend.d.ts +119 -0
- package/dist/src/backends/VectorBackend.d.ts.map +1 -0
- package/dist/src/backends/VectorBackend.js +14 -0
- package/dist/src/backends/VectorBackend.js.map +1 -0
- package/dist/src/backends/detector.d.ts +81 -0
- package/dist/src/backends/detector.d.ts.map +1 -0
- package/dist/src/backends/detector.js +192 -0
- package/dist/src/backends/detector.js.map +1 -0
- package/dist/src/backends/factory.d.ts +50 -0
- package/dist/src/backends/factory.d.ts.map +1 -0
- package/dist/src/backends/factory.js +161 -0
- package/dist/src/backends/factory.js.map +1 -0
- package/dist/src/backends/graph/GraphDatabaseAdapter.d.ts +151 -0
- package/dist/src/backends/graph/GraphDatabaseAdapter.d.ts.map +1 -0
- package/dist/src/backends/graph/GraphDatabaseAdapter.js +224 -0
- package/dist/src/backends/graph/GraphDatabaseAdapter.js.map +1 -0
- package/dist/src/backends/hnswlib/HNSWLibBackend.d.ts +92 -0
- package/dist/src/backends/hnswlib/HNSWLibBackend.d.ts.map +1 -0
- package/dist/src/backends/hnswlib/HNSWLibBackend.js +316 -0
- package/dist/src/backends/hnswlib/HNSWLibBackend.js.map +1 -0
- package/dist/src/backends/hnswlib/index.d.ts +7 -0
- package/dist/src/backends/hnswlib/index.d.ts.map +1 -0
- package/dist/src/backends/hnswlib/index.js +7 -0
- package/dist/src/backends/hnswlib/index.js.map +1 -0
- package/dist/src/backends/index.d.ts +14 -0
- package/dist/src/backends/index.d.ts.map +1 -0
- package/dist/src/backends/index.js +13 -0
- package/dist/src/backends/index.js.map +1 -0
- package/dist/src/backends/ruvector/RuVectorBackend.d.ts +75 -0
- package/dist/src/backends/ruvector/RuVectorBackend.d.ts.map +1 -0
- package/dist/src/backends/ruvector/RuVectorBackend.js +198 -0
- package/dist/src/backends/ruvector/RuVectorBackend.js.map +1 -0
- package/dist/src/backends/ruvector/RuVectorLearning.d.ts +104 -0
- package/dist/src/backends/ruvector/RuVectorLearning.d.ts.map +1 -0
- package/dist/src/backends/ruvector/RuVectorLearning.js +177 -0
- package/dist/src/backends/ruvector/RuVectorLearning.js.map +1 -0
- package/dist/src/backends/ruvector/index.d.ts +9 -0
- package/dist/src/backends/ruvector/index.d.ts.map +1 -0
- package/dist/src/backends/ruvector/index.js +8 -0
- package/dist/src/backends/ruvector/index.js.map +1 -0
- package/dist/src/benchmarks/wasm-vector-benchmark.d.ts +10 -0
- package/dist/src/benchmarks/wasm-vector-benchmark.d.ts.map +1 -0
- package/dist/src/benchmarks/wasm-vector-benchmark.js +196 -0
- package/dist/src/benchmarks/wasm-vector-benchmark.js.map +1 -0
- package/dist/src/browser/AdvancedFeatures.d.ts +144 -0
- package/dist/src/browser/AdvancedFeatures.d.ts.map +1 -0
- package/dist/src/browser/AdvancedFeatures.js +430 -0
- package/dist/src/browser/AdvancedFeatures.js.map +1 -0
- package/dist/src/browser/HNSWIndex.d.ts +117 -0
- package/dist/src/browser/HNSWIndex.d.ts.map +1 -0
- package/dist/src/browser/HNSWIndex.js +402 -0
- package/dist/src/browser/HNSWIndex.js.map +1 -0
- package/dist/src/browser/ProductQuantization.d.ts +107 -0
- package/dist/src/browser/ProductQuantization.d.ts.map +1 -0
- package/dist/src/browser/ProductQuantization.js +337 -0
- package/dist/src/browser/ProductQuantization.js.map +1 -0
- package/dist/src/browser/index.d.ts +223 -0
- package/dist/src/browser/index.d.ts.map +1 -0
- package/dist/src/browser/index.js +225 -0
- package/dist/src/browser/index.js.map +1 -0
- package/dist/src/cli/agentdb-cli.d.ts +154 -0
- package/dist/src/cli/agentdb-cli.d.ts.map +1 -0
- package/dist/src/cli/agentdb-cli.js +2273 -0
- package/dist/src/cli/agentdb-cli.js.map +1 -0
- package/dist/src/cli/commands/init.d.ts +12 -0
- package/dist/src/cli/commands/init.d.ts.map +1 -0
- package/dist/src/cli/commands/init.js +115 -0
- package/dist/src/cli/commands/init.js.map +1 -0
- package/dist/src/cli/commands/install-embeddings.d.ts +10 -0
- package/dist/src/cli/commands/install-embeddings.d.ts.map +1 -0
- package/dist/src/cli/commands/install-embeddings.js +68 -0
- package/dist/src/cli/commands/install-embeddings.js.map +1 -0
- package/dist/src/cli/commands/migrate.d.ts +15 -0
- package/dist/src/cli/commands/migrate.d.ts.map +1 -0
- package/dist/src/cli/commands/migrate.js +425 -0
- package/dist/src/cli/commands/migrate.js.map +1 -0
- package/dist/src/cli/commands/simulate-custom.d.ts +26 -0
- package/dist/src/cli/commands/simulate-custom.d.ts.map +1 -0
- package/dist/src/cli/commands/simulate-custom.js +207 -0
- package/dist/src/cli/commands/simulate-custom.js.map +1 -0
- package/dist/src/cli/commands/simulate-report.d.ts +15 -0
- package/dist/src/cli/commands/simulate-report.d.ts.map +1 -0
- package/dist/src/cli/commands/simulate-report.js +136 -0
- package/dist/src/cli/commands/simulate-report.js.map +1 -0
- package/dist/src/cli/commands/simulate-wizard.d.ts +6 -0
- package/dist/src/cli/commands/simulate-wizard.d.ts.map +1 -0
- package/dist/src/cli/commands/simulate-wizard.js +352 -0
- package/dist/src/cli/commands/simulate-wizard.js.map +1 -0
- package/dist/src/cli/commands/simulate.d.ts +7 -0
- package/dist/src/cli/commands/simulate.d.ts.map +1 -0
- package/dist/src/cli/commands/simulate.js +100 -0
- package/dist/src/cli/commands/simulate.js.map +1 -0
- package/dist/src/cli/commands/status.d.ts +10 -0
- package/dist/src/cli/commands/status.d.ts.map +1 -0
- package/dist/src/cli/commands/status.js +129 -0
- package/dist/src/cli/commands/status.js.map +1 -0
- package/dist/src/cli/lib/config-manager.d.ts +110 -0
- package/dist/src/cli/lib/config-manager.d.ts.map +1 -0
- package/dist/src/cli/lib/config-manager.js +512 -0
- package/dist/src/cli/lib/config-manager.js.map +1 -0
- package/dist/src/cli/lib/config-validator.d.ts +43 -0
- package/dist/src/cli/lib/config-validator.d.ts.map +1 -0
- package/dist/src/cli/lib/config-validator.js +217 -0
- package/dist/src/cli/lib/config-validator.js.map +1 -0
- package/dist/src/cli/lib/health-monitor.d.ts +149 -0
- package/dist/src/cli/lib/health-monitor.d.ts.map +1 -0
- package/dist/src/cli/lib/health-monitor.js +380 -0
- package/dist/src/cli/lib/health-monitor.js.map +1 -0
- package/dist/src/cli/lib/help-formatter.d.ts +38 -0
- package/dist/src/cli/lib/help-formatter.d.ts.map +1 -0
- package/dist/src/cli/lib/help-formatter.js +357 -0
- package/dist/src/cli/lib/help-formatter.js.map +1 -0
- package/dist/src/cli/lib/history-tracker.d.ts +103 -0
- package/dist/src/cli/lib/history-tracker.d.ts.map +1 -0
- package/dist/src/cli/lib/history-tracker.js +346 -0
- package/dist/src/cli/lib/history-tracker.js.map +1 -0
- package/dist/src/cli/lib/report-generator.d.ts +24 -0
- package/dist/src/cli/lib/report-generator.d.ts.map +1 -0
- package/dist/src/cli/lib/report-generator.js +417 -0
- package/dist/src/cli/lib/report-generator.js.map +1 -0
- package/dist/src/cli/lib/report-store.d.ts +116 -0
- package/dist/src/cli/lib/report-store.d.ts.map +1 -0
- package/dist/src/cli/lib/report-store.js +464 -0
- package/dist/src/cli/lib/report-store.js.map +1 -0
- package/dist/src/cli/lib/simulation-registry.d.ts +165 -0
- package/dist/src/cli/lib/simulation-registry.d.ts.map +1 -0
- package/dist/src/cli/lib/simulation-registry.js +332 -0
- package/dist/src/cli/lib/simulation-registry.js.map +1 -0
- package/dist/src/cli/lib/simulation-runner.d.ts +90 -0
- package/dist/src/cli/lib/simulation-runner.d.ts.map +1 -0
- package/dist/src/cli/lib/simulation-runner.js +211 -0
- package/dist/src/cli/lib/simulation-runner.js.map +1 -0
- package/dist/src/controllers/CausalMemoryGraph.d.ts +127 -0
- package/dist/src/controllers/CausalMemoryGraph.d.ts.map +1 -0
- package/dist/src/controllers/CausalMemoryGraph.js +354 -0
- package/dist/src/controllers/CausalMemoryGraph.js.map +1 -0
- package/dist/src/controllers/CausalRecall.d.ts +139 -0
- package/dist/src/controllers/CausalRecall.d.ts.map +1 -0
- package/dist/src/controllers/CausalRecall.js +356 -0
- package/dist/src/controllers/CausalRecall.js.map +1 -0
- package/dist/src/controllers/ContextSynthesizer.d.ts +65 -0
- package/dist/src/controllers/ContextSynthesizer.d.ts.map +1 -0
- package/dist/src/controllers/ContextSynthesizer.js +208 -0
- package/dist/src/controllers/ContextSynthesizer.js.map +1 -0
- package/dist/src/controllers/EmbeddingService.d.ts +37 -0
- package/dist/src/controllers/EmbeddingService.d.ts.map +1 -0
- package/dist/src/controllers/EmbeddingService.js +136 -0
- package/dist/src/controllers/EmbeddingService.js.map +1 -0
- package/dist/src/controllers/EnhancedEmbeddingService.d.ts +50 -0
- package/dist/src/controllers/EnhancedEmbeddingService.d.ts.map +1 -0
- package/dist/src/controllers/EnhancedEmbeddingService.js +119 -0
- package/dist/src/controllers/EnhancedEmbeddingService.js.map +1 -0
- package/dist/src/controllers/ExplainableRecall.d.ts +163 -0
- package/dist/src/controllers/ExplainableRecall.d.ts.map +1 -0
- package/dist/src/controllers/ExplainableRecall.js +485 -0
- package/dist/src/controllers/ExplainableRecall.js.map +1 -0
- package/dist/src/controllers/HNSWIndex.d.ts +128 -0
- package/dist/src/controllers/HNSWIndex.d.ts.map +1 -0
- package/dist/src/controllers/HNSWIndex.js +361 -0
- package/dist/src/controllers/HNSWIndex.js.map +1 -0
- package/dist/src/controllers/LearningSystem.d.ts +195 -0
- package/dist/src/controllers/LearningSystem.d.ts.map +1 -0
- package/dist/src/controllers/LearningSystem.js +929 -0
- package/dist/src/controllers/LearningSystem.js.map +1 -0
- package/dist/src/controllers/MMRDiversityRanker.d.ts +50 -0
- package/dist/src/controllers/MMRDiversityRanker.d.ts.map +1 -0
- package/dist/src/controllers/MMRDiversityRanker.js +130 -0
- package/dist/src/controllers/MMRDiversityRanker.js.map +1 -0
- package/dist/src/controllers/MetadataFilter.d.ts +70 -0
- package/dist/src/controllers/MetadataFilter.d.ts.map +1 -0
- package/dist/src/controllers/MetadataFilter.js +243 -0
- package/dist/src/controllers/MetadataFilter.js.map +1 -0
- package/dist/src/controllers/NightlyLearner.d.ts +114 -0
- package/dist/src/controllers/NightlyLearner.d.ts.map +1 -0
- package/dist/src/controllers/NightlyLearner.js +394 -0
- package/dist/src/controllers/NightlyLearner.js.map +1 -0
- package/dist/src/controllers/QUICClient.d.ts +109 -0
- package/dist/src/controllers/QUICClient.d.ts.map +1 -0
- package/dist/src/controllers/QUICClient.js +299 -0
- package/dist/src/controllers/QUICClient.js.map +1 -0
- package/dist/src/controllers/QUICServer.d.ts +121 -0
- package/dist/src/controllers/QUICServer.d.ts.map +1 -0
- package/dist/src/controllers/QUICServer.js +383 -0
- package/dist/src/controllers/QUICServer.js.map +1 -0
- package/dist/src/controllers/ReasoningBank.d.ts +196 -0
- package/dist/src/controllers/ReasoningBank.d.ts.map +1 -0
- package/dist/src/controllers/ReasoningBank.js +494 -0
- package/dist/src/controllers/ReasoningBank.js.map +1 -0
- package/dist/src/controllers/ReflexionMemory.d.ts +125 -0
- package/dist/src/controllers/ReflexionMemory.d.ts.map +1 -0
- package/dist/src/controllers/ReflexionMemory.js +654 -0
- package/dist/src/controllers/ReflexionMemory.js.map +1 -0
- package/dist/src/controllers/SkillLibrary.d.ts +150 -0
- package/dist/src/controllers/SkillLibrary.d.ts.map +1 -0
- package/dist/src/controllers/SkillLibrary.js +608 -0
- package/dist/src/controllers/SkillLibrary.js.map +1 -0
- package/dist/src/controllers/SyncCoordinator.d.ts +120 -0
- package/dist/src/controllers/SyncCoordinator.d.ts.map +1 -0
- package/dist/src/controllers/SyncCoordinator.js +441 -0
- package/dist/src/controllers/SyncCoordinator.js.map +1 -0
- package/dist/src/controllers/WASMVectorSearch.d.ts +89 -0
- package/dist/src/controllers/WASMVectorSearch.d.ts.map +1 -0
- package/dist/src/controllers/WASMVectorSearch.js +234 -0
- package/dist/src/controllers/WASMVectorSearch.js.map +1 -0
- package/dist/src/controllers/frontier-index.d.ts +14 -0
- package/dist/src/controllers/frontier-index.d.ts.map +1 -0
- package/dist/src/controllers/frontier-index.js +10 -0
- package/dist/src/controllers/frontier-index.js.map +1 -0
- package/dist/src/controllers/index.d.ts +30 -0
- package/dist/src/controllers/index.d.ts.map +1 -0
- package/dist/src/controllers/index.js +18 -0
- package/dist/src/controllers/index.js.map +1 -0
- package/dist/src/db-fallback.d.ts +26 -0
- package/dist/src/db-fallback.d.ts.map +1 -0
- package/dist/src/db-fallback.js +264 -0
- package/dist/src/db-fallback.js.map +1 -0
- package/dist/src/db-test.d.ts +13 -0
- package/dist/src/db-test.d.ts.map +1 -0
- package/dist/src/db-test.js +55 -0
- package/dist/src/db-test.js.map +1 -0
- package/dist/src/db-unified.d.ts +76 -0
- package/dist/src/db-unified.d.ts.map +1 -0
- package/dist/src/db-unified.js +279 -0
- package/dist/src/db-unified.js.map +1 -0
- package/dist/src/examples/quic-sync-example.d.ts +9 -0
- package/dist/src/examples/quic-sync-example.d.ts.map +1 -0
- package/dist/src/examples/quic-sync-example.js +169 -0
- package/dist/src/examples/quic-sync-example.js.map +1 -0
- package/dist/src/examples/wasm-vector-usage.d.ts +12 -0
- package/dist/src/examples/wasm-vector-usage.d.ts.map +1 -0
- package/dist/src/examples/wasm-vector-usage.js +190 -0
- package/dist/src/examples/wasm-vector-usage.js.map +1 -0
- package/dist/src/index.d.ts +28 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +35 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/mcp/agentdb-mcp-server.d.ts +8 -0
- package/dist/src/mcp/agentdb-mcp-server.d.ts.map +1 -0
- package/dist/src/mcp/agentdb-mcp-server.js +2116 -0
- package/dist/src/mcp/agentdb-mcp-server.js.map +1 -0
- package/dist/src/mcp/learning-tools-handlers.d.ts +16 -0
- package/dist/src/mcp/learning-tools-handlers.d.ts.map +1 -0
- package/dist/src/mcp/learning-tools-handlers.js +105 -0
- package/dist/src/mcp/learning-tools-handlers.js.map +1 -0
- package/dist/src/optimizations/BatchOperations.d.ts +109 -0
- package/dist/src/optimizations/BatchOperations.d.ts.map +1 -0
- package/dist/src/optimizations/BatchOperations.js +407 -0
- package/dist/src/optimizations/BatchOperations.js.map +1 -0
- package/dist/src/optimizations/QueryOptimizer.d.ts +83 -0
- package/dist/src/optimizations/QueryOptimizer.d.ts.map +1 -0
- package/dist/src/optimizations/QueryOptimizer.js +228 -0
- package/dist/src/optimizations/QueryOptimizer.js.map +1 -0
- package/dist/src/optimizations/ToolCache.d.ts +137 -0
- package/dist/src/optimizations/ToolCache.d.ts.map +1 -0
- package/dist/src/optimizations/ToolCache.js +281 -0
- package/dist/src/optimizations/ToolCache.js.map +1 -0
- package/dist/src/optimizations/index.d.ts +10 -0
- package/dist/src/optimizations/index.d.ts.map +1 -0
- package/dist/src/optimizations/index.js +8 -0
- package/dist/src/optimizations/index.js.map +1 -0
- package/dist/src/security/input-validation.d.ts +109 -0
- package/dist/src/security/input-validation.d.ts.map +1 -0
- package/dist/src/security/input-validation.js +398 -0
- package/dist/src/security/input-validation.js.map +1 -0
- package/dist/src/security/limits.d.ts +150 -0
- package/dist/src/security/limits.d.ts.map +1 -0
- package/dist/src/security/limits.js +288 -0
- package/dist/src/security/limits.js.map +1 -0
- package/dist/src/security/path-security.d.ts +100 -0
- package/dist/src/security/path-security.d.ts.map +1 -0
- package/dist/src/security/path-security.js +337 -0
- package/dist/src/security/path-security.js.map +1 -0
- package/dist/src/security/validation.d.ts +95 -0
- package/dist/src/security/validation.d.ts.map +1 -0
- package/dist/src/security/validation.js +315 -0
- package/dist/src/security/validation.js.map +1 -0
- package/dist/src/services/LLMRouter.d.ts +84 -0
- package/dist/src/services/LLMRouter.d.ts.map +1 -0
- package/dist/src/services/LLMRouter.js +329 -0
- package/dist/src/services/LLMRouter.js.map +1 -0
- package/dist/src/types/quic.d.ts +518 -0
- package/dist/src/types/quic.d.ts.map +1 -0
- package/dist/src/types/quic.js +272 -0
- package/dist/src/types/quic.js.map +1 -0
- package/dist/src/utils/NodeIdMapper.d.ts +38 -0
- package/dist/src/utils/NodeIdMapper.d.ts.map +1 -0
- package/dist/src/utils/NodeIdMapper.js +57 -0
- package/dist/src/utils/NodeIdMapper.js.map +1 -0
- package/package.json +15 -3
- package/scripts/README.md +314 -0
- package/src/backends/GraphBackend.ts +290 -0
- package/src/backends/LearningBackend.ts +210 -0
- package/src/backends/README.md +389 -0
- package/src/backends/VectorBackend.ts +145 -0
- package/src/backends/detector.ts +283 -0
- package/src/backends/factory.ts +193 -0
- package/src/backends/graph/GraphDatabaseAdapter.ts +334 -0
- package/src/backends/hnswlib/HNSWLibBackend.ts +413 -0
- package/src/backends/hnswlib/index.ts +7 -0
- package/src/backends/index.ts +32 -0
- package/src/backends/ruvector/RuVectorBackend.ts +232 -0
- package/src/backends/ruvector/RuVectorLearning.ts +242 -0
- package/src/backends/ruvector/index.ts +9 -0
- package/src/backends/ruvector/types.d.ts +64 -0
- package/src/browser/AdvancedFeatures.ts +565 -0
- package/src/browser/HNSWIndex.ts +494 -0
- package/src/browser/ProductQuantization.ts +419 -0
- package/src/browser/index.ts +301 -0
- package/src/cli/agentdb-cli.ts +131 -8
- package/src/cli/commands/init.ts +148 -0
- package/src/cli/commands/install-embeddings.ts +81 -0
- package/src/cli/commands/migrate.ts +545 -0
- package/src/cli/commands/simulate-custom.ts +232 -0
- package/src/cli/commands/simulate-report.ts +171 -0
- package/src/cli/commands/simulate-wizard.ts +379 -0
- package/src/cli/commands/simulate.ts +115 -0
- package/src/cli/commands/status.ts +156 -0
- package/src/cli/lib/config-manager.ts +627 -0
- package/src/cli/lib/config-validator.ts +261 -0
- package/src/cli/lib/health-monitor.ts +513 -0
- package/src/cli/lib/help-formatter.ts +406 -0
- package/src/cli/lib/history-tracker.ts +497 -0
- package/src/cli/lib/report-generator.ts +455 -0
- package/src/cli/lib/report-store.ts +582 -0
- package/src/cli/lib/simulation-registry.ts +502 -0
- package/src/cli/lib/simulation-runner.ts +291 -0
- package/src/cli/tests/agentdb-cli.test.ts +58 -0
- package/src/controllers/CausalMemoryGraph.ts +42 -2
- package/src/controllers/CausalRecall.ts +41 -4
- package/src/controllers/ExplainableRecall.ts +123 -5
- package/src/controllers/HNSWIndex.ts +495 -0
- package/src/controllers/NightlyLearner.ts +8 -4
- package/src/controllers/ReasoningBank.ts +268 -5
- package/src/controllers/ReflexionMemory.ts +531 -6
- package/src/controllers/SkillLibrary.ts +234 -60
- package/src/controllers/index.ts +2 -0
- package/src/db-fallback.ts +103 -35
- package/src/db-test.ts +59 -0
- package/src/db-unified.ts +327 -0
- package/src/index.ts +2 -1
- package/src/mcp/agentdb-mcp-server.ts +544 -38
- package/src/optimizations/BatchOperations.ts +270 -0
- package/src/optimizations/ToolCache.ts +355 -0
- package/src/security/input-validation.ts +166 -0
- package/src/security/limits.ts +375 -0
- package/src/security/path-security.ts +436 -0
- package/src/security/validation.ts +556 -0
- package/src/services/LLMRouter.ts +406 -0
- package/src/types/xenova-transformers.d.ts +26 -0
- package/src/utils/NodeIdMapper.ts +64 -0
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product Quantization for Browser
|
|
3
|
+
*
|
|
4
|
+
* Compresses high-dimensional vectors using product quantization.
|
|
5
|
+
* Achieves 4-32x memory reduction with minimal accuracy loss.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - PQ8: 8 subvectors, 256 centroids each (4x compression)
|
|
9
|
+
* - PQ16: 16 subvectors, 256 centroids each (8x compression)
|
|
10
|
+
* - Asymmetric distance computation (ADC)
|
|
11
|
+
* - K-means clustering for codebook training
|
|
12
|
+
*
|
|
13
|
+
* Performance:
|
|
14
|
+
* - Memory: Float32 (4 bytes) → uint8 (1 byte) per subvector
|
|
15
|
+
* - Speed: ~1.5x slower search vs uncompressed
|
|
16
|
+
* - Accuracy: 95-99% recall@10
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export interface PQConfig {
|
|
20
|
+
dimension: number;
|
|
21
|
+
numSubvectors: number; // 8, 16, 32, or 64
|
|
22
|
+
numCentroids: number; // Usually 256 (uint8)
|
|
23
|
+
maxIterations?: number; // K-means iterations
|
|
24
|
+
convergenceThreshold?: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface PQCodebook {
|
|
28
|
+
subvectorDim: number;
|
|
29
|
+
numSubvectors: number;
|
|
30
|
+
numCentroids: number;
|
|
31
|
+
centroids: Float32Array[]; // [numSubvectors][numCentroids][subvectorDim]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface CompressedVector {
|
|
35
|
+
codes: Uint8Array; // [numSubvectors] - indices into centroids
|
|
36
|
+
norm: number; // Original vector norm (for normalization)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export class ProductQuantization {
|
|
40
|
+
private config: Required<PQConfig>;
|
|
41
|
+
private codebook: PQCodebook | null = null;
|
|
42
|
+
private trained = false;
|
|
43
|
+
|
|
44
|
+
constructor(config: PQConfig) {
|
|
45
|
+
this.config = {
|
|
46
|
+
dimension: config.dimension,
|
|
47
|
+
numSubvectors: config.numSubvectors,
|
|
48
|
+
numCentroids: config.numCentroids,
|
|
49
|
+
maxIterations: config.maxIterations || 50,
|
|
50
|
+
convergenceThreshold: config.convergenceThreshold || 1e-4
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// Validate config
|
|
54
|
+
if (this.config.dimension % this.config.numSubvectors !== 0) {
|
|
55
|
+
throw new Error(`Dimension ${this.config.dimension} must be divisible by numSubvectors ${this.config.numSubvectors}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Train codebook using k-means on training vectors
|
|
61
|
+
*/
|
|
62
|
+
async train(vectors: Float32Array[]): Promise<void> {
|
|
63
|
+
if (vectors.length === 0) {
|
|
64
|
+
throw new Error('Training requires at least one vector');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const subvectorDim = this.config.dimension / this.config.numSubvectors;
|
|
68
|
+
const centroids: Float32Array[] = [];
|
|
69
|
+
|
|
70
|
+
console.log(`[PQ] Training ${this.config.numSubvectors} subvectors with ${this.config.numCentroids} centroids each...`);
|
|
71
|
+
|
|
72
|
+
// Train each subvector independently
|
|
73
|
+
for (let s = 0; s < this.config.numSubvectors; s++) {
|
|
74
|
+
const startDim = s * subvectorDim;
|
|
75
|
+
const endDim = startDim + subvectorDim;
|
|
76
|
+
|
|
77
|
+
// Extract subvectors
|
|
78
|
+
const subvectors = vectors.map(v => v.slice(startDim, endDim));
|
|
79
|
+
|
|
80
|
+
// Run k-means
|
|
81
|
+
const subCentroids = await this.kMeans(subvectors, this.config.numCentroids);
|
|
82
|
+
centroids.push(...subCentroids);
|
|
83
|
+
|
|
84
|
+
if ((s + 1) % 4 === 0 || s === this.config.numSubvectors - 1) {
|
|
85
|
+
console.log(`[PQ] Trained ${s + 1}/${this.config.numSubvectors} subvectors`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
this.codebook = {
|
|
90
|
+
subvectorDim,
|
|
91
|
+
numSubvectors: this.config.numSubvectors,
|
|
92
|
+
numCentroids: this.config.numCentroids,
|
|
93
|
+
centroids
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
this.trained = true;
|
|
97
|
+
console.log('[PQ] Training complete');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* K-means clustering for centroids
|
|
102
|
+
*/
|
|
103
|
+
private async kMeans(vectors: Float32Array[], k: number): Promise<Float32Array[]> {
|
|
104
|
+
const dim = vectors[0].length;
|
|
105
|
+
const n = vectors.length;
|
|
106
|
+
|
|
107
|
+
// Initialize centroids with k-means++
|
|
108
|
+
const centroids = this.kMeansPlusPlus(vectors, k);
|
|
109
|
+
const assignments = new Uint32Array(n);
|
|
110
|
+
let prevInertia = Infinity;
|
|
111
|
+
|
|
112
|
+
for (let iter = 0; iter < this.config.maxIterations; iter++) {
|
|
113
|
+
// Assign vectors to nearest centroid
|
|
114
|
+
let inertia = 0;
|
|
115
|
+
for (let i = 0; i < n; i++) {
|
|
116
|
+
let minDist = Infinity;
|
|
117
|
+
let minIdx = 0;
|
|
118
|
+
|
|
119
|
+
for (let j = 0; j < k; j++) {
|
|
120
|
+
const dist = this.squaredDistance(vectors[i], centroids[j]);
|
|
121
|
+
if (dist < minDist) {
|
|
122
|
+
minDist = dist;
|
|
123
|
+
minIdx = j;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
assignments[i] = minIdx;
|
|
128
|
+
inertia += minDist;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Check convergence
|
|
132
|
+
if (Math.abs(prevInertia - inertia) < this.config.convergenceThreshold) {
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
prevInertia = inertia;
|
|
136
|
+
|
|
137
|
+
// Update centroids
|
|
138
|
+
const counts = new Uint32Array(k);
|
|
139
|
+
const sums = Array.from({ length: k }, () => new Float32Array(dim));
|
|
140
|
+
|
|
141
|
+
for (let i = 0; i < n; i++) {
|
|
142
|
+
const cluster = assignments[i];
|
|
143
|
+
counts[cluster]++;
|
|
144
|
+
for (let d = 0; d < dim; d++) {
|
|
145
|
+
sums[cluster][d] += vectors[i][d];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
for (let j = 0; j < k; j++) {
|
|
150
|
+
if (counts[j] > 0) {
|
|
151
|
+
for (let d = 0; d < dim; d++) {
|
|
152
|
+
centroids[j][d] = sums[j][d] / counts[j];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return centroids;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* K-means++ initialization for better centroid selection
|
|
163
|
+
*/
|
|
164
|
+
private kMeansPlusPlus(vectors: Float32Array[], k: number): Float32Array[] {
|
|
165
|
+
const n = vectors.length;
|
|
166
|
+
const dim = vectors[0].length;
|
|
167
|
+
const centroids: Float32Array[] = [];
|
|
168
|
+
|
|
169
|
+
// Choose first centroid randomly
|
|
170
|
+
const firstIdx = Math.floor(Math.random() * n);
|
|
171
|
+
centroids.push(new Float32Array(vectors[firstIdx]));
|
|
172
|
+
|
|
173
|
+
// Choose remaining centroids
|
|
174
|
+
for (let i = 1; i < k; i++) {
|
|
175
|
+
const distances = new Float32Array(n);
|
|
176
|
+
let sumDistances = 0;
|
|
177
|
+
|
|
178
|
+
// Calculate distances to nearest centroid
|
|
179
|
+
for (let j = 0; j < n; j++) {
|
|
180
|
+
let minDist = Infinity;
|
|
181
|
+
for (const centroid of centroids) {
|
|
182
|
+
const dist = this.squaredDistance(vectors[j], centroid);
|
|
183
|
+
minDist = Math.min(minDist, dist);
|
|
184
|
+
}
|
|
185
|
+
distances[j] = minDist;
|
|
186
|
+
sumDistances += minDist;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Choose next centroid with probability proportional to distance²
|
|
190
|
+
let r = Math.random() * sumDistances;
|
|
191
|
+
for (let j = 0; j < n; j++) {
|
|
192
|
+
r -= distances[j];
|
|
193
|
+
if (r <= 0) {
|
|
194
|
+
centroids.push(new Float32Array(vectors[j]));
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return centroids;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Compress a vector using trained codebook
|
|
205
|
+
*/
|
|
206
|
+
compress(vector: Float32Array): CompressedVector {
|
|
207
|
+
if (!this.trained || !this.codebook) {
|
|
208
|
+
throw new Error('Codebook must be trained before compression');
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const codes = new Uint8Array(this.config.numSubvectors);
|
|
212
|
+
const subvectorDim = this.codebook.subvectorDim;
|
|
213
|
+
|
|
214
|
+
// Compute norm for later reconstruction
|
|
215
|
+
let norm = 0;
|
|
216
|
+
for (let i = 0; i < vector.length; i++) {
|
|
217
|
+
norm += vector[i] * vector[i];
|
|
218
|
+
}
|
|
219
|
+
norm = Math.sqrt(norm);
|
|
220
|
+
|
|
221
|
+
// Encode each subvector
|
|
222
|
+
for (let s = 0; s < this.config.numSubvectors; s++) {
|
|
223
|
+
const startDim = s * subvectorDim;
|
|
224
|
+
const subvector = vector.slice(startDim, startDim + subvectorDim);
|
|
225
|
+
|
|
226
|
+
// Find nearest centroid
|
|
227
|
+
let minDist = Infinity;
|
|
228
|
+
let minIdx = 0;
|
|
229
|
+
|
|
230
|
+
const centroidOffset = s * this.config.numCentroids;
|
|
231
|
+
for (let c = 0; c < this.config.numCentroids; c++) {
|
|
232
|
+
const centroid = this.codebook.centroids[centroidOffset + c];
|
|
233
|
+
const dist = this.squaredDistance(subvector, centroid);
|
|
234
|
+
if (dist < minDist) {
|
|
235
|
+
minDist = dist;
|
|
236
|
+
minIdx = c;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
codes[s] = minIdx;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return { codes, norm };
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Decompress a vector (approximate reconstruction)
|
|
248
|
+
*/
|
|
249
|
+
decompress(compressed: CompressedVector): Float32Array {
|
|
250
|
+
if (!this.codebook) {
|
|
251
|
+
throw new Error('Codebook not available');
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const vector = new Float32Array(this.config.dimension);
|
|
255
|
+
const subvectorDim = this.codebook.subvectorDim;
|
|
256
|
+
|
|
257
|
+
for (let s = 0; s < this.config.numSubvectors; s++) {
|
|
258
|
+
const code = compressed.codes[s];
|
|
259
|
+
const centroidOffset = s * this.config.numCentroids;
|
|
260
|
+
const centroid = this.codebook.centroids[centroidOffset + code];
|
|
261
|
+
|
|
262
|
+
const startDim = s * subvectorDim;
|
|
263
|
+
for (let d = 0; d < subvectorDim; d++) {
|
|
264
|
+
vector[startDim + d] = centroid[d];
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return vector;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Asymmetric Distance Computation (ADC)
|
|
273
|
+
* Computes distance from query vector to compressed vector
|
|
274
|
+
*/
|
|
275
|
+
asymmetricDistance(query: Float32Array, compressed: CompressedVector): number {
|
|
276
|
+
if (!this.codebook) {
|
|
277
|
+
throw new Error('Codebook not available');
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
let distance = 0;
|
|
281
|
+
const subvectorDim = this.codebook.subvectorDim;
|
|
282
|
+
|
|
283
|
+
for (let s = 0; s < this.config.numSubvectors; s++) {
|
|
284
|
+
const code = compressed.codes[s];
|
|
285
|
+
const centroidOffset = s * this.config.numCentroids;
|
|
286
|
+
const centroid = this.codebook.centroids[centroidOffset + code];
|
|
287
|
+
|
|
288
|
+
const startDim = s * subvectorDim;
|
|
289
|
+
const querySubvector = query.slice(startDim, startDim + subvectorDim);
|
|
290
|
+
|
|
291
|
+
distance += this.squaredDistance(querySubvector, centroid);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return Math.sqrt(distance);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Batch compression for multiple vectors
|
|
299
|
+
*/
|
|
300
|
+
batchCompress(vectors: Float32Array[]): CompressedVector[] {
|
|
301
|
+
return vectors.map(v => this.compress(v));
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Get memory savings
|
|
306
|
+
*/
|
|
307
|
+
getCompressionRatio(): number {
|
|
308
|
+
// Original: dimension * 4 bytes (Float32)
|
|
309
|
+
// Compressed: numSubvectors * 1 byte (Uint8) + 4 bytes (norm)
|
|
310
|
+
const originalBytes = this.config.dimension * 4;
|
|
311
|
+
const compressedBytes = this.config.numSubvectors + 4;
|
|
312
|
+
return originalBytes / compressedBytes;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Export codebook for persistence
|
|
317
|
+
*/
|
|
318
|
+
exportCodebook(): string {
|
|
319
|
+
if (!this.codebook) {
|
|
320
|
+
throw new Error('No codebook to export');
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
return JSON.stringify({
|
|
324
|
+
config: this.config,
|
|
325
|
+
codebook: {
|
|
326
|
+
subvectorDim: this.codebook.subvectorDim,
|
|
327
|
+
numSubvectors: this.codebook.numSubvectors,
|
|
328
|
+
numCentroids: this.codebook.numCentroids,
|
|
329
|
+
centroids: this.codebook.centroids.map(c => Array.from(c))
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Import codebook
|
|
336
|
+
*/
|
|
337
|
+
importCodebook(json: string): void {
|
|
338
|
+
const data = JSON.parse(json);
|
|
339
|
+
this.config = data.config;
|
|
340
|
+
this.codebook = {
|
|
341
|
+
subvectorDim: data.codebook.subvectorDim,
|
|
342
|
+
numSubvectors: data.codebook.numSubvectors,
|
|
343
|
+
numCentroids: data.codebook.numCentroids,
|
|
344
|
+
centroids: data.codebook.centroids.map((c: number[]) => new Float32Array(c))
|
|
345
|
+
};
|
|
346
|
+
this.trained = true;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Utility: Squared Euclidean distance
|
|
351
|
+
*/
|
|
352
|
+
private squaredDistance(a: Float32Array, b: Float32Array): number {
|
|
353
|
+
let sum = 0;
|
|
354
|
+
for (let i = 0; i < a.length; i++) {
|
|
355
|
+
const diff = a[i] - b[i];
|
|
356
|
+
sum += diff * diff;
|
|
357
|
+
}
|
|
358
|
+
return sum;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Get statistics
|
|
363
|
+
*/
|
|
364
|
+
getStats(): {
|
|
365
|
+
trained: boolean;
|
|
366
|
+
compressionRatio: number;
|
|
367
|
+
memoryPerVector: number;
|
|
368
|
+
codebookSize: number;
|
|
369
|
+
} {
|
|
370
|
+
const compressionRatio = this.getCompressionRatio();
|
|
371
|
+
const memoryPerVector = this.config.numSubvectors + 4; // codes + norm
|
|
372
|
+
const codebookSize = this.codebook
|
|
373
|
+
? this.config.numSubvectors * this.config.numCentroids * (this.config.dimension / this.config.numSubvectors) * 4
|
|
374
|
+
: 0;
|
|
375
|
+
|
|
376
|
+
return {
|
|
377
|
+
trained: this.trained,
|
|
378
|
+
compressionRatio,
|
|
379
|
+
memoryPerVector,
|
|
380
|
+
codebookSize
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Helper function to create PQ8 (8 subvectors, 4x compression)
|
|
387
|
+
*/
|
|
388
|
+
export function createPQ8(dimension: number): ProductQuantization {
|
|
389
|
+
return new ProductQuantization({
|
|
390
|
+
dimension,
|
|
391
|
+
numSubvectors: 8,
|
|
392
|
+
numCentroids: 256,
|
|
393
|
+
maxIterations: 50
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Helper function to create PQ16 (16 subvectors, 8x compression)
|
|
399
|
+
*/
|
|
400
|
+
export function createPQ16(dimension: number): ProductQuantization {
|
|
401
|
+
return new ProductQuantization({
|
|
402
|
+
dimension,
|
|
403
|
+
numSubvectors: 16,
|
|
404
|
+
numCentroids: 256,
|
|
405
|
+
maxIterations: 50
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Helper function to create PQ32 (32 subvectors, 16x compression)
|
|
411
|
+
*/
|
|
412
|
+
export function createPQ32(dimension: number): ProductQuantization {
|
|
413
|
+
return new ProductQuantization({
|
|
414
|
+
dimension,
|
|
415
|
+
numSubvectors: 32,
|
|
416
|
+
numCentroids: 256,
|
|
417
|
+
maxIterations: 50
|
|
418
|
+
});
|
|
419
|
+
}
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentDB Browser Advanced Features
|
|
3
|
+
*
|
|
4
|
+
* Unified export for all browser-compatible advanced features.
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - Product Quantization (PQ8/PQ16/PQ32) - 4-32x memory compression
|
|
8
|
+
* - HNSW Indexing - 10-20x faster approximate search
|
|
9
|
+
* - Graph Neural Networks - Graph attention and message passing
|
|
10
|
+
* - MMR Diversity - Maximal marginal relevance ranking
|
|
11
|
+
* - Tensor Compression - SVD dimension reduction
|
|
12
|
+
* - Batch Operations - Optimized vector processing
|
|
13
|
+
*
|
|
14
|
+
* Bundle Size: ~35 KB minified (~12 KB gzipped)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Product Quantization
|
|
19
|
+
// ============================================================================
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
ProductQuantization,
|
|
23
|
+
createPQ8,
|
|
24
|
+
createPQ16,
|
|
25
|
+
createPQ32,
|
|
26
|
+
type PQConfig,
|
|
27
|
+
type PQCodebook,
|
|
28
|
+
type CompressedVector
|
|
29
|
+
} from './ProductQuantization';
|
|
30
|
+
|
|
31
|
+
// ============================================================================
|
|
32
|
+
// HNSW Indexing
|
|
33
|
+
// ============================================================================
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
HNSWIndex,
|
|
37
|
+
createHNSW,
|
|
38
|
+
createFastHNSW,
|
|
39
|
+
createAccurateHNSW,
|
|
40
|
+
type HNSWConfig,
|
|
41
|
+
type HNSWNode,
|
|
42
|
+
type SearchResult
|
|
43
|
+
} from './HNSWIndex';
|
|
44
|
+
|
|
45
|
+
// ============================================================================
|
|
46
|
+
// Advanced Features
|
|
47
|
+
// ============================================================================
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
GraphNeuralNetwork,
|
|
51
|
+
MaximalMarginalRelevance,
|
|
52
|
+
TensorCompression,
|
|
53
|
+
BatchProcessor,
|
|
54
|
+
type GNNNode,
|
|
55
|
+
type GNNEdge,
|
|
56
|
+
type GNNConfig,
|
|
57
|
+
type MMRConfig
|
|
58
|
+
} from './AdvancedFeatures';
|
|
59
|
+
|
|
60
|
+
// ============================================================================
|
|
61
|
+
// Feature Detection
|
|
62
|
+
// ============================================================================
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Detect available browser features
|
|
66
|
+
*/
|
|
67
|
+
export function detectFeatures() {
|
|
68
|
+
return {
|
|
69
|
+
indexedDB: 'indexedDB' in globalThis,
|
|
70
|
+
broadcastChannel: 'BroadcastChannel' in globalThis,
|
|
71
|
+
webWorkers: typeof (globalThis as any).Worker !== 'undefined',
|
|
72
|
+
wasmSIMD: detectWasmSIMD(),
|
|
73
|
+
sharedArrayBuffer: typeof SharedArrayBuffer !== 'undefined'
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Detect WASM SIMD support
|
|
79
|
+
*/
|
|
80
|
+
async function detectWasmSIMD(): Promise<boolean> {
|
|
81
|
+
try {
|
|
82
|
+
// Check if WebAssembly is available (browser context)
|
|
83
|
+
if (typeof (globalThis as any).WebAssembly === 'undefined') {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// WASM SIMD detection via feature test
|
|
88
|
+
const simdTest = new Uint8Array([
|
|
89
|
+
0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00,
|
|
90
|
+
0x01, 0x05, 0x01, 0x60, 0x00, 0x01, 0x7b, 0x03,
|
|
91
|
+
0x02, 0x01, 0x00, 0x0a, 0x0a, 0x01, 0x08, 0x00,
|
|
92
|
+
0xfd, 0x0c, 0xfd, 0x0c, 0xfd, 0x54, 0x0b
|
|
93
|
+
]);
|
|
94
|
+
|
|
95
|
+
const WA = (globalThis as any).WebAssembly;
|
|
96
|
+
const module = await WA.instantiate(simdTest);
|
|
97
|
+
return module instanceof WA.Instance;
|
|
98
|
+
} catch {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ============================================================================
|
|
104
|
+
// Configuration Presets
|
|
105
|
+
// ============================================================================
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Recommended configuration for small datasets (<1K vectors)
|
|
109
|
+
*/
|
|
110
|
+
export const SMALL_DATASET_CONFIG = {
|
|
111
|
+
pq: { enabled: false },
|
|
112
|
+
hnsw: { enabled: false },
|
|
113
|
+
gnn: { enabled: true, numHeads: 2 },
|
|
114
|
+
mmr: { enabled: true, lambda: 0.7 },
|
|
115
|
+
svd: { enabled: false }
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Recommended configuration for medium datasets (1K-10K vectors)
|
|
120
|
+
*/
|
|
121
|
+
export const MEDIUM_DATASET_CONFIG = {
|
|
122
|
+
pq: { enabled: true, subvectors: 8 },
|
|
123
|
+
hnsw: { enabled: true, M: 16 },
|
|
124
|
+
gnn: { enabled: true, numHeads: 4 },
|
|
125
|
+
mmr: { enabled: true, lambda: 0.7 },
|
|
126
|
+
svd: { enabled: false }
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Recommended configuration for large datasets (10K-100K vectors)
|
|
131
|
+
*/
|
|
132
|
+
export const LARGE_DATASET_CONFIG = {
|
|
133
|
+
pq: { enabled: true, subvectors: 16 },
|
|
134
|
+
hnsw: { enabled: true, M: 32 },
|
|
135
|
+
gnn: { enabled: true, numHeads: 4 },
|
|
136
|
+
mmr: { enabled: true, lambda: 0.7 },
|
|
137
|
+
svd: { enabled: true, targetDim: 128 }
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Memory-optimized configuration (minimal memory usage)
|
|
142
|
+
*/
|
|
143
|
+
export const MEMORY_OPTIMIZED_CONFIG = {
|
|
144
|
+
pq: { enabled: true, subvectors: 32 }, // 16x compression
|
|
145
|
+
hnsw: { enabled: true, M: 8 }, // Fewer connections
|
|
146
|
+
gnn: { enabled: false },
|
|
147
|
+
mmr: { enabled: false },
|
|
148
|
+
svd: { enabled: true, targetDim: 64 } // Aggressive dimension reduction
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Speed-optimized configuration (fastest search)
|
|
153
|
+
*/
|
|
154
|
+
export const SPEED_OPTIMIZED_CONFIG = {
|
|
155
|
+
pq: { enabled: false }, // No compression overhead
|
|
156
|
+
hnsw: { enabled: true, M: 32, efSearch: 100 }, // Maximum HNSW quality
|
|
157
|
+
gnn: { enabled: false },
|
|
158
|
+
mmr: { enabled: false },
|
|
159
|
+
svd: { enabled: false }
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Quality-optimized configuration (best result quality)
|
|
164
|
+
*/
|
|
165
|
+
export const QUALITY_OPTIMIZED_CONFIG = {
|
|
166
|
+
pq: { enabled: false }, // No compression
|
|
167
|
+
hnsw: { enabled: true, M: 48, efConstruction: 400 }, // Highest quality
|
|
168
|
+
gnn: { enabled: true, numHeads: 8 }, // More attention heads
|
|
169
|
+
mmr: { enabled: true, lambda: 0.8 }, // More diversity
|
|
170
|
+
svd: { enabled: false } // No dimension loss
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
// ============================================================================
|
|
174
|
+
// Version Information
|
|
175
|
+
// ============================================================================
|
|
176
|
+
|
|
177
|
+
export const VERSION = {
|
|
178
|
+
major: 2,
|
|
179
|
+
minor: 0,
|
|
180
|
+
patch: 0,
|
|
181
|
+
prerelease: 'alpha.2',
|
|
182
|
+
features: 'advanced',
|
|
183
|
+
full: '2.0.0-alpha.2+advanced'
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// ============================================================================
|
|
187
|
+
// Utility Functions
|
|
188
|
+
// ============================================================================
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Estimate memory usage for configuration
|
|
192
|
+
*/
|
|
193
|
+
export function estimateMemoryUsage(
|
|
194
|
+
numVectors: number,
|
|
195
|
+
dimension: number,
|
|
196
|
+
config: any
|
|
197
|
+
): {
|
|
198
|
+
vectors: number;
|
|
199
|
+
index: number;
|
|
200
|
+
total: number;
|
|
201
|
+
totalMB: number;
|
|
202
|
+
} {
|
|
203
|
+
let vectorBytes = numVectors * dimension * 4; // Float32Array
|
|
204
|
+
|
|
205
|
+
// Apply PQ compression
|
|
206
|
+
if (config.pq?.enabled) {
|
|
207
|
+
const subvectors = config.pq.subvectors || 8;
|
|
208
|
+
vectorBytes = numVectors * (subvectors + 4); // codes + norm
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Apply SVD compression
|
|
212
|
+
if (config.svd?.enabled) {
|
|
213
|
+
const targetDim = config.svd.targetDim || dimension / 2;
|
|
214
|
+
vectorBytes = numVectors * targetDim * 4;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// HNSW index overhead
|
|
218
|
+
let indexBytes = 0;
|
|
219
|
+
if (config.hnsw?.enabled) {
|
|
220
|
+
const M = config.hnsw.M || 16;
|
|
221
|
+
const avgConnections = M * 1.5; // Estimate
|
|
222
|
+
indexBytes = numVectors * avgConnections * 4; // Connection IDs
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const total = vectorBytes + indexBytes;
|
|
226
|
+
|
|
227
|
+
return {
|
|
228
|
+
vectors: vectorBytes,
|
|
229
|
+
index: indexBytes,
|
|
230
|
+
total,
|
|
231
|
+
totalMB: total / (1024 * 1024)
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Recommend configuration based on dataset size
|
|
237
|
+
*/
|
|
238
|
+
export function recommendConfig(numVectors: number, dimension: number) {
|
|
239
|
+
if (numVectors < 1000) {
|
|
240
|
+
return {
|
|
241
|
+
name: 'SMALL_DATASET',
|
|
242
|
+
config: SMALL_DATASET_CONFIG,
|
|
243
|
+
reason: 'Small dataset, linear search is fast enough'
|
|
244
|
+
};
|
|
245
|
+
} else if (numVectors < 10000) {
|
|
246
|
+
return {
|
|
247
|
+
name: 'MEDIUM_DATASET',
|
|
248
|
+
config: MEDIUM_DATASET_CONFIG,
|
|
249
|
+
reason: 'Medium dataset, HNSW + PQ8 recommended'
|
|
250
|
+
};
|
|
251
|
+
} else {
|
|
252
|
+
return {
|
|
253
|
+
name: 'LARGE_DATASET',
|
|
254
|
+
config: LARGE_DATASET_CONFIG,
|
|
255
|
+
reason: 'Large dataset, aggressive compression + HNSW recommended'
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Benchmark search performance
|
|
262
|
+
*/
|
|
263
|
+
export async function benchmarkSearch(
|
|
264
|
+
searchFn: (query: Float32Array, k: number) => any[],
|
|
265
|
+
numQueries: number = 100,
|
|
266
|
+
k: number = 10,
|
|
267
|
+
dimension: number = 384
|
|
268
|
+
): Promise<{
|
|
269
|
+
avgTimeMs: number;
|
|
270
|
+
minTimeMs: number;
|
|
271
|
+
maxTimeMs: number;
|
|
272
|
+
p50Ms: number;
|
|
273
|
+
p95Ms: number;
|
|
274
|
+
p99Ms: number;
|
|
275
|
+
}> {
|
|
276
|
+
const times: number[] = [];
|
|
277
|
+
|
|
278
|
+
for (let i = 0; i < numQueries; i++) {
|
|
279
|
+
const query = new Float32Array(dimension);
|
|
280
|
+
for (let d = 0; d < dimension; d++) {
|
|
281
|
+
query[d] = Math.random() - 0.5;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const start = performance.now();
|
|
285
|
+
searchFn(query, k);
|
|
286
|
+
const end = performance.now();
|
|
287
|
+
|
|
288
|
+
times.push(end - start);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
times.sort((a, b) => a - b);
|
|
292
|
+
|
|
293
|
+
return {
|
|
294
|
+
avgTimeMs: times.reduce((a, b) => a + b, 0) / times.length,
|
|
295
|
+
minTimeMs: times[0],
|
|
296
|
+
maxTimeMs: times[times.length - 1],
|
|
297
|
+
p50Ms: times[Math.floor(times.length * 0.5)],
|
|
298
|
+
p95Ms: times[Math.floor(times.length * 0.95)],
|
|
299
|
+
p99Ms: times[Math.floor(times.length * 0.99)]
|
|
300
|
+
};
|
|
301
|
+
}
|