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
|
@@ -1,624 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>RAG Self-Learning Example - AgentDB</title>
|
|
7
|
-
<style>
|
|
8
|
-
* {
|
|
9
|
-
margin: 0;
|
|
10
|
-
padding: 0;
|
|
11
|
-
box-sizing: border-box;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
body {
|
|
15
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
16
|
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
17
|
-
min-height: 100vh;
|
|
18
|
-
padding: 2rem;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.container {
|
|
22
|
-
max-width: 1200px;
|
|
23
|
-
margin: 0 auto;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
header {
|
|
27
|
-
background: white;
|
|
28
|
-
border-radius: 12px;
|
|
29
|
-
padding: 2rem;
|
|
30
|
-
margin-bottom: 2rem;
|
|
31
|
-
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
h1 {
|
|
35
|
-
color: #333;
|
|
36
|
-
margin-bottom: 0.5rem;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.subtitle {
|
|
40
|
-
color: #666;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.main-grid {
|
|
44
|
-
display: grid;
|
|
45
|
-
grid-template-columns: 2fr 1fr;
|
|
46
|
-
gap: 2rem;
|
|
47
|
-
margin-bottom: 2rem;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.card {
|
|
51
|
-
background: white;
|
|
52
|
-
border-radius: 12px;
|
|
53
|
-
padding: 2rem;
|
|
54
|
-
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.card h2 {
|
|
58
|
-
color: #333;
|
|
59
|
-
margin-bottom: 1rem;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.query-section {
|
|
63
|
-
margin-bottom: 1.5rem;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
textarea, input[type="text"] {
|
|
67
|
-
width: 100%;
|
|
68
|
-
padding: 0.75rem;
|
|
69
|
-
border: 2px solid #e0e0e0;
|
|
70
|
-
border-radius: 6px;
|
|
71
|
-
font-family: inherit;
|
|
72
|
-
font-size: 1rem;
|
|
73
|
-
resize: vertical;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
textarea:focus, input[type="text"]:focus {
|
|
77
|
-
outline: none;
|
|
78
|
-
border-color: #667eea;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.btn {
|
|
82
|
-
padding: 0.75rem 1.5rem;
|
|
83
|
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
84
|
-
color: white;
|
|
85
|
-
border: none;
|
|
86
|
-
border-radius: 6px;
|
|
87
|
-
font-weight: 600;
|
|
88
|
-
cursor: pointer;
|
|
89
|
-
font-size: 1rem;
|
|
90
|
-
transition: opacity 0.3s ease;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.btn:hover {
|
|
94
|
-
opacity: 0.9;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.btn:disabled {
|
|
98
|
-
opacity: 0.5;
|
|
99
|
-
cursor: not-allowed;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.btn-group {
|
|
103
|
-
display: flex;
|
|
104
|
-
gap: 1rem;
|
|
105
|
-
margin-top: 1rem;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
.response-area {
|
|
109
|
-
background: #f8f9fa;
|
|
110
|
-
border-radius: 6px;
|
|
111
|
-
padding: 1rem;
|
|
112
|
-
min-height: 200px;
|
|
113
|
-
margin-top: 1rem;
|
|
114
|
-
white-space: pre-wrap;
|
|
115
|
-
line-height: 1.6;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
.stat-card {
|
|
119
|
-
background: #f8f9fa;
|
|
120
|
-
border-radius: 6px;
|
|
121
|
-
padding: 1rem;
|
|
122
|
-
margin-bottom: 1rem;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.stat-label {
|
|
126
|
-
color: #666;
|
|
127
|
-
font-size: 0.9rem;
|
|
128
|
-
margin-bottom: 0.25rem;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.stat-value {
|
|
132
|
-
color: #333;
|
|
133
|
-
font-size: 1.5rem;
|
|
134
|
-
font-weight: bold;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
.document-list {
|
|
138
|
-
max-height: 300px;
|
|
139
|
-
overflow-y: auto;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.document-item {
|
|
143
|
-
background: #f8f9fa;
|
|
144
|
-
border-radius: 6px;
|
|
145
|
-
padding: 1rem;
|
|
146
|
-
margin-bottom: 0.5rem;
|
|
147
|
-
cursor: pointer;
|
|
148
|
-
transition: background 0.2s ease;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
.document-item:hover {
|
|
152
|
-
background: #e9ecef;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.document-title {
|
|
156
|
-
font-weight: 600;
|
|
157
|
-
color: #333;
|
|
158
|
-
margin-bottom: 0.25rem;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
.document-preview {
|
|
162
|
-
color: #666;
|
|
163
|
-
font-size: 0.9rem;
|
|
164
|
-
overflow: hidden;
|
|
165
|
-
text-overflow: ellipsis;
|
|
166
|
-
white-space: nowrap;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
.learning-indicator {
|
|
170
|
-
background: #d4edda;
|
|
171
|
-
color: #155724;
|
|
172
|
-
padding: 0.5rem 1rem;
|
|
173
|
-
border-radius: 6px;
|
|
174
|
-
margin-top: 1rem;
|
|
175
|
-
display: none;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
.learning-indicator.show {
|
|
179
|
-
display: block;
|
|
180
|
-
animation: fadeIn 0.3s ease;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
@keyframes fadeIn {
|
|
184
|
-
from { opacity: 0; transform: translateY(-10px); }
|
|
185
|
-
to { opacity: 1; transform: translateY(0); }
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
.feedback-buttons {
|
|
189
|
-
margin-top: 1rem;
|
|
190
|
-
display: flex;
|
|
191
|
-
gap: 0.5rem;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
.feedback-btn {
|
|
195
|
-
padding: 0.5rem 1rem;
|
|
196
|
-
border: 2px solid #e0e0e0;
|
|
197
|
-
background: white;
|
|
198
|
-
border-radius: 6px;
|
|
199
|
-
cursor: pointer;
|
|
200
|
-
transition: all 0.2s ease;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
.feedback-btn:hover {
|
|
204
|
-
border-color: #667eea;
|
|
205
|
-
background: #f8f9fa;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
.feedback-btn.positive {
|
|
209
|
-
border-color: #28a745;
|
|
210
|
-
color: #28a745;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
.feedback-btn.negative {
|
|
214
|
-
border-color: #dc3545;
|
|
215
|
-
color: #dc3545;
|
|
216
|
-
}
|
|
217
|
-
</style>
|
|
218
|
-
</head>
|
|
219
|
-
<body>
|
|
220
|
-
<div class="container">
|
|
221
|
-
<header>
|
|
222
|
-
<h1>📚 RAG Self-Learning System</h1>
|
|
223
|
-
<p class="subtitle">Retrieval-Augmented Generation with Continuous Learning</p>
|
|
224
|
-
</header>
|
|
225
|
-
|
|
226
|
-
<div class="main-grid">
|
|
227
|
-
<div class="card">
|
|
228
|
-
<h2>Query Interface</h2>
|
|
229
|
-
|
|
230
|
-
<div class="query-section">
|
|
231
|
-
<label for="query"><strong>Ask a Question:</strong></label>
|
|
232
|
-
<textarea id="query" rows="3" placeholder="Enter your question here..."></textarea>
|
|
233
|
-
</div>
|
|
234
|
-
|
|
235
|
-
<div class="btn-group">
|
|
236
|
-
<button class="btn" id="submitQuery">Submit Query</button>
|
|
237
|
-
<button class="btn" id="clearBtn">Clear</button>
|
|
238
|
-
</div>
|
|
239
|
-
|
|
240
|
-
<div class="response-area" id="response">No response yet. Try asking a question!</div>
|
|
241
|
-
|
|
242
|
-
<div class="feedback-buttons" id="feedbackButtons" style="display: none;">
|
|
243
|
-
<button class="feedback-btn" id="positiveBtn">👍 Helpful</button>
|
|
244
|
-
<button class="feedback-btn" id="negativeBtn">👎 Not Helpful</button>
|
|
245
|
-
</div>
|
|
246
|
-
|
|
247
|
-
<div class="learning-indicator" id="learningIndicator">
|
|
248
|
-
✨ System learned from your feedback!
|
|
249
|
-
</div>
|
|
250
|
-
</div>
|
|
251
|
-
|
|
252
|
-
<div>
|
|
253
|
-
<div class="card">
|
|
254
|
-
<h2>System Stats</h2>
|
|
255
|
-
|
|
256
|
-
<div class="stat-card">
|
|
257
|
-
<div class="stat-label">Total Documents</div>
|
|
258
|
-
<div class="stat-value" id="docCount">0</div>
|
|
259
|
-
</div>
|
|
260
|
-
|
|
261
|
-
<div class="stat-card">
|
|
262
|
-
<div class="stat-label">Queries Processed</div>
|
|
263
|
-
<div class="stat-value" id="queryCount">0</div>
|
|
264
|
-
</div>
|
|
265
|
-
|
|
266
|
-
<div class="stat-card">
|
|
267
|
-
<div class="stat-label">Learning Rate</div>
|
|
268
|
-
<div class="stat-value" id="learningRate">0%</div>
|
|
269
|
-
</div>
|
|
270
|
-
|
|
271
|
-
<div class="btn-group">
|
|
272
|
-
<button class="btn" id="exportBtn">Export Data</button>
|
|
273
|
-
<button class="btn" id="resetBtn">Reset</button>
|
|
274
|
-
</div>
|
|
275
|
-
</div>
|
|
276
|
-
|
|
277
|
-
<div class="card" style="margin-top: 2rem;">
|
|
278
|
-
<h2>Add Document</h2>
|
|
279
|
-
<input type="text" id="docTitle" placeholder="Document title..." style="margin-bottom: 0.5rem;">
|
|
280
|
-
<textarea id="docContent" rows="4" placeholder="Document content..."></textarea>
|
|
281
|
-
<button class="btn" id="addDocBtn" style="margin-top: 0.5rem;">Add to Knowledge Base</button>
|
|
282
|
-
</div>
|
|
283
|
-
</div>
|
|
284
|
-
</div>
|
|
285
|
-
|
|
286
|
-
<div class="card">
|
|
287
|
-
<h2>Knowledge Base</h2>
|
|
288
|
-
<div class="document-list" id="documentList">
|
|
289
|
-
<p style="color: #666; text-align: center; padding: 2rem;">No documents yet. Add some knowledge!</p>
|
|
290
|
-
</div>
|
|
291
|
-
</div>
|
|
292
|
-
</div>
|
|
293
|
-
|
|
294
|
-
<script type="module">
|
|
295
|
-
/**
|
|
296
|
-
* RAG Self-Learning Example
|
|
297
|
-
*
|
|
298
|
-
* This demonstrates a Retrieval-Augmented Generation system that:
|
|
299
|
-
* 1. Stores documents as vector embeddings
|
|
300
|
-
* 2. Retrieves relevant documents for queries
|
|
301
|
-
* 3. Learns from user feedback to improve retrieval
|
|
302
|
-
* 4. Adapts query understanding based on interaction patterns
|
|
303
|
-
*/
|
|
304
|
-
|
|
305
|
-
// Initialize AgentDB with WASM backend
|
|
306
|
-
let db = null;
|
|
307
|
-
let queryHistory = [];
|
|
308
|
-
let feedbackData = [];
|
|
309
|
-
let currentQueryId = null;
|
|
310
|
-
|
|
311
|
-
async function initDB() {
|
|
312
|
-
// In a real implementation, import AgentDB WASM
|
|
313
|
-
// For this demo, we'll simulate the behavior
|
|
314
|
-
console.log('Initializing AgentDB WASM backend...');
|
|
315
|
-
|
|
316
|
-
// Simulated database
|
|
317
|
-
db = {
|
|
318
|
-
documents: [],
|
|
319
|
-
queries: [],
|
|
320
|
-
patterns: [],
|
|
321
|
-
|
|
322
|
-
async addDocument(doc) {
|
|
323
|
-
// Simulate embedding generation
|
|
324
|
-
const embedding = generateEmbedding(doc.content);
|
|
325
|
-
this.documents.push({
|
|
326
|
-
id: Date.now().toString(),
|
|
327
|
-
title: doc.title,
|
|
328
|
-
content: doc.content,
|
|
329
|
-
embedding: embedding,
|
|
330
|
-
timestamp: Date.now()
|
|
331
|
-
});
|
|
332
|
-
updateStats();
|
|
333
|
-
},
|
|
334
|
-
|
|
335
|
-
async search(query, k = 5) {
|
|
336
|
-
// Simulate vector search
|
|
337
|
-
const queryEmbedding = generateEmbedding(query);
|
|
338
|
-
|
|
339
|
-
// Calculate similarity scores
|
|
340
|
-
const results = this.documents.map(doc => ({
|
|
341
|
-
...doc,
|
|
342
|
-
score: cosineSimilarity(queryEmbedding, doc.embedding)
|
|
343
|
-
}));
|
|
344
|
-
|
|
345
|
-
// Sort by score and return top k
|
|
346
|
-
return results
|
|
347
|
-
.sort((a, b) => b.score - a.score)
|
|
348
|
-
.slice(0, k);
|
|
349
|
-
},
|
|
350
|
-
|
|
351
|
-
async storeQueryPattern(query, results, feedback) {
|
|
352
|
-
// Store query pattern for learning
|
|
353
|
-
this.patterns.push({
|
|
354
|
-
query: query,
|
|
355
|
-
queryEmbedding: generateEmbedding(query),
|
|
356
|
-
results: results,
|
|
357
|
-
feedback: feedback,
|
|
358
|
-
timestamp: Date.now()
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
// Learn from feedback to adjust future retrievals
|
|
362
|
-
if (feedback === 'positive') {
|
|
363
|
-
this.learnFromSuccess(query, results);
|
|
364
|
-
} else if (feedback === 'negative') {
|
|
365
|
-
this.learnFromFailure(query, results);
|
|
366
|
-
}
|
|
367
|
-
},
|
|
368
|
-
|
|
369
|
-
learnFromSuccess(query, results) {
|
|
370
|
-
// Reinforce successful query patterns
|
|
371
|
-
console.log('Learning from successful query:', query);
|
|
372
|
-
// In real implementation: update weights, boost similar document rankings
|
|
373
|
-
},
|
|
374
|
-
|
|
375
|
-
learnFromFailure(query, results) {
|
|
376
|
-
// Learn from unsuccessful queries
|
|
377
|
-
console.log('Learning from unsuccessful query:', query);
|
|
378
|
-
// In real implementation: penalize similar patterns, explore alternatives
|
|
379
|
-
}
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
// Load sample documents
|
|
383
|
-
await loadSampleDocuments();
|
|
384
|
-
updateStats();
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
async function loadSampleDocuments() {
|
|
388
|
-
const samples = [
|
|
389
|
-
{
|
|
390
|
-
title: "What is AgentDB?",
|
|
391
|
-
content: "AgentDB is an ultra-fast agent memory and vector database for AI agents. It works in Node.js and browsers with WASM support, providing blazing-fast vector search and persistent reasoning patterns."
|
|
392
|
-
},
|
|
393
|
-
{
|
|
394
|
-
title: "ReasoningBank Overview",
|
|
395
|
-
content: "ReasoningBank is a built-in memory and learning system for AI agents. It includes PatternMatcher for storing reasoning patterns, ExperienceCurator for managing task experiences, and MemoryOptimizer for efficient long-term storage."
|
|
396
|
-
},
|
|
397
|
-
{
|
|
398
|
-
title: "HNSW Index",
|
|
399
|
-
content: "The Hierarchical Navigable Small World (HNSW) index provides 12x faster search with 97% recall accuracy. It uses a graph-based structure for approximate nearest neighbor search at scale."
|
|
400
|
-
}
|
|
401
|
-
];
|
|
402
|
-
|
|
403
|
-
for (const doc of samples) {
|
|
404
|
-
await db.addDocument(doc);
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
function generateEmbedding(text) {
|
|
409
|
-
// Simulate embedding generation (in real app, use OpenAI/Cohere/local model)
|
|
410
|
-
// Simple bag-of-words hash for demo
|
|
411
|
-
const words = text.toLowerCase().split(/\s+/);
|
|
412
|
-
const embedding = new Array(384).fill(0); // Simulate 384-dim embedding
|
|
413
|
-
|
|
414
|
-
words.forEach((word, i) => {
|
|
415
|
-
const hash = simpleHash(word);
|
|
416
|
-
for (let j = 0; j < embedding.length; j++) {
|
|
417
|
-
embedding[j] += Math.sin(hash * (j + 1)) * 0.1;
|
|
418
|
-
}
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
// Normalize
|
|
422
|
-
const norm = Math.sqrt(embedding.reduce((sum, val) => sum + val * val, 0));
|
|
423
|
-
return embedding.map(val => val / norm);
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
function simpleHash(str) {
|
|
427
|
-
let hash = 0;
|
|
428
|
-
for (let i = 0; i < str.length; i++) {
|
|
429
|
-
hash = ((hash << 5) - hash) + str.charCodeAt(i);
|
|
430
|
-
hash = hash & hash;
|
|
431
|
-
}
|
|
432
|
-
return hash;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
function cosineSimilarity(a, b) {
|
|
436
|
-
let dot = 0, normA = 0, normB = 0;
|
|
437
|
-
for (let i = 0; i < a.length; i++) {
|
|
438
|
-
dot += a[i] * b[i];
|
|
439
|
-
normA += a[i] * a[i];
|
|
440
|
-
normB += b[i] * b[i];
|
|
441
|
-
}
|
|
442
|
-
return dot / (Math.sqrt(normA) * Math.sqrt(normB));
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
async function handleQuery() {
|
|
446
|
-
const query = document.getElementById('query').value.trim();
|
|
447
|
-
if (!query) return;
|
|
448
|
-
|
|
449
|
-
const responseArea = document.getElementById('response');
|
|
450
|
-
responseArea.textContent = 'Searching knowledge base...';
|
|
451
|
-
|
|
452
|
-
// Search for relevant documents
|
|
453
|
-
const results = await db.search(query, 3);
|
|
454
|
-
|
|
455
|
-
// Generate response from retrieved documents
|
|
456
|
-
let response = `Found ${results.length} relevant documents:\n\n`;
|
|
457
|
-
|
|
458
|
-
if (results.length > 0) {
|
|
459
|
-
results.forEach((doc, i) => {
|
|
460
|
-
response += `${i + 1}. ${doc.title} (${(doc.score * 100).toFixed(1)}% match)\n`;
|
|
461
|
-
response += ` ${doc.content.substring(0, 150)}...\n\n`;
|
|
462
|
-
});
|
|
463
|
-
} else {
|
|
464
|
-
response = "No relevant documents found. Try adding more content to the knowledge base!";
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
responseArea.textContent = response;
|
|
468
|
-
|
|
469
|
-
// Store query for feedback learning
|
|
470
|
-
currentQueryId = Date.now().toString();
|
|
471
|
-
queryHistory.push({
|
|
472
|
-
id: currentQueryId,
|
|
473
|
-
query: query,
|
|
474
|
-
results: results,
|
|
475
|
-
timestamp: Date.now()
|
|
476
|
-
});
|
|
477
|
-
|
|
478
|
-
// Show feedback buttons
|
|
479
|
-
document.getElementById('feedbackButtons').style.display = 'flex';
|
|
480
|
-
|
|
481
|
-
// Update stats
|
|
482
|
-
document.getElementById('queryCount').textContent = queryHistory.length;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
function handleFeedback(isPositive) {
|
|
486
|
-
if (!currentQueryId) return;
|
|
487
|
-
|
|
488
|
-
const query = queryHistory.find(q => q.id === currentQueryId);
|
|
489
|
-
if (!query) return;
|
|
490
|
-
|
|
491
|
-
const feedback = isPositive ? 'positive' : 'negative';
|
|
492
|
-
|
|
493
|
-
// Store feedback for learning
|
|
494
|
-
db.storeQueryPattern(query.query, query.results, feedback);
|
|
495
|
-
feedbackData.push({
|
|
496
|
-
queryId: currentQueryId,
|
|
497
|
-
feedback: feedback,
|
|
498
|
-
timestamp: Date.now()
|
|
499
|
-
});
|
|
500
|
-
|
|
501
|
-
// Show learning indicator
|
|
502
|
-
const indicator = document.getElementById('learningIndicator');
|
|
503
|
-
indicator.classList.add('show');
|
|
504
|
-
setTimeout(() => indicator.classList.remove('show'), 3000);
|
|
505
|
-
|
|
506
|
-
// Hide feedback buttons
|
|
507
|
-
document.getElementById('feedbackButtons').style.display = 'none';
|
|
508
|
-
currentQueryId = null;
|
|
509
|
-
|
|
510
|
-
// Update learning rate
|
|
511
|
-
updateStats();
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
async function addDocument() {
|
|
515
|
-
const title = document.getElementById('docTitle').value.trim();
|
|
516
|
-
const content = document.getElementById('docContent').value.trim();
|
|
517
|
-
|
|
518
|
-
if (!title || !content) {
|
|
519
|
-
alert('Please provide both title and content');
|
|
520
|
-
return;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
await db.addDocument({ title, content });
|
|
524
|
-
|
|
525
|
-
// Clear inputs
|
|
526
|
-
document.getElementById('docTitle').value = '';
|
|
527
|
-
document.getElementById('docContent').value = '';
|
|
528
|
-
|
|
529
|
-
// Update document list
|
|
530
|
-
renderDocuments();
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
function renderDocuments() {
|
|
534
|
-
const listEl = document.getElementById('documentList');
|
|
535
|
-
|
|
536
|
-
if (db.documents.length === 0) {
|
|
537
|
-
listEl.innerHTML = '<p style="color: #666; text-align: center; padding: 2rem;">No documents yet. Add some knowledge!</p>';
|
|
538
|
-
return;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
listEl.innerHTML = db.documents.map(doc => `
|
|
542
|
-
<div class="document-item">
|
|
543
|
-
<div class="document-title">${doc.title}</div>
|
|
544
|
-
<div class="document-preview">${doc.content}</div>
|
|
545
|
-
</div>
|
|
546
|
-
`).join('');
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
function updateStats() {
|
|
550
|
-
document.getElementById('docCount').textContent = db.documents.length;
|
|
551
|
-
document.getElementById('queryCount').textContent = queryHistory.length;
|
|
552
|
-
|
|
553
|
-
// Calculate learning rate (positive feedback ratio)
|
|
554
|
-
if (feedbackData.length > 0) {
|
|
555
|
-
const positiveCount = feedbackData.filter(f => f.feedback === 'positive').length;
|
|
556
|
-
const rate = (positiveCount / feedbackData.length * 100).toFixed(0);
|
|
557
|
-
document.getElementById('learningRate').textContent = `${rate}%`;
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
renderDocuments();
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
function exportData() {
|
|
564
|
-
const data = {
|
|
565
|
-
documents: db.documents,
|
|
566
|
-
queries: queryHistory,
|
|
567
|
-
feedback: feedbackData,
|
|
568
|
-
patterns: db.patterns,
|
|
569
|
-
exportDate: new Date().toISOString()
|
|
570
|
-
};
|
|
571
|
-
|
|
572
|
-
const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
|
|
573
|
-
const url = URL.createObjectURL(blob);
|
|
574
|
-
const a = document.createElement('a');
|
|
575
|
-
a.href = url;
|
|
576
|
-
a.download = `rag-data-${Date.now()}.json`;
|
|
577
|
-
a.click();
|
|
578
|
-
URL.revokeObjectURL(url);
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
function reset() {
|
|
582
|
-
if (confirm('Are you sure you want to reset all data?')) {
|
|
583
|
-
queryHistory = [];
|
|
584
|
-
feedbackData = [];
|
|
585
|
-
currentQueryId = null;
|
|
586
|
-
db.documents = [];
|
|
587
|
-
db.queries = [];
|
|
588
|
-
db.patterns = [];
|
|
589
|
-
|
|
590
|
-
document.getElementById('query').value = '';
|
|
591
|
-
document.getElementById('response').textContent = 'No response yet. Try asking a question!';
|
|
592
|
-
document.getElementById('feedbackButtons').style.display = 'none';
|
|
593
|
-
|
|
594
|
-
loadSampleDocuments();
|
|
595
|
-
updateStats();
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
// Event listeners
|
|
600
|
-
document.getElementById('submitQuery').addEventListener('click', handleQuery);
|
|
601
|
-
document.getElementById('clearBtn').addEventListener('click', () => {
|
|
602
|
-
document.getElementById('query').value = '';
|
|
603
|
-
document.getElementById('response').textContent = 'No response yet. Try asking a question!';
|
|
604
|
-
document.getElementById('feedbackButtons').style.display = 'none';
|
|
605
|
-
});
|
|
606
|
-
document.getElementById('positiveBtn').addEventListener('click', () => handleFeedback(true));
|
|
607
|
-
document.getElementById('negativeBtn').addEventListener('click', () => handleFeedback(false));
|
|
608
|
-
document.getElementById('addDocBtn').addEventListener('click', addDocument);
|
|
609
|
-
document.getElementById('exportBtn').addEventListener('click', exportData);
|
|
610
|
-
document.getElementById('resetBtn').addEventListener('click', reset);
|
|
611
|
-
|
|
612
|
-
// Enter key to submit
|
|
613
|
-
document.getElementById('query').addEventListener('keypress', (e) => {
|
|
614
|
-
if (e.key === 'Enter' && !e.shiftKey) {
|
|
615
|
-
e.preventDefault();
|
|
616
|
-
handleQuery();
|
|
617
|
-
}
|
|
618
|
-
});
|
|
619
|
-
|
|
620
|
-
// Initialize on load
|
|
621
|
-
initDB();
|
|
622
|
-
</script>
|
|
623
|
-
</body>
|
|
624
|
-
</html>
|