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,692 +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>Neuro-Symbolic Reasoning - 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, #0d47a1 0%, #1976d2 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: 1fr 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
|
-
.description {
|
|
64
|
-
background: #e3f2fd;
|
|
65
|
-
padding: 1rem;
|
|
66
|
-
border-radius: 8px;
|
|
67
|
-
margin-bottom: 1rem;
|
|
68
|
-
line-height: 1.6;
|
|
69
|
-
color: #555;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.knowledge-base {
|
|
73
|
-
background: #f5f5f5;
|
|
74
|
-
border-radius: 8px;
|
|
75
|
-
padding: 1rem;
|
|
76
|
-
margin-bottom: 1rem;
|
|
77
|
-
max-height: 300px;
|
|
78
|
-
overflow-y: auto;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.rule-item {
|
|
82
|
-
background: white;
|
|
83
|
-
padding: 0.75rem;
|
|
84
|
-
margin-bottom: 0.5rem;
|
|
85
|
-
border-radius: 6px;
|
|
86
|
-
border-left: 4px solid #1976d2;
|
|
87
|
-
font-family: 'Courier New', monospace;
|
|
88
|
-
font-size: 0.9rem;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.rule-premise {
|
|
92
|
-
color: #555;
|
|
93
|
-
margin-bottom: 0.25rem;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.rule-conclusion {
|
|
97
|
-
color: #2e7d32;
|
|
98
|
-
font-weight: 600;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.btn {
|
|
102
|
-
padding: 0.75rem 1.5rem;
|
|
103
|
-
background: linear-gradient(135deg, #0d47a1 0%, #1976d2 100%);
|
|
104
|
-
color: white;
|
|
105
|
-
border: none;
|
|
106
|
-
border-radius: 6px;
|
|
107
|
-
font-weight: 600;
|
|
108
|
-
cursor: pointer;
|
|
109
|
-
transition: opacity 0.3s;
|
|
110
|
-
width: 100%;
|
|
111
|
-
margin-bottom: 0.5rem;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
.btn:hover {
|
|
115
|
-
opacity: 0.9;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
textarea {
|
|
119
|
-
width: 100%;
|
|
120
|
-
padding: 1rem;
|
|
121
|
-
border: 2px solid #ddd;
|
|
122
|
-
border-radius: 8px;
|
|
123
|
-
font-family: 'Courier New', monospace;
|
|
124
|
-
font-size: 0.9rem;
|
|
125
|
-
resize: vertical;
|
|
126
|
-
margin-bottom: 1rem;
|
|
127
|
-
min-height: 100px;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
.reasoning-chain {
|
|
131
|
-
background: #f9f9f9;
|
|
132
|
-
border-radius: 8px;
|
|
133
|
-
padding: 1rem;
|
|
134
|
-
margin-bottom: 1rem;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
.reasoning-step {
|
|
138
|
-
background: white;
|
|
139
|
-
padding: 0.75rem;
|
|
140
|
-
margin-bottom: 0.5rem;
|
|
141
|
-
border-radius: 6px;
|
|
142
|
-
border-left: 4px solid #f57c00;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
.step-number {
|
|
146
|
-
font-weight: 600;
|
|
147
|
-
color: #e65100;
|
|
148
|
-
margin-bottom: 0.25rem;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
.step-inference {
|
|
152
|
-
font-family: 'Courier New', monospace;
|
|
153
|
-
color: #555;
|
|
154
|
-
margin-bottom: 0.25rem;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
.step-confidence {
|
|
158
|
-
font-size: 0.85rem;
|
|
159
|
-
color: #666;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
.conclusion-box {
|
|
163
|
-
background: #e8f5e9;
|
|
164
|
-
padding: 1.5rem;
|
|
165
|
-
border-radius: 8px;
|
|
166
|
-
border: 2px solid #2e7d32;
|
|
167
|
-
margin-bottom: 1rem;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
.conclusion-title {
|
|
171
|
-
font-weight: 600;
|
|
172
|
-
color: #1b5e20;
|
|
173
|
-
margin-bottom: 0.5rem;
|
|
174
|
-
font-size: 1.1rem;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
.conclusion-text {
|
|
178
|
-
font-family: 'Courier New', monospace;
|
|
179
|
-
color: #2e7d32;
|
|
180
|
-
font-size: 1rem;
|
|
181
|
-
line-height: 1.6;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
.stat-grid {
|
|
185
|
-
display: grid;
|
|
186
|
-
grid-template-columns: repeat(2, 1fr);
|
|
187
|
-
gap: 1rem;
|
|
188
|
-
margin-bottom: 1rem;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
.stat-item {
|
|
192
|
-
background: #f5f5f5;
|
|
193
|
-
padding: 1rem;
|
|
194
|
-
border-radius: 8px;
|
|
195
|
-
text-align: center;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
.stat-label {
|
|
199
|
-
font-size: 0.85rem;
|
|
200
|
-
color: #666;
|
|
201
|
-
margin-bottom: 0.5rem;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
.stat-value {
|
|
205
|
-
font-size: 1.5rem;
|
|
206
|
-
font-weight: bold;
|
|
207
|
-
color: #0d47a1;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
#log {
|
|
211
|
-
max-height: 200px;
|
|
212
|
-
overflow-y: auto;
|
|
213
|
-
background: #f9f9f9;
|
|
214
|
-
padding: 1rem;
|
|
215
|
-
border-radius: 8px;
|
|
216
|
-
font-family: 'Courier New', monospace;
|
|
217
|
-
font-size: 0.85rem;
|
|
218
|
-
line-height: 1.6;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
.log-entry {
|
|
222
|
-
margin-bottom: 0.5rem;
|
|
223
|
-
color: #555;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
.log-entry.success {
|
|
227
|
-
color: #2e7d32;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
.log-entry.info {
|
|
231
|
-
color: #1976d2;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
.hybrid-indicator {
|
|
235
|
-
display: flex;
|
|
236
|
-
justify-content: space-around;
|
|
237
|
-
margin-bottom: 1rem;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
.indicator-box {
|
|
241
|
-
flex: 1;
|
|
242
|
-
text-align: center;
|
|
243
|
-
padding: 1rem;
|
|
244
|
-
border-radius: 8px;
|
|
245
|
-
margin: 0 0.5rem;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
.neural-indicator {
|
|
249
|
-
background: linear-gradient(135deg, #673ab7 0%, #9c27b0 100%);
|
|
250
|
-
color: white;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
.symbolic-indicator {
|
|
254
|
-
background: linear-gradient(135deg, #0d47a1 0%, #1976d2 100%);
|
|
255
|
-
color: white;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
.indicator-label {
|
|
259
|
-
font-size: 0.85rem;
|
|
260
|
-
opacity: 0.9;
|
|
261
|
-
margin-bottom: 0.25rem;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
.indicator-value {
|
|
265
|
-
font-size: 1.5rem;
|
|
266
|
-
font-weight: 600;
|
|
267
|
-
}
|
|
268
|
-
</style>
|
|
269
|
-
</head>
|
|
270
|
-
<body>
|
|
271
|
-
<div class="container">
|
|
272
|
-
<header>
|
|
273
|
-
<h1>🧬 Neuro-Symbolic Reasoning</h1>
|
|
274
|
-
<p class="subtitle">Hybrid AI: Neural Perception + Symbolic Logic</p>
|
|
275
|
-
</header>
|
|
276
|
-
|
|
277
|
-
<div class="main-grid">
|
|
278
|
-
<div class="card">
|
|
279
|
-
<h2>Symbolic Knowledge Base</h2>
|
|
280
|
-
<div class="description">
|
|
281
|
-
Neuro-symbolic AI combines the pattern recognition power of neural networks with the logical reasoning of symbolic systems. The neural component learns from data while the symbolic component ensures interpretable, verifiable reasoning.
|
|
282
|
-
</div>
|
|
283
|
-
|
|
284
|
-
<div class="knowledge-base" id="knowledgeBase">
|
|
285
|
-
<!-- Populated with rules -->
|
|
286
|
-
</div>
|
|
287
|
-
|
|
288
|
-
<h2>Add Custom Rule</h2>
|
|
289
|
-
<textarea id="ruleInput" placeholder="IF condition1 AND condition2 THEN conclusion"></textarea>
|
|
290
|
-
<button class="btn" onclick="addRule()">➕ Add Logical Rule</button>
|
|
291
|
-
<button class="btn" onclick="trainNeuralComponent()">🧠 Train Neural Patterns</button>
|
|
292
|
-
</div>
|
|
293
|
-
|
|
294
|
-
<div class="card">
|
|
295
|
-
<h2>Query & Reasoning</h2>
|
|
296
|
-
|
|
297
|
-
<div class="hybrid-indicator">
|
|
298
|
-
<div class="indicator-box neural-indicator">
|
|
299
|
-
<div class="indicator-label">Neural Confidence</div>
|
|
300
|
-
<div class="indicator-value" id="neuralConfidence">0%</div>
|
|
301
|
-
</div>
|
|
302
|
-
<div class="indicator-box symbolic-indicator">
|
|
303
|
-
<div class="indicator-label">Symbolic Match</div>
|
|
304
|
-
<div class="indicator-value" id="symbolicMatch">0%</div>
|
|
305
|
-
</div>
|
|
306
|
-
</div>
|
|
307
|
-
|
|
308
|
-
<textarea id="queryInput" placeholder="Enter your query (e.g., 'Is Socrates mortal?')"></textarea>
|
|
309
|
-
<button class="btn" onclick="reason()">🔍 Perform Reasoning</button>
|
|
310
|
-
|
|
311
|
-
<h2>Reasoning Chain</h2>
|
|
312
|
-
<div class="reasoning-chain" id="reasoningChain">
|
|
313
|
-
<p style="color: #999; text-align: center;">No reasoning performed yet</p>
|
|
314
|
-
</div>
|
|
315
|
-
|
|
316
|
-
<div class="conclusion-box" id="conclusion" style="display: none;">
|
|
317
|
-
<div class="conclusion-title">✓ Conclusion</div>
|
|
318
|
-
<div class="conclusion-text" id="conclusionText"></div>
|
|
319
|
-
</div>
|
|
320
|
-
|
|
321
|
-
<div class="stat-grid">
|
|
322
|
-
<div class="stat-item">
|
|
323
|
-
<div class="stat-label">Rules in KB</div>
|
|
324
|
-
<div class="stat-value" id="ruleCount">0</div>
|
|
325
|
-
</div>
|
|
326
|
-
<div class="stat-item">
|
|
327
|
-
<div class="stat-label">Neural Patterns</div>
|
|
328
|
-
<div class="stat-value" id="patternCount">0</div>
|
|
329
|
-
</div>
|
|
330
|
-
<div class="stat-item">
|
|
331
|
-
<div class="stat-label">Inferences Made</div>
|
|
332
|
-
<div class="stat-value" id="inferenceCount">0</div>
|
|
333
|
-
</div>
|
|
334
|
-
<div class="stat-item">
|
|
335
|
-
<div class="stat-label">Hybrid Accuracy</div>
|
|
336
|
-
<div class="stat-value" id="accuracy">0%</div>
|
|
337
|
-
</div>
|
|
338
|
-
</div>
|
|
339
|
-
</div>
|
|
340
|
-
</div>
|
|
341
|
-
|
|
342
|
-
<div class="card">
|
|
343
|
-
<h2>📊 Reasoning Log</h2>
|
|
344
|
-
<div id="log"></div>
|
|
345
|
-
</div>
|
|
346
|
-
</div>
|
|
347
|
-
|
|
348
|
-
<script>
|
|
349
|
-
// Neuro-Symbolic Reasoning Engine with AgentDB
|
|
350
|
-
class NeuroSymbolicDB {
|
|
351
|
-
constructor() {
|
|
352
|
-
this.rules = [];
|
|
353
|
-
this.facts = new Set();
|
|
354
|
-
this.neuralPatterns = [];
|
|
355
|
-
this.inferenceHistory = [];
|
|
356
|
-
this.neuralWeights = this.initializeNeuralNetwork();
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
initializeNeuralNetwork() {
|
|
360
|
-
return {
|
|
361
|
-
embeddings: new Map(),
|
|
362
|
-
weights: Array(256).fill(0).map(() => Math.random() * 0.1 - 0.05),
|
|
363
|
-
bias: 0
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
addRule(premise, conclusion, confidence = 1.0) {
|
|
368
|
-
const rule = {
|
|
369
|
-
premise,
|
|
370
|
-
conclusion,
|
|
371
|
-
confidence,
|
|
372
|
-
embedding: this.generateRuleEmbedding(premise, conclusion),
|
|
373
|
-
timestamp: Date.now()
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
this.rules.push(rule);
|
|
377
|
-
logMessage(`Added rule: IF ${premise.join(' AND ')} THEN ${conclusion}`, 'success');
|
|
378
|
-
return rule;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
addFact(fact) {
|
|
382
|
-
this.facts.add(fact.toLowerCase());
|
|
383
|
-
logMessage(`Fact added: ${fact}`, 'info');
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
generateRuleEmbedding(premise, conclusion) {
|
|
387
|
-
const embedding = new Array(256).fill(0);
|
|
388
|
-
const text = premise.join(' ') + ' ' + conclusion;
|
|
389
|
-
|
|
390
|
-
for (let i = 0; i < text.length; i++) {
|
|
391
|
-
const char = text.charCodeAt(i);
|
|
392
|
-
embedding[i % 256] += Math.sin(char * (i + 1)) / text.length;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
return this.normalize(embedding);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
async trainNeuralPatterns(examples) {
|
|
399
|
-
logMessage('🧠 Training neural component on pattern examples...', 'info');
|
|
400
|
-
|
|
401
|
-
for (let epoch = 0; epoch < 50; epoch++) {
|
|
402
|
-
let totalLoss = 0;
|
|
403
|
-
|
|
404
|
-
examples.forEach(ex => {
|
|
405
|
-
const embedding = this.generateRuleEmbedding(ex.input.split(' '), ex.output);
|
|
406
|
-
const prediction = this.neuralForward(embedding);
|
|
407
|
-
const target = ex.label;
|
|
408
|
-
|
|
409
|
-
// Compute loss
|
|
410
|
-
const loss = Math.pow(prediction - target, 2);
|
|
411
|
-
totalLoss += loss;
|
|
412
|
-
|
|
413
|
-
// Update weights (gradient descent)
|
|
414
|
-
const gradient = 2 * (prediction - target);
|
|
415
|
-
for (let i = 0; i < this.neuralWeights.weights.length; i++) {
|
|
416
|
-
this.neuralWeights.weights[i] -= 0.01 * gradient * embedding[i];
|
|
417
|
-
}
|
|
418
|
-
this.neuralWeights.bias -= 0.01 * gradient;
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
if (epoch % 10 === 0) {
|
|
422
|
-
logMessage(`Neural training epoch ${epoch}, loss: ${(totalLoss / examples.length).toFixed(4)}`, 'info');
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
this.neuralPatterns.push(...examples);
|
|
427
|
-
logMessage('✅ Neural component trained successfully', 'success');
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
neuralForward(embedding) {
|
|
431
|
-
let activation = this.neuralWeights.bias;
|
|
432
|
-
for (let i = 0; i < Math.min(embedding.length, this.neuralWeights.weights.length); i++) {
|
|
433
|
-
activation += embedding[i] * this.neuralWeights.weights[i];
|
|
434
|
-
}
|
|
435
|
-
return 1 / (1 + Math.exp(-activation)); // Sigmoid
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
async reason(query) {
|
|
439
|
-
const reasoningChain = [];
|
|
440
|
-
const queryLower = query.toLowerCase();
|
|
441
|
-
|
|
442
|
-
logMessage(`🔍 Reasoning about: "${query}"`, 'info');
|
|
443
|
-
|
|
444
|
-
// Step 1: Neural component - pattern matching
|
|
445
|
-
const queryEmbedding = this.generateRuleEmbedding([query], '');
|
|
446
|
-
const neuralConfidence = this.neuralForward(queryEmbedding);
|
|
447
|
-
|
|
448
|
-
reasoningChain.push({
|
|
449
|
-
type: 'neural',
|
|
450
|
-
description: 'Neural pattern recognition',
|
|
451
|
-
inference: `Pattern similarity detected with ${(neuralConfidence * 100).toFixed(1)}% confidence`,
|
|
452
|
-
confidence: neuralConfidence
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
// Step 2: Symbolic component - rule matching
|
|
456
|
-
const matchingRules = this.findMatchingRules(queryLower);
|
|
457
|
-
let symbolicConfidence = 0;
|
|
458
|
-
|
|
459
|
-
if (matchingRules.length > 0) {
|
|
460
|
-
symbolicConfidence = Math.max(...matchingRules.map(r => r.confidence));
|
|
461
|
-
|
|
462
|
-
matchingRules.forEach(rule => {
|
|
463
|
-
reasoningChain.push({
|
|
464
|
-
type: 'symbolic',
|
|
465
|
-
description: 'Symbolic rule application',
|
|
466
|
-
inference: `IF ${rule.premise.join(' AND ')} THEN ${rule.conclusion}`,
|
|
467
|
-
confidence: rule.confidence
|
|
468
|
-
});
|
|
469
|
-
});
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
// Step 3: Forward chaining inference
|
|
473
|
-
const derived = await this.forwardChaining(queryLower, reasoningChain);
|
|
474
|
-
|
|
475
|
-
// Step 4: Hybrid decision
|
|
476
|
-
const hybridConfidence = (neuralConfidence * 0.4 + symbolicConfidence * 0.6);
|
|
477
|
-
const conclusion = hybridConfidence > 0.5 ? 'TRUE' : 'UNKNOWN';
|
|
478
|
-
|
|
479
|
-
reasoningChain.push({
|
|
480
|
-
type: 'hybrid',
|
|
481
|
-
description: 'Hybrid neuro-symbolic decision',
|
|
482
|
-
inference: `Combining neural (${(neuralConfidence*100).toFixed(1)}%) and symbolic (${(symbolicConfidence*100).toFixed(1)}%) reasoning`,
|
|
483
|
-
confidence: hybridConfidence
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
this.inferenceHistory.push({
|
|
487
|
-
query,
|
|
488
|
-
chain: reasoningChain,
|
|
489
|
-
conclusion,
|
|
490
|
-
confidence: hybridConfidence,
|
|
491
|
-
timestamp: Date.now()
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
return {
|
|
495
|
-
conclusion,
|
|
496
|
-
confidence: hybridConfidence,
|
|
497
|
-
chain: reasoningChain,
|
|
498
|
-
neuralConfidence,
|
|
499
|
-
symbolicConfidence
|
|
500
|
-
};
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
findMatchingRules(query) {
|
|
504
|
-
return this.rules.filter(rule => {
|
|
505
|
-
// Check if all premises are satisfied
|
|
506
|
-
return rule.premise.every(p => {
|
|
507
|
-
const pLower = p.toLowerCase();
|
|
508
|
-
return this.facts.has(pLower) || query.includes(pLower);
|
|
509
|
-
});
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
async forwardChaining(query, chain) {
|
|
514
|
-
const derivedFacts = new Set(this.facts);
|
|
515
|
-
let iterations = 0;
|
|
516
|
-
let newFactsAdded = true;
|
|
517
|
-
|
|
518
|
-
while (newFactsAdded && iterations < 10) {
|
|
519
|
-
newFactsAdded = false;
|
|
520
|
-
iterations++;
|
|
521
|
-
|
|
522
|
-
for (const rule of this.rules) {
|
|
523
|
-
if (rule.premise.every(p => derivedFacts.has(p.toLowerCase()))) {
|
|
524
|
-
const conclusion = rule.conclusion.toLowerCase();
|
|
525
|
-
if (!derivedFacts.has(conclusion)) {
|
|
526
|
-
derivedFacts.add(conclusion);
|
|
527
|
-
newFactsAdded = true;
|
|
528
|
-
|
|
529
|
-
chain.push({
|
|
530
|
-
type: 'inference',
|
|
531
|
-
description: `Forward chaining iteration ${iterations}`,
|
|
532
|
-
inference: `Derived: ${rule.conclusion}`,
|
|
533
|
-
confidence: rule.confidence
|
|
534
|
-
});
|
|
535
|
-
|
|
536
|
-
logMessage(`Inferred: ${rule.conclusion}`, 'success');
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
return Array.from(derivedFacts);
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
normalize(vec) {
|
|
546
|
-
const mag = Math.sqrt(vec.reduce((sum, v) => sum + v * v, 0));
|
|
547
|
-
return vec.map(v => v / (mag || 1));
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
// Global state
|
|
552
|
-
const db = new NeuroSymbolicDB();
|
|
553
|
-
let stats = {
|
|
554
|
-
ruleCount: 0,
|
|
555
|
-
patternCount: 0,
|
|
556
|
-
inferenceCount: 0,
|
|
557
|
-
accuracy: 0
|
|
558
|
-
};
|
|
559
|
-
|
|
560
|
-
// Initialize with classic logic examples
|
|
561
|
-
function initializeKnowledgeBase() {
|
|
562
|
-
// Classic Socrates example
|
|
563
|
-
db.addRule(['socrates is a man', 'all men are mortal'], 'socrates is mortal', 1.0);
|
|
564
|
-
db.addRule(['all men are mortal'], 'if x is a man then x is mortal', 1.0);
|
|
565
|
-
db.addFact('socrates is a man');
|
|
566
|
-
db.addFact('all men are mortal');
|
|
567
|
-
|
|
568
|
-
// Additional rules
|
|
569
|
-
db.addRule(['birds can fly', 'tweety is a bird'], 'tweety can fly', 0.9);
|
|
570
|
-
db.addRule(['mammals have fur', 'dogs are mammals'], 'dogs have fur', 0.95);
|
|
571
|
-
db.addFact('tweety is a bird');
|
|
572
|
-
db.addFact('birds can fly');
|
|
573
|
-
|
|
574
|
-
stats.ruleCount = db.rules.length;
|
|
575
|
-
updateStats();
|
|
576
|
-
displayKnowledgeBase();
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
function displayKnowledgeBase() {
|
|
580
|
-
const container = document.getElementById('knowledgeBase');
|
|
581
|
-
container.innerHTML = '';
|
|
582
|
-
|
|
583
|
-
db.rules.forEach((rule, idx) => {
|
|
584
|
-
const div = document.createElement('div');
|
|
585
|
-
div.className = 'rule-item';
|
|
586
|
-
div.innerHTML = `
|
|
587
|
-
<div class="rule-premise">IF ${rule.premise.join(' AND ')}</div>
|
|
588
|
-
<div class="rule-conclusion">THEN ${rule.conclusion} (conf: ${(rule.confidence*100).toFixed(0)}%)</div>
|
|
589
|
-
`;
|
|
590
|
-
container.appendChild(div);
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
function addRule() {
|
|
595
|
-
const input = document.getElementById('ruleInput').value.trim();
|
|
596
|
-
if (!input) return;
|
|
597
|
-
|
|
598
|
-
// Parse simple IF-THEN rule
|
|
599
|
-
const match = input.match(/IF\s+(.+)\s+THEN\s+(.+)/i);
|
|
600
|
-
if (match) {
|
|
601
|
-
const premises = match[1].split(/\s+AND\s+/i).map(p => p.trim());
|
|
602
|
-
const conclusion = match[2].trim();
|
|
603
|
-
|
|
604
|
-
db.addRule(premises, conclusion, 1.0);
|
|
605
|
-
stats.ruleCount = db.rules.length;
|
|
606
|
-
updateStats();
|
|
607
|
-
displayKnowledgeBase();
|
|
608
|
-
|
|
609
|
-
document.getElementById('ruleInput').value = '';
|
|
610
|
-
} else {
|
|
611
|
-
logMessage('Invalid rule format. Use: IF condition THEN conclusion', 'info');
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
async function trainNeuralComponent() {
|
|
616
|
-
// Generate training examples from rules
|
|
617
|
-
const examples = db.rules.map(rule => ({
|
|
618
|
-
input: rule.premise.join(' '),
|
|
619
|
-
output: rule.conclusion,
|
|
620
|
-
label: rule.confidence
|
|
621
|
-
}));
|
|
622
|
-
|
|
623
|
-
await db.trainNeuralPatterns(examples);
|
|
624
|
-
stats.patternCount = db.neuralPatterns.length;
|
|
625
|
-
updateStats();
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
async function reason() {
|
|
629
|
-
const query = document.getElementById('queryInput').value.trim();
|
|
630
|
-
if (!query) return;
|
|
631
|
-
|
|
632
|
-
const result = await db.reason(query);
|
|
633
|
-
|
|
634
|
-
stats.inferenceCount++;
|
|
635
|
-
stats.accuracy = Math.floor((stats.inferenceCount > 0 ? 1 : 0) * 100);
|
|
636
|
-
updateStats();
|
|
637
|
-
|
|
638
|
-
// Display reasoning chain
|
|
639
|
-
const chainContainer = document.getElementById('reasoningChain');
|
|
640
|
-
chainContainer.innerHTML = '';
|
|
641
|
-
|
|
642
|
-
result.chain.forEach((step, idx) => {
|
|
643
|
-
const div = document.createElement('div');
|
|
644
|
-
div.className = 'reasoning-step';
|
|
645
|
-
div.innerHTML = `
|
|
646
|
-
<div class="step-number">Step ${idx + 1}: ${step.description}</div>
|
|
647
|
-
<div class="step-inference">${step.inference}</div>
|
|
648
|
-
<div class="step-confidence">Confidence: ${(step.confidence * 100).toFixed(1)}%</div>
|
|
649
|
-
`;
|
|
650
|
-
chainContainer.appendChild(div);
|
|
651
|
-
});
|
|
652
|
-
|
|
653
|
-
// Display conclusion
|
|
654
|
-
const conclusionBox = document.getElementById('conclusion');
|
|
655
|
-
const conclusionText = document.getElementById('conclusionText');
|
|
656
|
-
conclusionBox.style.display = 'block';
|
|
657
|
-
conclusionText.textContent = `${result.conclusion} (${(result.confidence * 100).toFixed(1)}% confidence)`;
|
|
658
|
-
|
|
659
|
-
// Update hybrid indicators
|
|
660
|
-
document.getElementById('neuralConfidence').textContent = (result.neuralConfidence * 100).toFixed(1) + '%';
|
|
661
|
-
document.getElementById('symbolicMatch').textContent = (result.symbolicConfidence * 100).toFixed(1) + '%';
|
|
662
|
-
|
|
663
|
-
logMessage(`Reasoning complete: ${result.conclusion}`, 'success');
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
function updateStats() {
|
|
667
|
-
document.getElementById('ruleCount').textContent = stats.ruleCount;
|
|
668
|
-
document.getElementById('patternCount').textContent = stats.patternCount;
|
|
669
|
-
document.getElementById('inferenceCount').textContent = stats.inferenceCount;
|
|
670
|
-
document.getElementById('accuracy').textContent = stats.accuracy + '%';
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
function logMessage(message, type = '') {
|
|
674
|
-
const log = document.getElementById('log');
|
|
675
|
-
const entry = document.createElement('div');
|
|
676
|
-
entry.className = `log-entry ${type}`;
|
|
677
|
-
const timestamp = new Date().toLocaleTimeString();
|
|
678
|
-
entry.textContent = `[${timestamp}] ${message}`;
|
|
679
|
-
log.insertBefore(entry, log.firstChild);
|
|
680
|
-
|
|
681
|
-
while (log.children.length > 20) {
|
|
682
|
-
log.removeChild(log.lastChild);
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
// Initialize
|
|
687
|
-
initializeKnowledgeBase();
|
|
688
|
-
logMessage('🧬 Neuro-Symbolic reasoning engine initialized', 'success');
|
|
689
|
-
logMessage('Try querying: "Is Socrates mortal?" or "Can tweety fly?"', 'info');
|
|
690
|
-
</script>
|
|
691
|
-
</body>
|
|
692
|
-
</html>
|