agentdb 3.0.0-alpha.3 → 3.0.0-alpha.4

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.
Files changed (1038) hide show
  1. package/README.md +978 -2342
  2. package/dist/agentdb.browser.js +1492 -0
  3. package/dist/agentdb.browser.js.map +7 -0
  4. package/dist/agentdb.browser.min.js +3 -0
  5. package/dist/agentdb.browser.min.js.map +7 -0
  6. package/dist/agentdb.wasm-loader.js +207 -0
  7. package/dist/schemas/frontier-schema.sql +0 -7
  8. package/dist/schemas/schema.sql +0 -7
  9. package/dist/simulation/cli.d.ts +9 -0
  10. package/dist/simulation/cli.d.ts.map +1 -0
  11. package/dist/simulation/cli.js +68 -0
  12. package/dist/simulation/cli.js.map +1 -0
  13. package/dist/simulation/runner.d.ts +21 -0
  14. package/dist/simulation/runner.d.ts.map +1 -0
  15. package/dist/simulation/runner.js +241 -0
  16. package/dist/simulation/runner.js.map +1 -0
  17. package/dist/simulation/scenarios/aidefence-integration.d.ts +24 -0
  18. package/dist/simulation/scenarios/aidefence-integration.d.ts.map +1 -0
  19. package/dist/simulation/scenarios/aidefence-integration.js +124 -0
  20. package/dist/simulation/scenarios/aidefence-integration.js.map +1 -0
  21. package/dist/simulation/scenarios/bmssp-integration.d.ts +23 -0
  22. package/dist/simulation/scenarios/bmssp-integration.d.ts.map +1 -0
  23. package/dist/simulation/scenarios/bmssp-integration.js +104 -0
  24. package/dist/simulation/scenarios/bmssp-integration.js.map +1 -0
  25. package/dist/simulation/scenarios/causal-reasoning.d.ts +16 -0
  26. package/dist/simulation/scenarios/causal-reasoning.d.ts.map +1 -0
  27. package/dist/simulation/scenarios/causal-reasoning.js +108 -0
  28. package/dist/simulation/scenarios/causal-reasoning.js.map +1 -0
  29. package/dist/simulation/scenarios/consciousness-explorer.d.ts +25 -0
  30. package/dist/simulation/scenarios/consciousness-explorer.d.ts.map +1 -0
  31. package/dist/simulation/scenarios/consciousness-explorer.js +108 -0
  32. package/dist/simulation/scenarios/consciousness-explorer.js.map +1 -0
  33. package/dist/simulation/scenarios/domain-examples/e-commerce-recommendations.d.ts +135 -0
  34. package/dist/simulation/scenarios/domain-examples/e-commerce-recommendations.d.ts.map +1 -0
  35. package/dist/simulation/scenarios/domain-examples/e-commerce-recommendations.js +158 -0
  36. package/dist/simulation/scenarios/domain-examples/e-commerce-recommendations.js.map +1 -0
  37. package/dist/simulation/scenarios/domain-examples/index.d.ts +14 -0
  38. package/dist/simulation/scenarios/domain-examples/index.d.ts.map +1 -0
  39. package/dist/simulation/scenarios/domain-examples/index.js +14 -0
  40. package/dist/simulation/scenarios/domain-examples/index.js.map +1 -0
  41. package/dist/simulation/scenarios/domain-examples/iot-sensor-networks.d.ts +178 -0
  42. package/dist/simulation/scenarios/domain-examples/iot-sensor-networks.d.ts.map +1 -0
  43. package/dist/simulation/scenarios/domain-examples/iot-sensor-networks.js +218 -0
  44. package/dist/simulation/scenarios/domain-examples/iot-sensor-networks.js.map +1 -0
  45. package/dist/simulation/scenarios/domain-examples/medical-imaging.d.ts +122 -0
  46. package/dist/simulation/scenarios/domain-examples/medical-imaging.d.ts.map +1 -0
  47. package/dist/simulation/scenarios/domain-examples/medical-imaging.js +129 -0
  48. package/dist/simulation/scenarios/domain-examples/medical-imaging.js.map +1 -0
  49. package/dist/simulation/scenarios/domain-examples/robotics-navigation.d.ts +166 -0
  50. package/dist/simulation/scenarios/domain-examples/robotics-navigation.d.ts.map +1 -0
  51. package/dist/simulation/scenarios/domain-examples/robotics-navigation.js +161 -0
  52. package/dist/simulation/scenarios/domain-examples/robotics-navigation.js.map +1 -0
  53. package/dist/simulation/scenarios/domain-examples/scientific-research.d.ts +151 -0
  54. package/dist/simulation/scenarios/domain-examples/scientific-research.d.ts.map +1 -0
  55. package/dist/simulation/scenarios/domain-examples/scientific-research.js +187 -0
  56. package/dist/simulation/scenarios/domain-examples/scientific-research.js.map +1 -0
  57. package/dist/simulation/scenarios/domain-examples/trading-systems.d.ts +102 -0
  58. package/dist/simulation/scenarios/domain-examples/trading-systems.d.ts.map +1 -0
  59. package/dist/simulation/scenarios/domain-examples/trading-systems.js +100 -0
  60. package/dist/simulation/scenarios/domain-examples/trading-systems.js.map +1 -0
  61. package/dist/simulation/scenarios/goalie-integration.d.ts +24 -0
  62. package/dist/simulation/scenarios/goalie-integration.d.ts.map +1 -0
  63. package/dist/simulation/scenarios/goalie-integration.js +121 -0
  64. package/dist/simulation/scenarios/goalie-integration.js.map +1 -0
  65. package/dist/simulation/scenarios/graph-traversal.d.ts +17 -0
  66. package/dist/simulation/scenarios/graph-traversal.d.ts.map +1 -0
  67. package/dist/simulation/scenarios/graph-traversal.js +101 -0
  68. package/dist/simulation/scenarios/graph-traversal.js.map +1 -0
  69. package/dist/simulation/scenarios/latent-space/attention-analysis.d.ts +45 -0
  70. package/dist/simulation/scenarios/latent-space/attention-analysis.d.ts.map +1 -0
  71. package/dist/simulation/scenarios/latent-space/attention-analysis.js +435 -0
  72. package/dist/simulation/scenarios/latent-space/attention-analysis.js.map +1 -0
  73. package/dist/simulation/scenarios/latent-space/clustering-analysis.d.ts +55 -0
  74. package/dist/simulation/scenarios/latent-space/clustering-analysis.d.ts.map +1 -0
  75. package/dist/simulation/scenarios/latent-space/clustering-analysis.js +606 -0
  76. package/dist/simulation/scenarios/latent-space/clustering-analysis.js.map +1 -0
  77. package/dist/simulation/scenarios/latent-space/hnsw-exploration.d.ts +74 -0
  78. package/dist/simulation/scenarios/latent-space/hnsw-exploration.d.ts.map +1 -0
  79. package/dist/simulation/scenarios/latent-space/hnsw-exploration.js +391 -0
  80. package/dist/simulation/scenarios/latent-space/hnsw-exploration.js.map +1 -0
  81. package/dist/simulation/scenarios/latent-space/hypergraph-exploration.d.ts +51 -0
  82. package/dist/simulation/scenarios/latent-space/hypergraph-exploration.d.ts.map +1 -0
  83. package/dist/simulation/scenarios/latent-space/hypergraph-exploration.js +536 -0
  84. package/dist/simulation/scenarios/latent-space/hypergraph-exploration.js.map +1 -0
  85. package/dist/simulation/scenarios/latent-space/index.d.ts +35 -0
  86. package/dist/simulation/scenarios/latent-space/index.d.ts.map +1 -0
  87. package/dist/simulation/scenarios/latent-space/index.js +35 -0
  88. package/dist/simulation/scenarios/latent-space/index.js.map +1 -0
  89. package/dist/simulation/scenarios/latent-space/neural-augmentation.d.ts +52 -0
  90. package/dist/simulation/scenarios/latent-space/neural-augmentation.d.ts.map +1 -0
  91. package/dist/simulation/scenarios/latent-space/neural-augmentation.js +472 -0
  92. package/dist/simulation/scenarios/latent-space/neural-augmentation.js.map +1 -0
  93. package/dist/simulation/scenarios/latent-space/quantum-hybrid.d.ts +53 -0
  94. package/dist/simulation/scenarios/latent-space/quantum-hybrid.d.ts.map +1 -0
  95. package/dist/simulation/scenarios/latent-space/quantum-hybrid.js +391 -0
  96. package/dist/simulation/scenarios/latent-space/quantum-hybrid.js.map +1 -0
  97. package/dist/simulation/scenarios/latent-space/self-organizing-hnsw.d.ts +52 -0
  98. package/dist/simulation/scenarios/latent-space/self-organizing-hnsw.d.ts.map +1 -0
  99. package/dist/simulation/scenarios/latent-space/self-organizing-hnsw.js +514 -0
  100. package/dist/simulation/scenarios/latent-space/self-organizing-hnsw.js.map +1 -0
  101. package/dist/simulation/scenarios/latent-space/traversal-optimization.d.ts +53 -0
  102. package/dist/simulation/scenarios/latent-space/traversal-optimization.d.ts.map +1 -0
  103. package/dist/simulation/scenarios/latent-space/traversal-optimization.js +595 -0
  104. package/dist/simulation/scenarios/latent-space/traversal-optimization.js.map +1 -0
  105. package/dist/simulation/scenarios/lean-agentic-swarm.d.ts +18 -0
  106. package/dist/simulation/scenarios/lean-agentic-swarm.d.ts.map +1 -0
  107. package/dist/simulation/scenarios/lean-agentic-swarm.js +132 -0
  108. package/dist/simulation/scenarios/lean-agentic-swarm.js.map +1 -0
  109. package/dist/simulation/scenarios/multi-agent-swarm.d.ts +17 -0
  110. package/dist/simulation/scenarios/multi-agent-swarm.d.ts.map +1 -0
  111. package/dist/simulation/scenarios/multi-agent-swarm.js +111 -0
  112. package/dist/simulation/scenarios/multi-agent-swarm.js.map +1 -0
  113. package/dist/simulation/scenarios/psycho-symbolic-reasoner.d.ts +23 -0
  114. package/dist/simulation/scenarios/psycho-symbolic-reasoner.d.ts.map +1 -0
  115. package/dist/simulation/scenarios/psycho-symbolic-reasoner.js +98 -0
  116. package/dist/simulation/scenarios/psycho-symbolic-reasoner.js.map +1 -0
  117. package/dist/simulation/scenarios/reflexion-learning.d.ts +16 -0
  118. package/dist/simulation/scenarios/reflexion-learning.d.ts.map +1 -0
  119. package/dist/simulation/scenarios/reflexion-learning.js +98 -0
  120. package/dist/simulation/scenarios/reflexion-learning.js.map +1 -0
  121. package/dist/simulation/scenarios/research-swarm.d.ts +24 -0
  122. package/dist/simulation/scenarios/research-swarm.d.ts.map +1 -0
  123. package/dist/simulation/scenarios/research-swarm.js +146 -0
  124. package/dist/simulation/scenarios/research-swarm.js.map +1 -0
  125. package/dist/simulation/scenarios/skill-evolution.d.ts +16 -0
  126. package/dist/simulation/scenarios/skill-evolution.d.ts.map +1 -0
  127. package/dist/simulation/scenarios/skill-evolution.js +109 -0
  128. package/dist/simulation/scenarios/skill-evolution.js.map +1 -0
  129. package/dist/simulation/scenarios/stock-market-emergence.d.ts +33 -0
  130. package/dist/simulation/scenarios/stock-market-emergence.d.ts.map +1 -0
  131. package/dist/simulation/scenarios/stock-market-emergence.js +246 -0
  132. package/dist/simulation/scenarios/stock-market-emergence.js.map +1 -0
  133. package/dist/simulation/scenarios/strange-loops.d.ts +18 -0
  134. package/dist/simulation/scenarios/strange-loops.d.ts.map +1 -0
  135. package/dist/simulation/scenarios/strange-loops.js +133 -0
  136. package/dist/simulation/scenarios/strange-loops.js.map +1 -0
  137. package/dist/simulation/scenarios/sublinear-solver.d.ts +22 -0
  138. package/dist/simulation/scenarios/sublinear-solver.d.ts.map +1 -0
  139. package/dist/simulation/scenarios/sublinear-solver.js +82 -0
  140. package/dist/simulation/scenarios/sublinear-solver.js.map +1 -0
  141. package/dist/simulation/scenarios/temporal-lead-solver.d.ts +23 -0
  142. package/dist/simulation/scenarios/temporal-lead-solver.d.ts.map +1 -0
  143. package/dist/simulation/scenarios/temporal-lead-solver.js +90 -0
  144. package/dist/simulation/scenarios/temporal-lead-solver.js.map +1 -0
  145. package/dist/simulation/scenarios/voting-system-consensus.d.ts +27 -0
  146. package/dist/simulation/scenarios/voting-system-consensus.d.ts.map +1 -0
  147. package/dist/simulation/scenarios/voting-system-consensus.js +175 -0
  148. package/dist/simulation/scenarios/voting-system-consensus.js.map +1 -0
  149. package/dist/simulation/types.d.ts +162 -0
  150. package/dist/simulation/types.d.ts.map +1 -0
  151. package/dist/simulation/types.js +5 -0
  152. package/dist/simulation/types.js.map +1 -0
  153. package/dist/simulation/utils/PerformanceOptimizer.d.ts +115 -0
  154. package/dist/simulation/utils/PerformanceOptimizer.d.ts.map +1 -0
  155. package/dist/simulation/utils/PerformanceOptimizer.js +223 -0
  156. package/dist/simulation/utils/PerformanceOptimizer.js.map +1 -0
  157. package/dist/src/backends/GraphBackend.d.ts +8 -8
  158. package/dist/src/backends/GraphBackend.d.ts.map +1 -1
  159. package/dist/src/backends/GraphBackend.js +15 -16
  160. package/dist/src/backends/GraphBackend.js.map +1 -1
  161. package/dist/src/backends/LearningBackend.d.ts +2 -2
  162. package/dist/src/backends/LearningBackend.d.ts.map +1 -1
  163. package/dist/src/backends/LearningBackend.js +10 -11
  164. package/dist/src/backends/LearningBackend.js.map +1 -1
  165. package/dist/src/backends/VectorBackend.d.ts +6 -31
  166. package/dist/src/backends/VectorBackend.d.ts.map +1 -1
  167. package/dist/src/backends/detector.d.ts +3 -25
  168. package/dist/src/backends/detector.d.ts.map +1 -1
  169. package/dist/src/backends/detector.js +15 -119
  170. package/dist/src/backends/detector.js.map +1 -1
  171. package/dist/src/backends/factory.d.ts +32 -16
  172. package/dist/src/backends/factory.d.ts.map +1 -1
  173. package/dist/src/backends/factory.js +70 -133
  174. package/dist/src/backends/factory.js.map +1 -1
  175. package/dist/src/backends/graph/GraphDatabaseAdapter.d.ts +1 -1
  176. package/dist/src/backends/graph/GraphDatabaseAdapter.d.ts.map +1 -1
  177. package/dist/src/backends/graph/GraphDatabaseAdapter.js +1 -5
  178. package/dist/src/backends/graph/GraphDatabaseAdapter.js.map +1 -1
  179. package/dist/src/backends/hnswlib/HNSWLibBackend.d.ts +2 -2
  180. package/dist/src/backends/hnswlib/HNSWLibBackend.d.ts.map +1 -1
  181. package/dist/src/backends/hnswlib/HNSWLibBackend.js +13 -49
  182. package/dist/src/backends/hnswlib/HNSWLibBackend.js.map +1 -1
  183. package/dist/src/backends/index.d.ts +3 -25
  184. package/dist/src/backends/index.d.ts.map +1 -1
  185. package/dist/src/backends/index.js +1 -23
  186. package/dist/src/backends/index.js.map +1 -1
  187. package/dist/src/backends/ruvector/GuardedVectorBackend.d.ts +93 -0
  188. package/dist/src/backends/ruvector/GuardedVectorBackend.d.ts.map +1 -0
  189. package/dist/src/backends/ruvector/GuardedVectorBackend.js +182 -0
  190. package/dist/src/backends/ruvector/GuardedVectorBackend.js.map +1 -0
  191. package/dist/src/backends/ruvector/RuVectorBackend.d.ts +16 -187
  192. package/dist/src/backends/ruvector/RuVectorBackend.d.ts.map +1 -1
  193. package/dist/src/backends/ruvector/RuVectorBackend.js +94 -576
  194. package/dist/src/backends/ruvector/RuVectorBackend.js.map +1 -1
  195. package/dist/src/backends/ruvector/RuVectorLearning.d.ts +4 -0
  196. package/dist/src/backends/ruvector/RuVectorLearning.d.ts.map +1 -1
  197. package/dist/src/backends/ruvector/RuVectorLearning.js +11 -10
  198. package/dist/src/backends/ruvector/RuVectorLearning.js.map +1 -1
  199. package/dist/src/benchmarks/wasm-vector-benchmark.d.ts +10 -0
  200. package/dist/src/benchmarks/wasm-vector-benchmark.d.ts.map +1 -0
  201. package/dist/src/benchmarks/wasm-vector-benchmark.js +196 -0
  202. package/dist/src/benchmarks/wasm-vector-benchmark.js.map +1 -0
  203. package/dist/src/browser/AdvancedFeatures.d.ts.map +1 -1
  204. package/dist/src/browser/AdvancedFeatures.js +10 -3
  205. package/dist/src/browser/AdvancedFeatures.js.map +1 -1
  206. package/dist/src/browser/AttentionBrowser.d.ts.map +1 -1
  207. package/dist/src/browser/AttentionBrowser.js +12 -5
  208. package/dist/src/browser/AttentionBrowser.js.map +1 -1
  209. package/dist/src/browser/HNSWIndex.d.ts +1 -31
  210. package/dist/src/browser/HNSWIndex.d.ts.map +1 -1
  211. package/dist/src/browser/HNSWIndex.js +18 -136
  212. package/dist/src/browser/HNSWIndex.js.map +1 -1
  213. package/dist/src/browser/ProductQuantization.d.ts.map +1 -1
  214. package/dist/src/browser/ProductQuantization.js +1 -0
  215. package/dist/src/browser/ProductQuantization.js.map +1 -1
  216. package/dist/src/browser/index.d.ts +3 -3
  217. package/dist/src/browser/index.d.ts.map +1 -1
  218. package/dist/src/browser/index.js +1 -2
  219. package/dist/src/browser/index.js.map +1 -1
  220. package/dist/src/cli/agentdb-cli.d.ts +2 -16
  221. package/dist/src/cli/agentdb-cli.d.ts.map +1 -1
  222. package/dist/src/cli/agentdb-cli.js +216 -853
  223. package/dist/src/cli/agentdb-cli.js.map +1 -1
  224. package/dist/src/cli/commands/attention.js +3 -3
  225. package/dist/src/cli/commands/attention.js.map +1 -1
  226. package/dist/src/cli/commands/doctor.d.ts +0 -2
  227. package/dist/src/cli/commands/doctor.d.ts.map +1 -1
  228. package/dist/src/cli/commands/doctor.js +1 -106
  229. package/dist/src/cli/commands/doctor.js.map +1 -1
  230. package/dist/src/cli/commands/init.d.ts +1 -2
  231. package/dist/src/cli/commands/init.d.ts.map +1 -1
  232. package/dist/src/cli/commands/init.js +7 -30
  233. package/dist/src/cli/commands/init.js.map +1 -1
  234. package/dist/src/cli/commands/install-embeddings.d.ts.map +1 -1
  235. package/dist/src/cli/commands/install-embeddings.js.map +1 -1
  236. package/dist/src/cli/commands/migrate.d.ts +0 -15
  237. package/dist/src/cli/commands/migrate.d.ts.map +1 -1
  238. package/dist/src/cli/commands/migrate.js +5 -174
  239. package/dist/src/cli/commands/migrate.js.map +1 -1
  240. package/dist/src/cli/commands/simulate-report.js.map +1 -1
  241. package/dist/src/cli/commands/simulate-wizard.js.map +1 -1
  242. package/dist/src/cli/commands/simulate.d.ts +7 -0
  243. package/dist/src/cli/commands/simulate.d.ts.map +1 -0
  244. package/dist/src/cli/commands/simulate.js +100 -0
  245. package/dist/src/cli/commands/simulate.js.map +1 -0
  246. package/dist/src/cli/commands/status.js +1 -5
  247. package/dist/src/cli/commands/status.js.map +1 -1
  248. package/dist/src/cli/lib/attention-config.d.ts +2 -2
  249. package/dist/src/cli/lib/attention-config.d.ts.map +1 -1
  250. package/dist/src/cli/lib/attention-config.js +1 -2
  251. package/dist/src/cli/lib/attention-config.js.map +1 -1
  252. package/dist/src/cli/lib/config-manager.d.ts +110 -0
  253. package/dist/src/cli/lib/config-manager.d.ts.map +1 -0
  254. package/dist/src/cli/lib/config-manager.js +512 -0
  255. package/dist/src/cli/lib/config-manager.js.map +1 -0
  256. package/dist/src/cli/lib/config-validator.d.ts +1 -1
  257. package/dist/src/cli/lib/config-validator.d.ts.map +1 -1
  258. package/dist/src/cli/lib/health-monitor.d.ts +149 -0
  259. package/dist/src/cli/lib/health-monitor.d.ts.map +1 -0
  260. package/dist/src/cli/lib/health-monitor.js +380 -0
  261. package/dist/src/cli/lib/health-monitor.js.map +1 -0
  262. package/dist/src/cli/lib/history-tracker.d.ts +103 -0
  263. package/dist/src/cli/lib/history-tracker.d.ts.map +1 -0
  264. package/dist/src/cli/lib/history-tracker.js +352 -0
  265. package/dist/src/cli/lib/history-tracker.js.map +1 -0
  266. package/dist/src/cli/lib/report-store.d.ts +1 -2
  267. package/dist/src/cli/lib/report-store.d.ts.map +1 -1
  268. package/dist/src/cli/lib/report-store.js +65 -87
  269. package/dist/src/cli/lib/report-store.js.map +1 -1
  270. package/dist/src/cli/lib/simulation-registry.d.ts +1 -1
  271. package/dist/src/cli/lib/simulation-registry.d.ts.map +1 -1
  272. package/dist/src/cli/lib/simulation-registry.js +0 -1
  273. package/dist/src/cli/lib/simulation-registry.js.map +1 -1
  274. package/dist/src/cli/lib/simulation-runner.d.ts +4 -41
  275. package/dist/src/cli/lib/simulation-runner.d.ts.map +1 -1
  276. package/dist/src/cli/lib/simulation-runner.js +6 -251
  277. package/dist/src/cli/lib/simulation-runner.js.map +1 -1
  278. package/dist/src/controllers/AttentionService.d.ts.map +1 -1
  279. package/dist/src/controllers/AttentionService.js +5 -3
  280. package/dist/src/controllers/AttentionService.js.map +1 -1
  281. package/dist/src/controllers/CausalMemoryGraph.d.ts +8 -33
  282. package/dist/src/controllers/CausalMemoryGraph.d.ts.map +1 -1
  283. package/dist/src/controllers/CausalMemoryGraph.js +16 -93
  284. package/dist/src/controllers/CausalMemoryGraph.js.map +1 -1
  285. package/dist/src/controllers/CausalRecall.d.ts +3 -6
  286. package/dist/src/controllers/CausalRecall.d.ts.map +1 -1
  287. package/dist/src/controllers/CausalRecall.js +8 -14
  288. package/dist/src/controllers/CausalRecall.js.map +1 -1
  289. package/dist/src/controllers/ContextSynthesizer.d.ts +1 -1
  290. package/dist/src/controllers/ContextSynthesizer.d.ts.map +1 -1
  291. package/dist/src/controllers/EmbeddingService.d.ts.map +1 -1
  292. package/dist/src/controllers/EmbeddingService.js +3 -10
  293. package/dist/src/controllers/EmbeddingService.js.map +1 -1
  294. package/dist/src/controllers/EnhancedEmbeddingService.d.ts +0 -4
  295. package/dist/src/controllers/EnhancedEmbeddingService.d.ts.map +1 -1
  296. package/dist/src/controllers/EnhancedEmbeddingService.js +3 -10
  297. package/dist/src/controllers/EnhancedEmbeddingService.js.map +1 -1
  298. package/dist/src/controllers/ExplainableRecall.d.ts +6 -5
  299. package/dist/src/controllers/ExplainableRecall.d.ts.map +1 -1
  300. package/dist/src/controllers/ExplainableRecall.js +13 -21
  301. package/dist/src/controllers/ExplainableRecall.js.map +1 -1
  302. package/dist/src/controllers/HNSWIndex.d.ts +7 -24
  303. package/dist/src/controllers/HNSWIndex.d.ts.map +1 -1
  304. package/dist/src/controllers/HNSWIndex.js +10 -89
  305. package/dist/src/controllers/HNSWIndex.js.map +1 -1
  306. package/dist/src/controllers/LearningSystem.d.ts +10 -106
  307. package/dist/src/controllers/LearningSystem.d.ts.map +1 -1
  308. package/dist/src/controllers/LearningSystem.js +14 -39
  309. package/dist/src/controllers/LearningSystem.js.map +1 -1
  310. package/dist/src/controllers/MMRDiversityRanker.d.ts +1 -1
  311. package/dist/src/controllers/MMRDiversityRanker.d.ts.map +1 -1
  312. package/dist/src/controllers/MetadataFilter.d.ts +3 -3
  313. package/dist/src/controllers/MetadataFilter.d.ts.map +1 -1
  314. package/dist/src/controllers/MetadataFilter.js +6 -9
  315. package/dist/src/controllers/MetadataFilter.js.map +1 -1
  316. package/dist/src/controllers/NightlyLearner.d.ts +4 -9
  317. package/dist/src/controllers/NightlyLearner.d.ts.map +1 -1
  318. package/dist/src/controllers/NightlyLearner.js +9 -28
  319. package/dist/src/controllers/NightlyLearner.js.map +1 -1
  320. package/dist/src/controllers/QUICClient.d.ts +2 -50
  321. package/dist/src/controllers/QUICClient.d.ts.map +1 -1
  322. package/dist/src/controllers/QUICClient.js +3 -193
  323. package/dist/src/controllers/QUICClient.js.map +1 -1
  324. package/dist/src/controllers/QUICServer.d.ts +4 -4
  325. package/dist/src/controllers/QUICServer.d.ts.map +1 -1
  326. package/dist/src/controllers/QUICServer.js +14 -22
  327. package/dist/src/controllers/QUICServer.js.map +1 -1
  328. package/dist/src/controllers/ReasoningBank.d.ts +4 -14
  329. package/dist/src/controllers/ReasoningBank.d.ts.map +1 -1
  330. package/dist/src/controllers/ReasoningBank.js +46 -59
  331. package/dist/src/controllers/ReasoningBank.js.map +1 -1
  332. package/dist/src/controllers/ReflexionMemory.d.ts +7 -80
  333. package/dist/src/controllers/ReflexionMemory.d.ts.map +1 -1
  334. package/dist/src/controllers/ReflexionMemory.js +214 -372
  335. package/dist/src/controllers/ReflexionMemory.js.map +1 -1
  336. package/dist/src/controllers/SkillLibrary.d.ts +7 -37
  337. package/dist/src/controllers/SkillLibrary.d.ts.map +1 -1
  338. package/dist/src/controllers/SkillLibrary.js +96 -212
  339. package/dist/src/controllers/SkillLibrary.js.map +1 -1
  340. package/dist/src/controllers/SyncCoordinator.d.ts +3 -2
  341. package/dist/src/controllers/SyncCoordinator.d.ts.map +1 -1
  342. package/dist/src/controllers/SyncCoordinator.js +5 -117
  343. package/dist/src/controllers/SyncCoordinator.js.map +1 -1
  344. package/dist/src/controllers/WASMVectorSearch.d.ts +9 -20
  345. package/dist/src/controllers/WASMVectorSearch.d.ts.map +1 -1
  346. package/dist/src/controllers/WASMVectorSearch.js +29 -154
  347. package/dist/src/controllers/WASMVectorSearch.js.map +1 -1
  348. package/dist/src/controllers/frontier-index.d.ts +14 -0
  349. package/dist/src/controllers/frontier-index.d.ts.map +1 -0
  350. package/dist/src/controllers/frontier-index.js +10 -0
  351. package/dist/src/controllers/frontier-index.js.map +1 -0
  352. package/dist/src/controllers/index.d.ts +17 -8
  353. package/dist/src/controllers/index.d.ts.map +1 -1
  354. package/dist/src/controllers/index.js +12 -6
  355. package/dist/src/controllers/index.js.map +1 -1
  356. package/dist/src/core/AgentDB.d.ts +25 -57
  357. package/dist/src/core/AgentDB.d.ts.map +1 -1
  358. package/dist/src/core/AgentDB.js +115 -137
  359. package/dist/src/core/AgentDB.js.map +1 -1
  360. package/dist/src/db-fallback.d.ts +1 -10
  361. package/dist/src/db-fallback.d.ts.map +1 -1
  362. package/dist/src/db-fallback.js +4 -171
  363. package/dist/src/db-fallback.js.map +1 -1
  364. package/dist/src/db-test.d.ts +13 -0
  365. package/dist/src/db-test.d.ts.map +1 -0
  366. package/dist/src/db-test.js +55 -0
  367. package/dist/src/db-test.js.map +1 -0
  368. package/dist/src/db-unified.d.ts +76 -0
  369. package/dist/src/db-unified.d.ts.map +1 -0
  370. package/dist/src/db-unified.js +279 -0
  371. package/dist/src/db-unified.js.map +1 -0
  372. package/dist/src/examples/quic-sync-example.d.ts +9 -0
  373. package/dist/src/examples/quic-sync-example.d.ts.map +1 -0
  374. package/dist/src/examples/quic-sync-example.js +169 -0
  375. package/dist/src/examples/quic-sync-example.js.map +1 -0
  376. package/dist/src/examples/wasm-vector-usage.d.ts +12 -0
  377. package/dist/src/examples/wasm-vector-usage.d.ts.map +1 -0
  378. package/dist/src/examples/wasm-vector-usage.js +190 -0
  379. package/dist/src/examples/wasm-vector-usage.js.map +1 -0
  380. package/dist/src/index.d.ts +12 -38
  381. package/dist/src/index.d.ts.map +1 -1
  382. package/dist/src/index.js +11 -46
  383. package/dist/src/index.js.map +1 -1
  384. package/dist/src/mcp/agentdb-mcp-server.js +63 -219
  385. package/dist/src/mcp/agentdb-mcp-server.js.map +1 -1
  386. package/dist/src/mcp/learning-tools-handlers.d.ts +16 -0
  387. package/dist/src/mcp/learning-tools-handlers.d.ts.map +1 -0
  388. package/dist/src/mcp/learning-tools-handlers.js +105 -0
  389. package/dist/src/mcp/learning-tools-handlers.js.map +1 -0
  390. package/dist/src/optimizations/BatchOperations.d.ts +5 -52
  391. package/dist/src/optimizations/BatchOperations.d.ts.map +1 -1
  392. package/dist/src/optimizations/BatchOperations.js +33 -186
  393. package/dist/src/optimizations/BatchOperations.js.map +1 -1
  394. package/dist/src/optimizations/QueryOptimizer.d.ts +4 -4
  395. package/dist/src/optimizations/QueryOptimizer.d.ts.map +1 -1
  396. package/dist/src/optimizations/QueryOptimizer.js +1 -3
  397. package/dist/src/optimizations/QueryOptimizer.js.map +1 -1
  398. package/dist/src/optimizations/ToolCache.d.ts +4 -4
  399. package/dist/src/optimizations/ToolCache.d.ts.map +1 -1
  400. package/dist/src/optimizations/ToolCache.js.map +1 -1
  401. package/dist/src/optimizations/index.d.ts +1 -1
  402. package/dist/src/optimizations/index.d.ts.map +1 -1
  403. package/dist/src/security/AttestationLog.d.ts +70 -0
  404. package/dist/src/security/AttestationLog.d.ts.map +1 -0
  405. package/dist/src/security/AttestationLog.js +174 -0
  406. package/dist/src/security/AttestationLog.js.map +1 -0
  407. package/dist/src/security/MutationGuard.d.ts +83 -0
  408. package/dist/src/security/MutationGuard.d.ts.map +1 -0
  409. package/dist/src/security/MutationGuard.js +379 -0
  410. package/dist/src/security/MutationGuard.js.map +1 -0
  411. package/dist/src/security/index.d.ts +15 -0
  412. package/dist/src/security/index.d.ts.map +1 -0
  413. package/dist/src/security/index.js +18 -0
  414. package/dist/src/security/index.js.map +1 -0
  415. package/dist/src/security/input-validation.d.ts +12 -12
  416. package/dist/src/security/input-validation.d.ts.map +1 -1
  417. package/dist/src/security/input-validation.js +0 -1
  418. package/dist/src/security/input-validation.js.map +1 -1
  419. package/dist/src/security/limits.d.ts +150 -0
  420. package/dist/src/security/limits.d.ts.map +1 -0
  421. package/dist/src/security/limits.js +288 -0
  422. package/dist/src/security/limits.js.map +1 -0
  423. package/dist/src/security/path-security.d.ts +100 -0
  424. package/dist/src/security/path-security.d.ts.map +1 -0
  425. package/dist/src/security/path-security.js +337 -0
  426. package/dist/src/security/path-security.js.map +1 -0
  427. package/dist/src/security/validation.d.ts +95 -0
  428. package/dist/src/security/validation.d.ts.map +1 -0
  429. package/dist/src/security/validation.js +315 -0
  430. package/dist/src/security/validation.js.map +1 -0
  431. package/dist/src/services/GraphTransformerService.d.ts +79 -0
  432. package/dist/src/services/GraphTransformerService.d.ts.map +1 -0
  433. package/dist/src/services/GraphTransformerService.js +331 -0
  434. package/dist/src/services/GraphTransformerService.js.map +1 -0
  435. package/dist/src/services/LLMRouter.d.ts +7 -61
  436. package/dist/src/services/LLMRouter.d.ts.map +1 -1
  437. package/dist/src/services/LLMRouter.js +25 -295
  438. package/dist/src/services/LLMRouter.js.map +1 -1
  439. package/dist/src/services/SemanticRouter.d.ts +78 -0
  440. package/dist/src/services/SemanticRouter.d.ts.map +1 -0
  441. package/dist/src/services/SemanticRouter.js +149 -0
  442. package/dist/src/services/SemanticRouter.js.map +1 -0
  443. package/dist/src/services/SonaTrajectoryService.d.ts +100 -0
  444. package/dist/src/services/SonaTrajectoryService.d.ts.map +1 -0
  445. package/dist/src/services/SonaTrajectoryService.js +231 -0
  446. package/dist/src/services/SonaTrajectoryService.js.map +1 -0
  447. package/dist/src/types/attention.d.ts +249 -0
  448. package/dist/src/types/attention.d.ts.map +1 -0
  449. package/dist/src/types/attention.js +43 -0
  450. package/dist/src/types/attention.js.map +1 -0
  451. package/dist/src/types/quic.d.ts +518 -0
  452. package/dist/src/types/quic.d.ts.map +1 -0
  453. package/dist/src/types/quic.js +272 -0
  454. package/dist/src/types/quic.js.map +1 -0
  455. package/dist/src/utils/LegacyAttentionAdapter.d.ts +93 -0
  456. package/dist/src/utils/LegacyAttentionAdapter.d.ts.map +1 -0
  457. package/dist/src/utils/LegacyAttentionAdapter.js +241 -0
  458. package/dist/src/utils/LegacyAttentionAdapter.js.map +1 -0
  459. package/dist/src/utils/attention-metrics.d.ts +76 -0
  460. package/dist/src/utils/attention-metrics.d.ts.map +1 -0
  461. package/dist/src/utils/attention-metrics.js +178 -0
  462. package/dist/src/utils/attention-metrics.js.map +1 -0
  463. package/dist/src/utils/vector-math.d.ts +29 -0
  464. package/dist/src/utils/vector-math.d.ts.map +1 -0
  465. package/dist/src/utils/vector-math.js +66 -0
  466. package/dist/src/utils/vector-math.js.map +1 -0
  467. package/examples/README.md +105 -0
  468. package/examples/browser/attention-demo.html +499 -0
  469. package/examples/browser/flash-consolidation.html +598 -0
  470. package/examples/browser/hyperbolic-hierarchy.html +497 -0
  471. package/examples/quickstart.js +43 -0
  472. package/package.json +53 -56
  473. package/simulation/.claude-flow/metrics/agent-metrics.json +1 -0
  474. package/simulation/.claude-flow/metrics/performance.json +87 -0
  475. package/simulation/.claude-flow/metrics/task-metrics.json +10 -0
  476. package/simulation/COMPLETION-STATUS.md +139 -0
  477. package/simulation/FINAL-RESULTS.md +414 -0
  478. package/simulation/FINAL-STATUS.md +281 -0
  479. package/simulation/INTEGRATION-COMPLETE.md +452 -0
  480. package/simulation/MIGRATION-STATUS.md +231 -0
  481. package/simulation/OPTIMIZATION-RESULTS.md +397 -0
  482. package/simulation/PHASE1-COMPLETE.md +163 -0
  483. package/simulation/README.md +848 -0
  484. package/simulation/SIMULATION-RESULTS.md +239 -0
  485. package/simulation/cli.ts +78 -0
  486. package/simulation/configs/default.json +37 -0
  487. package/simulation/data/advanced/aidefence.graph +0 -0
  488. package/simulation/data/advanced/bmssp.graph +0 -0
  489. package/simulation/data/advanced/consciousness.graph +0 -0
  490. package/simulation/data/advanced/goalie.graph +0 -0
  491. package/simulation/data/advanced/psycho-symbolic.graph +0 -0
  492. package/simulation/data/advanced/research-swarm.graph +0 -0
  493. package/simulation/data/advanced/sublinear.graph +0 -0
  494. package/simulation/data/advanced/temporal.graph +0 -0
  495. package/simulation/data/causal.graph +0 -0
  496. package/simulation/data/graph-traversal.graph +0 -0
  497. package/simulation/data/lean-agentic.graph +0 -0
  498. package/simulation/data/reflexion.graph +0 -0
  499. package/simulation/data/skills.graph +0 -0
  500. package/simulation/data/stock-market.graph +0 -0
  501. package/simulation/data/strange-loops.graph +0 -0
  502. package/simulation/data/swarm.graph +0 -0
  503. package/simulation/data/voting-consensus.graph +0 -0
  504. package/simulation/docs/CLI-INTEGRATION-PLAN.md +1038 -0
  505. package/simulation/docs/COMPREHENSIVE-LATENT-SPACE-COMPLETION.md +354 -0
  506. package/simulation/docs/DOCUMENTATION-INDEX.md +226 -0
  507. package/simulation/docs/IMPLEMENTATION-COMPLETE.md +521 -0
  508. package/simulation/docs/OPTIMIZATION-SUMMARY.md +279 -0
  509. package/simulation/docs/README.md +229 -0
  510. package/simulation/docs/SWARM-5-INTEGRATION-SUMMARY.md +528 -0
  511. package/simulation/docs/TESTING-SUMMARY.md +304 -0
  512. package/simulation/docs/architecture/EXTENSION-API.md +868 -0
  513. package/simulation/docs/architecture/INTEGRATION-ARCHITECTURE.md +1138 -0
  514. package/simulation/docs/architecture/OPTIMIZATION-STRATEGY.md +778 -0
  515. package/simulation/docs/architecture/SIMULATION-ARCHITECTURE.md +892 -0
  516. package/simulation/docs/guides/CLI-REFERENCE.md +896 -0
  517. package/simulation/docs/guides/CUSTOM-SIMULATIONS.md +931 -0
  518. package/simulation/docs/guides/DEPLOYMENT.md +832 -0
  519. package/simulation/docs/guides/IMPLEMENTATION-SUMMARY.md +544 -0
  520. package/simulation/docs/guides/MIGRATION-GUIDE.md +591 -0
  521. package/simulation/docs/guides/QUICK-START.md +361 -0
  522. package/simulation/docs/guides/README.md +736 -0
  523. package/simulation/docs/guides/TROUBLESHOOTING.md +817 -0
  524. package/simulation/docs/guides/WIZARD-GUIDE.md +869 -0
  525. package/simulation/docs/reports/latent-space/MASTER-SYNTHESIS.md +345 -0
  526. package/simulation/docs/reports/latent-space/README.md +132 -0
  527. package/simulation/docs/reports/latent-space/attention-analysis-RESULTS.md +238 -0
  528. package/simulation/docs/reports/latent-space/clustering-analysis-RESULTS.md +210 -0
  529. package/simulation/docs/reports/latent-space/hnsw-exploration-RESULTS.md +332 -0
  530. package/simulation/docs/reports/latent-space/hypergraph-exploration-RESULTS.md +37 -0
  531. package/simulation/docs/reports/latent-space/neural-augmentation-RESULTS.md +69 -0
  532. package/simulation/docs/reports/latent-space/quantum-hybrid-RESULTS.md +91 -0
  533. package/simulation/docs/reports/latent-space/self-organizing-hnsw-RESULTS.md +51 -0
  534. package/simulation/docs/reports/latent-space/traversal-optimization-RESULTS.md +238 -0
  535. package/simulation/reports/README.md +397 -0
  536. package/simulation/reports/advanced-simulations-performance.md +1241 -0
  537. package/simulation/reports/aidefence-integration-2025-11-30T01-36-53-486Z.json +30 -0
  538. package/simulation/reports/architecture-analysis.md +1396 -0
  539. package/simulation/reports/basic-scenarios-performance.md +1840 -0
  540. package/simulation/reports/bmssp-integration-2025-11-30T01-36-27-193Z.json +30 -0
  541. package/simulation/reports/bmssp-integration-2025-11-30T03-38-12-887Z.json +30 -0
  542. package/simulation/reports/causal-reasoning-2025-11-29T23-35-21-795Z.json +36 -0
  543. package/simulation/reports/causal-reasoning-2025-11-30T00-58-42-862Z.json +30 -0
  544. package/simulation/reports/causal-reasoning-2025-11-30T00-59-12-546Z.json +40 -0
  545. package/simulation/reports/consciousness-explorer-2025-11-30T01-36-51-269Z.json +31 -0
  546. package/simulation/reports/core-benchmarks.md +727 -0
  547. package/simulation/reports/goalie-integration-2025-11-30T01-36-52-377Z.json +30 -0
  548. package/simulation/reports/graph-traversal-2025-11-29T23-35-35-279Z.json +78 -0
  549. package/simulation/reports/graph-traversal-2025-11-29T23-37-36-697Z.json +30 -0
  550. package/simulation/reports/graph-traversal-2025-11-30T01-03-59-716Z.json +30 -0
  551. package/simulation/reports/graph-traversal-2025-11-30T01-05-10-984Z.json +30 -0
  552. package/simulation/reports/graph-traversal-2025-11-30T01-06-16-334Z.json +30 -0
  553. package/simulation/reports/graph-traversal-2025-11-30T01-06-53-312Z.json +30 -0
  554. package/simulation/reports/graph-traversal-2025-11-30T01-07-51-075Z.json +24 -0
  555. package/simulation/reports/graph-traversal-2025-11-30T01-08-22-179Z.json +42 -0
  556. package/simulation/reports/lean-agentic-swarm-2025-11-29T23-37-23-804Z.json +148 -0
  557. package/simulation/reports/lean-agentic-swarm-2025-11-30T01-31-24-401Z.json +31 -0
  558. package/simulation/reports/lean-agentic-swarm-2025-11-30T03-38-01-470Z.json +31 -0
  559. package/simulation/reports/multi-agent-swarm-2025-11-29T23-35-28-093Z.json +78 -0
  560. package/simulation/reports/multi-agent-swarm-2025-11-30T01-03-54-062Z.json +42 -0
  561. package/simulation/reports/multi-agent-swarm-2025-11-30T01-05-06-092Z.json +42 -0
  562. package/simulation/reports/psycho-symbolic-reasoner-2025-11-30T01-36-50-180Z.json +30 -0
  563. package/simulation/reports/quality-metrics.md +727 -0
  564. package/simulation/reports/reflexion-learning-2025-11-29T23-35-09-774Z.json +48 -0
  565. package/simulation/reports/reflexion-learning-2025-11-29T23-37-16-934Z.json +36 -0
  566. package/simulation/reports/reflexion-learning-2025-11-30T00-07-49-259Z.json +30 -0
  567. package/simulation/reports/reflexion-learning-2025-11-30T00-09-29-319Z.json +51 -0
  568. package/simulation/reports/reflexion-learning-2025-11-30T00-28-37-659Z.json +51 -0
  569. package/simulation/reports/reflexion-learning-2025-11-30T01-31-30-690Z.json +29 -0
  570. package/simulation/reports/reflexion-learning-2025-11-30T03-38-06-937Z.json +29 -0
  571. package/simulation/reports/research-foundations.md +2004 -0
  572. package/simulation/reports/research-swarm-2025-11-30T01-36-54-647Z.json +30 -0
  573. package/simulation/reports/scalability-deployment.md +2404 -0
  574. package/simulation/reports/skill-evolution-2025-11-29T23-35-15-945Z.json +36 -0
  575. package/simulation/reports/skill-evolution-2025-11-30T01-03-17-995Z.json +30 -0
  576. package/simulation/reports/skill-evolution-2025-11-30T01-03-48-441Z.json +30 -0
  577. package/simulation/reports/skill-evolution-2025-11-30T01-05-00-554Z.json +30 -0
  578. package/simulation/reports/skill-evolution-2025-11-30T01-06-11-436Z.json +30 -0
  579. package/simulation/reports/skill-evolution-2025-11-30T01-06-51-979Z.json +30 -0
  580. package/simulation/reports/skill-evolution-2025-11-30T01-07-32-695Z.json +40 -0
  581. package/simulation/reports/stock-market-emergence-2025-11-30T00-11-43-865Z.json +56 -0
  582. package/simulation/reports/stock-market-emergence-2025-11-30T00-28-57-495Z.json +56 -0
  583. package/simulation/reports/strange-loops-2025-11-29T23-37-30-621Z.json +78 -0
  584. package/simulation/reports/strange-loops-2025-11-30T00-07-55-415Z.json +30 -0
  585. package/simulation/reports/strange-loops-2025-11-30T00-09-35-133Z.json +30 -0
  586. package/simulation/reports/strange-loops-2025-11-30T00-48-50-744Z.json +24 -0
  587. package/simulation/reports/strange-loops-2025-11-30T00-54-48-044Z.json +24 -0
  588. package/simulation/reports/strange-loops-2025-11-30T00-57-27-633Z.json +24 -0
  589. package/simulation/reports/strange-loops-2025-11-30T00-57-59-135Z.json +42 -0
  590. package/simulation/reports/sublinear-solver-2025-11-30T01-36-33-134Z.json +30 -0
  591. package/simulation/reports/temporal-lead-solver-2025-11-30T01-36-38-628Z.json +30 -0
  592. package/simulation/reports/use-cases-applications.md +2212 -0
  593. package/simulation/reports/voting-system-consensus-2025-11-30T00-11-37-199Z.json +58 -0
  594. package/simulation/reports/voting-system-consensus-2025-11-30T00-28-47-735Z.json +58 -0
  595. package/simulation/runner.ts +300 -0
  596. package/simulation/scenarios/README-advanced/aidefence-integration.md +63 -0
  597. package/simulation/scenarios/README-advanced/bmssp-integration.md +58 -0
  598. package/simulation/scenarios/README-advanced/consciousness-explorer.md +53 -0
  599. package/simulation/scenarios/README-advanced/goalie-integration.md +61 -0
  600. package/simulation/scenarios/README-advanced/psycho-symbolic-reasoner.md +55 -0
  601. package/simulation/scenarios/README-advanced/research-swarm.md +63 -0
  602. package/simulation/scenarios/README-advanced/sublinear-solver.md +58 -0
  603. package/simulation/scenarios/README-advanced/temporal-lead-solver.md +55 -0
  604. package/simulation/scenarios/README-basic/causal-reasoning.md +39 -0
  605. package/simulation/scenarios/README-basic/graph-traversal.md +41 -0
  606. package/simulation/scenarios/README-basic/lean-agentic-swarm.md +122 -0
  607. package/simulation/scenarios/README-basic/multi-agent-swarm.md +34 -0
  608. package/simulation/scenarios/README-basic/reflexion-learning.md +41 -0
  609. package/simulation/scenarios/README-basic/skill-evolution.md +38 -0
  610. package/simulation/scenarios/README-basic/stock-market-emergence.md +28 -0
  611. package/simulation/scenarios/README-basic/strange-loops.md +36 -0
  612. package/simulation/scenarios/README-basic/voting-system-consensus.md +28 -0
  613. package/simulation/scenarios/README.md +438 -0
  614. package/simulation/scenarios/aidefence-integration.ts +165 -0
  615. package/simulation/scenarios/bmssp-integration.ts +137 -0
  616. package/simulation/scenarios/causal-reasoning.ts +143 -0
  617. package/simulation/scenarios/consciousness-explorer.ts +139 -0
  618. package/simulation/scenarios/domain-examples/.claude-flow/metrics/agent-metrics.json +1 -0
  619. package/simulation/scenarios/domain-examples/.claude-flow/metrics/performance.json +87 -0
  620. package/simulation/scenarios/domain-examples/.claude-flow/metrics/task-metrics.json +10 -0
  621. package/simulation/scenarios/domain-examples/README.md +525 -0
  622. package/simulation/scenarios/domain-examples/e-commerce-recommendations.ts +220 -0
  623. package/simulation/scenarios/domain-examples/index.ts +81 -0
  624. package/simulation/scenarios/domain-examples/iot-sensor-networks.ts +290 -0
  625. package/simulation/scenarios/domain-examples/medical-imaging.ts +181 -0
  626. package/simulation/scenarios/domain-examples/robotics-navigation.ts +214 -0
  627. package/simulation/scenarios/domain-examples/scientific-research.ts +250 -0
  628. package/simulation/scenarios/domain-examples/trading-systems.ts +138 -0
  629. package/simulation/scenarios/goalie-integration.ts +161 -0
  630. package/simulation/scenarios/graph-traversal.ts +129 -0
  631. package/simulation/scenarios/latent-space/OPTIMIZATION-COMPLETE.md +287 -0
  632. package/simulation/scenarios/latent-space/README-attention-analysis.md +170 -0
  633. package/simulation/scenarios/latent-space/README-clustering-analysis.md +239 -0
  634. package/simulation/scenarios/latent-space/README-hnsw-exploration.md +199 -0
  635. package/simulation/scenarios/latent-space/README-hypergraph-exploration.md +279 -0
  636. package/simulation/scenarios/latent-space/README-neural-augmentation.md +267 -0
  637. package/simulation/scenarios/latent-space/README-quantum-hybrid.md +276 -0
  638. package/simulation/scenarios/latent-space/README-self-organizing-hnsw.md +244 -0
  639. package/simulation/scenarios/latent-space/README-traversal-optimization.md +212 -0
  640. package/simulation/scenarios/latent-space/attention-analysis.ts +598 -0
  641. package/simulation/scenarios/latent-space/clustering-analysis.ts +796 -0
  642. package/simulation/scenarios/latent-space/hnsw-exploration.ts +526 -0
  643. package/simulation/scenarios/latent-space/hypergraph-exploration.ts +706 -0
  644. package/simulation/scenarios/latent-space/index.ts +47 -0
  645. package/simulation/scenarios/latent-space/neural-augmentation.ts +604 -0
  646. package/simulation/scenarios/latent-space/quantum-hybrid.ts +508 -0
  647. package/simulation/scenarios/latent-space/self-organizing-hnsw.ts +680 -0
  648. package/simulation/scenarios/latent-space/traversal-optimization.ts +782 -0
  649. package/simulation/scenarios/lean-agentic-swarm.ts +182 -0
  650. package/simulation/scenarios/multi-agent-swarm.ts +146 -0
  651. package/simulation/scenarios/psycho-symbolic-reasoner.ts +136 -0
  652. package/simulation/scenarios/reflexion-learning.ts +132 -0
  653. package/simulation/scenarios/research-swarm.ts +187 -0
  654. package/simulation/scenarios/skill-evolution.ts +135 -0
  655. package/simulation/scenarios/stock-market-emergence.ts +323 -0
  656. package/simulation/scenarios/strange-loops.ts +175 -0
  657. package/simulation/scenarios/sublinear-solver.ts +108 -0
  658. package/simulation/scenarios/temporal-lead-solver.ts +121 -0
  659. package/simulation/scenarios/voting-system-consensus.ts +251 -0
  660. package/simulation/tests/latent-space/attention-analysis.test.ts +204 -0
  661. package/simulation/tests/latent-space/clustering-analysis.test.ts +281 -0
  662. package/simulation/tests/latent-space/hnsw-exploration.test.ts +253 -0
  663. package/simulation/tests/latent-space/hypergraph-exploration.test.ts +295 -0
  664. package/simulation/tests/latent-space/neural-augmentation.test.ts +326 -0
  665. package/simulation/tests/latent-space/quantum-hybrid.test.ts +307 -0
  666. package/simulation/tests/latent-space/self-organizing-hnsw.test.ts +291 -0
  667. package/simulation/tests/latent-space/traversal-optimization.test.ts +261 -0
  668. package/simulation/types.ts +177 -0
  669. package/simulation/utils/PerformanceOptimizer.ts +269 -0
  670. package/src/backends/GraphBackend.ts +290 -0
  671. package/src/backends/LearningBackend.ts +210 -0
  672. package/src/backends/README.md +389 -0
  673. package/src/backends/VectorBackend.ts +147 -0
  674. package/src/backends/detector.ts +283 -0
  675. package/src/backends/factory.ts +279 -0
  676. package/src/backends/graph/GraphDatabaseAdapter.ts +334 -0
  677. package/src/backends/hnswlib/HNSWLibBackend.ts +419 -0
  678. package/src/backends/hnswlib/index.ts +7 -0
  679. package/src/backends/index.ts +32 -0
  680. package/src/backends/ruvector/GuardedVectorBackend.ts +219 -0
  681. package/src/backends/ruvector/RuVectorBackend.ts +343 -0
  682. package/src/backends/ruvector/RuVectorLearning.ts +254 -0
  683. package/src/backends/ruvector/index.ts +9 -0
  684. package/src/benchmarks/wasm-vector-benchmark.ts +250 -0
  685. package/src/browser/AdvancedFeatures.ts +565 -0
  686. package/src/browser/AttentionBrowser.ts +387 -0
  687. package/src/browser/HNSWIndex.ts +494 -0
  688. package/src/browser/ProductQuantization.ts +419 -0
  689. package/src/browser/index.ts +317 -0
  690. package/src/cli/agentdb-cli.ts +2712 -0
  691. package/src/cli/attention-cli-integration.ts +91 -0
  692. package/src/cli/commands/attention.ts +656 -0
  693. package/src/cli/commands/doctor.ts +322 -0
  694. package/src/cli/commands/init.ts +176 -0
  695. package/src/cli/commands/install-embeddings.ts +81 -0
  696. package/src/cli/commands/migrate.ts +545 -0
  697. package/src/cli/commands/simulate-custom.ts +232 -0
  698. package/src/cli/commands/simulate-report.ts +171 -0
  699. package/src/cli/commands/simulate-wizard.ts +379 -0
  700. package/src/cli/commands/simulate.ts +115 -0
  701. package/src/cli/commands/status.ts +156 -0
  702. package/src/cli/examples.sh +83 -0
  703. package/src/cli/lib/attention-config.ts +326 -0
  704. package/src/cli/lib/config-manager.ts +627 -0
  705. package/src/cli/lib/config-validator.ts +261 -0
  706. package/src/cli/lib/health-monitor.ts +513 -0
  707. package/src/cli/lib/help-formatter.ts +406 -0
  708. package/src/cli/lib/history-tracker.ts +503 -0
  709. package/src/cli/lib/report-generator.ts +455 -0
  710. package/src/cli/lib/report-store.ts +582 -0
  711. package/src/cli/lib/simulation-registry.ts +503 -0
  712. package/src/cli/lib/simulation-runner.ts +291 -0
  713. package/src/cli/tests/agentdb-cli.test.ts +58 -0
  714. package/src/cli/tests/attention-cli.test.ts +335 -0
  715. package/src/controllers/AttentionService.ts +770 -0
  716. package/src/controllers/CausalMemoryGraph.ts +773 -0
  717. package/src/controllers/CausalRecall.ts +484 -0
  718. package/src/controllers/ContextSynthesizer.ts +285 -0
  719. package/src/controllers/EmbeddingService.ts +161 -0
  720. package/src/controllers/EnhancedEmbeddingService.ts +143 -0
  721. package/src/controllers/ExplainableRecall.ts +746 -0
  722. package/src/controllers/HNSWIndex.ts +495 -0
  723. package/src/controllers/LearningSystem.ts +1270 -0
  724. package/src/controllers/MMRDiversityRanker.ts +187 -0
  725. package/src/controllers/MetadataFilter.ts +280 -0
  726. package/src/controllers/NightlyLearner.ts +647 -0
  727. package/src/controllers/QUICClient.ts +413 -0
  728. package/src/controllers/QUICServer.ts +498 -0
  729. package/src/controllers/ReasoningBank.ts +665 -0
  730. package/src/controllers/ReflexionMemory.ts +872 -0
  731. package/src/controllers/SkillLibrary.ts +795 -0
  732. package/src/controllers/SyncCoordinator.ts +597 -0
  733. package/src/controllers/WASMVectorSearch.ts +292 -0
  734. package/src/controllers/frontier-index.ts +35 -0
  735. package/src/controllers/index.ts +57 -0
  736. package/src/coordination/MultiDatabaseCoordinator.ts +1107 -0
  737. package/src/coordination/index.ts +24 -0
  738. package/src/core/AgentDB.ts +211 -0
  739. package/src/db-fallback.ts +296 -0
  740. package/src/db-test.ts +59 -0
  741. package/src/db-unified.ts +327 -0
  742. package/src/examples/quic-sync-example.ts +198 -0
  743. package/src/examples/wasm-vector-usage.ts +245 -0
  744. package/src/index.ts +69 -0
  745. package/src/mcp/agentdb-mcp-server.ts +2318 -0
  746. package/src/mcp/attention-mcp-integration.ts +145 -0
  747. package/src/mcp/attention-tools-handlers.ts +586 -0
  748. package/src/mcp/learning-tools-handlers.ts +106 -0
  749. package/src/optimizations/BatchOperations.ts +594 -0
  750. package/src/optimizations/QueryOptimizer.ts +297 -0
  751. package/src/optimizations/ToolCache.ts +355 -0
  752. package/src/optimizations/index.ts +11 -0
  753. package/src/schemas/frontier-schema.sql +378 -0
  754. package/src/schemas/schema.sql +382 -0
  755. package/src/security/AttestationLog.ts +252 -0
  756. package/src/security/MutationGuard.ts +420 -0
  757. package/src/security/index.ts +52 -0
  758. package/src/security/input-validation.ts +543 -0
  759. package/src/security/limits.ts +375 -0
  760. package/src/security/path-security.ts +436 -0
  761. package/src/security/validation.ts +556 -0
  762. package/src/services/GraphTransformerService.ts +389 -0
  763. package/src/services/LLMRouter.ts +380 -0
  764. package/src/services/SemanticRouter.ts +169 -0
  765. package/src/services/SonaTrajectoryService.ts +264 -0
  766. package/src/tests/attention-service.test.ts +492 -0
  767. package/src/tests/wasm-vector-search.test.ts +240 -0
  768. package/src/types/attention.ts +392 -0
  769. package/src/types/quic.ts +772 -0
  770. package/src/utils/LegacyAttentionAdapter.ts +393 -0
  771. package/src/utils/NodeIdMapper.ts +64 -0
  772. package/src/utils/attention-metrics.ts +253 -0
  773. package/src/utils/vector-math.ts +71 -0
  774. package/LICENSE +0 -21
  775. package/dist/src/backends/rvf/AdaptiveIndexTuner.d.ts +0 -175
  776. package/dist/src/backends/rvf/AdaptiveIndexTuner.d.ts.map +0 -1
  777. package/dist/src/backends/rvf/AdaptiveIndexTuner.js +0 -559
  778. package/dist/src/backends/rvf/AdaptiveIndexTuner.js.map +0 -1
  779. package/dist/src/backends/rvf/ContrastiveTrainer.d.ts +0 -148
  780. package/dist/src/backends/rvf/ContrastiveTrainer.d.ts.map +0 -1
  781. package/dist/src/backends/rvf/ContrastiveTrainer.js +0 -438
  782. package/dist/src/backends/rvf/ContrastiveTrainer.js.map +0 -1
  783. package/dist/src/backends/rvf/FederatedSessionManager.d.ts +0 -211
  784. package/dist/src/backends/rvf/FederatedSessionManager.d.ts.map +0 -1
  785. package/dist/src/backends/rvf/FederatedSessionManager.js +0 -389
  786. package/dist/src/backends/rvf/FederatedSessionManager.js.map +0 -1
  787. package/dist/src/backends/rvf/FilterBuilder.d.ts +0 -136
  788. package/dist/src/backends/rvf/FilterBuilder.d.ts.map +0 -1
  789. package/dist/src/backends/rvf/FilterBuilder.js +0 -157
  790. package/dist/src/backends/rvf/FilterBuilder.js.map +0 -1
  791. package/dist/src/backends/rvf/NativeAccelerator.d.ts +0 -140
  792. package/dist/src/backends/rvf/NativeAccelerator.d.ts.map +0 -1
  793. package/dist/src/backends/rvf/NativeAccelerator.js +0 -630
  794. package/dist/src/backends/rvf/NativeAccelerator.js.map +0 -1
  795. package/dist/src/backends/rvf/RvfBackend.d.ts +0 -194
  796. package/dist/src/backends/rvf/RvfBackend.d.ts.map +0 -1
  797. package/dist/src/backends/rvf/RvfBackend.js +0 -607
  798. package/dist/src/backends/rvf/RvfBackend.js.map +0 -1
  799. package/dist/src/backends/rvf/RvfSolver.d.ts +0 -175
  800. package/dist/src/backends/rvf/RvfSolver.d.ts.map +0 -1
  801. package/dist/src/backends/rvf/RvfSolver.js +0 -176
  802. package/dist/src/backends/rvf/RvfSolver.js.map +0 -1
  803. package/dist/src/backends/rvf/SelfLearningRvfBackend.d.ts +0 -143
  804. package/dist/src/backends/rvf/SelfLearningRvfBackend.d.ts.map +0 -1
  805. package/dist/src/backends/rvf/SelfLearningRvfBackend.js +0 -569
  806. package/dist/src/backends/rvf/SelfLearningRvfBackend.js.map +0 -1
  807. package/dist/src/backends/rvf/SemanticQueryRouter.d.ts +0 -128
  808. package/dist/src/backends/rvf/SemanticQueryRouter.d.ts.map +0 -1
  809. package/dist/src/backends/rvf/SemanticQueryRouter.js +0 -415
  810. package/dist/src/backends/rvf/SemanticQueryRouter.js.map +0 -1
  811. package/dist/src/backends/rvf/SimdFallbacks.d.ts +0 -25
  812. package/dist/src/backends/rvf/SimdFallbacks.d.ts.map +0 -1
  813. package/dist/src/backends/rvf/SimdFallbacks.js +0 -287
  814. package/dist/src/backends/rvf/SimdFallbacks.js.map +0 -1
  815. package/dist/src/backends/rvf/SolverBandit.d.ts +0 -100
  816. package/dist/src/backends/rvf/SolverBandit.d.ts.map +0 -1
  817. package/dist/src/backends/rvf/SolverBandit.js +0 -216
  818. package/dist/src/backends/rvf/SolverBandit.js.map +0 -1
  819. package/dist/src/backends/rvf/SonaLearningBackend.d.ts +0 -157
  820. package/dist/src/backends/rvf/SonaLearningBackend.d.ts.map +0 -1
  821. package/dist/src/backends/rvf/SonaLearningBackend.js +0 -283
  822. package/dist/src/backends/rvf/SonaLearningBackend.js.map +0 -1
  823. package/dist/src/backends/rvf/SqlJsRvfBackend.d.ts +0 -77
  824. package/dist/src/backends/rvf/SqlJsRvfBackend.d.ts.map +0 -1
  825. package/dist/src/backends/rvf/SqlJsRvfBackend.js +0 -382
  826. package/dist/src/backends/rvf/SqlJsRvfBackend.js.map +0 -1
  827. package/dist/src/backends/rvf/WasmStoreBridge.d.ts +0 -27
  828. package/dist/src/backends/rvf/WasmStoreBridge.d.ts.map +0 -1
  829. package/dist/src/backends/rvf/WasmStoreBridge.js +0 -87
  830. package/dist/src/backends/rvf/WasmStoreBridge.js.map +0 -1
  831. package/dist/src/backends/rvf/validation.d.ts +0 -20
  832. package/dist/src/backends/rvf/validation.d.ts.map +0 -1
  833. package/dist/src/backends/rvf/validation.js +0 -78
  834. package/dist/src/backends/rvf/validation.js.map +0 -1
  835. package/dist/src/benchmark/BenchmarkSuite.d.ts +0 -318
  836. package/dist/src/benchmark/BenchmarkSuite.d.ts.map +0 -1
  837. package/dist/src/benchmark/BenchmarkSuite.js +0 -986
  838. package/dist/src/benchmark/BenchmarkSuite.js.map +0 -1
  839. package/dist/src/benchmark/index.d.ts +0 -29
  840. package/dist/src/benchmark/index.d.ts.map +0 -1
  841. package/dist/src/benchmark/index.js +0 -39
  842. package/dist/src/benchmark/index.js.map +0 -1
  843. package/dist/src/cli/commands/hyperbolic.d.ts +0 -11
  844. package/dist/src/cli/commands/hyperbolic.d.ts.map +0 -1
  845. package/dist/src/cli/commands/hyperbolic.js +0 -428
  846. package/dist/src/cli/commands/hyperbolic.js.map +0 -1
  847. package/dist/src/cli/commands/learn.d.ts +0 -11
  848. package/dist/src/cli/commands/learn.d.ts.map +0 -1
  849. package/dist/src/cli/commands/learn.js +0 -404
  850. package/dist/src/cli/commands/learn.js.map +0 -1
  851. package/dist/src/cli/commands/route.d.ts +0 -11
  852. package/dist/src/cli/commands/route.d.ts.map +0 -1
  853. package/dist/src/cli/commands/route.js +0 -414
  854. package/dist/src/cli/commands/route.js.map +0 -1
  855. package/dist/src/cli/commands/rvf.d.ts +0 -21
  856. package/dist/src/cli/commands/rvf.d.ts.map +0 -1
  857. package/dist/src/cli/commands/rvf.js +0 -448
  858. package/dist/src/cli/commands/rvf.js.map +0 -1
  859. package/dist/src/cli/tests/agentdb-cli.test.d.ts +0 -8
  860. package/dist/src/cli/tests/agentdb-cli.test.d.ts.map +0 -1
  861. package/dist/src/cli/tests/agentdb-cli.test.js +0 -50
  862. package/dist/src/cli/tests/agentdb-cli.test.js.map +0 -1
  863. package/dist/src/cli/tests/attention-cli.test.d.ts +0 -5
  864. package/dist/src/cli/tests/attention-cli.test.d.ts.map +0 -1
  865. package/dist/src/cli/tests/attention-cli.test.js +0 -257
  866. package/dist/src/cli/tests/attention-cli.test.js.map +0 -1
  867. package/dist/src/compatibility/DeprecationWarnings.d.ts +0 -54
  868. package/dist/src/compatibility/DeprecationWarnings.d.ts.map +0 -1
  869. package/dist/src/compatibility/DeprecationWarnings.js +0 -131
  870. package/dist/src/compatibility/DeprecationWarnings.js.map +0 -1
  871. package/dist/src/compatibility/MigrationUtilities.d.ts +0 -30
  872. package/dist/src/compatibility/MigrationUtilities.d.ts.map +0 -1
  873. package/dist/src/compatibility/MigrationUtilities.js +0 -184
  874. package/dist/src/compatibility/MigrationUtilities.js.map +0 -1
  875. package/dist/src/compatibility/V1toV2Adapter.d.ts +0 -76
  876. package/dist/src/compatibility/V1toV2Adapter.d.ts.map +0 -1
  877. package/dist/src/compatibility/V1toV2Adapter.js +0 -198
  878. package/dist/src/compatibility/V1toV2Adapter.js.map +0 -1
  879. package/dist/src/compatibility/VersionDetector.d.ts +0 -32
  880. package/dist/src/compatibility/VersionDetector.d.ts.map +0 -1
  881. package/dist/src/compatibility/VersionDetector.js +0 -144
  882. package/dist/src/compatibility/VersionDetector.js.map +0 -1
  883. package/dist/src/compatibility/index.d.ts +0 -11
  884. package/dist/src/compatibility/index.d.ts.map +0 -1
  885. package/dist/src/compatibility/index.js +0 -10
  886. package/dist/src/compatibility/index.js.map +0 -1
  887. package/dist/src/compatibility/types.d.ts +0 -103
  888. package/dist/src/compatibility/types.d.ts.map +0 -1
  889. package/dist/src/compatibility/types.js +0 -5
  890. package/dist/src/compatibility/types.js.map +0 -1
  891. package/dist/src/controllers/MemoryController.d.ts +0 -161
  892. package/dist/src/controllers/MemoryController.d.ts.map +0 -1
  893. package/dist/src/controllers/MemoryController.js +0 -290
  894. package/dist/src/controllers/MemoryController.js.map +0 -1
  895. package/dist/src/controllers/attention/CrossAttentionController.d.ts +0 -141
  896. package/dist/src/controllers/attention/CrossAttentionController.d.ts.map +0 -1
  897. package/dist/src/controllers/attention/CrossAttentionController.js +0 -325
  898. package/dist/src/controllers/attention/CrossAttentionController.js.map +0 -1
  899. package/dist/src/controllers/attention/MultiHeadAttentionController.d.ts +0 -137
  900. package/dist/src/controllers/attention/MultiHeadAttentionController.d.ts.map +0 -1
  901. package/dist/src/controllers/attention/MultiHeadAttentionController.js +0 -339
  902. package/dist/src/controllers/attention/MultiHeadAttentionController.js.map +0 -1
  903. package/dist/src/controllers/attention/SelfAttentionController.d.ts +0 -117
  904. package/dist/src/controllers/attention/SelfAttentionController.d.ts.map +0 -1
  905. package/dist/src/controllers/attention/SelfAttentionController.js +0 -205
  906. package/dist/src/controllers/attention/SelfAttentionController.js.map +0 -1
  907. package/dist/src/controllers/attention/index.d.ts +0 -15
  908. package/dist/src/controllers/attention/index.d.ts.map +0 -1
  909. package/dist/src/controllers/attention/index.js +0 -12
  910. package/dist/src/controllers/attention/index.js.map +0 -1
  911. package/dist/src/core/QueryCache.d.ts +0 -138
  912. package/dist/src/core/QueryCache.d.ts.map +0 -1
  913. package/dist/src/core/QueryCache.js +0 -313
  914. package/dist/src/core/QueryCache.js.map +0 -1
  915. package/dist/src/observability/index.d.ts +0 -8
  916. package/dist/src/observability/index.d.ts.map +0 -1
  917. package/dist/src/observability/index.js +0 -8
  918. package/dist/src/observability/index.js.map +0 -1
  919. package/dist/src/observability/integration.d.ts +0 -32
  920. package/dist/src/observability/integration.d.ts.map +0 -1
  921. package/dist/src/observability/integration.js +0 -157
  922. package/dist/src/observability/integration.js.map +0 -1
  923. package/dist/src/observability/telemetry.d.ts +0 -137
  924. package/dist/src/observability/telemetry.d.ts.map +0 -1
  925. package/dist/src/observability/telemetry.js +0 -420
  926. package/dist/src/observability/telemetry.js.map +0 -1
  927. package/dist/src/quantization/index.d.ts +0 -7
  928. package/dist/src/quantization/index.d.ts.map +0 -1
  929. package/dist/src/quantization/index.js +0 -15
  930. package/dist/src/quantization/index.js.map +0 -1
  931. package/dist/src/quantization/vector-quantization.d.ts +0 -388
  932. package/dist/src/quantization/vector-quantization.d.ts.map +0 -1
  933. package/dist/src/quantization/vector-quantization.js +0 -1136
  934. package/dist/src/quantization/vector-quantization.js.map +0 -1
  935. package/dist/src/search/HybridSearch.d.ts +0 -311
  936. package/dist/src/search/HybridSearch.d.ts.map +0 -1
  937. package/dist/src/search/HybridSearch.js +0 -712
  938. package/dist/src/search/HybridSearch.js.map +0 -1
  939. package/dist/src/search/index.d.ts +0 -12
  940. package/dist/src/search/index.d.ts.map +0 -1
  941. package/dist/src/search/index.js +0 -16
  942. package/dist/src/search/index.js.map +0 -1
  943. package/dist/src/services/AttentionService.d.ts +0 -303
  944. package/dist/src/services/AttentionService.d.ts.map +0 -1
  945. package/dist/src/services/AttentionService.js +0 -1167
  946. package/dist/src/services/AttentionService.js.map +0 -1
  947. package/dist/src/simd/index.d.ts +0 -9
  948. package/dist/src/simd/index.d.ts.map +0 -1
  949. package/dist/src/simd/index.js +0 -27
  950. package/dist/src/simd/index.js.map +0 -1
  951. package/dist/src/simd/simd-vector-ops.d.ts +0 -332
  952. package/dist/src/simd/simd-vector-ops.d.ts.map +0 -1
  953. package/dist/src/simd/simd-vector-ops.js +0 -947
  954. package/dist/src/simd/simd-vector-ops.js.map +0 -1
  955. package/dist/src/tests/attention-service.test.d.ts +0 -7
  956. package/dist/src/tests/attention-service.test.d.ts.map +0 -1
  957. package/dist/src/tests/attention-service.test.js +0 -401
  958. package/dist/src/tests/attention-service.test.js.map +0 -1
  959. package/dist/src/tests/integration/compatibility/backwards-compat.integration.test.d.ts +0 -7
  960. package/dist/src/tests/integration/compatibility/backwards-compat.integration.test.d.ts.map +0 -1
  961. package/dist/src/tests/integration/compatibility/backwards-compat.integration.test.js +0 -283
  962. package/dist/src/tests/integration/compatibility/backwards-compat.integration.test.js.map +0 -1
  963. package/dist/src/tests/query-cache.test.d.ts +0 -7
  964. package/dist/src/tests/query-cache.test.d.ts.map +0 -1
  965. package/dist/src/tests/query-cache.test.js +0 -343
  966. package/dist/src/tests/query-cache.test.js.map +0 -1
  967. package/dist/src/tests/ruvector-integration.test.d.ts +0 -14
  968. package/dist/src/tests/ruvector-integration.test.d.ts.map +0 -1
  969. package/dist/src/tests/ruvector-integration.test.js +0 -1156
  970. package/dist/src/tests/ruvector-integration.test.js.map +0 -1
  971. package/dist/src/tests/unit/auth/crypto.utils.test.d.ts +0 -6
  972. package/dist/src/tests/unit/auth/crypto.utils.test.d.ts.map +0 -1
  973. package/dist/src/tests/unit/auth/crypto.utils.test.js +0 -310
  974. package/dist/src/tests/unit/auth/crypto.utils.test.js.map +0 -1
  975. package/dist/src/tests/unit/compatibility/deprecation-warnings.test.d.ts +0 -5
  976. package/dist/src/tests/unit/compatibility/deprecation-warnings.test.d.ts.map +0 -1
  977. package/dist/src/tests/unit/compatibility/deprecation-warnings.test.js +0 -207
  978. package/dist/src/tests/unit/compatibility/deprecation-warnings.test.js.map +0 -1
  979. package/dist/src/tests/unit/compatibility/migration-utils.test.d.ts +0 -5
  980. package/dist/src/tests/unit/compatibility/migration-utils.test.d.ts.map +0 -1
  981. package/dist/src/tests/unit/compatibility/migration-utils.test.js +0 -264
  982. package/dist/src/tests/unit/compatibility/migration-utils.test.js.map +0 -1
  983. package/dist/src/tests/unit/compatibility/v1-adapter.test.d.ts +0 -7
  984. package/dist/src/tests/unit/compatibility/v1-adapter.test.d.ts.map +0 -1
  985. package/dist/src/tests/unit/compatibility/v1-adapter.test.js +0 -228
  986. package/dist/src/tests/unit/compatibility/v1-adapter.test.js.map +0 -1
  987. package/dist/src/tests/unit/compatibility/version-detector.test.d.ts +0 -10
  988. package/dist/src/tests/unit/compatibility/version-detector.test.d.ts.map +0 -1
  989. package/dist/src/tests/unit/compatibility/version-detector.test.js +0 -162
  990. package/dist/src/tests/unit/compatibility/version-detector.test.js.map +0 -1
  991. package/dist/src/tests/vector-quantization.test.d.ts +0 -5
  992. package/dist/src/tests/vector-quantization.test.d.ts.map +0 -1
  993. package/dist/src/tests/vector-quantization.test.js +0 -338
  994. package/dist/src/tests/vector-quantization.test.js.map +0 -1
  995. package/dist/src/tests/wasm-vector-search.test.d.ts +0 -7
  996. package/dist/src/tests/wasm-vector-search.test.d.ts.map +0 -1
  997. package/dist/src/tests/wasm-vector-search.test.js +0 -193
  998. package/dist/src/tests/wasm-vector-search.test.js.map +0 -1
  999. package/dist/src/types/database.types.d.ts +0 -275
  1000. package/dist/src/types/database.types.d.ts.map +0 -1
  1001. package/dist/src/types/database.types.js +0 -57
  1002. package/dist/src/types/database.types.js.map +0 -1
  1003. package/dist/src/utils/chalk-fallback.d.ts +0 -3
  1004. package/dist/src/utils/chalk-fallback.d.ts.map +0 -1
  1005. package/dist/src/utils/chalk-fallback.js +0 -20
  1006. package/dist/src/utils/chalk-fallback.js.map +0 -1
  1007. package/dist/src/utils/crypto.utils.d.ts +0 -122
  1008. package/dist/src/utils/crypto.utils.d.ts.map +0 -1
  1009. package/dist/src/utils/crypto.utils.js +0 -296
  1010. package/dist/src/utils/crypto.utils.js.map +0 -1
  1011. package/dist/src/utils/similarity.d.ts +0 -11
  1012. package/dist/src/utils/similarity.d.ts.map +0 -1
  1013. package/dist/src/utils/similarity.js +0 -25
  1014. package/dist/src/utils/similarity.js.map +0 -1
  1015. package/dist/src/wasm-loader.d.ts +0 -67
  1016. package/dist/src/wasm-loader.d.ts.map +0 -1
  1017. package/dist/src/wasm-loader.js +0 -78
  1018. package/dist/src/wasm-loader.js.map +0 -1
  1019. package/dist/src/wrappers/agentdb-fast.d.ts +0 -139
  1020. package/dist/src/wrappers/agentdb-fast.d.ts.map +0 -1
  1021. package/dist/src/wrappers/agentdb-fast.js +0 -316
  1022. package/dist/src/wrappers/agentdb-fast.js.map +0 -1
  1023. package/dist/src/wrappers/attention-fallbacks.d.ts +0 -351
  1024. package/dist/src/wrappers/attention-fallbacks.d.ts.map +0 -1
  1025. package/dist/src/wrappers/attention-fallbacks.js +0 -1487
  1026. package/dist/src/wrappers/attention-fallbacks.js.map +0 -1
  1027. package/dist/src/wrappers/embedding-service.d.ts +0 -117
  1028. package/dist/src/wrappers/embedding-service.d.ts.map +0 -1
  1029. package/dist/src/wrappers/embedding-service.js +0 -376
  1030. package/dist/src/wrappers/embedding-service.js.map +0 -1
  1031. package/dist/src/wrappers/gnn-wrapper.d.ts +0 -71
  1032. package/dist/src/wrappers/gnn-wrapper.d.ts.map +0 -1
  1033. package/dist/src/wrappers/gnn-wrapper.js +0 -240
  1034. package/dist/src/wrappers/gnn-wrapper.js.map +0 -1
  1035. package/dist/src/wrappers/index.d.ts +0 -48
  1036. package/dist/src/wrappers/index.d.ts.map +0 -1
  1037. package/dist/src/wrappers/index.js +0 -83
  1038. package/dist/src/wrappers/index.js.map +0 -1
