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,811 +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>Swarm Intelligence - AgentDB WASM</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, #1e3c72 0%, #2a5298 100%);
|
|
17
|
-
min-height: 100vh;
|
|
18
|
-
padding: 2rem;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.container {
|
|
22
|
-
max-width: 1400px;
|
|
23
|
-
margin: 0 auto;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
header {
|
|
27
|
-
text-align: center;
|
|
28
|
-
color: white;
|
|
29
|
-
margin-bottom: 2rem;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
h1 {
|
|
33
|
-
font-size: 2rem;
|
|
34
|
-
margin-bottom: 0.5rem;
|
|
35
|
-
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.subtitle {
|
|
39
|
-
opacity: 0.9;
|
|
40
|
-
font-size: 1rem;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.main-grid {
|
|
44
|
-
display: grid;
|
|
45
|
-
grid-template-columns: 2fr 1fr;
|
|
46
|
-
gap: 1.5rem;
|
|
47
|
-
margin-bottom: 1.5rem;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.card {
|
|
51
|
-
background: white;
|
|
52
|
-
border-radius: 12px;
|
|
53
|
-
padding: 1.5rem;
|
|
54
|
-
box-shadow: 0 8px 24px rgba(0,0,0,0.2);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.card h2 {
|
|
58
|
-
color: #333;
|
|
59
|
-
margin-bottom: 1rem;
|
|
60
|
-
font-size: 1.3rem;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
#canvas {
|
|
64
|
-
width: 100%;
|
|
65
|
-
height: 500px;
|
|
66
|
-
border: 2px solid #e0e0e0;
|
|
67
|
-
border-radius: 8px;
|
|
68
|
-
background: #0a0a0a;
|
|
69
|
-
cursor: crosshair;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.controls {
|
|
73
|
-
display: grid;
|
|
74
|
-
grid-template-columns: repeat(2, 1fr);
|
|
75
|
-
gap: 1rem;
|
|
76
|
-
margin-bottom: 1rem;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.control-group {
|
|
80
|
-
display: flex;
|
|
81
|
-
flex-direction: column;
|
|
82
|
-
gap: 0.5rem;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
label {
|
|
86
|
-
font-size: 0.9rem;
|
|
87
|
-
color: #555;
|
|
88
|
-
font-weight: 500;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
input[type="range"] {
|
|
92
|
-
width: 100%;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
input[type="number"] {
|
|
96
|
-
padding: 0.5rem;
|
|
97
|
-
border: 1px solid #ddd;
|
|
98
|
-
border-radius: 4px;
|
|
99
|
-
font-size: 0.9rem;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.btn {
|
|
103
|
-
padding: 0.75rem 1.5rem;
|
|
104
|
-
background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
|
|
105
|
-
color: white;
|
|
106
|
-
border: none;
|
|
107
|
-
border-radius: 6px;
|
|
108
|
-
font-weight: 600;
|
|
109
|
-
cursor: pointer;
|
|
110
|
-
transition: opacity 0.3s;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
.btn:hover {
|
|
114
|
-
opacity: 0.9;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.btn.danger {
|
|
118
|
-
background: linear-gradient(135deg, #c62828 0%, #b71c1c 100%);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.btn.success {
|
|
122
|
-
background: linear-gradient(135deg, #2e7d32 0%, #1b5e20 100%);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.stat-grid {
|
|
126
|
-
display: grid;
|
|
127
|
-
grid-template-columns: repeat(2, 1fr);
|
|
128
|
-
gap: 1rem;
|
|
129
|
-
margin-top: 1rem;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.stat-item {
|
|
133
|
-
background: #f5f5f5;
|
|
134
|
-
padding: 1rem;
|
|
135
|
-
border-radius: 8px;
|
|
136
|
-
text-align: center;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.stat-label {
|
|
140
|
-
font-size: 0.85rem;
|
|
141
|
-
color: #666;
|
|
142
|
-
margin-bottom: 0.5rem;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
.stat-value {
|
|
146
|
-
font-size: 1.5rem;
|
|
147
|
-
font-weight: bold;
|
|
148
|
-
color: #1e3c72;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
.behavior-select {
|
|
152
|
-
display: flex;
|
|
153
|
-
gap: 0.5rem;
|
|
154
|
-
margin-bottom: 1rem;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
.behavior-btn {
|
|
158
|
-
flex: 1;
|
|
159
|
-
padding: 0.5rem;
|
|
160
|
-
background: white;
|
|
161
|
-
border: 2px solid #ddd;
|
|
162
|
-
border-radius: 6px;
|
|
163
|
-
cursor: pointer;
|
|
164
|
-
transition: all 0.3s;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
.behavior-btn.active {
|
|
168
|
-
background: #1e3c72;
|
|
169
|
-
color: white;
|
|
170
|
-
border-color: #1e3c72;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
#log {
|
|
174
|
-
max-height: 200px;
|
|
175
|
-
overflow-y: auto;
|
|
176
|
-
background: #f9f9f9;
|
|
177
|
-
padding: 1rem;
|
|
178
|
-
border-radius: 8px;
|
|
179
|
-
font-family: 'Courier New', monospace;
|
|
180
|
-
font-size: 0.85rem;
|
|
181
|
-
line-height: 1.6;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
.log-entry {
|
|
185
|
-
margin-bottom: 0.5rem;
|
|
186
|
-
color: #555;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
.log-entry.success {
|
|
190
|
-
color: #2e7d32;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
.log-entry.info {
|
|
194
|
-
color: #1976d2;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.description {
|
|
198
|
-
background: #e3f2fd;
|
|
199
|
-
padding: 1rem;
|
|
200
|
-
border-radius: 8px;
|
|
201
|
-
margin-bottom: 1rem;
|
|
202
|
-
line-height: 1.6;
|
|
203
|
-
}
|
|
204
|
-
</style>
|
|
205
|
-
</head>
|
|
206
|
-
<body>
|
|
207
|
-
<div class="container">
|
|
208
|
-
<header>
|
|
209
|
-
<h1>🐝 Swarm Intelligence with Emergent Behavior</h1>
|
|
210
|
-
<p class="subtitle">Particle Swarm Optimization + Stigmergy + Vector Memory</p>
|
|
211
|
-
</header>
|
|
212
|
-
|
|
213
|
-
<div class="main-grid">
|
|
214
|
-
<div class="card">
|
|
215
|
-
<h2>Swarm Visualization</h2>
|
|
216
|
-
<canvas id="canvas"></canvas>
|
|
217
|
-
<div class="controls">
|
|
218
|
-
<button class="btn" onclick="addTarget()">Add Target 🎯</button>
|
|
219
|
-
<button class="btn" onclick="addObstacle()">Add Obstacle 🚧</button>
|
|
220
|
-
<button class="btn success" onclick="startSwarm()">Start Swarm 🚀</button>
|
|
221
|
-
<button class="btn danger" onclick="resetSwarm()">Reset ⟲</button>
|
|
222
|
-
</div>
|
|
223
|
-
</div>
|
|
224
|
-
|
|
225
|
-
<div class="card">
|
|
226
|
-
<h2>Swarm Parameters</h2>
|
|
227
|
-
<div class="description">
|
|
228
|
-
Watch agents exhibit emergent collective intelligence through pheromone trails, local interactions, and vector-based memory.
|
|
229
|
-
</div>
|
|
230
|
-
|
|
231
|
-
<div class="control-group">
|
|
232
|
-
<label>Agents: <span id="agentCount">50</span></label>
|
|
233
|
-
<input type="range" id="agentSlider" min="10" max="200" value="50" oninput="updateAgentCount()">
|
|
234
|
-
</div>
|
|
235
|
-
|
|
236
|
-
<div class="control-group">
|
|
237
|
-
<label>Exploration Rate: <span id="exploreRate">0.3</span></label>
|
|
238
|
-
<input type="range" id="exploreSlider" min="0" max="1" step="0.1" value="0.3" oninput="updateExploreRate()">
|
|
239
|
-
</div>
|
|
240
|
-
|
|
241
|
-
<div class="control-group">
|
|
242
|
-
<label>Pheromone Decay: <span id="decayRate">0.95</span></label>
|
|
243
|
-
<input type="range" id="decaySlider" min="0.8" max="0.99" step="0.01" value="0.95" oninput="updateDecayRate()">
|
|
244
|
-
</div>
|
|
245
|
-
|
|
246
|
-
<div class="behavior-select">
|
|
247
|
-
<button class="behavior-btn active" onclick="setBehavior('foraging')">🍃 Foraging</button>
|
|
248
|
-
<button class="behavior-btn" onclick="setBehavior('flocking')">🐦 Flocking</button>
|
|
249
|
-
<button class="behavior-btn" onclick="setBehavior('exploration')">🗺️ Exploration</button>
|
|
250
|
-
</div>
|
|
251
|
-
|
|
252
|
-
<div class="stat-grid">
|
|
253
|
-
<div class="stat-item">
|
|
254
|
-
<div class="stat-label">Targets Found</div>
|
|
255
|
-
<div class="stat-value" id="targetsFound">0</div>
|
|
256
|
-
</div>
|
|
257
|
-
<div class="stat-item">
|
|
258
|
-
<div class="stat-label">Emergent Paths</div>
|
|
259
|
-
<div class="stat-value" id="pathsDiscovered">0</div>
|
|
260
|
-
</div>
|
|
261
|
-
<div class="stat-item">
|
|
262
|
-
<div class="stat-label">Collective IQ</div>
|
|
263
|
-
<div class="stat-value" id="collectiveIQ">0</div>
|
|
264
|
-
</div>
|
|
265
|
-
<div class="stat-item">
|
|
266
|
-
<div class="stat-label">Pheromone Trails</div>
|
|
267
|
-
<div class="stat-value" id="trailCount">0</div>
|
|
268
|
-
</div>
|
|
269
|
-
</div>
|
|
270
|
-
</div>
|
|
271
|
-
</div>
|
|
272
|
-
|
|
273
|
-
<div class="card">
|
|
274
|
-
<h2>📊 Swarm Intelligence Log</h2>
|
|
275
|
-
<div id="log"></div>
|
|
276
|
-
</div>
|
|
277
|
-
</div>
|
|
278
|
-
|
|
279
|
-
<script>
|
|
280
|
-
// Simulated AgentDB for vector storage
|
|
281
|
-
class SwarmVectorDB {
|
|
282
|
-
constructor() {
|
|
283
|
-
this.pheromones = [];
|
|
284
|
-
this.paths = [];
|
|
285
|
-
this.memories = [];
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
storePheromone(position, strength, type) {
|
|
289
|
-
const embedding = this.generatePositionEmbedding(position);
|
|
290
|
-
this.pheromones.push({
|
|
291
|
-
position,
|
|
292
|
-
embedding,
|
|
293
|
-
strength,
|
|
294
|
-
type,
|
|
295
|
-
timestamp: Date.now()
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
// Decay old pheromones
|
|
299
|
-
this.pheromones = this.pheromones.filter(p => p.strength > 0.01);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
findNearbyPheromones(position, radius = 50) {
|
|
303
|
-
const posEmbedding = this.generatePositionEmbedding(position);
|
|
304
|
-
return this.pheromones
|
|
305
|
-
.map(p => ({
|
|
306
|
-
...p,
|
|
307
|
-
distance: Math.hypot(p.position.x - position.x, p.position.y - position.y),
|
|
308
|
-
similarity: this.cosineSimilarity(posEmbedding, p.embedding)
|
|
309
|
-
}))
|
|
310
|
-
.filter(p => p.distance < radius)
|
|
311
|
-
.sort((a, b) => b.strength - a.strength);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
storePath(path, success) {
|
|
315
|
-
const embedding = this.generatePathEmbedding(path);
|
|
316
|
-
this.paths.push({
|
|
317
|
-
path,
|
|
318
|
-
embedding,
|
|
319
|
-
success,
|
|
320
|
-
fitness: success ? 1.0 : 0.1,
|
|
321
|
-
timestamp: Date.now()
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
getBestPaths(count = 5) {
|
|
326
|
-
return this.paths
|
|
327
|
-
.sort((a, b) => b.fitness - a.fitness)
|
|
328
|
-
.slice(0, count);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
storeCollectiveMemory(observation, context) {
|
|
332
|
-
this.memories.push({
|
|
333
|
-
observation,
|
|
334
|
-
context,
|
|
335
|
-
embedding: this.generateEmbedding(JSON.stringify(observation)),
|
|
336
|
-
timestamp: Date.now()
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
recallSimilarExperiences(query, k = 5) {
|
|
341
|
-
const queryEmbedding = this.generateEmbedding(JSON.stringify(query));
|
|
342
|
-
return this.memories
|
|
343
|
-
.map(m => ({
|
|
344
|
-
...m,
|
|
345
|
-
similarity: this.cosineSimilarity(queryEmbedding, m.embedding)
|
|
346
|
-
}))
|
|
347
|
-
.sort((a, b) => b.similarity - a.similarity)
|
|
348
|
-
.slice(0, k);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
generatePositionEmbedding(pos) {
|
|
352
|
-
const embedding = new Array(64).fill(0);
|
|
353
|
-
const scale = 0.01;
|
|
354
|
-
for (let i = 0; i < 64; i++) {
|
|
355
|
-
embedding[i] = Math.sin(pos.x * scale * i) + Math.cos(pos.y * scale * i);
|
|
356
|
-
}
|
|
357
|
-
return this.normalize(embedding);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
generatePathEmbedding(path) {
|
|
361
|
-
const embedding = new Array(128).fill(0);
|
|
362
|
-
path.forEach((pos, idx) => {
|
|
363
|
-
const weight = 1 / (idx + 1);
|
|
364
|
-
for (let i = 0; i < 64; i++) {
|
|
365
|
-
embedding[i] += Math.sin(pos.x * 0.01 * i) * weight;
|
|
366
|
-
embedding[i + 64] += Math.cos(pos.y * 0.01 * i) * weight;
|
|
367
|
-
}
|
|
368
|
-
});
|
|
369
|
-
return this.normalize(embedding);
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
generateEmbedding(text) {
|
|
373
|
-
const embedding = new Array(256).fill(0);
|
|
374
|
-
for (let i = 0; i < text.length; i++) {
|
|
375
|
-
const char = text.charCodeAt(i);
|
|
376
|
-
embedding[i % 256] += Math.sin(char * (i + 1));
|
|
377
|
-
}
|
|
378
|
-
return this.normalize(embedding);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
cosineSimilarity(a, b) {
|
|
382
|
-
let dot = 0, magA = 0, magB = 0;
|
|
383
|
-
for (let i = 0; i < a.length; i++) {
|
|
384
|
-
dot += a[i] * b[i];
|
|
385
|
-
magA += a[i] * a[i];
|
|
386
|
-
magB += b[i] * b[i];
|
|
387
|
-
}
|
|
388
|
-
return dot / (Math.sqrt(magA) * Math.sqrt(magB));
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
normalize(vec) {
|
|
392
|
-
const mag = Math.sqrt(vec.reduce((sum, val) => sum + val * val, 0));
|
|
393
|
-
return vec.map(v => v / (mag || 1));
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
decayPheromones(rate = 0.95) {
|
|
397
|
-
this.pheromones.forEach(p => {
|
|
398
|
-
p.strength *= rate;
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
class Agent {
|
|
404
|
-
constructor(x, y, id) {
|
|
405
|
-
this.id = id;
|
|
406
|
-
this.x = x;
|
|
407
|
-
this.y = y;
|
|
408
|
-
this.vx = (Math.random() - 0.5) * 2;
|
|
409
|
-
this.vy = (Math.random() - 0.5) * 2;
|
|
410
|
-
this.path = [{x, y}];
|
|
411
|
-
this.targetReached = false;
|
|
412
|
-
this.color = `hsl(${Math.random() * 360}, 70%, 60%)`;
|
|
413
|
-
this.energy = 100;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
update(agents, targets, obstacles, pheromones, behavior) {
|
|
417
|
-
if (this.targetReached || this.energy <= 0) return;
|
|
418
|
-
|
|
419
|
-
// Behavior-specific movement
|
|
420
|
-
switch(behavior) {
|
|
421
|
-
case 'foraging':
|
|
422
|
-
this.foragingBehavior(targets, pheromones);
|
|
423
|
-
break;
|
|
424
|
-
case 'flocking':
|
|
425
|
-
this.flockingBehavior(agents);
|
|
426
|
-
break;
|
|
427
|
-
case 'exploration':
|
|
428
|
-
this.explorationBehavior(pheromones);
|
|
429
|
-
break;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
// Avoid obstacles
|
|
433
|
-
obstacles.forEach(obs => {
|
|
434
|
-
const dx = this.x - obs.x;
|
|
435
|
-
const dy = this.y - obs.y;
|
|
436
|
-
const dist = Math.hypot(dx, dy);
|
|
437
|
-
if (dist < obs.radius + 20) {
|
|
438
|
-
this.vx += dx / dist * 0.5;
|
|
439
|
-
this.vy += dy / dist * 0.5;
|
|
440
|
-
}
|
|
441
|
-
});
|
|
442
|
-
|
|
443
|
-
// Apply velocity
|
|
444
|
-
this.x += this.vx;
|
|
445
|
-
this.y += this.vy;
|
|
446
|
-
|
|
447
|
-
// Boundary wrapping
|
|
448
|
-
if (this.x < 0) this.x = canvas.width;
|
|
449
|
-
if (this.x > canvas.width) this.x = 0;
|
|
450
|
-
if (this.y < 0) this.y = canvas.height;
|
|
451
|
-
if (this.y > canvas.height) this.y = 0;
|
|
452
|
-
|
|
453
|
-
// Damping
|
|
454
|
-
this.vx *= 0.98;
|
|
455
|
-
this.vy *= 0.98;
|
|
456
|
-
|
|
457
|
-
// Max speed
|
|
458
|
-
const speed = Math.hypot(this.vx, this.vy);
|
|
459
|
-
if (speed > 3) {
|
|
460
|
-
this.vx = (this.vx / speed) * 3;
|
|
461
|
-
this.vy = (this.vy / speed) * 3;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
// Energy consumption
|
|
465
|
-
this.energy -= 0.1;
|
|
466
|
-
|
|
467
|
-
// Track path
|
|
468
|
-
if (this.path.length < 100) {
|
|
469
|
-
this.path.push({x: this.x, y: this.y});
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
// Check target collision
|
|
473
|
-
targets.forEach(target => {
|
|
474
|
-
const dist = Math.hypot(this.x - target.x, this.y - target.y);
|
|
475
|
-
if (dist < target.radius + 5) {
|
|
476
|
-
this.targetReached = true;
|
|
477
|
-
target.found = true;
|
|
478
|
-
db.storePath(this.path, true);
|
|
479
|
-
logMessage(`Agent ${this.id} found target! Path efficiency: ${(100/this.path.length).toFixed(2)}`, 'success');
|
|
480
|
-
}
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
foragingBehavior(targets, pheromones) {
|
|
485
|
-
// Follow pheromone trails
|
|
486
|
-
const nearby = pheromones.filter(p => {
|
|
487
|
-
const dist = Math.hypot(p.position.x - this.x, p.position.y - this.y);
|
|
488
|
-
return dist < 60;
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
if (nearby.length > 0 && Math.random() > params.exploration) {
|
|
492
|
-
const strongest = nearby.reduce((a, b) => a.strength > b.strength ? a : b);
|
|
493
|
-
const dx = strongest.position.x - this.x;
|
|
494
|
-
const dy = strongest.position.y - this.y;
|
|
495
|
-
const dist = Math.hypot(dx, dy);
|
|
496
|
-
this.vx += (dx / dist) * 0.3;
|
|
497
|
-
this.vy += (dy / dist) * 0.3;
|
|
498
|
-
} else {
|
|
499
|
-
// Move toward nearest target
|
|
500
|
-
const nearest = targets.reduce((a, b) => {
|
|
501
|
-
const distA = Math.hypot(a.x - this.x, a.y - this.y);
|
|
502
|
-
const distB = Math.hypot(b.x - this.x, b.y - this.y);
|
|
503
|
-
return distA < distB ? a : b;
|
|
504
|
-
});
|
|
505
|
-
|
|
506
|
-
if (nearest) {
|
|
507
|
-
const dx = nearest.x - this.x;
|
|
508
|
-
const dy = nearest.y - this.y;
|
|
509
|
-
const dist = Math.hypot(dx, dy);
|
|
510
|
-
this.vx += (dx / dist) * 0.2;
|
|
511
|
-
this.vy += (dy / dist) * 0.2;
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
flockingBehavior(agents) {
|
|
517
|
-
// Separation, alignment, cohesion
|
|
518
|
-
let sepX = 0, sepY = 0, alignX = 0, alignY = 0, cohX = 0, cohY = 0;
|
|
519
|
-
let neighbors = 0;
|
|
520
|
-
|
|
521
|
-
agents.forEach(other => {
|
|
522
|
-
if (other === this) return;
|
|
523
|
-
const dist = Math.hypot(other.x - this.x, other.y - this.y);
|
|
524
|
-
|
|
525
|
-
if (dist < 100) {
|
|
526
|
-
neighbors++;
|
|
527
|
-
|
|
528
|
-
// Separation
|
|
529
|
-
if (dist < 30) {
|
|
530
|
-
sepX += this.x - other.x;
|
|
531
|
-
sepY += this.y - other.y;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
// Alignment
|
|
535
|
-
alignX += other.vx;
|
|
536
|
-
alignY += other.vy;
|
|
537
|
-
|
|
538
|
-
// Cohesion
|
|
539
|
-
cohX += other.x;
|
|
540
|
-
cohY += other.y;
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
|
|
544
|
-
if (neighbors > 0) {
|
|
545
|
-
this.vx += sepX * 0.05 + (alignX / neighbors) * 0.02;
|
|
546
|
-
this.vy += sepY * 0.05 + (alignY / neighbors) * 0.02;
|
|
547
|
-
|
|
548
|
-
const avgX = cohX / neighbors;
|
|
549
|
-
const avgY = cohY / neighbors;
|
|
550
|
-
this.vx += (avgX - this.x) * 0.01;
|
|
551
|
-
this.vy += (avgY - this.y) * 0.01;
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
explorationBehavior(pheromones) {
|
|
556
|
-
// Avoid visited areas (anti-pheromone)
|
|
557
|
-
const visited = pheromones.filter(p => p.type === 'exploration');
|
|
558
|
-
let avoidX = 0, avoidY = 0;
|
|
559
|
-
|
|
560
|
-
visited.forEach(p => {
|
|
561
|
-
const dist = Math.hypot(p.position.x - this.x, p.position.y - this.y);
|
|
562
|
-
if (dist < 50) {
|
|
563
|
-
avoidX += (this.x - p.position.x) / dist;
|
|
564
|
-
avoidY += (this.y - p.position.y) / dist;
|
|
565
|
-
}
|
|
566
|
-
});
|
|
567
|
-
|
|
568
|
-
this.vx += avoidX * 0.1 + (Math.random() - 0.5) * 0.5;
|
|
569
|
-
this.vy += avoidY * 0.1 + (Math.random() - 0.5) * 0.5;
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
// Global state
|
|
574
|
-
const db = new SwarmVectorDB();
|
|
575
|
-
let agents = [];
|
|
576
|
-
let targets = [];
|
|
577
|
-
let obstacles = [];
|
|
578
|
-
let running = false;
|
|
579
|
-
let animationId = null;
|
|
580
|
-
let params = {
|
|
581
|
-
agentCount: 50,
|
|
582
|
-
exploration: 0.3,
|
|
583
|
-
pheromoneDecay: 0.95,
|
|
584
|
-
behavior: 'foraging'
|
|
585
|
-
};
|
|
586
|
-
|
|
587
|
-
let stats = {
|
|
588
|
-
targetsFound: 0,
|
|
589
|
-
pathsDiscovered: 0,
|
|
590
|
-
collectiveIQ: 0,
|
|
591
|
-
generation: 0
|
|
592
|
-
};
|
|
593
|
-
|
|
594
|
-
// Canvas setup
|
|
595
|
-
const canvas = document.getElementById('canvas');
|
|
596
|
-
const ctx = canvas.getContext('2d');
|
|
597
|
-
canvas.width = canvas.offsetWidth;
|
|
598
|
-
canvas.height = canvas.offsetHeight;
|
|
599
|
-
|
|
600
|
-
// Initialize
|
|
601
|
-
function initSwarm() {
|
|
602
|
-
agents = [];
|
|
603
|
-
for (let i = 0; i < params.agentCount; i++) {
|
|
604
|
-
agents.push(new Agent(
|
|
605
|
-
Math.random() * canvas.width,
|
|
606
|
-
Math.random() * canvas.height,
|
|
607
|
-
i
|
|
608
|
-
));
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
function addTarget() {
|
|
613
|
-
targets.push({
|
|
614
|
-
x: Math.random() * canvas.width,
|
|
615
|
-
y: Math.random() * canvas.height,
|
|
616
|
-
radius: 15,
|
|
617
|
-
found: false
|
|
618
|
-
});
|
|
619
|
-
logMessage('Target added to environment', 'info');
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
function addObstacle() {
|
|
623
|
-
obstacles.push({
|
|
624
|
-
x: Math.random() * canvas.width,
|
|
625
|
-
y: Math.random() * canvas.height,
|
|
626
|
-
radius: 30
|
|
627
|
-
});
|
|
628
|
-
logMessage('Obstacle added to environment', 'info');
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
function startSwarm() {
|
|
632
|
-
if (!running) {
|
|
633
|
-
initSwarm();
|
|
634
|
-
running = true;
|
|
635
|
-
animate();
|
|
636
|
-
logMessage('Swarm activated! Watch emergent behavior unfold...', 'success');
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
function resetSwarm() {
|
|
641
|
-
running = false;
|
|
642
|
-
if (animationId) cancelAnimationFrame(animationId);
|
|
643
|
-
agents = [];
|
|
644
|
-
targets = [];
|
|
645
|
-
obstacles = [];
|
|
646
|
-
db.pheromones = [];
|
|
647
|
-
db.paths = [];
|
|
648
|
-
stats = { targetsFound: 0, pathsDiscovered: 0, collectiveIQ: 0, generation: 0 };
|
|
649
|
-
updateStats();
|
|
650
|
-
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
651
|
-
logMessage('Swarm reset', 'info');
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
function animate() {
|
|
655
|
-
if (!running) return;
|
|
656
|
-
|
|
657
|
-
ctx.fillStyle = 'rgba(10, 10, 10, 0.1)';
|
|
658
|
-
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
659
|
-
|
|
660
|
-
// Decay pheromones
|
|
661
|
-
db.decayPheromones(params.pheromoneDecay);
|
|
662
|
-
|
|
663
|
-
// Draw pheromone trails
|
|
664
|
-
db.pheromones.forEach(p => {
|
|
665
|
-
ctx.fillStyle = `rgba(100, 200, 255, ${p.strength * 0.3})`;
|
|
666
|
-
ctx.beginPath();
|
|
667
|
-
ctx.arc(p.position.x, p.position.y, 8, 0, Math.PI * 2);
|
|
668
|
-
ctx.fill();
|
|
669
|
-
});
|
|
670
|
-
|
|
671
|
-
// Draw obstacles
|
|
672
|
-
obstacles.forEach(obs => {
|
|
673
|
-
ctx.fillStyle = '#c62828';
|
|
674
|
-
ctx.beginPath();
|
|
675
|
-
ctx.arc(obs.x, obs.y, obs.radius, 0, Math.PI * 2);
|
|
676
|
-
ctx.fill();
|
|
677
|
-
});
|
|
678
|
-
|
|
679
|
-
// Draw targets
|
|
680
|
-
targets.forEach(target => {
|
|
681
|
-
ctx.fillStyle = target.found ? '#2e7d32' : '#ffd600';
|
|
682
|
-
ctx.beginPath();
|
|
683
|
-
ctx.arc(target.x, target.y, target.radius, 0, Math.PI * 2);
|
|
684
|
-
ctx.fill();
|
|
685
|
-
|
|
686
|
-
if (!target.found) {
|
|
687
|
-
ctx.strokeStyle = '#ffd600';
|
|
688
|
-
ctx.lineWidth = 2;
|
|
689
|
-
ctx.beginPath();
|
|
690
|
-
ctx.arc(target.x, target.y, target.radius + 5, 0, Math.PI * 2);
|
|
691
|
-
ctx.stroke();
|
|
692
|
-
}
|
|
693
|
-
});
|
|
694
|
-
|
|
695
|
-
// Update and draw agents
|
|
696
|
-
agents.forEach(agent => {
|
|
697
|
-
agent.update(agents, targets, obstacles, db.pheromones, params.behavior);
|
|
698
|
-
|
|
699
|
-
// Leave pheromone trail
|
|
700
|
-
if (Math.random() < 0.1) {
|
|
701
|
-
db.storePheromone(
|
|
702
|
-
{x: agent.x, y: agent.y},
|
|
703
|
-
agent.targetReached ? 1.0 : 0.5,
|
|
704
|
-
params.behavior
|
|
705
|
-
);
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
// Draw agent
|
|
709
|
-
ctx.fillStyle = agent.targetReached ? '#00ff00' : agent.color;
|
|
710
|
-
ctx.globalAlpha = agent.energy / 100;
|
|
711
|
-
ctx.beginPath();
|
|
712
|
-
ctx.arc(agent.x, agent.y, 4, 0, Math.PI * 2);
|
|
713
|
-
ctx.fill();
|
|
714
|
-
ctx.globalAlpha = 1;
|
|
715
|
-
|
|
716
|
-
// Draw path for successful agents
|
|
717
|
-
if (agent.targetReached && agent.path.length > 1) {
|
|
718
|
-
ctx.strokeStyle = agent.color;
|
|
719
|
-
ctx.lineWidth = 1;
|
|
720
|
-
ctx.globalAlpha = 0.3;
|
|
721
|
-
ctx.beginPath();
|
|
722
|
-
ctx.moveTo(agent.path[0].x, agent.path[0].y);
|
|
723
|
-
agent.path.forEach(p => ctx.lineTo(p.x, p.y));
|
|
724
|
-
ctx.stroke();
|
|
725
|
-
ctx.globalAlpha = 1;
|
|
726
|
-
}
|
|
727
|
-
});
|
|
728
|
-
|
|
729
|
-
// Update stats
|
|
730
|
-
stats.targetsFound = targets.filter(t => t.found).length;
|
|
731
|
-
stats.pathsDiscovered = db.paths.length;
|
|
732
|
-
stats.collectiveIQ = Math.floor(
|
|
733
|
-
(stats.pathsDiscovered * 10 + db.pheromones.length * 2) / (stats.generation + 1)
|
|
734
|
-
);
|
|
735
|
-
stats.generation++;
|
|
736
|
-
|
|
737
|
-
updateStats();
|
|
738
|
-
|
|
739
|
-
animationId = requestAnimationFrame(animate);
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
function updateStats() {
|
|
743
|
-
document.getElementById('targetsFound').textContent = stats.targetsFound;
|
|
744
|
-
document.getElementById('pathsDiscovered').textContent = stats.pathsDiscovered;
|
|
745
|
-
document.getElementById('collectiveIQ').textContent = stats.collectiveIQ;
|
|
746
|
-
document.getElementById('trailCount').textContent = db.pheromones.length;
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
function updateAgentCount() {
|
|
750
|
-
params.agentCount = parseInt(document.getElementById('agentSlider').value);
|
|
751
|
-
document.getElementById('agentCount').textContent = params.agentCount;
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
function updateExploreRate() {
|
|
755
|
-
params.exploration = parseFloat(document.getElementById('exploreSlider').value);
|
|
756
|
-
document.getElementById('exploreRate').textContent = params.exploration.toFixed(1);
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
function updateDecayRate() {
|
|
760
|
-
params.pheromoneDecay = parseFloat(document.getElementById('decaySlider').value);
|
|
761
|
-
document.getElementById('decayRate').textContent = params.pheromoneDecay.toFixed(2);
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
function setBehavior(behavior) {
|
|
765
|
-
params.behavior = behavior;
|
|
766
|
-
document.querySelectorAll('.behavior-btn').forEach(btn => {
|
|
767
|
-
btn.classList.remove('active');
|
|
768
|
-
});
|
|
769
|
-
event.target.classList.add('active');
|
|
770
|
-
logMessage(`Swarm behavior changed to: ${behavior}`, 'info');
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
function logMessage(message, type = '') {
|
|
774
|
-
const log = document.getElementById('log');
|
|
775
|
-
const entry = document.createElement('div');
|
|
776
|
-
entry.className = `log-entry ${type}`;
|
|
777
|
-
const timestamp = new Date().toLocaleTimeString();
|
|
778
|
-
entry.textContent = `[${timestamp}] ${message}`;
|
|
779
|
-
log.insertBefore(entry, log.firstChild);
|
|
780
|
-
|
|
781
|
-
// Keep only last 20 messages
|
|
782
|
-
while (log.children.length > 20) {
|
|
783
|
-
log.removeChild(log.lastChild);
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
// Canvas click handler
|
|
788
|
-
canvas.addEventListener('click', (e) => {
|
|
789
|
-
const rect = canvas.getBoundingClientRect();
|
|
790
|
-
const x = e.clientX - rect.left;
|
|
791
|
-
const y = e.clientY - rect.top;
|
|
792
|
-
|
|
793
|
-
if (e.shiftKey) {
|
|
794
|
-
obstacles.push({x, y, radius: 30});
|
|
795
|
-
logMessage('Obstacle placed', 'info');
|
|
796
|
-
} else {
|
|
797
|
-
targets.push({x, y, radius: 15, found: false});
|
|
798
|
-
logMessage('Target placed', 'info');
|
|
799
|
-
}
|
|
800
|
-
});
|
|
801
|
-
|
|
802
|
-
// Initialize with some targets
|
|
803
|
-
addTarget();
|
|
804
|
-
addTarget();
|
|
805
|
-
addTarget();
|
|
806
|
-
|
|
807
|
-
logMessage('🐝 Swarm Intelligence initialized', 'success');
|
|
808
|
-
logMessage('Click to add targets, Shift+Click for obstacles', 'info');
|
|
809
|
-
</script>
|
|
810
|
-
</body>
|
|
811
|
-
</html>
|