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,582 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Report Store (SQLite)
|
|
3
|
+
*
|
|
4
|
+
* Persistent storage for simulation results with queryable history,
|
|
5
|
+
* trend analysis, and comparison tools.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as sqlite3 from 'sqlite3';
|
|
9
|
+
import { Database, open } from 'sqlite';
|
|
10
|
+
import * as path from 'path';
|
|
11
|
+
import * as fs from 'fs';
|
|
12
|
+
import { AgentDBConfig, SimulationResult } from './simulation-registry';
|
|
13
|
+
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// Types
|
|
16
|
+
// ============================================================================
|
|
17
|
+
|
|
18
|
+
export interface ComparisonReport {
|
|
19
|
+
scenarios: string[];
|
|
20
|
+
metrics: Record<string, {
|
|
21
|
+
values: number[];
|
|
22
|
+
best: number;
|
|
23
|
+
worst: number;
|
|
24
|
+
average: number;
|
|
25
|
+
winner: number; // Index of best run
|
|
26
|
+
}>;
|
|
27
|
+
insights: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface TrendData {
|
|
31
|
+
metric: string;
|
|
32
|
+
points: Array<{
|
|
33
|
+
timestamp: Date;
|
|
34
|
+
value: number;
|
|
35
|
+
runId: number;
|
|
36
|
+
}>;
|
|
37
|
+
trend: 'improving' | 'degrading' | 'stable';
|
|
38
|
+
slope?: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface Regression {
|
|
42
|
+
metric: string;
|
|
43
|
+
baseline: number;
|
|
44
|
+
current: number;
|
|
45
|
+
degradation: number;
|
|
46
|
+
severity: 'minor' | 'major' | 'critical';
|
|
47
|
+
firstDetected: Date;
|
|
48
|
+
affectedRuns: number[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// ============================================================================
|
|
52
|
+
// Report Store
|
|
53
|
+
// ============================================================================
|
|
54
|
+
|
|
55
|
+
export class ReportStore {
|
|
56
|
+
private db: Database | null = null;
|
|
57
|
+
private dbPath: string;
|
|
58
|
+
|
|
59
|
+
constructor(dbPath: string = ':memory:') {
|
|
60
|
+
this.dbPath = dbPath;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// --------------------------------------------------------------------------
|
|
64
|
+
// Initialization
|
|
65
|
+
// --------------------------------------------------------------------------
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Initialize database connection and create schema.
|
|
69
|
+
*/
|
|
70
|
+
async initialize(): Promise<void> {
|
|
71
|
+
// Ensure directory exists
|
|
72
|
+
if (this.dbPath !== ':memory:') {
|
|
73
|
+
const dir = path.dirname(this.dbPath);
|
|
74
|
+
if (!fs.existsSync(dir)) {
|
|
75
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Open database
|
|
80
|
+
this.db = await open({
|
|
81
|
+
filename: this.dbPath,
|
|
82
|
+
driver: sqlite3.Database
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Create schema
|
|
86
|
+
await this.createSchema();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Create database schema.
|
|
91
|
+
*/
|
|
92
|
+
private async createSchema(): Promise<void> {
|
|
93
|
+
if (!this.db) throw new Error('Database not initialized');
|
|
94
|
+
|
|
95
|
+
await this.db.exec(`
|
|
96
|
+
-- Simulation runs
|
|
97
|
+
CREATE TABLE IF NOT EXISTS simulations (
|
|
98
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
99
|
+
scenario_id TEXT NOT NULL,
|
|
100
|
+
scenario_name TEXT NOT NULL,
|
|
101
|
+
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
102
|
+
config_json TEXT NOT NULL,
|
|
103
|
+
profile TEXT,
|
|
104
|
+
agentdb_version TEXT,
|
|
105
|
+
duration_ms INTEGER,
|
|
106
|
+
iterations INTEGER,
|
|
107
|
+
status TEXT CHECK(status IN ('running', 'completed', 'failed', 'cancelled')) DEFAULT 'completed'
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
-- Metrics (normalized for efficient queries)
|
|
111
|
+
CREATE TABLE IF NOT EXISTS metrics (
|
|
112
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
113
|
+
simulation_id INTEGER REFERENCES simulations(id) ON DELETE CASCADE,
|
|
114
|
+
metric_name TEXT NOT NULL,
|
|
115
|
+
metric_value REAL NOT NULL,
|
|
116
|
+
iteration INTEGER DEFAULT 0,
|
|
117
|
+
UNIQUE(simulation_id, metric_name, iteration)
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
-- Insights and recommendations
|
|
121
|
+
CREATE TABLE IF NOT EXISTS insights (
|
|
122
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
123
|
+
simulation_id INTEGER REFERENCES simulations(id) ON DELETE CASCADE,
|
|
124
|
+
type TEXT CHECK(type IN ('insight', 'recommendation', 'warning')) NOT NULL,
|
|
125
|
+
content TEXT NOT NULL,
|
|
126
|
+
category TEXT
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
-- Comparison groups (for A/B testing)
|
|
130
|
+
CREATE TABLE IF NOT EXISTS comparison_groups (
|
|
131
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
132
|
+
name TEXT NOT NULL,
|
|
133
|
+
description TEXT,
|
|
134
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
CREATE TABLE IF NOT EXISTS comparison_members (
|
|
138
|
+
group_id INTEGER REFERENCES comparison_groups(id) ON DELETE CASCADE,
|
|
139
|
+
simulation_id INTEGER REFERENCES simulations(id) ON DELETE CASCADE,
|
|
140
|
+
PRIMARY KEY(group_id, simulation_id)
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
-- Indexes for performance
|
|
144
|
+
CREATE INDEX IF NOT EXISTS idx_simulations_scenario ON simulations(scenario_id);
|
|
145
|
+
CREATE INDEX IF NOT EXISTS idx_simulations_timestamp ON simulations(timestamp);
|
|
146
|
+
CREATE INDEX IF NOT EXISTS idx_simulations_status ON simulations(status);
|
|
147
|
+
CREATE INDEX IF NOT EXISTS idx_metrics_simulation ON metrics(simulation_id);
|
|
148
|
+
CREATE INDEX IF NOT EXISTS idx_metrics_name ON metrics(metric_name);
|
|
149
|
+
CREATE INDEX IF NOT EXISTS idx_insights_simulation ON insights(simulation_id);
|
|
150
|
+
`);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Close database connection.
|
|
155
|
+
*/
|
|
156
|
+
async close(): Promise<void> {
|
|
157
|
+
if (this.db) {
|
|
158
|
+
await this.db.close();
|
|
159
|
+
this.db = null;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// --------------------------------------------------------------------------
|
|
164
|
+
// CRUD Operations
|
|
165
|
+
// --------------------------------------------------------------------------
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Save a simulation result.
|
|
169
|
+
*/
|
|
170
|
+
async save(result: SimulationResult): Promise<number> {
|
|
171
|
+
if (!this.db) throw new Error('Database not initialized');
|
|
172
|
+
|
|
173
|
+
// Insert simulation record
|
|
174
|
+
const insertResult = await this.db.run(`
|
|
175
|
+
INSERT INTO simulations (
|
|
176
|
+
scenario_id, scenario_name, timestamp, config_json, profile,
|
|
177
|
+
agentdb_version, duration_ms, iterations, status
|
|
178
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
179
|
+
`, [
|
|
180
|
+
result.scenario,
|
|
181
|
+
result.scenario,
|
|
182
|
+
result.timestamp.toISOString(),
|
|
183
|
+
JSON.stringify(result.config),
|
|
184
|
+
result.config.profile,
|
|
185
|
+
'2.0.0', // TODO: Get from package.json
|
|
186
|
+
result.duration || 0,
|
|
187
|
+
result.iterations || 1,
|
|
188
|
+
'completed'
|
|
189
|
+
]);
|
|
190
|
+
|
|
191
|
+
const simulationId = insertResult.lastID!;
|
|
192
|
+
|
|
193
|
+
// Insert metrics
|
|
194
|
+
for (const [metricName, metricValue] of Object.entries(result.metrics)) {
|
|
195
|
+
await this.db.run(`
|
|
196
|
+
INSERT INTO metrics (simulation_id, metric_name, metric_value)
|
|
197
|
+
VALUES (?, ?, ?)
|
|
198
|
+
`, [simulationId, metricName, metricValue]);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Insert insights
|
|
202
|
+
for (const insight of result.insights) {
|
|
203
|
+
await this.db.run(`
|
|
204
|
+
INSERT INTO insights (simulation_id, type, content, category)
|
|
205
|
+
VALUES (?, ?, ?, ?)
|
|
206
|
+
`, [simulationId, 'insight', insight, 'general']);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Insert recommendations
|
|
210
|
+
for (const recommendation of result.recommendations) {
|
|
211
|
+
await this.db.run(`
|
|
212
|
+
INSERT INTO insights (simulation_id, type, content, category)
|
|
213
|
+
VALUES (?, ?, ?, ?)
|
|
214
|
+
`, [simulationId, 'recommendation', recommendation, 'general']);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return simulationId;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Get simulation by ID.
|
|
222
|
+
*/
|
|
223
|
+
async get(id: number): Promise<SimulationResult | null> {
|
|
224
|
+
if (!this.db) throw new Error('Database not initialized');
|
|
225
|
+
|
|
226
|
+
const simulation = await this.db.get(`
|
|
227
|
+
SELECT * FROM simulations WHERE id = ?
|
|
228
|
+
`, [id]);
|
|
229
|
+
|
|
230
|
+
if (!simulation) return null;
|
|
231
|
+
|
|
232
|
+
// Get metrics
|
|
233
|
+
const metrics = await this.db.all(`
|
|
234
|
+
SELECT metric_name, metric_value FROM metrics
|
|
235
|
+
WHERE simulation_id = ? AND iteration = 0
|
|
236
|
+
`, [id]);
|
|
237
|
+
|
|
238
|
+
// Get insights
|
|
239
|
+
const insights = await this.db.all(`
|
|
240
|
+
SELECT content FROM insights
|
|
241
|
+
WHERE simulation_id = ? AND type = 'insight'
|
|
242
|
+
`, [id]);
|
|
243
|
+
|
|
244
|
+
// Get recommendations
|
|
245
|
+
const recommendations = await this.db.all(`
|
|
246
|
+
SELECT content FROM insights
|
|
247
|
+
WHERE simulation_id = ? AND type = 'recommendation'
|
|
248
|
+
`, [id]);
|
|
249
|
+
|
|
250
|
+
return {
|
|
251
|
+
id: simulation.id,
|
|
252
|
+
scenario: simulation.scenario_id,
|
|
253
|
+
timestamp: new Date(simulation.timestamp),
|
|
254
|
+
config: JSON.parse(simulation.config_json),
|
|
255
|
+
metrics: metrics.reduce((acc, m) => {
|
|
256
|
+
acc[m.metric_name] = m.metric_value;
|
|
257
|
+
return acc;
|
|
258
|
+
}, {} as any),
|
|
259
|
+
insights: insights.map(i => i.content),
|
|
260
|
+
recommendations: recommendations.map(r => r.content),
|
|
261
|
+
iterations: simulation.iterations,
|
|
262
|
+
duration: simulation.duration_ms
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* List recent simulations.
|
|
268
|
+
*/
|
|
269
|
+
async list(limit: number = 10): Promise<SimulationResult[]> {
|
|
270
|
+
if (!this.db) throw new Error('Database not initialized');
|
|
271
|
+
|
|
272
|
+
const simulations = await this.db.all(`
|
|
273
|
+
SELECT id FROM simulations
|
|
274
|
+
ORDER BY timestamp DESC
|
|
275
|
+
LIMIT ?
|
|
276
|
+
`, [limit]);
|
|
277
|
+
|
|
278
|
+
const results: SimulationResult[] = [];
|
|
279
|
+
|
|
280
|
+
for (const sim of simulations) {
|
|
281
|
+
const result = await this.get(sim.id);
|
|
282
|
+
if (result) results.push(result);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return results;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Find simulations by scenario ID.
|
|
290
|
+
*/
|
|
291
|
+
async findByScenario(scenarioId: string): Promise<SimulationResult[]> {
|
|
292
|
+
if (!this.db) throw new Error('Database not initialized');
|
|
293
|
+
|
|
294
|
+
const simulations = await this.db.all(`
|
|
295
|
+
SELECT id FROM simulations
|
|
296
|
+
WHERE scenario_id = ?
|
|
297
|
+
ORDER BY timestamp DESC
|
|
298
|
+
`, [scenarioId]);
|
|
299
|
+
|
|
300
|
+
const results: SimulationResult[] = [];
|
|
301
|
+
|
|
302
|
+
for (const sim of simulations) {
|
|
303
|
+
const result = await this.get(sim.id);
|
|
304
|
+
if (result) results.push(result);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return results;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// --------------------------------------------------------------------------
|
|
311
|
+
// Comparison
|
|
312
|
+
// --------------------------------------------------------------------------
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Compare multiple simulation runs.
|
|
316
|
+
*/
|
|
317
|
+
async compare(ids: number[]): Promise<ComparisonReport> {
|
|
318
|
+
if (!this.db) throw new Error('Database not initialized');
|
|
319
|
+
|
|
320
|
+
const results: SimulationResult[] = [];
|
|
321
|
+
|
|
322
|
+
for (const id of ids) {
|
|
323
|
+
const result = await this.get(id);
|
|
324
|
+
if (result) results.push(result);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (results.length === 0) {
|
|
328
|
+
throw new Error('No valid simulations found for comparison');
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// Collect all metric names
|
|
332
|
+
const allMetrics = new Set<string>();
|
|
333
|
+
for (const result of results) {
|
|
334
|
+
Object.keys(result.metrics).forEach(m => allMetrics.add(m));
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// Build comparison
|
|
338
|
+
const metrics: ComparisonReport['metrics'] = {};
|
|
339
|
+
|
|
340
|
+
for (const metricName of allMetrics) {
|
|
341
|
+
const values = results.map(r => r.metrics[metricName] || 0);
|
|
342
|
+
const best = Math.max(...values);
|
|
343
|
+
const worst = Math.min(...values);
|
|
344
|
+
const average = values.reduce((a, b) => a + b, 0) / values.length;
|
|
345
|
+
const winner = values.indexOf(best);
|
|
346
|
+
|
|
347
|
+
metrics[metricName] = { values, best, worst, average, winner };
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// Generate insights
|
|
351
|
+
const insights: string[] = [];
|
|
352
|
+
|
|
353
|
+
for (const [metricName, data] of Object.entries(metrics)) {
|
|
354
|
+
const improvement = ((data.best - data.worst) / data.worst * 100).toFixed(1);
|
|
355
|
+
insights.push(
|
|
356
|
+
`${metricName}: Best run improved by ${improvement}% over worst`
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return {
|
|
361
|
+
scenarios: results.map(r => r.scenario),
|
|
362
|
+
metrics,
|
|
363
|
+
insights
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// --------------------------------------------------------------------------
|
|
368
|
+
// Trend Analysis
|
|
369
|
+
// --------------------------------------------------------------------------
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Get performance trends for a metric.
|
|
373
|
+
*/
|
|
374
|
+
async getTrends(scenarioId: string, metric: string): Promise<TrendData> {
|
|
375
|
+
if (!this.db) throw new Error('Database not initialized');
|
|
376
|
+
|
|
377
|
+
const rows = await this.db.all(`
|
|
378
|
+
SELECT s.id, s.timestamp, m.metric_value
|
|
379
|
+
FROM simulations s
|
|
380
|
+
JOIN metrics m ON s.id = m.simulation_id
|
|
381
|
+
WHERE s.scenario_id = ? AND m.metric_name = ?
|
|
382
|
+
ORDER BY s.timestamp ASC
|
|
383
|
+
`, [scenarioId, metric]);
|
|
384
|
+
|
|
385
|
+
const points = rows.map(r => ({
|
|
386
|
+
timestamp: new Date(r.timestamp),
|
|
387
|
+
value: r.metric_value,
|
|
388
|
+
runId: r.id
|
|
389
|
+
}));
|
|
390
|
+
|
|
391
|
+
// Calculate trend (simple linear regression)
|
|
392
|
+
const n = points.length;
|
|
393
|
+
if (n < 2) {
|
|
394
|
+
return { metric, points, trend: 'stable' };
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
const timestamps = points.map((p, i) => i); // Use index as x
|
|
398
|
+
const values = points.map(p => p.value);
|
|
399
|
+
|
|
400
|
+
const sumX = timestamps.reduce((a, b) => a + b, 0);
|
|
401
|
+
const sumY = values.reduce((a, b) => a + b, 0);
|
|
402
|
+
const sumXY = timestamps.reduce((sum, x, i) => sum + x * values[i], 0);
|
|
403
|
+
const sumX2 = timestamps.reduce((sum, x) => sum + x * x, 0);
|
|
404
|
+
|
|
405
|
+
const slope = (n * sumXY - sumX * sumY) / (n * sumX2 - sumX * sumX);
|
|
406
|
+
|
|
407
|
+
let trend: 'improving' | 'degrading' | 'stable';
|
|
408
|
+
if (slope > 0.01) trend = 'improving';
|
|
409
|
+
else if (slope < -0.01) trend = 'degrading';
|
|
410
|
+
else trend = 'stable';
|
|
411
|
+
|
|
412
|
+
return { metric, points, trend, slope };
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Detect performance regressions.
|
|
417
|
+
*/
|
|
418
|
+
async detectRegressions(
|
|
419
|
+
scenarioId: string,
|
|
420
|
+
threshold: number = 0.1
|
|
421
|
+
): Promise<Regression[]> {
|
|
422
|
+
if (!this.db) throw new Error('Database not initialized');
|
|
423
|
+
|
|
424
|
+
// Get all metrics for this scenario
|
|
425
|
+
const metricNames = await this.db.all(`
|
|
426
|
+
SELECT DISTINCT m.metric_name
|
|
427
|
+
FROM simulations s
|
|
428
|
+
JOIN metrics m ON s.id = m.simulation_id
|
|
429
|
+
WHERE s.scenario_id = ?
|
|
430
|
+
`, [scenarioId]);
|
|
431
|
+
|
|
432
|
+
const regressions: Regression[] = [];
|
|
433
|
+
|
|
434
|
+
for (const { metric_name } of metricNames) {
|
|
435
|
+
const trend = await this.getTrends(scenarioId, metric_name);
|
|
436
|
+
|
|
437
|
+
if (trend.points.length < 5) continue; // Need at least 5 points
|
|
438
|
+
|
|
439
|
+
// Calculate baseline (moving average of first 3 points)
|
|
440
|
+
const baseline = trend.points.slice(0, 3)
|
|
441
|
+
.reduce((sum, p) => sum + p.value, 0) / 3;
|
|
442
|
+
|
|
443
|
+
// Check recent points (last 2)
|
|
444
|
+
const recent = trend.points.slice(-2);
|
|
445
|
+
|
|
446
|
+
for (const point of recent) {
|
|
447
|
+
const degradation = (baseline - point.value) / baseline;
|
|
448
|
+
|
|
449
|
+
if (degradation > threshold) {
|
|
450
|
+
regressions.push({
|
|
451
|
+
metric: metric_name,
|
|
452
|
+
baseline,
|
|
453
|
+
current: point.value,
|
|
454
|
+
degradation,
|
|
455
|
+
severity: this.getSeverity(degradation),
|
|
456
|
+
firstDetected: point.timestamp,
|
|
457
|
+
affectedRuns: [point.runId]
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
return regressions;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
private getSeverity(degradation: number): 'minor' | 'major' | 'critical' {
|
|
467
|
+
if (degradation > 0.3) return 'critical';
|
|
468
|
+
if (degradation > 0.15) return 'major';
|
|
469
|
+
return 'minor';
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
// --------------------------------------------------------------------------
|
|
473
|
+
// Import/Export
|
|
474
|
+
// --------------------------------------------------------------------------
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Export simulations to JSON.
|
|
478
|
+
*/
|
|
479
|
+
async export(ids: number[]): Promise<string> {
|
|
480
|
+
const results: SimulationResult[] = [];
|
|
481
|
+
|
|
482
|
+
for (const id of ids) {
|
|
483
|
+
const result = await this.get(id);
|
|
484
|
+
if (result) results.push(result);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
return JSON.stringify(results, null, 2);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Import simulations from JSON.
|
|
492
|
+
*/
|
|
493
|
+
async import(json: string): Promise<number[]> {
|
|
494
|
+
const results: SimulationResult[] = JSON.parse(json);
|
|
495
|
+
const ids: number[] = [];
|
|
496
|
+
|
|
497
|
+
for (const result of results) {
|
|
498
|
+
const id = await this.save(result);
|
|
499
|
+
ids.push(id);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
return ids;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Backup database to file.
|
|
507
|
+
*/
|
|
508
|
+
async backup(path: string): Promise<void> {
|
|
509
|
+
if (!this.db || this.dbPath === ':memory:') {
|
|
510
|
+
throw new Error('Cannot backup in-memory database');
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// SQLite backup API
|
|
514
|
+
await this.db.exec(`VACUUM INTO '${path}'`);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// --------------------------------------------------------------------------
|
|
518
|
+
// Statistics
|
|
519
|
+
// --------------------------------------------------------------------------
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Get database statistics.
|
|
523
|
+
*/
|
|
524
|
+
async getStats(): Promise<{
|
|
525
|
+
totalSimulations: number;
|
|
526
|
+
totalMetrics: number;
|
|
527
|
+
totalInsights: number;
|
|
528
|
+
scenarios: { id: string; count: number }[];
|
|
529
|
+
profiles: { profile: string; count: number }[];
|
|
530
|
+
}> {
|
|
531
|
+
if (!this.db) throw new Error('Database not initialized');
|
|
532
|
+
|
|
533
|
+
const totalSimulations = await this.db.get(`
|
|
534
|
+
SELECT COUNT(*) as count FROM simulations
|
|
535
|
+
`);
|
|
536
|
+
|
|
537
|
+
const totalMetrics = await this.db.get(`
|
|
538
|
+
SELECT COUNT(*) as count FROM metrics
|
|
539
|
+
`);
|
|
540
|
+
|
|
541
|
+
const totalInsights = await this.db.get(`
|
|
542
|
+
SELECT COUNT(*) as count FROM insights
|
|
543
|
+
`);
|
|
544
|
+
|
|
545
|
+
const scenarios = await this.db.all(`
|
|
546
|
+
SELECT scenario_id as id, COUNT(*) as count
|
|
547
|
+
FROM simulations
|
|
548
|
+
GROUP BY scenario_id
|
|
549
|
+
ORDER BY count DESC
|
|
550
|
+
`);
|
|
551
|
+
|
|
552
|
+
const profiles = await this.db.all(`
|
|
553
|
+
SELECT profile, COUNT(*) as count
|
|
554
|
+
FROM simulations
|
|
555
|
+
GROUP BY profile
|
|
556
|
+
ORDER BY count DESC
|
|
557
|
+
`);
|
|
558
|
+
|
|
559
|
+
return {
|
|
560
|
+
totalSimulations: totalSimulations.count,
|
|
561
|
+
totalMetrics: totalMetrics.count,
|
|
562
|
+
totalInsights: totalInsights.count,
|
|
563
|
+
scenarios,
|
|
564
|
+
profiles
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// ============================================================================
|
|
570
|
+
// Factory
|
|
571
|
+
// ============================================================================
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Create and initialize a report store.
|
|
575
|
+
*/
|
|
576
|
+
export async function createReportStore(
|
|
577
|
+
dbPath: string = ':memory:'
|
|
578
|
+
): Promise<ReportStore> {
|
|
579
|
+
const store = new ReportStore(dbPath);
|
|
580
|
+
await store.initialize();
|
|
581
|
+
return store;
|
|
582
|
+
}
|