agentdb 1.0.11 → 1.1.0
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 +196 -838
- package/dist/benchmarks/comprehensive-benchmark.js +664 -0
- package/dist/benchmarks/frontier-benchmark.js +419 -0
- package/dist/benchmarks/reflexion-benchmark.js +370 -0
- package/dist/cli/agentdb-cli.d.ts +117 -0
- package/dist/cli/agentdb-cli.d.ts.map +1 -0
- package/dist/cli/agentdb-cli.js +718 -0
- package/dist/cli/agentdb-cli.js.map +1 -0
- package/dist/controllers/CausalMemoryGraph.d.ts +125 -0
- package/dist/controllers/CausalMemoryGraph.d.ts.map +1 -0
- package/dist/controllers/CausalMemoryGraph.js +323 -0
- package/dist/controllers/CausalMemoryGraph.js.map +1 -0
- package/dist/controllers/CausalRecall.d.ts +111 -0
- package/dist/controllers/CausalRecall.d.ts.map +1 -0
- package/dist/controllers/CausalRecall.js +282 -0
- package/dist/controllers/CausalRecall.js.map +1 -0
- package/dist/controllers/EmbeddingService.d.ts +37 -0
- package/dist/controllers/EmbeddingService.d.ts.map +1 -0
- package/dist/controllers/EmbeddingService.js +119 -0
- package/dist/controllers/EmbeddingService.js.map +1 -0
- package/dist/controllers/ExplainableRecall.d.ts +138 -0
- package/dist/controllers/ExplainableRecall.d.ts.map +1 -0
- package/dist/controllers/ExplainableRecall.js +388 -0
- package/dist/controllers/ExplainableRecall.js.map +1 -0
- package/dist/controllers/NightlyLearner.d.ts +113 -0
- package/dist/controllers/NightlyLearner.d.ts.map +1 -0
- package/dist/controllers/NightlyLearner.js +383 -0
- package/dist/controllers/NightlyLearner.js.map +1 -0
- package/dist/controllers/ReflexionMemory.d.ts +84 -0
- package/dist/controllers/ReflexionMemory.d.ts.map +1 -0
- package/dist/controllers/ReflexionMemory.js +240 -0
- package/dist/controllers/ReflexionMemory.js.map +1 -0
- package/dist/controllers/SkillLibrary.d.ts +96 -0
- package/dist/controllers/SkillLibrary.d.ts.map +1 -0
- package/dist/controllers/SkillLibrary.js +277 -0
- package/dist/controllers/SkillLibrary.js.map +1 -0
- package/dist/controllers/frontier-index.d.ts +14 -0
- package/dist/controllers/frontier-index.d.ts.map +1 -0
- package/dist/controllers/frontier-index.js +10 -0
- package/dist/controllers/frontier-index.js.map +1 -0
- package/dist/controllers/index.d.ts +12 -0
- package/dist/controllers/index.d.ts.map +1 -0
- package/dist/controllers/index.js +9 -0
- package/dist/controllers/index.js.map +1 -0
- package/dist/optimizations/BatchOperations.d.ts +61 -0
- package/dist/optimizations/BatchOperations.d.ts.map +1 -0
- package/dist/optimizations/BatchOperations.js +199 -0
- package/dist/optimizations/BatchOperations.js.map +1 -0
- package/dist/optimizations/QueryOptimizer.d.ts +82 -0
- package/dist/optimizations/QueryOptimizer.d.ts.map +1 -0
- package/dist/optimizations/QueryOptimizer.js +226 -0
- package/dist/optimizations/QueryOptimizer.js.map +1 -0
- package/dist/optimizations/index.d.ts +10 -0
- package/dist/optimizations/index.d.ts.map +1 -0
- package/dist/optimizations/index.js +8 -0
- package/dist/optimizations/index.js.map +1 -0
- package/dist/schemas/frontier-schema.sql +341 -0
- package/dist/schemas/schema.sql +382 -0
- package/dist/tests/frontier-features.test.js +665 -0
- package/package.json +54 -117
- package/src/cli/agentdb-cli.ts +861 -0
- package/src/cli/examples.sh +83 -0
- package/src/controllers/CausalMemoryGraph.ts +504 -0
- package/src/controllers/CausalRecall.ts +395 -0
- package/src/controllers/EmbeddingService.ts +141 -0
- package/src/controllers/ExplainableRecall.ts +577 -0
- package/src/controllers/NightlyLearner.ts +475 -0
- package/src/controllers/ReflexionMemory.ts +349 -0
- package/src/controllers/SkillLibrary.ts +391 -0
- package/src/controllers/frontier-index.ts +35 -0
- package/src/controllers/index.ts +13 -0
- package/src/optimizations/BatchOperations.ts +292 -0
- package/src/optimizations/QueryOptimizer.ts +294 -0
- package/src/optimizations/index.ts +11 -0
- package/src/schemas/frontier-schema.sql +341 -0
- package/src/schemas/schema.sql +382 -0
- package/CHANGELOG.md +0 -166
- package/LICENSE +0 -38
- package/LICENSE-APACHE +0 -190
- package/LICENSE-MIT +0 -21
- package/bin/agentdb.js +0 -733
- package/bin/benchmark.js +0 -162
- package/bin/plugin-cli-wrapper.mjs +0 -21
- package/dist/agentdb.js +0 -5352
- package/dist/agentdb.js.map +0 -7
- package/dist/agentdb.min.js +0 -143
- package/dist/agentdb.min.js.map +0 -7
- package/dist/cache/query-cache.d.ts +0 -105
- package/dist/cache/query-cache.d.ts.map +0 -1
- package/dist/cache/query-cache.js +0 -224
- package/dist/cache/query-cache.js.map +0 -1
- package/dist/cache/query-cache.mjs +0 -219
- package/dist/cli/cache/query-cache.d.ts +0 -104
- package/dist/cli/cache/query-cache.js +0 -244
- package/dist/cli/cli/db-commands.d.ts +0 -48
- package/dist/cli/cli/db-commands.js +0 -613
- package/dist/cli/commands.d.ts +0 -7
- package/dist/cli/commands.d.ts.map +0 -1
- package/dist/cli/commands.js +0 -113
- package/dist/cli/commands.js.map +0 -1
- package/dist/cli/commands.mjs +0 -104
- package/dist/cli/core/backend-interface.d.ts +0 -70
- package/dist/cli/core/backend-interface.js +0 -15
- package/dist/cli/core/native-backend.d.ts +0 -140
- package/dist/cli/core/native-backend.js +0 -432
- package/dist/cli/core/vector-db.d.ts +0 -126
- package/dist/cli/core/vector-db.js +0 -338
- package/dist/cli/core/wasm-backend.d.ts +0 -95
- package/dist/cli/core/wasm-backend.js +0 -418
- package/dist/cli/db-commands.d.ts +0 -49
- package/dist/cli/db-commands.d.ts.map +0 -1
- package/dist/cli/db-commands.js +0 -533
- package/dist/cli/db-commands.js.map +0 -1
- package/dist/cli/db-commands.mjs +0 -522
- package/dist/cli/generator.d.ts +0 -11
- package/dist/cli/generator.d.ts.map +0 -1
- package/dist/cli/generator.js +0 -567
- package/dist/cli/generator.js.map +0 -1
- package/dist/cli/generator.mjs +0 -527
- package/dist/cli/help.d.ts +0 -18
- package/dist/cli/help.d.ts.map +0 -1
- package/dist/cli/help.js +0 -676
- package/dist/cli/help.js.map +0 -1
- package/dist/cli/help.mjs +0 -667
- package/dist/cli/index/hnsw.d.ts +0 -164
- package/dist/cli/index/hnsw.js +0 -558
- package/dist/cli/plugin-cli.d.ts +0 -7
- package/dist/cli/plugin-cli.d.ts.map +0 -1
- package/dist/cli/plugin-cli.js +0 -295
- package/dist/cli/plugin-cli.js.map +0 -1
- package/dist/cli/plugin-cli.mjs +0 -289
- package/dist/cli/quantization/product-quantization.d.ts +0 -108
- package/dist/cli/quantization/product-quantization.js +0 -350
- package/dist/cli/query/query-builder.d.ts +0 -322
- package/dist/cli/query/query-builder.js +0 -600
- package/dist/cli/templates.d.ts +0 -14
- package/dist/cli/templates.d.ts.map +0 -1
- package/dist/cli/templates.js +0 -182
- package/dist/cli/templates.js.map +0 -1
- package/dist/cli/templates.mjs +0 -176
- package/dist/cli/types/index.d.ts +0 -116
- package/dist/cli/types/index.js +0 -5
- package/dist/cli/types.d.ts +0 -91
- package/dist/cli/types.d.ts.map +0 -1
- package/dist/cli/types.js +0 -6
- package/dist/cli/types.js.map +0 -1
- package/dist/cli/types.mjs +0 -4
- package/dist/cli/wizard/index.d.ts +0 -6
- package/dist/cli/wizard/index.d.ts.map +0 -1
- package/dist/cli/wizard/index.js +0 -138
- package/dist/cli/wizard/index.js.map +0 -1
- package/dist/cli/wizard/index.mjs +0 -131
- package/dist/cli/wizard/prompts.d.ts +0 -11
- package/dist/cli/wizard/prompts.d.ts.map +0 -1
- package/dist/cli/wizard/prompts.js +0 -482
- package/dist/cli/wizard/prompts.js.map +0 -1
- package/dist/cli/wizard/prompts.mjs +0 -470
- package/dist/cli/wizard/validator.d.ts +0 -13
- package/dist/cli/wizard/validator.d.ts.map +0 -1
- package/dist/cli/wizard/validator.js +0 -234
- package/dist/cli/wizard/validator.js.map +0 -1
- package/dist/cli/wizard/validator.mjs +0 -224
- package/dist/core/backend-interface.d.ts +0 -71
- package/dist/core/backend-interface.d.ts.map +0 -1
- package/dist/core/backend-interface.js +0 -16
- package/dist/core/backend-interface.js.map +0 -1
- package/dist/core/backend-interface.mjs +0 -12
- package/dist/core/native-backend.d.ts +0 -141
- package/dist/core/native-backend.d.ts.map +0 -1
- package/dist/core/native-backend.js +0 -457
- package/dist/core/native-backend.js.map +0 -1
- package/dist/core/native-backend.mjs +0 -449
- package/dist/core/vector-db.d.ts +0 -127
- package/dist/core/vector-db.d.ts.map +0 -1
- package/dist/core/vector-db.js +0 -270
- package/dist/core/vector-db.js.map +0 -1
- package/dist/core/vector-db.mjs +0 -265
- package/dist/core/wasm-backend.d.ts +0 -96
- package/dist/core/wasm-backend.d.ts.map +0 -1
- package/dist/core/wasm-backend.js +0 -393
- package/dist/core/wasm-backend.js.map +0 -1
- package/dist/core/wasm-backend.mjs +0 -385
- package/dist/index/hnsw-optimized.d.ts +0 -75
- package/dist/index/hnsw-optimized.d.ts.map +0 -1
- package/dist/index/hnsw-optimized.js +0 -412
- package/dist/index/hnsw-optimized.js.map +0 -1
- package/dist/index/hnsw-optimized.mjs +0 -407
- package/dist/index/hnsw.d.ts +0 -165
- package/dist/index/hnsw.d.ts.map +0 -1
- package/dist/index/hnsw.js +0 -521
- package/dist/index/hnsw.js.map +0 -1
- package/dist/index/hnsw.mjs +0 -516
- package/dist/index.browser.d.ts +0 -47
- package/dist/index.browser.d.ts.map +0 -1
- package/dist/index.browser.js +0 -72
- package/dist/index.browser.js.map +0 -1
- package/dist/index.browser.mjs +0 -54
- package/dist/index.d.ts +0 -59
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -84
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -65
- package/dist/mcp/learning/core/experience-buffer.d.ts +0 -61
- package/dist/mcp/learning/core/experience-buffer.d.ts.map +0 -1
- package/dist/mcp/learning/core/experience-buffer.js +0 -175
- package/dist/mcp/learning/core/experience-buffer.js.map +0 -1
- package/dist/mcp/learning/core/experience-buffer.mjs +0 -170
- package/dist/mcp/learning/core/experience-recorder.d.ts +0 -40
- package/dist/mcp/learning/core/experience-recorder.d.ts.map +0 -1
- package/dist/mcp/learning/core/experience-recorder.js +0 -200
- package/dist/mcp/learning/core/experience-recorder.js.map +0 -1
- package/dist/mcp/learning/core/experience-recorder.mjs +0 -195
- package/dist/mcp/learning/core/learning-manager.d.ts +0 -66
- package/dist/mcp/learning/core/learning-manager.d.ts.map +0 -1
- package/dist/mcp/learning/core/learning-manager.js +0 -252
- package/dist/mcp/learning/core/learning-manager.js.map +0 -1
- package/dist/mcp/learning/core/learning-manager.mjs +0 -247
- package/dist/mcp/learning/core/policy-optimizer.d.ts +0 -53
- package/dist/mcp/learning/core/policy-optimizer.d.ts.map +0 -1
- package/dist/mcp/learning/core/policy-optimizer.js +0 -251
- package/dist/mcp/learning/core/policy-optimizer.js.map +0 -1
- package/dist/mcp/learning/core/policy-optimizer.mjs +0 -246
- package/dist/mcp/learning/core/reward-estimator.d.ts +0 -44
- package/dist/mcp/learning/core/reward-estimator.d.ts.map +0 -1
- package/dist/mcp/learning/core/reward-estimator.js +0 -158
- package/dist/mcp/learning/core/reward-estimator.js.map +0 -1
- package/dist/mcp/learning/core/reward-estimator.mjs +0 -153
- package/dist/mcp/learning/core/session-manager.d.ts +0 -63
- package/dist/mcp/learning/core/session-manager.d.ts.map +0 -1
- package/dist/mcp/learning/core/session-manager.js +0 -202
- package/dist/mcp/learning/core/session-manager.js.map +0 -1
- package/dist/mcp/learning/core/session-manager.mjs +0 -197
- package/dist/mcp/learning/index.d.ts +0 -19
- package/dist/mcp/learning/index.d.ts.map +0 -1
- package/dist/mcp/learning/index.js +0 -30
- package/dist/mcp/learning/index.js.map +0 -1
- package/dist/mcp/learning/index.mjs +0 -19
- package/dist/mcp/learning/tools/mcp-learning-tools.d.ts +0 -369
- package/dist/mcp/learning/tools/mcp-learning-tools.d.ts.map +0 -1
- package/dist/mcp/learning/tools/mcp-learning-tools.js +0 -361
- package/dist/mcp/learning/tools/mcp-learning-tools.js.map +0 -1
- package/dist/mcp/learning/tools/mcp-learning-tools.mjs +0 -356
- package/dist/mcp/learning/types/index.d.ts +0 -138
- package/dist/mcp/learning/types/index.d.ts.map +0 -1
- package/dist/mcp/learning/types/index.js +0 -6
- package/dist/mcp/learning/types/index.js.map +0 -1
- package/dist/mcp/learning/types/index.mjs +0 -4
- package/dist/mcp-server.d.ts +0 -29
- package/dist/mcp-server.d.ts.map +0 -1
- package/dist/mcp-server.js +0 -862
- package/dist/mcp-server.js.map +0 -1
- package/dist/mcp-server.mjs +0 -857
- package/dist/plugins/base-plugin.d.ts +0 -114
- package/dist/plugins/base-plugin.d.ts.map +0 -1
- package/dist/plugins/base-plugin.js +0 -313
- package/dist/plugins/base-plugin.js.map +0 -1
- package/dist/plugins/base-plugin.mjs +0 -275
- package/dist/plugins/implementations/active-learning.d.ts +0 -135
- package/dist/plugins/implementations/active-learning.d.ts.map +0 -1
- package/dist/plugins/implementations/active-learning.js +0 -372
- package/dist/plugins/implementations/active-learning.js.map +0 -1
- package/dist/plugins/implementations/active-learning.mjs +0 -367
- package/dist/plugins/implementations/actor-critic.d.ts +0 -64
- package/dist/plugins/implementations/actor-critic.d.ts.map +0 -1
- package/dist/plugins/implementations/actor-critic.js +0 -363
- package/dist/plugins/implementations/actor-critic.js.map +0 -1
- package/dist/plugins/implementations/actor-critic.mjs +0 -358
- package/dist/plugins/implementations/adversarial-training.d.ts +0 -133
- package/dist/plugins/implementations/adversarial-training.d.ts.map +0 -1
- package/dist/plugins/implementations/adversarial-training.js +0 -409
- package/dist/plugins/implementations/adversarial-training.js.map +0 -1
- package/dist/plugins/implementations/adversarial-training.mjs +0 -404
- package/dist/plugins/implementations/curriculum-learning.d.ts +0 -132
- package/dist/plugins/implementations/curriculum-learning.d.ts.map +0 -1
- package/dist/plugins/implementations/curriculum-learning.js +0 -354
- package/dist/plugins/implementations/curriculum-learning.js.map +0 -1
- package/dist/plugins/implementations/curriculum-learning.mjs +0 -349
- package/dist/plugins/implementations/decision-transformer.d.ts +0 -77
- package/dist/plugins/implementations/decision-transformer.d.ts.map +0 -1
- package/dist/plugins/implementations/decision-transformer.js +0 -422
- package/dist/plugins/implementations/decision-transformer.js.map +0 -1
- package/dist/plugins/implementations/decision-transformer.mjs +0 -417
- package/dist/plugins/implementations/federated-learning.d.ts +0 -126
- package/dist/plugins/implementations/federated-learning.d.ts.map +0 -1
- package/dist/plugins/implementations/federated-learning.js +0 -436
- package/dist/plugins/implementations/federated-learning.js.map +0 -1
- package/dist/plugins/implementations/federated-learning.mjs +0 -431
- package/dist/plugins/implementations/index.d.ts +0 -30
- package/dist/plugins/implementations/index.d.ts.map +0 -1
- package/dist/plugins/implementations/index.js +0 -45
- package/dist/plugins/implementations/index.js.map +0 -1
- package/dist/plugins/implementations/index.mjs +0 -31
- package/dist/plugins/implementations/multi-task-learning.d.ts +0 -115
- package/dist/plugins/implementations/multi-task-learning.d.ts.map +0 -1
- package/dist/plugins/implementations/multi-task-learning.js +0 -369
- package/dist/plugins/implementations/multi-task-learning.js.map +0 -1
- package/dist/plugins/implementations/multi-task-learning.mjs +0 -364
- package/dist/plugins/implementations/neural-architecture-search.d.ts +0 -148
- package/dist/plugins/implementations/neural-architecture-search.d.ts.map +0 -1
- package/dist/plugins/implementations/neural-architecture-search.js +0 -379
- package/dist/plugins/implementations/neural-architecture-search.js.map +0 -1
- package/dist/plugins/implementations/neural-architecture-search.mjs +0 -374
- package/dist/plugins/implementations/q-learning.d.ts +0 -98
- package/dist/plugins/implementations/q-learning.d.ts.map +0 -1
- package/dist/plugins/implementations/q-learning.js +0 -435
- package/dist/plugins/implementations/q-learning.js.map +0 -1
- package/dist/plugins/implementations/q-learning.mjs +0 -430
- package/dist/plugins/implementations/sarsa.d.ts +0 -103
- package/dist/plugins/implementations/sarsa.d.ts.map +0 -1
- package/dist/plugins/implementations/sarsa.js +0 -347
- package/dist/plugins/implementations/sarsa.js.map +0 -1
- package/dist/plugins/implementations/sarsa.mjs +0 -342
- package/dist/plugins/index.d.ts +0 -107
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/index.js +0 -179
- package/dist/plugins/index.js.map +0 -1
- package/dist/plugins/index.mjs +0 -168
- package/dist/plugins/interface.d.ts +0 -439
- package/dist/plugins/interface.d.ts.map +0 -1
- package/dist/plugins/interface.js +0 -12
- package/dist/plugins/interface.js.map +0 -1
- package/dist/plugins/interface.mjs +0 -10
- package/dist/plugins/learning-plugin.interface.d.ts +0 -257
- package/dist/plugins/learning-plugin.interface.d.ts.map +0 -1
- package/dist/plugins/learning-plugin.interface.js +0 -7
- package/dist/plugins/learning-plugin.interface.js.map +0 -1
- package/dist/plugins/learning-plugin.interface.mjs +0 -5
- package/dist/plugins/plugin-exports.d.ts +0 -71
- package/dist/plugins/plugin-exports.d.ts.map +0 -1
- package/dist/plugins/plugin-exports.js +0 -78
- package/dist/plugins/plugin-exports.js.map +0 -1
- package/dist/plugins/plugin-exports.mjs +0 -69
- package/dist/plugins/registry.d.ts +0 -206
- package/dist/plugins/registry.d.ts.map +0 -1
- package/dist/plugins/registry.js +0 -365
- package/dist/plugins/registry.js.map +0 -1
- package/dist/plugins/registry.mjs +0 -356
- package/dist/plugins/validator.d.ts +0 -63
- package/dist/plugins/validator.d.ts.map +0 -1
- package/dist/plugins/validator.js +0 -464
- package/dist/plugins/validator.js.map +0 -1
- package/dist/plugins/validator.mjs +0 -458
- package/dist/presets.d.ts +0 -65
- package/dist/presets.d.ts.map +0 -1
- package/dist/presets.js +0 -145
- package/dist/presets.js.map +0 -1
- package/dist/presets.mjs +0 -140
- package/dist/quantization/binary-quantization.d.ts +0 -104
- package/dist/quantization/binary-quantization.d.ts.map +0 -1
- package/dist/quantization/binary-quantization.js +0 -246
- package/dist/quantization/binary-quantization.js.map +0 -1
- package/dist/quantization/binary-quantization.mjs +0 -240
- package/dist/quantization/optimized-pq.d.ts +0 -138
- package/dist/quantization/optimized-pq.d.ts.map +0 -1
- package/dist/quantization/optimized-pq.js +0 -320
- package/dist/quantization/optimized-pq.js.map +0 -1
- package/dist/quantization/optimized-pq.mjs +0 -313
- package/dist/quantization/product-quantization.d.ts +0 -109
- package/dist/quantization/product-quantization.d.ts.map +0 -1
- package/dist/quantization/product-quantization.js +0 -287
- package/dist/quantization/product-quantization.js.map +0 -1
- package/dist/quantization/product-quantization.mjs +0 -282
- package/dist/quantization/scalar-quantization.d.ts +0 -100
- package/dist/quantization/scalar-quantization.d.ts.map +0 -1
- package/dist/quantization/scalar-quantization.js +0 -324
- package/dist/quantization/scalar-quantization.js.map +0 -1
- package/dist/quantization/scalar-quantization.mjs +0 -319
- package/dist/query/index.d.ts +0 -6
- package/dist/query/index.d.ts.map +0 -1
- package/dist/query/index.js +0 -9
- package/dist/query/index.js.map +0 -1
- package/dist/query/index.mjs +0 -4
- package/dist/query/query-builder.d.ts +0 -323
- package/dist/query/query-builder.d.ts.map +0 -1
- package/dist/query/query-builder.js +0 -524
- package/dist/query/query-builder.js.map +0 -1
- package/dist/query/query-builder.mjs +0 -519
- package/dist/reasoning/context-synthesizer.d.ts +0 -57
- package/dist/reasoning/context-synthesizer.d.ts.map +0 -1
- package/dist/reasoning/context-synthesizer.js +0 -224
- package/dist/reasoning/context-synthesizer.js.map +0 -1
- package/dist/reasoning/context-synthesizer.mjs +0 -219
- package/dist/reasoning/experience-curator.d.ts +0 -66
- package/dist/reasoning/experience-curator.d.ts.map +0 -1
- package/dist/reasoning/experience-curator.js +0 -288
- package/dist/reasoning/experience-curator.js.map +0 -1
- package/dist/reasoning/experience-curator.mjs +0 -283
- package/dist/reasoning/memory-optimizer.d.ts +0 -69
- package/dist/reasoning/memory-optimizer.d.ts.map +0 -1
- package/dist/reasoning/memory-optimizer.js +0 -331
- package/dist/reasoning/memory-optimizer.js.map +0 -1
- package/dist/reasoning/memory-optimizer.mjs +0 -326
- package/dist/reasoning/pattern-matcher.d.ts +0 -59
- package/dist/reasoning/pattern-matcher.d.ts.map +0 -1
- package/dist/reasoning/pattern-matcher.js +0 -229
- package/dist/reasoning/pattern-matcher.js.map +0 -1
- package/dist/reasoning/pattern-matcher.mjs +0 -224
- package/dist/reasoningbank/adapter/agentdb-adapter.d.ts +0 -118
- package/dist/reasoningbank/adapter/agentdb-adapter.d.ts.map +0 -1
- package/dist/reasoningbank/adapter/agentdb-adapter.js +0 -477
- package/dist/reasoningbank/adapter/agentdb-adapter.js.map +0 -1
- package/dist/reasoningbank/adapter/types.d.ts +0 -113
- package/dist/reasoningbank/adapter/types.d.ts.map +0 -1
- package/dist/reasoningbank/adapter/types.js +0 -9
- package/dist/reasoningbank/adapter/types.js.map +0 -1
- package/dist/reasoningbank/cli/commands.d.ts +0 -16
- package/dist/reasoningbank/cli/commands.d.ts.map +0 -1
- package/dist/reasoningbank/cli/commands.js +0 -272
- package/dist/reasoningbank/cli/commands.js.map +0 -1
- package/dist/reasoningbank/mcp/agentdb-tools.d.ts +0 -319
- package/dist/reasoningbank/mcp/agentdb-tools.d.ts.map +0 -1
- package/dist/reasoningbank/mcp/agentdb-tools.js +0 -301
- package/dist/reasoningbank/mcp/agentdb-tools.js.map +0 -1
- package/dist/reasoningbank/migration/migrate.d.ts +0 -25
- package/dist/reasoningbank/migration/migrate.d.ts.map +0 -1
- package/dist/reasoningbank/migration/migrate.js +0 -178
- package/dist/reasoningbank/migration/migrate.js.map +0 -1
- package/dist/reasoningbank/reasoning/context-synthesizer.d.ts +0 -37
- package/dist/reasoningbank/reasoning/context-synthesizer.d.ts.map +0 -1
- package/dist/reasoningbank/reasoning/context-synthesizer.js +0 -114
- package/dist/reasoningbank/reasoning/context-synthesizer.js.map +0 -1
- package/dist/reasoningbank/reasoning/experience-curator.d.ts +0 -39
- package/dist/reasoningbank/reasoning/experience-curator.d.ts.map +0 -1
- package/dist/reasoningbank/reasoning/experience-curator.js +0 -98
- package/dist/reasoningbank/reasoning/experience-curator.js.map +0 -1
- package/dist/reasoningbank/reasoning/memory-optimizer.d.ts +0 -44
- package/dist/reasoningbank/reasoning/memory-optimizer.d.ts.map +0 -1
- package/dist/reasoningbank/reasoning/memory-optimizer.js +0 -184
- package/dist/reasoningbank/reasoning/memory-optimizer.js.map +0 -1
- package/dist/reasoningbank/reasoning/pattern-matcher.d.ts +0 -40
- package/dist/reasoningbank/reasoning/pattern-matcher.d.ts.map +0 -1
- package/dist/reasoningbank/reasoning/pattern-matcher.js +0 -87
- package/dist/reasoningbank/reasoning/pattern-matcher.js.map +0 -1
- package/dist/reasoningbank/sync/quic-sync.d.ts +0 -77
- package/dist/reasoningbank/sync/quic-sync.d.ts.map +0 -1
- package/dist/reasoningbank/sync/quic-sync.js +0 -165
- package/dist/reasoningbank/sync/quic-sync.js.map +0 -1
- package/dist/sync/conflict.d.ts +0 -78
- package/dist/sync/conflict.d.ts.map +0 -1
- package/dist/sync/conflict.js +0 -202
- package/dist/sync/conflict.js.map +0 -1
- package/dist/sync/conflict.mjs +0 -196
- package/dist/sync/coordinator.d.ts +0 -111
- package/dist/sync/coordinator.d.ts.map +0 -1
- package/dist/sync/coordinator.js +0 -256
- package/dist/sync/coordinator.js.map +0 -1
- package/dist/sync/coordinator.mjs +0 -250
- package/dist/sync/delta.d.ts +0 -81
- package/dist/sync/delta.d.ts.map +0 -1
- package/dist/sync/delta.js +0 -245
- package/dist/sync/delta.js.map +0 -1
- package/dist/sync/delta.mjs +0 -238
- package/dist/sync/index.d.ts +0 -11
- package/dist/sync/index.d.ts.map +0 -1
- package/dist/sync/index.js +0 -22
- package/dist/sync/index.js.map +0 -1
- package/dist/sync/index.mjs +0 -9
- package/dist/sync/quic-sync.d.ts +0 -81
- package/dist/sync/quic-sync.d.ts.map +0 -1
- package/dist/sync/quic-sync.js +0 -329
- package/dist/sync/quic-sync.js.map +0 -1
- package/dist/sync/quic-sync.mjs +0 -323
- package/dist/sync/types.d.ts +0 -168
- package/dist/sync/types.d.ts.map +0 -1
- package/dist/sync/types.js +0 -8
- package/dist/sync/types.js.map +0 -1
- package/dist/sync/types.mjs +0 -6
- package/dist/types/index.d.ts +0 -117
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -6
- package/dist/types/index.js.map +0 -1
- package/dist/types/index.mjs +0 -4
- package/dist/wasm/sql-wasm-debug.js +0 -6989
- package/dist/wasm/sql-wasm-debug.wasm +0 -0
- package/dist/wasm/sql-wasm.js +0 -188
- package/dist/wasm/sql-wasm.wasm +0 -0
- package/dist/wasm-loader.d.ts +0 -32
- package/dist/wasm-loader.d.ts.map +0 -1
- package/dist/wasm-loader.js +0 -78
- package/dist/wasm-loader.js.map +0 -1
- package/dist/wasm-loader.mjs +0 -67
- package/examples/adaptive-learning.ts +0 -284
- package/examples/browser/README.md +0 -732
- package/examples/browser/adaptive-recommendations/index.html +0 -427
- package/examples/browser/collaborative-filtering/index.html +0 -310
- package/examples/browser/continual-learning/index.html +0 -736
- package/examples/browser/experience-replay/index.html +0 -616
- package/examples/browser/index.html +0 -369
- package/examples/browser/meta-learning/index.html +0 -789
- package/examples/browser/neuro-symbolic/index.html +0 -692
- package/examples/browser/pattern-learning/index.html +0 -620
- package/examples/browser/quantum-inspired/index.html +0 -728
- package/examples/browser/rag/index.html +0 -624
- package/examples/browser/swarm-intelligence/index.html +0 -811
- package/examples/browser-basic.html +0 -170
- package/examples/browser-wasm-real.html +0 -231
- package/examples/hnsw-example.ts +0 -148
- package/examples/mcp-learning-example.ts +0 -220
- package/examples/node-basic.js +0 -70
- package/examples/quic-sync-example.ts +0 -310
- package/examples/quick-start.js +0 -68
- package/examples/test-v1.0.7-cdn.html +0 -190
- package/examples/wasm-example.ts +0 -222
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReflexionMemory - Episodic Replay Memory System
|
|
3
|
+
*
|
|
4
|
+
* Implements reflexion-style episodic replay for agent self-improvement.
|
|
5
|
+
* Stores self-critiques and outcomes, retrieves relevant past experiences.
|
|
6
|
+
*
|
|
7
|
+
* Based on: "Reflexion: Language Agents with Verbal Reinforcement Learning"
|
|
8
|
+
* https://arxiv.org/abs/2303.11366
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { Database } from 'better-sqlite3';
|
|
12
|
+
import { EmbeddingService } from './EmbeddingService.js';
|
|
13
|
+
|
|
14
|
+
export interface Episode {
|
|
15
|
+
id?: number;
|
|
16
|
+
ts?: number;
|
|
17
|
+
sessionId: string;
|
|
18
|
+
task: string;
|
|
19
|
+
input?: string;
|
|
20
|
+
output?: string;
|
|
21
|
+
critique?: string;
|
|
22
|
+
reward: number;
|
|
23
|
+
success: boolean;
|
|
24
|
+
latencyMs?: number;
|
|
25
|
+
tokensUsed?: number;
|
|
26
|
+
tags?: string[];
|
|
27
|
+
metadata?: Record<string, any>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface EpisodeWithEmbedding extends Episode {
|
|
31
|
+
embedding?: Float32Array;
|
|
32
|
+
similarity?: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface ReflexionQuery {
|
|
36
|
+
task: string;
|
|
37
|
+
currentState?: string;
|
|
38
|
+
k?: number; // Top-k to retrieve
|
|
39
|
+
minReward?: number;
|
|
40
|
+
onlyFailures?: boolean;
|
|
41
|
+
onlySuccesses?: boolean;
|
|
42
|
+
timeWindowDays?: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export class ReflexionMemory {
|
|
46
|
+
private db: Database;
|
|
47
|
+
private embedder: EmbeddingService;
|
|
48
|
+
|
|
49
|
+
constructor(db: Database, embedder: EmbeddingService) {
|
|
50
|
+
this.db = db;
|
|
51
|
+
this.embedder = embedder;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Store a new episode with its critique and outcome
|
|
56
|
+
*/
|
|
57
|
+
async storeEpisode(episode: Episode): Promise<number> {
|
|
58
|
+
const stmt = this.db.prepare(`
|
|
59
|
+
INSERT INTO episodes (
|
|
60
|
+
session_id, task, input, output, critique, reward, success,
|
|
61
|
+
latency_ms, tokens_used, tags, metadata
|
|
62
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
63
|
+
`);
|
|
64
|
+
|
|
65
|
+
const tags = episode.tags ? JSON.stringify(episode.tags) : null;
|
|
66
|
+
const metadata = episode.metadata ? JSON.stringify(episode.metadata) : null;
|
|
67
|
+
|
|
68
|
+
const result = stmt.run(
|
|
69
|
+
episode.sessionId,
|
|
70
|
+
episode.task,
|
|
71
|
+
episode.input || null,
|
|
72
|
+
episode.output || null,
|
|
73
|
+
episode.critique || null,
|
|
74
|
+
episode.reward,
|
|
75
|
+
episode.success ? 1 : 0,
|
|
76
|
+
episode.latencyMs || null,
|
|
77
|
+
episode.tokensUsed || null,
|
|
78
|
+
tags,
|
|
79
|
+
metadata
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const episodeId = result.lastInsertRowid as number;
|
|
83
|
+
|
|
84
|
+
// Generate and store embedding
|
|
85
|
+
const text = this.buildEpisodeText(episode);
|
|
86
|
+
const embedding = await this.embedder.embed(text);
|
|
87
|
+
|
|
88
|
+
this.storeEmbedding(episodeId, embedding);
|
|
89
|
+
|
|
90
|
+
return episodeId;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Retrieve relevant past episodes for a new task attempt
|
|
95
|
+
*/
|
|
96
|
+
async retrieveRelevant(query: ReflexionQuery): Promise<EpisodeWithEmbedding[]> {
|
|
97
|
+
const {
|
|
98
|
+
task,
|
|
99
|
+
currentState = '',
|
|
100
|
+
k = 5,
|
|
101
|
+
minReward,
|
|
102
|
+
onlyFailures = false,
|
|
103
|
+
onlySuccesses = false,
|
|
104
|
+
timeWindowDays
|
|
105
|
+
} = query;
|
|
106
|
+
|
|
107
|
+
// Generate query embedding
|
|
108
|
+
const queryText = currentState ? `${task}\n${currentState}` : task;
|
|
109
|
+
const queryEmbedding = await this.embedder.embed(queryText);
|
|
110
|
+
|
|
111
|
+
// Build SQL filters
|
|
112
|
+
const filters: string[] = [];
|
|
113
|
+
const params: any[] = [];
|
|
114
|
+
|
|
115
|
+
if (minReward !== undefined) {
|
|
116
|
+
filters.push('e.reward >= ?');
|
|
117
|
+
params.push(minReward);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (onlyFailures) {
|
|
121
|
+
filters.push('e.success = 0');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (onlySuccesses) {
|
|
125
|
+
filters.push('e.success = 1');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (timeWindowDays) {
|
|
129
|
+
filters.push('e.ts > strftime("%s", "now") - ?');
|
|
130
|
+
params.push(timeWindowDays * 86400);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const whereClause = filters.length > 0 ? `WHERE ${filters.join(' AND ')}` : '';
|
|
134
|
+
|
|
135
|
+
// Retrieve all candidates
|
|
136
|
+
const stmt = this.db.prepare(`
|
|
137
|
+
SELECT
|
|
138
|
+
e.*,
|
|
139
|
+
ee.embedding
|
|
140
|
+
FROM episodes e
|
|
141
|
+
JOIN episode_embeddings ee ON e.id = ee.episode_id
|
|
142
|
+
${whereClause}
|
|
143
|
+
ORDER BY e.reward DESC
|
|
144
|
+
`);
|
|
145
|
+
|
|
146
|
+
const rows = stmt.all(...params) as any[];
|
|
147
|
+
|
|
148
|
+
// Calculate similarities
|
|
149
|
+
const episodes: EpisodeWithEmbedding[] = rows.map(row => {
|
|
150
|
+
const embedding = this.deserializeEmbedding(row.embedding);
|
|
151
|
+
const similarity = this.cosineSimilarity(queryEmbedding, embedding);
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
id: row.id,
|
|
155
|
+
ts: row.ts,
|
|
156
|
+
sessionId: row.session_id,
|
|
157
|
+
task: row.task,
|
|
158
|
+
input: row.input,
|
|
159
|
+
output: row.output,
|
|
160
|
+
critique: row.critique,
|
|
161
|
+
reward: row.reward,
|
|
162
|
+
success: row.success === 1,
|
|
163
|
+
latencyMs: row.latency_ms,
|
|
164
|
+
tokensUsed: row.tokens_used,
|
|
165
|
+
tags: row.tags ? JSON.parse(row.tags) : undefined,
|
|
166
|
+
metadata: row.metadata ? JSON.parse(row.metadata) : undefined,
|
|
167
|
+
embedding,
|
|
168
|
+
similarity
|
|
169
|
+
};
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Sort by similarity and return top-k
|
|
173
|
+
episodes.sort((a, b) => (b.similarity || 0) - (a.similarity || 0));
|
|
174
|
+
return episodes.slice(0, k);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Get statistics for a task
|
|
179
|
+
*/
|
|
180
|
+
getTaskStats(task: string, timeWindowDays?: number): {
|
|
181
|
+
totalAttempts: number;
|
|
182
|
+
successRate: number;
|
|
183
|
+
avgReward: number;
|
|
184
|
+
avgLatency: number;
|
|
185
|
+
improvementTrend: number;
|
|
186
|
+
} {
|
|
187
|
+
const windowFilter = timeWindowDays
|
|
188
|
+
? `AND ts > strftime('%s', 'now') - ${timeWindowDays * 86400}`
|
|
189
|
+
: '';
|
|
190
|
+
|
|
191
|
+
const stmt = this.db.prepare(`
|
|
192
|
+
SELECT
|
|
193
|
+
COUNT(*) as total,
|
|
194
|
+
AVG(CASE WHEN success = 1 THEN 1.0 ELSE 0.0 END) as success_rate,
|
|
195
|
+
AVG(reward) as avg_reward,
|
|
196
|
+
AVG(latency_ms) as avg_latency
|
|
197
|
+
FROM episodes
|
|
198
|
+
WHERE task = ? ${windowFilter}
|
|
199
|
+
`);
|
|
200
|
+
|
|
201
|
+
const stats = stmt.get(task) as any;
|
|
202
|
+
|
|
203
|
+
// Calculate improvement trend (recent vs older)
|
|
204
|
+
const trendStmt = this.db.prepare(`
|
|
205
|
+
SELECT
|
|
206
|
+
AVG(CASE
|
|
207
|
+
WHEN ts > strftime('%s', 'now') - ${7 * 86400} THEN reward
|
|
208
|
+
END) as recent_reward,
|
|
209
|
+
AVG(CASE
|
|
210
|
+
WHEN ts <= strftime('%s', 'now') - ${7 * 86400} THEN reward
|
|
211
|
+
END) as older_reward
|
|
212
|
+
FROM episodes
|
|
213
|
+
WHERE task = ? ${windowFilter}
|
|
214
|
+
`);
|
|
215
|
+
|
|
216
|
+
const trend = trendStmt.get(task) as any;
|
|
217
|
+
const improvementTrend = trend.recent_reward && trend.older_reward
|
|
218
|
+
? (trend.recent_reward - trend.older_reward) / trend.older_reward
|
|
219
|
+
: 0;
|
|
220
|
+
|
|
221
|
+
return {
|
|
222
|
+
totalAttempts: stats.total || 0,
|
|
223
|
+
successRate: stats.success_rate || 0,
|
|
224
|
+
avgReward: stats.avg_reward || 0,
|
|
225
|
+
avgLatency: stats.avg_latency || 0,
|
|
226
|
+
improvementTrend
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Build critique summary from similar failed episodes
|
|
232
|
+
*/
|
|
233
|
+
async getCritiqueSummary(query: ReflexionQuery): Promise<string> {
|
|
234
|
+
const failures = await this.retrieveRelevant({
|
|
235
|
+
...query,
|
|
236
|
+
onlyFailures: true,
|
|
237
|
+
k: 3
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
if (failures.length === 0) {
|
|
241
|
+
return 'No prior failures found for this task.';
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const critiques = failures
|
|
245
|
+
.filter(ep => ep.critique)
|
|
246
|
+
.map((ep, i) => `${i + 1}. ${ep.critique} (reward: ${ep.reward.toFixed(2)})`)
|
|
247
|
+
.join('\n');
|
|
248
|
+
|
|
249
|
+
return `Prior failures and lessons learned:\n${critiques}`;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Get successful strategies for a task
|
|
254
|
+
*/
|
|
255
|
+
async getSuccessStrategies(query: ReflexionQuery): Promise<string> {
|
|
256
|
+
const successes = await this.retrieveRelevant({
|
|
257
|
+
...query,
|
|
258
|
+
onlySuccesses: true,
|
|
259
|
+
minReward: 0.7,
|
|
260
|
+
k: 3
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
if (successes.length === 0) {
|
|
264
|
+
return 'No successful strategies found for this task.';
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const strategies = successes
|
|
268
|
+
.map((ep, i) => {
|
|
269
|
+
const approach = ep.output?.substring(0, 200) || 'No output recorded';
|
|
270
|
+
return `${i + 1}. Approach (reward ${ep.reward.toFixed(2)}): ${approach}...`;
|
|
271
|
+
})
|
|
272
|
+
.join('\n');
|
|
273
|
+
|
|
274
|
+
return `Successful strategies:\n${strategies}`;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Prune low-quality episodes based on TTL and quality threshold
|
|
279
|
+
*/
|
|
280
|
+
pruneEpisodes(config: {
|
|
281
|
+
minReward?: number;
|
|
282
|
+
maxAgeDays?: number;
|
|
283
|
+
keepMinPerTask?: number;
|
|
284
|
+
}): number {
|
|
285
|
+
const { minReward = 0.3, maxAgeDays = 30, keepMinPerTask = 5 } = config;
|
|
286
|
+
|
|
287
|
+
// Keep high-reward episodes and minimum per task
|
|
288
|
+
const stmt = this.db.prepare(`
|
|
289
|
+
DELETE FROM episodes
|
|
290
|
+
WHERE id IN (
|
|
291
|
+
SELECT id FROM (
|
|
292
|
+
SELECT
|
|
293
|
+
id,
|
|
294
|
+
reward,
|
|
295
|
+
ts,
|
|
296
|
+
ROW_NUMBER() OVER (PARTITION BY task ORDER BY reward DESC) as rank
|
|
297
|
+
FROM episodes
|
|
298
|
+
WHERE reward < ?
|
|
299
|
+
AND ts < strftime('%s', 'now') - ?
|
|
300
|
+
) WHERE rank > ?
|
|
301
|
+
)
|
|
302
|
+
`);
|
|
303
|
+
|
|
304
|
+
const result = stmt.run(minReward, maxAgeDays * 86400, keepMinPerTask);
|
|
305
|
+
return result.changes;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// ========================================================================
|
|
309
|
+
// Private Helper Methods
|
|
310
|
+
// ========================================================================
|
|
311
|
+
|
|
312
|
+
private buildEpisodeText(episode: Episode): string {
|
|
313
|
+
const parts = [episode.task];
|
|
314
|
+
if (episode.critique) parts.push(episode.critique);
|
|
315
|
+
if (episode.output) parts.push(episode.output);
|
|
316
|
+
return parts.join('\n');
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
private storeEmbedding(episodeId: number, embedding: Float32Array): void {
|
|
320
|
+
const stmt = this.db.prepare(`
|
|
321
|
+
INSERT INTO episode_embeddings (episode_id, embedding)
|
|
322
|
+
VALUES (?, ?)
|
|
323
|
+
`);
|
|
324
|
+
|
|
325
|
+
stmt.run(episodeId, this.serializeEmbedding(embedding));
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
private serializeEmbedding(embedding: Float32Array): Buffer {
|
|
329
|
+
return Buffer.from(embedding.buffer);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
private deserializeEmbedding(buffer: Buffer): Float32Array {
|
|
333
|
+
return new Float32Array(buffer.buffer, buffer.byteOffset, buffer.length / 4);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
private cosineSimilarity(a: Float32Array, b: Float32Array): number {
|
|
337
|
+
let dotProduct = 0;
|
|
338
|
+
let normA = 0;
|
|
339
|
+
let normB = 0;
|
|
340
|
+
|
|
341
|
+
for (let i = 0; i < a.length; i++) {
|
|
342
|
+
dotProduct += a[i] * b[i];
|
|
343
|
+
normA += a[i] * a[i];
|
|
344
|
+
normB += b[i] * b[i];
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
return dotProduct / (Math.sqrt(normA) * Math.sqrt(normB));
|
|
348
|
+
}
|
|
349
|
+
}
|