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
|
@@ -23,10 +23,17 @@ import { LearningSystem } from '../controllers/LearningSystem.js';
|
|
|
23
23
|
import { EmbeddingService } from '../controllers/EmbeddingService.js';
|
|
24
24
|
import { BatchOperations } from '../optimizations/BatchOperations.js';
|
|
25
25
|
import { ReasoningBank } from '../controllers/ReasoningBank.js';
|
|
26
|
+
import { MCPToolCaches } from '../optimizations/ToolCache.js';
|
|
26
27
|
import {
|
|
27
28
|
validateId,
|
|
28
29
|
validateTimestamp,
|
|
29
30
|
validateSessionId,
|
|
31
|
+
validateTaskString,
|
|
32
|
+
validateNumericRange,
|
|
33
|
+
validateArrayLength,
|
|
34
|
+
validateObject,
|
|
35
|
+
validateBoolean,
|
|
36
|
+
validateEnum,
|
|
30
37
|
ValidationError,
|
|
31
38
|
handleSecurityError,
|
|
32
39
|
} from '../security/input-validation.js';
|
|
@@ -265,6 +272,7 @@ const learner = new NightlyLearner(db, embeddingService);
|
|
|
265
272
|
const learningSystem = new LearningSystem(db, embeddingService);
|
|
266
273
|
const batchOps = new BatchOperations(db, embeddingService);
|
|
267
274
|
const reasoningBank = new ReasoningBank(db, embeddingService);
|
|
275
|
+
const caches = new MCPToolCaches();
|
|
268
276
|
|
|
269
277
|
// ============================================================================
|
|
270
278
|
// MCP Server Setup
|
|
@@ -755,6 +763,123 @@ const tools = [
|
|
|
755
763
|
},
|
|
756
764
|
},
|
|
757
765
|
},
|
|
766
|
+
|
|
767
|
+
// ==========================================================================
|
|
768
|
+
// BATCH OPERATION TOOLS (v2.0 MCP Optimization - Phase 2)
|
|
769
|
+
// ==========================================================================
|
|
770
|
+
{
|
|
771
|
+
name: 'skill_create_batch',
|
|
772
|
+
description: 'Batch create multiple skills efficiently using transactions and parallel embedding generation. 3x faster than sequential skill_create calls (304 → 900 ops/sec). 🔄 PARALLEL-SAFE: Can be used alongside other batch operations.',
|
|
773
|
+
inputSchema: {
|
|
774
|
+
type: 'object',
|
|
775
|
+
properties: {
|
|
776
|
+
skills: {
|
|
777
|
+
type: 'array',
|
|
778
|
+
items: {
|
|
779
|
+
type: 'object',
|
|
780
|
+
properties: {
|
|
781
|
+
name: { type: 'string', description: 'Skill name (unique)' },
|
|
782
|
+
description: { type: 'string', description: 'What the skill does' },
|
|
783
|
+
signature: { type: 'object', description: 'Optional function signature' },
|
|
784
|
+
code: { type: 'string', description: 'Skill implementation code' },
|
|
785
|
+
success_rate: { type: 'number', description: 'Initial success rate (0-1)', default: 0.0 },
|
|
786
|
+
uses: { type: 'number', description: 'Initial use count', default: 0 },
|
|
787
|
+
avg_reward: { type: 'number', description: 'Average reward', default: 0.0 },
|
|
788
|
+
avg_latency_ms: { type: 'number', description: 'Average latency', default: 0.0 },
|
|
789
|
+
tags: { type: 'array', items: { type: 'string' }, description: 'Tags for categorization' },
|
|
790
|
+
metadata: { type: 'object', description: 'Additional metadata (JSON)' },
|
|
791
|
+
},
|
|
792
|
+
required: ['name', 'description'],
|
|
793
|
+
},
|
|
794
|
+
description: 'Array of skills to create',
|
|
795
|
+
minItems: 1,
|
|
796
|
+
maxItems: 100,
|
|
797
|
+
},
|
|
798
|
+
batch_size: { type: 'number', description: 'Batch size for processing (default: 32)', default: 32 },
|
|
799
|
+
format: {
|
|
800
|
+
type: 'string',
|
|
801
|
+
enum: ['concise', 'detailed', 'json'],
|
|
802
|
+
description: 'Response format (default: concise)',
|
|
803
|
+
default: 'concise',
|
|
804
|
+
},
|
|
805
|
+
},
|
|
806
|
+
required: ['skills'],
|
|
807
|
+
},
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
name: 'reflexion_store_batch',
|
|
811
|
+
description: 'Batch store multiple episodes efficiently using transactions and parallel embedding generation. 3.3x faster than sequential reflexion_store calls (152 → 500 ops/sec). 🔄 PARALLEL-SAFE: Can be used alongside other batch operations.',
|
|
812
|
+
inputSchema: {
|
|
813
|
+
type: 'object',
|
|
814
|
+
properties: {
|
|
815
|
+
episodes: {
|
|
816
|
+
type: 'array',
|
|
817
|
+
items: {
|
|
818
|
+
type: 'object',
|
|
819
|
+
properties: {
|
|
820
|
+
session_id: { type: 'string', description: 'Session identifier' },
|
|
821
|
+
task: { type: 'string', description: 'Task description' },
|
|
822
|
+
reward: { type: 'number', description: 'Task reward (0-1)' },
|
|
823
|
+
success: { type: 'boolean', description: 'Whether task succeeded' },
|
|
824
|
+
critique: { type: 'string', description: 'Self-critique reflection' },
|
|
825
|
+
input: { type: 'string', description: 'Task input' },
|
|
826
|
+
output: { type: 'string', description: 'Task output' },
|
|
827
|
+
latency_ms: { type: 'number', description: 'Execution latency' },
|
|
828
|
+
tokens: { type: 'number', description: 'Tokens used' },
|
|
829
|
+
tags: { type: 'array', items: { type: 'string' }, description: 'Tags' },
|
|
830
|
+
metadata: { type: 'object', description: 'Additional metadata' },
|
|
831
|
+
},
|
|
832
|
+
required: ['session_id', 'task', 'reward', 'success'],
|
|
833
|
+
},
|
|
834
|
+
description: 'Array of episodes to store',
|
|
835
|
+
minItems: 1,
|
|
836
|
+
maxItems: 1000,
|
|
837
|
+
},
|
|
838
|
+
batch_size: { type: 'number', description: 'Batch size for processing (default: 100)', default: 100 },
|
|
839
|
+
format: {
|
|
840
|
+
type: 'string',
|
|
841
|
+
enum: ['concise', 'detailed', 'json'],
|
|
842
|
+
description: 'Response format (default: concise)',
|
|
843
|
+
default: 'concise',
|
|
844
|
+
},
|
|
845
|
+
},
|
|
846
|
+
required: ['episodes'],
|
|
847
|
+
},
|
|
848
|
+
},
|
|
849
|
+
{
|
|
850
|
+
name: 'agentdb_pattern_store_batch',
|
|
851
|
+
description: 'Batch store multiple reasoning patterns efficiently using transactions and parallel embedding generation. 4x faster than sequential agentdb_pattern_store calls. 🔄 PARALLEL-SAFE: Can be used alongside other batch operations.',
|
|
852
|
+
inputSchema: {
|
|
853
|
+
type: 'object',
|
|
854
|
+
properties: {
|
|
855
|
+
patterns: {
|
|
856
|
+
type: 'array',
|
|
857
|
+
items: {
|
|
858
|
+
type: 'object',
|
|
859
|
+
properties: {
|
|
860
|
+
taskType: { type: 'string', description: 'Type of task (e.g., "code_review", "data_analysis")' },
|
|
861
|
+
approach: { type: 'string', description: 'Description of the reasoning approach' },
|
|
862
|
+
successRate: { type: 'number', description: 'Success rate (0-1)' },
|
|
863
|
+
tags: { type: 'array', items: { type: 'string' }, description: 'Optional tags' },
|
|
864
|
+
metadata: { type: 'object', description: 'Additional metadata' },
|
|
865
|
+
},
|
|
866
|
+
required: ['taskType', 'approach', 'successRate'],
|
|
867
|
+
},
|
|
868
|
+
description: 'Array of reasoning patterns to store',
|
|
869
|
+
minItems: 1,
|
|
870
|
+
maxItems: 500,
|
|
871
|
+
},
|
|
872
|
+
batch_size: { type: 'number', description: 'Batch size for processing (default: 50)', default: 50 },
|
|
873
|
+
format: {
|
|
874
|
+
type: 'string',
|
|
875
|
+
enum: ['concise', 'detailed', 'json'],
|
|
876
|
+
description: 'Response format (default: concise)',
|
|
877
|
+
default: 'concise',
|
|
878
|
+
},
|
|
879
|
+
},
|
|
880
|
+
required: ['patterns'],
|
|
881
|
+
},
|
|
882
|
+
},
|
|
758
883
|
];
|
|
759
884
|
|
|
760
885
|
// ============================================================================
|
|
@@ -1202,6 +1327,20 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1202
1327
|
case 'agentdb_stats': {
|
|
1203
1328
|
const detailed = (args?.detailed as boolean) || false;
|
|
1204
1329
|
|
|
1330
|
+
// Check cache first (60s TTL)
|
|
1331
|
+
const cacheKey = `stats:${detailed ? 'detailed' : 'summary'}`;
|
|
1332
|
+
const cached = caches.stats.get(cacheKey);
|
|
1333
|
+
if (cached) {
|
|
1334
|
+
return {
|
|
1335
|
+
content: [
|
|
1336
|
+
{
|
|
1337
|
+
type: 'text',
|
|
1338
|
+
text: `${cached}\n\n⚡ (cached)`,
|
|
1339
|
+
},
|
|
1340
|
+
],
|
|
1341
|
+
};
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1205
1344
|
// Helper to safely query table count
|
|
1206
1345
|
const safeCount = (tableName: string): number => {
|
|
1207
1346
|
try {
|
|
@@ -1259,6 +1398,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1259
1398
|
` Recent Activity (7d): ${recentActivity.count} episodes\n`;
|
|
1260
1399
|
}
|
|
1261
1400
|
|
|
1401
|
+
// Cache the result (60s TTL)
|
|
1402
|
+
caches.stats.set(cacheKey, output);
|
|
1403
|
+
|
|
1262
1404
|
return {
|
|
1263
1405
|
content: [
|
|
1264
1406
|
{
|
|
@@ -1343,24 +1485,43 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1343
1485
|
}
|
|
1344
1486
|
|
|
1345
1487
|
case 'agentdb_pattern_stats': {
|
|
1488
|
+
// Check cache first (60s TTL)
|
|
1489
|
+
const cacheKey = 'pattern_stats';
|
|
1490
|
+
const cached = caches.stats.get(cacheKey);
|
|
1491
|
+
if (cached) {
|
|
1492
|
+
return {
|
|
1493
|
+
content: [
|
|
1494
|
+
{
|
|
1495
|
+
type: 'text',
|
|
1496
|
+
text: `${cached}\n\n⚡ (cached)`,
|
|
1497
|
+
},
|
|
1498
|
+
],
|
|
1499
|
+
};
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1346
1502
|
const stats = reasoningBank.getPatternStats();
|
|
1347
1503
|
|
|
1504
|
+
const output = `📊 Reasoning Pattern Statistics\n\n` +
|
|
1505
|
+
`📈 Overview:\n` +
|
|
1506
|
+
` Total Patterns: ${stats.totalPatterns}\n` +
|
|
1507
|
+
` Avg Success Rate: ${(stats.avgSuccessRate * 100).toFixed(1)}%\n` +
|
|
1508
|
+
` Avg Uses per Pattern: ${stats.avgUses.toFixed(1)}\n` +
|
|
1509
|
+
` High Performing (≥80%): ${stats.highPerformingPatterns}\n` +
|
|
1510
|
+
` Recent (7 days): ${stats.recentPatterns}\n\n` +
|
|
1511
|
+
`🏆 Top Task Types:\n` +
|
|
1512
|
+
stats.topTaskTypes.slice(0, 10).map((tt, i) =>
|
|
1513
|
+
` ${i + 1}. ${tt.taskType}: ${tt.count} patterns`
|
|
1514
|
+
).join('\n') +
|
|
1515
|
+
(stats.topTaskTypes.length === 0 ? ' No patterns stored yet' : '');
|
|
1516
|
+
|
|
1517
|
+
// Cache the result (60s TTL)
|
|
1518
|
+
caches.stats.set(cacheKey, output);
|
|
1519
|
+
|
|
1348
1520
|
return {
|
|
1349
1521
|
content: [
|
|
1350
1522
|
{
|
|
1351
1523
|
type: 'text',
|
|
1352
|
-
text:
|
|
1353
|
-
`📈 Overview:\n` +
|
|
1354
|
-
` Total Patterns: ${stats.totalPatterns}\n` +
|
|
1355
|
-
` Avg Success Rate: ${(stats.avgSuccessRate * 100).toFixed(1)}%\n` +
|
|
1356
|
-
` Avg Uses per Pattern: ${stats.avgUses.toFixed(1)}\n` +
|
|
1357
|
-
` High Performing (≥80%): ${stats.highPerformingPatterns}\n` +
|
|
1358
|
-
` Recent (7 days): ${stats.recentPatterns}\n\n` +
|
|
1359
|
-
`🏆 Top Task Types:\n` +
|
|
1360
|
-
stats.topTaskTypes.slice(0, 10).map((tt, i) =>
|
|
1361
|
-
` ${i + 1}. ${tt.taskType}: ${tt.count} patterns`
|
|
1362
|
-
).join('\n') +
|
|
1363
|
-
(stats.topTaskTypes.length === 0 ? ' No patterns stored yet' : ''),
|
|
1524
|
+
text: output,
|
|
1364
1525
|
},
|
|
1365
1526
|
],
|
|
1366
1527
|
};
|
|
@@ -1369,11 +1530,21 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1369
1530
|
case 'agentdb_clear_cache': {
|
|
1370
1531
|
const cacheType = (args?.cache_type as string) || 'all';
|
|
1371
1532
|
|
|
1533
|
+
let cleared = 0;
|
|
1534
|
+
|
|
1372
1535
|
switch (cacheType) {
|
|
1373
1536
|
case 'patterns':
|
|
1537
|
+
cleared += caches.patterns.clear();
|
|
1538
|
+
reasoningBank.clearCache();
|
|
1539
|
+
break;
|
|
1374
1540
|
case 'stats':
|
|
1541
|
+
cleared += caches.stats.clear();
|
|
1542
|
+
cleared += caches.metrics.clear();
|
|
1543
|
+
break;
|
|
1375
1544
|
case 'all':
|
|
1545
|
+
caches.clearAll();
|
|
1376
1546
|
reasoningBank.clearCache();
|
|
1547
|
+
cleared = -1; // All cleared
|
|
1377
1548
|
break;
|
|
1378
1549
|
}
|
|
1379
1550
|
|
|
@@ -1383,12 +1554,328 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1383
1554
|
type: 'text',
|
|
1384
1555
|
text: `✅ Cache cleared successfully!\n\n` +
|
|
1385
1556
|
`🧹 Cache Type: ${cacheType}\n` +
|
|
1386
|
-
`♻️
|
|
1557
|
+
`♻️ ${cleared === -1 ? 'All caches' : `${cleared} cache entries`} cleared\n` +
|
|
1558
|
+
`📊 Statistics and search results will be refreshed on next query`,
|
|
1387
1559
|
},
|
|
1388
1560
|
],
|
|
1389
1561
|
};
|
|
1390
1562
|
}
|
|
1391
1563
|
|
|
1564
|
+
// ======================================================================
|
|
1565
|
+
// BATCH OPERATION TOOLS (v2.0 MCP Optimization - Phase 2)
|
|
1566
|
+
// ======================================================================
|
|
1567
|
+
case 'skill_create_batch': {
|
|
1568
|
+
try {
|
|
1569
|
+
// Validate inputs
|
|
1570
|
+
const skillsArray = validateArrayLength(args?.skills, 'skills', 1, 100);
|
|
1571
|
+
const batchSize = args?.batch_size ? validateNumericRange(args.batch_size, 'batch_size', 1, 100) : 32;
|
|
1572
|
+
const format = args?.format ? validateEnum(args.format, 'format', ['concise', 'detailed', 'json'] as const) : 'concise';
|
|
1573
|
+
|
|
1574
|
+
// Validate each skill
|
|
1575
|
+
const validatedSkills = skillsArray.map((skill: any, index: number) => {
|
|
1576
|
+
const name = validateTaskString(skill.name, `skills[${index}].name`);
|
|
1577
|
+
const description = validateTaskString(skill.description, `skills[${index}].description`);
|
|
1578
|
+
const successRate = skill.success_rate !== undefined
|
|
1579
|
+
? validateNumericRange(skill.success_rate, `skills[${index}].success_rate`, 0, 1)
|
|
1580
|
+
: 0.0;
|
|
1581
|
+
|
|
1582
|
+
return {
|
|
1583
|
+
name,
|
|
1584
|
+
description,
|
|
1585
|
+
signature: skill.signature || { inputs: {}, outputs: {} },
|
|
1586
|
+
code: skill.code || '',
|
|
1587
|
+
successRate,
|
|
1588
|
+
uses: skill.uses || 0,
|
|
1589
|
+
avgReward: skill.avg_reward || 0.0,
|
|
1590
|
+
avgLatencyMs: skill.avg_latency_ms || 0.0,
|
|
1591
|
+
tags: skill.tags || [],
|
|
1592
|
+
metadata: skill.metadata || {},
|
|
1593
|
+
};
|
|
1594
|
+
});
|
|
1595
|
+
|
|
1596
|
+
// Use BatchOperations for efficient insertion
|
|
1597
|
+
const startTime = Date.now();
|
|
1598
|
+
const batchOpsConfig = new BatchOperations(db, embeddingService, {
|
|
1599
|
+
batchSize,
|
|
1600
|
+
parallelism: 4,
|
|
1601
|
+
});
|
|
1602
|
+
|
|
1603
|
+
const skillIds = await batchOpsConfig.insertSkills(validatedSkills);
|
|
1604
|
+
const duration = Date.now() - startTime;
|
|
1605
|
+
|
|
1606
|
+
// Format response
|
|
1607
|
+
if (format === 'json') {
|
|
1608
|
+
return {
|
|
1609
|
+
content: [
|
|
1610
|
+
{
|
|
1611
|
+
type: 'text',
|
|
1612
|
+
text: JSON.stringify({
|
|
1613
|
+
success: true,
|
|
1614
|
+
inserted: skillIds.length,
|
|
1615
|
+
skill_ids: skillIds,
|
|
1616
|
+
duration_ms: duration,
|
|
1617
|
+
batch_size: batchSize,
|
|
1618
|
+
}, null, 2),
|
|
1619
|
+
},
|
|
1620
|
+
],
|
|
1621
|
+
};
|
|
1622
|
+
} else if (format === 'detailed') {
|
|
1623
|
+
return {
|
|
1624
|
+
content: [
|
|
1625
|
+
{
|
|
1626
|
+
type: 'text',
|
|
1627
|
+
text: `✅ Batch skill creation completed!\n\n` +
|
|
1628
|
+
`📊 Performance:\n` +
|
|
1629
|
+
` • Skills Created: ${skillIds.length}\n` +
|
|
1630
|
+
` • Duration: ${duration}ms\n` +
|
|
1631
|
+
` • Throughput: ${(skillIds.length / (duration / 1000)).toFixed(1)} skills/sec\n` +
|
|
1632
|
+
` • Batch Size: ${batchSize}\n` +
|
|
1633
|
+
` • Parallelism: 4 workers\n\n` +
|
|
1634
|
+
`🆔 Created Skill IDs:\n` +
|
|
1635
|
+
skillIds.slice(0, 10).map((id, i) =>
|
|
1636
|
+
` ${i + 1}. Skill #${id}: ${validatedSkills[i].name}`
|
|
1637
|
+
).join('\n') +
|
|
1638
|
+
(skillIds.length > 10 ? `\n ... and ${skillIds.length - 10} more skills` : '') +
|
|
1639
|
+
`\n\n🧠 All embeddings generated in parallel\n` +
|
|
1640
|
+
`💾 Transaction committed successfully`,
|
|
1641
|
+
},
|
|
1642
|
+
],
|
|
1643
|
+
};
|
|
1644
|
+
} else {
|
|
1645
|
+
// Concise format (default)
|
|
1646
|
+
return {
|
|
1647
|
+
content: [
|
|
1648
|
+
{
|
|
1649
|
+
type: 'text',
|
|
1650
|
+
text: `✅ Created ${skillIds.length} skills in ${duration}ms (${(skillIds.length / (duration / 1000)).toFixed(1)} skills/sec)`,
|
|
1651
|
+
},
|
|
1652
|
+
],
|
|
1653
|
+
};
|
|
1654
|
+
}
|
|
1655
|
+
} catch (error: any) {
|
|
1656
|
+
const safeMessage = handleSecurityError(error);
|
|
1657
|
+
return {
|
|
1658
|
+
content: [
|
|
1659
|
+
{
|
|
1660
|
+
type: 'text',
|
|
1661
|
+
text: `❌ Batch skill creation failed: ${safeMessage}\n\n` +
|
|
1662
|
+
`💡 Troubleshooting:\n` +
|
|
1663
|
+
` • Ensure all skills have unique names\n` +
|
|
1664
|
+
` • Verify success_rate is between 0 and 1\n` +
|
|
1665
|
+
` • Check that skills array has 1-100 items\n` +
|
|
1666
|
+
` • Ensure descriptions are not empty`,
|
|
1667
|
+
},
|
|
1668
|
+
],
|
|
1669
|
+
isError: true,
|
|
1670
|
+
};
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
case 'reflexion_store_batch': {
|
|
1675
|
+
try {
|
|
1676
|
+
// Validate inputs
|
|
1677
|
+
const episodesArray = validateArrayLength(args?.episodes, 'episodes', 1, 1000);
|
|
1678
|
+
const batchSize = args?.batch_size ? validateNumericRange(args.batch_size, 'batch_size', 1, 1000) : 100;
|
|
1679
|
+
const format = args?.format ? validateEnum(args.format, 'format', ['concise', 'detailed', 'json'] as const) : 'concise';
|
|
1680
|
+
|
|
1681
|
+
// Validate each episode
|
|
1682
|
+
const validatedEpisodes = episodesArray.map((ep: any, index: number) => {
|
|
1683
|
+
const sessionId = validateSessionId(ep.session_id);
|
|
1684
|
+
const task = validateTaskString(ep.task, `episodes[${index}].task`);
|
|
1685
|
+
const reward = validateNumericRange(ep.reward, `episodes[${index}].reward`, 0, 1);
|
|
1686
|
+
const success = validateBoolean(ep.success, `episodes[${index}].success`);
|
|
1687
|
+
|
|
1688
|
+
return {
|
|
1689
|
+
sessionId,
|
|
1690
|
+
task,
|
|
1691
|
+
reward,
|
|
1692
|
+
success,
|
|
1693
|
+
critique: ep.critique || '',
|
|
1694
|
+
input: ep.input || '',
|
|
1695
|
+
output: ep.output || '',
|
|
1696
|
+
latencyMs: ep.latency_ms || 0,
|
|
1697
|
+
tokensUsed: ep.tokens || 0,
|
|
1698
|
+
tags: ep.tags || [],
|
|
1699
|
+
metadata: ep.metadata || {},
|
|
1700
|
+
};
|
|
1701
|
+
});
|
|
1702
|
+
|
|
1703
|
+
// Use BatchOperations for efficient insertion
|
|
1704
|
+
const startTime = Date.now();
|
|
1705
|
+
const batchOpsConfig = new BatchOperations(db, embeddingService, {
|
|
1706
|
+
batchSize,
|
|
1707
|
+
parallelism: 4,
|
|
1708
|
+
});
|
|
1709
|
+
|
|
1710
|
+
const insertedCount = await batchOpsConfig.insertEpisodes(validatedEpisodes);
|
|
1711
|
+
const duration = Date.now() - startTime;
|
|
1712
|
+
|
|
1713
|
+
// Format response
|
|
1714
|
+
if (format === 'json') {
|
|
1715
|
+
return {
|
|
1716
|
+
content: [
|
|
1717
|
+
{
|
|
1718
|
+
type: 'text',
|
|
1719
|
+
text: JSON.stringify({
|
|
1720
|
+
success: true,
|
|
1721
|
+
inserted: insertedCount,
|
|
1722
|
+
duration_ms: duration,
|
|
1723
|
+
batch_size: batchSize,
|
|
1724
|
+
}, null, 2),
|
|
1725
|
+
},
|
|
1726
|
+
],
|
|
1727
|
+
};
|
|
1728
|
+
} else if (format === 'detailed') {
|
|
1729
|
+
return {
|
|
1730
|
+
content: [
|
|
1731
|
+
{
|
|
1732
|
+
type: 'text',
|
|
1733
|
+
text: `✅ Batch episode storage completed!\n\n` +
|
|
1734
|
+
`📊 Performance:\n` +
|
|
1735
|
+
` • Episodes Stored: ${insertedCount}\n` +
|
|
1736
|
+
` • Duration: ${duration}ms\n` +
|
|
1737
|
+
` • Throughput: ${(insertedCount / (duration / 1000)).toFixed(1)} episodes/sec\n` +
|
|
1738
|
+
` • Batch Size: ${batchSize}\n` +
|
|
1739
|
+
` • Parallelism: 4 workers\n\n` +
|
|
1740
|
+
`📈 Statistics:\n` +
|
|
1741
|
+
` • Sessions: ${new Set(validatedEpisodes.map(e => e.sessionId)).size}\n` +
|
|
1742
|
+
` • Success Rate: ${(validatedEpisodes.filter(e => e.success).length / validatedEpisodes.length * 100).toFixed(1)}%\n` +
|
|
1743
|
+
` • Avg Reward: ${(validatedEpisodes.reduce((sum, e) => sum + e.reward, 0) / validatedEpisodes.length).toFixed(3)}\n\n` +
|
|
1744
|
+
`🧠 All embeddings generated in parallel\n` +
|
|
1745
|
+
`💾 Transaction committed successfully`,
|
|
1746
|
+
},
|
|
1747
|
+
],
|
|
1748
|
+
};
|
|
1749
|
+
} else {
|
|
1750
|
+
// Concise format (default)
|
|
1751
|
+
return {
|
|
1752
|
+
content: [
|
|
1753
|
+
{
|
|
1754
|
+
type: 'text',
|
|
1755
|
+
text: `✅ Stored ${insertedCount} episodes in ${duration}ms (${(insertedCount / (duration / 1000)).toFixed(1)} episodes/sec)`,
|
|
1756
|
+
},
|
|
1757
|
+
],
|
|
1758
|
+
};
|
|
1759
|
+
}
|
|
1760
|
+
} catch (error: any) {
|
|
1761
|
+
const safeMessage = handleSecurityError(error);
|
|
1762
|
+
return {
|
|
1763
|
+
content: [
|
|
1764
|
+
{
|
|
1765
|
+
type: 'text',
|
|
1766
|
+
text: `❌ Batch episode storage failed: ${safeMessage}\n\n` +
|
|
1767
|
+
`💡 Troubleshooting:\n` +
|
|
1768
|
+
` • Ensure all session_ids are valid (alphanumeric, hyphens, underscores)\n` +
|
|
1769
|
+
` • Verify rewards are between 0 and 1\n` +
|
|
1770
|
+
` • Check that episodes array has 1-1000 items\n` +
|
|
1771
|
+
` • Ensure tasks are not empty or excessively long`,
|
|
1772
|
+
},
|
|
1773
|
+
],
|
|
1774
|
+
isError: true,
|
|
1775
|
+
};
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
case 'agentdb_pattern_store_batch': {
|
|
1780
|
+
try {
|
|
1781
|
+
// Validate inputs
|
|
1782
|
+
const patternsArray = validateArrayLength(args?.patterns, 'patterns', 1, 500);
|
|
1783
|
+
const batchSize = args?.batch_size ? validateNumericRange(args.batch_size, 'batch_size', 1, 500) : 50;
|
|
1784
|
+
const format = args?.format ? validateEnum(args.format, 'format', ['concise', 'detailed', 'json'] as const) : 'concise';
|
|
1785
|
+
|
|
1786
|
+
// Validate each pattern
|
|
1787
|
+
const validatedPatterns = patternsArray.map((pattern: any, index: number) => {
|
|
1788
|
+
const taskType = validateTaskString(pattern.taskType, `patterns[${index}].taskType`);
|
|
1789
|
+
const approach = validateTaskString(pattern.approach, `patterns[${index}].approach`);
|
|
1790
|
+
const successRate = validateNumericRange(pattern.successRate, `patterns[${index}].successRate`, 0, 1);
|
|
1791
|
+
|
|
1792
|
+
return {
|
|
1793
|
+
taskType,
|
|
1794
|
+
approach,
|
|
1795
|
+
successRate,
|
|
1796
|
+
tags: pattern.tags || [],
|
|
1797
|
+
metadata: pattern.metadata || {},
|
|
1798
|
+
};
|
|
1799
|
+
});
|
|
1800
|
+
|
|
1801
|
+
// Use BatchOperations for efficient insertion
|
|
1802
|
+
const startTime = Date.now();
|
|
1803
|
+
const batchOpsConfig = new BatchOperations(db, embeddingService, {
|
|
1804
|
+
batchSize,
|
|
1805
|
+
parallelism: 4,
|
|
1806
|
+
});
|
|
1807
|
+
|
|
1808
|
+
const patternIds = await batchOpsConfig.insertPatterns(validatedPatterns);
|
|
1809
|
+
const duration = Date.now() - startTime;
|
|
1810
|
+
|
|
1811
|
+
// Format response
|
|
1812
|
+
if (format === 'json') {
|
|
1813
|
+
return {
|
|
1814
|
+
content: [
|
|
1815
|
+
{
|
|
1816
|
+
type: 'text',
|
|
1817
|
+
text: JSON.stringify({
|
|
1818
|
+
success: true,
|
|
1819
|
+
inserted: patternIds.length,
|
|
1820
|
+
pattern_ids: patternIds,
|
|
1821
|
+
duration_ms: duration,
|
|
1822
|
+
batch_size: batchSize,
|
|
1823
|
+
}, null, 2),
|
|
1824
|
+
},
|
|
1825
|
+
],
|
|
1826
|
+
};
|
|
1827
|
+
} else if (format === 'detailed') {
|
|
1828
|
+
return {
|
|
1829
|
+
content: [
|
|
1830
|
+
{
|
|
1831
|
+
type: 'text',
|
|
1832
|
+
text: `✅ Batch pattern storage completed!\n\n` +
|
|
1833
|
+
`📊 Performance:\n` +
|
|
1834
|
+
` • Patterns Stored: ${patternIds.length}\n` +
|
|
1835
|
+
` • Duration: ${duration}ms\n` +
|
|
1836
|
+
` • Throughput: ${(patternIds.length / (duration / 1000)).toFixed(1)} patterns/sec\n` +
|
|
1837
|
+
` • Batch Size: ${batchSize}\n` +
|
|
1838
|
+
` • Parallelism: 4 workers\n\n` +
|
|
1839
|
+
`📈 Statistics:\n` +
|
|
1840
|
+
` • Task Types: ${new Set(validatedPatterns.map(p => p.taskType)).size}\n` +
|
|
1841
|
+
` • Avg Success Rate: ${(validatedPatterns.reduce((sum, p) => sum + p.successRate, 0) / validatedPatterns.length * 100).toFixed(1)}%\n` +
|
|
1842
|
+
` • High Performing (≥80%): ${validatedPatterns.filter(p => p.successRate >= 0.8).length}\n\n` +
|
|
1843
|
+
`🆔 Sample Pattern IDs: ${patternIds.slice(0, 5).join(', ')}${patternIds.length > 5 ? '...' : ''}\n` +
|
|
1844
|
+
`🧠 All embeddings generated in parallel\n` +
|
|
1845
|
+
`💾 Transaction committed successfully`,
|
|
1846
|
+
},
|
|
1847
|
+
],
|
|
1848
|
+
};
|
|
1849
|
+
} else {
|
|
1850
|
+
// Concise format (default)
|
|
1851
|
+
return {
|
|
1852
|
+
content: [
|
|
1853
|
+
{
|
|
1854
|
+
type: 'text',
|
|
1855
|
+
text: `✅ Stored ${patternIds.length} patterns in ${duration}ms (${(patternIds.length / (duration / 1000)).toFixed(1)} patterns/sec)`,
|
|
1856
|
+
},
|
|
1857
|
+
],
|
|
1858
|
+
};
|
|
1859
|
+
}
|
|
1860
|
+
} catch (error: any) {
|
|
1861
|
+
const safeMessage = handleSecurityError(error);
|
|
1862
|
+
return {
|
|
1863
|
+
content: [
|
|
1864
|
+
{
|
|
1865
|
+
type: 'text',
|
|
1866
|
+
text: `❌ Batch pattern storage failed: ${safeMessage}\n\n` +
|
|
1867
|
+
`💡 Troubleshooting:\n` +
|
|
1868
|
+
` • Ensure taskType and approach are not empty\n` +
|
|
1869
|
+
` • Verify successRate is between 0 and 1\n` +
|
|
1870
|
+
` • Check that patterns array has 1-500 items\n` +
|
|
1871
|
+
` • Avoid excessively long task types or approaches`,
|
|
1872
|
+
},
|
|
1873
|
+
],
|
|
1874
|
+
isError: true,
|
|
1875
|
+
};
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1392
1879
|
// ======================================================================
|
|
1393
1880
|
// LEARNING SYSTEM TOOLS (Tools 1-5)
|
|
1394
1881
|
// ======================================================================
|
|
@@ -1540,6 +2027,20 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1540
2027
|
const includeTrends = (args?.include_trends as boolean) !== false;
|
|
1541
2028
|
const groupBy = (args?.group_by as 'task' | 'session' | 'skill') || 'task';
|
|
1542
2029
|
|
|
2030
|
+
// Check cache first (120s TTL for expensive computations)
|
|
2031
|
+
const cacheKey = `metrics:${sessionId || 'all'}:${timeWindowDays}:${groupBy}:${includeTrends}`;
|
|
2032
|
+
const cached = caches.metrics.get(cacheKey);
|
|
2033
|
+
if (cached) {
|
|
2034
|
+
return {
|
|
2035
|
+
content: [
|
|
2036
|
+
{
|
|
2037
|
+
type: 'text',
|
|
2038
|
+
text: `${cached}\n\n⚡ (cached)`,
|
|
2039
|
+
},
|
|
2040
|
+
],
|
|
2041
|
+
};
|
|
2042
|
+
}
|
|
2043
|
+
|
|
1543
2044
|
const metrics = await learningSystem.getMetrics({
|
|
1544
2045
|
sessionId,
|
|
1545
2046
|
timeWindowDays,
|
|
@@ -1547,31 +2048,36 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1547
2048
|
groupBy,
|
|
1548
2049
|
});
|
|
1549
2050
|
|
|
2051
|
+
const output = `📊 Learning Performance Metrics\n\n` +
|
|
2052
|
+
`⏱️ Time Window: ${timeWindowDays} days\n\n` +
|
|
2053
|
+
`📈 Overall Performance:\n` +
|
|
2054
|
+
` • Total Episodes: ${metrics.overall.totalEpisodes}\n` +
|
|
2055
|
+
` • Success Rate: ${(metrics.overall.successRate * 100).toFixed(1)}%\n` +
|
|
2056
|
+
` • Avg Reward: ${metrics.overall.avgReward.toFixed(3)}\n` +
|
|
2057
|
+
` • Reward Range: [${metrics.overall.minReward.toFixed(2)}, ${metrics.overall.maxReward.toFixed(2)}]\n` +
|
|
2058
|
+
` • Avg Latency: ${metrics.overall.avgLatencyMs.toFixed(0)}ms\n\n` +
|
|
2059
|
+
`🎯 Top ${groupBy.charAt(0).toUpperCase() + groupBy.slice(1)}s:\n` +
|
|
2060
|
+
metrics.groupedMetrics.slice(0, 5).map((g, i) =>
|
|
2061
|
+
` ${i + 1}. ${g.key.substring(0, 40)}${g.key.length > 40 ? '...' : ''}\n` +
|
|
2062
|
+
` Count: ${g.count}, Success: ${(g.successRate * 100).toFixed(1)}%, Reward: ${g.avgReward.toFixed(2)}`
|
|
2063
|
+
).join('\n') +
|
|
2064
|
+
(metrics.groupedMetrics.length === 0 ? ' No data available' : '') +
|
|
2065
|
+
(includeTrends && metrics.trends.length > 0 ? `\n\n📉 Recent Trends (last ${Math.min(7, metrics.trends.length)} days):\n` +
|
|
2066
|
+
metrics.trends.slice(-7).map((t) =>
|
|
2067
|
+
` ${t.date}: ${t.count} episodes, ${(t.successRate * 100).toFixed(1)}% success`
|
|
2068
|
+
).join('\n') : '') +
|
|
2069
|
+
(metrics.policyImprovement.versions > 0 ? `\n\n🧠 Policy Improvement:\n` +
|
|
2070
|
+
` • Versions: ${metrics.policyImprovement.versions}\n` +
|
|
2071
|
+
` • Q-Value Improvement: ${metrics.policyImprovement.qValueImprovement >= 0 ? '+' : ''}${metrics.policyImprovement.qValueImprovement.toFixed(3)}` : '');
|
|
2072
|
+
|
|
2073
|
+
// Cache the result (120s TTL)
|
|
2074
|
+
caches.metrics.set(cacheKey, output);
|
|
2075
|
+
|
|
1550
2076
|
return {
|
|
1551
2077
|
content: [
|
|
1552
2078
|
{
|
|
1553
2079
|
type: 'text',
|
|
1554
|
-
text:
|
|
1555
|
-
`⏱️ Time Window: ${timeWindowDays} days\n\n` +
|
|
1556
|
-
`📈 Overall Performance:\n` +
|
|
1557
|
-
` • Total Episodes: ${metrics.overall.totalEpisodes}\n` +
|
|
1558
|
-
` • Success Rate: ${(metrics.overall.successRate * 100).toFixed(1)}%\n` +
|
|
1559
|
-
` • Avg Reward: ${metrics.overall.avgReward.toFixed(3)}\n` +
|
|
1560
|
-
` • Reward Range: [${metrics.overall.minReward.toFixed(2)}, ${metrics.overall.maxReward.toFixed(2)}]\n` +
|
|
1561
|
-
` • Avg Latency: ${metrics.overall.avgLatencyMs.toFixed(0)}ms\n\n` +
|
|
1562
|
-
`🎯 Top ${groupBy.charAt(0).toUpperCase() + groupBy.slice(1)}s:\n` +
|
|
1563
|
-
metrics.groupedMetrics.slice(0, 5).map((g, i) =>
|
|
1564
|
-
` ${i + 1}. ${g.key.substring(0, 40)}${g.key.length > 40 ? '...' : ''}\n` +
|
|
1565
|
-
` Count: ${g.count}, Success: ${(g.successRate * 100).toFixed(1)}%, Reward: ${g.avgReward.toFixed(2)}`
|
|
1566
|
-
).join('\n') +
|
|
1567
|
-
(metrics.groupedMetrics.length === 0 ? ' No data available' : '') +
|
|
1568
|
-
(includeTrends && metrics.trends.length > 0 ? `\n\n📉 Recent Trends (last ${Math.min(7, metrics.trends.length)} days):\n` +
|
|
1569
|
-
metrics.trends.slice(-7).map((t) =>
|
|
1570
|
-
` ${t.date}: ${t.count} episodes, ${(t.successRate * 100).toFixed(1)}% success`
|
|
1571
|
-
).join('\n') : '') +
|
|
1572
|
-
(metrics.policyImprovement.versions > 0 ? `\n\n🧠 Policy Improvement:\n` +
|
|
1573
|
-
` • Versions: ${metrics.policyImprovement.versions}\n` +
|
|
1574
|
-
` • Q-Value Improvement: ${metrics.policyImprovement.qValueImprovement >= 0 ? '+' : ''}${metrics.policyImprovement.qValueImprovement.toFixed(3)}` : ''),
|
|
2080
|
+
text: output,
|
|
1575
2081
|
},
|
|
1576
2082
|
],
|
|
1577
2083
|
};
|
|
@@ -1777,12 +2283,12 @@ async function main() {
|
|
|
1777
2283
|
const transport = new StdioServerTransport();
|
|
1778
2284
|
await server.connect(transport);
|
|
1779
2285
|
|
|
1780
|
-
console.error('🚀 AgentDB MCP Server
|
|
1781
|
-
console.error('📦
|
|
2286
|
+
console.error('🚀 AgentDB MCP Server v2.0.0 running on stdio');
|
|
2287
|
+
console.error('📦 32 tools available (5 core + 9 frontier + 10 learning + 5 AgentDB + 3 batch ops)');
|
|
1782
2288
|
console.error('🧠 Embedding service initialized');
|
|
1783
2289
|
console.error('🎓 Learning system ready (9 RL algorithms)');
|
|
1784
|
-
console.error('
|
|
1785
|
-
console.error('🔬
|
|
2290
|
+
console.error('⚡ NEW v2.0: Batch operations (3-4x faster), format parameters, enhanced validation');
|
|
2291
|
+
console.error('🔬 Features: transfer learning, XAI explanations, reward shaping, intelligent caching');
|
|
1786
2292
|
|
|
1787
2293
|
// Keep the process alive - the StdioServerTransport handles stdin/stdout
|
|
1788
2294
|
// but we need to ensure Node.js doesn't exit when main() completes
|