@@ -0,0 +1,1492 @@
1
+ /*! AgentDB Browser Bundle v3.0.0-alpha.1 | MIT License | https://agentdb.ruv.io */
2
+
3
+ // src/browser/ProductQuantization.ts
4
+ var ProductQuantization = class {
5
+ config;
6
+ codebook = null;
7
+ trained = false;
8
+ constructor(config) {
9
+ this.config = {
10
+ dimension: config.dimension,
11
+ numSubvectors: config.numSubvectors,
12
+ numCentroids: config.numCentroids,
13
+ maxIterations: config.maxIterations || 50,
14
+ convergenceThreshold: config.convergenceThreshold || 1e-4
15
+ };
16
+ if (this.config.dimension % this.config.numSubvectors !== 0) {
17
+ throw new Error(`Dimension ${this.config.dimension} must be divisible by numSubvectors ${this.config.numSubvectors}`);
18
+ }
19
+ }
20
+ /**
21
+ * Train codebook using k-means on training vectors
22
+ */
23
+ async train(vectors) {
24
+ if (vectors.length === 0) {
25
+ throw new Error("Training requires at least one vector");
26
+ }
27
+ const subvectorDim = this.config.dimension / this.config.numSubvectors;
28
+ const centroids = [];
29
+ console.log(`[PQ] Training ${this.config.numSubvectors} subvectors with ${this.config.numCentroids} centroids each...`);
30
+ for (let s = 0; s < this.config.numSubvectors; s++) {
31
+ const startDim = s * subvectorDim;
32
+ const endDim = startDim + subvectorDim;
33
+ const subvectors = vectors.map((v) => v.slice(startDim, endDim));
34
+ const subCentroids = await this.kMeans(subvectors, this.config.numCentroids);
35
+ centroids.push(...subCentroids);
36
+ if ((s + 1) % 4 === 0 || s === this.config.numSubvectors - 1) {
37
+ console.log(`[PQ] Trained ${s + 1}/${this.config.numSubvectors} subvectors`);
38
+ }
39
+ }
40
+ this.codebook = {
41
+ subvectorDim,
42
+ numSubvectors: this.config.numSubvectors,
43
+ numCentroids: this.config.numCentroids,
44
+ centroids
45
+ };
46
+ this.trained = true;
47
+ console.log("[PQ] Training complete");
48
+ }
49
+ /**
50
+ * K-means clustering for centroids
51
+ */
52
+ async kMeans(vectors, k) {
53
+ const dim = vectors[0].length;
54
+ const n = vectors.length;
55
+ const centroids = this.kMeansPlusPlus(vectors, k);
56
+ const assignments = new Uint32Array(n);
57
+ let prevInertia = Infinity;
58
+ for (let iter = 0; iter < this.config.maxIterations; iter++) {
59
+ let inertia = 0;
60
+ for (let i = 0; i < n; i++) {
61
+ let minDist = Infinity;
62
+ let minIdx = 0;
63
+ for (let j = 0; j < k; j++) {
64
+ const dist = this.squaredDistance(vectors[i], centroids[j]);
65
+ if (dist < minDist) {
66
+ minDist = dist;
67
+ minIdx = j;
68
+ }
69
+ }
70
+ assignments[i] = minIdx;
71
+ inertia += minDist;
72
+ }
73
+ if (Math.abs(prevInertia - inertia) < this.config.convergenceThreshold) {
74
+ break;
75
+ }
76
+ prevInertia = inertia;
77
+ const counts = new Uint32Array(k);
78
+ const sums = Array.from({ length: k }, () => new Float32Array(dim));
79
+ for (let i = 0; i < n; i++) {
80
+ const cluster = assignments[i];
81
+ counts[cluster]++;
82
+ for (let d = 0; d < dim; d++) {
83
+ sums[cluster][d] += vectors[i][d];
84
+ }
85
+ }
86
+ for (let j = 0; j < k; j++) {
87
+ if (counts[j] > 0) {
88
+ for (let d = 0; d < dim; d++) {
89
+ centroids[j][d] = sums[j][d] / counts[j];
90
+ }
91
+ }
92
+ }
93
+ }
94
+ return centroids;
95
+ }
96
+ /**
97
+ * K-means++ initialization for better centroid selection
98
+ */
99
+ kMeansPlusPlus(vectors, k) {
100
+ const n = vectors.length;
101
+ const dim = vectors[0].length;
102
+ const centroids = [];
103
+ const firstIdx = Math.floor(Math.random() * n);
104
+ centroids.push(new Float32Array(vectors[firstIdx]));
105
+ for (let i = 1; i < k; i++) {
106
+ const distances = new Float32Array(n);
107
+ let sumDistances = 0;
108
+ for (let j = 0; j < n; j++) {
109
+ let minDist = Infinity;
110
+ for (const centroid of centroids) {
111
+ const dist = this.squaredDistance(vectors[j], centroid);
112
+ minDist = Math.min(minDist, dist);
113
+ }
114
+ distances[j] = minDist;
115
+ sumDistances += minDist;
116
+ }
117
+ let r = Math.random() * sumDistances;
118
+ for (let j = 0; j < n; j++) {
119
+ r -= distances[j];
120
+ if (r <= 0) {
121
+ centroids.push(new Float32Array(vectors[j]));
122
+ break;
123
+ }
124
+ }
125
+ }
126
+ return centroids;
127
+ }
128
+ /**
129
+ * Compress a vector using trained codebook
130
+ */
131
+ compress(vector) {
132
+ if (!this.trained || !this.codebook) {
133
+ throw new Error("Codebook must be trained before compression");
134
+ }
135
+ const codes = new Uint8Array(this.config.numSubvectors);
136
+ const subvectorDim = this.codebook.subvectorDim;
137
+ let norm = 0;
138
+ for (let i = 0; i < vector.length; i++) {
139
+ norm += vector[i] * vector[i];
140
+ }
141
+ norm = Math.sqrt(norm);
142
+ for (let s = 0; s < this.config.numSubvectors; s++) {
143
+ const startDim = s * subvectorDim;
144
+ const subvector = vector.slice(startDim, startDim + subvectorDim);
145
+ let minDist = Infinity;
146
+ let minIdx = 0;
147
+ const centroidOffset = s * this.config.numCentroids;
148
+ for (let c = 0; c < this.config.numCentroids; c++) {
149
+ const centroid = this.codebook.centroids[centroidOffset + c];
150
+ const dist = this.squaredDistance(subvector, centroid);
151
+ if (dist < minDist) {
152
+ minDist = dist;
153
+ minIdx = c;
154
+ }
155
+ }
156
+ codes[s] = minIdx;
157
+ }
158
+ return { codes, norm };
159
+ }
160
+ /**
161
+ * Decompress a vector (approximate reconstruction)
162
+ */
163
+ decompress(compressed) {
164
+ if (!this.codebook) {
165
+ throw new Error("Codebook not available");
166
+ }
167
+ const vector = new Float32Array(this.config.dimension);
168
+ const subvectorDim = this.codebook.subvectorDim;
169
+ for (let s = 0; s < this.config.numSubvectors; s++) {
170
+ const code = compressed.codes[s];
171
+ const centroidOffset = s * this.config.numCentroids;
172
+ const centroid = this.codebook.centroids[centroidOffset + code];
173
+ const startDim = s * subvectorDim;
174
+ for (let d = 0; d < subvectorDim; d++) {
175
+ vector[startDim + d] = centroid[d];
176
+ }
177
+ }
178
+ return vector;
179
+ }
180
+ /**
181
+ * Asymmetric Distance Computation (ADC)
182
+ * Computes distance from query vector to compressed vector
183
+ */
184
+ asymmetricDistance(query, compressed) {
185
+ if (!this.codebook) {
186
+ throw new Error("Codebook not available");
187
+ }
188
+ let distance = 0;
189
+ const subvectorDim = this.codebook.subvectorDim;
190
+ for (let s = 0; s < this.config.numSubvectors; s++) {
191
+ const code = compressed.codes[s];
192
+ const centroidOffset = s * this.config.numCentroids;
193
+ const centroid = this.codebook.centroids[centroidOffset + code];
194
+ const startDim = s * subvectorDim;
195
+ const querySubvector = query.slice(startDim, startDim + subvectorDim);
196
+ distance += this.squaredDistance(querySubvector, centroid);
197
+ }
198
+ return Math.sqrt(distance);
199
+ }
200
+ /**
201
+ * Batch compression for multiple vectors
202
+ */
203
+ batchCompress(vectors) {
204
+ return vectors.map((v) => this.compress(v));
205
+ }
206
+ /**
207
+ * Get memory savings
208
+ */
209
+ getCompressionRatio() {
210
+ const originalBytes = this.config.dimension * 4;
211
+ const compressedBytes = this.config.numSubvectors + 4;
212
+ return originalBytes / compressedBytes;
213
+ }
214
+ /**
215
+ * Export codebook for persistence
216
+ */
217
+ exportCodebook() {
218
+ if (!this.codebook) {
219
+ throw new Error("No codebook to export");
220
+ }
221
+ return JSON.stringify({
222
+ config: this.config,
223
+ codebook: {
224
+ subvectorDim: this.codebook.subvectorDim,
225
+ numSubvectors: this.codebook.numSubvectors,
226
+ numCentroids: this.codebook.numCentroids,
227
+ centroids: this.codebook.centroids.map((c) => Array.from(c))
228
+ }
229
+ });
230
+ }
231
+ /**
232
+ * Import codebook
233
+ */
234
+ importCodebook(json) {
235
+ const data = JSON.parse(json);
236
+ this.config = data.config;
237
+ this.codebook = {
238
+ subvectorDim: data.codebook.subvectorDim,
239
+ numSubvectors: data.codebook.numSubvectors,
240
+ numCentroids: data.codebook.numCentroids,
241
+ centroids: data.codebook.centroids.map((c) => new Float32Array(c))
242
+ };
243
+ this.trained = true;
244
+ }
245
+ /**
246
+ * Utility: Squared Euclidean distance
247
+ */
248
+ squaredDistance(a, b) {
249
+ let sum = 0;
250
+ for (let i = 0; i < a.length; i++) {
251
+ const diff = a[i] - b[i];
252
+ sum += diff * diff;
253
+ }
254
+ return sum;
255
+ }
256
+ /**
257
+ * Get statistics
258
+ */
259
+ getStats() {
260
+ const compressionRatio = this.getCompressionRatio();
261
+ const memoryPerVector = this.config.numSubvectors + 4;
262
+ const codebookSize = this.codebook ? this.config.numSubvectors * this.config.numCentroids * (this.config.dimension / this.config.numSubvectors) * 4 : 0;
263
+ return {
264
+ trained: this.trained,
265
+ compressionRatio,
266
+ memoryPerVector,
267
+ codebookSize
268
+ };
269
+ }
270
+ };
271
+ function createPQ8(dimension) {
272
+ return new ProductQuantization({
273
+ dimension,
274
+ numSubvectors: 8,
275
+ numCentroids: 256,
276
+ maxIterations: 50
277
+ });
278
+ }
279
+ function createPQ16(dimension) {
280
+ return new ProductQuantization({
281
+ dimension,
282
+ numSubvectors: 16,
283
+ numCentroids: 256,
284
+ maxIterations: 50
285
+ });
286
+ }
287
+ function createPQ32(dimension) {
288
+ return new ProductQuantization({
289
+ dimension,
290
+ numSubvectors: 32,
291
+ numCentroids: 256,
292
+ maxIterations: 50
293
+ });
294
+ }
295
+
296
+ // src/browser/HNSWIndex.ts
297
+ var MinHeap = class {
298
+ items = [];
299
+ push(item, priority) {
300
+ this.items.push({ item, priority });
301
+ this.bubbleUp(this.items.length - 1);
302
+ }
303
+ pop() {
304
+ if (this.items.length === 0) return void 0;
305
+ const result = this.items[0].item;
306
+ const last = this.items.pop();
307
+ if (this.items.length > 0) {
308
+ this.items[0] = last;
309
+ this.bubbleDown(0);
310
+ }
311
+ return result;
312
+ }
313
+ peek() {
314
+ var _a;
315
+ return (_a = this.items[0]) == null ? void 0 : _a.item;
316
+ }
317
+ size() {
318
+ return this.items.length;
319
+ }
320
+ bubbleUp(index) {
321
+ while (index > 0) {
322
+ const parentIndex = Math.floor((index - 1) / 2);
323
+ if (this.items[index].priority >= this.items[parentIndex].priority) break;
324
+ [this.items[index], this.items[parentIndex]] = [this.items[parentIndex], this.items[index]];
325
+ index = parentIndex;
326
+ }
327
+ }
328
+ bubbleDown(index) {
329
+ while (true) {
330
+ const leftChild = 2 * index + 1;
331
+ const rightChild = 2 * index + 2;
332
+ let smallest = index;
333
+ if (leftChild < this.items.length && this.items[leftChild].priority < this.items[smallest].priority) {
334
+ smallest = leftChild;
335
+ }
336
+ if (rightChild < this.items.length && this.items[rightChild].priority < this.items[smallest].priority) {
337
+ smallest = rightChild;
338
+ }
339
+ if (smallest === index) break;
340
+ [this.items[index], this.items[smallest]] = [this.items[smallest], this.items[index]];
341
+ index = smallest;
342
+ }
343
+ }
344
+ };
345
+ var HNSWIndex = class {
346
+ config;
347
+ nodes = /* @__PURE__ */ new Map();
348
+ entryPoint = null;
349
+ currentId = 0;
350
+ ml;
351
+ constructor(config = {}) {
352
+ this.config = {
353
+ dimension: config.dimension || 384,
354
+ M: config.M || 16,
355
+ efConstruction: config.efConstruction || 200,
356
+ efSearch: config.efSearch || 50,
357
+ ml: config.ml || 1 / Math.log(2),
358
+ maxLayers: config.maxLayers || 16,
359
+ distanceFunction: config.distanceFunction || "cosine"
360
+ };
361
+ this.ml = this.config.ml;
362
+ }
363
+ /**
364
+ * Add vector to index
365
+ */
366
+ add(vector, id) {
367
+ const nodeId = id !== void 0 ? id : this.currentId++;
368
+ const level = this.randomLevel();
369
+ const node = {
370
+ id: nodeId,
371
+ vector,
372
+ level,
373
+ connections: /* @__PURE__ */ new Map()
374
+ };
375
+ for (let l = 0; l <= level; l++) {
376
+ node.connections.set(l, []);
377
+ }
378
+ if (this.entryPoint === null) {
379
+ this.entryPoint = nodeId;
380
+ this.nodes.set(nodeId, node);
381
+ return nodeId;
382
+ }
383
+ const ep = this.entryPoint;
384
+ let nearest = ep;
385
+ for (let lc = this.nodes.get(ep).level; lc > level; lc--) {
386
+ nearest = this.searchLayer(vector, nearest, 1, lc)[0];
387
+ }
388
+ for (let lc = Math.min(level, this.nodes.get(ep).level); lc >= 0; lc--) {
389
+ const candidates = this.searchLayer(vector, nearest, this.config.efConstruction, lc);
390
+ const M = lc === 0 ? this.config.M * 2 : this.config.M;
391
+ const neighbors = this.selectNeighbors(vector, candidates, M);
392
+ for (const neighbor of neighbors) {
393
+ this.connect(nodeId, neighbor, lc);
394
+ this.connect(neighbor, nodeId, lc);
395
+ const neighborNode = this.nodes.get(neighbor);
396
+ const neighborConnections = neighborNode.connections.get(lc);
397
+ if (neighborConnections.length > M) {
398
+ const newNeighbors = this.selectNeighbors(
399
+ neighborNode.vector,
400
+ neighborConnections,
401
+ M
402
+ );
403
+ neighborNode.connections.set(lc, newNeighbors);
404
+ }
405
+ }
406
+ nearest = candidates[0];
407
+ }
408
+ if (level > this.nodes.get(this.entryPoint).level) {
409
+ this.entryPoint = nodeId;
410
+ }
411
+ this.nodes.set(nodeId, node);
412
+ return nodeId;
413
+ }
414
+ /**
415
+ * Search for k nearest neighbors
416
+ */
417
+ search(query, k, ef) {
418
+ if (this.entryPoint === null) return [];
419
+ ef = ef || Math.max(this.config.efSearch, k);
420
+ let ep = this.entryPoint;
421
+ let nearest = ep;
422
+ for (let lc = this.nodes.get(ep).level; lc > 0; lc--) {
423
+ nearest = this.searchLayer(query, nearest, 1, lc)[0];
424
+ }
425
+ const candidates = this.searchLayer(query, nearest, ef, 0);
426
+ return candidates.slice(0, k).map((id) => ({
427
+ id,
428
+ distance: this.distance(query, this.nodes.get(id).vector),
429
+ vector: this.nodes.get(id).vector
430
+ }));
431
+ }
432
+ /**
433
+ * Search at specific layer
434
+ */
435
+ searchLayer(query, ep, ef, layer) {
436
+ const visited = /* @__PURE__ */ new Set();
437
+ const candidates = new MinHeap();
438
+ const w = new MinHeap();
439
+ const dist = this.distance(query, this.nodes.get(ep).vector);
440
+ candidates.push(ep, dist);
441
+ w.push(ep, -dist);
442
+ visited.add(ep);
443
+ while (candidates.size() > 0) {
444
+ const c = candidates.pop();
445
+ const fDist = -w.peek();
446
+ const cDist = this.distance(query, this.nodes.get(c).vector);
447
+ if (cDist > fDist) break;
448
+ const neighbors = this.nodes.get(c).connections.get(layer) || [];
449
+ for (const e of neighbors) {
450
+ if (visited.has(e)) continue;
451
+ visited.add(e);
452
+ const eDist = this.distance(query, this.nodes.get(e).vector);
453
+ const fDist2 = -w.peek();
454
+ if (eDist < fDist2 || w.size() < ef) {
455
+ candidates.push(e, eDist);
456
+ w.push(e, -eDist);
457
+ if (w.size() > ef) {
458
+ w.pop();
459
+ }
460
+ }
461
+ }
462
+ }
463
+ const result = [];
464
+ while (w.size() > 0) {
465
+ result.unshift(w.pop());
466
+ }
467
+ return result;
468
+ }
469
+ /**
470
+ * Select best neighbors using heuristic
471
+ */
472
+ selectNeighbors(base, candidates, M) {
473
+ if (candidates.length <= M) return candidates;
474
+ const sorted = candidates.map((id) => ({
475
+ id,
476
+ distance: this.distance(base, this.nodes.get(id).vector)
477
+ })).sort((a, b) => a.distance - b.distance);
478
+ return sorted.slice(0, M).map((x) => x.id);
479
+ }
480
+ /**
481
+ * Connect two nodes at layer
482
+ */
483
+ connect(from, to, layer) {
484
+ const node = this.nodes.get(from);
485
+ const connections = node.connections.get(layer);
486
+ if (!connections.includes(to)) {
487
+ connections.push(to);
488
+ }
489
+ }
490
+ /**
491
+ * Random level assignment
492
+ */
493
+ randomLevel() {
494
+ let level = 0;
495
+ while (Math.random() < this.ml && level < this.config.maxLayers - 1) {
496
+ level++;
497
+ }
498
+ return level;
499
+ }
500
+ /**
501
+ * Distance function
502
+ */
503
+ distance(a, b) {
504
+ switch (this.config.distanceFunction) {
505
+ case "cosine":
506
+ return 1 - this.cosineSimilarity(a, b);
507
+ case "euclidean":
508
+ return this.euclideanDistance(a, b);
509
+ case "manhattan":
510
+ return this.manhattanDistance(a, b);
511
+ default:
512
+ return 1 - this.cosineSimilarity(a, b);
513
+ }
514
+ }
515
+ cosineSimilarity(a, b) {
516
+ let dotProduct = 0;
517
+ let normA = 0;
518
+ let normB = 0;
519
+ for (let i = 0; i < a.length; i++) {
520
+ dotProduct += a[i] * b[i];
521
+ normA += a[i] * a[i];
522
+ normB += b[i] * b[i];
523
+ }
524
+ return dotProduct / (Math.sqrt(normA) * Math.sqrt(normB));
525
+ }
526
+ euclideanDistance(a, b) {
527
+ let sum = 0;
528
+ for (let i = 0; i < a.length; i++) {
529
+ const diff = a[i] - b[i];
530
+ sum += diff * diff;
531
+ }
532
+ return Math.sqrt(sum);
533
+ }
534
+ manhattanDistance(a, b) {
535
+ let sum = 0;
536
+ for (let i = 0; i < a.length; i++) {
537
+ sum += Math.abs(a[i] - b[i]);
538
+ }
539
+ return sum;
540
+ }
541
+ /**
542
+ * Get index statistics
543
+ */
544
+ getStats() {
545
+ if (this.nodes.size === 0) {
546
+ return {
547
+ numNodes: 0,
548
+ numLayers: 0,
549
+ avgConnections: 0,
550
+ entryPointLevel: 0,
551
+ memoryBytes: 0
552
+ };
553
+ }
554
+ const maxLevel = Math.max(...Array.from(this.nodes.values()).map((n) => n.level));
555
+ let totalConnections = 0;
556
+ for (const node of this.nodes.values()) {
557
+ for (const connections of node.connections.values()) {
558
+ totalConnections += connections.length;
559
+ }
560
+ }
561
+ const avgConnections = totalConnections / this.nodes.size;
562
+ const vectorBytes = this.config.dimension * 4;
563
+ const connectionBytes = avgConnections * 4;
564
+ const metadataBytes = 100;
565
+ const memoryBytes = this.nodes.size * (vectorBytes + connectionBytes + metadataBytes);
566
+ return {
567
+ numNodes: this.nodes.size,
568
+ numLayers: maxLevel + 1,
569
+ avgConnections,
570
+ entryPointLevel: this.entryPoint ? this.nodes.get(this.entryPoint).level : 0,
571
+ memoryBytes
572
+ };
573
+ }
574
+ /**
575
+ * Export index for persistence
576
+ */
577
+ export() {
578
+ const data = {
579
+ config: this.config,
580
+ entryPoint: this.entryPoint,
581
+ currentId: this.currentId,
582
+ nodes: Array.from(this.nodes.entries()).map(([id, node]) => ({
583
+ id,
584
+ vector: Array.from(node.vector),
585
+ level: node.level,
586
+ connections: Array.from(node.connections.entries())
587
+ }))
588
+ };
589
+ return JSON.stringify(data);
590
+ }
591
+ /**
592
+ * Import index from JSON
593
+ */
594
+ import(json) {
595
+ const data = JSON.parse(json);
596
+ this.config = data.config;
597
+ this.entryPoint = data.entryPoint;
598
+ this.currentId = data.currentId;
599
+ this.nodes.clear();
600
+ for (const nodeData of data.nodes) {
601
+ const node = {
602
+ id: nodeData.id,
603
+ vector: new Float32Array(nodeData.vector),
604
+ level: nodeData.level,
605
+ connections: new Map(nodeData.connections)
606
+ };
607
+ this.nodes.set(nodeData.id, node);
608
+ }
609
+ }
610
+ /**
611
+ * Clear index
612
+ */
613
+ clear() {
614
+ this.nodes.clear();
615
+ this.entryPoint = null;
616
+ this.currentId = 0;
617
+ }
618
+ /**
619
+ * Get number of nodes
620
+ */
621
+ size() {
622
+ return this.nodes.size;
623
+ }
624
+ };
625
+ function createHNSW(dimension) {
626
+ return new HNSWIndex({
627
+ dimension,
628
+ M: 16,
629
+ efConstruction: 200,
630
+ efSearch: 50
631
+ });
632
+ }
633
+ function createFastHNSW(dimension) {
634
+ return new HNSWIndex({
635
+ dimension,
636
+ M: 8,
637
+ efConstruction: 100,
638
+ efSearch: 30
639
+ });
640
+ }
641
+ function createAccurateHNSW(dimension) {
642
+ return new HNSWIndex({
643
+ dimension,
644
+ M: 32,
645
+ efConstruction: 400,
646
+ efSearch: 100
647
+ });
648
+ }
649
+
650
+ // src/browser/AdvancedFeatures.ts
651
+ var GraphNeuralNetwork = class {
652
+ config;
653
+ nodes = /* @__PURE__ */ new Map();
654
+ edges = [];
655
+ attentionWeights = /* @__PURE__ */ new Map();
656
+ constructor(config = {}) {
657
+ this.config = {
658
+ hiddenDim: config.hiddenDim || 64,
659
+ numHeads: config.numHeads || 4,
660
+ dropout: config.dropout || 0.1,
661
+ learningRate: config.learningRate || 0.01,
662
+ attentionType: config.attentionType || "gat"
663
+ };
664
+ }
665
+ /**
666
+ * Add node to graph
667
+ */
668
+ addNode(id, features) {
669
+ this.nodes.set(id, {
670
+ id,
671
+ features,
672
+ neighbors: []
673
+ });
674
+ }
675
+ /**
676
+ * Add edge to graph
677
+ */
678
+ addEdge(from, to, weight = 1) {
679
+ this.edges.push({ from, to, weight });
680
+ const fromNode = this.nodes.get(from);
681
+ const toNode = this.nodes.get(to);
682
+ if (fromNode && !fromNode.neighbors.includes(to)) {
683
+ fromNode.neighbors.push(to);
684
+ }
685
+ if (toNode && !toNode.neighbors.includes(from)) {
686
+ toNode.neighbors.push(from);
687
+ }
688
+ }
689
+ /**
690
+ * Graph Attention Network (GAT) message passing
691
+ */
692
+ graphAttention(nodeId) {
693
+ const node = this.nodes.get(nodeId);
694
+ if (!node) throw new Error(`Node ${nodeId} not found`);
695
+ const neighbors = node.neighbors;
696
+ if (neighbors.length === 0) {
697
+ return node.features;
698
+ }
699
+ const headDim = Math.floor(this.config.hiddenDim / this.config.numHeads);
700
+ const aggregated = new Float32Array(this.config.hiddenDim);
701
+ for (let h = 0; h < this.config.numHeads; h++) {
702
+ let attentionSum = 0;
703
+ const headOutput = new Float32Array(headDim);
704
+ for (const neighborId of neighbors) {
705
+ const neighbor = this.nodes.get(neighborId);
706
+ const score = this.computeAttentionScore(
707
+ node.features,
708
+ neighbor.features,
709
+ h
710
+ );
711
+ attentionSum += score;
712
+ for (let i = 0; i < headDim && i < neighbor.features.length; i++) {
713
+ headOutput[i] += score * neighbor.features[i];
714
+ }
715
+ }
716
+ if (attentionSum > 0) {
717
+ for (let i = 0; i < headDim; i++) {
718
+ headOutput[i] /= attentionSum;
719
+ }
720
+ }
721
+ const offset = h * headDim;
722
+ for (let i = 0; i < headDim; i++) {
723
+ aggregated[offset + i] = headOutput[i];
724
+ }
725
+ }
726
+ for (let i = 0; i < aggregated.length; i++) {
727
+ aggregated[i] = aggregated[i] > 0 ? aggregated[i] : 0.01 * aggregated[i];
728
+ }
729
+ return aggregated;
730
+ }
731
+ /**
732
+ * Compute attention score between two nodes
733
+ */
734
+ computeAttentionScore(features1, features2, head) {
735
+ let score = 0;
736
+ const len = Math.min(features1.length, features2.length);
737
+ for (let i = 0; i < len; i++) {
738
+ score += features1[i] * features2[i];
739
+ }
740
+ return Math.exp(score / Math.sqrt(len));
741
+ }
742
+ /**
743
+ * Message passing for all nodes
744
+ */
745
+ messagePass() {
746
+ const newFeatures = /* @__PURE__ */ new Map();
747
+ for (const [nodeId] of this.nodes) {
748
+ newFeatures.set(nodeId, this.graphAttention(nodeId));
749
+ }
750
+ return newFeatures;
751
+ }
752
+ /**
753
+ * Update node features after message passing
754
+ */
755
+ update(newFeatures) {
756
+ for (const [nodeId, features] of newFeatures) {
757
+ const node = this.nodes.get(nodeId);
758
+ if (node) {
759
+ node.features = features;
760
+ }
761
+ }
762
+ }
763
+ /**
764
+ * Compute graph embeddings for query enhancement
765
+ */
766
+ computeGraphEmbedding(nodeId, hops = 2) {
767
+ const features = /* @__PURE__ */ new Map();
768
+ features.set(nodeId, this.nodes.get(nodeId).features);
769
+ for (let h = 0; h < hops; h++) {
770
+ const newFeatures = this.messagePass();
771
+ this.update(newFeatures);
772
+ }
773
+ return this.nodes.get(nodeId).features;
774
+ }
775
+ /**
776
+ * Get statistics
777
+ */
778
+ getStats() {
779
+ return {
780
+ numNodes: this.nodes.size,
781
+ numEdges: this.edges.length,
782
+ avgDegree: this.edges.length / Math.max(this.nodes.size, 1),
783
+ config: this.config
784
+ };
785
+ }
786
+ };
787
+ var MaximalMarginalRelevance = class {
788
+ config;
789
+ constructor(config = {}) {
790
+ this.config = {
791
+ lambda: config.lambda || 0.7,
792
+ metric: config.metric || "cosine"
793
+ };
794
+ }
795
+ /**
796
+ * Rerank results for diversity
797
+ * @param query Query vector
798
+ * @param candidates Candidate vectors with scores
799
+ * @param k Number of results to return
800
+ * @returns Reranked indices
801
+ */
802
+ rerank(query, candidates, k) {
803
+ if (candidates.length === 0) return [];
804
+ const selected = [];
805
+ const remaining = new Set(candidates.map((_, i) => i));
806
+ let bestIdx = 0;
807
+ let bestScore = -Infinity;
808
+ for (let i = 0; i < candidates.length; i++) {
809
+ if (candidates[i].score > bestScore) {
810
+ bestScore = candidates[i].score;
811
+ bestIdx = i;
812
+ }
813
+ }
814
+ selected.push(candidates[bestIdx].id);
815
+ remaining.delete(bestIdx);
816
+ while (selected.length < k && remaining.size > 0) {
817
+ let bestMMR = -Infinity;
818
+ let bestCandidate = -1;
819
+ for (const idx of remaining) {
820
+ const candidate = candidates[idx];
821
+ const relevance = this.similarity(query, candidate.vector);
822
+ let maxSimilarity = -Infinity;
823
+ for (const selectedId of selected) {
824
+ const selectedCandidate = candidates.find((c) => c.id === selectedId);
825
+ const sim = this.similarity(candidate.vector, selectedCandidate.vector);
826
+ maxSimilarity = Math.max(maxSimilarity, sim);
827
+ }
828
+ const mmr = this.config.lambda * relevance - (1 - this.config.lambda) * maxSimilarity;
829
+ if (mmr > bestMMR) {
830
+ bestMMR = mmr;
831
+ bestCandidate = idx;
832
+ }
833
+ }
834
+ if (bestCandidate !== -1) {
835
+ selected.push(candidates[bestCandidate].id);
836
+ remaining.delete(bestCandidate);
837
+ } else {
838
+ break;
839
+ }
840
+ }
841
+ return selected;
842
+ }
843
+ /**
844
+ * Similarity computation
845
+ */
846
+ similarity(a, b) {
847
+ if (this.config.metric === "cosine") {
848
+ return this.cosineSimilarity(a, b);
849
+ } else {
850
+ const dist = this.euclideanDistance(a, b);
851
+ return 1 / (1 + dist);
852
+ }
853
+ }
854
+ cosineSimilarity(a, b) {
855
+ let dotProduct = 0;
856
+ let normA = 0;
857
+ let normB = 0;
858
+ for (let i = 0; i < a.length; i++) {
859
+ dotProduct += a[i] * b[i];
860
+ normA += a[i] * a[i];
861
+ normB += b[i] * b[i];
862
+ }
863
+ return dotProduct / (Math.sqrt(normA) * Math.sqrt(normB));
864
+ }
865
+ euclideanDistance(a, b) {
866
+ let sum = 0;
867
+ for (let i = 0; i < a.length; i++) {
868
+ const diff = a[i] - b[i];
869
+ sum += diff * diff;
870
+ }
871
+ return Math.sqrt(sum);
872
+ }
873
+ /**
874
+ * Set lambda (relevance vs diversity trade-off)
875
+ */
876
+ setLambda(lambda) {
877
+ this.config.lambda = Math.max(0, Math.min(1, lambda));
878
+ }
879
+ };
880
+ var TensorCompression = class {
881
+ /**
882
+ * Reduce dimensionality using truncated SVD
883
+ * @param vectors Array of vectors to compress
884
+ * @param targetDim Target dimension
885
+ * @returns Compressed vectors
886
+ */
887
+ static compress(vectors, targetDim) {
888
+ if (vectors.length === 0) return [];
889
+ const originalDim = vectors[0].length;
890
+ if (targetDim >= originalDim) return vectors;
891
+ const matrix = vectors.map((v) => Array.from(v));
892
+ const mean = this.computeMean(matrix);
893
+ const centered = matrix.map(
894
+ (row) => row.map((val, i) => val - mean[i])
895
+ );
896
+ const cov = this.computeCovariance(centered);
897
+ const eigenvectors = this.powerIteration(cov, targetDim);
898
+ const compressed = centered.map((row) => {
899
+ const projected = new Float32Array(targetDim);
900
+ for (let i = 0; i < targetDim; i++) {
901
+ let sum = 0;
902
+ for (let j = 0; j < originalDim; j++) {
903
+ sum += row[j] * eigenvectors[i][j];
904
+ }
905
+ projected[i] = sum;
906
+ }
907
+ return projected;
908
+ });
909
+ return compressed;
910
+ }
911
+ /**
912
+ * Compute mean vector
913
+ */
914
+ static computeMean(matrix) {
915
+ const n = matrix.length;
916
+ const dim = matrix[0].length;
917
+ const mean = new Array(dim).fill(0);
918
+ for (const row of matrix) {
919
+ for (let i = 0; i < dim; i++) {
920
+ mean[i] += row[i];
921
+ }
922
+ }
923
+ return mean.map((v) => v / n);
924
+ }
925
+ /**
926
+ * Compute covariance matrix
927
+ */
928
+ static computeCovariance(matrix) {
929
+ const n = matrix.length;
930
+ const dim = matrix[0].length;
931
+ const cov = Array.from(
932
+ { length: dim },
933
+ () => new Array(dim).fill(0)
934
+ );
935
+ for (let i = 0; i < dim; i++) {
936
+ for (let j = 0; j <= i; j++) {
937
+ let sum = 0;
938
+ for (const row of matrix) {
939
+ sum += row[i] * row[j];
940
+ }
941
+ cov[i][j] = cov[j][i] = sum / n;
942
+ }
943
+ }
944
+ return cov;
945
+ }
946
+ /**
947
+ * Power iteration for computing top eigenvectors
948
+ */
949
+ static powerIteration(matrix, k, iterations = 100) {
950
+ const dim = matrix.length;
951
+ const eigenvectors = [];
952
+ for (let i = 0; i < k; i++) {
953
+ let v = new Array(dim).fill(0).map(() => Math.random() - 0.5);
954
+ for (let iter = 0; iter < iterations; iter++) {
955
+ const newV = new Array(dim).fill(0);
956
+ for (let r = 0; r < dim; r++) {
957
+ for (let c = 0; c < dim; c++) {
958
+ newV[r] += matrix[r][c] * v[c];
959
+ }
960
+ }
961
+ for (const prev of eigenvectors) {
962
+ let dot = 0;
963
+ for (let j = 0; j < dim; j++) {
964
+ dot += newV[j] * prev[j];
965
+ }
966
+ for (let j = 0; j < dim; j++) {
967
+ newV[j] -= dot * prev[j];
968
+ }
969
+ }
970
+ let norm = 0;
971
+ for (const val of newV) {
972
+ norm += val * val;
973
+ }
974
+ norm = Math.sqrt(norm);
975
+ if (norm < 1e-10) break;
976
+ v = newV.map((val) => val / norm);
977
+ }
978
+ eigenvectors.push(v);
979
+ }
980
+ return eigenvectors;
981
+ }
982
+ };
983
+ var BatchProcessor = class {
984
+ /**
985
+ * Batch cosine similarity computation
986
+ */
987
+ static batchCosineSimilarity(query, vectors) {
988
+ const similarities = new Float32Array(vectors.length);
989
+ let queryNorm = 0;
990
+ for (let i = 0; i < query.length; i++) {
991
+ queryNorm += query[i] * query[i];
992
+ }
993
+ queryNorm = Math.sqrt(queryNorm);
994
+ for (let v = 0; v < vectors.length; v++) {
995
+ const vector = vectors[v];
996
+ let dotProduct = 0;
997
+ let vectorNorm = 0;
998
+ for (let i = 0; i < query.length; i++) {
999
+ dotProduct += query[i] * vector[i];
1000
+ vectorNorm += vector[i] * vector[i];
1001
+ }
1002
+ vectorNorm = Math.sqrt(vectorNorm);
1003
+ similarities[v] = dotProduct / (queryNorm * vectorNorm);
1004
+ }
1005
+ return similarities;
1006
+ }
1007
+ /**
1008
+ * Batch vector normalization
1009
+ */
1010
+ static batchNormalize(vectors) {
1011
+ return vectors.map((v) => {
1012
+ let norm = 0;
1013
+ for (let i = 0; i < v.length; i++) {
1014
+ norm += v[i] * v[i];
1015
+ }
1016
+ norm = Math.sqrt(norm);
1017
+ const normalized = new Float32Array(v.length);
1018
+ for (let i = 0; i < v.length; i++) {
1019
+ normalized[i] = v[i] / norm;
1020
+ }
1021
+ return normalized;
1022
+ });
1023
+ }
1024
+ };
1025
+
1026
+ // src/browser/AttentionBrowser.ts
1027
+ var AttentionBrowser = class {
1028
+ wasmModule = null;
1029
+ loadingState = "idle";
1030
+ loadError = null;
1031
+ config;
1032
+ constructor(config = {}) {
1033
+ this.config = {
1034
+ dimension: 384,
1035
+ numHeads: 4,
1036
+ blockSize: 64,
1037
+ curvature: -1,
1038
+ useWASM: true,
1039
+ ...config
1040
+ };
1041
+ }
1042
+ /**
1043
+ * Get current loading state
1044
+ */
1045
+ getLoadingState() {
1046
+ return this.loadingState;
1047
+ }
1048
+ /**
1049
+ * Get loading error if any
1050
+ */
1051
+ getError() {
1052
+ return this.loadError;
1053
+ }
1054
+ /**
1055
+ * Initialize WASM module (lazy loaded)
1056
+ */
1057
+ async initialize() {
1058
+ if (this.loadingState === "loaded") return;
1059
+ if (this.loadingState === "loading") {
1060
+ while (this.loadingState === "loading") {
1061
+ await new Promise((resolve) => setTimeout(resolve, 50));
1062
+ }
1063
+ return;
1064
+ }
1065
+ this.loadingState = "loading";
1066
+ try {
1067
+ if (!this.config.useWASM) {
1068
+ this.loadingState = "loaded";
1069
+ return;
1070
+ }
1071
+ const wasmLoader = await import("../../dist/agentdb.wasm-loader.js");
1072
+ this.wasmModule = await wasmLoader.initWASM();
1073
+ this.loadingState = "loaded";
1074
+ } catch (error) {
1075
+ this.loadError = error instanceof Error ? error : new Error(String(error));
1076
+ this.loadingState = "error";
1077
+ console.warn("WASM initialization failed, using fallback:", this.loadError.message);
1078
+ }
1079
+ }
1080
+ /**
1081
+ * Flash Attention - Optimized attention mechanism
1082
+ * O(N) memory complexity instead of O(N²)
1083
+ *
1084
+ * @param query - Query vectors
1085
+ * @param keys - Key vectors
1086
+ * @param values - Value vectors
1087
+ * @returns Attention output
1088
+ */
1089
+ async flashAttention(query, keys, values) {
1090
+ var _a;
1091
+ await this.initialize();
1092
+ if ((_a = this.wasmModule) == null ? void 0 : _a.flashAttention) {
1093
+ try {
1094
+ return this.wasmModule.flashAttention(query, keys, values, this.config);
1095
+ } catch (error) {
1096
+ console.warn("WASM flash attention failed, using fallback:", error);
1097
+ }
1098
+ }
1099
+ return this.flashAttentionFallback(query, keys, values);
1100
+ }
1101
+ /**
1102
+ * Hyperbolic Attention - Attention in hyperbolic space
1103
+ * Better for hierarchical relationships
1104
+ *
1105
+ * @param query - Query vector
1106
+ * @param keys - Key vectors
1107
+ * @returns Similarity scores in hyperbolic space
1108
+ */
1109
+ async hyperbolicAttention(query, keys) {
1110
+ var _a;
1111
+ await this.initialize();
1112
+ if ((_a = this.wasmModule) == null ? void 0 : _a.hyperbolicAttention) {
1113
+ try {
1114
+ return this.wasmModule.hyperbolicAttention(query, keys, this.config);
1115
+ } catch (error) {
1116
+ console.warn("WASM hyperbolic attention failed, using fallback:", error);
1117
+ }
1118
+ }
1119
+ return this.hyperbolicAttentionFallback(query, keys);
1120
+ }
1121
+ /**
1122
+ * Memory Consolidation - Cluster and consolidate similar memories
1123
+ *
1124
+ * @param memories - Array of memory vectors
1125
+ * @param config - Consolidation configuration
1126
+ * @returns Consolidated memory clusters
1127
+ */
1128
+ async consolidateMemories(memories, config = {}) {
1129
+ var _a;
1130
+ await this.initialize();
1131
+ const fullConfig = {
1132
+ threshold: 0.8,
1133
+ maxClusters: 10,
1134
+ minClusterSize: 1,
1135
+ ...config
1136
+ };
1137
+ if ((_a = this.wasmModule) == null ? void 0 : _a.memoryConsolidation) {
1138
+ try {
1139
+ return this.wasmModule.memoryConsolidation(memories, fullConfig);
1140
+ } catch (error) {
1141
+ console.warn("WASM memory consolidation failed, using fallback:", error);
1142
+ }
1143
+ }
1144
+ return this.consolidateMemoriesFallback(memories, fullConfig);
1145
+ }
1146
+ /**
1147
+ * Clean up WASM memory
1148
+ */
1149
+ dispose() {
1150
+ this.wasmModule = null;
1151
+ this.loadingState = "idle";
1152
+ this.loadError = null;
1153
+ }
1154
+ // ========================================================================
1155
+ // Fallback Implementations (Pure JavaScript)
1156
+ // ========================================================================
1157
+ flashAttentionFallback(query, keys, values) {
1158
+ const { dimension = 384 } = this.config;
1159
+ const seqLen = keys.length / dimension;
1160
+ const output = new Float32Array(query.length);
1161
+ for (let i = 0; i < query.length; i += dimension) {
1162
+ const q = query.slice(i, i + dimension);
1163
+ let sumWeights = 0;
1164
+ const weights = new Float32Array(seqLen);
1165
+ for (let j = 0; j < seqLen; j++) {
1166
+ const k = keys.slice(j * dimension, (j + 1) * dimension);
1167
+ let dot = 0;
1168
+ for (let d = 0; d < dimension; d++) {
1169
+ dot += q[d] * k[d];
1170
+ }
1171
+ weights[j] = Math.exp(dot / Math.sqrt(dimension));
1172
+ sumWeights += weights[j];
1173
+ }
1174
+ for (let j = 0; j < seqLen; j++) {
1175
+ weights[j] /= sumWeights || 1;
1176
+ const v = values.slice(j * dimension, (j + 1) * dimension);
1177
+ for (let d = 0; d < dimension; d++) {
1178
+ output[i + d] += weights[j] * v[d];
1179
+ }
1180
+ }
1181
+ }
1182
+ return output;
1183
+ }
1184
+ hyperbolicAttentionFallback(query, keys) {
1185
+ const { curvature = -1 } = this.config;
1186
+ const k = Math.abs(curvature);
1187
+ const similarities = new Float32Array(keys.length / query.length);
1188
+ for (let i = 0; i < similarities.length; i++) {
1189
+ const offset = i * query.length;
1190
+ let dotProduct = 0;
1191
+ let normQ = 0;
1192
+ let normK = 0;
1193
+ for (let j = 0; j < query.length; j++) {
1194
+ dotProduct += query[j] * keys[offset + j];
1195
+ normQ += query[j] * query[j];
1196
+ normK += keys[offset + j] * keys[offset + j];
1197
+ }
1198
+ const euclidean = Math.sqrt(normQ + normK - 2 * dotProduct);
1199
+ const poincare = Math.acosh(1 + 2 * k * euclidean * euclidean);
1200
+ similarities[i] = 1 / (1 + poincare);
1201
+ }
1202
+ return similarities;
1203
+ }
1204
+ consolidateMemoriesFallback(memories, config) {
1205
+ const { threshold = 0.8, maxClusters = 10, minClusterSize = 1 } = config;
1206
+ const consolidated = [];
1207
+ const used = /* @__PURE__ */ new Set();
1208
+ for (let i = 0; i < memories.length; i++) {
1209
+ if (used.has(i)) continue;
1210
+ const cluster = [memories[i]];
1211
+ used.add(i);
1212
+ for (let j = i + 1; j < memories.length; j++) {
1213
+ if (used.has(j)) continue;
1214
+ const similarity = this.cosineSimilarity(memories[i], memories[j]);
1215
+ if (similarity > threshold) {
1216
+ cluster.push(memories[j]);
1217
+ used.add(j);
1218
+ }
1219
+ }
1220
+ if (cluster.length >= minClusterSize) {
1221
+ const centroid = new Float32Array(memories[i].length);
1222
+ for (const mem of cluster) {
1223
+ for (let k = 0; k < centroid.length; k++) {
1224
+ centroid[k] += mem[k] / cluster.length;
1225
+ }
1226
+ }
1227
+ let norm = 0;
1228
+ for (let k = 0; k < centroid.length; k++) {
1229
+ norm += centroid[k] * centroid[k];
1230
+ }
1231
+ norm = Math.sqrt(norm);
1232
+ if (norm > 0) {
1233
+ for (let k = 0; k < centroid.length; k++) {
1234
+ centroid[k] /= norm;
1235
+ }
1236
+ }
1237
+ consolidated.push({
1238
+ memory: centroid,
1239
+ count: cluster.length,
1240
+ members: cluster
1241
+ });
1242
+ }
1243
+ if (consolidated.length >= maxClusters) break;
1244
+ }
1245
+ return consolidated;
1246
+ }
1247
+ cosineSimilarity(a, b) {
1248
+ let dot = 0;
1249
+ let normA = 0;
1250
+ let normB = 0;
1251
+ for (let i = 0; i < a.length; i++) {
1252
+ dot += a[i] * b[i];
1253
+ normA += a[i] * a[i];
1254
+ normB += b[i] * b[i];
1255
+ }
1256
+ const denominator = Math.sqrt(normA * normB);
1257
+ return denominator > 0 ? dot / denominator : 0;
1258
+ }
1259
+ };
1260
+ function createAttention(config) {
1261
+ return new AttentionBrowser(config);
1262
+ }
1263
+ function createFastAttention() {
1264
+ return new AttentionBrowser({
1265
+ dimension: 256,
1266
+ numHeads: 2,
1267
+ blockSize: 32,
1268
+ useWASM: true
1269
+ });
1270
+ }
1271
+ function createAccurateAttention() {
1272
+ return new AttentionBrowser({
1273
+ dimension: 768,
1274
+ numHeads: 8,
1275
+ blockSize: 128,
1276
+ useWASM: true
1277
+ });
1278
+ }
1279
+
1280
+ // src/browser/index.ts
1281
+ function detectFeatures() {
1282
+ return {
1283
+ indexedDB: "indexedDB" in globalThis,
1284
+ broadcastChannel: "BroadcastChannel" in globalThis,
1285
+ webWorkers: typeof globalThis.Worker !== "undefined",
1286
+ wasmSIMD: detectWasmSIMD(),
1287
+ sharedArrayBuffer: typeof SharedArrayBuffer !== "undefined"
1288
+ };
1289
+ }
1290
+ async function detectWasmSIMD() {
1291
+ try {
1292
+ if (typeof globalThis.WebAssembly === "undefined") {
1293
+ return false;
1294
+ }
1295
+ const simdTest = new Uint8Array([
1296
+ 0,
1297
+ 97,
1298
+ 115,
1299
+ 109,
1300
+ 1,
1301
+ 0,
1302
+ 0,
1303
+ 0,
1304
+ 1,
1305
+ 5,
1306
+ 1,
1307
+ 96,
1308
+ 0,
1309
+ 1,
1310
+ 123,
1311
+ 3,
1312
+ 2,
1313
+ 1,
1314
+ 0,
1315
+ 10,
1316
+ 10,
1317
+ 1,
1318
+ 8,
1319
+ 0,
1320
+ 253,
1321
+ 12,
1322
+ 253,
1323
+ 12,
1324
+ 253,
1325
+ 84,
1326
+ 11
1327
+ ]);
1328
+ const WA = globalThis.WebAssembly;
1329
+ const module = await WA.instantiate(simdTest);
1330
+ return module instanceof WA.Instance;
1331
+ } catch {
1332
+ return false;
1333
+ }
1334
+ }
1335
+ var SMALL_DATASET_CONFIG = {
1336
+ pq: { enabled: false },
1337
+ hnsw: { enabled: false },
1338
+ gnn: { enabled: true, numHeads: 2 },
1339
+ mmr: { enabled: true, lambda: 0.7 },
1340
+ svd: { enabled: false }
1341
+ };
1342
+ var MEDIUM_DATASET_CONFIG = {
1343
+ pq: { enabled: true, subvectors: 8 },
1344
+ hnsw: { enabled: true, M: 16 },
1345
+ gnn: { enabled: true, numHeads: 4 },
1346
+ mmr: { enabled: true, lambda: 0.7 },
1347
+ svd: { enabled: false }
1348
+ };
1349
+ var LARGE_DATASET_CONFIG = {
1350
+ pq: { enabled: true, subvectors: 16 },
1351
+ hnsw: { enabled: true, M: 32 },
1352
+ gnn: { enabled: true, numHeads: 4 },
1353
+ mmr: { enabled: true, lambda: 0.7 },
1354
+ svd: { enabled: true, targetDim: 128 }
1355
+ };
1356
+ var MEMORY_OPTIMIZED_CONFIG = {
1357
+ pq: { enabled: true, subvectors: 32 },
1358
+ // 16x compression
1359
+ hnsw: { enabled: true, M: 8 },
1360
+ // Fewer connections
1361
+ gnn: { enabled: false },
1362
+ mmr: { enabled: false },
1363
+ svd: { enabled: true, targetDim: 64 }
1364
+ // Aggressive dimension reduction
1365
+ };
1366
+ var SPEED_OPTIMIZED_CONFIG = {
1367
+ pq: { enabled: false },
1368
+ // No compression overhead
1369
+ hnsw: { enabled: true, M: 32, efSearch: 100 },
1370
+ // Maximum HNSW quality
1371
+ gnn: { enabled: false },
1372
+ mmr: { enabled: false },
1373
+ svd: { enabled: false }
1374
+ };
1375
+ var QUALITY_OPTIMIZED_CONFIG = {
1376
+ pq: { enabled: false },
1377
+ // No compression
1378
+ hnsw: { enabled: true, M: 48, efConstruction: 400 },
1379
+ // Highest quality
1380
+ gnn: { enabled: true, numHeads: 8 },
1381
+ // More attention heads
1382
+ mmr: { enabled: true, lambda: 0.8 },
1383
+ // More diversity
1384
+ svd: { enabled: false }
1385
+ // No dimension loss
1386
+ };
1387
+ var VERSION = {
1388
+ major: 2,
1389
+ minor: 0,
1390
+ patch: 0,
1391
+ prerelease: "alpha.2",
1392
+ features: "advanced",
1393
+ full: "2.0.0-alpha.2+advanced"
1394
+ };
1395
+ function estimateMemoryUsage(numVectors, dimension, config) {
1396
+ var _a, _b, _c;
1397
+ let vectorBytes = numVectors * dimension * 4;
1398
+ if ((_a = config.pq) == null ? void 0 : _a.enabled) {
1399
+ const subvectors = config.pq.subvectors || 8;
1400
+ vectorBytes = numVectors * (subvectors + 4);
1401
+ }
1402
+ if ((_b = config.svd) == null ? void 0 : _b.enabled) {
1403
+ const targetDim = config.svd.targetDim || dimension / 2;
1404
+ vectorBytes = numVectors * targetDim * 4;
1405
+ }
1406
+ let indexBytes = 0;
1407
+ if ((_c = config.hnsw) == null ? void 0 : _c.enabled) {
1408
+ const M = config.hnsw.M || 16;
1409
+ const avgConnections = M * 1.5;
1410
+ indexBytes = numVectors * avgConnections * 4;
1411
+ }
1412
+ const total = vectorBytes + indexBytes;
1413
+ return {
1414
+ vectors: vectorBytes,
1415
+ index: indexBytes,
1416
+ total,
1417
+ totalMB: total / (1024 * 1024)
1418
+ };
1419
+ }
1420
+ function recommendConfig(numVectors, dimension) {
1421
+ if (numVectors < 1e3) {
1422
+ return {
1423
+ name: "SMALL_DATASET",
1424
+ config: SMALL_DATASET_CONFIG,
1425
+ reason: "Small dataset, linear search is fast enough"
1426
+ };
1427
+ } else if (numVectors < 1e4) {
1428
+ return {
1429
+ name: "MEDIUM_DATASET",
1430
+ config: MEDIUM_DATASET_CONFIG,
1431
+ reason: "Medium dataset, HNSW + PQ8 recommended"
1432
+ };
1433
+ } else {
1434
+ return {
1435
+ name: "LARGE_DATASET",
1436
+ config: LARGE_DATASET_CONFIG,
1437
+ reason: "Large dataset, aggressive compression + HNSW recommended"
1438
+ };
1439
+ }
1440
+ }
1441
+ async function benchmarkSearch(searchFn, numQueries = 100, k = 10, dimension = 384) {
1442
+ const times = [];
1443
+ for (let i = 0; i < numQueries; i++) {
1444
+ const query = new Float32Array(dimension);
1445
+ for (let d = 0; d < dimension; d++) {
1446
+ query[d] = Math.random() - 0.5;
1447
+ }
1448
+ const start = performance.now();
1449
+ searchFn(query, k);
1450
+ const end = performance.now();
1451
+ times.push(end - start);
1452
+ }
1453
+ times.sort((a, b) => a - b);
1454
+ return {
1455
+ avgTimeMs: times.reduce((a, b) => a + b, 0) / times.length,
1456
+ minTimeMs: times[0],
1457
+ maxTimeMs: times[times.length - 1],
1458
+ p50Ms: times[Math.floor(times.length * 0.5)],
1459
+ p95Ms: times[Math.floor(times.length * 0.95)],
1460
+ p99Ms: times[Math.floor(times.length * 0.99)]
1461
+ };
1462
+ }
1463
+ export {
1464
+ AttentionBrowser,
1465
+ BatchProcessor,
1466
+ GraphNeuralNetwork,
1467
+ HNSWIndex,
1468
+ LARGE_DATASET_CONFIG,
1469
+ MEDIUM_DATASET_CONFIG,
1470
+ MEMORY_OPTIMIZED_CONFIG,
1471
+ MaximalMarginalRelevance,
1472
+ ProductQuantization,
1473
+ QUALITY_OPTIMIZED_CONFIG,
1474
+ SMALL_DATASET_CONFIG,
1475
+ SPEED_OPTIMIZED_CONFIG,
1476
+ TensorCompression,
1477
+ VERSION,
1478
+ benchmarkSearch,
1479
+ createAccurateAttention,
1480
+ createAccurateHNSW,
1481
+ createAttention,
1482
+ createFastAttention,
1483
+ createFastHNSW,
1484
+ createHNSW,
1485
+ createPQ16,
1486
+ createPQ32,
1487
+ createPQ8,
1488
+ detectFeatures,
1489
+ estimateMemoryUsage,
1490
+ recommendConfig
1491
+ };
1492
+ //# sourceMappingURL=agentdb.browser.js.map