@ninebix/nmt-system 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (639) hide show
  1. package/LICENSE +70 -0
  2. package/README.md +465 -0
  3. package/dist/api/cli-server.d.ts +83 -0
  4. package/dist/api/cli-server.d.ts.map +1 -0
  5. package/dist/api/cli-server.js +597 -0
  6. package/dist/api/cli-server.js.map +1 -0
  7. package/dist/api/index.d.ts +6 -0
  8. package/dist/api/index.d.ts.map +1 -0
  9. package/dist/api/index.js +6 -0
  10. package/dist/api/index.js.map +1 -0
  11. package/dist/api/middleware/index.d.ts +12 -0
  12. package/dist/api/middleware/index.d.ts.map +1 -0
  13. package/dist/api/middleware/index.js +13 -0
  14. package/dist/api/middleware/index.js.map +1 -0
  15. package/dist/api/middleware/logger.d.ts +21 -0
  16. package/dist/api/middleware/logger.d.ts.map +1 -0
  17. package/dist/api/middleware/logger.js +134 -0
  18. package/dist/api/middleware/logger.js.map +1 -0
  19. package/dist/api/middleware/rate-limit.d.ts +26 -0
  20. package/dist/api/middleware/rate-limit.d.ts.map +1 -0
  21. package/dist/api/middleware/rate-limit.js +107 -0
  22. package/dist/api/middleware/rate-limit.js.map +1 -0
  23. package/dist/api/middleware/response.d.ts +61 -0
  24. package/dist/api/middleware/response.d.ts.map +1 -0
  25. package/dist/api/middleware/response.js +86 -0
  26. package/dist/api/middleware/response.js.map +1 -0
  27. package/dist/api/middleware/validation.d.ts +43 -0
  28. package/dist/api/middleware/validation.d.ts.map +1 -0
  29. package/dist/api/middleware/validation.js +257 -0
  30. package/dist/api/middleware/validation.js.map +1 -0
  31. package/dist/api/server.d.ts +79 -0
  32. package/dist/api/server.d.ts.map +1 -0
  33. package/dist/api/server.js +2011 -0
  34. package/dist/api/server.js.map +1 -0
  35. package/dist/bin/nmt.d.ts +9 -0
  36. package/dist/bin/nmt.d.ts.map +1 -0
  37. package/dist/bin/nmt.js +1142 -0
  38. package/dist/bin/nmt.js.map +1 -0
  39. package/dist/cli/commands/attractor.d.ts +6 -0
  40. package/dist/cli/commands/attractor.d.ts.map +1 -0
  41. package/dist/cli/commands/attractor.js +167 -0
  42. package/dist/cli/commands/attractor.js.map +1 -0
  43. package/dist/cli/commands/dimension.d.ts +6 -0
  44. package/dist/cli/commands/dimension.d.ts.map +1 -0
  45. package/dist/cli/commands/dimension.js +85 -0
  46. package/dist/cli/commands/dimension.js.map +1 -0
  47. package/dist/cli/commands/index.d.ts +11 -0
  48. package/dist/cli/commands/index.d.ts.map +1 -0
  49. package/dist/cli/commands/index.js +11 -0
  50. package/dist/cli/commands/index.js.map +1 -0
  51. package/dist/cli/commands/infer.d.ts +6 -0
  52. package/dist/cli/commands/infer.d.ts.map +1 -0
  53. package/dist/cli/commands/infer.js +139 -0
  54. package/dist/cli/commands/infer.js.map +1 -0
  55. package/dist/cli/commands/learn.d.ts +6 -0
  56. package/dist/cli/commands/learn.d.ts.map +1 -0
  57. package/dist/cli/commands/learn.js +87 -0
  58. package/dist/cli/commands/learn.js.map +1 -0
  59. package/dist/cli/commands/orchestrate.d.ts +6 -0
  60. package/dist/cli/commands/orchestrate.d.ts.map +1 -0
  61. package/dist/cli/commands/orchestrate.js +279 -0
  62. package/dist/cli/commands/orchestrate.js.map +1 -0
  63. package/dist/cli/commands/prob.d.ts +6 -0
  64. package/dist/cli/commands/prob.d.ts.map +1 -0
  65. package/dist/cli/commands/prob.js +256 -0
  66. package/dist/cli/commands/prob.js.map +1 -0
  67. package/dist/cli/commands/quantum.d.ts +6 -0
  68. package/dist/cli/commands/quantum.d.ts.map +1 -0
  69. package/dist/cli/commands/quantum.js +150 -0
  70. package/dist/cli/commands/quantum.js.map +1 -0
  71. package/dist/cli/commands/sync.d.ts +65 -0
  72. package/dist/cli/commands/sync.d.ts.map +1 -0
  73. package/dist/cli/commands/sync.js +338 -0
  74. package/dist/cli/commands/sync.js.map +1 -0
  75. package/dist/cli/index.d.ts +9 -0
  76. package/dist/cli/index.d.ts.map +1 -0
  77. package/dist/cli/index.js +9 -0
  78. package/dist/cli/index.js.map +1 -0
  79. package/dist/cli/probabilistic-commands.d.ts +39 -0
  80. package/dist/cli/probabilistic-commands.d.ts.map +1 -0
  81. package/dist/cli/probabilistic-commands.js +112 -0
  82. package/dist/cli/probabilistic-commands.js.map +1 -0
  83. package/dist/cli/types.d.ts +69 -0
  84. package/dist/cli/types.d.ts.map +1 -0
  85. package/dist/cli/types.js +5 -0
  86. package/dist/cli/types.js.map +1 -0
  87. package/dist/cli/utils/formatters.d.ts +51 -0
  88. package/dist/cli/utils/formatters.d.ts.map +1 -0
  89. package/dist/cli/utils/formatters.js +79 -0
  90. package/dist/cli/utils/formatters.js.map +1 -0
  91. package/dist/cli/utils/helpers.d.ts +21 -0
  92. package/dist/cli/utils/helpers.d.ts.map +1 -0
  93. package/dist/cli/utils/helpers.js +51 -0
  94. package/dist/cli/utils/helpers.js.map +1 -0
  95. package/dist/cli/utils/index.d.ts +7 -0
  96. package/dist/cli/utils/index.d.ts.map +1 -0
  97. package/dist/cli/utils/index.js +13 -0
  98. package/dist/cli/utils/index.js.map +1 -0
  99. package/dist/cli/utils/validators.d.ts +162 -0
  100. package/dist/cli/utils/validators.d.ts.map +1 -0
  101. package/dist/cli/utils/validators.js +351 -0
  102. package/dist/cli/utils/validators.js.map +1 -0
  103. package/dist/core/advanced-embedding.d.ts +154 -0
  104. package/dist/core/advanced-embedding.d.ts.map +1 -0
  105. package/dist/core/advanced-embedding.js +367 -0
  106. package/dist/core/advanced-embedding.js.map +1 -0
  107. package/dist/core/attractor-model.d.ts +381 -0
  108. package/dist/core/attractor-model.d.ts.map +1 -0
  109. package/dist/core/attractor-model.js +821 -0
  110. package/dist/core/attractor-model.js.map +1 -0
  111. package/dist/core/bidirectional-inference.d.ts +143 -0
  112. package/dist/core/bidirectional-inference.d.ts.map +1 -0
  113. package/dist/core/bidirectional-inference.js +501 -0
  114. package/dist/core/bidirectional-inference.js.map +1 -0
  115. package/dist/core/chunk-engine.d.ts +78 -0
  116. package/dist/core/chunk-engine.d.ts.map +1 -0
  117. package/dist/core/chunk-engine.js +192 -0
  118. package/dist/core/chunk-engine.js.map +1 -0
  119. package/dist/core/dynamic-embedding.d.ts +327 -0
  120. package/dist/core/dynamic-embedding.d.ts.map +1 -0
  121. package/dist/core/dynamic-embedding.js +527 -0
  122. package/dist/core/dynamic-embedding.js.map +1 -0
  123. package/dist/core/embedding-similarity.d.ts +68 -0
  124. package/dist/core/embedding-similarity.d.ts.map +1 -0
  125. package/dist/core/embedding-similarity.js +291 -0
  126. package/dist/core/embedding-similarity.js.map +1 -0
  127. package/dist/core/evolution-scheduler.d.ts +101 -0
  128. package/dist/core/evolution-scheduler.d.ts.map +1 -0
  129. package/dist/core/evolution-scheduler.js +235 -0
  130. package/dist/core/evolution-scheduler.js.map +1 -0
  131. package/dist/core/hierarchical-chunker.d.ts +108 -0
  132. package/dist/core/hierarchical-chunker.d.ts.map +1 -0
  133. package/dist/core/hierarchical-chunker.js +296 -0
  134. package/dist/core/hierarchical-chunker.js.map +1 -0
  135. package/dist/core/hnsw-index.d.ts +111 -0
  136. package/dist/core/hnsw-index.d.ts.map +1 -0
  137. package/dist/core/hnsw-index.js +466 -0
  138. package/dist/core/hnsw-index.js.map +1 -0
  139. package/dist/core/index.d.ts +23 -0
  140. package/dist/core/index.d.ts.map +1 -0
  141. package/dist/core/index.js +25 -0
  142. package/dist/core/index.js.map +1 -0
  143. package/dist/core/language-analyzers.d.ts +124 -0
  144. package/dist/core/language-analyzers.d.ts.map +1 -0
  145. package/dist/core/language-analyzers.js +365 -0
  146. package/dist/core/language-analyzers.js.map +1 -0
  147. package/dist/core/local-embedding.d.ts +109 -0
  148. package/dist/core/local-embedding.d.ts.map +1 -0
  149. package/dist/core/local-embedding.js +222 -0
  150. package/dist/core/local-embedding.js.map +1 -0
  151. package/dist/core/merkle-engine.d.ts +263 -0
  152. package/dist/core/merkle-engine.d.ts.map +1 -0
  153. package/dist/core/merkle-engine.js +528 -0
  154. package/dist/core/merkle-engine.js.map +1 -0
  155. package/dist/core/multi-layer-reasoning.d.ts +178 -0
  156. package/dist/core/multi-layer-reasoning.d.ts.map +1 -0
  157. package/dist/core/multi-layer-reasoning.js +607 -0
  158. package/dist/core/multi-layer-reasoning.js.map +1 -0
  159. package/dist/core/neuron-graph.d.ts +134 -0
  160. package/dist/core/neuron-graph.d.ts.map +1 -0
  161. package/dist/core/neuron-graph.js +436 -0
  162. package/dist/core/neuron-graph.js.map +1 -0
  163. package/dist/core/probabilistic-neuron.d.ts +251 -0
  164. package/dist/core/probabilistic-neuron.d.ts.map +1 -0
  165. package/dist/core/probabilistic-neuron.js +618 -0
  166. package/dist/core/probabilistic-neuron.js.map +1 -0
  167. package/dist/core/probabilistic-orchestrator.d.ts +408 -0
  168. package/dist/core/probabilistic-orchestrator.d.ts.map +1 -0
  169. package/dist/core/probabilistic-orchestrator.js +798 -0
  170. package/dist/core/probabilistic-orchestrator.js.map +1 -0
  171. package/dist/core/semantic-chunker.d.ts +117 -0
  172. package/dist/core/semantic-chunker.d.ts.map +1 -0
  173. package/dist/core/semantic-chunker.js +464 -0
  174. package/dist/core/semantic-chunker.js.map +1 -0
  175. package/dist/events/event-bus.d.ts +166 -0
  176. package/dist/events/event-bus.d.ts.map +1 -0
  177. package/dist/events/event-bus.js +228 -0
  178. package/dist/events/event-bus.js.map +1 -0
  179. package/dist/events/index.d.ts +7 -0
  180. package/dist/events/index.d.ts.map +1 -0
  181. package/dist/events/index.js +7 -0
  182. package/dist/events/index.js.map +1 -0
  183. package/dist/events/progress-tracker.d.ts +150 -0
  184. package/dist/events/progress-tracker.d.ts.map +1 -0
  185. package/dist/events/progress-tracker.js +290 -0
  186. package/dist/events/progress-tracker.js.map +1 -0
  187. package/dist/extensions/clustering/community-detection.d.ts +90 -0
  188. package/dist/extensions/clustering/community-detection.d.ts.map +1 -0
  189. package/dist/extensions/clustering/community-detection.js +470 -0
  190. package/dist/extensions/clustering/community-detection.js.map +1 -0
  191. package/dist/extensions/clustering/index.d.ts +114 -0
  192. package/dist/extensions/clustering/index.d.ts.map +1 -0
  193. package/dist/extensions/clustering/index.js +468 -0
  194. package/dist/extensions/clustering/index.js.map +1 -0
  195. package/dist/extensions/clustering/topic-modeling.d.ts +86 -0
  196. package/dist/extensions/clustering/topic-modeling.d.ts.map +1 -0
  197. package/dist/extensions/clustering/topic-modeling.js +355 -0
  198. package/dist/extensions/clustering/topic-modeling.js.map +1 -0
  199. package/dist/extensions/distributed/coordinator.d.ts +114 -0
  200. package/dist/extensions/distributed/coordinator.d.ts.map +1 -0
  201. package/dist/extensions/distributed/coordinator.js +319 -0
  202. package/dist/extensions/distributed/coordinator.js.map +1 -0
  203. package/dist/extensions/distributed/index.d.ts +10 -0
  204. package/dist/extensions/distributed/index.d.ts.map +1 -0
  205. package/dist/extensions/distributed/index.js +10 -0
  206. package/dist/extensions/distributed/index.js.map +1 -0
  207. package/dist/extensions/distributed/queue.d.ts +157 -0
  208. package/dist/extensions/distributed/queue.d.ts.map +1 -0
  209. package/dist/extensions/distributed/queue.js +326 -0
  210. package/dist/extensions/distributed/queue.js.map +1 -0
  211. package/dist/extensions/distributed/scheduler.d.ts +107 -0
  212. package/dist/extensions/distributed/scheduler.d.ts.map +1 -0
  213. package/dist/extensions/distributed/scheduler.js +301 -0
  214. package/dist/extensions/distributed/scheduler.js.map +1 -0
  215. package/dist/extensions/distributed/worker.d.ts +112 -0
  216. package/dist/extensions/distributed/worker.d.ts.map +1 -0
  217. package/dist/extensions/distributed/worker.js +260 -0
  218. package/dist/extensions/distributed/worker.js.map +1 -0
  219. package/dist/index.d.ts +14 -0
  220. package/dist/index.d.ts.map +1 -0
  221. package/dist/index.js +20 -0
  222. package/dist/index.js.map +1 -0
  223. package/dist/mcp/server.d.ts +43 -0
  224. package/dist/mcp/server.d.ts.map +1 -0
  225. package/dist/mcp/server.js +494 -0
  226. package/dist/mcp/server.js.map +1 -0
  227. package/dist/services/adaptive-fallback.d.ts +140 -0
  228. package/dist/services/adaptive-fallback.d.ts.map +1 -0
  229. package/dist/services/adaptive-fallback.js +273 -0
  230. package/dist/services/adaptive-fallback.js.map +1 -0
  231. package/dist/services/answer-gate.d.ts +112 -0
  232. package/dist/services/answer-gate.d.ts.map +1 -0
  233. package/dist/services/answer-gate.js +299 -0
  234. package/dist/services/answer-gate.js.map +1 -0
  235. package/dist/services/auto-learning.d.ts +135 -0
  236. package/dist/services/auto-learning.d.ts.map +1 -0
  237. package/dist/services/auto-learning.js +413 -0
  238. package/dist/services/auto-learning.js.map +1 -0
  239. package/dist/services/context-compressor.d.ts +77 -0
  240. package/dist/services/context-compressor.d.ts.map +1 -0
  241. package/dist/services/context-compressor.js +234 -0
  242. package/dist/services/context-compressor.js.map +1 -0
  243. package/dist/services/efficient-rag.d.ts +140 -0
  244. package/dist/services/efficient-rag.d.ts.map +1 -0
  245. package/dist/services/efficient-rag.js +311 -0
  246. package/dist/services/efficient-rag.js.map +1 -0
  247. package/dist/services/embedding-provider.d.ts +72 -0
  248. package/dist/services/embedding-provider.d.ts.map +1 -0
  249. package/dist/services/embedding-provider.js +176 -0
  250. package/dist/services/embedding-provider.js.map +1 -0
  251. package/dist/services/file-ingestion.d.ts +72 -0
  252. package/dist/services/file-ingestion.d.ts.map +1 -0
  253. package/dist/services/file-ingestion.js +237 -0
  254. package/dist/services/file-ingestion.js.map +1 -0
  255. package/dist/services/four-stage-learning.d.ts +552 -0
  256. package/dist/services/four-stage-learning.d.ts.map +1 -0
  257. package/dist/services/four-stage-learning.js +1110 -0
  258. package/dist/services/four-stage-learning.js.map +1 -0
  259. package/dist/services/graph.d.ts +94 -0
  260. package/dist/services/graph.d.ts.map +1 -0
  261. package/dist/services/graph.js +292 -0
  262. package/dist/services/graph.js.map +1 -0
  263. package/dist/services/index.d.ts +15 -0
  264. package/dist/services/index.d.ts.map +1 -0
  265. package/dist/services/index.js +18 -0
  266. package/dist/services/index.js.map +1 -0
  267. package/dist/services/ingestion.d.ts +98 -0
  268. package/dist/services/ingestion.d.ts.map +1 -0
  269. package/dist/services/ingestion.js +259 -0
  270. package/dist/services/ingestion.js.map +1 -0
  271. package/dist/services/learning.d.ts +67 -0
  272. package/dist/services/learning.d.ts.map +1 -0
  273. package/dist/services/learning.js +262 -0
  274. package/dist/services/learning.js.map +1 -0
  275. package/dist/services/llm-router.d.ts +143 -0
  276. package/dist/services/llm-router.d.ts.map +1 -0
  277. package/dist/services/llm-router.js +284 -0
  278. package/dist/services/llm-router.js.map +1 -0
  279. package/dist/services/llm.d.ts +86 -0
  280. package/dist/services/llm.d.ts.map +1 -0
  281. package/dist/services/llm.js +283 -0
  282. package/dist/services/llm.js.map +1 -0
  283. package/dist/services/metrics-dashboard.d.ts +262 -0
  284. package/dist/services/metrics-dashboard.d.ts.map +1 -0
  285. package/dist/services/metrics-dashboard.js +417 -0
  286. package/dist/services/metrics-dashboard.js.map +1 -0
  287. package/dist/services/neuron-lifecycle.d.ts +137 -0
  288. package/dist/services/neuron-lifecycle.d.ts.map +1 -0
  289. package/dist/services/neuron-lifecycle.js +422 -0
  290. package/dist/services/neuron-lifecycle.js.map +1 -0
  291. package/dist/services/nmt-pipeline.d.ts +219 -0
  292. package/dist/services/nmt-pipeline.d.ts.map +1 -0
  293. package/dist/services/nmt-pipeline.js +449 -0
  294. package/dist/services/nmt-pipeline.js.map +1 -0
  295. package/dist/services/query-cache.d.ts +136 -0
  296. package/dist/services/query-cache.d.ts.map +1 -0
  297. package/dist/services/query-cache.js +255 -0
  298. package/dist/services/query-cache.js.map +1 -0
  299. package/dist/services/query-normalize.d.ts +107 -0
  300. package/dist/services/query-normalize.d.ts.map +1 -0
  301. package/dist/services/query-normalize.js +366 -0
  302. package/dist/services/query-normalize.js.map +1 -0
  303. package/dist/services/query.d.ts +102 -0
  304. package/dist/services/query.d.ts.map +1 -0
  305. package/dist/services/query.js +227 -0
  306. package/dist/services/query.js.map +1 -0
  307. package/dist/services/text-embedding.d.ts +183 -0
  308. package/dist/services/text-embedding.d.ts.map +1 -0
  309. package/dist/services/text-embedding.js +633 -0
  310. package/dist/services/text-embedding.js.map +1 -0
  311. package/dist/services/verification-gate.d.ts +147 -0
  312. package/dist/services/verification-gate.d.ts.map +1 -0
  313. package/dist/services/verification-gate.js +344 -0
  314. package/dist/services/verification-gate.js.map +1 -0
  315. package/dist/services/verify.d.ts +114 -0
  316. package/dist/services/verify.d.ts.map +1 -0
  317. package/dist/services/verify.js +237 -0
  318. package/dist/services/verify.js.map +1 -0
  319. package/dist/services/web-search.d.ts +145 -0
  320. package/dist/services/web-search.d.ts.map +1 -0
  321. package/dist/services/web-search.js +534 -0
  322. package/dist/services/web-search.js.map +1 -0
  323. package/dist/src/api/cli-server.d.ts +83 -0
  324. package/dist/src/api/cli-server.d.ts.map +1 -0
  325. package/dist/src/api/cli-server.js +597 -0
  326. package/dist/src/api/cli-server.js.map +1 -0
  327. package/dist/src/api/index.d.ts +6 -0
  328. package/dist/src/api/index.d.ts.map +1 -0
  329. package/dist/src/api/index.js +6 -0
  330. package/dist/src/api/index.js.map +1 -0
  331. package/dist/src/cli/commands/attractor.d.ts +6 -0
  332. package/dist/src/cli/commands/attractor.d.ts.map +1 -0
  333. package/dist/src/cli/commands/attractor.js +167 -0
  334. package/dist/src/cli/commands/attractor.js.map +1 -0
  335. package/dist/src/cli/commands/dimension.d.ts +6 -0
  336. package/dist/src/cli/commands/dimension.d.ts.map +1 -0
  337. package/dist/src/cli/commands/dimension.js +85 -0
  338. package/dist/src/cli/commands/dimension.js.map +1 -0
  339. package/dist/src/cli/commands/index.d.ts +11 -0
  340. package/dist/src/cli/commands/index.d.ts.map +1 -0
  341. package/dist/src/cli/commands/index.js +11 -0
  342. package/dist/src/cli/commands/index.js.map +1 -0
  343. package/dist/src/cli/commands/infer.d.ts +6 -0
  344. package/dist/src/cli/commands/infer.d.ts.map +1 -0
  345. package/dist/src/cli/commands/infer.js +139 -0
  346. package/dist/src/cli/commands/infer.js.map +1 -0
  347. package/dist/src/cli/commands/learn.d.ts +6 -0
  348. package/dist/src/cli/commands/learn.d.ts.map +1 -0
  349. package/dist/src/cli/commands/learn.js +87 -0
  350. package/dist/src/cli/commands/learn.js.map +1 -0
  351. package/dist/src/cli/commands/orchestrate.d.ts +6 -0
  352. package/dist/src/cli/commands/orchestrate.d.ts.map +1 -0
  353. package/dist/src/cli/commands/orchestrate.js +279 -0
  354. package/dist/src/cli/commands/orchestrate.js.map +1 -0
  355. package/dist/src/cli/commands/prob.d.ts +6 -0
  356. package/dist/src/cli/commands/prob.d.ts.map +1 -0
  357. package/dist/src/cli/commands/prob.js +256 -0
  358. package/dist/src/cli/commands/prob.js.map +1 -0
  359. package/dist/src/cli/commands/sync.d.ts +65 -0
  360. package/dist/src/cli/commands/sync.d.ts.map +1 -0
  361. package/dist/src/cli/commands/sync.js +338 -0
  362. package/dist/src/cli/commands/sync.js.map +1 -0
  363. package/dist/src/cli/index.d.ts +9 -0
  364. package/dist/src/cli/index.d.ts.map +1 -0
  365. package/dist/src/cli/index.js +9 -0
  366. package/dist/src/cli/index.js.map +1 -0
  367. package/dist/src/cli/probabilistic-commands.d.ts +39 -0
  368. package/dist/src/cli/probabilistic-commands.d.ts.map +1 -0
  369. package/dist/src/cli/probabilistic-commands.js +112 -0
  370. package/dist/src/cli/probabilistic-commands.js.map +1 -0
  371. package/dist/src/cli/types.d.ts +69 -0
  372. package/dist/src/cli/types.d.ts.map +1 -0
  373. package/dist/src/cli/types.js +5 -0
  374. package/dist/src/cli/types.js.map +1 -0
  375. package/dist/src/cli/utils/formatters.d.ts +51 -0
  376. package/dist/src/cli/utils/formatters.d.ts.map +1 -0
  377. package/dist/src/cli/utils/formatters.js +79 -0
  378. package/dist/src/cli/utils/formatters.js.map +1 -0
  379. package/dist/src/cli/utils/helpers.d.ts +21 -0
  380. package/dist/src/cli/utils/helpers.d.ts.map +1 -0
  381. package/dist/src/cli/utils/helpers.js +51 -0
  382. package/dist/src/cli/utils/helpers.js.map +1 -0
  383. package/dist/src/cli/utils/index.d.ts +7 -0
  384. package/dist/src/cli/utils/index.d.ts.map +1 -0
  385. package/dist/src/cli/utils/index.js +13 -0
  386. package/dist/src/cli/utils/index.js.map +1 -0
  387. package/dist/src/cli/utils/validators.d.ts +162 -0
  388. package/dist/src/cli/utils/validators.d.ts.map +1 -0
  389. package/dist/src/cli/utils/validators.js +351 -0
  390. package/dist/src/cli/utils/validators.js.map +1 -0
  391. package/dist/src/core/attractor-model.d.ts +381 -0
  392. package/dist/src/core/attractor-model.d.ts.map +1 -0
  393. package/dist/src/core/attractor-model.js +821 -0
  394. package/dist/src/core/attractor-model.js.map +1 -0
  395. package/dist/src/core/bidirectional-inference.d.ts +143 -0
  396. package/dist/src/core/bidirectional-inference.d.ts.map +1 -0
  397. package/dist/src/core/bidirectional-inference.js +501 -0
  398. package/dist/src/core/bidirectional-inference.js.map +1 -0
  399. package/dist/src/core/chunk-engine.d.ts +78 -0
  400. package/dist/src/core/chunk-engine.d.ts.map +1 -0
  401. package/dist/src/core/chunk-engine.js +192 -0
  402. package/dist/src/core/chunk-engine.js.map +1 -0
  403. package/dist/src/core/dynamic-embedding.d.ts +327 -0
  404. package/dist/src/core/dynamic-embedding.d.ts.map +1 -0
  405. package/dist/src/core/dynamic-embedding.js +527 -0
  406. package/dist/src/core/dynamic-embedding.js.map +1 -0
  407. package/dist/src/core/evolution-scheduler.d.ts +101 -0
  408. package/dist/src/core/evolution-scheduler.d.ts.map +1 -0
  409. package/dist/src/core/evolution-scheduler.js +235 -0
  410. package/dist/src/core/evolution-scheduler.js.map +1 -0
  411. package/dist/src/core/hnsw-index.d.ts +111 -0
  412. package/dist/src/core/hnsw-index.d.ts.map +1 -0
  413. package/dist/src/core/hnsw-index.js +466 -0
  414. package/dist/src/core/hnsw-index.js.map +1 -0
  415. package/dist/src/core/index.d.ts +23 -0
  416. package/dist/src/core/index.d.ts.map +1 -0
  417. package/dist/src/core/index.js +25 -0
  418. package/dist/src/core/index.js.map +1 -0
  419. package/dist/src/core/merkle-engine.d.ts +263 -0
  420. package/dist/src/core/merkle-engine.d.ts.map +1 -0
  421. package/dist/src/core/merkle-engine.js +528 -0
  422. package/dist/src/core/merkle-engine.js.map +1 -0
  423. package/dist/src/core/neuron-graph.d.ts +134 -0
  424. package/dist/src/core/neuron-graph.d.ts.map +1 -0
  425. package/dist/src/core/neuron-graph.js +436 -0
  426. package/dist/src/core/neuron-graph.js.map +1 -0
  427. package/dist/src/core/probabilistic-neuron.d.ts +251 -0
  428. package/dist/src/core/probabilistic-neuron.d.ts.map +1 -0
  429. package/dist/src/core/probabilistic-neuron.js +618 -0
  430. package/dist/src/core/probabilistic-neuron.js.map +1 -0
  431. package/dist/src/core/probabilistic-orchestrator.d.ts +408 -0
  432. package/dist/src/core/probabilistic-orchestrator.d.ts.map +1 -0
  433. package/dist/src/core/probabilistic-orchestrator.js +798 -0
  434. package/dist/src/core/probabilistic-orchestrator.js.map +1 -0
  435. package/dist/src/events/event-bus.d.ts +166 -0
  436. package/dist/src/events/event-bus.d.ts.map +1 -0
  437. package/dist/src/events/event-bus.js +228 -0
  438. package/dist/src/events/event-bus.js.map +1 -0
  439. package/dist/src/events/index.d.ts +7 -0
  440. package/dist/src/events/index.d.ts.map +1 -0
  441. package/dist/src/events/index.js +7 -0
  442. package/dist/src/events/index.js.map +1 -0
  443. package/dist/src/events/progress-tracker.d.ts +150 -0
  444. package/dist/src/events/progress-tracker.d.ts.map +1 -0
  445. package/dist/src/events/progress-tracker.js +290 -0
  446. package/dist/src/events/progress-tracker.js.map +1 -0
  447. package/dist/src/extensions/clustering/index.d.ts +114 -0
  448. package/dist/src/extensions/clustering/index.d.ts.map +1 -0
  449. package/dist/src/extensions/clustering/index.js +468 -0
  450. package/dist/src/extensions/clustering/index.js.map +1 -0
  451. package/dist/src/index.d.ts +14 -0
  452. package/dist/src/index.d.ts.map +1 -0
  453. package/dist/src/index.js +20 -0
  454. package/dist/src/index.js.map +1 -0
  455. package/dist/src/mcp/server.d.ts +43 -0
  456. package/dist/src/mcp/server.d.ts.map +1 -0
  457. package/dist/src/mcp/server.js +494 -0
  458. package/dist/src/mcp/server.js.map +1 -0
  459. package/dist/src/services/embedding-provider.d.ts +72 -0
  460. package/dist/src/services/embedding-provider.d.ts.map +1 -0
  461. package/dist/src/services/embedding-provider.js +176 -0
  462. package/dist/src/services/embedding-provider.js.map +1 -0
  463. package/dist/src/services/four-stage-learning.d.ts +552 -0
  464. package/dist/src/services/four-stage-learning.d.ts.map +1 -0
  465. package/dist/src/services/four-stage-learning.js +1110 -0
  466. package/dist/src/services/four-stage-learning.js.map +1 -0
  467. package/dist/src/services/index.d.ts +15 -0
  468. package/dist/src/services/index.d.ts.map +1 -0
  469. package/dist/src/services/index.js +18 -0
  470. package/dist/src/services/index.js.map +1 -0
  471. package/dist/src/services/ingestion.d.ts +98 -0
  472. package/dist/src/services/ingestion.d.ts.map +1 -0
  473. package/dist/src/services/ingestion.js +259 -0
  474. package/dist/src/services/ingestion.js.map +1 -0
  475. package/dist/src/services/query.d.ts +102 -0
  476. package/dist/src/services/query.d.ts.map +1 -0
  477. package/dist/src/services/query.js +227 -0
  478. package/dist/src/services/query.js.map +1 -0
  479. package/dist/src/services/text-embedding.d.ts +183 -0
  480. package/dist/src/services/text-embedding.d.ts.map +1 -0
  481. package/dist/src/services/text-embedding.js +633 -0
  482. package/dist/src/services/text-embedding.js.map +1 -0
  483. package/dist/src/services/verify.d.ts +114 -0
  484. package/dist/src/services/verify.d.ts.map +1 -0
  485. package/dist/src/services/verify.js +237 -0
  486. package/dist/src/services/verify.js.map +1 -0
  487. package/dist/src/storage/chunk-store.d.ts +107 -0
  488. package/dist/src/storage/chunk-store.d.ts.map +1 -0
  489. package/dist/src/storage/chunk-store.js +293 -0
  490. package/dist/src/storage/chunk-store.js.map +1 -0
  491. package/dist/src/storage/index-store.d.ts +126 -0
  492. package/dist/src/storage/index-store.d.ts.map +1 -0
  493. package/dist/src/storage/index-store.js +316 -0
  494. package/dist/src/storage/index-store.js.map +1 -0
  495. package/dist/src/storage/index.d.ts +45 -0
  496. package/dist/src/storage/index.d.ts.map +1 -0
  497. package/dist/src/storage/index.js +52 -0
  498. package/dist/src/storage/index.js.map +1 -0
  499. package/dist/src/storage/neuron-store.d.ts +121 -0
  500. package/dist/src/storage/neuron-store.d.ts.map +1 -0
  501. package/dist/src/storage/neuron-store.js +466 -0
  502. package/dist/src/storage/neuron-store.js.map +1 -0
  503. package/dist/src/storage/probabilistic-store.d.ts +104 -0
  504. package/dist/src/storage/probabilistic-store.d.ts.map +1 -0
  505. package/dist/src/storage/probabilistic-store.js +257 -0
  506. package/dist/src/storage/probabilistic-store.js.map +1 -0
  507. package/dist/src/sync/change-journal.d.ts +171 -0
  508. package/dist/src/sync/change-journal.d.ts.map +1 -0
  509. package/dist/src/sync/change-journal.js +362 -0
  510. package/dist/src/sync/change-journal.js.map +1 -0
  511. package/dist/src/sync/index.d.ts +8 -0
  512. package/dist/src/sync/index.d.ts.map +1 -0
  513. package/dist/src/sync/index.js +8 -0
  514. package/dist/src/sync/index.js.map +1 -0
  515. package/dist/src/sync/state-sync.d.ts +241 -0
  516. package/dist/src/sync/state-sync.d.ts.map +1 -0
  517. package/dist/src/sync/state-sync.js +396 -0
  518. package/dist/src/sync/state-sync.js.map +1 -0
  519. package/dist/src/sync/vector-clock.d.ts +144 -0
  520. package/dist/src/sync/vector-clock.d.ts.map +1 -0
  521. package/dist/src/sync/vector-clock.js +266 -0
  522. package/dist/src/sync/vector-clock.js.map +1 -0
  523. package/dist/src/types/index.d.ts +224 -0
  524. package/dist/src/types/index.d.ts.map +1 -0
  525. package/dist/src/types/index.js +24 -0
  526. package/dist/src/types/index.js.map +1 -0
  527. package/dist/src/utils/hash.d.ts +39 -0
  528. package/dist/src/utils/hash.d.ts.map +1 -0
  529. package/dist/src/utils/hash.js +56 -0
  530. package/dist/src/utils/hash.js.map +1 -0
  531. package/dist/src/utils/index.d.ts +26 -0
  532. package/dist/src/utils/index.d.ts.map +1 -0
  533. package/dist/src/utils/index.js +50 -0
  534. package/dist/src/utils/index.js.map +1 -0
  535. package/dist/src/utils/logger.d.ts +88 -0
  536. package/dist/src/utils/logger.d.ts.map +1 -0
  537. package/dist/src/utils/logger.js +157 -0
  538. package/dist/src/utils/logger.js.map +1 -0
  539. package/dist/src/utils/metrics.d.ts +232 -0
  540. package/dist/src/utils/metrics.d.ts.map +1 -0
  541. package/dist/src/utils/metrics.js +387 -0
  542. package/dist/src/utils/metrics.js.map +1 -0
  543. package/dist/src/utils/similarity.d.ts +64 -0
  544. package/dist/src/utils/similarity.d.ts.map +1 -0
  545. package/dist/src/utils/similarity.js +151 -0
  546. package/dist/src/utils/similarity.js.map +1 -0
  547. package/dist/src/utils/uuid.d.ts +23 -0
  548. package/dist/src/utils/uuid.d.ts.map +1 -0
  549. package/dist/src/utils/uuid.js +29 -0
  550. package/dist/src/utils/uuid.js.map +1 -0
  551. package/dist/storage/chunk-store.d.ts +107 -0
  552. package/dist/storage/chunk-store.d.ts.map +1 -0
  553. package/dist/storage/chunk-store.js +293 -0
  554. package/dist/storage/chunk-store.js.map +1 -0
  555. package/dist/storage/hybrid-adapters.d.ts +111 -0
  556. package/dist/storage/hybrid-adapters.d.ts.map +1 -0
  557. package/dist/storage/hybrid-adapters.js +223 -0
  558. package/dist/storage/hybrid-adapters.js.map +1 -0
  559. package/dist/storage/hybrid-store.d.ts +125 -0
  560. package/dist/storage/hybrid-store.d.ts.map +1 -0
  561. package/dist/storage/hybrid-store.js +655 -0
  562. package/dist/storage/hybrid-store.js.map +1 -0
  563. package/dist/storage/index-store.d.ts +126 -0
  564. package/dist/storage/index-store.d.ts.map +1 -0
  565. package/dist/storage/index-store.js +316 -0
  566. package/dist/storage/index-store.js.map +1 -0
  567. package/dist/storage/index.d.ts +45 -0
  568. package/dist/storage/index.d.ts.map +1 -0
  569. package/dist/storage/index.js +52 -0
  570. package/dist/storage/index.js.map +1 -0
  571. package/dist/storage/neuron-store.d.ts +121 -0
  572. package/dist/storage/neuron-store.d.ts.map +1 -0
  573. package/dist/storage/neuron-store.js +466 -0
  574. package/dist/storage/neuron-store.js.map +1 -0
  575. package/dist/storage/ontology-store.d.ts +132 -0
  576. package/dist/storage/ontology-store.d.ts.map +1 -0
  577. package/dist/storage/ontology-store.js +319 -0
  578. package/dist/storage/ontology-store.js.map +1 -0
  579. package/dist/storage/probabilistic-store.d.ts +104 -0
  580. package/dist/storage/probabilistic-store.d.ts.map +1 -0
  581. package/dist/storage/probabilistic-store.js +257 -0
  582. package/dist/storage/probabilistic-store.js.map +1 -0
  583. package/dist/storage/redis-adapters.d.ts +102 -0
  584. package/dist/storage/redis-adapters.d.ts.map +1 -0
  585. package/dist/storage/redis-adapters.js +205 -0
  586. package/dist/storage/redis-adapters.js.map +1 -0
  587. package/dist/storage/redis-ontology-store.d.ts +146 -0
  588. package/dist/storage/redis-ontology-store.d.ts.map +1 -0
  589. package/dist/storage/redis-ontology-store.js +384 -0
  590. package/dist/storage/redis-ontology-store.js.map +1 -0
  591. package/dist/storage/redis-store.d.ts +174 -0
  592. package/dist/storage/redis-store.d.ts.map +1 -0
  593. package/dist/storage/redis-store.js +506 -0
  594. package/dist/storage/redis-store.js.map +1 -0
  595. package/dist/sync/change-journal.d.ts +171 -0
  596. package/dist/sync/change-journal.d.ts.map +1 -0
  597. package/dist/sync/change-journal.js +362 -0
  598. package/dist/sync/change-journal.js.map +1 -0
  599. package/dist/sync/index.d.ts +8 -0
  600. package/dist/sync/index.d.ts.map +1 -0
  601. package/dist/sync/index.js +8 -0
  602. package/dist/sync/index.js.map +1 -0
  603. package/dist/sync/state-sync.d.ts +241 -0
  604. package/dist/sync/state-sync.d.ts.map +1 -0
  605. package/dist/sync/state-sync.js +396 -0
  606. package/dist/sync/state-sync.js.map +1 -0
  607. package/dist/sync/vector-clock.d.ts +144 -0
  608. package/dist/sync/vector-clock.d.ts.map +1 -0
  609. package/dist/sync/vector-clock.js +266 -0
  610. package/dist/sync/vector-clock.js.map +1 -0
  611. package/dist/types/index.d.ts +224 -0
  612. package/dist/types/index.d.ts.map +1 -0
  613. package/dist/types/index.js +24 -0
  614. package/dist/types/index.js.map +1 -0
  615. package/dist/utils/hash.d.ts +39 -0
  616. package/dist/utils/hash.d.ts.map +1 -0
  617. package/dist/utils/hash.js +56 -0
  618. package/dist/utils/hash.js.map +1 -0
  619. package/dist/utils/index.d.ts +26 -0
  620. package/dist/utils/index.d.ts.map +1 -0
  621. package/dist/utils/index.js +50 -0
  622. package/dist/utils/index.js.map +1 -0
  623. package/dist/utils/logger.d.ts +88 -0
  624. package/dist/utils/logger.d.ts.map +1 -0
  625. package/dist/utils/logger.js +157 -0
  626. package/dist/utils/logger.js.map +1 -0
  627. package/dist/utils/metrics.d.ts +232 -0
  628. package/dist/utils/metrics.d.ts.map +1 -0
  629. package/dist/utils/metrics.js +387 -0
  630. package/dist/utils/metrics.js.map +1 -0
  631. package/dist/utils/similarity.d.ts +64 -0
  632. package/dist/utils/similarity.d.ts.map +1 -0
  633. package/dist/utils/similarity.js +151 -0
  634. package/dist/utils/similarity.js.map +1 -0
  635. package/dist/utils/uuid.d.ts +23 -0
  636. package/dist/utils/uuid.d.ts.map +1 -0
  637. package/dist/utils/uuid.js +29 -0
  638. package/dist/utils/uuid.js.map +1 -0
  639. package/package.json +72 -0
