agentdb 1.0.12 → 1.1.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 +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 +724 -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 -165
- 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,190 +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>AgentDB v1.0.7 CDN Test - better-sqlite3 Fix Validation</title>
|
|
7
|
-
<style>
|
|
8
|
-
body {
|
|
9
|
-
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
10
|
-
max-width: 1000px;
|
|
11
|
-
margin: 50px auto;
|
|
12
|
-
padding: 20px;
|
|
13
|
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
14
|
-
color: white;
|
|
15
|
-
}
|
|
16
|
-
.container {
|
|
17
|
-
background: rgba(255, 255, 255, 0.95);
|
|
18
|
-
border-radius: 15px;
|
|
19
|
-
padding: 30px;
|
|
20
|
-
box-shadow: 0 10px 40px rgba(0,0,0,0.3);
|
|
21
|
-
color: #333;
|
|
22
|
-
}
|
|
23
|
-
h1 {
|
|
24
|
-
color: #667eea;
|
|
25
|
-
margin-bottom: 10px;
|
|
26
|
-
}
|
|
27
|
-
.status {
|
|
28
|
-
padding: 15px;
|
|
29
|
-
margin: 15px 0;
|
|
30
|
-
border-radius: 8px;
|
|
31
|
-
font-weight: bold;
|
|
32
|
-
}
|
|
33
|
-
.loading { background: #fff3cd; color: #856404; }
|
|
34
|
-
.success { background: #d4edda; color: #155724; }
|
|
35
|
-
.error { background: #f8d7da; color: #721c24; }
|
|
36
|
-
pre {
|
|
37
|
-
background: #f8f9fa;
|
|
38
|
-
padding: 15px;
|
|
39
|
-
border-radius: 8px;
|
|
40
|
-
overflow-x: auto;
|
|
41
|
-
font-size: 14px;
|
|
42
|
-
}
|
|
43
|
-
.version {
|
|
44
|
-
color: #6c757d;
|
|
45
|
-
font-size: 0.9em;
|
|
46
|
-
}
|
|
47
|
-
.test-results {
|
|
48
|
-
margin-top: 20px;
|
|
49
|
-
}
|
|
50
|
-
.test-item {
|
|
51
|
-
padding: 10px;
|
|
52
|
-
margin: 10px 0;
|
|
53
|
-
border-left: 4px solid #667eea;
|
|
54
|
-
background: #f8f9fa;
|
|
55
|
-
border-radius: 4px;
|
|
56
|
-
}
|
|
57
|
-
.pass { border-left-color: #28a745; }
|
|
58
|
-
.fail { border-left-color: #dc3545; }
|
|
59
|
-
</style>
|
|
60
|
-
</head>
|
|
61
|
-
<body>
|
|
62
|
-
<div class="container">
|
|
63
|
-
<h1>🚀 AgentDB v1.0.7 CDN Test</h1>
|
|
64
|
-
<p class="version">Testing better-sqlite3 fix via unpkg.com CDN</p>
|
|
65
|
-
|
|
66
|
-
<div id="status" class="status loading">
|
|
67
|
-
⏳ Loading AgentDB from CDN...
|
|
68
|
-
</div>
|
|
69
|
-
|
|
70
|
-
<div class="test-results">
|
|
71
|
-
<h3>Test Results:</h3>
|
|
72
|
-
<div id="results"></div>
|
|
73
|
-
</div>
|
|
74
|
-
|
|
75
|
-
<h3>Console Output:</h3>
|
|
76
|
-
<pre id="console"></pre>
|
|
77
|
-
</div>
|
|
78
|
-
|
|
79
|
-
<script type="module">
|
|
80
|
-
const statusEl = document.getElementById('status');
|
|
81
|
-
const resultsEl = document.getElementById('results');
|
|
82
|
-
const consoleEl = document.getElementById('console');
|
|
83
|
-
|
|
84
|
-
let logs = [];
|
|
85
|
-
function log(message, type = 'info') {
|
|
86
|
-
const timestamp = new Date().toLocaleTimeString();
|
|
87
|
-
const logMessage = `[${timestamp}] ${message}`;
|
|
88
|
-
logs.push(logMessage);
|
|
89
|
-
consoleEl.textContent = logs.join('\n');
|
|
90
|
-
console.log(message);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function addTestResult(name, passed, details) {
|
|
94
|
-
const div = document.createElement('div');
|
|
95
|
-
div.className = `test-item ${passed ? 'pass' : 'fail'}`;
|
|
96
|
-
div.innerHTML = `
|
|
97
|
-
<strong>${passed ? '✅' : '❌'} ${name}</strong>
|
|
98
|
-
${details ? `<br><small>${details}</small>` : ''}
|
|
99
|
-
`;
|
|
100
|
-
resultsEl.appendChild(div);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async function runTests() {
|
|
104
|
-
try {
|
|
105
|
-
log('🔍 Attempting to import AgentDB v1.0.7 from unpkg CDN...');
|
|
106
|
-
|
|
107
|
-
// Import from unpkg CDN
|
|
108
|
-
const { SQLiteVectorDB, createVectorDB } = await import('https://unpkg.com/agentdb@1.0.7/dist/agentdb.min.js');
|
|
109
|
-
|
|
110
|
-
log('✅ Successfully loaded AgentDB module!');
|
|
111
|
-
addTestResult('Module Import', true, 'No better-sqlite3 import errors!');
|
|
112
|
-
|
|
113
|
-
// Test 1: Create database instance
|
|
114
|
-
log('🧪 Test 1: Creating SQLiteVectorDB instance...');
|
|
115
|
-
const db = new SQLiteVectorDB({
|
|
116
|
-
memoryMode: true,
|
|
117
|
-
backend: 'wasm'
|
|
118
|
-
});
|
|
119
|
-
addTestResult('Database Instance Creation', true, 'Backend set to WASM');
|
|
120
|
-
|
|
121
|
-
// Test 2: Initialize WASM backend
|
|
122
|
-
log('🧪 Test 2: Initializing WASM backend...');
|
|
123
|
-
await db.initializeAsync();
|
|
124
|
-
log('✅ WASM backend initialized successfully!');
|
|
125
|
-
addTestResult('WASM Initialization', true, 'sql.js loaded without errors');
|
|
126
|
-
|
|
127
|
-
// Test 3: Insert vector
|
|
128
|
-
log('🧪 Test 3: Inserting test vector...');
|
|
129
|
-
const vector1 = {
|
|
130
|
-
id: 'vec1',
|
|
131
|
-
embedding: [0.1, 0.2, 0.3, 0.4, 0.5],
|
|
132
|
-
metadata: { test: 'v1.0.7-fix', type: 'validation' }
|
|
133
|
-
};
|
|
134
|
-
const id1 = db.insert(vector1);
|
|
135
|
-
log(`✅ Inserted vector with ID: ${id1}`);
|
|
136
|
-
addTestResult('Vector Insert', true, `ID: ${id1}`);
|
|
137
|
-
|
|
138
|
-
// Test 4: Search
|
|
139
|
-
log('🧪 Test 4: Searching for similar vectors...');
|
|
140
|
-
const results = db.search([0.1, 0.2, 0.3, 0.4, 0.5], 1);
|
|
141
|
-
log(`✅ Found ${results.length} results, score: ${results[0]?.score}`);
|
|
142
|
-
addTestResult('Vector Search', results.length > 0, `Score: ${results[0]?.score?.toFixed(4)}`);
|
|
143
|
-
|
|
144
|
-
// Test 5: Verify backend type
|
|
145
|
-
log('🧪 Test 5: Verifying backend type...');
|
|
146
|
-
const backendType = db.getBackendType();
|
|
147
|
-
log(`✅ Backend type: ${backendType}`);
|
|
148
|
-
addTestResult('Backend Type Check', backendType === 'wasm', `Using: ${backendType}`);
|
|
149
|
-
|
|
150
|
-
// Test 6: Stats
|
|
151
|
-
log('🧪 Test 6: Getting database stats...');
|
|
152
|
-
const stats = db.stats();
|
|
153
|
-
log(`✅ Database has ${stats.count} vectors, size: ${stats.size} bytes`);
|
|
154
|
-
addTestResult('Database Stats', stats.count === 1, `Vectors: ${stats.count}, Size: ${stats.size}B`);
|
|
155
|
-
|
|
156
|
-
// All tests passed!
|
|
157
|
-
statusEl.textContent = '🎉 All tests passed! The better-sqlite3 fix works perfectly!';
|
|
158
|
-
statusEl.className = 'status success';
|
|
159
|
-
|
|
160
|
-
log('');
|
|
161
|
-
log('=' .repeat(60));
|
|
162
|
-
log('🎉 VALIDATION SUCCESSFUL!');
|
|
163
|
-
log('✅ No better-sqlite3 import errors');
|
|
164
|
-
log('✅ WASM backend works correctly');
|
|
165
|
-
log('✅ All vector operations functional');
|
|
166
|
-
log('✅ AgentDB v1.0.7 ready for production use in browsers!');
|
|
167
|
-
log('=' .repeat(60));
|
|
168
|
-
|
|
169
|
-
} catch (error) {
|
|
170
|
-
log(`❌ ERROR: ${error.message}`, 'error');
|
|
171
|
-
log(`Stack: ${error.stack}`, 'error');
|
|
172
|
-
|
|
173
|
-
statusEl.textContent = `❌ Test failed: ${error.message}`;
|
|
174
|
-
statusEl.className = 'status error';
|
|
175
|
-
|
|
176
|
-
addTestResult('Error Occurred', false, error.message);
|
|
177
|
-
|
|
178
|
-
// Check if it's the better-sqlite3 error
|
|
179
|
-
if (error.message.includes('better-sqlite3')) {
|
|
180
|
-
log('🚨 CRITICAL: better-sqlite3 dependency still present in bundle!');
|
|
181
|
-
addTestResult('better-sqlite3 Fix', false, 'Module still contains Node.js dependency');
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// Run tests when page loads
|
|
187
|
-
runTests();
|
|
188
|
-
</script>
|
|
189
|
-
</body>
|
|
190
|
-
</html>
|
package/examples/wasm-example.ts
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Example: Using SQLiteVector with WASM backend
|
|
3
|
-
*
|
|
4
|
-
* This example demonstrates:
|
|
5
|
-
* - WASM backend initialization
|
|
6
|
-
* - Vector insertion and search
|
|
7
|
-
* - Import/Export for persistence
|
|
8
|
-
* - Performance benchmarking
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { SQLiteVectorDB, BackendType, WasmBackend } from '../src/index';
|
|
12
|
-
|
|
13
|
-
async function basicUsage() {
|
|
14
|
-
console.log('=== Basic WASM Backend Usage ===\n');
|
|
15
|
-
|
|
16
|
-
// Create database with WASM backend
|
|
17
|
-
const db = new SQLiteVectorDB({
|
|
18
|
-
backend: BackendType.WASM
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
// WASM requires async initialization
|
|
22
|
-
await db.initializeAsync();
|
|
23
|
-
console.log('✓ Database initialized');
|
|
24
|
-
|
|
25
|
-
// Insert vectors
|
|
26
|
-
const vectors = [
|
|
27
|
-
{ id: 'vec1', embedding: [1.0, 0.0, 0.0], metadata: { label: 'x-axis' } },
|
|
28
|
-
{ id: 'vec2', embedding: [0.0, 1.0, 0.0], metadata: { label: 'y-axis' } },
|
|
29
|
-
{ id: 'vec3', embedding: [0.0, 0.0, 1.0], metadata: { label: 'z-axis' } },
|
|
30
|
-
{ id: 'vec4', embedding: [0.7, 0.7, 0.0], metadata: { label: 'diagonal' } }
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
const ids = db.insertBatch(vectors);
|
|
34
|
-
console.log(`✓ Inserted ${ids.length} vectors`);
|
|
35
|
-
|
|
36
|
-
// Search for similar vectors
|
|
37
|
-
const query = [1.0, 0.0, 0.0];
|
|
38
|
-
const results = db.search(query, 3, 'cosine', 0.0);
|
|
39
|
-
|
|
40
|
-
console.log('\nSearch results for [1.0, 0.0, 0.0]:');
|
|
41
|
-
results.forEach((result, i) => {
|
|
42
|
-
console.log(` ${i + 1}. ${result.id} - Score: ${result.score.toFixed(4)} - ${result.metadata?.label}`);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// Get statistics
|
|
46
|
-
const stats = db.stats();
|
|
47
|
-
console.log(`\nDatabase stats: ${stats.count} vectors, ${(stats.size / 1024).toFixed(2)} KB`);
|
|
48
|
-
|
|
49
|
-
db.close();
|
|
50
|
-
console.log('✓ Database closed\n');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async function persistenceExample() {
|
|
54
|
-
console.log('=== Persistence with Import/Export ===\n');
|
|
55
|
-
|
|
56
|
-
// Create and populate database
|
|
57
|
-
const db = new SQLiteVectorDB({ backend: BackendType.WASM });
|
|
58
|
-
await db.initializeAsync();
|
|
59
|
-
|
|
60
|
-
const vectors = Array.from({ length: 100 }, (_, i) => ({
|
|
61
|
-
embedding: [Math.random(), Math.random(), Math.random()],
|
|
62
|
-
metadata: { index: i }
|
|
63
|
-
}));
|
|
64
|
-
|
|
65
|
-
db.insertBatch(vectors);
|
|
66
|
-
console.log('✓ Inserted 100 vectors');
|
|
67
|
-
|
|
68
|
-
// Export to binary
|
|
69
|
-
const binary = db.export();
|
|
70
|
-
console.log(`✓ Exported database: ${binary.byteLength} bytes`);
|
|
71
|
-
|
|
72
|
-
db.close();
|
|
73
|
-
|
|
74
|
-
// Import to new database
|
|
75
|
-
const newDb = new SQLiteVectorDB({ backend: BackendType.WASM });
|
|
76
|
-
await newDb.importAsync(binary);
|
|
77
|
-
console.log('✓ Imported database');
|
|
78
|
-
|
|
79
|
-
const stats = newDb.stats();
|
|
80
|
-
console.log(`✓ Verified: ${stats.count} vectors restored\n`);
|
|
81
|
-
|
|
82
|
-
newDb.close();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
async function performanceBenchmark() {
|
|
86
|
-
console.log('=== Performance Benchmark ===\n');
|
|
87
|
-
|
|
88
|
-
const db = new SQLiteVectorDB({ backend: BackendType.WASM });
|
|
89
|
-
await db.initializeAsync();
|
|
90
|
-
|
|
91
|
-
// Benchmark: Batch insert
|
|
92
|
-
const insertSize = 1000;
|
|
93
|
-
const vectors = Array.from({ length: insertSize }, (_, i) => ({
|
|
94
|
-
embedding: Array.from({ length: 384 }, () => Math.random())
|
|
95
|
-
}));
|
|
96
|
-
|
|
97
|
-
const insertStart = performance.now();
|
|
98
|
-
db.insertBatch(vectors);
|
|
99
|
-
const insertDuration = performance.now() - insertStart;
|
|
100
|
-
|
|
101
|
-
console.log(`Batch Insert (${insertSize} vectors, 384-dim):`);
|
|
102
|
-
console.log(` Total time: ${insertDuration.toFixed(2)}ms`);
|
|
103
|
-
console.log(` Rate: ${(insertSize / (insertDuration / 1000)).toFixed(0)} vectors/sec`);
|
|
104
|
-
|
|
105
|
-
// Benchmark: Search
|
|
106
|
-
const searchIterations = 100;
|
|
107
|
-
const query = Array.from({ length: 384 }, () => Math.random());
|
|
108
|
-
|
|
109
|
-
const searchStart = performance.now();
|
|
110
|
-
for (let i = 0; i < searchIterations; i++) {
|
|
111
|
-
db.search(query, 10, 'cosine', 0.0);
|
|
112
|
-
}
|
|
113
|
-
const searchDuration = performance.now() - searchStart;
|
|
114
|
-
|
|
115
|
-
console.log(`\nSearch (${searchIterations} iterations, k=10):`);
|
|
116
|
-
console.log(` Avg time: ${(searchDuration / searchIterations).toFixed(2)}ms`);
|
|
117
|
-
console.log(` Rate: ${(searchIterations / (searchDuration / 1000)).toFixed(0)} searches/sec`);
|
|
118
|
-
|
|
119
|
-
// Memory usage
|
|
120
|
-
const stats = db.stats();
|
|
121
|
-
console.log(`\nMemory usage: ${(stats.size / (1024 * 1024)).toFixed(2)} MB`);
|
|
122
|
-
|
|
123
|
-
db.close();
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
async function similarityComparison() {
|
|
127
|
-
console.log('\n=== Similarity Metrics Comparison ===\n');
|
|
128
|
-
|
|
129
|
-
const db = new SQLiteVectorDB({ backend: BackendType.WASM });
|
|
130
|
-
await db.initializeAsync();
|
|
131
|
-
|
|
132
|
-
// Insert test vectors
|
|
133
|
-
const vectors = [
|
|
134
|
-
{ id: 'parallel', embedding: [1.0, 1.0, 1.0] },
|
|
135
|
-
{ id: 'orthogonal', embedding: [1.0, -1.0, 0.0] },
|
|
136
|
-
{ id: 'opposite', embedding: [-1.0, -1.0, -1.0] },
|
|
137
|
-
{ id: 'similar', embedding: [0.9, 0.9, 0.9] }
|
|
138
|
-
];
|
|
139
|
-
|
|
140
|
-
db.insertBatch(vectors);
|
|
141
|
-
|
|
142
|
-
const query = [1.0, 1.0, 1.0];
|
|
143
|
-
|
|
144
|
-
// Compare metrics
|
|
145
|
-
console.log('Query: [1.0, 1.0, 1.0]\n');
|
|
146
|
-
|
|
147
|
-
const cosineResults = db.search(query, 4, 'cosine', 0.0);
|
|
148
|
-
console.log('Cosine Similarity:');
|
|
149
|
-
cosineResults.forEach(r => {
|
|
150
|
-
console.log(` ${r.id.padEnd(12)} - ${r.score.toFixed(4)}`);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
const euclideanResults = db.search(query, 4, 'euclidean', 0.0);
|
|
154
|
-
console.log('\nEuclidean Distance:');
|
|
155
|
-
euclideanResults.forEach(r => {
|
|
156
|
-
console.log(` ${r.id.padEnd(12)} - ${r.score.toFixed(4)}`);
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
const dotResults = db.search(query, 4, 'dot', 0.0);
|
|
160
|
-
console.log('\nDot Product:');
|
|
161
|
-
dotResults.forEach(r => {
|
|
162
|
-
console.log(` ${r.id.padEnd(12)} - ${r.score.toFixed(4)}`);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
db.close();
|
|
166
|
-
console.log();
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
async function directBackendUsage() {
|
|
170
|
-
console.log('\n=== Direct WASM Backend Usage ===\n');
|
|
171
|
-
|
|
172
|
-
// Use WasmBackend directly for more control
|
|
173
|
-
const backend = new WasmBackend();
|
|
174
|
-
await backend.initializeAsync({
|
|
175
|
-
cacheSize: 50 * 1024, // 50MB cache
|
|
176
|
-
memoryMode: true
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
console.log('✓ WASM backend initialized');
|
|
180
|
-
|
|
181
|
-
// All operations same as unified API
|
|
182
|
-
const id = backend.insert({
|
|
183
|
-
embedding: [1, 2, 3, 4, 5],
|
|
184
|
-
metadata: { type: 'test' }
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
const vector = backend.get(id);
|
|
188
|
-
console.log(`✓ Retrieved vector: ${vector?.embedding.slice(0, 5)}`);
|
|
189
|
-
|
|
190
|
-
const results = backend.search([1, 2, 3, 4, 5], 1, 'cosine', 0.0);
|
|
191
|
-
console.log(`✓ Search found ${results.length} results`);
|
|
192
|
-
|
|
193
|
-
backend.close();
|
|
194
|
-
console.log('✓ Backend closed\n');
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Run all examples
|
|
198
|
-
async function main() {
|
|
199
|
-
console.log('SQLiteVector WASM Backend Examples\n');
|
|
200
|
-
console.log('===================================\n');
|
|
201
|
-
|
|
202
|
-
try {
|
|
203
|
-
await basicUsage();
|
|
204
|
-
await persistenceExample();
|
|
205
|
-
await performanceBenchmark();
|
|
206
|
-
await similarityComparison();
|
|
207
|
-
await directBackendUsage();
|
|
208
|
-
|
|
209
|
-
console.log('===================================\n');
|
|
210
|
-
console.log('✓ All examples completed successfully!');
|
|
211
|
-
} catch (error) {
|
|
212
|
-
console.error('Error:', error);
|
|
213
|
-
process.exit(1);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// Run if executed directly
|
|
218
|
-
if (require.main === module) {
|
|
219
|
-
main();
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export { main };
|