@graphrefly/graphrefly 0.44.0 → 0.46.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 (720) hide show
  1. package/README.md +22 -19
  2. package/dist/_internal-B23BagFd.d.cts +33 -0
  3. package/dist/_internal-B23BagFd.d.ts +33 -0
  4. package/dist/adaptive-rate-limiter-Dch_xYIi.d.cts +111 -0
  5. package/dist/adaptive-rate-limiter-Dch_xYIi.d.ts +111 -0
  6. package/dist/agents-C0Ji9ldU.d.cts +629 -0
  7. package/dist/agents-C9zexT7I.d.ts +629 -0
  8. package/dist/audit-BAXb3VOg.d.ts +246 -0
  9. package/dist/audit-C_bPfkqS.d.cts +246 -0
  10. package/dist/backoff-7KIK3WQW.js +24 -0
  11. package/dist/backoff-7KIK3WQW.js.map +1 -0
  12. package/dist/backoff-Bnb9OoPh.d.cts +6 -0
  13. package/dist/backoff-Bnb9OoPh.d.ts +6 -0
  14. package/dist/base/composition/index.cjs +811 -0
  15. package/dist/base/composition/index.cjs.map +1 -0
  16. package/dist/base/composition/index.d.cts +469 -0
  17. package/dist/base/composition/index.d.ts +469 -0
  18. package/dist/base/composition/index.js +40 -0
  19. package/dist/base/composition/index.js.map +1 -0
  20. package/dist/base/index.cjs +6336 -0
  21. package/dist/base/index.cjs.map +1 -0
  22. package/dist/base/index.d.cts +22 -0
  23. package/dist/base/index.d.ts +22 -0
  24. package/dist/base/index.js +259 -0
  25. package/dist/base/index.js.map +1 -0
  26. package/dist/base/io/index.cjs +3270 -0
  27. package/dist/base/io/index.cjs.map +1 -0
  28. package/dist/base/io/index.d.cts +2245 -0
  29. package/dist/base/io/index.d.ts +2245 -0
  30. package/dist/base/io/index.js +117 -0
  31. package/dist/base/io/index.js.map +1 -0
  32. package/dist/base/meta/index.cjs +43 -0
  33. package/dist/base/meta/index.cjs.map +1 -0
  34. package/dist/base/meta/index.d.cts +45 -0
  35. package/dist/base/meta/index.d.ts +45 -0
  36. package/dist/base/meta/index.js +13 -0
  37. package/dist/base/meta/index.js.map +1 -0
  38. package/dist/base/mutation/index.cjs +200 -0
  39. package/dist/base/mutation/index.cjs.map +1 -0
  40. package/dist/base/mutation/index.d.cts +177 -0
  41. package/dist/base/mutation/index.d.ts +177 -0
  42. package/dist/base/mutation/index.js +22 -0
  43. package/dist/base/mutation/index.js.map +1 -0
  44. package/dist/base/render/index.cjs +1120 -0
  45. package/dist/base/render/index.cjs.map +1 -0
  46. package/dist/{extra/render/index.d.ts → base/render/index.d.cts} +75 -31
  47. package/dist/{extra/render/index.d.cts → base/render/index.d.ts} +75 -31
  48. package/dist/base/render/index.js +24 -0
  49. package/dist/base/render/index.js.map +1 -0
  50. package/dist/base/sources/browser/index.cjs +172 -0
  51. package/dist/base/sources/browser/index.cjs.map +1 -0
  52. package/dist/base/sources/browser/index.d.cts +84 -0
  53. package/dist/base/sources/browser/index.d.ts +84 -0
  54. package/dist/base/sources/browser/index.js +151 -0
  55. package/dist/base/sources/browser/index.js.map +1 -0
  56. package/dist/base/sources/event/index.cjs +98 -0
  57. package/dist/base/sources/event/index.cjs.map +1 -0
  58. package/dist/base/sources/event/index.d.cts +91 -0
  59. package/dist/base/sources/event/index.d.ts +91 -0
  60. package/dist/base/sources/event/index.js +13 -0
  61. package/dist/base/sources/event/index.js.map +1 -0
  62. package/dist/base/sources/index.cjs +755 -0
  63. package/dist/base/sources/index.cjs.map +1 -0
  64. package/dist/{extra/sources.d.ts → base/sources/index.d.cts} +74 -301
  65. package/dist/{extra/sources.d.cts → base/sources/index.d.ts} +74 -301
  66. package/dist/base/sources/index.js +42 -0
  67. package/dist/base/sources/index.js.map +1 -0
  68. package/dist/base/sources/node/index.cjs +320 -0
  69. package/dist/base/sources/node/index.cjs.map +1 -0
  70. package/dist/{extra/node.d.ts → base/sources/node/index.d.cts} +35 -37
  71. package/dist/{extra/node.d.cts → base/sources/node/index.d.ts} +35 -37
  72. package/dist/base/sources/node/index.js +306 -0
  73. package/dist/base/sources/node/index.js.map +1 -0
  74. package/dist/base/utils/index.cjs +37 -0
  75. package/dist/base/utils/index.cjs.map +1 -0
  76. package/dist/base/utils/index.d.cts +37 -0
  77. package/dist/base/utils/index.d.ts +37 -0
  78. package/dist/base/utils/index.js +11 -0
  79. package/dist/base/utils/index.js.map +1 -0
  80. package/dist/base/worker/index.cjs +548 -0
  81. package/dist/base/worker/index.cjs.map +1 -0
  82. package/dist/base/worker/index.d.cts +207 -0
  83. package/dist/base/worker/index.d.ts +207 -0
  84. package/dist/base/worker/index.js +20 -0
  85. package/dist/base/worker/index.js.map +1 -0
  86. package/dist/breaker-C9skL3d8.d.ts +175 -0
  87. package/dist/breaker-ugSdq54q.d.cts +175 -0
  88. package/dist/{cascading-BglDkMdX.d.cts → cascading-CSSbKGrJ.d.ts} +3 -3
  89. package/dist/{cascading-MFgxu7Yo.d.ts → cascading-baGkiihI.d.cts} +3 -3
  90. package/dist/chunk-255UCBG4.js +58 -0
  91. package/dist/chunk-255UCBG4.js.map +1 -0
  92. package/dist/chunk-2LO3EL4W.js +1 -0
  93. package/dist/chunk-2LO3EL4W.js.map +1 -0
  94. package/dist/chunk-2OB3CEJS.js +1065 -0
  95. package/dist/chunk-2OB3CEJS.js.map +1 -0
  96. package/dist/chunk-36NMM65U.js +144 -0
  97. package/dist/chunk-36NMM65U.js.map +1 -0
  98. package/dist/chunk-3CEXCBN6.js +1 -0
  99. package/dist/chunk-3CEXCBN6.js.map +1 -0
  100. package/dist/chunk-3MUSLI6E.js +105 -0
  101. package/dist/chunk-3MUSLI6E.js.map +1 -0
  102. package/dist/chunk-3PSLNJDU.js +884 -0
  103. package/dist/chunk-3PSLNJDU.js.map +1 -0
  104. package/dist/chunk-3QZY5BI7.js +92 -0
  105. package/dist/chunk-3QZY5BI7.js.map +1 -0
  106. package/dist/chunk-42FQ27MQ.js +594 -0
  107. package/dist/chunk-42FQ27MQ.js.map +1 -0
  108. package/dist/chunk-4GYMCUDZ.js +1085 -0
  109. package/dist/chunk-4GYMCUDZ.js.map +1 -0
  110. package/dist/chunk-4S53H2KR.js +382 -0
  111. package/dist/chunk-4S53H2KR.js.map +1 -0
  112. package/dist/chunk-4XCHZRUJ.js +128 -0
  113. package/dist/chunk-4XCHZRUJ.js.map +1 -0
  114. package/dist/chunk-5THCXDWY.js +725 -0
  115. package/dist/chunk-5THCXDWY.js.map +1 -0
  116. package/dist/chunk-6XZYT4SW.js +256 -0
  117. package/dist/chunk-6XZYT4SW.js.map +1 -0
  118. package/dist/chunk-7EGRP2VX.js +76 -0
  119. package/dist/chunk-7EGRP2VX.js.map +1 -0
  120. package/dist/chunk-A7KV5UK4.js +150 -0
  121. package/dist/chunk-A7KV5UK4.js.map +1 -0
  122. package/dist/chunk-APY2SS5X.js +156 -0
  123. package/dist/chunk-APY2SS5X.js.map +1 -0
  124. package/dist/chunk-AZDQPQ3V.js +66 -0
  125. package/dist/chunk-AZDQPQ3V.js.map +1 -0
  126. package/dist/chunk-BU3SEFA5.js +90 -0
  127. package/dist/chunk-BU3SEFA5.js.map +1 -0
  128. package/dist/chunk-BXGZFGZ4.js +189 -0
  129. package/dist/chunk-BXGZFGZ4.js.map +1 -0
  130. package/dist/chunk-CGHORL6G.js +579 -0
  131. package/dist/chunk-CGHORL6G.js.map +1 -0
  132. package/dist/chunk-CXANAIZU.js +530 -0
  133. package/dist/chunk-CXANAIZU.js.map +1 -0
  134. package/dist/chunk-CZQHCKKG.js +1 -0
  135. package/dist/chunk-CZQHCKKG.js.map +1 -0
  136. package/dist/chunk-DKNHAICT.js +133 -0
  137. package/dist/chunk-DKNHAICT.js.map +1 -0
  138. package/dist/chunk-DM4OMPWK.js +584 -0
  139. package/dist/chunk-DM4OMPWK.js.map +1 -0
  140. package/dist/chunk-DMSNO6ZB.js +452 -0
  141. package/dist/chunk-DMSNO6ZB.js.map +1 -0
  142. package/dist/chunk-E5OZPDIW.js +229 -0
  143. package/dist/chunk-E5OZPDIW.js.map +1 -0
  144. package/dist/chunk-EVYY4X5A.js +509 -0
  145. package/dist/chunk-EVYY4X5A.js.map +1 -0
  146. package/dist/chunk-FDFD67UO.js +1 -0
  147. package/dist/chunk-FDFD67UO.js.map +1 -0
  148. package/dist/chunk-FMPF42Q4.js +13 -0
  149. package/dist/chunk-FMPF42Q4.js.map +1 -0
  150. package/dist/chunk-FR6RGA3B.js +1277 -0
  151. package/dist/chunk-FR6RGA3B.js.map +1 -0
  152. package/dist/chunk-FW23JYNQ.js +454 -0
  153. package/dist/chunk-FW23JYNQ.js.map +1 -0
  154. package/dist/chunk-GBCENOLN.js +1575 -0
  155. package/dist/chunk-GBCENOLN.js.map +1 -0
  156. package/dist/chunk-HL7HUJIX.js +1 -0
  157. package/dist/chunk-HL7HUJIX.js.map +1 -0
  158. package/dist/chunk-HULCUY35.js +2508 -0
  159. package/dist/chunk-HULCUY35.js.map +1 -0
  160. package/dist/chunk-IHTWQEDR.js +169 -0
  161. package/dist/chunk-IHTWQEDR.js.map +1 -0
  162. package/dist/chunk-IJRR6YAI.js +128 -0
  163. package/dist/chunk-IJRR6YAI.js.map +1 -0
  164. package/dist/chunk-JGFRAFDL.js +221 -0
  165. package/dist/chunk-JGFRAFDL.js.map +1 -0
  166. package/dist/chunk-KIIXR252.js +211 -0
  167. package/dist/chunk-KIIXR252.js.map +1 -0
  168. package/dist/chunk-KN3H5CNT.js +11 -0
  169. package/dist/chunk-KN3H5CNT.js.map +1 -0
  170. package/dist/chunk-KPG3DGLA.js +1 -0
  171. package/dist/chunk-KPG3DGLA.js.map +1 -0
  172. package/dist/chunk-KRNQ6RGQ.js +1 -0
  173. package/dist/chunk-KRNQ6RGQ.js.map +1 -0
  174. package/dist/chunk-LBAJK24K.js +1071 -0
  175. package/dist/chunk-LBAJK24K.js.map +1 -0
  176. package/dist/chunk-MLTPJMH6.js +417 -0
  177. package/dist/chunk-MLTPJMH6.js.map +1 -0
  178. package/dist/chunk-N3SZ7BMH.js +95 -0
  179. package/dist/chunk-N3SZ7BMH.js.map +1 -0
  180. package/dist/chunk-NDUD3IMO.js +540 -0
  181. package/dist/chunk-NDUD3IMO.js.map +1 -0
  182. package/dist/chunk-NY2PYHNC.js +873 -0
  183. package/dist/chunk-NY2PYHNC.js.map +1 -0
  184. package/dist/chunk-O3MT7DYI.js +225 -0
  185. package/dist/chunk-O3MT7DYI.js.map +1 -0
  186. package/dist/chunk-OCUDSN63.js +2386 -0
  187. package/dist/chunk-OCUDSN63.js.map +1 -0
  188. package/dist/chunk-OIWU3NYV.js +199 -0
  189. package/dist/chunk-OIWU3NYV.js.map +1 -0
  190. package/dist/chunk-OO5BM6CJ.js +1153 -0
  191. package/dist/chunk-OO5BM6CJ.js.map +1 -0
  192. package/dist/chunk-OQUIJT7A.js +1 -0
  193. package/dist/chunk-OQUIJT7A.js.map +1 -0
  194. package/dist/chunk-P5LBT622.js +105 -0
  195. package/dist/chunk-P5LBT622.js.map +1 -0
  196. package/dist/chunk-PKGQG5QQ.js +519 -0
  197. package/dist/chunk-PKGQG5QQ.js.map +1 -0
  198. package/dist/chunk-PKPO3JTZ.js +561 -0
  199. package/dist/chunk-PKPO3JTZ.js.map +1 -0
  200. package/dist/chunk-PL5UDIQ5.js +118 -0
  201. package/dist/chunk-PL5UDIQ5.js.map +1 -0
  202. package/dist/chunk-PZWISPIQ.js +432 -0
  203. package/dist/chunk-PZWISPIQ.js.map +1 -0
  204. package/dist/chunk-Q3EYOCZB.js +510 -0
  205. package/dist/chunk-Q3EYOCZB.js.map +1 -0
  206. package/dist/chunk-QMBYUVRL.js +15 -0
  207. package/dist/chunk-QMBYUVRL.js.map +1 -0
  208. package/dist/chunk-RAGGHLCV.js +200 -0
  209. package/dist/chunk-RAGGHLCV.js.map +1 -0
  210. package/dist/chunk-RGL53X5G.js +574 -0
  211. package/dist/chunk-RGL53X5G.js.map +1 -0
  212. package/dist/chunk-RJOG4IJU.js +1039 -0
  213. package/dist/chunk-RJOG4IJU.js.map +1 -0
  214. package/dist/chunk-SOOKUYVM.js +403 -0
  215. package/dist/chunk-SOOKUYVM.js.map +1 -0
  216. package/dist/chunk-T5BN5KG7.js +1 -0
  217. package/dist/chunk-T5BN5KG7.js.map +1 -0
  218. package/dist/chunk-TP7244Y6.js +207 -0
  219. package/dist/chunk-TP7244Y6.js.map +1 -0
  220. package/dist/chunk-TSBFTJKM.js +57 -0
  221. package/dist/chunk-TSBFTJKM.js.map +1 -0
  222. package/dist/chunk-URQ2CBBF.js +143 -0
  223. package/dist/chunk-URQ2CBBF.js.map +1 -0
  224. package/dist/chunk-W2BOPXTI.js +1 -0
  225. package/dist/chunk-W2BOPXTI.js.map +1 -0
  226. package/dist/chunk-WKSWLSCX.js +207 -0
  227. package/dist/chunk-WKSWLSCX.js.map +1 -0
  228. package/dist/chunk-Y52CS6YA.js +88 -0
  229. package/dist/chunk-Y52CS6YA.js.map +1 -0
  230. package/dist/chunk-YCBUWK77.js +92 -0
  231. package/dist/chunk-YCBUWK77.js.map +1 -0
  232. package/dist/chunk-YJ4U2D2C.js +314 -0
  233. package/dist/chunk-YJ4U2D2C.js.map +1 -0
  234. package/dist/chunk-Z4YXAUDN.js +239 -0
  235. package/dist/chunk-Z4YXAUDN.js.map +1 -0
  236. package/dist/chunk-Z6EGP5D7.js +92 -0
  237. package/dist/chunk-Z6EGP5D7.js.map +1 -0
  238. package/dist/compat/index.cjs +3100 -9
  239. package/dist/compat/index.cjs.map +1 -0
  240. package/dist/compat/index.d.cts +112 -18
  241. package/dist/compat/index.d.ts +112 -18
  242. package/dist/compat/index.js +176 -1
  243. package/dist/compat/index.js.map +1 -0
  244. package/dist/compat/jotai/index.cjs +149 -1
  245. package/dist/compat/jotai/index.cjs.map +1 -0
  246. package/dist/compat/jotai/index.d.cts +2 -2
  247. package/dist/compat/jotai/index.d.ts +2 -2
  248. package/dist/compat/jotai/index.js +8 -1
  249. package/dist/compat/jotai/index.js.map +1 -0
  250. package/dist/compat/nanostores/index.cjs +205 -1
  251. package/dist/compat/nanostores/index.cjs.map +1 -0
  252. package/dist/compat/nanostores/index.d.cts +2 -2
  253. package/dist/compat/nanostores/index.d.ts +2 -2
  254. package/dist/compat/nanostores/index.js +22 -1
  255. package/dist/compat/nanostores/index.js.map +1 -0
  256. package/dist/compat/nestjs/index.cjs +2241 -9
  257. package/dist/compat/nestjs/index.cjs.map +1 -0
  258. package/dist/compat/nestjs/index.d.cts +7 -10
  259. package/dist/compat/nestjs/index.d.ts +7 -10
  260. package/dist/compat/nestjs/index.js +78 -1
  261. package/dist/compat/nestjs/index.js.map +1 -0
  262. package/dist/compat/react/index.cjs +114 -1
  263. package/dist/compat/react/index.cjs.map +1 -0
  264. package/dist/compat/react/index.d.cts +2 -2
  265. package/dist/compat/react/index.d.ts +2 -2
  266. package/dist/compat/react/index.js +12 -1
  267. package/dist/compat/react/index.js.map +1 -0
  268. package/dist/compat/solid/index.cjs +101 -1
  269. package/dist/compat/solid/index.cjs.map +1 -0
  270. package/dist/compat/solid/index.d.cts +2 -2
  271. package/dist/compat/solid/index.d.ts +2 -2
  272. package/dist/compat/solid/index.js +12 -1
  273. package/dist/compat/solid/index.js.map +1 -0
  274. package/dist/compat/svelte/index.cjs +104 -1
  275. package/dist/compat/svelte/index.cjs.map +1 -0
  276. package/dist/compat/svelte/index.d.cts +2 -2
  277. package/dist/compat/svelte/index.d.ts +2 -2
  278. package/dist/compat/svelte/index.js +12 -1
  279. package/dist/compat/svelte/index.js.map +1 -0
  280. package/dist/compat/vue/index.cjs +119 -1
  281. package/dist/compat/vue/index.cjs.map +1 -0
  282. package/dist/compat/vue/index.d.cts +2 -2
  283. package/dist/compat/vue/index.d.ts +2 -2
  284. package/dist/compat/vue/index.js +12 -1
  285. package/dist/compat/vue/index.js.map +1 -0
  286. package/dist/compat/zustand/index.cjs +69 -3
  287. package/dist/compat/zustand/index.cjs.map +1 -0
  288. package/dist/compat/zustand/index.d.cts +2 -6
  289. package/dist/compat/zustand/index.d.ts +2 -6
  290. package/dist/compat/zustand/index.js +8 -1
  291. package/dist/compat/zustand/index.js.map +1 -0
  292. package/dist/distill-De6Rnn15.d.cts +48 -0
  293. package/dist/distill-De6Rnn15.d.ts +48 -0
  294. package/dist/external-register-CWyroXb_.d.cts +138 -0
  295. package/dist/external-register-CWyroXb_.d.ts +138 -0
  296. package/dist/{fallback-74oxi34l.d.cts → fallback-Bx46zqky.d.cts} +3 -10
  297. package/dist/{fallback-DUyyBTBK.d.ts → fallback-pIWW8A2d.d.ts} +3 -10
  298. package/dist/guarded-execution-BcdtxeBk.d.ts +207 -0
  299. package/dist/guarded-execution-C-3hnP6A.d.cts +207 -0
  300. package/dist/{index-CBGUK09R.d.ts → index-5SU_O78r.d.cts} +5 -5
  301. package/dist/{index-BmZXHqkE.d.ts → index-B6pxYJzO.d.cts} +1 -1
  302. package/dist/{index-hcDJ8PSI.d.cts → index-B6pxYJzO.d.ts} +1 -1
  303. package/dist/{index-C5stwKcw.d.cts → index-BFsng6v1.d.cts} +1 -1
  304. package/dist/{index-CdAlHFEt.d.ts → index-BFsng6v1.d.ts} +1 -1
  305. package/dist/{index-_6ODbuOu.d.cts → index-Bg-LwEt-.d.cts} +1 -1
  306. package/dist/{index-CviRnE4K.d.ts → index-Bg-LwEt-.d.ts} +1 -1
  307. package/dist/{index-CBBLl_rc.d.ts → index-Brp888t0.d.cts} +1 -1
  308. package/dist/{index-BQSKmbuG.d.cts → index-Brp888t0.d.ts} +1 -1
  309. package/dist/{index-sqkqlb1p.d.ts → index-CDfk6jHN.d.cts} +1 -1
  310. package/dist/{index-ZVQhLa2i.d.cts → index-CDfk6jHN.d.ts} +1 -1
  311. package/dist/{index-Climxqsu.d.cts → index-CEXCtYYJ.d.ts} +5 -5
  312. package/dist/index-DLAxYaN5.d.cts +169 -0
  313. package/dist/index-DLAxYaN5.d.ts +169 -0
  314. package/dist/{index-CK29LV56.d.cts → index-DeWbQzMe.d.cts} +1 -1
  315. package/dist/{index-CPQlGA29.d.ts → index-DeWbQzMe.d.ts} +1 -1
  316. package/dist/{index-BrPrLl4e.d.cts → index-dX9IzPqj.d.cts} +1 -1
  317. package/dist/{index-Dgl1HpPn.d.ts → index-dX9IzPqj.d.ts} +1 -1
  318. package/dist/index.cjs +25934 -191
  319. package/dist/index.cjs.map +1 -0
  320. package/dist/index.d.cts +58 -94
  321. package/dist/index.d.ts +58 -94
  322. package/dist/index.js +852 -1
  323. package/dist/index.js.map +1 -0
  324. package/dist/layout-types-B5aiHYgk.d.cts +72 -0
  325. package/dist/layout-types-B5aiHYgk.d.ts +72 -0
  326. package/dist/memory-composers-BryDrRBX.d.cts +529 -0
  327. package/dist/memory-composers-CVQqPYEV.d.ts +529 -0
  328. package/dist/{observable-DWjNfLvC.d.ts → observable-BXQoW1P-.d.cts} +1 -1
  329. package/dist/{observable-e3eiPPFy.d.cts → observable-BXQoW1P-.d.ts} +1 -1
  330. package/dist/{pipeline-graph-Sgj0gCwn.d.ts → pipeline-graph-Ce47CB6Y.d.cts} +13 -10
  331. package/dist/{pipeline-graph-CIKhynsF.d.cts → pipeline-graph-DXCwY9vG.d.ts} +13 -10
  332. package/dist/presets/ai/index.cjs +4377 -0
  333. package/dist/presets/ai/index.cjs.map +1 -0
  334. package/dist/presets/ai/index.d.cts +98 -0
  335. package/dist/presets/ai/index.d.ts +98 -0
  336. package/dist/presets/ai/index.js +54 -0
  337. package/dist/presets/ai/index.js.map +1 -0
  338. package/dist/presets/harness/index.cjs +5929 -0
  339. package/dist/presets/harness/index.cjs.map +1 -0
  340. package/dist/presets/harness/index.d.cts +566 -0
  341. package/dist/presets/harness/index.d.ts +566 -0
  342. package/dist/presets/harness/index.js +71 -0
  343. package/dist/presets/harness/index.js.map +1 -0
  344. package/dist/presets/index.cjs +9782 -0
  345. package/dist/presets/index.cjs.map +1 -0
  346. package/dist/presets/index.d.cts +28 -0
  347. package/dist/presets/index.d.ts +28 -0
  348. package/dist/presets/index.js +129 -0
  349. package/dist/presets/index.js.map +1 -0
  350. package/dist/presets/inspect/index.cjs +1087 -0
  351. package/dist/presets/inspect/index.cjs.map +1 -0
  352. package/dist/presets/inspect/index.d.cts +172 -0
  353. package/dist/presets/inspect/index.d.ts +172 -0
  354. package/dist/presets/inspect/index.js +21 -0
  355. package/dist/presets/inspect/index.js.map +1 -0
  356. package/dist/presets/resilience/index.cjs +1593 -0
  357. package/dist/presets/resilience/index.cjs.map +1 -0
  358. package/dist/presets/resilience/index.d.cts +205 -0
  359. package/dist/presets/resilience/index.d.ts +205 -0
  360. package/dist/presets/resilience/index.js +18 -0
  361. package/dist/presets/resilience/index.js.map +1 -0
  362. package/dist/rate-limiter-CEALq4N1.d.ts +559 -0
  363. package/dist/rate-limiter-DpVbSYdH.d.cts +559 -0
  364. package/dist/{reactive-layout-DOTs9P3X.d.ts → reactive-layout-fswlBUvX.d.cts} +19 -7
  365. package/dist/{reactive-layout-DgctbqZo.d.cts → reactive-layout-fswlBUvX.d.ts} +19 -7
  366. package/dist/retry-BDbRZ_gx.d.ts +125 -0
  367. package/dist/retry-DWuhjvsA.d.cts +125 -0
  368. package/dist/solutions/index.cjs +8200 -0
  369. package/dist/solutions/index.cjs.map +1 -0
  370. package/dist/solutions/index.d.cts +23 -0
  371. package/dist/solutions/index.d.ts +23 -0
  372. package/dist/solutions/index.js +55 -0
  373. package/dist/solutions/index.js.map +1 -0
  374. package/dist/spawnable-5mDY501F.d.cts +746 -0
  375. package/dist/spawnable-D3lR0oQu.d.ts +746 -0
  376. package/dist/status-U-rUI79b.d.cts +84 -0
  377. package/dist/status-U-rUI79b.d.ts +84 -0
  378. package/dist/timeout-U5O4ESK3.js +12 -0
  379. package/dist/timeout-U5O4ESK3.js.map +1 -0
  380. package/dist/{types-CWFysE9E.d.ts → types-BB5Lw-pB.d.cts} +3 -3
  381. package/dist/{types-C0_yquda.d.cts → types-BB5Lw-pB.d.ts} +3 -3
  382. package/dist/types-CJWIMJiZ.d.ts +548 -0
  383. package/dist/types-vCq7ShIm.d.cts +548 -0
  384. package/dist/utils/ai/browser.cjs +2169 -0
  385. package/dist/utils/ai/browser.cjs.map +1 -0
  386. package/dist/{patterns → utils}/ai/browser.d.cts +7 -5
  387. package/dist/{patterns → utils}/ai/browser.d.ts +7 -5
  388. package/dist/utils/ai/browser.js +255 -0
  389. package/dist/utils/ai/browser.js.map +1 -0
  390. package/dist/utils/ai/index.cjs +8468 -0
  391. package/dist/utils/ai/index.cjs.map +1 -0
  392. package/dist/{index-CR8QpwX8.d.ts → utils/ai/index.d.cts} +73 -976
  393. package/dist/{index-UPSiS-X7.d.cts → utils/ai/index.d.ts} +73 -976
  394. package/dist/utils/ai/index.js +173 -0
  395. package/dist/utils/ai/index.js.map +1 -0
  396. package/dist/utils/ai/node.cjs +648 -0
  397. package/dist/utils/ai/node.cjs.map +1 -0
  398. package/dist/{patterns → utils}/ai/node.d.cts +5 -7
  399. package/dist/{patterns → utils}/ai/node.d.ts +5 -7
  400. package/dist/utils/ai/node.js +84 -0
  401. package/dist/utils/ai/node.js.map +1 -0
  402. package/dist/utils/cqrs/index.cjs +1036 -0
  403. package/dist/utils/cqrs/index.cjs.map +1 -0
  404. package/dist/{index-CeFiHtAg.d.ts → utils/cqrs/index.d.cts} +7 -37
  405. package/dist/{index-B-_tFaqV.d.cts → utils/cqrs/index.d.ts} +7 -37
  406. package/dist/utils/cqrs/index.js +18 -0
  407. package/dist/utils/cqrs/index.js.map +1 -0
  408. package/dist/utils/demo-shell/index.cjs +865 -0
  409. package/dist/utils/demo-shell/index.cjs.map +1 -0
  410. package/dist/{index-B8YnZpIR.d.ts → utils/demo-shell/index.d.cts} +4 -16
  411. package/dist/{index-Cwv0KWcU.d.cts → utils/demo-shell/index.d.ts} +4 -16
  412. package/dist/utils/demo-shell/index.js +13 -0
  413. package/dist/utils/demo-shell/index.js.map +1 -0
  414. package/dist/utils/domain-templates/index.cjs +732 -0
  415. package/dist/utils/domain-templates/index.cjs.map +1 -0
  416. package/dist/{index-CzLVrjxn.d.ts → utils/domain-templates/index.d.cts} +3 -20
  417. package/dist/{index-BaQaY_IQ.d.cts → utils/domain-templates/index.d.ts} +3 -20
  418. package/dist/utils/domain-templates/index.js +17 -0
  419. package/dist/utils/domain-templates/index.js.map +1 -0
  420. package/dist/utils/graphspec/index.cjs +1174 -0
  421. package/dist/utils/graphspec/index.cjs.map +1 -0
  422. package/dist/{index-CMh5Rz1y.d.ts → utils/graphspec/index.d.cts} +106 -42
  423. package/dist/{index-CS0LTlB8.d.cts → utils/graphspec/index.d.ts} +106 -42
  424. package/dist/utils/graphspec/index.js +35 -0
  425. package/dist/utils/graphspec/index.js.map +1 -0
  426. package/dist/utils/harness/index.cjs +656 -0
  427. package/dist/utils/harness/index.cjs.map +1 -0
  428. package/dist/utils/harness/index.d.cts +542 -0
  429. package/dist/utils/harness/index.d.ts +542 -0
  430. package/dist/utils/harness/index.js +56 -0
  431. package/dist/utils/harness/index.js.map +1 -0
  432. package/dist/utils/index.cjs +17609 -0
  433. package/dist/utils/index.cjs.map +1 -0
  434. package/dist/utils/index.d.cts +96 -0
  435. package/dist/utils/index.d.ts +96 -0
  436. package/dist/utils/index.js +514 -0
  437. package/dist/utils/index.js.map +1 -0
  438. package/dist/utils/inspect/index.cjs +807 -0
  439. package/dist/utils/inspect/index.cjs.map +1 -0
  440. package/dist/utils/inspect/index.d.cts +123 -0
  441. package/dist/utils/inspect/index.d.ts +123 -0
  442. package/dist/utils/inspect/index.js +30 -0
  443. package/dist/utils/inspect/index.js.map +1 -0
  444. package/dist/utils/job-queue/index.cjs +717 -0
  445. package/dist/utils/job-queue/index.cjs.map +1 -0
  446. package/dist/{index-DisjX8a-.d.ts → utils/job-queue/index.d.cts} +5 -26
  447. package/dist/{index-DV_1YuVk.d.cts → utils/job-queue/index.d.ts} +5 -26
  448. package/dist/utils/job-queue/index.js +18 -0
  449. package/dist/utils/job-queue/index.js.map +1 -0
  450. package/dist/utils/memory/index.cjs +1451 -0
  451. package/dist/utils/memory/index.cjs.map +1 -0
  452. package/dist/{index-CZ3r5Rxp.d.ts → utils/memory/index.d.cts} +242 -34
  453. package/dist/{index-B17QddL1.d.cts → utils/memory/index.d.ts} +242 -34
  454. package/dist/utils/memory/index.js +19 -0
  455. package/dist/utils/memory/index.js.map +1 -0
  456. package/dist/utils/messaging/index.cjs +666 -0
  457. package/dist/utils/messaging/index.cjs.map +1 -0
  458. package/dist/utils/messaging/index.d.cts +562 -0
  459. package/dist/utils/messaging/index.d.ts +562 -0
  460. package/dist/utils/messaging/index.js +50 -0
  461. package/dist/utils/messaging/index.js.map +1 -0
  462. package/dist/utils/orchestration/index.cjs +876 -0
  463. package/dist/utils/orchestration/index.cjs.map +1 -0
  464. package/dist/utils/orchestration/index.d.cts +233 -0
  465. package/dist/utils/orchestration/index.d.ts +233 -0
  466. package/dist/utils/orchestration/index.js +19 -0
  467. package/dist/utils/orchestration/index.js.map +1 -0
  468. package/dist/utils/process/index.cjs +743 -0
  469. package/dist/utils/process/index.cjs.map +1 -0
  470. package/dist/{index-p09KSrTN.d.ts → utils/process/index.d.cts} +97 -44
  471. package/dist/{index-CasX6Pfq.d.cts → utils/process/index.d.ts} +97 -44
  472. package/dist/utils/process/index.js +14 -0
  473. package/dist/utils/process/index.js.map +1 -0
  474. package/dist/utils/reactive-layout/index.cjs +1607 -0
  475. package/dist/utils/reactive-layout/index.cjs.map +1 -0
  476. package/dist/{index-B5S8ULbU.d.ts → utils/reactive-layout/index.d.cts} +58 -81
  477. package/dist/{index-Dc4AYqrJ.d.cts → utils/reactive-layout/index.d.ts} +58 -81
  478. package/dist/utils/reactive-layout/index.js +52 -0
  479. package/dist/utils/reactive-layout/index.js.map +1 -0
  480. package/dist/utils/reduction/index.cjs +203 -0
  481. package/dist/utils/reduction/index.cjs.map +1 -0
  482. package/dist/{index-Byu-OpX_.d.ts → utils/reduction/index.d.cts} +6 -17
  483. package/dist/{index-tRCxuAXF.d.cts → utils/reduction/index.d.ts} +6 -17
  484. package/dist/utils/reduction/index.js +14 -0
  485. package/dist/utils/reduction/index.js.map +1 -0
  486. package/dist/utils/resilience/index.cjs +1617 -0
  487. package/dist/utils/resilience/index.cjs.map +1 -0
  488. package/dist/utils/resilience/index.d.cts +9 -0
  489. package/dist/utils/resilience/index.d.ts +9 -0
  490. package/dist/utils/resilience/index.js +44 -0
  491. package/dist/utils/resilience/index.js.map +1 -0
  492. package/dist/utils/surface/index.cjs +1070 -0
  493. package/dist/utils/surface/index.cjs.map +1 -0
  494. package/dist/{index-CYq8vAyV.d.ts → utils/surface/index.d.cts} +7 -58
  495. package/dist/{index-CSOmP7xT.d.cts → utils/surface/index.d.ts} +7 -58
  496. package/dist/utils/surface/index.js +30 -0
  497. package/dist/utils/surface/index.js.map +1 -0
  498. package/dist/utils/topology-view/index.cjs +620 -0
  499. package/dist/utils/topology-view/index.cjs.map +1 -0
  500. package/dist/utils/topology-view/index.d.cts +68 -0
  501. package/dist/utils/topology-view/index.d.ts +68 -0
  502. package/dist/utils/topology-view/index.js +11 -0
  503. package/dist/utils/topology-view/index.js.map +1 -0
  504. package/package.json +664 -584
  505. package/dist/backoff-HPZMEZNF.js +0 -1
  506. package/dist/chunk-2T7U5EU6.js +0 -1
  507. package/dist/chunk-3G5U5QNE.js +0 -5
  508. package/dist/chunk-4VVTGLXJ.js +0 -1
  509. package/dist/chunk-5M4CCMMD.js +0 -45
  510. package/dist/chunk-5QDBSZBV.js +0 -1
  511. package/dist/chunk-5XJ6B66J.js +0 -1
  512. package/dist/chunk-6QZNQS5B.js +0 -1
  513. package/dist/chunk-6X7AFUJV.js +0 -9
  514. package/dist/chunk-7K6PWTDQ.js +0 -1
  515. package/dist/chunk-7LIAPXJB.js +0 -1
  516. package/dist/chunk-7WPU3UHQ.js +0 -1
  517. package/dist/chunk-A5WCQ5NO.js +0 -1
  518. package/dist/chunk-APPIWSGD.js +0 -84
  519. package/dist/chunk-BEZWM2SY.js +0 -1
  520. package/dist/chunk-C72GO4IZ.js +0 -1
  521. package/dist/chunk-CB676TKJ.js +0 -1
  522. package/dist/chunk-CE6TI2TL.js +0 -1
  523. package/dist/chunk-CE72X3WO.js +0 -1
  524. package/dist/chunk-CK2E7BTU.js +0 -1
  525. package/dist/chunk-CLVB32RD.js +0 -1
  526. package/dist/chunk-CRVT7D2P.js +0 -1
  527. package/dist/chunk-D5RFJOZ2.js +0 -1
  528. package/dist/chunk-D7GPHKFH.js +0 -1
  529. package/dist/chunk-DHRX7JX4.js +0 -2
  530. package/dist/chunk-ESMPEKEV.js +0 -1
  531. package/dist/chunk-F672GV32.js +0 -1
  532. package/dist/chunk-FZMYDOWV.js +0 -1
  533. package/dist/chunk-GHBWHMRZ.js +0 -1
  534. package/dist/chunk-GLERH466.js +0 -1
  535. package/dist/chunk-GPW2V3RE.js +0 -1
  536. package/dist/chunk-HIDYF36O.js +0 -1
  537. package/dist/chunk-HITNVN6B.js +0 -3
  538. package/dist/chunk-HY4DJBA7.js +0 -5
  539. package/dist/chunk-KZIEYVXN.js +0 -1
  540. package/dist/chunk-L6NSJVJZ.js +0 -1
  541. package/dist/chunk-N4MQX6JU.js +0 -18
  542. package/dist/chunk-N7FHEL4D.js +0 -1
  543. package/dist/chunk-NTEURFZH.js +0 -1
  544. package/dist/chunk-OIVP6KFV.js +0 -1
  545. package/dist/chunk-OPHBU3LG.js +0 -1
  546. package/dist/chunk-OYQOZP2F.js +0 -5
  547. package/dist/chunk-PTZK576G.js +0 -1
  548. package/dist/chunk-QYADASLV.js +0 -1
  549. package/dist/chunk-ST7UXLWR.js +0 -1
  550. package/dist/chunk-SVY7VUYU.js +0 -1
  551. package/dist/chunk-TK3NWWD4.js +0 -1
  552. package/dist/chunk-TSOYJ743.js +0 -1
  553. package/dist/chunk-UNGSTR4X.js +0 -61
  554. package/dist/chunk-VIMF6LGM.js +0 -1
  555. package/dist/chunk-VJLMUKOI.js +0 -1
  556. package/dist/chunk-VN6RDSK2.js +0 -1
  557. package/dist/chunk-VV4N5P64.js +0 -1
  558. package/dist/chunk-W3I423PS.js +0 -1
  559. package/dist/chunk-WJR24TAG.js +0 -1
  560. package/dist/chunk-XTGKMHSW.js +0 -1
  561. package/dist/chunk-YBB7ZGTY.js +0 -1
  562. package/dist/chunk-Z4NPUARF.js +0 -1
  563. package/dist/chunk-ZGNQRPDT.js +0 -1
  564. package/dist/chunk-ZKPSFFKU.js +0 -1
  565. package/dist/chunk-ZLV5SQSX.js +0 -1
  566. package/dist/content-addressed-storage-4-ST1tYk.d.cts +0 -124
  567. package/dist/content-addressed-storage-DuYMjV7o.d.ts +0 -124
  568. package/dist/core/index.cjs +0 -1
  569. package/dist/core/index.d.cts +0 -3
  570. package/dist/core/index.d.ts +0 -3
  571. package/dist/core/index.js +0 -1
  572. package/dist/decay-BvOWTZ00.d.ts +0 -112
  573. package/dist/decay-CFlLvXUT.d.cts +0 -112
  574. package/dist/extra/browser.cjs +0 -1
  575. package/dist/extra/browser.d.cts +0 -4
  576. package/dist/extra/browser.d.ts +0 -4
  577. package/dist/extra/browser.js +0 -1
  578. package/dist/extra/index.cjs +0 -20
  579. package/dist/extra/index.d.cts +0 -17
  580. package/dist/extra/index.d.ts +0 -17
  581. package/dist/extra/index.js +0 -1
  582. package/dist/extra/node.cjs +0 -2
  583. package/dist/extra/node.js +0 -2
  584. package/dist/extra/operators.cjs +0 -1
  585. package/dist/extra/operators.d.cts +0 -958
  586. package/dist/extra/operators.d.ts +0 -958
  587. package/dist/extra/operators.js +0 -1
  588. package/dist/extra/reactive.cjs +0 -1
  589. package/dist/extra/reactive.d.cts +0 -353
  590. package/dist/extra/reactive.d.ts +0 -353
  591. package/dist/extra/reactive.js +0 -1
  592. package/dist/extra/render/index.cjs +0 -5
  593. package/dist/extra/render/index.js +0 -1
  594. package/dist/extra/sources.cjs +0 -3
  595. package/dist/extra/sources.js +0 -1
  596. package/dist/extra/storage-browser.cjs +0 -1
  597. package/dist/extra/storage-browser.d.cts +0 -37
  598. package/dist/extra/storage-browser.d.ts +0 -37
  599. package/dist/extra/storage-browser.js +0 -1
  600. package/dist/extra/storage-core.cjs +0 -1
  601. package/dist/extra/storage-core.d.cts +0 -28
  602. package/dist/extra/storage-core.d.ts +0 -28
  603. package/dist/extra/storage-core.js +0 -1
  604. package/dist/extra/storage-node.cjs +0 -1
  605. package/dist/extra/storage-node.d.cts +0 -2
  606. package/dist/extra/storage-node.d.ts +0 -2
  607. package/dist/extra/storage-node.js +0 -0
  608. package/dist/extra/storage-tiers-browser.cjs +0 -1
  609. package/dist/extra/storage-tiers-browser.d.cts +0 -120
  610. package/dist/extra/storage-tiers-browser.d.ts +0 -120
  611. package/dist/extra/storage-tiers-browser.js +0 -1
  612. package/dist/extra/storage-tiers-node.cjs +0 -1
  613. package/dist/extra/storage-tiers-node.d.cts +0 -210
  614. package/dist/extra/storage-tiers-node.d.ts +0 -210
  615. package/dist/extra/storage-tiers-node.js +0 -1
  616. package/dist/extra/storage-tiers.cjs +0 -1
  617. package/dist/extra/storage-tiers.d.cts +0 -412
  618. package/dist/extra/storage-tiers.d.ts +0 -412
  619. package/dist/extra/storage-tiers.js +0 -1
  620. package/dist/graph/index.cjs +0 -7
  621. package/dist/graph/index.d.cts +0 -7
  622. package/dist/graph/index.d.ts +0 -7
  623. package/dist/graph/index.js +0 -1
  624. package/dist/graph-CWvEUQAq.d.cts +0 -1861
  625. package/dist/graph-D9LFnda9.d.ts +0 -1861
  626. package/dist/index-5k1T6jl0.d.cts +0 -121
  627. package/dist/index-9770hRuQ.d.cts +0 -779
  628. package/dist/index-B1F8Enjf.d.ts +0 -704
  629. package/dist/index-BHskSB8v.d.ts +0 -3413
  630. package/dist/index-BIYAkbAi.d.cts +0 -26
  631. package/dist/index-BoJ5JHxI.d.ts +0 -557
  632. package/dist/index-BocU7pqs.d.ts +0 -779
  633. package/dist/index-BxNs2HB9.d.cts +0 -1858
  634. package/dist/index-C1T3d7V-.d.cts +0 -704
  635. package/dist/index-C5ri2Axc.d.cts +0 -301
  636. package/dist/index-C9l6OEBL.d.ts +0 -26
  637. package/dist/index-CC-AvFTy.d.cts +0 -557
  638. package/dist/index-CJF1URuX.d.ts +0 -121
  639. package/dist/index-CdTelp1M.d.ts +0 -202
  640. package/dist/index-Cj3WohTd.d.cts +0 -202
  641. package/dist/index-Co7uli2l.d.cts +0 -3413
  642. package/dist/index-D0aciIex.d.cts +0 -209
  643. package/dist/index-DHen9Klo.d.ts +0 -1858
  644. package/dist/index-Yq60JP3s.d.ts +0 -209
  645. package/dist/index-nozs3fFC.d.ts +0 -301
  646. package/dist/node-kK3CvTrR.d.cts +0 -1347
  647. package/dist/node-kK3CvTrR.d.ts +0 -1347
  648. package/dist/patterns/ai/browser.cjs +0 -8
  649. package/dist/patterns/ai/browser.js +0 -3
  650. package/dist/patterns/ai/index.cjs +0 -74
  651. package/dist/patterns/ai/index.d.cts +0 -20
  652. package/dist/patterns/ai/index.d.ts +0 -20
  653. package/dist/patterns/ai/index.js +0 -1
  654. package/dist/patterns/ai/node.cjs +0 -1
  655. package/dist/patterns/ai/node.js +0 -1
  656. package/dist/patterns/cqrs/index.cjs +0 -3
  657. package/dist/patterns/cqrs/index.d.cts +0 -8
  658. package/dist/patterns/cqrs/index.d.ts +0 -8
  659. package/dist/patterns/cqrs/index.js +0 -1
  660. package/dist/patterns/demo-shell/index.cjs +0 -5
  661. package/dist/patterns/demo-shell/index.d.cts +0 -7
  662. package/dist/patterns/demo-shell/index.d.ts +0 -7
  663. package/dist/patterns/demo-shell/index.js +0 -1
  664. package/dist/patterns/domain-templates/index.cjs +0 -3
  665. package/dist/patterns/domain-templates/index.d.cts +0 -6
  666. package/dist/patterns/domain-templates/index.d.ts +0 -6
  667. package/dist/patterns/domain-templates/index.js +0 -1
  668. package/dist/patterns/graphspec/index.cjs +0 -86
  669. package/dist/patterns/graphspec/index.d.cts +0 -8
  670. package/dist/patterns/graphspec/index.d.ts +0 -8
  671. package/dist/patterns/graphspec/index.js +0 -1
  672. package/dist/patterns/harness/index.cjs +0 -48
  673. package/dist/patterns/harness/index.d.cts +0 -13
  674. package/dist/patterns/harness/index.d.ts +0 -13
  675. package/dist/patterns/harness/index.js +0 -1
  676. package/dist/patterns/inspect/index.cjs +0 -3
  677. package/dist/patterns/inspect/index.d.cts +0 -9
  678. package/dist/patterns/inspect/index.d.ts +0 -9
  679. package/dist/patterns/inspect/index.js +0 -1
  680. package/dist/patterns/job-queue/index.cjs +0 -3
  681. package/dist/patterns/job-queue/index.d.cts +0 -9
  682. package/dist/patterns/job-queue/index.d.ts +0 -9
  683. package/dist/patterns/job-queue/index.js +0 -1
  684. package/dist/patterns/memory/index.cjs +0 -3
  685. package/dist/patterns/memory/index.d.cts +0 -8
  686. package/dist/patterns/memory/index.d.ts +0 -8
  687. package/dist/patterns/memory/index.js +0 -1
  688. package/dist/patterns/messaging/index.cjs +0 -3
  689. package/dist/patterns/messaging/index.d.cts +0 -7
  690. package/dist/patterns/messaging/index.d.ts +0 -7
  691. package/dist/patterns/messaging/index.js +0 -1
  692. package/dist/patterns/orchestration/index.cjs +0 -3
  693. package/dist/patterns/orchestration/index.d.cts +0 -8
  694. package/dist/patterns/orchestration/index.d.ts +0 -8
  695. package/dist/patterns/orchestration/index.js +0 -1
  696. package/dist/patterns/process/index.cjs +0 -3
  697. package/dist/patterns/process/index.d.cts +0 -10
  698. package/dist/patterns/process/index.d.ts +0 -10
  699. package/dist/patterns/process/index.js +0 -1
  700. package/dist/patterns/reactive-layout/index.cjs +0 -4
  701. package/dist/patterns/reactive-layout/index.d.cts +0 -7
  702. package/dist/patterns/reactive-layout/index.d.ts +0 -7
  703. package/dist/patterns/reactive-layout/index.js +0 -1
  704. package/dist/patterns/reduction/index.cjs +0 -3
  705. package/dist/patterns/reduction/index.d.cts +0 -6
  706. package/dist/patterns/reduction/index.d.ts +0 -6
  707. package/dist/patterns/reduction/index.js +0 -1
  708. package/dist/patterns/surface/index.cjs +0 -13
  709. package/dist/patterns/surface/index.d.cts +0 -9
  710. package/dist/patterns/surface/index.d.ts +0 -9
  711. package/dist/patterns/surface/index.js +0 -1
  712. package/dist/reactive-log-BKALbfal.d.ts +0 -223
  713. package/dist/reactive-log-DIGdYqQ6.d.cts +0 -223
  714. package/dist/reactive-map-CEFGp8TK.d.cts +0 -296
  715. package/dist/reactive-map-DS_SIAxv.d.ts +0 -296
  716. package/dist/resilience-6LYQJAC5.js +0 -1
  717. package/dist/sugar-DQjFmVqb.d.cts +0 -399
  718. package/dist/sugar-fhLIE7TT.d.ts +0 -399
  719. package/dist/topology-tree-Bcz27hpF.d.cts +0 -25
  720. package/dist/topology-tree-xvaD0fOX.d.ts +0 -25