@@ -0,0 +1,821 @@
1
+ /**
2
+ * Future Attractor Model - Goal-Driven Probability Steering
3
+ *
4
+ * Based on Probabilistic Ontology Framework - Teleological Determinism:
5
+ * - Future states act as "attractors" that influence present choices
6
+ * - Current state probabilities are shaped by potential futures
7
+ * - Goals create probability gradients that guide decision paths
8
+ *
9
+ * @module core/attractor-model
10
+ */
11
+ import { cosineSimilarity } from '../utils/similarity.js';
12
+ /**
13
+ * Priority Queue for A* algorithm
14
+ */
15
+ class PriorityQueue {
16
+ items = [];
17
+ enqueue(item) {
18
+ this.items.push(item);
19
+ this.bubbleUp(this.items.length - 1);
20
+ }
21
+ dequeue() {
22
+ if (this.items.length === 0)
23
+ return undefined;
24
+ if (this.items.length === 1)
25
+ return this.items.pop();
26
+ const result = this.items[0];
27
+ this.items[0] = this.items.pop();
28
+ this.bubbleDown(0);
29
+ return result;
30
+ }
31
+ isEmpty() {
32
+ return this.items.length === 0;
33
+ }
34
+ has(predicate) {
35
+ return this.items.some(predicate);
36
+ }
37
+ update(predicate, newItem) {
38
+ const index = this.items.findIndex(predicate);
39
+ if (index >= 0) {
40
+ this.items[index] = newItem;
41
+ this.bubbleUp(index);
42
+ this.bubbleDown(index);
43
+ }
44
+ }
45
+ bubbleUp(index) {
46
+ while (index > 0) {
47
+ const parentIndex = Math.floor((index - 1) / 2);
48
+ if (this.items[parentIndex].f <= this.items[index].f)
49
+ break;
50
+ [this.items[parentIndex], this.items[index]] = [this.items[index], this.items[parentIndex]];
51
+ index = parentIndex;
52
+ }
53
+ }
54
+ bubbleDown(index) {
55
+ while (true) {
56
+ const left = 2 * index + 1;
57
+ const right = 2 * index + 2;
58
+ let smallest = index;
59
+ if (left < this.items.length && this.items[left].f < this.items[smallest].f) {
60
+ smallest = left;
61
+ }
62
+ if (right < this.items.length && this.items[right].f < this.items[smallest].f) {
63
+ smallest = right;
64
+ }
65
+ if (smallest === index)
66
+ break;
67
+ [this.items[index], this.items[smallest]] = [this.items[smallest], this.items[index]];
68
+ index = smallest;
69
+ }
70
+ }
71
+ }
72
+ /**
73
+ * Attractor Model - Goal-Driven Probability Steering
74
+ *
75
+ * Implements teleological determinism where future goals (attractors)
76
+ * influence present state probabilities through probability fields.
77
+ *
78
+ * Key Concepts:
79
+ * - **Attractors**: Future goal states that "pull" the system towards them
80
+ * - **Probability Fields**: Gradients that guide state transitions
81
+ * - **Influence**: How strongly an attractor affects current decisions
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const model = new AttractorModel({ neuronStore: store });
86
+ *
87
+ * // Create a goal attractor
88
+ * const attractor = model.createAttractor(
89
+ * 'goal-1',
90
+ * 'Complete Project',
91
+ * 'Finish all remaining tasks',
92
+ * goalEmbedding,
93
+ * { strength: 0.8, priority: 10 }
94
+ * );
95
+ *
96
+ * // Calculate influence on current state
97
+ * const influence = model.calculateInfluence(currentStateEmbedding);
98
+ * console.log(`Goal influence: ${influence.get('goal-1')}`);
99
+ *
100
+ * // Find path to goal
101
+ * const path = await model.findPathToAttractor('current-neuron', 'goal-1');
102
+ * console.log(`Path probability: ${path?.probability}`);
103
+ * ```
104
+ *
105
+ * @see {@link Attractor} for attractor state structure
106
+ * @see {@link ProbabilityField} for field configuration
107
+ */
108
+ export class AttractorModel {
109
+ store;
110
+ maxAttractors;
111
+ defaultStrength;
112
+ decayRate;
113
+ influenceRadius;
114
+ // A* algorithm options
115
+ heuristicWeight;
116
+ maxSearchNodes;
117
+ // Attractor storage
118
+ attractors = new Map();
119
+ // Probability fields
120
+ fields = new Map();
121
+ // State history
122
+ stateHistory = [];
123
+ transitions = [];
124
+ // Current dominant attractor
125
+ dominantAttractor = null;
126
+ // Caching for A* heuristics
127
+ embeddingCache = new Map();
128
+ constructor(options) {
129
+ this.store = options.neuronStore;
130
+ this.maxAttractors = options.maxAttractors ?? 100;
131
+ this.defaultStrength = options.defaultStrength ?? 0.5;
132
+ this.decayRate = options.decayRate ?? 0.95;
133
+ this.influenceRadius = options.influenceRadius ?? 0.7;
134
+ this.heuristicWeight = options.heuristicWeight ?? 1.0;
135
+ this.maxSearchNodes = options.maxSearchNodes ?? 1000;
136
+ }
137
+ /**
138
+ * Create a new attractor (future goal state).
139
+ *
140
+ * Attractors represent desired future states that influence present
141
+ * probability distributions. The strength and priority determine how
142
+ * much pull the attractor has on state transitions.
143
+ *
144
+ * @param id - Unique identifier for the attractor
145
+ * @param name - Human-readable name for the goal
146
+ * @param description - Detailed description of the goal state
147
+ * @param embedding - Semantic embedding representing the goal
148
+ * @param options - Configuration options
149
+ * @param options.strength - Pull strength (0-1), default: 0.5
150
+ * @param options.probability - Initial probability of reaching (0-1), default: 0.5
151
+ * @param options.priority - User-defined priority (1-10), default: 5
152
+ * @param options.deadline - Optional ISO8601 deadline
153
+ * @param options.prerequisites - IDs of required states before this
154
+ * @returns The created Attractor object
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * const attractor = model.createAttractor(
159
+ * 'learn-typescript',
160
+ * 'Master TypeScript',
161
+ * 'Become proficient in TypeScript development',
162
+ * tsEmbedding,
163
+ * { strength: 0.9, priority: 8, deadline: '2024-12-31' }
164
+ * );
165
+ * ```
166
+ */
167
+ createAttractor(id, name, description, embedding, options = {}) {
168
+ if (this.attractors.size >= this.maxAttractors) {
169
+ // Remove least activated attractor
170
+ this.pruneWeakestAttractor();
171
+ }
172
+ const attractor = {
173
+ id,
174
+ name,
175
+ description,
176
+ embedding,
177
+ strength: options.strength ?? this.defaultStrength,
178
+ probability: options.probability ?? 0.5,
179
+ priority: options.priority ?? 5,
180
+ deadline: options.deadline,
181
+ prerequisites: options.prerequisites ?? [],
182
+ createdAt: new Date().toISOString(),
183
+ updatedAt: new Date().toISOString(),
184
+ activations: 0
185
+ };
186
+ this.attractors.set(id, attractor);
187
+ this.updateProbabilityField(attractor);
188
+ return attractor;
189
+ }
190
+ /**
191
+ * Get attractor by ID
192
+ */
193
+ getAttractor(id) {
194
+ return this.attractors.get(id);
195
+ }
196
+ /**
197
+ * Update attractor properties
198
+ */
199
+ updateAttractor(id, updates) {
200
+ const attractor = this.attractors.get(id);
201
+ if (!attractor)
202
+ return null;
203
+ Object.assign(attractor, updates, { updatedAt: new Date().toISOString() });
204
+ this.updateProbabilityField(attractor);
205
+ return attractor;
206
+ }
207
+ /**
208
+ * Calculate influence of all attractors on a given state.
209
+ *
210
+ * Influence is calculated using exponential decay based on semantic
211
+ * distance, multiplied by attractor strength and priority.
212
+ *
213
+ * @param stateEmbedding - The current state's embedding vector
214
+ * @returns Map of attractor IDs to their influence values (0-1)
215
+ *
216
+ * @example
217
+ * ```typescript
218
+ * const influences = model.calculateInfluence(currentEmbedding);
219
+ * for (const [attractorId, influence] of influences) {
220
+ * if (influence > 0.5) {
221
+ * console.log(`Strong pull from ${attractorId}: ${influence}`);
222
+ * }
223
+ * }
224
+ * ```
225
+ */
226
+ calculateInfluence(stateEmbedding) {
227
+ const influences = new Map();
228
+ for (const [id, attractor] of this.attractors) {
229
+ const similarity = cosineSimilarity(stateEmbedding, attractor.embedding);
230
+ // Influence decreases with distance but increases with strength
231
+ const distance = 1 - similarity;
232
+ const influence = attractor.strength * Math.exp(-distance / this.influenceRadius);
233
+ // Apply priority multiplier
234
+ const priorityMultiplier = attractor.priority / 10;
235
+ influences.set(id, influence * priorityMultiplier);
236
+ }
237
+ return influences;
238
+ }
239
+ /**
240
+ * Get the dominant attractor for a state
241
+ */
242
+ getDominantAttractor(stateEmbedding) {
243
+ const influences = this.calculateInfluence(stateEmbedding);
244
+ let maxInfluence = 0;
245
+ let dominant = null;
246
+ for (const [id, influence] of influences) {
247
+ if (influence > maxInfluence) {
248
+ maxInfluence = influence;
249
+ dominant = this.attractors.get(id) ?? null;
250
+ }
251
+ }
252
+ return dominant;
253
+ }
254
+ /**
255
+ * Calculate transition probabilities from current state
256
+ */
257
+ async calculateTransitionProbabilities(currentNeuronId, candidateIds) {
258
+ const current = await this.store.getNeuron(currentNeuronId);
259
+ if (!current)
260
+ return new Map();
261
+ const probabilities = new Map();
262
+ const currentInfluences = this.calculateInfluence(current.embedding);
263
+ for (const candidateId of candidateIds) {
264
+ const candidate = await this.store.getNeuron(candidateId);
265
+ if (!candidate)
266
+ continue;
267
+ // Base probability from semantic similarity
268
+ const baseSimilarity = cosineSimilarity(current.embedding, candidate.embedding);
269
+ // Attractor boost: how much better is candidate for reaching attractors?
270
+ let attractorBoost = 0;
271
+ const candidateInfluences = this.calculateInfluence(candidate.embedding);
272
+ for (const [attractorId, currentInf] of currentInfluences) {
273
+ const candidateInf = candidateInfluences.get(attractorId) ?? 0;
274
+ // Positive if candidate is closer to attractor
275
+ attractorBoost += (candidateInf - currentInf);
276
+ }
277
+ // Normalize attractor boost
278
+ attractorBoost = Math.tanh(attractorBoost);
279
+ // Combined probability
280
+ const probability = baseSimilarity * 0.4 + (0.5 + attractorBoost * 0.5) * 0.6;
281
+ probabilities.set(candidateId, Math.max(0, Math.min(1, probability)));
282
+ }
283
+ // Normalize probabilities
284
+ const total = Array.from(probabilities.values()).reduce((a, b) => a + b, 0);
285
+ if (total > 0) {
286
+ for (const [id, prob] of probabilities) {
287
+ probabilities.set(id, prob / total);
288
+ }
289
+ }
290
+ return probabilities;
291
+ }
292
+ /**
293
+ * Find optimal path from current state to an attractor using A* algorithm.
294
+ *
295
+ * A* guarantees the optimal path by combining:
296
+ * - g(n): Actual cost from start to node n
297
+ * - h(n): Heuristic estimate from n to goal (semantic distance)
298
+ * - f(n) = g(n) + h(n): Total estimated cost
299
+ *
300
+ * The heuristic uses semantic distance (1 - cosine similarity) which is
301
+ * admissible (never overestimates) for semantic spaces.
302
+ *
303
+ * @param currentNeuronId - Starting neuron ID
304
+ * @param attractorId - Target attractor ID
305
+ * @param maxDepth - Maximum search depth, default: 10
306
+ * @returns Path information including probability and bottlenecks, or null if not found
307
+ *
308
+ * @example
309
+ * ```typescript
310
+ * const result = await model.findPathToAttractor('start', 'goal', 10);
311
+ * if (result.found) {
312
+ * console.log(`Optimal path: ${result.path.join(' → ')}`);
313
+ * console.log(`Path probability: ${(result.pathProbability * 100).toFixed(1)}%`);
314
+ * console.log(`Nodes explored: ${result.nodesExplored}`);
315
+ * for (const bottleneck of result.bottlenecks) {
316
+ * console.log(`Bottleneck: ${bottleneck.nodeId} (cost: ${bottleneck.costContribution})`);
317
+ * }
318
+ * }
319
+ * ```
320
+ */
321
+ async findPathToAttractor(currentNeuronId, attractorId, maxDepth = 10) {
322
+ const attractor = this.attractors.get(attractorId);
323
+ if (!attractor)
324
+ return null;
325
+ const result = await this.aStarSearch(currentNeuronId, attractor, maxDepth);
326
+ if (!result.found)
327
+ return null;
328
+ return {
329
+ path: result.path,
330
+ probability: result.pathProbability,
331
+ estimatedSteps: result.path.length - 1,
332
+ bottlenecks: result.bottlenecks.map(b => b.nodeId)
333
+ };
334
+ }
335
+ /**
336
+ * A* Search Algorithm Implementation
337
+ *
338
+ * Uses:
339
+ * - g(n) = sum of edge costs (1 - synapse.weight) from start
340
+ * - h(n) = semantic distance (1 - cosine_similarity) to goal
341
+ * - f(n) = g(n) + w * h(n) where w is heuristicWeight
342
+ *
343
+ * @param startId - Starting neuron ID
344
+ * @param goal - Target attractor
345
+ * @param maxDepth - Maximum path length
346
+ * @returns A* search result with path, cost, and bottlenecks
347
+ */
348
+ async aStarSearch(startId, goal, maxDepth = 10) {
349
+ // Initialize result
350
+ const result = {
351
+ found: false,
352
+ path: [],
353
+ totalCost: Infinity,
354
+ nodesExplored: 0,
355
+ pathProbability: 0,
356
+ bottlenecks: []
357
+ };
358
+ // Get start node
359
+ const startNode = await this.store.getNeuron(startId);
360
+ if (!startNode)
361
+ return result;
362
+ // Cache start embedding
363
+ this.embeddingCache.set(startId, startNode.embedding);
364
+ // Calculate initial heuristic
365
+ const startH = this.calculateHeuristic(startNode.embedding, goal.embedding);
366
+ // Check if already at goal
367
+ if (startH < 0.1) {
368
+ result.found = true;
369
+ result.path = [startId];
370
+ result.totalCost = 0;
371
+ result.pathProbability = 1;
372
+ return result;
373
+ }
374
+ // Initialize open set (priority queue)
375
+ const openSet = new PriorityQueue();
376
+ openSet.enqueue({
377
+ id: startId,
378
+ parent: null,
379
+ g: 0,
380
+ h: startH,
381
+ f: this.heuristicWeight * startH
382
+ });
383
+ // Initialize closed set
384
+ const closedSet = new Set();
385
+ // Track best g values
386
+ const gScores = new Map();
387
+ gScores.set(startId, 0);
388
+ // Track parent pointers for path reconstruction
389
+ const cameFrom = new Map();
390
+ // Track edge costs for bottleneck analysis
391
+ const edgeCosts = new Map();
392
+ // Main A* loop
393
+ while (!openSet.isEmpty() && result.nodesExplored < this.maxSearchNodes) {
394
+ const current = openSet.dequeue();
395
+ result.nodesExplored++;
396
+ // Skip if already processed
397
+ if (closedSet.has(current.id))
398
+ continue;
399
+ // Get current node embedding
400
+ let currentEmbedding = this.embeddingCache.get(current.id);
401
+ if (!currentEmbedding) {
402
+ const node = await this.store.getNeuron(current.id);
403
+ if (!node)
404
+ continue;
405
+ currentEmbedding = node.embedding;
406
+ this.embeddingCache.set(current.id, currentEmbedding);
407
+ }
408
+ // Check if goal reached (similarity > 0.9)
409
+ const similarity = cosineSimilarity(currentEmbedding, goal.embedding);
410
+ if (similarity > 0.9) {
411
+ result.found = true;
412
+ result.totalCost = current.g;
413
+ result.path = this.reconstructPath(current.id, cameFrom);
414
+ result.pathProbability = this.calculatePathProbability(result.path, edgeCosts);
415
+ result.bottlenecks = this.identifyAStarBottlenecks(result.path, edgeCosts);
416
+ return result;
417
+ }
418
+ // Add to closed set
419
+ closedSet.add(current.id);
420
+ // Check depth limit
421
+ const depth = this.reconstructPath(current.id, cameFrom).length - 1;
422
+ if (depth >= maxDepth)
423
+ continue;
424
+ // Expand neighbors
425
+ const outgoing = await this.store.getOutgoingSynapses(current.id);
426
+ for (const synapse of outgoing) {
427
+ if (closedSet.has(synapse.targetId))
428
+ continue;
429
+ // Get neighbor embedding
430
+ let neighborEmbedding = this.embeddingCache.get(synapse.targetId);
431
+ if (!neighborEmbedding) {
432
+ const neighborNode = await this.store.getNeuron(synapse.targetId);
433
+ if (!neighborNode)
434
+ continue;
435
+ neighborEmbedding = neighborNode.embedding;
436
+ this.embeddingCache.set(synapse.targetId, neighborEmbedding);
437
+ }
438
+ // Calculate edge cost (lower weight = higher cost)
439
+ // Cost = 1 - weight, so strong connections are cheap
440
+ const edgeCost = 1 - synapse.weight;
441
+ // Factor in attractor pull (moving towards attractor reduces cost)
442
+ const currentToGoal = 1 - cosineSimilarity(currentEmbedding, goal.embedding);
443
+ const neighborToGoal = 1 - cosineSimilarity(neighborEmbedding, goal.embedding);
444
+ const attractorBonus = Math.max(0, currentToGoal - neighborToGoal) * 0.5;
445
+ const adjustedCost = Math.max(0.01, edgeCost - attractorBonus);
446
+ // Calculate tentative g score
447
+ const tentativeG = current.g + adjustedCost;
448
+ // Check if this path is better
449
+ const existingG = gScores.get(synapse.targetId) ?? Infinity;
450
+ if (tentativeG < existingG) {
451
+ // Record this path
452
+ cameFrom.set(synapse.targetId, current.id);
453
+ gScores.set(synapse.targetId, tentativeG);
454
+ edgeCosts.set(`${current.id}:${synapse.targetId}`, adjustedCost);
455
+ // Calculate heuristic
456
+ const h = this.calculateHeuristic(neighborEmbedding, goal.embedding);
457
+ const f = tentativeG + this.heuristicWeight * h;
458
+ // Add to open set
459
+ openSet.enqueue({
460
+ id: synapse.targetId,
461
+ parent: current.id,
462
+ g: tentativeG,
463
+ h,
464
+ f
465
+ });
466
+ }
467
+ }
468
+ }
469
+ return result;
470
+ }
471
+ /**
472
+ * Calculate heuristic for A* (semantic distance to goal)
473
+ *
474
+ * Uses 1 - cosine_similarity as distance metric.
475
+ * This heuristic is admissible for semantic spaces.
476
+ */
477
+ calculateHeuristic(embedding, goalEmbedding) {
478
+ const similarity = cosineSimilarity(embedding, goalEmbedding);
479
+ // Distance = 1 - similarity, bounded [0, 2] for cosine
480
+ return 1 - similarity;
481
+ }
482
+ /**
483
+ * Reconstruct path from A* search
484
+ */
485
+ reconstructPath(goalId, cameFrom) {
486
+ const path = [goalId];
487
+ let current = goalId;
488
+ while (cameFrom.has(current)) {
489
+ current = cameFrom.get(current);
490
+ path.unshift(current);
491
+ }
492
+ return path;
493
+ }
494
+ /**
495
+ * Calculate path probability (product of edge weights)
496
+ */
497
+ calculatePathProbability(path, edgeCosts) {
498
+ if (path.length < 2)
499
+ return 1;
500
+ let probability = 1;
501
+ for (let i = 0; i < path.length - 1; i++) {
502
+ const edgeKey = `${path[i]}:${path[i + 1]}`;
503
+ const cost = edgeCosts.get(edgeKey) ?? 0.5;
504
+ // Convert cost back to probability-like value
505
+ // cost = 1 - weight, so weight = 1 - cost
506
+ probability *= (1 - cost);
507
+ }
508
+ return probability;
509
+ }
510
+ /**
511
+ * Identify bottlenecks from A* search (high-cost edges)
512
+ */
513
+ identifyAStarBottlenecks(path, edgeCosts) {
514
+ const bottlenecks = [];
515
+ // Calculate average edge cost
516
+ let totalCost = 0;
517
+ let edgeCount = 0;
518
+ for (let i = 0; i < path.length - 1; i++) {
519
+ const edgeKey = `${path[i]}:${path[i + 1]}`;
520
+ const cost = edgeCosts.get(edgeKey) ?? 0;
521
+ totalCost += cost;
522
+ edgeCount++;
523
+ }
524
+ const avgCost = edgeCount > 0 ? totalCost / edgeCount : 0;
525
+ // Bottlenecks are edges with above-average cost
526
+ for (let i = 0; i < path.length - 1; i++) {
527
+ const edgeKey = `${path[i]}:${path[i + 1]}`;
528
+ const cost = edgeCosts.get(edgeKey) ?? 0;
529
+ if (cost > avgCost * 1.5) {
530
+ bottlenecks.push({
531
+ nodeId: path[i + 1],
532
+ costContribution: cost
533
+ });
534
+ }
535
+ }
536
+ // Sort by cost contribution (highest first)
537
+ bottlenecks.sort((a, b) => b.costContribution - a.costContribution);
538
+ return bottlenecks;
539
+ }
540
+ /**
541
+ * Find multiple alternative paths to attractor
542
+ *
543
+ * Uses A* with path exclusion to find k-best paths
544
+ */
545
+ async findAlternativePaths(currentNeuronId, attractorId, k = 3, maxDepth = 10) {
546
+ const attractor = this.attractors.get(attractorId);
547
+ if (!attractor)
548
+ return [];
549
+ const results = [];
550
+ const usedPaths = new Set();
551
+ for (let i = 0; i < k; i++) {
552
+ const result = await this.aStarSearchWithExclusion(currentNeuronId, attractor, maxDepth, usedPaths);
553
+ if (!result.found)
554
+ break;
555
+ results.push(result);
556
+ usedPaths.add(result.path.join(':'));
557
+ }
558
+ return results;
559
+ }
560
+ /**
561
+ * A* search with path exclusion for k-best paths
562
+ */
563
+ async aStarSearchWithExclusion(startId, goal, maxDepth, excludedPaths) {
564
+ // Similar to aStarSearch but with path exclusion
565
+ const result = await this.aStarSearch(startId, goal, maxDepth);
566
+ // If the found path is excluded, try again with penalty
567
+ if (result.found && excludedPaths.has(result.path.join(':'))) {
568
+ // Add penalty and retry - this is simplified
569
+ result.found = false;
570
+ }
571
+ return result;
572
+ }
573
+ /**
574
+ * Bidirectional A* search for faster pathfinding
575
+ *
576
+ * Searches from both start and goal simultaneously
577
+ */
578
+ async bidirectionalAStarSearch(startId, attractorId, maxDepth = 10) {
579
+ const attractor = this.attractors.get(attractorId);
580
+ if (!attractor) {
581
+ return { found: false, path: [], totalCost: Infinity, nodesExplored: 0, pathProbability: 0, bottlenecks: [] };
582
+ }
583
+ // For now, delegate to standard A* (full bidirectional needs goal node ID)
584
+ // In a full implementation, you'd need to identify goal nodes first
585
+ return this.aStarSearch(startId, attractor, maxDepth);
586
+ }
587
+ /**
588
+ * Clear embedding cache to free memory
589
+ */
590
+ clearCache() {
591
+ this.embeddingCache.clear();
592
+ }
593
+ /**
594
+ * Record a state transition between neurons.
595
+ *
596
+ * Tracks how state transitions are influenced by attractors,
597
+ * updating attractor activation counts when transitions move
598
+ * towards them.
599
+ *
600
+ * @param fromId - Source neuron ID
601
+ * @param toId - Target neuron ID
602
+ * @returns The recorded transition with attractor influences
603
+ * @throws Error if either neuron ID is invalid
604
+ */
605
+ async recordTransition(fromId, toId) {
606
+ const from = await this.store.getNeuron(fromId);
607
+ const to = await this.store.getNeuron(toId);
608
+ if (!from || !to) {
609
+ throw new Error('Invalid neuron IDs for transition');
610
+ }
611
+ // Calculate probability based on attractor influences
612
+ const fromInfluences = this.calculateInfluence(from.embedding);
613
+ const toInfluences = this.calculateInfluence(to.embedding);
614
+ let probability = cosineSimilarity(from.embedding, to.embedding);
615
+ // Track attractor contribution
616
+ const attractorInfluence = new Map();
617
+ for (const [attractorId, fromInf] of fromInfluences) {
618
+ const toInf = toInfluences.get(attractorId) ?? 0;
619
+ const contribution = toInf - fromInf;
620
+ attractorInfluence.set(attractorId, contribution);
621
+ // If moving towards an attractor, increase that attractor's activation
622
+ if (contribution > 0) {
623
+ const attractor = this.attractors.get(attractorId);
624
+ if (attractor) {
625
+ attractor.activations++;
626
+ }
627
+ }
628
+ }
629
+ const transition = {
630
+ from: fromId,
631
+ to: toId,
632
+ probability,
633
+ attractorInfluence,
634
+ timestamp: new Date().toISOString()
635
+ };
636
+ this.transitions.push(transition);
637
+ // Update state history
638
+ this.stateHistory.push({
639
+ neuronId: toId,
640
+ embedding: to.embedding,
641
+ timestamp: transition.timestamp,
642
+ activeAttractors: Array.from(attractorInfluence.keys()).filter(id => (attractorInfluence.get(id) ?? 0) > 0),
643
+ dominantAttractor: this.getDominantAttractor(to.embedding)?.id,
644
+ transitionProbabilities: new Map()
645
+ });
646
+ return transition;
647
+ }
648
+ /**
649
+ * Update attractor probabilities based on current state
650
+ */
651
+ async updateAttractorProbabilities(currentNeuronId) {
652
+ const current = await this.store.getNeuron(currentNeuronId);
653
+ if (!current)
654
+ return;
655
+ for (const [id, attractor] of this.attractors) {
656
+ const similarity = cosineSimilarity(current.embedding, attractor.embedding);
657
+ // Update probability with exponential smoothing
658
+ const newProb = 0.8 * attractor.probability + 0.2 * similarity;
659
+ attractor.probability = Math.max(0, Math.min(1, newProb));
660
+ attractor.updatedAt = new Date().toISOString();
661
+ }
662
+ }
663
+ /**
664
+ * Decay attractor strengths over time.
665
+ *
666
+ * Applies exponential decay to attractors that haven't been
667
+ * updated in 24+ hours. Very weak attractors with few activations
668
+ * are automatically removed.
669
+ *
670
+ * Call this periodically (e.g., hourly) to maintain attractor health.
671
+ */
672
+ decayAttractors() {
673
+ const now = Date.now();
674
+ for (const attractor of this.attractors.values()) {
675
+ const lastUpdated = new Date(attractor.updatedAt).getTime();
676
+ const hoursSinceUpdate = (now - lastUpdated) / (1000 * 60 * 60);
677
+ if (hoursSinceUpdate > 24) {
678
+ // Apply decay
679
+ attractor.strength *= this.decayRate;
680
+ // Remove very weak attractors
681
+ if (attractor.strength < 0.01 && attractor.activations < 5) {
682
+ this.attractors.delete(attractor.id);
683
+ this.fields.delete(attractor.id);
684
+ }
685
+ }
686
+ }
687
+ }
688
+ /**
689
+ * Get all active attractors
690
+ */
691
+ getActiveAttractors() {
692
+ return Array.from(this.attractors.values())
693
+ .filter(a => a.strength > 0.1)
694
+ .sort((a, b) => b.priority * b.strength - a.priority * a.strength);
695
+ }
696
+ /**
697
+ * Get statistics
698
+ */
699
+ getStats() {
700
+ let totalStrength = 0;
701
+ let totalActivations = 0;
702
+ let activeCount = 0;
703
+ for (const attractor of this.attractors.values()) {
704
+ totalStrength += attractor.strength;
705
+ totalActivations += attractor.activations;
706
+ if (attractor.strength > 0.1)
707
+ activeCount++;
708
+ }
709
+ return {
710
+ totalAttractors: this.attractors.size,
711
+ activeAttractors: activeCount,
712
+ transitions: this.transitions.length,
713
+ stateHistory: this.stateHistory.length,
714
+ averageStrength: this.attractors.size > 0 ? totalStrength / this.attractors.size : 0,
715
+ averageActivations: this.attractors.size > 0 ? totalActivations / this.attractors.size : 0
716
+ };
717
+ }
718
+ /**
719
+ * Serialize attractor model state for persistence.
720
+ *
721
+ * Converts all attractors, transitions, and state to a JSON-serializable
722
+ * object. Embeddings are converted to plain arrays.
723
+ *
724
+ * @returns Serialized state object for storage
725
+ * @see {@link load} for restoring state
726
+ */
727
+ serialize() {
728
+ return {
729
+ attractors: Array.from(this.attractors.entries()).map(([id, a]) => ({
730
+ ...a,
731
+ embedding: Array.from(a.embedding)
732
+ })),
733
+ transitions: this.transitions.slice(-1000), // Keep last 1000 transitions
734
+ dominantAttractor: this.dominantAttractor
735
+ };
736
+ }
737
+ /**
738
+ * Load attractor model from serialized data.
739
+ *
740
+ * Restores all attractors, transitions, and state from previously
741
+ * serialized data. Embeddings are converted back to Float32Array.
742
+ *
743
+ * @param data - Previously serialized attractor model state
744
+ * @see {@link serialize} for creating serialized state
745
+ */
746
+ load(data) {
747
+ this.attractors.clear();
748
+ for (const a of data.attractors ?? []) {
749
+ const attractor = {
750
+ ...a,
751
+ embedding: new Float32Array(a.embedding)
752
+ };
753
+ this.attractors.set(a.id, attractor);
754
+ this.updateProbabilityField(attractor);
755
+ }
756
+ this.transitions = data.transitions ?? [];
757
+ this.dominantAttractor = data.dominantAttractor ?? null;
758
+ }
759
+ // ==================== Private Methods ====================
760
+ updateProbabilityField(attractor) {
761
+ const field = {
762
+ attractor,
763
+ gradient: new Map(),
764
+ reachableStates: [],
765
+ pathProbabilities: []
766
+ };
767
+ this.fields.set(attractor.id, field);
768
+ }
769
+ pruneWeakestAttractor() {
770
+ let weakest = null;
771
+ let weakestScore = Infinity;
772
+ for (const attractor of this.attractors.values()) {
773
+ const score = attractor.strength * attractor.priority * (1 + attractor.activations / 100);
774
+ if (score < weakestScore) {
775
+ weakestScore = score;
776
+ weakest = attractor;
777
+ }
778
+ }
779
+ if (weakest) {
780
+ this.attractors.delete(weakest.id);
781
+ this.fields.delete(weakest.id);
782
+ }
783
+ }
784
+ /**
785
+ * Simple bottleneck identification for legacy compatibility
786
+ * @deprecated Use identifyAStarBottlenecks for accurate bottleneck detection
787
+ */
788
+ identifyBottlenecks(path) {
789
+ // Bottlenecks are nodes where probability drops significantly
790
+ // For now, return middle nodes as potential bottlenecks
791
+ if (path.length <= 2)
792
+ return [];
793
+ return path.slice(1, -1);
794
+ }
795
+ /**
796
+ * Get path cost breakdown
797
+ */
798
+ async analyzePathCost(path) {
799
+ const edgeCosts = [];
800
+ let totalCost = 0;
801
+ for (let i = 0; i < path.length - 1; i++) {
802
+ const synapses = await this.store.getOutgoingSynapses(path[i]);
803
+ const synapse = synapses.find(s => s.targetId === path[i + 1]);
804
+ const cost = synapse ? 1 - synapse.weight : 0.5;
805
+ edgeCosts.push({ from: path[i], to: path[i + 1], cost });
806
+ totalCost += cost;
807
+ }
808
+ return {
809
+ totalCost,
810
+ edgeCosts,
811
+ avgCost: edgeCosts.length > 0 ? totalCost / edgeCosts.length : 0
812
+ };
813
+ }
814
+ }
815
+ /**
816
+ * Create an AttractorModel instance
817
+ */
818
+ export function createAttractorModel(options) {
819
+ return new AttractorModel(options);
820
+ }
821
+ //# sourceMappingURL=attractor-model.js.map