@@ -0,0 +1,1451 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/utils/memory/index.ts
21
+ var memory_exports = {};
22
+ __export(memory_exports, {
23
+ collection: () => collection,
24
+ cosineSimilarity: () => cosineSimilarity,
25
+ knowledgeGraph: () => knowledgeGraph,
26
+ reactiveFactStore: () => reactiveFactStore,
27
+ vectorIndex: () => vectorIndex
28
+ });
29
+ module.exports = __toCommonJS(memory_exports);
30
+ var import_core3 = require("@graphrefly/pure-ts/core");
31
+ var import_extra3 = require("@graphrefly/pure-ts/extra");
32
+ var import_graph3 = require("@graphrefly/pure-ts/graph");
33
+
34
+ // src/base/meta/domain-meta.ts
35
+ function domainMeta(domain, kind, extra) {
36
+ return {
37
+ [domain]: true,
38
+ [`${domain}_type`]: kind,
39
+ ...extra ?? {}
40
+ };
41
+ }
42
+
43
+ // src/base/mutation/index.ts
44
+ var import_core = require("@graphrefly/pure-ts/core");
45
+ var import_extra = require("@graphrefly/pure-ts/extra");
46
+ var import_graph = require("@graphrefly/pure-ts/graph");
47
+ var DEFAULT_AUDIT_GUARD = (0, import_core.policy)((allow, deny) => {
48
+ allow("observe");
49
+ allow("signal");
50
+ deny("write");
51
+ });
52
+ function createAuditLog(opts) {
53
+ const log = (0, import_extra.reactiveLog)([], {
54
+ name: opts.name,
55
+ maxSize: opts.retainedLimit ?? 1024,
56
+ guard: opts.guard ?? DEFAULT_AUDIT_GUARD,
57
+ ...opts.versioning != null ? { versioning: opts.versioning } : {}
58
+ });
59
+ log.withLatest();
60
+ if (opts.graph) {
61
+ opts.graph.add(log.entries, { name: opts.name });
62
+ }
63
+ return log;
64
+ }
65
+ function deepFreeze(value) {
66
+ if (value === null || typeof value !== "object" || Object.isFrozen(value)) return value;
67
+ for (const k of Object.keys(value)) {
68
+ deepFreeze(value[k]);
69
+ }
70
+ return Object.freeze(value);
71
+ }
72
+ function mutate(act, opts) {
73
+ const { up, down } = typeof act === "function" ? { up: act, down: void 0 } : act;
74
+ const freeze = opts.freeze ?? true;
75
+ if (opts.frame === "inline") {
76
+ return function wrapped(...args) {
77
+ const sealed = freeze ? args.map(deepFreeze) : args;
78
+ const t_ns = (0, import_core.wallClockNs)();
79
+ const seq = opts.seq ? bumpCursor(opts.seq) : void 0;
80
+ try {
81
+ const result = up(...sealed);
82
+ if (opts.log && opts.onSuccessRecord) {
83
+ appendAudit(
84
+ opts.log,
85
+ opts.onSuccessRecord,
86
+ sealed,
87
+ result,
88
+ { t_ns, seq },
89
+ opts.handlerVersion
90
+ );
91
+ }
92
+ return result;
93
+ } catch (err) {
94
+ if (opts.log && opts.onFailureRecord) {
95
+ const errorType = err instanceof Error ? err.name : typeof err;
96
+ appendAudit(
97
+ opts.log,
98
+ opts.onFailureRecord,
99
+ sealed,
100
+ err,
101
+ { t_ns, seq, errorType },
102
+ opts.handlerVersion
103
+ );
104
+ }
105
+ throw err;
106
+ }
107
+ };
108
+ }
109
+ return function wrapped(...args) {
110
+ const sealed = freeze ? args.map(deepFreeze) : args;
111
+ const t_ns = (0, import_core.wallClockNs)();
112
+ let result;
113
+ let captured;
114
+ let captureSet = false;
115
+ let seq;
116
+ try {
117
+ (0, import_core.batch)(() => {
118
+ if (opts.seq) seq = bumpCursor(opts.seq);
119
+ try {
120
+ result = up(...sealed);
121
+ if (opts.log && opts.onSuccessRecord) {
122
+ appendAudit(
123
+ opts.log,
124
+ opts.onSuccessRecord,
125
+ sealed,
126
+ result,
127
+ { t_ns, seq },
128
+ opts.handlerVersion
129
+ );
130
+ }
131
+ } catch (err) {
132
+ captured = err;
133
+ captureSet = true;
134
+ throw err;
135
+ }
136
+ });
137
+ } catch (outerErr) {
138
+ if (captureSet && down) {
139
+ try {
140
+ down(...sealed);
141
+ } catch (downErr) {
142
+ console.error(
143
+ `mutate: down hook threw \u2014 original action error preserved (${captured instanceof Error ? captured.name : typeof captured}). Down error:`,
144
+ downErr
145
+ );
146
+ }
147
+ }
148
+ if (captureSet && opts.log && opts.onFailureRecord) {
149
+ const errorType = captured instanceof Error ? captured.name : typeof captured;
150
+ appendAudit(
151
+ opts.log,
152
+ opts.onFailureRecord,
153
+ sealed,
154
+ captured,
155
+ { t_ns, seq, errorType },
156
+ opts.handlerVersion
157
+ );
158
+ }
159
+ throw captureSet ? captured : outerErr;
160
+ }
161
+ return result;
162
+ };
163
+ }
164
+ var _bumpCursorWarned = /* @__PURE__ */ new WeakSet();
165
+ function bumpCursor(seq) {
166
+ const raw = seq.cache;
167
+ const valid = typeof raw === "number" && Number.isFinite(raw);
168
+ if (!valid && raw !== void 0 && !_bumpCursorWarned.has(seq)) {
169
+ _bumpCursorWarned.add(seq);
170
+ console.warn(
171
+ `bumpCursor: cursor cache held a non-numeric value (${String(raw)}); resetting to 0. Causes include: a snapshot codec round-tripping the cursor as a string / null / NaN, OR a malformed initial seed (e.g. state<number>(NaN)). Audit consumers may see colliding seq values after this point.`
172
+ );
173
+ }
174
+ const cur = valid ? raw : 0;
175
+ const next = cur + 1;
176
+ seq.down([[import_core.DIRTY], [import_core.DATA, next]]);
177
+ return next;
178
+ }
179
+ function appendAudit(audit, builder, args, value, meta, handlerVersion) {
180
+ const record = builder(args, value, meta);
181
+ if (record === void 0) return;
182
+ const stamped = handlerVersion != null ? { ...record, handlerVersion } : record;
183
+ audit.append(stamped);
184
+ }
185
+ function registerCursor(graph, name, initial = 0) {
186
+ const cursor = (0, import_core.node)([], { initial, name, describeKind: "state" });
187
+ graph.add(cursor, { name });
188
+ return cursor;
189
+ }
190
+
191
+ // src/base/utils/decay.ts
192
+ var DEFAULT_DECAY_RATE = Math.LN2 / (7 * 86400);
193
+ function decay(baseScore, ageSeconds2, ratePerSecond, minScore = 0) {
194
+ if (!Number.isFinite(baseScore)) return minScore;
195
+ if (!Number.isFinite(ageSeconds2) || ageSeconds2 <= 0) return Math.max(minScore, baseScore);
196
+ if (!Number.isFinite(ratePerSecond) || ratePerSecond <= 0) return Math.max(minScore, baseScore);
197
+ const decayed = baseScore * Math.exp(-ratePerSecond * ageSeconds2);
198
+ return Math.max(minScore, decayed);
199
+ }
200
+
201
+ // src/utils/memory/fact-store.ts
202
+ var import_core2 = require("@graphrefly/pure-ts/core");
203
+ var import_extra2 = require("@graphrefly/pure-ts/extra");
204
+ var import_graph2 = require("@graphrefly/pure-ts/graph");
205
+ var OVERFLOW_SAMPLE_SIZE = 8;
206
+ function factMeta(kind, extra) {
207
+ return domainMeta("memory", kind, extra);
208
+ }
209
+ function fnv1a(s) {
210
+ let h = 2166136261;
211
+ for (let i = 0; i < s.length; i += 1) {
212
+ h ^= s.charCodeAt(i);
213
+ h = h + ((h << 1) + (h << 4) + (h << 7) + (h << 8) + (h << 24)) >>> 0;
214
+ }
215
+ return h >>> 0;
216
+ }
217
+ function makeReadHandle(byId) {
218
+ return {
219
+ get: (id) => byId.get(id),
220
+ has: (id) => byId.has(id),
221
+ get size() {
222
+ return byId.size;
223
+ },
224
+ values: () => byId.values()
225
+ };
226
+ }
227
+ function currentlyValid(f, asOf) {
228
+ if (asOf === void 0) return f.validTo === void 0;
229
+ if (f.validFrom !== void 0 && asOf < f.validFrom) return false;
230
+ if (f.validTo !== void 0 && asOf >= f.validTo) return false;
231
+ return true;
232
+ }
233
+ function lastOf(batch2, prev) {
234
+ return batch2 != null && batch2.length > 0 ? batch2.at(-1) : prev;
235
+ }
236
+ function reactiveFactStore(config) {
237
+ const shardCount = Math.max(1, config.shardCount ?? 4);
238
+ const maxIterations = Math.max(1, config.cascadeMaxIterations ?? 8);
239
+ const reviewThreshold = config.reviewThreshold ?? 0.3;
240
+ const shardBy = config.shardBy ?? ((f) => fnv1a(String(f.id)) % shardCount);
241
+ let cascadeIteration = 0;
242
+ const processedRoots = /* @__PURE__ */ new Set();
243
+ const graph = new import_graph2.Graph("reactive_fact_store");
244
+ const events = createAuditLog({
245
+ name: "events",
246
+ retainedLimit: 1024,
247
+ graph
248
+ });
249
+ const seqCursor = registerCursor(graph, "seq", 0);
250
+ const emptyStore = () => ({ byId: /* @__PURE__ */ new Map() });
251
+ const shards = [];
252
+ for (let s = 0; s < shardCount; s += 1) {
253
+ const shard = (0, import_core2.node)([], {
254
+ initial: emptyStore(),
255
+ name: `shard_${s}`,
256
+ describeKind: "state",
257
+ meta: factMeta("factstore", { shard: s })
258
+ });
259
+ graph.add(shard, { name: `shard_${s}` });
260
+ graph.addDisposer((0, import_extra2.keepalive)(shard));
261
+ shards.push(shard);
262
+ }
263
+ const shardIndexFor = (f) => {
264
+ const key = shardBy(f);
265
+ const n = typeof key === "number" ? key : fnv1a(String(key));
266
+ const idx = (n % shardCount + shardCount) % shardCount;
267
+ return idx;
268
+ };
269
+ const findShardOf = (id) => {
270
+ for (let s = 0; s < shardCount; s += 1) {
271
+ const fs = shards[s].cache;
272
+ if (fs?.byId.has(id)) return s;
273
+ }
274
+ return -1;
275
+ };
276
+ const allFacts = () => {
277
+ const out2 = /* @__PURE__ */ new Map();
278
+ for (const sh of shards) {
279
+ const fs = sh.cache;
280
+ if (!fs) continue;
281
+ for (const [k, v] of fs.byId) out2.set(k, v);
282
+ }
283
+ return out2;
284
+ };
285
+ const commitFragment = (f) => {
286
+ const idx = shardIndexFor(f);
287
+ const cur = shards[idx].cache ?? emptyStore();
288
+ const next = new Map(cur.byId);
289
+ next.set(f.id, f);
290
+ shards[idx].emit({ byId: next });
291
+ };
292
+ const replaceFragment = (id, mut) => {
293
+ const idx = findShardOf(id);
294
+ if (idx < 0) return false;
295
+ const cur = shards[idx].cache;
296
+ const prev = cur.byId.get(id);
297
+ if (!prev) return false;
298
+ const next = new Map(cur.byId);
299
+ next.set(id, mut(prev));
300
+ shards[idx].emit({ byId: next });
301
+ return true;
302
+ };
303
+ const dependentsIndex = (0, import_core2.node)([], {
304
+ initial: /* @__PURE__ */ new Map(),
305
+ name: "dependents_index",
306
+ describeKind: "state",
307
+ meta: factMeta("factstore", { role: "dependents_index" })
308
+ });
309
+ graph.add(dependentsIndex, { name: "dependents_index" });
310
+ graph.addDisposer((0, import_extra2.keepalive)(dependentsIndex));
311
+ const indexFragment = (f, deps) => {
312
+ const cur = dependentsIndex.cache;
313
+ const next = /* @__PURE__ */ new Map();
314
+ for (const [k, v] of cur) next.set(k, [...v]);
315
+ for (const src of deps) {
316
+ const bucket = next.get(src) ?? [];
317
+ if (!bucket.includes(f.id)) bucket.push(f.id);
318
+ next.set(src, bucket);
319
+ }
320
+ dependentsIndex.emit(next);
321
+ };
322
+ const factStore = (0, import_core2.node)(
323
+ shards,
324
+ (batchData, actions, ctx) => {
325
+ void batchData;
326
+ void ctx;
327
+ actions.emit({ byId: allFacts() });
328
+ },
329
+ {
330
+ name: "fact_store",
331
+ describeKind: "derived",
332
+ initial: emptyStore(),
333
+ meta: factMeta("factstore", { role: "read_view" }),
334
+ // F10a: `allFacts()` builds a fresh Map every detector retrigger.
335
+ // Fragments are immutable (replaced wholesale on mutation), so a
336
+ // same-size + per-key-identity check is a sound structural equality
337
+ // that stops `factStore` (and its `review` dependent) from re-firing
338
+ // every cascade wave when nothing actually changed.
339
+ equals: (a, b) => {
340
+ if (a === b) return true;
341
+ if (a.byId.size !== b.byId.size) return false;
342
+ for (const [k, v] of a.byId) {
343
+ if (b.byId.get(k) !== v) return false;
344
+ }
345
+ return true;
346
+ }
347
+ }
348
+ );
349
+ graph.add(factStore, { name: "fact_store" });
350
+ graph.addDisposer((0, import_extra2.keepalive)(factStore));
351
+ const extractOp = (0, import_core2.node)(
352
+ config.admissionFilter ? [config.ingest, config.admissionFilter] : [config.ingest],
353
+ (batchData, actions, ctx) => {
354
+ const f = lastOf(batchData[0], ctx.prevData[0]);
355
+ if (f == null) {
356
+ actions.emit(null);
357
+ return;
358
+ }
359
+ if (config.admissionFilter) {
360
+ const filter = lastOf(batchData[1], ctx.prevData[1]);
361
+ if (filter && !filter(f)) {
362
+ actions.emit(null);
363
+ return;
364
+ }
365
+ }
366
+ const deps = config.extractDependencies(f);
367
+ cascadeIteration = 0;
368
+ processedRoots.delete(f.id);
369
+ commitFragment(f);
370
+ indexFragment(f, deps);
371
+ actions.emit(f);
372
+ },
373
+ {
374
+ name: "extract_op",
375
+ describeKind: "derived",
376
+ meta: factMeta("extract")
377
+ }
378
+ );
379
+ graph.add(extractOp, { name: "extract_op" });
380
+ graph.addDisposer((0, import_extra2.keepalive)(extractOp));
381
+ const invalidationDetector = (0, import_core2.node)(
382
+ [...shards],
383
+ (batchData, actions, ctx) => {
384
+ void batchData;
385
+ void ctx;
386
+ const facts = allFacts();
387
+ const index = dependentsIndex.cache;
388
+ const out2 = [];
389
+ const seen = /* @__PURE__ */ new Set();
390
+ for (const f of facts.values()) {
391
+ const obsolete = f.validTo !== void 0;
392
+ if (!obsolete) continue;
393
+ if (processedRoots.has(f.id)) continue;
394
+ const dependents = index.get(f.id) ?? [];
395
+ for (const dep of dependents) {
396
+ const depFact = facts.get(dep);
397
+ if (!depFact || depFact.validTo !== void 0) continue;
398
+ const k = `${f.id}->${dep}`;
399
+ if (seen.has(k)) continue;
400
+ seen.add(k);
401
+ out2.push({
402
+ factId: dep,
403
+ rootFactId: f.id,
404
+ reason: "obsolete",
405
+ iteration: cascadeIteration + 1,
406
+ causalReason: `dependentsIndex[${f.id}] \u2192 ${dep} (obsolete: validTo set)`
407
+ });
408
+ }
409
+ processedRoots.add(f.id);
410
+ }
411
+ if (out2.length === 0) {
412
+ cascadeIteration = 0;
413
+ }
414
+ actions.emit(out2);
415
+ },
416
+ {
417
+ name: "invalidation_detector",
418
+ describeKind: "derived",
419
+ initial: [],
420
+ meta: factMeta("invalidation", { cycle: "cascade" })
421
+ }
422
+ );
423
+ graph.add(invalidationDetector, { name: "invalidation_detector" });
424
+ graph.addDisposer((0, import_extra2.keepalive)(invalidationDetector));
425
+ const cascade = (0, import_core2.node)(
426
+ [invalidationDetector],
427
+ (batchData, actions, ctx) => {
428
+ const evts = lastOf(batchData[0], ctx.prevData[0]) ?? [];
429
+ actions.emit(evts);
430
+ },
431
+ {
432
+ name: "cascade",
433
+ describeKind: "derived",
434
+ initial: [],
435
+ meta: factMeta("cascade_topic", { cycle: "cascade" })
436
+ }
437
+ );
438
+ graph.add(cascade, { name: "cascade" });
439
+ graph.addDisposer((0, import_extra2.keepalive)(cascade));
440
+ const cascadeOverflow = (0, import_core2.node)([], {
441
+ initial: null,
442
+ name: "cascade_overflow",
443
+ describeKind: "state",
444
+ meta: factMeta("cascade_overflow")
445
+ });
446
+ graph.add(cascadeOverflow, { name: "cascade_overflow" });
447
+ graph.addDisposer((0, import_extra2.keepalive)(cascadeOverflow));
448
+ const cascadeProcessor = (0, import_core2.node)(
449
+ [cascade],
450
+ (batchData, actions, ctx) => {
451
+ const evts = lastOf(batchData[0], ctx.prevData[0]) ?? [];
452
+ if (evts.length === 0) {
453
+ actions.emit([]);
454
+ return;
455
+ }
456
+ const byId = /* @__PURE__ */ new Map();
457
+ for (const e of evts) if (!byId.has(e.factId)) byId.set(e.factId, e);
458
+ cascadeIteration += 1;
459
+ if (cascadeIteration > maxIterations) {
460
+ const sample = [...byId.keys()].slice(0, OVERFLOW_SAMPLE_SIZE);
461
+ const rootFactId = evts[0]?.rootFactId ?? "";
462
+ cascadeOverflow.emit({
463
+ droppedCount: byId.size,
464
+ sample,
465
+ rootFactId
466
+ });
467
+ events.append({
468
+ action: "overflow",
469
+ reason: "cascade",
470
+ id: rootFactId,
471
+ t_ns: (0, import_core2.wallClockNs)(),
472
+ seq: bumpCursor(seqCursor)
473
+ });
474
+ actions.emit([]);
475
+ return;
476
+ }
477
+ const now = (0, import_core2.monotonicNs)();
478
+ for (const [id] of byId) {
479
+ replaceFragment(
480
+ id,
481
+ (prev) => prev.validTo !== void 0 ? prev : { ...prev, validTo: BigInt(now) }
482
+ );
483
+ }
484
+ actions.emit([...byId.values()]);
485
+ },
486
+ {
487
+ name: "cascade_processor",
488
+ describeKind: "derived",
489
+ initial: [],
490
+ meta: factMeta("cascade_processor", { cycle: "cascade" })
491
+ }
492
+ );
493
+ graph.add(cascadeProcessor, { name: "cascade_processor" });
494
+ graph.addDisposer((0, import_extra2.keepalive)(cascadeProcessor));
495
+ const review = (0, import_core2.node)(
496
+ [factStore],
497
+ (batchData, actions, ctx) => {
498
+ const fs = lastOf(batchData[0], ctx.prevData[0]);
499
+ if (fs == null) {
500
+ actions.emit(null);
501
+ return;
502
+ }
503
+ for (const f of fs.byId.values()) {
504
+ if (f.confidence < reviewThreshold && f.validTo === void 0) {
505
+ actions.emit({
506
+ factId: f.id,
507
+ confidence: f.confidence,
508
+ threshold: reviewThreshold
509
+ });
510
+ return;
511
+ }
512
+ }
513
+ actions.emit(null);
514
+ },
515
+ {
516
+ name: "review",
517
+ describeKind: "derived",
518
+ initial: null,
519
+ meta: factMeta("review"),
520
+ // F10a: dedupe on the requested factId (null === no request) so a
521
+ // stable low-confidence fact does not re-emit a review every wave.
522
+ equals: (a, b) => (a?.factId ?? null) === (b?.factId ?? null)
523
+ }
524
+ );
525
+ graph.add(review, { name: "review" });
526
+ graph.addDisposer((0, import_extra2.keepalive)(review));
527
+ if (config.outcome) {
528
+ const outcomeProcessor = (0, import_core2.node)(
529
+ config.scoring ? [config.outcome, config.scoring] : [config.outcome],
530
+ (batchData, actions, ctx) => {
531
+ const sig = lastOf(batchData[0], ctx.prevData[0]);
532
+ if (sig == null) {
533
+ actions.emit(null);
534
+ return;
535
+ }
536
+ replaceFragment(sig.factId, (prev) => {
537
+ let nextConf = prev.confidence;
538
+ if (config.scoring) {
539
+ const policy2 = lastOf(batchData[1], ctx.prevData[1]);
540
+ if (policy2) {
541
+ nextConf = policy2(prev, makeReadHandle(allFacts()));
542
+ }
543
+ } else {
544
+ nextConf = Math.max(0, Math.min(1, prev.confidence + sig.reward));
545
+ }
546
+ return { ...prev, confidence: nextConf };
547
+ });
548
+ actions.emit(sig);
549
+ },
550
+ {
551
+ name: "outcome_processor",
552
+ describeKind: "derived",
553
+ initial: null,
554
+ meta: factMeta("outcome")
555
+ }
556
+ );
557
+ graph.add(outcomeProcessor, { name: "outcome_processor" });
558
+ graph.addDisposer((0, import_extra2.keepalive)(outcomeProcessor));
559
+ }
560
+ const answer = (0, import_core2.node)(
561
+ config.query ? [config.query, factStore] : [factStore],
562
+ (batchData, actions, ctx) => {
563
+ if (!config.query) {
564
+ actions.emit(null);
565
+ return;
566
+ }
567
+ const q = lastOf(batchData[0], ctx.prevData[0]);
568
+ const fs = lastOf(batchData[1], ctx.prevData[1]);
569
+ if (q == null) {
570
+ actions.emit(null);
571
+ return;
572
+ }
573
+ const store = fs ?? emptyStore();
574
+ let results = [...store.byId.values()].filter((f) => {
575
+ if (q.tags && q.tags.length > 0 && !q.tags.some((t) => f.tags.includes(t))) {
576
+ return false;
577
+ }
578
+ if (q.minConfidence !== void 0 && f.confidence < q.minConfidence) return false;
579
+ if (!currentlyValid(f, q.asOf)) return false;
580
+ return true;
581
+ });
582
+ results.sort((a, b) => b.confidence - a.confidence || Number(b.t_ns - a.t_ns));
583
+ if (q.limit !== void 0) results = results.slice(0, Math.max(0, q.limit));
584
+ actions.emit({ query: q, results });
585
+ },
586
+ {
587
+ name: "answer",
588
+ describeKind: "derived",
589
+ initial: null,
590
+ meta: factMeta("query", { role: "output" })
591
+ }
592
+ );
593
+ graph.add(answer, { name: "answer" });
594
+ graph.addDisposer((0, import_extra2.keepalive)(answer));
595
+ const consolidated = (0, import_core2.node)(
596
+ config.consolidateTrigger ? [config.consolidateTrigger] : [],
597
+ (batchData, actions, ctx) => {
598
+ void batchData;
599
+ void ctx;
600
+ if (!config.consolidateTrigger || !config.consolidate) {
601
+ actions.emit([]);
602
+ return;
603
+ }
604
+ const fragments = config.consolidate(makeReadHandle(allFacts()));
605
+ for (const f of fragments) {
606
+ const deps = config.extractDependencies(f);
607
+ processedRoots.delete(f.id);
608
+ commitFragment(f);
609
+ indexFragment(f, deps);
610
+ events.append({
611
+ action: "consolidate",
612
+ id: f.id,
613
+ t_ns: (0, import_core2.wallClockNs)(),
614
+ seq: bumpCursor(seqCursor)
615
+ });
616
+ }
617
+ actions.emit(fragments);
618
+ },
619
+ {
620
+ name: "consolidated",
621
+ describeKind: "derived",
622
+ initial: [],
623
+ meta: factMeta("consolidator")
624
+ }
625
+ );
626
+ graph.add(consolidated, { name: "consolidated" });
627
+ graph.addDisposer((0, import_extra2.keepalive)(consolidated));
628
+ const ingestAudit = (0, import_core2.node)(
629
+ [extractOp],
630
+ (batchData, actions, ctx) => {
631
+ const f = lastOf(batchData[0], ctx.prevData[0]);
632
+ if (f != null) {
633
+ events.append({
634
+ action: "ingest",
635
+ id: f.id,
636
+ t_ns: (0, import_core2.wallClockNs)(),
637
+ seq: bumpCursor(seqCursor)
638
+ });
639
+ }
640
+ actions.emit(f ?? null);
641
+ },
642
+ {
643
+ name: "_ingest_audit",
644
+ describeKind: "derived",
645
+ initial: null,
646
+ meta: factMeta("audit")
647
+ }
648
+ );
649
+ graph.add(ingestAudit, { name: "_ingest_audit" });
650
+ graph.addDisposer((0, import_extra2.keepalive)(ingestAudit));
651
+ function itemNode(id) {
652
+ return (0, import_core2.node)(
653
+ [factStore],
654
+ (batchData, actions, ctx) => {
655
+ const fs = lastOf(batchData[0], ctx.prevData[0]);
656
+ actions.emit(fs?.byId.get(id));
657
+ },
658
+ {
659
+ name: `item_${id}`,
660
+ describeKind: "derived",
661
+ meta: factMeta("item")
662
+ }
663
+ );
664
+ }
665
+ const out = Object.assign(graph, {
666
+ shards,
667
+ factStore,
668
+ dependentsIndex,
669
+ answer,
670
+ cascade,
671
+ cascadeOverflow,
672
+ review,
673
+ consolidated,
674
+ events,
675
+ itemNode
676
+ });
677
+ return out;
678
+ }
679
+
680
+ // src/utils/memory/index.ts
681
+ var NS_PER_SEC = 1e9;
682
+ function memoryMeta(kind, extra) {
683
+ return domainMeta("memory", kind, extra);
684
+ }
685
+ function toNode(v, name) {
686
+ if (v instanceof import_core3.NodeImpl) return v;
687
+ return (0, import_core3.node)([], { initial: v, ...name ? { name } : void 0 });
688
+ }
689
+ function ageSeconds(now, lastNs) {
690
+ return (now - lastNs) / NS_PER_SEC;
691
+ }
692
+ function cosineSimilarity(a, b) {
693
+ const n = Math.max(a.length, b.length);
694
+ let dot = 0;
695
+ let na = 0;
696
+ let nb = 0;
697
+ for (let i = 0; i < n; i += 1) {
698
+ const av = a[i] ?? 0;
699
+ const bv = b[i] ?? 0;
700
+ dot += av * bv;
701
+ na += av * av;
702
+ nb += bv * bv;
703
+ }
704
+ if (na === 0 || nb === 0) return 0;
705
+ const score = dot / Math.sqrt(na * nb);
706
+ return Number.isFinite(score) ? score : 0;
707
+ }
708
+ function searchResultsEqual(a, b) {
709
+ if (a === b) return true;
710
+ if (a == null || b == null) return false;
711
+ if (a.length !== b.length) return false;
712
+ for (let i = 0; i < a.length; i += 1) {
713
+ const x = a[i];
714
+ const y = b[i];
715
+ if (x.id !== y.id || x.score !== y.score || x.meta !== y.meta) return false;
716
+ }
717
+ return true;
718
+ }
719
+ function rankedEqual(a, b) {
720
+ if (a === b) return true;
721
+ if (a == null || b == null) return false;
722
+ if (a.length !== b.length) return false;
723
+ for (let i = 0; i < a.length; i += 1) {
724
+ const x = a[i];
725
+ const y = b[i];
726
+ if (x.id !== y.id || x.score !== y.score || x.lastAccessNs !== y.lastAccessNs || x.value !== y.value)
727
+ return false;
728
+ }
729
+ return true;
730
+ }
731
+ function collection(name, opts = {}) {
732
+ const maxSize = opts.maxSize;
733
+ const ranked = opts.ranked ?? true;
734
+ const decayRate = ranked ? opts.decayRate ?? 0 : 0;
735
+ const minScore = opts.minScore ?? 0;
736
+ if (maxSize !== void 0 && maxSize < 1) {
737
+ throw new RangeError("collection: maxSize must be >= 1");
738
+ }
739
+ const scoreFnDefault = () => ranked ? 1 : 0;
740
+ const scoreInput = opts.score ?? scoreFnDefault;
741
+ const scoreNode = ranked && scoreInput instanceof import_core3.NodeImpl ? scoreInput : void 0;
742
+ const readScoreFn = () => {
743
+ if (scoreNode) return scoreNode.cache ?? scoreFnDefault;
744
+ return scoreInput;
745
+ };
746
+ const graph = new import_graph3.Graph(name);
747
+ const retentionScore = (_k, v) => ranked ? decay(v.baseScore, ageSeconds((0, import_core3.monotonicNs)(), v.lastAccessNs), decayRate, minScore) : v.lastAccessNs;
748
+ const items = (0, import_extra3.reactiveMap)({
749
+ name: "items",
750
+ ...maxSize !== void 0 ? { retention: { score: retentionScore, maxSize } } : {}
751
+ });
752
+ graph.add(items.entries, { name: "items" });
753
+ let refreshTick;
754
+ if (ranked && decayRate > 0) {
755
+ const intervalMs = opts.refreshIntervalMs ?? Math.max(1, 1e3 * Math.LN2 / (10 * decayRate));
756
+ const tickCounter = (0, import_extra3.fromTimer)(intervalMs, { period: intervalMs });
757
+ refreshTick = (0, import_core3.node)(
758
+ [tickCounter],
759
+ (_batchData, actions) => {
760
+ actions.emit((0, import_core3.monotonicNs)());
761
+ },
762
+ {
763
+ name: "refresh_tick_ns",
764
+ describeKind: "derived",
765
+ initial: (0, import_core3.monotonicNs)(),
766
+ meta: memoryMeta("clock")
767
+ }
768
+ );
769
+ graph.add(refreshTick, { name: "refresh_tick_ns" });
770
+ }
771
+ let rankedNode;
772
+ if (ranked) {
773
+ const rankedDeps = [items.entries];
774
+ if (refreshTick) rankedDeps.push(refreshTick);
775
+ if (scoreNode) rankedDeps.push(scoreNode);
776
+ rankedNode = (0, import_core3.node)(
777
+ rankedDeps,
778
+ (batchData, actions, ctx) => {
779
+ const values = batchData.map(
780
+ (batch2, i) => batch2 != null && batch2.length > 0 ? batch2.at(-1) : ctx.prevData[i]
781
+ );
782
+ const snapshot = values[0];
783
+ let now;
784
+ if (refreshTick) {
785
+ const tickValue = values[1];
786
+ now = typeof tickValue === "number" ? tickValue : (0, import_core3.monotonicNs)();
787
+ } else {
788
+ now = (0, import_core3.monotonicNs)();
789
+ }
790
+ if (!snapshot || snapshot.size === 0) {
791
+ actions.emit([]);
792
+ return;
793
+ }
794
+ const out2 = [];
795
+ for (const entry of snapshot.values()) {
796
+ out2.push({
797
+ ...entry,
798
+ score: decay(entry.baseScore, ageSeconds(now, entry.lastAccessNs), decayRate, minScore)
799
+ });
800
+ }
801
+ out2.sort((a, b) => b.score - a.score || b.lastAccessNs - a.lastAccessNs);
802
+ actions.emit(out2);
803
+ },
804
+ {
805
+ name: "ranked",
806
+ describeKind: "derived",
807
+ equals: rankedEqual,
808
+ meta: memoryMeta("ranked")
809
+ }
810
+ );
811
+ graph.add(rankedNode, { name: "ranked" });
812
+ } else {
813
+ rankedNode = (0, import_core3.node)([], {
814
+ initial: [],
815
+ name: "ranked",
816
+ describeKind: "state",
817
+ meta: memoryMeta("ranked_disabled")
818
+ });
819
+ graph.add(rankedNode, { name: "ranked" });
820
+ }
821
+ const size = (0, import_core3.node)(
822
+ [items.entries],
823
+ (batchData, actions, ctx) => {
824
+ const data = batchData.map(
825
+ (batch2, i) => batch2 != null && batch2.length > 0 ? batch2.at(-1) : ctx.prevData[i]
826
+ );
827
+ const snapshot = data[0];
828
+ actions.emit((snapshot ?? /* @__PURE__ */ new Map()).size);
829
+ },
830
+ {
831
+ name: "size",
832
+ describeKind: "derived",
833
+ initial: 0,
834
+ meta: memoryMeta("size")
835
+ }
836
+ );
837
+ graph.add(size, { name: "size" });
838
+ graph.addDisposer((0, import_extra3.keepalive)(size));
839
+ const events = createAuditLog({
840
+ name: "events",
841
+ retainedLimit: 1024,
842
+ graph
843
+ });
844
+ const seqCursor = registerCursor(graph, "seq", 0);
845
+ const upsertImpl = (id, value, _opts) => {
846
+ const now = (0, import_core3.monotonicNs)();
847
+ const prev = items.get(id);
848
+ const baseScore = _opts?.score ?? readScoreFn()(value);
849
+ items.set(id, {
850
+ id,
851
+ value,
852
+ baseScore,
853
+ createdAtNs: prev?.createdAtNs ?? now,
854
+ lastAccessNs: now
855
+ });
856
+ };
857
+ const removeImpl = (id) => {
858
+ if (!items.has(id)) return;
859
+ items.delete(id);
860
+ };
861
+ const clearImpl = () => {
862
+ if (items.size === 0) return;
863
+ items.clear();
864
+ };
865
+ const rescoreImpl = () => {
866
+ if (!ranked) return;
867
+ const fn = readScoreFn();
868
+ const snapshot = items.entries.cache;
869
+ if (!snapshot || snapshot.size === 0) return;
870
+ const updates = [];
871
+ for (const entry of snapshot.values()) {
872
+ updates.push([entry.id, { ...entry, baseScore: fn(entry.value) }]);
873
+ }
874
+ items.setMany(updates);
875
+ };
876
+ const upsert = mutate(upsertImpl, {
877
+ frame: "inline",
878
+ log: events,
879
+ seq: seqCursor,
880
+ onSuccessRecord: ([id], _r, m) => ({ action: "upsert", id, t_ns: m.t_ns, seq: m.seq })
881
+ });
882
+ const remove = mutate(removeImpl, {
883
+ frame: "inline",
884
+ log: events,
885
+ seq: seqCursor,
886
+ onSuccessRecord: ([id], _r, m) => ({ action: "remove", id, t_ns: m.t_ns, seq: m.seq })
887
+ });
888
+ const clear = mutate(clearImpl, {
889
+ frame: "inline",
890
+ log: events,
891
+ seq: seqCursor,
892
+ onSuccessRecord: (_args, _r, m) => ({ action: "clear", t_ns: m.t_ns, seq: m.seq })
893
+ });
894
+ const rescore = mutate(rescoreImpl, {
895
+ frame: "inline",
896
+ log: events,
897
+ seq: seqCursor,
898
+ onSuccessRecord: (_args, _r, m) => ({ action: "rescore", t_ns: m.t_ns, seq: m.seq })
899
+ });
900
+ function itemNode(id) {
901
+ const idN = toNode(id, "id");
902
+ return (0, import_core3.node)(
903
+ [items.entries, idN],
904
+ (batchData, actions, ctx) => {
905
+ const data = batchData.map(
906
+ (batch2, i) => batch2 != null && batch2.length > 0 ? batch2.at(-1) : ctx.prevData[i]
907
+ );
908
+ const map = data[0];
909
+ const key = data[1];
910
+ actions.emit(map?.get(key));
911
+ },
912
+ {
913
+ describeKind: "derived",
914
+ meta: memoryMeta("collection_item")
915
+ }
916
+ );
917
+ }
918
+ function hasNode(id) {
919
+ const idN = toNode(id, "id");
920
+ return (0, import_core3.node)(
921
+ [items.entries, idN],
922
+ (batchData, actions, ctx) => {
923
+ const data = batchData.map(
924
+ (batch2, i) => batch2 != null && batch2.length > 0 ? batch2.at(-1) : ctx.prevData[i]
925
+ );
926
+ const map = data[0];
927
+ const key = data[1];
928
+ actions.emit(map?.has(key) ?? false);
929
+ },
930
+ {
931
+ describeKind: "derived",
932
+ meta: memoryMeta("collection_has")
933
+ }
934
+ );
935
+ }
936
+ const out = Object.assign(graph, {
937
+ events,
938
+ items: items.entries,
939
+ ranked: rankedNode,
940
+ size,
941
+ upsert,
942
+ remove,
943
+ clear,
944
+ rescore,
945
+ itemNode,
946
+ hasNode
947
+ });
948
+ return out;
949
+ }
950
+ function vectorIndex(opts = {}) {
951
+ const backend = opts.backend ?? "flat";
952
+ const dimension = opts.dimension;
953
+ const strictDimension = opts.strictDimension ?? true;
954
+ const maxSize = opts.maxSize;
955
+ const userRetentionScore = opts.retentionScore;
956
+ let hnsw;
957
+ if (backend === "hnsw") {
958
+ hnsw = opts.hnswFactory?.();
959
+ if (!hnsw) {
960
+ throw new Error(
961
+ 'vectorIndex backend "hnsw" requires an optional dependency adapter; install your HNSW package and provide `hnswFactory`.'
962
+ );
963
+ }
964
+ }
965
+ const graph = new import_graph3.Graph(opts.name ?? "vector_index");
966
+ let inferredDimension;
967
+ function assertDimension(vector) {
968
+ if (dimension !== void 0) {
969
+ if (vector.length !== dimension) {
970
+ throw new RangeError(
971
+ `vector dimension mismatch: expected ${dimension}, got ${vector.length}`
972
+ );
973
+ }
974
+ return;
975
+ }
976
+ if (!strictDimension) return;
977
+ if (inferredDimension === void 0) {
978
+ inferredDimension = vector.length;
979
+ return;
980
+ }
981
+ if (vector.length !== inferredDimension) {
982
+ throw new RangeError(
983
+ `vector dimension mismatch: inferred ${inferredDimension} from first upsert, got ${vector.length}. Pass \`strictDimension: false\` to opt into zero-pad behavior, or set an explicit \`dimension\`.`
984
+ );
985
+ }
986
+ }
987
+ const baseRetentionScore = userRetentionScore ?? ((r) => r.upsertedAtNs);
988
+ let clearInProgress = false;
989
+ const events = createAuditLog({
990
+ name: "events",
991
+ retainedLimit: 1024,
992
+ graph
993
+ });
994
+ const seqCursor = registerCursor(graph, "seq", 0);
995
+ const entries = (0, import_extra3.reactiveMap)({
996
+ name: "entries",
997
+ ...maxSize !== void 0 ? {
998
+ retention: {
999
+ score: (_k, v) => baseRetentionScore(v),
1000
+ maxSize,
1001
+ onArchive: (key) => {
1002
+ if (clearInProgress) return;
1003
+ if (backend === "hnsw") hnsw.remove(key);
1004
+ events.append({
1005
+ action: "evict",
1006
+ id: key,
1007
+ t_ns: (0, import_core3.wallClockNs)(),
1008
+ seq: bumpCursor(seqCursor)
1009
+ });
1010
+ }
1011
+ }
1012
+ } : {}
1013
+ });
1014
+ graph.add(entries.entries, { name: "entries" });
1015
+ graph.addDisposer((0, import_extra3.keepalive)(entries.entries));
1016
+ if (hnsw?.dispose) {
1017
+ const disposeAdapter = hnsw.dispose.bind(hnsw);
1018
+ graph.addDisposer(() => disposeAdapter());
1019
+ }
1020
+ const upsertImpl = (id, vector, meta) => {
1021
+ assertDimension(vector);
1022
+ if (backend === "hnsw") hnsw.upsert(id, vector, meta);
1023
+ const copiedMeta = (() => {
1024
+ if (meta === void 0) return void 0;
1025
+ if (meta === null || typeof meta !== "object") return meta;
1026
+ return Array.isArray(meta) ? [...meta] : { ...meta };
1027
+ })();
1028
+ const record = {
1029
+ id,
1030
+ vector: [...vector],
1031
+ ...copiedMeta !== void 0 ? { meta: copiedMeta } : {},
1032
+ upsertedAtNs: (0, import_core3.monotonicNs)()
1033
+ };
1034
+ entries.set(id, record);
1035
+ };
1036
+ const removeImpl = (id) => {
1037
+ if (!entries.has(id)) return;
1038
+ if (backend === "hnsw") hnsw.remove(id);
1039
+ entries.delete(id);
1040
+ };
1041
+ const clearImpl = () => {
1042
+ if (entries.size === 0) return;
1043
+ clearInProgress = true;
1044
+ try {
1045
+ entries.clear();
1046
+ if (backend === "hnsw") hnsw.clear();
1047
+ } finally {
1048
+ clearInProgress = false;
1049
+ }
1050
+ inferredDimension = void 0;
1051
+ };
1052
+ const reindexImpl = () => {
1053
+ if (backend !== "hnsw") return;
1054
+ const snapshot = entries.entries.cache;
1055
+ if (!snapshot) return;
1056
+ hnsw.clear();
1057
+ for (const r of snapshot.values()) {
1058
+ hnsw.upsert(r.id, r.vector, r.meta);
1059
+ }
1060
+ };
1061
+ const upsert = mutate(upsertImpl, {
1062
+ frame: "inline",
1063
+ log: events,
1064
+ freeze: false,
1065
+ seq: seqCursor,
1066
+ onSuccessRecord: ([id], _r, m) => ({ action: "upsert", id, t_ns: m.t_ns, seq: m.seq })
1067
+ });
1068
+ const remove = mutate(removeImpl, {
1069
+ frame: "inline",
1070
+ log: events,
1071
+ seq: seqCursor,
1072
+ onSuccessRecord: ([id], _r, m) => ({ action: "remove", id, t_ns: m.t_ns, seq: m.seq })
1073
+ });
1074
+ const clear = mutate(clearImpl, {
1075
+ frame: "inline",
1076
+ log: events,
1077
+ seq: seqCursor,
1078
+ onSuccessRecord: (_args, _r, m) => ({ action: "clear", t_ns: m.t_ns, seq: m.seq })
1079
+ });
1080
+ const reindex = mutate(reindexImpl, {
1081
+ frame: "inline",
1082
+ log: events,
1083
+ seq: seqCursor,
1084
+ onSuccessRecord: (_args, _r, m) => ({ action: "reindex", t_ns: m.t_ns, seq: m.seq })
1085
+ });
1086
+ function searchNode(query, k = 5) {
1087
+ const kN = toNode(k, "k");
1088
+ return (0, import_core3.node)(
1089
+ [entries.entries, query, kN],
1090
+ (batchData, actions, ctx) => {
1091
+ const values = batchData.map(
1092
+ (batch2, i) => batch2 != null && batch2.length > 0 ? batch2.at(-1) : ctx.prevData[i]
1093
+ );
1094
+ const snapshot = values[0];
1095
+ const q = values[1];
1096
+ const kRaw = values[2];
1097
+ const kVal = Number.isFinite(kRaw) ? Math.max(0, Math.floor(kRaw)) : 0;
1098
+ if (!snapshot || snapshot.size === 0 || kVal <= 0) {
1099
+ actions.emit([]);
1100
+ return;
1101
+ }
1102
+ if (q == null || q.length === 0) {
1103
+ actions.emit([]);
1104
+ return;
1105
+ }
1106
+ const expectedDim = dimension ?? (strictDimension ? inferredDimension : void 0);
1107
+ if (expectedDim !== void 0 && q.length !== expectedDim) {
1108
+ actions.emit([]);
1109
+ return;
1110
+ }
1111
+ if (backend === "hnsw") {
1112
+ const adapterResults = hnsw.search(q, kVal);
1113
+ actions.emit([...adapterResults]);
1114
+ return;
1115
+ }
1116
+ const ranked = [...snapshot.values()].map((row) => {
1117
+ const result = {
1118
+ id: row.id,
1119
+ score: cosineSimilarity(q, row.vector),
1120
+ ...row.meta !== void 0 ? { meta: row.meta } : {}
1121
+ };
1122
+ return result;
1123
+ }).sort((a, b) => b.score - a.score).slice(0, kVal);
1124
+ actions.emit(ranked);
1125
+ },
1126
+ {
1127
+ describeKind: "derived",
1128
+ // A1: include `score` in equality. The previous id-only
1129
+ // comparator suppressed re-emissions when the same set of
1130
+ // IDs/order had different scores (re-upsert with new
1131
+ // vector; query change preserving ranking order).
1132
+ equals: (a, b) => searchResultsEqual(a, b),
1133
+ meta: memoryMeta("vector_search")
1134
+ }
1135
+ );
1136
+ }
1137
+ const out = Object.assign(graph, {
1138
+ backend,
1139
+ events,
1140
+ entries: entries.entries,
1141
+ upsert,
1142
+ remove,
1143
+ clear,
1144
+ reindex,
1145
+ searchNode
1146
+ });
1147
+ return out;
1148
+ }
1149
+ var TRIPLE_SEP = "\0";
1150
+ function tripleKey(from, to, relation) {
1151
+ return `${from}${TRIPLE_SEP}${to}${TRIPLE_SEP}${relation}`;
1152
+ }
1153
+ function buildAdjacency(edges, side) {
1154
+ if (!edges || edges.size === 0) return /* @__PURE__ */ new Map();
1155
+ const buckets = /* @__PURE__ */ new Map();
1156
+ for (const edge of edges.values()) {
1157
+ const key = side === "from" ? edge.from : edge.to;
1158
+ let bucket = buckets.get(key);
1159
+ if (!bucket) {
1160
+ bucket = [];
1161
+ buckets.set(key, bucket);
1162
+ }
1163
+ bucket.push(edge);
1164
+ }
1165
+ const out = /* @__PURE__ */ new Map();
1166
+ for (const [key, bucket] of buckets) out.set(key, Object.freeze(bucket));
1167
+ return out;
1168
+ }
1169
+ function adjacencyEqual(a, b) {
1170
+ if (a === b) return true;
1171
+ if (a == null || b == null) return false;
1172
+ if (a.size !== b.size) return false;
1173
+ for (const [k, av] of a) {
1174
+ const bv = b.get(k);
1175
+ if (!bv || av.length !== bv.length) return false;
1176
+ for (let i = 0; i < av.length; i += 1) {
1177
+ const ae = av[i];
1178
+ const be = bv[i];
1179
+ if (ae.from !== be.from || ae.to !== be.to || ae.relation !== be.relation || ae.weight !== be.weight)
1180
+ return false;
1181
+ }
1182
+ }
1183
+ return true;
1184
+ }
1185
+ function knowledgeGraph(name, opts = {}) {
1186
+ const orphanGC = opts.orphanGC ?? "keep";
1187
+ if (opts.entitiesMaxSize !== void 0 && opts.entitiesMaxSize < 1) {
1188
+ throw new RangeError("knowledgeGraph: entitiesMaxSize must be >= 1");
1189
+ }
1190
+ if (opts.edgesMaxSize !== void 0 && opts.edgesMaxSize < 1) {
1191
+ throw new RangeError("knowledgeGraph: edgesMaxSize must be >= 1");
1192
+ }
1193
+ const graph = new import_graph3.Graph(name);
1194
+ const entitiesMap = (0, import_extra3.reactiveMap)({
1195
+ name: "entities",
1196
+ ...opts.entitiesMaxSize !== void 0 ? { maxSize: opts.entitiesMaxSize } : {}
1197
+ });
1198
+ const edgesMap = (0, import_extra3.reactiveMap)({
1199
+ name: "edges",
1200
+ ...opts.edgesMaxSize !== void 0 ? { maxSize: opts.edgesMaxSize } : {}
1201
+ });
1202
+ graph.add(entitiesMap.entries, { name: "entities" });
1203
+ graph.add(edgesMap.entries, { name: "edges" });
1204
+ const adjacencyOut = (0, import_core3.node)(
1205
+ [edgesMap.entries],
1206
+ (batchData, actions, ctx) => {
1207
+ const data = batchData.map(
1208
+ (batch2, i) => batch2 != null && batch2.length > 0 ? batch2.at(-1) : ctx.prevData[i]
1209
+ );
1210
+ const snapshot = data[0];
1211
+ actions.emit(buildAdjacency(snapshot, "from"));
1212
+ },
1213
+ {
1214
+ name: "adjacencyOut",
1215
+ describeKind: "derived",
1216
+ initial: /* @__PURE__ */ new Map(),
1217
+ equals: adjacencyEqual,
1218
+ meta: memoryMeta("adjacency_out")
1219
+ }
1220
+ );
1221
+ const adjacencyIn = (0, import_core3.node)(
1222
+ [edgesMap.entries],
1223
+ (batchData, actions, ctx) => {
1224
+ const data = batchData.map(
1225
+ (batch2, i) => batch2 != null && batch2.length > 0 ? batch2.at(-1) : ctx.prevData[i]
1226
+ );
1227
+ const snapshot = data[0];
1228
+ actions.emit(buildAdjacency(snapshot, "to"));
1229
+ },
1230
+ {
1231
+ name: "adjacencyIn",
1232
+ describeKind: "derived",
1233
+ initial: /* @__PURE__ */ new Map(),
1234
+ equals: adjacencyEqual,
1235
+ meta: memoryMeta("adjacency_in")
1236
+ }
1237
+ );
1238
+ graph.add(adjacencyOut, { name: "adjacencyOut" });
1239
+ graph.add(adjacencyIn, { name: "adjacencyIn" });
1240
+ graph.addDisposer((0, import_extra3.keepalive)(adjacencyOut));
1241
+ graph.addDisposer((0, import_extra3.keepalive)(adjacencyIn));
1242
+ const entityCount = (0, import_core3.node)(
1243
+ [entitiesMap.entries],
1244
+ (batchData, actions, ctx) => {
1245
+ const data = batchData.map(
1246
+ (batch2, i) => batch2 != null && batch2.length > 0 ? batch2.at(-1) : ctx.prevData[i]
1247
+ );
1248
+ const m = data[0];
1249
+ actions.emit((m ?? /* @__PURE__ */ new Map()).size);
1250
+ },
1251
+ { name: "entityCount", describeKind: "derived", initial: 0, meta: memoryMeta("entity_count") }
1252
+ );
1253
+ const edgeCount = (0, import_core3.node)(
1254
+ [edgesMap.entries],
1255
+ (batchData, actions, ctx) => {
1256
+ const data = batchData.map(
1257
+ (batch2, i) => batch2 != null && batch2.length > 0 ? batch2.at(-1) : ctx.prevData[i]
1258
+ );
1259
+ const m = data[0];
1260
+ actions.emit((m ?? /* @__PURE__ */ new Map()).size);
1261
+ },
1262
+ { name: "edgeCount", describeKind: "derived", initial: 0, meta: memoryMeta("edge_count") }
1263
+ );
1264
+ graph.add(entityCount, { name: "entityCount" });
1265
+ graph.add(edgeCount, { name: "edgeCount" });
1266
+ graph.addDisposer((0, import_extra3.keepalive)(entityCount));
1267
+ graph.addDisposer((0, import_extra3.keepalive)(edgeCount));
1268
+ const events = createAuditLog({
1269
+ name: "events",
1270
+ retainedLimit: 1024,
1271
+ graph
1272
+ });
1273
+ const seqCursor = registerCursor(graph, "seq", 0);
1274
+ function entityHasReferences(id) {
1275
+ const out2 = adjacencyOut.cache;
1276
+ const inb = adjacencyIn.cache;
1277
+ if ((out2?.get(id)?.length ?? 0) > 0) return true;
1278
+ if ((inb?.get(id)?.length ?? 0) > 0) return true;
1279
+ return false;
1280
+ }
1281
+ function applyOrphanGC(candidates) {
1282
+ if (orphanGC !== "remove") return;
1283
+ for (const candidate of candidates) {
1284
+ if (!entitiesMap.has(candidate)) continue;
1285
+ if (entityHasReferences(candidate)) continue;
1286
+ entitiesMap.delete(candidate);
1287
+ events.append({
1288
+ action: "orphanRemove",
1289
+ id: candidate,
1290
+ t_ns: (0, import_core3.wallClockNs)(),
1291
+ seq: bumpCursor(seqCursor)
1292
+ });
1293
+ }
1294
+ }
1295
+ const upsertEntityImpl = (id, value) => {
1296
+ entitiesMap.set(id, value);
1297
+ };
1298
+ const removeEntityImpl = (id) => {
1299
+ const snapshot = edgesMap.entries.cache;
1300
+ const cascadedNeighbors = /* @__PURE__ */ new Set();
1301
+ if (snapshot) {
1302
+ const toDrop = [];
1303
+ for (const [key, edge] of snapshot) {
1304
+ if (edge.from === id || edge.to === id) {
1305
+ toDrop.push(key);
1306
+ if (edge.from !== id) cascadedNeighbors.add(edge.from);
1307
+ if (edge.to !== id) cascadedNeighbors.add(edge.to);
1308
+ }
1309
+ }
1310
+ if (toDrop.length > 0) edgesMap.deleteMany(toDrop);
1311
+ }
1312
+ if (entitiesMap.has(id)) entitiesMap.delete(id);
1313
+ applyOrphanGC([...cascadedNeighbors]);
1314
+ };
1315
+ const linkImpl = (from, to, relation, weight = 1) => {
1316
+ edgesMap.set(tripleKey(from, to, relation), { from, to, relation, weight });
1317
+ };
1318
+ const unlinkImpl = (from, to, relation) => {
1319
+ if (relation !== void 0) {
1320
+ edgesMap.delete(tripleKey(from, to, relation));
1321
+ } else {
1322
+ const snapshot = edgesMap.entries.cache;
1323
+ if (!snapshot) return;
1324
+ const toDrop = [];
1325
+ for (const [key, edge] of snapshot) {
1326
+ if (edge.from === from && edge.to === to) toDrop.push(key);
1327
+ }
1328
+ if (toDrop.length > 0) edgesMap.deleteMany(toDrop);
1329
+ }
1330
+ applyOrphanGC([from, to]);
1331
+ };
1332
+ const upsertEntity = mutate(upsertEntityImpl, {
1333
+ frame: "inline",
1334
+ log: events,
1335
+ seq: seqCursor,
1336
+ onSuccessRecord: ([id], _r, m) => ({
1337
+ action: "upsertEntity",
1338
+ id,
1339
+ t_ns: m.t_ns,
1340
+ seq: m.seq
1341
+ })
1342
+ });
1343
+ const removeEntity = mutate(removeEntityImpl, {
1344
+ frame: "inline",
1345
+ log: events,
1346
+ seq: seqCursor,
1347
+ onSuccessRecord: ([id], _r, m) => ({
1348
+ action: "removeEntity",
1349
+ id,
1350
+ t_ns: m.t_ns,
1351
+ seq: m.seq
1352
+ })
1353
+ });
1354
+ const link = mutate(linkImpl, {
1355
+ frame: "inline",
1356
+ log: events,
1357
+ seq: seqCursor,
1358
+ onSuccessRecord: ([from, to, relation, weight], _r, m) => ({
1359
+ action: "link",
1360
+ from,
1361
+ to,
1362
+ relation,
1363
+ weight: weight ?? 1,
1364
+ t_ns: m.t_ns,
1365
+ seq: m.seq
1366
+ })
1367
+ });
1368
+ const unlink = mutate(unlinkImpl, {
1369
+ frame: "inline",
1370
+ log: events,
1371
+ seq: seqCursor,
1372
+ onSuccessRecord: ([from, to, relation], _r, m) => ({
1373
+ action: "unlink",
1374
+ from,
1375
+ to,
1376
+ ...relation !== void 0 ? { relation } : {},
1377
+ t_ns: m.t_ns,
1378
+ seq: m.seq
1379
+ })
1380
+ });
1381
+ function relatedNode(id, relation) {
1382
+ const idN = toNode(id, "id");
1383
+ const relN = relation !== void 0 ? toNode(relation, "relation") : void 0;
1384
+ const deps = relN ? [adjacencyOut, adjacencyIn, idN, relN] : [adjacencyOut, adjacencyIn, idN];
1385
+ return (0, import_core3.node)(
1386
+ deps,
1387
+ (batchData, actions, ctx) => {
1388
+ const values = batchData.map(
1389
+ (batch2, i) => batch2 != null && batch2.length > 0 ? batch2.at(-1) : ctx.prevData[i]
1390
+ );
1391
+ const out2 = values[0];
1392
+ const inb = values[1];
1393
+ const key = values[2];
1394
+ const rel = relN ? values[3] : void 0;
1395
+ const outE = out2?.get(key) ?? [];
1396
+ const inE = inb?.get(key) ?? [];
1397
+ const seen = /* @__PURE__ */ new Set();
1398
+ const acc = [];
1399
+ for (const edge of outE) {
1400
+ const k = tripleKey(edge.from, edge.to, edge.relation);
1401
+ if (seen.has(k)) continue;
1402
+ if (rel !== void 0 && edge.relation !== rel) continue;
1403
+ seen.add(k);
1404
+ acc.push(edge);
1405
+ }
1406
+ for (const edge of inE) {
1407
+ const k = tripleKey(edge.from, edge.to, edge.relation);
1408
+ if (seen.has(k)) continue;
1409
+ if (rel !== void 0 && edge.relation !== rel) continue;
1410
+ seen.add(k);
1411
+ acc.push(edge);
1412
+ }
1413
+ actions.emit(acc);
1414
+ },
1415
+ {
1416
+ describeKind: "derived",
1417
+ equals: (a, b) => {
1418
+ const av = a;
1419
+ const bv = b;
1420
+ if (av === bv) return true;
1421
+ if (av == null || bv == null) return false;
1422
+ if (av.length !== bv.length) return false;
1423
+ for (let i = 0; i < av.length; i += 1) {
1424
+ const x = av[i];
1425
+ const y = bv[i];
1426
+ if (x.from !== y.from || x.to !== y.to || x.relation !== y.relation || x.weight !== y.weight)
1427
+ return false;
1428
+ }
1429
+ return true;
1430
+ },
1431
+ meta: memoryMeta("related")
1432
+ }
1433
+ );
1434
+ }
1435
+ const out = Object.assign(graph, {
1436
+ events,
1437
+ entities: entitiesMap.entries,
1438
+ edges: edgesMap.entries,
1439
+ adjacencyOut,
1440
+ adjacencyIn,
1441
+ entityCount,
1442
+ edgeCount,
1443
+ upsertEntity,
1444
+ removeEntity,
1445
+ link,
1446
+ unlink,
1447
+ relatedNode
1448
+ });
1449
+ return out;
1450
+ }
1451
+ //# sourceMappingURL=index.cjs.map