@graphrefly/graphrefly 0.27.0 → 0.28.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 (428) hide show
  1. package/dist/backoff-HPZMEZNF.js +1 -0
  2. package/dist/cascading-B-5zmAUv.d.cts +180 -0
  3. package/dist/cascading-D9WG1-9L.d.ts +180 -0
  4. package/dist/chunk-2FOAM3OR.js +1 -0
  5. package/dist/chunk-2PMCKKRK.js +1 -0
  6. package/dist/chunk-3JXNEPCD.js +2 -0
  7. package/dist/chunk-3R5HFPX7.js +78 -0
  8. package/dist/chunk-4GKB4OUJ.js +1 -0
  9. package/dist/chunk-4VVTGLXJ.js +1 -0
  10. package/dist/chunk-5QDBSZBV.js +1 -0
  11. package/dist/chunk-6QZNQS5B.js +1 -0
  12. package/dist/chunk-6V3SEX2I.js +1 -0
  13. package/dist/chunk-76A3HVQE.js +9 -0
  14. package/dist/chunk-7H6LGFUG.js +64 -0
  15. package/dist/chunk-CK2E7BTU.js +1 -0
  16. package/dist/chunk-CKCSDI7T.js +6 -0
  17. package/dist/chunk-CRXTH3SH.js +1 -0
  18. package/dist/chunk-CWLN3X3N.js +1 -0
  19. package/dist/chunk-D7A7DBE4.js +1 -0
  20. package/dist/chunk-DBGGMN3D.js +1 -0
  21. package/dist/chunk-DQA3UIQ2.js +1 -0
  22. package/dist/chunk-ERLIRFPA.js +1 -0
  23. package/dist/chunk-ESMPEKEV.js +1 -0
  24. package/dist/chunk-ETWTCCJI.js +1 -0
  25. package/dist/chunk-FNYWM6JC.js +1 -0
  26. package/dist/chunk-GHJJR5P4.js +1 -0
  27. package/dist/chunk-GPW2V3RE.js +1 -0
  28. package/dist/chunk-I6VIH3VA.js +1 -0
  29. package/dist/chunk-K2GNMCQT.js +1 -0
  30. package/dist/chunk-LBTDSCCO.js +3 -0
  31. package/dist/chunk-LQ3Y5NJS.js +1 -0
  32. package/dist/chunk-MIQTDPY4.js +5 -0
  33. package/dist/chunk-MTTAAPCK.js +1 -0
  34. package/dist/chunk-OAWLCNJJ.js +1 -0
  35. package/dist/chunk-OBKQQA5I.js +1 -0
  36. package/dist/chunk-OYHGKYQM.js +1 -0
  37. package/dist/chunk-PIOGHC63.js +1 -0
  38. package/dist/chunk-QWAPKG3O.js +2 -0
  39. package/dist/chunk-QYADASLV.js +1 -0
  40. package/dist/chunk-RHESUC3V.js +43 -0
  41. package/dist/chunk-S35VARIR.js +1 -0
  42. package/dist/chunk-SC3U7ETD.js +1 -0
  43. package/dist/chunk-U3AICJKU.js +1 -0
  44. package/dist/chunk-UMBIDLJ4.js +1 -0
  45. package/dist/chunk-UPHHLMHE.js +1 -0
  46. package/dist/chunk-UPXUCFMX.js +1 -0
  47. package/dist/chunk-UWJE5FQA.js +18 -0
  48. package/dist/chunk-V6YQICXZ.js +1 -0
  49. package/dist/chunk-VIMF6LGM.js +1 -0
  50. package/dist/chunk-VJLMUKOI.js +1 -0
  51. package/dist/chunk-VPYBOXVT.js +1 -0
  52. package/dist/chunk-VTPVOGHH.js +1 -0
  53. package/dist/chunk-WQ2BN6X6.js +1 -0
  54. package/dist/chunk-XAUNPIMX.js +1 -0
  55. package/dist/chunk-Y2EMPB3I.js +1 -0
  56. package/dist/chunk-Z4HDAS2Q.js +1 -0
  57. package/dist/chunk-ZB5EHBIO.js +1 -0
  58. package/dist/chunk-ZV2DXV5A.js +23 -0
  59. package/dist/compat/index.cjs +14 -7656
  60. package/dist/compat/index.d.cts +15 -14
  61. package/dist/compat/index.d.ts +15 -14
  62. package/dist/compat/index.js +1 -50
  63. package/dist/compat/jotai/index.cjs +1 -2048
  64. package/dist/compat/jotai/index.d.cts +2 -2
  65. package/dist/compat/jotai/index.d.ts +2 -2
  66. package/dist/compat/jotai/index.js +1 -9
  67. package/dist/compat/nanostores/index.cjs +1 -2175
  68. package/dist/compat/nanostores/index.d.cts +2 -2
  69. package/dist/compat/nanostores/index.d.ts +2 -2
  70. package/dist/compat/nanostores/index.js +1 -23
  71. package/dist/compat/nestjs/index.cjs +14 -6782
  72. package/dist/compat/nestjs/index.d.cts +7 -6
  73. package/dist/compat/nestjs/index.d.ts +7 -6
  74. package/dist/compat/nestjs/index.js +1 -83
  75. package/dist/compat/react/index.cjs +1 -141
  76. package/dist/compat/react/index.d.cts +2 -2
  77. package/dist/compat/react/index.d.ts +2 -2
  78. package/dist/compat/react/index.js +1 -12
  79. package/dist/compat/solid/index.cjs +1 -128
  80. package/dist/compat/solid/index.d.cts +2 -2
  81. package/dist/compat/solid/index.d.ts +2 -2
  82. package/dist/compat/solid/index.js +1 -12
  83. package/dist/compat/svelte/index.cjs +1 -131
  84. package/dist/compat/svelte/index.d.cts +2 -2
  85. package/dist/compat/svelte/index.d.ts +2 -2
  86. package/dist/compat/svelte/index.js +1 -12
  87. package/dist/compat/vue/index.cjs +1 -146
  88. package/dist/compat/vue/index.d.cts +2 -2
  89. package/dist/compat/vue/index.d.ts +2 -2
  90. package/dist/compat/vue/index.js +1 -12
  91. package/dist/compat/zustand/index.cjs +6 -4931
  92. package/dist/compat/zustand/index.d.cts +5 -5
  93. package/dist/compat/zustand/index.d.ts +5 -5
  94. package/dist/compat/zustand/index.js +1 -12
  95. package/dist/composite-B-xqw4Kk.d.cts +69 -0
  96. package/dist/composite-BhbKHbOS.d.ts +69 -0
  97. package/dist/core/index.cjs +1 -2271
  98. package/dist/core/index.d.cts +4 -4
  99. package/dist/core/index.d.ts +4 -4
  100. package/dist/core/index.js +1 -110
  101. package/dist/extra/browser.cjs +1 -0
  102. package/dist/extra/browser.d.cts +3 -0
  103. package/dist/extra/browser.d.ts +3 -0
  104. package/dist/extra/browser.js +1 -0
  105. package/dist/extra/index.cjs +23 -9971
  106. package/dist/extra/index.d.cts +13 -6
  107. package/dist/extra/index.d.ts +13 -6
  108. package/dist/extra/index.js +1 -381
  109. package/dist/extra/node.cjs +3 -0
  110. package/dist/extra/node.d.cts +81 -0
  111. package/dist/extra/node.d.ts +81 -0
  112. package/dist/extra/node.js +2 -0
  113. package/dist/extra/operators.cjs +1 -0
  114. package/dist/extra/operators.d.cts +910 -0
  115. package/dist/extra/operators.d.ts +910 -0
  116. package/dist/extra/operators.js +1 -0
  117. package/dist/extra/reactive.cjs +1 -0
  118. package/dist/extra/reactive.d.cts +352 -0
  119. package/dist/extra/reactive.d.ts +352 -0
  120. package/dist/extra/reactive.js +1 -0
  121. package/dist/extra/sources.cjs +1 -2486
  122. package/dist/extra/sources.d.cts +6 -2
  123. package/dist/extra/sources.d.ts +6 -2
  124. package/dist/extra/sources.js +1 -57
  125. package/dist/extra/storage-browser.cjs +1 -0
  126. package/dist/extra/storage-browser.d.cts +71 -0
  127. package/dist/extra/storage-browser.d.ts +71 -0
  128. package/dist/extra/storage-browser.js +1 -0
  129. package/dist/extra/storage-core.cjs +1 -0
  130. package/dist/extra/storage-core.d.cts +98 -0
  131. package/dist/extra/storage-core.d.ts +98 -0
  132. package/dist/extra/storage-core.js +1 -0
  133. package/dist/extra/storage-node.cjs +2 -0
  134. package/dist/extra/storage-node.d.cts +60 -0
  135. package/dist/extra/storage-node.d.ts +60 -0
  136. package/dist/extra/storage-node.js +1 -0
  137. package/dist/fallback-BaTS7vVY.d.cts +258 -0
  138. package/dist/fallback-eOm3LNxP.d.ts +258 -0
  139. package/dist/graph/index.cjs +6 -5030
  140. package/dist/graph/index.d.cts +6 -5
  141. package/dist/graph/index.d.ts +6 -5
  142. package/dist/graph/index.js +1 -50
  143. package/dist/{graph-CCwGKLCm.d.ts → graph-BZGRXwOm.d.ts} +134 -31
  144. package/dist/{graph-DNCrvZSn.d.cts → graph-D48Qw9Cg.d.cts} +134 -31
  145. package/dist/index-8FSVk4Uf.d.ts +135 -0
  146. package/dist/index-9oDeHH2u.d.cts +291 -0
  147. package/dist/{messaging-XDoYablx.d.ts → index-B0c4cmIO.d.ts} +31 -93
  148. package/dist/{index-VdHQMPy1.d.ts → index-B1AmmSlb.d.ts} +1 -1
  149. package/dist/{index-VHqptjhu.d.cts → index-B2pwesl9.d.cts} +1 -1
  150. package/dist/index-BHvIquRZ.d.ts +1957 -0
  151. package/dist/{index-Dzk2hrlR.d.ts → index-BVHOrDwO.d.ts} +1 -1
  152. package/dist/{index-CxFrXH4m.d.ts → index-BWJV63ti.d.ts} +1 -1
  153. package/dist/{index-Xi3u0HCQ.d.cts → index-B_agccPe.d.cts} +1 -1
  154. package/dist/index-BgyGlizc.d.ts +163 -0
  155. package/dist/index-BpA5c4G9.d.ts +357 -0
  156. package/dist/index-BpIFjILY.d.cts +357 -0
  157. package/dist/{index-3lsddbbS.d.ts → index-Bqachn9_.d.ts} +1 -1
  158. package/dist/index-Btib9rsU.d.ts +607 -0
  159. package/dist/{index-wEn0eFe8.d.ts → index-BwM9BEkt.d.ts} +1 -1
  160. package/dist/index-BxJ86YZZ.d.cts +105 -0
  161. package/dist/{audit-DRlSzBu9.d.ts → index-C73n7lo-.d.cts} +27 -21
  162. package/dist/index-CEXXwWVH.d.cts +192 -0
  163. package/dist/index-CHEswufn.d.cts +163 -0
  164. package/dist/{index-C0svESO4.d.ts → index-CMn8S8Hw.d.ts} +1 -1
  165. package/dist/{index-ByQxazQJ.d.cts → index-CRO83MmV.d.cts} +1 -1
  166. package/dist/{index-BuEoe-Qu.d.ts → index-CloUk1kY.d.ts} +9 -9
  167. package/dist/index-CpgYhnrG.d.ts +291 -0
  168. package/dist/{index-DO_6JN9Z.d.cts → index-Cyojz0AE.d.cts} +1 -1
  169. package/dist/{demo-shell-BDkOptd6.d.ts → index-CzobVSMr.d.ts} +14 -14
  170. package/dist/index-Czq6ynh8.d.ts +143 -0
  171. package/dist/{index-BaSM3aYt.d.ts → index-D-YB-Vl3.d.ts} +3 -3
  172. package/dist/index-DAlweici.d.ts +231 -0
  173. package/dist/index-DEwTb_fm.d.cts +1957 -0
  174. package/dist/{index-DYme44FM.d.cts → index-DL-rYJrx.d.cts} +1 -1
  175. package/dist/{memory-li6FL5RM.d.ts → index-DP4ZTkdw.d.ts} +26 -26
  176. package/dist/{index-BwfLUNw4.d.ts → index-DUqMOlKZ.d.cts} +173 -2040
  177. package/dist/{index-B1tloyhO.d.cts → index-D_NwnRYS.d.cts} +1 -1
  178. package/dist/index-DaLJvH8Z.d.ts +105 -0
  179. package/dist/index-DcXZBF5a.d.cts +135 -0
  180. package/dist/index-DfyOkTvs.d.ts +321 -0
  181. package/dist/{index-B9B7_HEY.d.ts → index-DiOXyAwt.d.ts} +1 -1
  182. package/dist/index-DpHe5e0Q.d.ts +186 -0
  183. package/dist/index-DraikLjn.d.ts +86 -0
  184. package/dist/{index-D8wS_PeY.d.cts → index-DxsnAMWD.d.cts} +9 -9
  185. package/dist/{messaging-Gt4LPbyA.d.cts → index-DyxjtScX.d.cts} +31 -93
  186. package/dist/{audit-ClmqGOCx.d.cts → index-HDpJe9hX.d.ts} +27 -21
  187. package/dist/{index-DVGiGFGT.d.cts → index-O6TgGUBV.d.cts} +3 -3
  188. package/dist/{index-B6EhDnjH.d.cts → index-Oi8d8w4R.d.cts} +1 -1
  189. package/dist/{index-C8oil6M6.d.ts → index-ROpQmGjE.d.ts} +30 -6
  190. package/dist/index-RukJ4DLS.d.cts +607 -0
  191. package/dist/{index-BHlKbUwO.d.cts → index-ZftwfxJM.d.ts} +173 -2040
  192. package/dist/{index-BPVt8kqc.d.ts → index-cByzxQIC.d.cts} +10 -195
  193. package/dist/index-dtN7YA2x.d.cts +143 -0
  194. package/dist/{index-CI3DprxP.d.cts → index-fM6y00vT.d.cts} +30 -6
  195. package/dist/{index-DlLp-2Xn.d.cts → index-m-yHof5p.d.ts} +10 -195
  196. package/dist/index-pXrDMpRO.d.cts +231 -0
  197. package/dist/index-rHJSKsU8.d.cts +186 -0
  198. package/dist/index-rX8HBM5h.d.cts +321 -0
  199. package/dist/{index-CO8uBlUh.d.cts → index-rnwQly8X.d.cts} +147 -20
  200. package/dist/index-sm373fsH.d.ts +192 -0
  201. package/dist/{memory-C6Z2tGpC.d.cts → index-tbf2gKHd.d.cts} +26 -26
  202. package/dist/{demo-shell-Crid1WdR.d.cts → index-u15meRxL.d.cts} +14 -14
  203. package/dist/{index-B6D3QNSA.d.ts → index-umtoWT8K.d.ts} +147 -20
  204. package/dist/index-vscRDkjW.d.cts +86 -0
  205. package/dist/index.cjs +150 -24142
  206. package/dist/index.d.cts +69 -2099
  207. package/dist/index.d.ts +69 -2099
  208. package/dist/index.js +1 -3868
  209. package/dist/{meta-CbznRPYJ.d.ts → meta-Cgj6zeji.d.cts} +5 -5
  210. package/dist/{meta-BxCA7rcr.d.cts → meta-CwesDrMD.d.ts} +5 -5
  211. package/dist/{node-BmerH3kS.d.cts → node-Cc1TniY8.d.cts} +36 -9
  212. package/dist/{node-BmerH3kS.d.ts → node-Cc1TniY8.d.ts} +36 -9
  213. package/dist/{observable-BgGUwcqp.d.ts → observable-Ct-gJ9jI.d.ts} +1 -1
  214. package/dist/{observable-DJt_AxzQ.d.cts → observable-glXQoGj2.d.cts} +1 -1
  215. package/dist/patterns/ai/browser.cjs +25 -0
  216. package/dist/patterns/ai/browser.d.cts +127 -0
  217. package/dist/patterns/ai/browser.d.ts +127 -0
  218. package/dist/patterns/ai/browser.js +3 -0
  219. package/dist/patterns/ai/index.cjs +91 -0
  220. package/dist/patterns/ai/index.d.cts +17 -0
  221. package/dist/patterns/ai/index.d.ts +17 -0
  222. package/dist/patterns/ai/index.js +1 -0
  223. package/dist/patterns/ai/node.cjs +2 -0
  224. package/dist/patterns/ai/node.d.cts +58 -0
  225. package/dist/patterns/ai/node.d.ts +58 -0
  226. package/dist/patterns/ai/node.js +1 -0
  227. package/dist/patterns/audit/index.cjs +6 -0
  228. package/dist/patterns/audit/index.d.cts +6 -0
  229. package/dist/patterns/audit/index.d.ts +6 -0
  230. package/dist/patterns/audit/index.js +1 -0
  231. package/dist/patterns/cqrs/index.cjs +6 -0
  232. package/dist/patterns/cqrs/index.d.cts +5 -0
  233. package/dist/patterns/cqrs/index.d.ts +5 -0
  234. package/dist/patterns/cqrs/index.js +1 -0
  235. package/dist/patterns/demo-shell/index.cjs +7 -0
  236. package/dist/patterns/demo-shell/index.d.cts +6 -0
  237. package/dist/patterns/demo-shell/index.d.ts +6 -0
  238. package/dist/patterns/demo-shell/index.js +1 -0
  239. package/dist/patterns/domain-templates/index.cjs +6 -0
  240. package/dist/patterns/domain-templates/index.d.cts +5 -0
  241. package/dist/patterns/domain-templates/index.d.ts +5 -0
  242. package/dist/patterns/domain-templates/index.js +1 -0
  243. package/dist/patterns/graphspec/index.cjs +83 -0
  244. package/dist/patterns/graphspec/index.d.cts +7 -0
  245. package/dist/patterns/graphspec/index.d.ts +7 -0
  246. package/dist/patterns/graphspec/index.js +1 -0
  247. package/dist/patterns/guarded-execution/index.cjs +6 -0
  248. package/dist/patterns/guarded-execution/index.d.cts +7 -0
  249. package/dist/patterns/guarded-execution/index.d.ts +7 -0
  250. package/dist/patterns/guarded-execution/index.js +1 -0
  251. package/dist/patterns/harness/index.cjs +48 -0
  252. package/dist/patterns/harness/index.d.cts +8 -0
  253. package/dist/patterns/harness/index.d.ts +8 -0
  254. package/dist/patterns/harness/index.js +1 -0
  255. package/dist/patterns/job-queue/index.cjs +6 -0
  256. package/dist/patterns/job-queue/index.d.cts +5 -0
  257. package/dist/patterns/job-queue/index.d.ts +5 -0
  258. package/dist/patterns/job-queue/index.js +1 -0
  259. package/dist/patterns/lens/index.cjs +6 -0
  260. package/dist/patterns/lens/index.d.cts +7 -0
  261. package/dist/patterns/lens/index.d.ts +7 -0
  262. package/dist/patterns/lens/index.js +1 -0
  263. package/dist/patterns/memory/index.cjs +6 -0
  264. package/dist/patterns/memory/index.d.cts +5 -0
  265. package/dist/patterns/memory/index.d.ts +5 -0
  266. package/dist/patterns/memory/index.js +1 -0
  267. package/dist/patterns/messaging/index.cjs +6 -0
  268. package/dist/patterns/messaging/index.d.cts +5 -0
  269. package/dist/patterns/messaging/index.d.ts +5 -0
  270. package/dist/patterns/messaging/index.js +1 -0
  271. package/dist/patterns/orchestration/index.cjs +6 -0
  272. package/dist/patterns/orchestration/index.d.cts +6 -0
  273. package/dist/patterns/orchestration/index.d.ts +6 -0
  274. package/dist/patterns/orchestration/index.js +1 -0
  275. package/dist/patterns/reactive-layout/index.cjs +7 -6444
  276. package/dist/patterns/reactive-layout/index.d.cts +6 -6
  277. package/dist/patterns/reactive-layout/index.d.ts +6 -6
  278. package/dist/patterns/reactive-layout/index.js +1 -56
  279. package/dist/patterns/reduction/index.cjs +6 -0
  280. package/dist/patterns/reduction/index.d.cts +5 -0
  281. package/dist/patterns/reduction/index.d.ts +5 -0
  282. package/dist/patterns/reduction/index.js +1 -0
  283. package/dist/patterns/refine-loop/index.cjs +8 -0
  284. package/dist/patterns/refine-loop/index.d.cts +7 -0
  285. package/dist/patterns/refine-loop/index.d.ts +7 -0
  286. package/dist/patterns/refine-loop/index.js +1 -0
  287. package/dist/patterns/resilient-pipeline/index.cjs +1 -0
  288. package/dist/patterns/resilient-pipeline/index.d.cts +7 -0
  289. package/dist/patterns/resilient-pipeline/index.d.ts +7 -0
  290. package/dist/patterns/resilient-pipeline/index.js +1 -0
  291. package/dist/patterns/surface/index.cjs +14 -0
  292. package/dist/patterns/surface/index.d.cts +8 -0
  293. package/dist/patterns/surface/index.d.ts +8 -0
  294. package/dist/patterns/surface/index.js +1 -0
  295. package/dist/{reactive-layout-MQP--J3F.d.cts → reactive-layout-CpYb5qLP.d.cts} +2 -2
  296. package/dist/{reactive-layout-u5Ulnqag.d.ts → reactive-layout-D8u4wuUR.d.ts} +2 -2
  297. package/dist/reactive-log-DPzuUDj5.d.cts +190 -0
  298. package/dist/reactive-log-YuH9VYN8.d.ts +190 -0
  299. package/dist/{composite-aUCvjZVR.d.ts → reactive-map-CdbNoSgP.d.ts} +2 -67
  300. package/dist/{composite-C7PcQvcs.d.cts → reactive-map-DUeRmb9d.d.cts} +2 -67
  301. package/dist/resilience-Ba5-b4WD.d.cts +493 -0
  302. package/dist/resilience-CGRzhnD3.d.ts +493 -0
  303. package/dist/resilience-QAHKANT5.js +1 -0
  304. package/dist/{sugar-D02n5JjF.d.cts → sugar-BV0htudb.d.cts} +8 -4
  305. package/dist/{sugar-CCOxXK1e.d.ts → sugar-Dtyrq2_q.d.ts} +8 -4
  306. package/dist/topology-tree-CYHOwQZ_.d.ts +25 -0
  307. package/dist/topology-tree-DROUdq5B.d.cts +25 -0
  308. package/dist/types-O3GzJY2U.d.cts +401 -0
  309. package/dist/types-u64Ose53.d.ts +401 -0
  310. package/package.json +252 -22
  311. package/dist/ai-CaR_912Q.d.cts +0 -1033
  312. package/dist/ai-WlRltJV7.d.ts +0 -1033
  313. package/dist/chunk-3ZWCKRHX.js +0 -117
  314. package/dist/chunk-3ZWCKRHX.js.map +0 -1
  315. package/dist/chunk-7TAQJHQV.js +0 -103
  316. package/dist/chunk-7TAQJHQV.js.map +0 -1
  317. package/dist/chunk-APFNLIRG.js +0 -62
  318. package/dist/chunk-APFNLIRG.js.map +0 -1
  319. package/dist/chunk-AT5LKYNL.js +0 -395
  320. package/dist/chunk-AT5LKYNL.js.map +0 -1
  321. package/dist/chunk-BQ6RQQFF.js +0 -5087
  322. package/dist/chunk-BQ6RQQFF.js.map +0 -1
  323. package/dist/chunk-BVZYTZ5H.js +0 -599
  324. package/dist/chunk-BVZYTZ5H.js.map +0 -1
  325. package/dist/chunk-DST5DKZS.js +0 -1371
  326. package/dist/chunk-DST5DKZS.js.map +0 -1
  327. package/dist/chunk-GTE6PWRZ.js +0 -866
  328. package/dist/chunk-GTE6PWRZ.js.map +0 -1
  329. package/dist/chunk-HXZEYDUR.js +0 -94
  330. package/dist/chunk-HXZEYDUR.js.map +0 -1
  331. package/dist/chunk-J22W6HV3.js +0 -107
  332. package/dist/chunk-J22W6HV3.js.map +0 -1
  333. package/dist/chunk-J2VBW3DZ.js +0 -302
  334. package/dist/chunk-J2VBW3DZ.js.map +0 -1
  335. package/dist/chunk-JSCT3CR4.js +0 -38
  336. package/dist/chunk-JSCT3CR4.js.map +0 -1
  337. package/dist/chunk-JWBCY4NC.js +0 -330
  338. package/dist/chunk-JWBCY4NC.js.map +0 -1
  339. package/dist/chunk-K2AUJHVP.js +0 -2251
  340. package/dist/chunk-K2AUJHVP.js.map +0 -1
  341. package/dist/chunk-MJ2NKQQL.js +0 -119
  342. package/dist/chunk-MJ2NKQQL.js.map +0 -1
  343. package/dist/chunk-N6UR7YVY.js +0 -198
  344. package/dist/chunk-N6UR7YVY.js.map +0 -1
  345. package/dist/chunk-NC6S43JJ.js +0 -456
  346. package/dist/chunk-NC6S43JJ.js.map +0 -1
  347. package/dist/chunk-OFVJBJXR.js +0 -98
  348. package/dist/chunk-OFVJBJXR.js.map +0 -1
  349. package/dist/chunk-OHISZPOJ.js +0 -97
  350. package/dist/chunk-OHISZPOJ.js.map +0 -1
  351. package/dist/chunk-OU5CQKNW.js +0 -102
  352. package/dist/chunk-OU5CQKNW.js.map +0 -1
  353. package/dist/chunk-PF7GRZMW.js +0 -2712
  354. package/dist/chunk-PF7GRZMW.js.map +0 -1
  355. package/dist/chunk-PHOUUNK7.js +0 -2291
  356. package/dist/chunk-PHOUUNK7.js.map +0 -1
  357. package/dist/chunk-RNHBMHKA.js +0 -1665
  358. package/dist/chunk-RNHBMHKA.js.map +0 -1
  359. package/dist/chunk-SX52TAR4.js +0 -110
  360. package/dist/chunk-SX52TAR4.js.map +0 -1
  361. package/dist/chunk-VYPWMZ6H.js +0 -98
  362. package/dist/chunk-VYPWMZ6H.js.map +0 -1
  363. package/dist/chunk-WBZOVTYK.js +0 -171
  364. package/dist/chunk-WBZOVTYK.js.map +0 -1
  365. package/dist/chunk-WKNUIZOY.js +0 -354
  366. package/dist/chunk-WKNUIZOY.js.map +0 -1
  367. package/dist/chunk-X3VMZYBT.js +0 -713
  368. package/dist/chunk-X3VMZYBT.js.map +0 -1
  369. package/dist/chunk-X5R3GL6H.js +0 -525
  370. package/dist/chunk-X5R3GL6H.js.map +0 -1
  371. package/dist/chunk-XGPU467M.js +0 -136
  372. package/dist/chunk-XGPU467M.js.map +0 -1
  373. package/dist/compat/index.cjs.map +0 -1
  374. package/dist/compat/index.js.map +0 -1
  375. package/dist/compat/jotai/index.cjs.map +0 -1
  376. package/dist/compat/jotai/index.js.map +0 -1
  377. package/dist/compat/nanostores/index.cjs.map +0 -1
  378. package/dist/compat/nanostores/index.js.map +0 -1
  379. package/dist/compat/nestjs/index.cjs.map +0 -1
  380. package/dist/compat/nestjs/index.js.map +0 -1
  381. package/dist/compat/react/index.cjs.map +0 -1
  382. package/dist/compat/react/index.js.map +0 -1
  383. package/dist/compat/solid/index.cjs.map +0 -1
  384. package/dist/compat/solid/index.js.map +0 -1
  385. package/dist/compat/svelte/index.cjs.map +0 -1
  386. package/dist/compat/svelte/index.js.map +0 -1
  387. package/dist/compat/vue/index.cjs.map +0 -1
  388. package/dist/compat/vue/index.js.map +0 -1
  389. package/dist/compat/zustand/index.cjs.map +0 -1
  390. package/dist/compat/zustand/index.js.map +0 -1
  391. package/dist/core/index.cjs.map +0 -1
  392. package/dist/core/index.js.map +0 -1
  393. package/dist/extra/index.cjs.map +0 -1
  394. package/dist/extra/index.js.map +0 -1
  395. package/dist/extra/sources.cjs.map +0 -1
  396. package/dist/extra/sources.js.map +0 -1
  397. package/dist/graph/index.cjs.map +0 -1
  398. package/dist/graph/index.js.map +0 -1
  399. package/dist/index.cjs.map +0 -1
  400. package/dist/index.js.map +0 -1
  401. package/dist/patterns/ai.cjs +0 -7930
  402. package/dist/patterns/ai.cjs.map +0 -1
  403. package/dist/patterns/ai.d.cts +0 -10
  404. package/dist/patterns/ai.d.ts +0 -10
  405. package/dist/patterns/ai.js +0 -71
  406. package/dist/patterns/ai.js.map +0 -1
  407. package/dist/patterns/audit.cjs +0 -5805
  408. package/dist/patterns/audit.cjs.map +0 -1
  409. package/dist/patterns/audit.d.cts +0 -6
  410. package/dist/patterns/audit.d.ts +0 -6
  411. package/dist/patterns/audit.js +0 -29
  412. package/dist/patterns/audit.js.map +0 -1
  413. package/dist/patterns/demo-shell.cjs +0 -5604
  414. package/dist/patterns/demo-shell.cjs.map +0 -1
  415. package/dist/patterns/demo-shell.d.cts +0 -6
  416. package/dist/patterns/demo-shell.d.ts +0 -6
  417. package/dist/patterns/demo-shell.js +0 -15
  418. package/dist/patterns/demo-shell.js.map +0 -1
  419. package/dist/patterns/memory.cjs +0 -5283
  420. package/dist/patterns/memory.cjs.map +0 -1
  421. package/dist/patterns/memory.d.cts +0 -5
  422. package/dist/patterns/memory.d.ts +0 -5
  423. package/dist/patterns/memory.js +0 -20
  424. package/dist/patterns/memory.js.map +0 -1
  425. package/dist/patterns/reactive-layout/index.cjs.map +0 -1
  426. package/dist/patterns/reactive-layout/index.js.map +0 -1
  427. package/dist/storage-CMjUUuxn.d.ts +0 -190
  428. package/dist/storage-DdWlZo6U.d.cts +0 -190
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h,i}from"./chunk-4VVTGLXJ.js";import"./chunk-QYADASLV.js";export{a as NS_PER_MS,b as NS_PER_SEC,c as constant,g as decorrelatedJitter,e as exponential,f as fibonacci,d as linear,i as resolveBackoffPreset,h as withMaxAttempts};
@@ -0,0 +1,180 @@
1
+ import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-O3GzJY2U.cjs';
2
+ import { a as CircuitBreakerOptions, e as CircuitBreaker } from './resilience-Ba5-b4WD.cjs';
3
+
4
+ /**
5
+ * OpenAICompatAdapter — default fetch-backed, optional SDK-backed.
6
+ *
7
+ * Covers any provider that speaks OpenAI chat/completions. Preset base URLs
8
+ * for OpenAI, OpenRouter, Groq, Ollama, DeepSeek, xAI Grok (all expose the
9
+ * same `/v1/chat/completions` shape).
10
+ *
11
+ * Token usage mapping:
12
+ * - `prompt_tokens` → `input.regular` (minus cached_tokens)
13
+ * - `prompt_tokens_details.cached_tokens` → `input.cacheRead`
14
+ * - `prompt_tokens_details.audio_tokens` → `input.audio`
15
+ * - `completion_tokens` → `output.regular` (minus reasoning)
16
+ * - `completion_tokens_details.reasoning_tokens` → `output.reasoning`
17
+ * - `completion_tokens_details.audio_tokens` → `output.audio`
18
+ * - `completion_tokens_details.accepted_prediction_tokens` → `output.predictionAccepted`
19
+ * - `completion_tokens_details.rejected_prediction_tokens` → `output.predictionRejected`
20
+ *
21
+ * DeepSeek compatibility: `prompt_cache_hit_tokens` / `prompt_cache_miss_tokens`
22
+ * are surfaced in the `raw` field of `TokenUsage`; when present we prefer
23
+ * them over the OpenAI-style `cached_tokens` for cache-read attribution.
24
+ */
25
+
26
+ type OpenAICompatPreset = "openai" | "openrouter" | "groq" | "ollama" | "deepseek" | "xai";
27
+ interface OpenAICompatAdapterOptions {
28
+ preset?: OpenAICompatPreset;
29
+ /** Explicit provider label (defaults to preset's provider). */
30
+ provider?: string;
31
+ /** API key. Falls back to the preset's default env var on Node. */
32
+ apiKey?: string;
33
+ model?: string;
34
+ /** Override base URL (wins over `preset`). */
35
+ baseURL?: string;
36
+ /** Extra request headers. */
37
+ headers?: Record<string, string>;
38
+ /** Extra request-body fields merged on every request (OpenRouter routing etc.). */
39
+ bodyExtras?: Record<string, unknown>;
40
+ /** User-provided SDK instance (OpenAI-family shape). */
41
+ sdk?: OpenAISdkLike;
42
+ /** Custom fetch (for tests). */
43
+ fetchImpl?: typeof fetch;
44
+ }
45
+ interface OpenAISdkLike {
46
+ chat: {
47
+ completions: {
48
+ create(params: Record<string, unknown>, opts?: {
49
+ signal?: AbortSignal;
50
+ }): Promise<OpenAIChatResponse>;
51
+ };
52
+ };
53
+ }
54
+ interface OpenAIChatResponse {
55
+ id: string;
56
+ choices: ReadonlyArray<{
57
+ message: {
58
+ role: string;
59
+ content?: string | null;
60
+ tool_calls?: ReadonlyArray<{
61
+ id: string;
62
+ type: "function";
63
+ function: {
64
+ name: string;
65
+ arguments: string;
66
+ };
67
+ }>;
68
+ reasoning_content?: string;
69
+ };
70
+ finish_reason?: string;
71
+ }>;
72
+ usage?: OpenAIUsage;
73
+ model?: string;
74
+ }
75
+ interface OpenAIUsage {
76
+ prompt_tokens?: number;
77
+ completion_tokens?: number;
78
+ total_tokens?: number;
79
+ prompt_tokens_details?: {
80
+ cached_tokens?: number;
81
+ audio_tokens?: number;
82
+ };
83
+ completion_tokens_details?: {
84
+ reasoning_tokens?: number;
85
+ audio_tokens?: number;
86
+ accepted_prediction_tokens?: number;
87
+ rejected_prediction_tokens?: number;
88
+ };
89
+ prompt_cache_hit_tokens?: number;
90
+ prompt_cache_miss_tokens?: number;
91
+ }
92
+ declare function openAICompatAdapter(opts?: OpenAICompatAdapterOptions): LLMAdapter;
93
+
94
+ /**
95
+ * `createAdapter` — provider-dispatching factory.
96
+ *
97
+ * One entry point, one config object. Picks the right concrete adapter by
98
+ * `provider`, forwards everything else. Users who want finer control import
99
+ * the concrete adapter directly (`anthropicAdapter`, `openAICompatAdapter`,
100
+ * `googleAdapter`, `dryRunAdapter`, `webllmAdapter`, `chromeNanoAdapter`).
101
+ */
102
+
103
+ type AdapterProvider = "anthropic" | OpenAICompatPreset | "google" | "dry-run" | "fallback";
104
+ interface CreateAdapterOptions {
105
+ provider: AdapterProvider;
106
+ apiKey?: string;
107
+ model?: string;
108
+ baseURL?: string;
109
+ headers?: Record<string, string>;
110
+ /** OpenAI-compat bodyExtras (OpenRouter routing, etc.). */
111
+ bodyExtras?: Record<string, unknown>;
112
+ /** Provider-specific SDK instance (any of AnthropicSdkLike / OpenAISdkLike / GoogleSdkLike). */
113
+ sdk?: unknown;
114
+ /** Custom fetch (for tests). */
115
+ fetchImpl?: typeof fetch;
116
+ /** Extra per-provider options forwarded verbatim. */
117
+ extras?: Record<string, unknown>;
118
+ }
119
+ declare function createAdapter(opts: CreateAdapterOptions): LLMAdapter;
120
+
121
+ /**
122
+ * `cascadingLlmAdapter` — N-tier fallback over any mix of LLM adapters.
123
+ *
124
+ * Same structural pattern as `cascadingCache` and `Graph.attachStorage`:
125
+ * ordered list, first-success wins, per-tier breaker optional, filter gates
126
+ * per request. Semantics:
127
+ *
128
+ * - `invoke()`: try tier 0 first. On error (or breaker-open), fall through
129
+ * to tier 1, 2, ... until one succeeds or all fail.
130
+ * - `stream()`: tries to start the stream on tier 0; once tokens begin, it
131
+ * commits — failures in mid-stream surface rather than re-starting on the
132
+ * next tier (would double-bill and confuse consumers). **State-machine
133
+ * consumers (usage accounting, UI accumulators) must handle errors in a
134
+ * catch block — no synthetic `{type: "finish"}` is emitted after a thrown
135
+ * stream error.**
136
+ * - `filter`: skips a tier for requests that use features it doesn't
137
+ * support (e.g., Chrome Nano can't do tool use).
138
+ * - `breaker`: per-tier circuit; when open, cascade treats the tier as
139
+ * unavailable and moves on immediately.
140
+ *
141
+ * On exhaustion, throws `AllTiersExhaustedError` with separate `skipped` and
142
+ * `failed` collections so consumers can distinguish "no tier applicable"
143
+ * from "all tiers failed".
144
+ */
145
+
146
+ interface AdapterTier {
147
+ name: string;
148
+ adapter: LLMAdapter;
149
+ /** Per-tier circuit breaker. If omitted, no breaker on this tier. */
150
+ breaker?: CircuitBreakerOptions | CircuitBreaker;
151
+ /** Skip this tier when the request doesn't fit (e.g. Chrome Nano + tools). */
152
+ filter?: (messages: readonly ChatMessage[], opts?: LLMInvokeOptions) => boolean;
153
+ }
154
+ interface CascadeExhaustionReport {
155
+ /** Tiers that never ran (filter returned false, or breaker was open). */
156
+ readonly skipped: ReadonlyArray<{
157
+ name: string;
158
+ reason: "filter" | "breaker";
159
+ }>;
160
+ /** Tiers that ran and threw. */
161
+ readonly failed: ReadonlyMap<string, unknown>;
162
+ }
163
+ interface CascadingLlmAdapterOptions {
164
+ onFallback?: (from: string, to: string, error: unknown) => void;
165
+ onExhausted?: (report: CascadeExhaustionReport) => void;
166
+ /** Whether to attempt stream retry on subsequent tiers before first chunk. Default true. */
167
+ streamRetryBeforeFirstChunk?: boolean;
168
+ }
169
+ declare class AllTiersExhaustedError extends Error {
170
+ name: string;
171
+ readonly skipped: ReadonlyArray<{
172
+ name: string;
173
+ reason: "filter" | "breaker";
174
+ }>;
175
+ readonly failed: ReadonlyMap<string, unknown>;
176
+ constructor(report: CascadeExhaustionReport);
177
+ }
178
+ declare function cascadingLlmAdapter(tiers: readonly AdapterTier[], opts?: CascadingLlmAdapterOptions): LLMAdapter;
179
+
180
+ export { type AdapterProvider as A, type CascadingLlmAdapterOptions as C, type OpenAICompatAdapterOptions as O, type CascadeExhaustionReport as a, type AdapterTier as b, createAdapter as c, AllTiersExhaustedError as d, type CreateAdapterOptions as e, type OpenAICompatPreset as f, type OpenAISdkLike as g, cascadingLlmAdapter as h, openAICompatAdapter as o };
@@ -0,0 +1,180 @@
1
+ import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-u64Ose53.js';
2
+ import { a as CircuitBreakerOptions, e as CircuitBreaker } from './resilience-CGRzhnD3.js';
3
+
4
+ /**
5
+ * OpenAICompatAdapter — default fetch-backed, optional SDK-backed.
6
+ *
7
+ * Covers any provider that speaks OpenAI chat/completions. Preset base URLs
8
+ * for OpenAI, OpenRouter, Groq, Ollama, DeepSeek, xAI Grok (all expose the
9
+ * same `/v1/chat/completions` shape).
10
+ *
11
+ * Token usage mapping:
12
+ * - `prompt_tokens` → `input.regular` (minus cached_tokens)
13
+ * - `prompt_tokens_details.cached_tokens` → `input.cacheRead`
14
+ * - `prompt_tokens_details.audio_tokens` → `input.audio`
15
+ * - `completion_tokens` → `output.regular` (minus reasoning)
16
+ * - `completion_tokens_details.reasoning_tokens` → `output.reasoning`
17
+ * - `completion_tokens_details.audio_tokens` → `output.audio`
18
+ * - `completion_tokens_details.accepted_prediction_tokens` → `output.predictionAccepted`
19
+ * - `completion_tokens_details.rejected_prediction_tokens` → `output.predictionRejected`
20
+ *
21
+ * DeepSeek compatibility: `prompt_cache_hit_tokens` / `prompt_cache_miss_tokens`
22
+ * are surfaced in the `raw` field of `TokenUsage`; when present we prefer
23
+ * them over the OpenAI-style `cached_tokens` for cache-read attribution.
24
+ */
25
+
26
+ type OpenAICompatPreset = "openai" | "openrouter" | "groq" | "ollama" | "deepseek" | "xai";
27
+ interface OpenAICompatAdapterOptions {
28
+ preset?: OpenAICompatPreset;
29
+ /** Explicit provider label (defaults to preset's provider). */
30
+ provider?: string;
31
+ /** API key. Falls back to the preset's default env var on Node. */
32
+ apiKey?: string;
33
+ model?: string;
34
+ /** Override base URL (wins over `preset`). */
35
+ baseURL?: string;
36
+ /** Extra request headers. */
37
+ headers?: Record<string, string>;
38
+ /** Extra request-body fields merged on every request (OpenRouter routing etc.). */
39
+ bodyExtras?: Record<string, unknown>;
40
+ /** User-provided SDK instance (OpenAI-family shape). */
41
+ sdk?: OpenAISdkLike;
42
+ /** Custom fetch (for tests). */
43
+ fetchImpl?: typeof fetch;
44
+ }
45
+ interface OpenAISdkLike {
46
+ chat: {
47
+ completions: {
48
+ create(params: Record<string, unknown>, opts?: {
49
+ signal?: AbortSignal;
50
+ }): Promise<OpenAIChatResponse>;
51
+ };
52
+ };
53
+ }
54
+ interface OpenAIChatResponse {
55
+ id: string;
56
+ choices: ReadonlyArray<{
57
+ message: {
58
+ role: string;
59
+ content?: string | null;
60
+ tool_calls?: ReadonlyArray<{
61
+ id: string;
62
+ type: "function";
63
+ function: {
64
+ name: string;
65
+ arguments: string;
66
+ };
67
+ }>;
68
+ reasoning_content?: string;
69
+ };
70
+ finish_reason?: string;
71
+ }>;
72
+ usage?: OpenAIUsage;
73
+ model?: string;
74
+ }
75
+ interface OpenAIUsage {
76
+ prompt_tokens?: number;
77
+ completion_tokens?: number;
78
+ total_tokens?: number;
79
+ prompt_tokens_details?: {
80
+ cached_tokens?: number;
81
+ audio_tokens?: number;
82
+ };
83
+ completion_tokens_details?: {
84
+ reasoning_tokens?: number;
85
+ audio_tokens?: number;
86
+ accepted_prediction_tokens?: number;
87
+ rejected_prediction_tokens?: number;
88
+ };
89
+ prompt_cache_hit_tokens?: number;
90
+ prompt_cache_miss_tokens?: number;
91
+ }
92
+ declare function openAICompatAdapter(opts?: OpenAICompatAdapterOptions): LLMAdapter;
93
+
94
+ /**
95
+ * `createAdapter` — provider-dispatching factory.
96
+ *
97
+ * One entry point, one config object. Picks the right concrete adapter by
98
+ * `provider`, forwards everything else. Users who want finer control import
99
+ * the concrete adapter directly (`anthropicAdapter`, `openAICompatAdapter`,
100
+ * `googleAdapter`, `dryRunAdapter`, `webllmAdapter`, `chromeNanoAdapter`).
101
+ */
102
+
103
+ type AdapterProvider = "anthropic" | OpenAICompatPreset | "google" | "dry-run" | "fallback";
104
+ interface CreateAdapterOptions {
105
+ provider: AdapterProvider;
106
+ apiKey?: string;
107
+ model?: string;
108
+ baseURL?: string;
109
+ headers?: Record<string, string>;
110
+ /** OpenAI-compat bodyExtras (OpenRouter routing, etc.). */
111
+ bodyExtras?: Record<string, unknown>;
112
+ /** Provider-specific SDK instance (any of AnthropicSdkLike / OpenAISdkLike / GoogleSdkLike). */
113
+ sdk?: unknown;
114
+ /** Custom fetch (for tests). */
115
+ fetchImpl?: typeof fetch;
116
+ /** Extra per-provider options forwarded verbatim. */
117
+ extras?: Record<string, unknown>;
118
+ }
119
+ declare function createAdapter(opts: CreateAdapterOptions): LLMAdapter;
120
+
121
+ /**
122
+ * `cascadingLlmAdapter` — N-tier fallback over any mix of LLM adapters.
123
+ *
124
+ * Same structural pattern as `cascadingCache` and `Graph.attachStorage`:
125
+ * ordered list, first-success wins, per-tier breaker optional, filter gates
126
+ * per request. Semantics:
127
+ *
128
+ * - `invoke()`: try tier 0 first. On error (or breaker-open), fall through
129
+ * to tier 1, 2, ... until one succeeds or all fail.
130
+ * - `stream()`: tries to start the stream on tier 0; once tokens begin, it
131
+ * commits — failures in mid-stream surface rather than re-starting on the
132
+ * next tier (would double-bill and confuse consumers). **State-machine
133
+ * consumers (usage accounting, UI accumulators) must handle errors in a
134
+ * catch block — no synthetic `{type: "finish"}` is emitted after a thrown
135
+ * stream error.**
136
+ * - `filter`: skips a tier for requests that use features it doesn't
137
+ * support (e.g., Chrome Nano can't do tool use).
138
+ * - `breaker`: per-tier circuit; when open, cascade treats the tier as
139
+ * unavailable and moves on immediately.
140
+ *
141
+ * On exhaustion, throws `AllTiersExhaustedError` with separate `skipped` and
142
+ * `failed` collections so consumers can distinguish "no tier applicable"
143
+ * from "all tiers failed".
144
+ */
145
+
146
+ interface AdapterTier {
147
+ name: string;
148
+ adapter: LLMAdapter;
149
+ /** Per-tier circuit breaker. If omitted, no breaker on this tier. */
150
+ breaker?: CircuitBreakerOptions | CircuitBreaker;
151
+ /** Skip this tier when the request doesn't fit (e.g. Chrome Nano + tools). */
152
+ filter?: (messages: readonly ChatMessage[], opts?: LLMInvokeOptions) => boolean;
153
+ }
154
+ interface CascadeExhaustionReport {
155
+ /** Tiers that never ran (filter returned false, or breaker was open). */
156
+ readonly skipped: ReadonlyArray<{
157
+ name: string;
158
+ reason: "filter" | "breaker";
159
+ }>;
160
+ /** Tiers that ran and threw. */
161
+ readonly failed: ReadonlyMap<string, unknown>;
162
+ }
163
+ interface CascadingLlmAdapterOptions {
164
+ onFallback?: (from: string, to: string, error: unknown) => void;
165
+ onExhausted?: (report: CascadeExhaustionReport) => void;
166
+ /** Whether to attempt stream retry on subsequent tiers before first chunk. Default true. */
167
+ streamRetryBeforeFirstChunk?: boolean;
168
+ }
169
+ declare class AllTiersExhaustedError extends Error {
170
+ name: string;
171
+ readonly skipped: ReadonlyArray<{
172
+ name: string;
173
+ reason: "filter" | "breaker";
174
+ }>;
175
+ readonly failed: ReadonlyMap<string, unknown>;
176
+ constructor(report: CascadeExhaustionReport);
177
+ }
178
+ declare function cascadingLlmAdapter(tiers: readonly AdapterTier[], opts?: CascadingLlmAdapterOptions): LLMAdapter;
179
+
180
+ export { type AdapterProvider as A, type CascadingLlmAdapterOptions as C, type OpenAICompatAdapterOptions as O, type CascadeExhaustionReport as a, type AdapterTier as b, createAdapter as c, AllTiersExhaustedError as d, type CreateAdapterOptions as e, type OpenAICompatPreset as f, type OpenAISdkLike as g, cascadingLlmAdapter as h, openAICompatAdapter as o };
@@ -0,0 +1 @@
1
+ import{b as x,c as D,d as $,e as S,f as A,g as R,h as T,i as F,j as y,k as P,l as V}from"./chunk-CKCSDI7T.js";import{a as m,b as g,c as k,d as v,e as O,f as G,g as E,h as C}from"./chunk-ZB5EHBIO.js";import{b as u}from"./chunk-CK2E7BTU.js";import{b as _}from"./chunk-QYADASLV.js";var j={};_(j,{ENVELOPE_VERSION:()=>v,GRAPH_META_SEGMENT:()=>R,Graph:()=>y,JsonCodec:()=>m,SIZEOF_OVERHEAD:()=>D,SIZEOF_SYMBOL:()=>$,SNAPSHOT_VERSION:()=>T,createDagCborCodec:()=>g,createDagCborZstdCodec:()=>k,decodeEnvelope:()=>G,diffForWAL:()=>P,encodeEnvelope:()=>O,explainPath:()=>x,graphProfile:()=>A,mermaidLiveUrl:()=>F,reachable:()=>V,registerBuiltinCodecs:()=>E,replayWAL:()=>C,sizeof:()=>S,validateGraphObservability:()=>L,watchTopologyTree:()=>N});function N(p,s){let o=new Map,c=(n,a)=>{if(o.has(n))return;let d={off:()=>{},prefix:a};o.set(n,d);let f=n.topology.subscribe(l=>{for(let r of l){if(r[0]!==u)continue;let e=r[1];if(s(e,n,a),e.kind==="added"&&e.nodeKind==="mount"){let t=n._mounts.get(e.name);if(t instanceof y){let i=`${a}${e.name}::`;c(t,i)}}else if(e.kind==="removed"&&e.nodeKind==="mount"){let t=`${a}${e.name}::`;for(let[i,h]of Array.from(o.entries()))i!==p&&h.prefix.startsWith(t)&&(h.off(),o.delete(i))}}});d.off=f;for(let[l,r]of n._mounts)if(r instanceof y){let e=`${a}${l}::`;c(r,e)}};return c(p,""),()=>{for(let n of o.values())n.off();o.clear()}}function L(p,s={}){let o=[],c=s.requireFound??!0;if(s.skipDescribe!==!0)try{let r=p.describe(),e=new Set(Object.keys(r.nodes)),t=[];for(let[i,h]of Object.entries(r.nodes))for(let b of h.deps)b!==""&&!e.has(b)&&t.push(`${i} \u2192 ${b}`);for(let i of r.edges)e.has(i.from)||t.push(`edge.from: ${i.from}`),e.has(i.to)||t.push(`edge.to: ${i.to}`);t.length>0?o.push({kind:"describe",ok:!1,reason:`describe() has ${t.length} dangling pointer(s); nodes \u2289 deps`,danglingDeps:t}):o.push({kind:"describe",ok:!0,nodeCount:e.size,edgeCount:r.edges.length})}catch(r){o.push({kind:"describe",ok:!1,reason:`describe() threw: ${r instanceof Error?r.message:String(r)}`})}for(let r of s.formats??[])try{let e=p.describe({format:r});typeof e!="string"||e.length===0?o.push({kind:"describe-format",ok:!1,format:r,reason:`describe({ format: "${r}" }) returned empty or non-string output`}):o.push({kind:"describe-format",ok:!0,format:r,length:e.length})}catch(e){o.push({kind:"describe-format",ok:!1,format:r,reason:e instanceof Error?e.message:String(e)})}for(let r of s.paths??[])try{p.resolve(r),o.push({kind:"observe",ok:!0,path:r})}catch(e){o.push({kind:"observe",ok:!1,path:r,reason:e instanceof Error?e.message:String(e)})}for(let[r,e]of s.pairs??[])try{let t=p.explain(r,e);c&&t.found===!1?o.push({kind:"explain",ok:!1,from:r,to:e,reason:`explain(${r} \u2192 ${e}) found no path${t.reason?`: ${t.reason}`:""}`}):o.push({kind:"explain",ok:!0,from:r,to:e,found:t.found,steps:t.steps.length})}catch(t){o.push({kind:"explain",ok:!1,from:r,to:e,reason:t instanceof Error?t.message:String(t)})}let n=o.filter(r=>!r.ok),a=n.length===0,d=s.paths?.length??0,f=s.pairs?.length??0,l=s.formats?.length??0;return{ok:a,checks:o,failures:n,summary(){let r=[s.skipDescribe===!0?null:"describe",l>0?`${l} format${l===1?"":"s"}`:null,d>0?`${d} observe path${d===1?"":"s"}`:null,f>0?`${f} explain pair${f===1?"":"s"}`:null].filter(t=>t!=null),e=r.length>0?r.join(", "):"describe-only";return a?`validateGraphObservability: OK (${e})`:`validateGraphObservability: ${n.length} failure(s) across ${e}`}}}export{N as a,L as b,j as c};
@@ -0,0 +1 @@
1
+ import{D as N,E as C,F as p,p as A}from"./chunk-ZB5EHBIO.js";import{b as h,c as S,d as x,i as T,j as b}from"./chunk-CK2E7BTU.js";function y(e,n,t){let s=new Set;for(let i of e.split(",")){let[r,o]=i.split("/"),u=o?Number.parseInt(o,10):1;if(Number.isNaN(u)||u<1)throw new Error(`Invalid cron step: ${i}`);let a,d;if(r==="*")a=n,d=t;else if(r.includes("-")){let[f,c]=r.split("-");a=Number.parseInt(f,10),d=Number.parseInt(c,10)}else a=Number.parseInt(r,10),d=a;if(Number.isNaN(a)||Number.isNaN(d))throw new Error(`Invalid cron field: ${e}`);if(a<n||d>t)throw new Error(`Cron field out of range: ${e} (${n}-${t})`);if(a>d)throw new Error(`Invalid cron range: ${a}-${d} in ${e}`);for(let f=a;f<=d;f+=u)s.add(f)}return s}function I(e){let n=e.trim().split(/\s+/);if(n.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${n.length}`);return{minutes:y(n[0],0,59),hours:y(n[1],0,23),daysOfMonth:y(n[2],1,31),months:y(n[3],1,12),daysOfWeek:y(n[4],0,6)}}function L(e,n){return e.minutes.has(n.getMinutes())&&e.hours.has(n.getHours())&&e.daysOfMonth.has(n.getDate())&&e.months.has(n.getMonth()+1)&&e.daysOfWeek.has(n.getDay())}function m(e){return{describeKind:"producer",...e}}function $(e){return/[\\^$+?.()|[\]{}]/.test(e)?`\\${e}`:e}function J(e){let n="^";for(let t=0;t<e.length;t+=1){let s=e[t];if(s==="*"){e[t+1]==="*"?(n+=".*",t+=1):n+="[^/]*";continue}n+=$(s)}return n+="$",new RegExp(n)}function Q(e,n){for(let t of n)if(t.test(e))return!0;return!1}function _(e,n){let t=N([e],(i,r)=>{let o=i[0];if(o==null||o.length===0){r.down([[x]]);return}for(let u of o)r.emit(u)},{describeKind:"derived",initial:e.cache}),s=t.subscribe.bind(t);return t.subscribe=(i,r)=>(n(i),s(i,r)),t}function X(e,n){let{signal:t,period:s,...i}=n??{};return p(r=>{let o=!1,u=0,a,d,f=()=>{o=!0,a!==void 0&&clearTimeout(a),d!==void 0&&clearInterval(d),t?.removeEventListener("abort",l)},c=()=>{o||(s!=null?(r.emit(u++),d=setInterval(()=>{o||r.emit(u++)},s)):(o=!0,t?.removeEventListener("abort",l),r.emit(u++),r.down([[T]])))},l=()=>{o||(f(),r.down([[b,t.reason]]))};if(t?.aborted){l();return}return a=setTimeout(c,e),t?.addEventListener("abort",l,{once:!0}),f},m(i))}function Z(e){let{signal:n,...t}=e??{};return p(s=>{let i=!1,r,o,u=!1,a=!1,d=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,f=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,c=typeof document<"u"?document:void 0,l=()=>{r!==void 0&&f&&f(r),o!==void 0&&clearTimeout(o),r=void 0,o=void 0},v=()=>{i=!0,l(),u&&(n?.removeEventListener("abort",w),u=!1),a&&c&&(c.removeEventListener("visibilitychange",k),a=!1)},w=()=>{i||(v(),s.down([[b,n.reason]]))},O=F=>{i||(s.emit(F),g())},g=()=>{i||(d&&(!c||c.visibilityState!=="hidden")?r=d(O):o=setTimeout(()=>O(performance.now()),16))},k=()=>{i||(l(),g())};return n?.aborted?(w(),v):(n?.addEventListener("abort",w,{once:!0}),u=n!==void 0,c&&d&&(c.addEventListener("visibilitychange",k),a=!0),g(),v)},m(t))}function ee(e,n){let t=I(e),{tickMs:s,output:i,...r}=n??{},o=s??6e4,u=i==="date";return p(a=>{let d=-1,f=()=>{let l=new Date,v=l.getFullYear()*1e8+(l.getMonth()+1)*1e6+l.getDate()*1e4+l.getHours()*100+l.getMinutes();v!==d&&L(t,l)&&(d=v,a.emit(u?l:A()))};f();let c=setInterval(f,o);return()=>clearInterval(c)},{...m(r),name:r.name??`cron:${e}`})}function ne(e,n,t){let{capture:s,passive:i,once:r,...o}=t??{};return p(u=>{let a=f=>{u.emit(f)},d={capture:s,passive:i,once:r};return e.addEventListener(n,a,d),()=>e.removeEventListener(n,a,d)},m(o))}function M(e,n){return p(t=>{let s=!1;try{for(let i of e){if(s)return;t.emit(i)}s||t.down([[T]])}catch(i){s||t.down([[b,i]])}return()=>{s=!0}},m(n))}function K(e){return e!=null&&typeof e.then=="function"}function W(e,n){let{signal:t,...s}=n??{};return p(i=>{let r=!1,o=()=>{r||(r=!0,i.down([[b,t.reason]]))};if(t?.aborted){o();return}return t?.addEventListener("abort",o,{once:!0}),Promise.resolve(e).then(u=>{r||(r=!0,t?.removeEventListener("abort",o),i.emit(u),i.down([[T]]))},u=>{r||(r=!0,t?.removeEventListener("abort",o),i.down([[b,u]]))}),()=>{r=!0,t?.removeEventListener("abort",o)}},m(s))}function q(e,n){let{signal:t,...s}=n??{};return p(i=>{let r=new AbortController,o=()=>r.abort(t?.reason);t?.aborted?r.abort(t.reason):t?.addEventListener("abort",o,{once:!0});let u=t??r.signal,a=!1,d=e[Symbol.asyncIterator](),f=()=>{a||u.aborted||Promise.resolve(d.next()).then(c=>{if(!(a||u.aborted)){if(c.done){i.down([[T]]);return}i.emit(c.value),f()}},c=>{!a&&!u.aborted&&i.down([[b,c]])})};return f(),()=>{a=!0,t?.removeEventListener("abort",o),r.abort(),Promise.resolve(d.return?.()).catch(()=>{})}},m(s))}function H(e){return e!=null&&typeof e=="object"&&"cache"in e&&typeof e.subscribe=="function"}function te(e,n){if(H(e))return e;if(K(e))return W(e,n);if(e!=null){let t=e;if(typeof t[Symbol.asyncIterator]=="function")return q(e,n);if(typeof t[Symbol.iterator]=="function")return M(e,n)}return V(e)}function V(...e){return M(e,void 0)}function re(e){return p(n=>{n.down([[T]])},m(e))}function oe(e){return p(()=>{},m(e))}function ie(e,n){return p(t=>{t.down([[b,e]])},m(n))}function se(e,n,t){return N([e],(i,r)=>{let o=i[0];if(o!=null&&o.length>0)for(let u of o)n(u)},{describeKind:"effect",...t}).subscribe(()=>{})}function ue(e,n){return N([e],(t,s,i)=>{i.store.buf||(i.store.buf=[]);let r=i.store.buf,o=t[0];if(o!=null&&o.length>0)for(let u of o)r.push(u);if(i.terminalDeps[0]===!0){s.emit([...r]),s.down([[T]]);return}(o==null||o.length===0)&&s.down([[x]])},{describeKind:"derived",completeWhenDepsComplete:!1,...n})}function ae(e,n){return p(t=>e.subscribe(s=>{t.down(s)}),{...m(n),initial:e.cache})}function D(e,n,t){if(n<1)throw new RangeError("replay expects bufferSize >= 1");let s=[],i=p(r=>e.subscribe(o=>{for(let u of o)u[0]===h&&(s.push(u[1]),s.length>n&&s.shift());r.down(o)}),{...m(t),initial:e.cache});return _(i,r=>{for(let o of s)r([[h,o]])})}function de(e,n){return D(e,1,n)}function fe(e){return new Promise((n,t)=>{let s=!1,i=!1,r;r=e.subscribe(o=>{for(let u of o){if(s)return;if(u[0]===h){s=!0,n(u[1]),r?(r(),r=void 0):i=!0;return}if(u[0]===b){s=!0,t(u[1]),r?(r(),r=void 0):i=!0;return}if(u[0]===T){s=!0,t(new Error("completed without DATA")),r?(r(),r=void 0):i=!0;return}}}),i&&(r?.(),r=void 0)})}function P(e,n){return new Promise((t,s)=>{let i=!1,r=!1,o;o=e.subscribe(u=>{for(let a of u){if(i)return;if(a[0]===h){let d=a[1];if(n(d)){i=!0,t(d),o?(o(),o=void 0):r=!0;return}}if(a[0]===b){i=!0,s(a[1]),o?(o(),o=void 0):r=!0;return}if(a[0]===T){i=!0,s(new Error("completed without matching value")),o?(o(),o=void 0):r=!0;return}}}),r&&(o?.(),o=void 0)})}var E,R;async function ce(e,n){let t=n?.predicate??(i=>i!=null);if(n?.timeoutMs==null||n.timeoutMs<=0)return await P(e,t);if(E===void 0){let[i,r]=await Promise.all([import("./resilience-QAHKANT5.js"),import("./backoff-HPZMEZNF.js")]);E=i.timeout,R=r.NS_PER_MS}let s=E(e,n.timeoutMs*R);return await P(s,t)}var le=D;function pe(e){return e.subscribe(()=>{})}function me(e){let n=C(0);return{node:n,increment(){let t=n.cache??0;return t>=e?!1:(n.down([[S],[h,t+1]]),!0)},get(){return n.cache??0},atCap(){return(n.cache??0)>=e}}}export{I as a,L as b,$ as c,J as d,Q as e,X as f,Z as g,ee as h,ne as i,M as j,W as k,q as l,te as m,V as n,re as o,oe as p,ie as q,se as r,ue as s,ae as t,D as u,de as v,fe as w,P as x,ce as y,le as z,pe as A,me as B};
@@ -0,0 +1,2 @@
1
+ import{b as f}from"./chunk-I6VIH3VA.js";import{randomBytes as g}from"crypto";import{mkdirSync as y,readdirSync as S,readFileSync as m,renameSync as T,unlinkSync as h,writeFileSync as k}from"fs";import{basename as w,dirname as N,join as d}from"path";import{DatabaseSync as R}from"sqlite";function F(u){let s=new TextEncoder,i=new TextDecoder("utf-8",{fatal:!0}),n=e=>{let t="";for(let r of e){if(r.length===1&&/[a-zA-Z0-9_-]/.test(r)){t+=r;continue}for(let a of s.encode(r))t+=`%${a.toString(16).padStart(2,"0")}`}return d(u,`${t}.json`)},p=e=>{if(!e.endsWith(".json"))return null;let t=e.slice(0,-5),r=[],a=l=>{for(let o=0;o<l.length;o++)r.push(l.charCodeAt(o))},c=0;for(;c<t.length;){let l=t[c];if(l==="%"&&c+2<t.length){let o=t.slice(c+1,c+3);if(/^[0-9a-f]{2}$/i.test(o)){r.push(Number.parseInt(o,16)),c+=3;continue}}a(l),c+=1}try{return i.decode(new Uint8Array(r))}catch{return null}};return{save(e,t){y(u,{recursive:!0});let r=n(e),a=`${f(t)}
2
+ `,c=w(r),l=N(r),o=d(l,`.${c}.${g(8).toString("hex")}.tmp`);try{k(o,a,"utf8"),T(o,r)}catch(E){try{h(o)}catch{}throw E}},load(e){try{let t=m(n(e),"utf8").trim();return t?JSON.parse(t):null}catch{return null}},clear(e){try{h(n(e))}catch(t){if(t.code!=="ENOENT")throw t}},list(){try{let e=S(u),t=[];for(let r of e){if(r.startsWith("."))continue;let a=p(r);a!==null&&t.push(a)}return t.sort()}catch(e){if(e.code==="ENOENT")return[];throw e}}}}function L(u){let s=new R(u);return s.exec("CREATE TABLE IF NOT EXISTS graphrefly_checkpoint (k TEXT PRIMARY KEY, v TEXT NOT NULL)"),{save(i,n){let p=f(n);s.prepare("INSERT OR REPLACE INTO graphrefly_checkpoint (k, v) VALUES (?, ?)").run(i,p)},load(i){let n=s.prepare("SELECT v FROM graphrefly_checkpoint WHERE k = ?").get(i);return n===void 0||typeof n.v!="string"||n.v.trim()===""?null:JSON.parse(n.v)},clear(i){s.prepare("DELETE FROM graphrefly_checkpoint WHERE k = ?").run(i)},list(){return s.prepare("SELECT k FROM graphrefly_checkpoint ORDER BY k").all().map(n=>n.k)},close(){try{s.close()}catch{}}}}export{F as a,L as b};
@@ -0,0 +1,78 @@
1
+ import{b as q}from"./chunk-ERLIRFPA.js";import{g as W,j as D}from"./chunk-CKCSDI7T.js";import{E as M,F as A,G as L,H as T}from"./chunk-ZB5EHBIO.js";import{b as Q}from"./chunk-QYADASLV.js";var ie={};Q(ie,{compileSpec:()=>ne,decompileGraph:()=>se,extractFnFactory:()=>z,extractSourceFactory:()=>U,generateCatalogPrompt:()=>V,isRichFnEntry:()=>_,isRichSourceEntry:()=>J,llmCompose:()=>ae,llmRefine:()=>H,specDiff:()=>re,validateSpec:()=>E,validateSpecAgainstCatalog:()=>I});function _(a){return typeof a=="object"&&a!==null&&"factory"in a}function J(a){return typeof a=="object"&&a!==null&&"factory"in a}function z(a){return _(a)?a.factory:a}function U(a){return J(a)?a.factory:a}function V(a){let o=[];if(a.fns){let n=new Map;for(let[p,i]of Object.entries(a.fns)){let l=_(i)?i.tags?.[0]??"Other":"Other";n.has(l)||n.set(l,[]),n.get(l).push(X(p,i))}for(let[p,i]of n)o.push(`${p}:
2
+ ${i.join(`
3
+ `)}`)}if(a.sources){let n=[];for(let[p,i]of Object.entries(a.sources))n.push(Z(p,i));n.length>0&&o.push(`Sources:
4
+ ${n.join(`
5
+ `)}`)}return o.join(`
6
+
7
+ `)}function X(a,o){if(!_(o))return`- ${a}`;let n=`- ${a}: ${o.description}`;if(o.configSchema){let p=Object.entries(o.configSchema).map(([i,l])=>{let s=`${i}: ${l.type}`;return l.enum&&(s+=` (${l.enum.join("|")})`),l.required===!1&&(s+="?"),s});n+=`. Config: { ${p.join(", ")} }`}return n}function Z(a,o){if(!J(o))return`- ${a}`;let n=`- ${a}: ${o.description}`;if(o.configSchema){let p=Object.entries(o.configSchema).map(([i,l])=>{let s=`${i}: ${l.type}`;return l.required===!1&&(s+="?"),s});n+=`. Config: { ${p.join(", ")} }`}return n}function I(a,o){let n=[],p=new Set(Object.keys(o.fns??{})),i=new Set(Object.keys(o.sources??{}));for(let[l,s]of Object.entries(a.nodes)){if(s.type==="template")continue;let c=s;if(c.fn&&p.size>0&&!p.has(c.fn))if(i.has(c.fn))n.push(`Node "${l}": fn "${c.fn}" is a source, not a function. Use it as a producer source instead, or use a function from: ${[...p].join(", ")}`);else{let e=P(c.fn,p);n.push(`Node "${l}": fn "${c.fn}" not found in catalog`+(e?`. Did you mean "${e}"?`:""))}if(c.source&&i.size>0&&!i.has(c.source))if(p.has(c.source))n.push(`Node "${l}": source "${c.source}" is a function, not a source. Use it as fn instead, or use a source from: ${[...i].join(", ")}`);else{let e=P(c.source,i);n.push(`Node "${l}": source "${c.source}" not found in catalog`+(e?`. Did you mean "${e}"?`:""))}if(c.fn&&c.config&&o.fns?.[c.fn]){let e=o.fns[c.fn];if(_(e)&&e.configSchema){for(let[m,$]of Object.entries(e.configSchema))if($.required!==!1&&!(m in c.config)&&n.push(`Node "${l}": config missing required field "${m}"`),m in c.config&&$.enum){let w=c.config[m];$.enum.includes(w)||n.push(`Node "${l}": config.${m} = ${JSON.stringify(w)}, expected one of: ${$.enum.join(", ")}`)}}}}if(a.templates){for(let[l,s]of Object.entries(a.templates))for(let[c,e]of Object.entries(s.nodes))if(e.fn&&p.size>0&&!p.has(e.fn)){let m=P(e.fn,p);n.push(`Template "${l}" node "${c}": fn "${e.fn}" not found in catalog`+(m?`. Did you mean "${m}"?`:""))}}return{valid:n.length===0,errors:n}}function P(a,o){let n=null,p=1/0,i=a.toLowerCase();for(let l of o){let s=ee(i,l.toLowerCase());s<p&&s<=Math.max(3,Math.floor(a.length/2))&&(p=s,n=l)}return n}function ee(a,o){let n=a.length,p=o.length,i=Array.from({length:n+1},(l,s)=>Array.from({length:p+1},(c,e)=>s===0?e:e===0?s:0));for(let l=1;l<=n;l++)for(let s=1;s<=p;s++)i[l][s]=a[l-1]===o[s-1]?i[l-1][s-1]:1+Math.min(i[l-1][s],i[l][s-1],i[l-1][s-1]);return i[n][p]}var Y=new Set(["state","producer","derived","effect","operator","template"]),te=new Set(["state","producer","derived","effect","operator"]);function E(a){let o=[];if(a==null||typeof a!="object")return{valid:!1,errors:["GraphSpec must be a non-null object"]};let n=a;if((typeof n.name!="string"||n.name.length===0)&&o.push("Missing or empty 'name' field"),n.nodes==null||typeof n.nodes!="object"||Array.isArray(n.nodes))return o.push("Missing or invalid 'nodes' field (must be an object)"),{valid:!1,errors:o};let p=new Set(Object.keys(n.nodes)),i=new Map,l=new Map;if(n.templates!=null&&typeof n.templates=="object"&&!Array.isArray(n.templates)){for(let[s,c]of Object.entries(n.templates))if(c!=null&&typeof c=="object"){let e=c;l.set(s,{params:Array.isArray(e.params)?e.params:[]})}}if(n.templates!=null)if(typeof n.templates!="object"||Array.isArray(n.templates))o.push("'templates' must be an object");else for(let[s,c]of Object.entries(n.templates)){if(c==null||typeof c!="object"){o.push(`Template "${s}": must be an object`);continue}let e=c;if(Array.isArray(e.params)||o.push(`Template "${s}": missing 'params' array`),e.nodes==null||typeof e.nodes!="object"||Array.isArray(e.nodes))o.push(`Template "${s}": missing or invalid 'nodes' object`);else{let m=new Set(Array.isArray(e.params)?e.params:[]),$=new Set(Object.keys(e.nodes));for(let[w,R]of Object.entries(e.nodes)){if(R==null||typeof R!="object"){o.push(`Template "${s}" node "${w}": must be an object`);continue}let r=R;if((typeof r.type!="string"||!te.has(r.type))&&o.push(`Template "${s}" node "${w}": invalid type`),Array.isArray(r.deps))for(let f of r.deps)!$.has(f)&&!m.has(f)&&o.push(`Template "${s}" node "${w}": dep "${f}" is not an inner node or param`)}typeof e.output!="string"?o.push(`Template "${s}": missing 'output' string`):e.nodes[e.output]||o.push(`Template "${s}": output "${e.output}" is not a declared node`)}}for(let[s,c]of Object.entries(n.nodes)){if(c==null||typeof c!="object"){o.push(`Node "${s}": must be an object`);continue}let e=c;if(typeof e.type!="string"||!Y.has(e.type)){o.push(`Node "${s}": invalid type "${String(e.type)}" (expected: ${[...Y].join(", ")})`);continue}if(i.set(s,e.type),e.type==="template")if(typeof e.template!="string"||!l.has(e.template))o.push(`Node "${s}": template "${String(e.template)}" not found in templates`);else if(e.bind==null||typeof e.bind!="object"||Array.isArray(e.bind))o.push(`Node "${s}": template ref requires 'bind' object`);else{let m=l.get(e.template),$=e.bind;for(let w of m.params)w in $||o.push(`Node "${s}": template param "${w}" is not bound (template "${e.template}")`);for(let[,w]of Object.entries($))typeof w=="string"&&!p.has(w)&&o.push(`Node "${s}": bind target "${w}" does not reference an existing node`)}else{if(Array.isArray(e.deps))for(let m of e.deps)m===s?o.push(`Node "${s}": self-referencing dep`):p.has(m)||o.push(`Node "${s}": dep "${m}" does not reference an existing node`);(e.type==="derived"||e.type==="effect"||e.type==="operator")&&!Array.isArray(e.deps)&&o.push(`Node "${s}": ${e.type} node should have a 'deps' array`)}}if(n.feedback!=null)if(!Array.isArray(n.feedback))o.push("'feedback' must be an array");else for(let s=0;s<n.feedback.length;s++){let c=n.feedback[s];if(c==null||typeof c!="object"){o.push(`Feedback [${s}]: must be an object`);continue}let e=c;(typeof e.from!="string"||!p.has(e.from))&&o.push(`Feedback [${s}]: 'from' "${String(e.from)}" does not reference an existing node`),typeof e.from=="string"&&e.from===e.to&&o.push(`Feedback [${s}]: 'from' and 'to' must be different nodes`),typeof e.to!="string"||!p.has(e.to)?o.push(`Feedback [${s}]: 'to' "${String(e.to)}" does not reference an existing node`):typeof e.to=="string"&&i.get(e.to)!=="state"&&o.push(`Feedback [${s}]: 'to' node "${e.to}" must be a state node (got "${i.get(e.to)??"unknown"}")`)}return{valid:o.length===0,errors:o}}function ne(a,o){let n=E(a);if(!n.valid)throw new Error(`compileSpec: invalid GraphSpec:
8
+ ${n.errors.join(`
9
+ `)}`);let p=o?.catalog??{},i=new D(a.name),l=a.templates??{},s=I(a,p);if(!s.valid)throw new Error(`compileSpec: catalog validation errors:
10
+ ${s.errors.join(`
11
+ `)}`);let c=r=>{let f=p.fns?.[r];return f?z(f):void 0},e=r=>{let f=p.sources?.[r];return f?U(f):void 0},m=new Map,$=[];for(let[r,f]of Object.entries(a.nodes)){if(f.type==="template")continue;let d=f;if(d.type==="state"){let h=M(d.initial,{name:r,meta:d.meta?{...d.meta}:void 0});i.add(h,{name:r}),m.set(r,h)}else if(d.type==="producer"){let h=d.source?e(d.source):void 0,b=d.fn?c(d.fn):void 0;if(h){let t=h(d.config??{});i.add(t,{name:r}),m.set(r,t)}else if(b){let t=b([],d.config??{});i.add(t,{name:r}),m.set(r,t)}else{let t=A(()=>{},{name:r,meta:{...d.meta,_specFn:d.fn,_specSource:d.source}});i.add(t,{name:r}),m.set(r,t)}}else $.push([r,d])}let w=!0,R=new Map($);for(;R.size>0&&w;){w=!1;for(let[r,f]of[...R.entries()]){let d=f.deps??[];if(!d.every(y=>m.has(y)))continue;let h=d.map(y=>m.get(y)),b=f.fn?c(f.fn):void 0,t;b?t=b(h,f.config??{}):f.type==="effect"?t=T(h,()=>{}):t=L(h,y=>y[0]),i.add(t,{name:r}),m.set(r,t),R.delete(r),w=!0}}if(R.size>0){let r=[...R.keys()].sort().join(", ");throw new Error(`compileSpec: unresolvable deps for nodes: ${r}`)}for(let[r,f]of Object.entries(a.nodes)){if(f.type!=="template")continue;let d=f,h=l[d.template],b=new D(r),t=new Map,y=[];for(let[g,u]of Object.entries(h.nodes)){let v=(u.deps??[]).map(j=>j.startsWith("$")&&d.bind[j]?d.bind[j]:j),F={...u,deps:v};if(u.type==="state"){let j=M(u.initial,{name:g,meta:u.meta?{...u.meta}:void 0});b.add(j,{name:g}),t.set(g,j)}else if(u.type==="producer"){let j=u.source?e(u.source):void 0,O=u.fn?c(u.fn):void 0;if(j){let S=j(u.config??{});b.add(S,{name:g}),t.set(g,S)}else if(O){let S=O([],u.config??{});b.add(S,{name:g}),t.set(g,S)}else{let S=A(()=>{},{name:g,meta:{...u.meta,_specFn:u.fn,_specSource:u.source}});b.add(S,{name:g}),t.set(g,S)}}else y.push([g,F])}let N=!0,k=new Map(y);for(;k.size>0&&N;){N=!1;for(let[g,u]of[...k.entries()]){let v=u.deps??[];if(!v.every(G=>t.has(G)||m.has(G)))continue;let j=v.map(G=>t.get(G)??m.get(G)),O=u.fn?c(u.fn):void 0,S;O?S=O(j,u.config??{}):u.type==="effect"?S=T(j,()=>{}):S=L(j,G=>G[0]),b.add(S,{name:g}),t.set(g,S),k.delete(g),N=!0}}if(k.size>0){let g=[...k.keys()].sort().join(", ");throw new Error(`compileSpec: template "${d.template}" has unresolvable deps: ${g}`)}i.mount(r,b);let x=`${r}::${h.output}`;m.set(r,i.resolve(x));try{let g=i.resolve(x);g.meta._templateName?.emit(d.template),g.meta._templateBind?.emit(d.bind)}catch{}}for(let r of a.feedback??[])q(i,r.from,r.to,{maxIterations:r.maxIterations});return i}var oe=new Set(["reduction","reduction_type","_specFn","_specSource","_templateName","_templateBind","feedbackFrom","feedbackTo","_internal"]);function se(a){let o=a.describe({detail:"standard"}),n={},p=[],i=`::${W}::`,l=/^__feedback_(?!effect_)(.+)$/,s=new Set;for(let r of Object.keys(o.nodes)){if(r.includes(i))continue;let f=l.exec(r);if(f){s.add(f[1]);let d=o.nodes[r]?.meta;d?.feedbackFrom&&d?.feedbackTo&&p.push({from:d.feedbackFrom,to:d.feedbackTo,...d.maxIterations?{maxIterations:d.maxIterations}:{}})}}for(let[r,f]of Object.entries(o.nodes)){if(r.includes(i)||l.test(r)||f.meta?._internal||r.startsWith("__feedback_effect_")||r.startsWith("__bridge_")||r.includes("::"))continue;let d={type:f.type};if(f.deps.length>0&&(d.deps=f.deps.filter(h=>!h.includes("::"))),f.type==="state"&&f.value!==void 0&&(d.initial=f.value),f.meta&&Object.keys(f.meta).length>0){let h={};for(let[b,t]of Object.entries(f.meta))oe.has(b)||(h[b]=t);Object.keys(h).length>0&&(d.meta=h)}n[r]=d}let c={},e={},m=new Set;for(let r of o.subgraphs){let f=`${r}::`;for(let[d,h]of Object.entries(o.nodes)){if(!d.startsWith(f)||d.includes(i))continue;let b=h.meta;if(b?._templateName&&b?._templateBind){let t=b._templateName,y=b._templateBind;if(!c[t]){let N={},k=new Set,x=`${r}::`;for(let[O,S]of Object.entries(o.nodes)){if(!O.startsWith(x)||O.includes(i))continue;let G=O.slice(x.length);G.includes("::")||(k.add(G),N[G]={type:S.type,...S.deps.length>0?{deps:S.deps.map(C=>C.startsWith(x)?C.slice(x.length):C)}:{}})}let g=[],u=new Map;for(let O of Object.values(N))for(let S of O.deps??[])if(!k.has(S)&&!u.has(S)){let G=`$${S}`;g.push(G),u.set(S,G)}for(let O of Object.values(N))O.deps&&(O.deps=O.deps.map(S=>u.get(S)??S));let v=new Set;for(let O of Object.values(N))for(let S of O.deps??[])k.has(S)&&v.add(S);let j=[...k].filter(O=>!v.has(O))[0]??[...k].pop();c[t]={params:g,nodes:N,output:j}}delete n[r],e[r]={type:"template",template:t,bind:y},m.add(r);break}}}let $=new Map;for(let r of o.subgraphs){if(m.has(r))continue;let f={},d=`${r}::`;for(let[b,t]of Object.entries(o.nodes)){if(b.includes(i)||!b.startsWith(d))continue;let y=b.slice(d.length);y.includes("::")||(f[y]={type:t.type,...t.deps.length>0?{deps:t.deps.map(N=>N.startsWith(d)?N.slice(d.length):N)}:{}})}let h=JSON.stringify(Object.fromEntries(Object.entries(f).sort(([b],[t])=>b.localeCompare(t)).map(([b,t])=>[b,{type:t.type,deps:t.deps??[]}])));$.has(h)||$.set(h,[]),$.get(h).push({name:r,nodes:f})}for(let[,r]of $){if(r.length<2)continue;let f=`${r[0].name}_template`,d=r[0].nodes,h=new Set(Object.keys(d)),b=[],t=new Map;for(let g of Object.values(d))for(let u of g.deps??[])if(!h.has(u)&&!t.has(u)){let v=`$${u}`;b.push(v),t.set(u,v)}let y=new Set;for(let g of Object.values(d))for(let u of g.deps??[])h.has(u)&&y.add(u);let k=[...h].filter(g=>!y.has(g))[0]??[...h].pop(),x={};for(let[g,u]of Object.entries(d))x[g]={...u,deps:u.deps?.map(v=>t.get(v)??v)};c[f]={params:b,nodes:x,output:k};for(let g of r){delete n[g.name];let u={},v=new Set(Object.keys(g.nodes));for(let F of Object.values(g.nodes))for(let j of F.deps??[])if(!v.has(j)){let O=t.get(j)??`$${j}`;u[O]=j}e[g.name]={type:"template",template:f,bind:u}}}let w={...n,...e},R={name:o.name,nodes:w};return Object.keys(c).length>0&&(R.templates=c),p.length>0&&(R.feedback=p),R}function re(a,o){let n=[];a.name!==o.name&&n.push({type:"changed",path:"name",detail:`"${a.name}" \u2192 "${o.name}"`});let p=new Set(Object.keys(a.nodes)),i=new Set(Object.keys(o.nodes));for(let t of i)if(!p.has(t)){let y=o.nodes[t];n.push({type:"added",path:`nodes.${t}`,detail:`type: ${y.type}`})}for(let t of p)i.has(t)||n.push({type:"removed",path:`nodes.${t}`});for(let t of p){if(!i.has(t))continue;let y=a.nodes[t],N=o.nodes[t];if(JSON.stringify(y)!==JSON.stringify(N)){let k=[];y.type!==N.type&&k.push(`type: ${y.type} \u2192 ${N.type}`),JSON.stringify(y.deps)!==JSON.stringify(N.deps)&&k.push("deps changed"),y.fn!==N.fn&&k.push(`fn: ${y.fn} \u2192 ${N.fn}`),JSON.stringify(y.config)!==JSON.stringify(N.config)&&k.push("config changed"),n.push({type:"changed",path:`nodes.${t}`,detail:k.join("; ")||"modified"})}}let l=a.templates??{},s=o.templates??{},c=new Set(Object.keys(l)),e=new Set(Object.keys(s));for(let t of e)c.has(t)||n.push({type:"added",path:`templates.${t}`});for(let t of c)e.has(t)||n.push({type:"removed",path:`templates.${t}`});for(let t of c)e.has(t)&&JSON.stringify(l[t])!==JSON.stringify(s[t])&&n.push({type:"changed",path:`templates.${t}`,detail:"template definition changed"});let m=a.feedback??[],$=o.feedback??[],w=new Set(m.map(t=>`${t.from}->${t.to}`)),R=new Set($.map(t=>`${t.from}->${t.to}`));for(let t of $){let y=`${t.from}->${t.to}`;w.has(y)||n.push({type:"added",path:`feedback.${y}`,detail:`maxIterations: ${t.maxIterations??10}`})}for(let t of m){let y=`${t.from}->${t.to}`;R.has(y)||n.push({type:"removed",path:`feedback.${y}`})}for(let t of m){let y=`${t.from}->${t.to}`,N=$.find(k=>k.from===t.from&&k.to===t.to);N&&JSON.stringify(t)!==JSON.stringify(N)&&n.push({type:"changed",path:`feedback.${y}`,detail:`maxIterations: ${t.maxIterations??10} \u2192 ${N.maxIterations??10}`})}let r=n.filter(t=>t.type==="added").length,f=n.filter(t=>t.type==="removed").length,d=n.filter(t=>t.type==="changed").length,h=[];r&&h.push(`${r} added`),f&&h.push(`${f} removed`),d&&h.push(`${d} changed`);let b=h.length>0?h.join(", "):"no changes";return{entries:n,summary:b}}var B=`You are a graph architect for GraphReFly, a reactive graph protocol.
12
+
13
+ Given a natural-language description, produce a JSON GraphSpec with this structure:
14
+
15
+ {
16
+ "name": "<graph_name>",
17
+ "nodes": {
18
+ "<node_name>": {
19
+ "type": "state" | "derived" | "producer" | "effect" | "operator",
20
+ "deps": ["<dep_node_name>", ...],
21
+ "fn": "<catalog_function_name>",
22
+ "source": "<catalog_source_name>",
23
+ "config": { ... },
24
+ "initial": <value>,
25
+ "meta": { "description": "<purpose>" }
26
+ },
27
+ "<template_instance>": {
28
+ "type": "template",
29
+ "template": "<template_name>",
30
+ "bind": { "$param": "node_name" }
31
+ }
32
+ },
33
+ "templates": {
34
+ "<template_name>": {
35
+ "params": ["$param1", "$param2"],
36
+ "nodes": { ... },
37
+ "output": "<output_node>"
38
+ }
39
+ },
40
+ "feedback": [
41
+ { "from": "<condition_node>", "to": "<state_node>", "maxIterations": 10 }
42
+ ]
43
+ }
44
+
45
+ Rules:
46
+ - "state" nodes hold user/LLM-writable values (knobs). Use "initial" for default values.
47
+ - "derived" nodes compute from deps using a named "fn".
48
+ - "effect" nodes produce side effects from deps.
49
+ - "producer" nodes generate values from a named "source".
50
+ - Use "templates" when the same subgraph pattern repeats (e.g., per-source resilience).
51
+ - Use "feedback" for bounded cycles where a derived value writes back to a state node.
52
+ - meta.description is required for every node.
53
+ - Return ONLY valid JSON, no markdown fences or commentary.`;function K(a){let o=a.match(/^```(?:json)?\s*([\s\S]*?)\s*```[\s\S]*$/);return o?o[1]:a}async function ae(a,o,n){let p=B,i=n?.catalogDescription??(n?.catalog?V(n.catalog):void 0);i&&(p+=`
54
+
55
+ Available catalog (use ONLY these names):
56
+ ${i}`),n?.systemPromptExtra&&(p+=`
57
+
58
+ ${n.systemPromptExtra}`);let l=[{role:"system",content:p},{role:"user",content:a}],e=(await o.invoke(l,{model:n?.model,temperature:n?.temperature??0,maxTokens:n?.maxTokens})).content.trim();e.startsWith("```")&&(e=K(e));let m;try{m=JSON.parse(e)}catch{throw new Error(`llmCompose: LLM response is not valid JSON: ${e.slice(0,200)}`)}let $=E(m);if(!$.valid)throw new Error(`llmCompose: invalid GraphSpec:
59
+ ${$.errors.join(`
60
+ `)}`);let w=m;if(n?.catalog){let R=n.maxAutoRefine??0;for(let r=0;r<=R;r++){let f=I(w,n.catalog);if(f.valid)break;if(r===R)throw new Error(`llmCompose: catalog validation failed after ${R} refine attempts:
61
+ ${f.errors.join(`
62
+ `)}`);w=await H(w,`Fix these catalog errors:
63
+ ${f.errors.join(`
64
+ `)}
65
+
66
+ Use ONLY functions and sources from the catalog.`,o,{...n,catalogDescription:i})}}return w}async function H(a,o,n,p){let i=B;p?.catalogDescription&&(i+=`
67
+
68
+ Available catalog:
69
+ ${p.catalogDescription}`),p?.systemPromptExtra&&(i+=`
70
+
71
+ ${p.systemPromptExtra}`);let l=[{role:"system",content:i},{role:"user",content:`Current GraphSpec:
72
+ ${JSON.stringify(a,null,2)}
73
+
74
+ Modification request: ${o}
75
+
76
+ Return the complete modified GraphSpec as JSON.`}],e=(await n.invoke(l,{model:p?.model,temperature:p?.temperature??0,maxTokens:p?.maxTokens})).content.trim();e.startsWith("```")&&(e=K(e));let m;try{m=JSON.parse(e)}catch{throw new Error(`llmRefine: LLM response is not valid JSON: ${e.slice(0,200)}`)}let $=E(m);if(!$.valid)throw new Error(`llmRefine: invalid GraphSpec:
77
+ ${$.errors.join(`
78
+ `)}`);return m}export{_ as a,J as b,z as c,U as d,V as e,I as f,E as g,ne as h,se as i,re as j,ae as k,H as l,ie as m};
@@ -0,0 +1 @@
1
+ import{a as E}from"./chunk-ESMPEKEV.js";import{a as B,b as R,i as _}from"./chunk-4VVTGLXJ.js";import{m as I}from"./chunk-2PMCKKRK.js";import{D as P,F as g,m as L,o as O}from"./chunk-ZB5EHBIO.js";import{b,c as k,d as y,h as C,i as h,j as T}from"./chunk-CK2E7BTU.js";function S(e){return{describeKind:"derived",...e}}function V(e){return e<0?0:e}function M(e){return e[1]}function W(e){if(typeof e!="number"||!Number.isFinite(e))throw new TypeError("backoff strategy must return a finite number");return e<0?0:e}function Z(e,s){let r=s?.count,n=s?.backoff,l=r!==void 0?r:n===void 0?0:2147483647;if(l<0)throw new RangeError("retry count must be >= 0");let u=n===void 0?null:typeof n=="string"?_(n):n;return g(t=>{let o=0,c=!1,i=null,f,a=new E;function w(){f?.(),f=void 0}function N(p){if(c)return;if(o>=l){w(),t.down([[T,p]]);return}let m=u===null?0:u(o,p,i);if(m==null){w(),t.down([[T,p]]);return}let d;try{d=W(m)}catch{w(),t.down([[T,p]]);return}i=d,o+=1,w();let v=d>0?d/1e6:1;a.start(v,()=>{c||x()})}function x(){a.cancel(),w(),f=e.subscribe(p=>{if(!c)for(let m of p){let d=m[0];if(d===k)t.down([[k]]);else if(d===b)o=0,i=null,t.emit(m[1]);else if(d===y)t.down([[y]]);else if(d===h)w(),t.down([[h]]);else if(d===T){N(M(m));return}else t.down([m])}})}return x(),()=>{c=!0,a.cancel(),w()}},{...S(),initial:e.cache})}function ee(e,s){let r=s?.count,n=s?.backoff,l=r!==void 0?r:n===void 0?0:2147483647;if(l<0)throw new RangeError("retry count must be >= 0");let u=n===void 0?null:typeof n=="string"?_(n):n;return g(t=>{let o=0,c=!1,i=null,f,a=new E;function w(){f?.(),f=void 0}function N(p){if(c)return;if(o>=l){w(),t.down([[T,p]]);return}let m=u===null?0:u(o,p,i);if(m==null){w(),t.down([[T,p]]);return}let d;try{d=W(m)}catch{w(),t.down([[T,p]]);return}i=d,o+=1,w();let v=d>0?d/1e6:1;a.start(v,()=>{c||x()})}function x(){a.cancel(),w();let p;try{p=e()}catch(m){N(m);return}f=p.subscribe(m=>{if(!c)for(let d of m){let v=d[0];if(v===k)t.down([[k]]);else if(v===b)o=0,i=null,t.emit(d[1]);else if(v===y)t.down([[y]]);else if(v===h)w(),t.down([[h]]);else if(v===T){N(M(d));return}else t.down([d])}})}return x(),()=>{c=!0,a.cancel(),w()}},{...S(),initial:s?.initial})}var A=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};function te(e){let s=Math.max(1,e?.failureThreshold??5),r=V(e?.cooldownNs??30*1e9),n=e?.cooldown??null,l=Math.max(1,e?.halfOpenMax??1),u=e?.now??O,t="closed",o=0,c=0,i=0,f=r,a=0;function w(){if(!n)return r;let p=n(c);return p!==null?p:r}function N(){t="open",f=w(),i=u(),a=0}return{canExecute(){return t==="closed"?!0:t==="open"?u()-i>=f?(t="half-open",a=1,!0):!1:a<l?(a++,!0):!1},recordSuccess(){t==="half-open"?(t="closed",o=0,c=0):t==="closed"&&(o=0)},recordFailure(p){if(t==="half-open"){c++,N();return}t==="closed"&&(o++,o>=s&&N())},get state(){return t},get failureCount(){return o},reset(){t="closed",o=0,c=0,a=0}}}function ne(e,s){let r=s?.onOpen??"skip";return n=>{let l=P([],(u,t)=>{function o(){l.meta.breakerState.down([[b,e.state]])}let c=n.subscribe(i=>{for(let f of i){let a=f[0];a===k?t.down([[k]]):a===b?e.canExecute()?(o(),t.emit(f[1])):(o(),r==="error"?t.down([[T,new A]]):t.down([[y]])):a===y?t.down([[y]]):a===h?(e.recordSuccess(),o(),t.down([[h]])):a===T?(e.recordFailure(M(f)),o(),t.down([f])):t.down([f])}});return o(),c},{...S(),meta:{breakerState:e.state},completeWhenDepsComplete:!1,initial:n.cache});return{node:l,breakerState:l.meta.breakerState}}}function U(e,s){if(e<=0)throw new RangeError("capacity must be > 0");if(s<0)throw new RangeError("refillPerSecond must be >= 0");let r=e,n=O();function l(u){if(s>0){let t=u-n;r=Math.min(e,r+t/1e9*s)}n=u}return{available(){return l(O()),r},tryConsume(u=1){if(u<=0)return!0;let t=O();return l(t),r>=u?(r-=u,!0):!1},putBack(u=1){u<=0||(l(O()),r=Math.min(e,r+u))}}}var D=class extends Error{name="RateLimiterOverflowError";constructor(s){super(`rateLimiter buffer overflow (maxBuffer=${s})`)}};function re(e,s){let{maxEvents:r,windowNs:n}=s;if(r<=0)throw new RangeError("maxEvents must be > 0");if(n<=0)throw new RangeError("windowNs must be > 0");let l=s.maxBuffer;if(l!==void 0&&l<1)throw new RangeError("maxBuffer must be >= 1");let u=s.onOverflow??"drop-newest",t=r*1e9/n;return g(o=>{let c=U(r,t),i=[],f=new E,a=!1,w=1e9/t;function N(){for(;i.length>0;)if(c.tryConsume(1))o.emit(i.shift());else{f.start(Math.max(1,w/1e6),N);return}}let x=e.subscribe(p=>{for(let m of p){if(a)return;let d=m[0];if(d===k)o.down([[k]]);else if(d===b){if(l!==void 0&&i.length>=l){if(u!=="drop-newest")if(u==="drop-oldest")i.shift(),i.push(m[1]);else{a=!0,f.cancel(),i.length=0,o.down([[T,new D(l)]]);return}}else i.push(m[1]);N()}else if(d===y)o.down([[y]]);else if(d===h)a=!0,f.cancel(),i.length=0,o.down([[h]]);else if(d===T)a=!0,f.cancel(),i.length=0,o.down([m]);else if(d===C){a=!0,f.cancel(),i.length=0,o.down([m]);return}else o.down([m])}});return()=>{a=!0,f.cancel(),x()}},{...S(),initial:e.cache})}function oe(e,s){let r=s?.initialStatus??"pending",n=P([],(l,u)=>{let t=r;return n.meta.status.down([[b,r]]),n.meta.error.down([[b,null]]),e.subscribe(c=>{for(let i of c){let f=i[0];if(f===k)u.down([[k]]);else if(f===b)t==="errored"?L(()=>{n.meta.error.down([[b,null]]),n.meta.status.down([[b,"active"]])}):n.meta.status.down([[b,"active"]]),t="active",u.emit(i[1]);else if(f===y)u.down([[y]]);else if(f===h)n.meta.status.down([[b,"completed"]]),t="completed",u.down([[h]]);else if(f===T){let a=M(i);L(()=>{n.meta.error.down([[b,a]]),n.meta.status.down([[b,"errored"]])}),t="errored",u.down([i])}else u.down([i])}})},{...S(),meta:{status:r,error:null},completeWhenDepsComplete:!1,resubscribable:!0,initial:e.cache});return{node:n,status:n.meta.status,error:n.meta.error}}var F=class extends Error{name="TimeoutError";constructor(s){super(`Timed out after ${s/1e6}ms`)}};function j(e){return e!=null&&typeof e=="object"&&"cache"in e&&typeof e.subscribe=="function"}function K(e){return e!=null&&typeof e.then=="function"}function $(e){return e!=null&&typeof e=="object"&&typeof e[Symbol.asyncIterator]=="function"}function ie(e,s){return g(r=>{let n,l;function u(){l?.(),l=void 0,j(s)||K(s)||$(s)?n=I(s).subscribe(o=>{r.down(o)}):(r.emit(s),r.down([[h]]))}return l=e.subscribe(t=>{for(let o of t){let c=o[0];if(c===k)r.down([[k]]);else if(c===b)r.emit(o[1]);else if(c===y)r.down([[y]]);else if(c===h)r.down([[h]]);else if(c===T){u();return}else if(c===C){n?.(),r.down([o]);return}else r.down([o])}}),()=>{l?.(),n?.()}},{...S(),initial:e.cache})}function se(e,s){if(s<=0)throw new RangeError("timeoutNs must be > 0");return g(r=>{let n=!1,l=new E;function u(){let o=s/1e6;l.start(o,()=>{n||(n=!0,t(),r.down([[T,new F(s)]]))})}let t=e.subscribe(o=>{for(let c of o){if(n)return;let i=c[0];if(i===k)r.down([[k]]);else if(i===b)u(),r.emit(c[1]);else if(i===y)r.down([[y]]);else if(i===h){l.cancel(),n=!0,r.down([[h]]);return}else if(i===T){l.cancel(),n=!0,r.down([c]);return}else if(i===C){l.cancel(),n=!0,r.down([c]);return}else r.down([c])}});return u(),()=>{n=!0,l.cancel(),t()}},{...S(),initial:e.cache})}export{Z as a,ee as b,A as c,te as d,ne as e,U as f,D as g,re as h,oe as i,F as j,ie as k,se as l};
@@ -0,0 +1 @@
1
+ var E=1e6,k=1e9;function i(e){return e<0?0:e}function l(e,t){return t==="none"?e:t==="full"?Math.random()*e:e/2+Math.random()*(e/2)}function b(e,t){return e+Math.random()*(t-e)}function S(e){let t=i(e);return()=>t}function m(e,t){let n=i(e),o=t===void 0?n:i(t);return a=>n+o*Math.max(0,a)}function p(e){let t=i(e?.baseNs??1e8),n=e?.factor!==void 0&&e.factor<1?1:e?.factor??2,o=i(e?.maxDelayNs??30*1e9),a=e?.jitter??"none";return f=>{let r;if(t===0)r=0;else if(n===1)r=t;else{let c=o/t,u=1;for(let s=0;s<Math.max(0,f);s++){if(u>=c){u=c;break}u*=n}r=t*u,r>o&&(r=o)}return l(r,a)}}function x(e=100*1e6,t=30*1e9){let n=i(e),o=i(t);function a(f){if(f<=0)return 1;let r=1,c=2;for(let u=1;u<f;u++){let s=r+c;r=c,c=s}return c}return f=>{let r=a(f)*n;return r<=o?r:o}}function _(e=100*1e6,t=30*1e9){return(n,o,a)=>{let r=Math.min(t,(a??e)*3);return b(e,r)}}function d(e,t){return(n,o,a)=>n>=t?null:e(n,o,a)}function B(e){if(e==="constant")return S(1*1e9);if(e==="linear")return m(1*1e9);if(e==="exponential")return p();if(e==="fibonacci")return x();if(e==="decorrelatedJitter")return _();throw new Error(`Unknown backoff preset: "${String(e)}". Use one of: constant, linear, exponential, fibonacci, decorrelatedJitter`)}export{E as a,k as b,S as c,m as d,p as e,x as f,_ as g,d as h,B as i};
@@ -0,0 +1 @@
1
+ import{b as i,f,g as s,i as l,j as u}from"./chunk-CK2E7BTU.js";import{Observable as b}from"rxjs";function g(a,t){return t?.raw?new b(e=>a.subscribe(r=>{if(!e.closed){e.next(r);for(let o of r){if(o[0]===u){e.error(o[1]);return}if(o[0]===l){e.complete();return}}}})):new b(e=>a.subscribe(r=>{for(let o of r){if(e.closed)return;if(o[0]===i)e.next(o[1]);else if(o[0]===u){e.error(o[1]);return}else if(o[0]===l){e.complete();return}}}))}var p=0;function O(a,t){if(t.highWaterMark<1)throw new RangeError("highWaterMark must be >= 1");if(t.lowWaterMark<0)throw new RangeError("lowWaterMark must be >= 0");if(t.lowWaterMark>=t.highWaterMark)throw new RangeError("lowWaterMark must be < highWaterMark");let e=Symbol(`bp-${++p}`),n=0,r=!1;return{onEnqueue(){return n+=1,!r&&n>=t.highWaterMark?(r=!0,a([[f,e]]),!0):!1},onDequeue(){return n>0&&(n-=1),r&&n<=t.lowWaterMark?(r=!1,a([[s,e]]),!0):!1},get pending(){return n},get paused(){return r},dispose(){r&&(r=!1,a([[s,e]]))}}}export{g as a,O as b};
@@ -0,0 +1 @@
1
+ import{b as d,c as i,d as R}from"./chunk-CK2E7BTU.js";import{b as T}from"./chunk-QYADASLV.js";var h={};T(h,{useStore:()=>y,useSubscribe:()=>p,useSubscribeRecord:()=>S});function p(e){return{subscribe(s){let n=e.subscribe(()=>{s(e.cache)});return s(e.cache),n}}}function y(e){return{subscribe(s){let n=e.subscribe(()=>{s(e.cache)});return s(e.cache),n},set(s){e.down([[i],[d,s]])},update(s){let n=s(e.cache);e.down([[i],[d,n]])}}}function S(e,s){return{subscribe(n){let a=[],l=()=>{for(let o of a)o();a=[]},b=()=>{let o={};for(let t of e.cache??[]){let c=s(t),r={};for(let u of Object.keys(c))r[u]=c[u].cache;o[t]=r}return o},f=o=>{l();for(let t of o){let c=s(t);for(let r of Object.keys(c)){let u=c[r].subscribe(()=>{n(b())});a.push(u)}}n(b())},v=e.subscribe(o=>{o.some(t=>t[0]===d||t[0]===R)&&f(e.cache??[])});return f(e.cache??[]),()=>{v(),l()}}}}export{p as a,y as b,S as c,h as d};
@@ -0,0 +1 @@
1
+ import{c as R}from"./chunk-ETWTCCJI.js";import{j as k}from"./chunk-CKCSDI7T.js";import{b as N}from"./chunk-D7A7DBE4.js";import{A as g}from"./chunk-2PMCKKRK.js";import{D as T,E as S,G as y,m as q,p as w,t as u}from"./chunk-ZB5EHBIO.js";import{b as A}from"./chunk-QYADASLV.js";var P={};A(P,{CqrsGraph:()=>h,MemoryEventStore:()=>_,cqrs:()=>O});var j=u((i,e)=>{i("write"),i("signal"),e("observe")}),D=u((i,e)=>{i("observe"),i("signal"),e("write")}),H=u((i,e)=>{i("observe"),i("signal"),e("write")});function m(i,e){return R("cqrs",i,e)}var _=class{_store=new Map;persist(e){let t=this._store.get(e.type);t||(t=[],this._store.set(e.type,t)),t.push(e)}loadEvents(e,t){let n=this._store.get(e)??[],r=t?.timestampNs,s=t?.seq,o=r==null?[...n]:n.filter(d=>d.timestampNs>r||d.timestampNs===r&&d.seq>(s??-1)),a=o.length>0?o[o.length-1]:void 0;return{events:o,cursor:a?{timestampNs:a.timestampNs,seq:a.seq}:t}}clear(){this._store.clear()}},h=class extends k{_eventLogs=new Map;_commandHandlers=new Map;_projections=new Set;_sagas=new Set;_keepaliveDisposers=[];_eventStore;_seq=0;constructor(e,t={}){super(e,t.graph)}destroy(){for(let e of this._keepaliveDisposers)e();this._keepaliveDisposers.length=0,super.destroy()}event(e){let t=this._eventLogs.get(e);if(t)return t.node;let n=N([],{name:e,versioning:0}),r=n.entries,s=y([r],([o])=>o,{name:e,describeKind:"state",meta:m("event",{event_name:e}),guard:H,initial:r.cache});return this.add(s,{name:e}),this._keepaliveDisposers.push(g(s)),this._eventLogs.set(e,{log:n,node:s}),s}_appendEvent(e,t){let n=this._eventLogs.get(e);if(n||(this.event(e),n=this._eventLogs.get(e)),n.node.status==="completed"||n.node.status==="errored")throw new Error(`Cannot dispatch to terminated event stream "${e}" (status: ${n.node.status}).`);let r=n.log.entries.v,s={type:e,payload:t,timestampNs:w(),seq:++this._seq,...r!=null?{v0:{id:r.id,version:r.version}}:{}};n.log.append(s),this._eventStore&&this._eventStore.persist(s)}command(e,t){let n=S(void 0,{name:e,describeKind:"state",meta:{...m("command",{command_name:e}),error:null},guard:j});return this.add(n,{name:e}),this._commandHandlers.set(e,t),n}dispatch(e,t){let n=this._commandHandlers.get(e);if(!n)throw new Error(`Unknown command: "${e}". Register with .command() first.`);let r=this.resolve(e);q(()=>{r.emit(t,{internal:!0});try{n(t,{emit:(s,o)=>this._appendEvent(s,o)}),r.meta.error.emit(null,{internal:!0})}catch(s){throw r.meta.error.emit(s,{internal:!0}),s}})}projection(e,t,n,r){let s=t.map(a=>(this._eventLogs.has(a)||this.event(a),this._eventLogs.get(a).node)),o=y(s,a=>{let d=[];for(let v of a){let p=v;d.push(...p)}return d.sort((v,p)=>v.timestampNs-p.timestampNs||v.seq-p.seq),n(r,d)},{name:e,describeKind:"derived",meta:m("projection",{projection_name:e,source_events:t}),guard:D,initial:r});return this.add(o,{name:e}),this._keepaliveDisposers.push(g(o)),this._projections.add(e),o}saga(e,t,n){let r=t.map(d=>(this._eventLogs.has(d)||this.event(d),this._eventLogs.get(d).node)),s=new Map,o={},a=T(r,(d,v)=>{let p=o.n.meta.error;for(let c=0;c<d.length;c++){let E=d[c];if(E==null||E.length===0)continue;let l=E.at(-1);if(!l)continue;let f=t[c],C=s.get(f)??0;if(l.length>C){let b=l.slice(C);for(let L of b)try{n(L),p.emit(null,{internal:!0})}catch(x){p.emit(x,{internal:!0})}s.set(f,l.length)}}},{name:e,describeKind:"effect",meta:{...m("saga",{saga_name:e,source_events:t}),error:null}});return o.n=a,this.add(a,{name:e}),this._keepaliveDisposers.push(g(a)),this._sagas.add(e),a}useEventStore(e){this._eventStore=e}async rebuildProjection(e,t,n){if(!this._eventStore)throw new Error("No event store wired. Call useEventStore() first.");let r=[];for(let s of e){let o=await this._eventStore.loadEvents(s);r.push(...o.events)}return r.sort((s,o)=>s.timestampNs-o.timestampNs||s.seq-o.seq),t(n,r)}};function O(i,e){return new h(i,e)}export{_ as a,h as b,O as c,P as d};
@@ -0,0 +1,9 @@
1
+ import{c as ce}from"./chunk-6V3SEX2I.js";import{a as se,b as P}from"./chunk-5QDBSZBV.js";import{j as L}from"./chunk-CKCSDI7T.js";import{f as ae,h as ie}from"./chunk-2PMCKKRK.js";import{i as ne,j as U}from"./chunk-ZB5EHBIO.js";import{b,h as _,i as T,j as W}from"./chunk-CK2E7BTU.js";import{b as Oe,c as re,d as te,e as oe}from"./chunk-QYADASLV.js";var ke={};Oe(ke,{ACTOR_KEY:()=>F,COMMAND_HANDLERS:()=>A,CQRS_EVENT_HANDLERS:()=>S,CRON_HANDLERS:()=>D,CommandHandler:()=>me,EVENT_HANDLERS:()=>G,EventHandler:()=>ve,GRAPHREFLY_REQUEST_GRAPH:()=>R,GRAPHREFLY_ROOT_GRAPH:()=>v,GraphCron:()=>fe,GraphInterval:()=>he,GraphReflyEventExplorer:()=>x,GraphReflyGuard:()=>Re,GraphReflyGuardImpl:()=>I,GraphReflyModule:()=>Q,INTERVAL_HANDLERS:()=>O,InjectCqrsGraph:()=>de,InjectGraph:()=>ue,InjectNode:()=>pe,ObserveGateway:()=>B,OnGraphEvent:()=>le,QUERY_HANDLERS:()=>H,QueryHandler:()=>ye,SAGA_HANDLERS:()=>N,SagaHandler:()=>ge,fromHeader:()=>Ee,fromJwtPayload:()=>V,getActor:()=>we,getGraphToken:()=>m,getNodeToken:()=>y,observeSSE:()=>Me,observeSubscription:()=>Ce,toObservable:()=>se});import{Inject as j}from"@nestjs/common";var v=Symbol.for("graphrefly:root-graph");var R=Symbol.for("graphrefly:request-graph");function m(s){return Symbol.for(`graphrefly:graph:${s}`)}function y(s){return Symbol.for(`graphrefly:node:${s}`)}var G=new Map,O=new Map,D=new Map,A=new Map,S=new Map,H=new Map,N=new Map;function ue(s){return s==="request"?j(R):j(s?m(s):v)}function de(s){return j(m(s))}function pe(s){return j(y(s))}function le(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=G.get(o)??[];n.push({nodeName:s,methodKey:t}),G.set(o,n)})}}function he(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=O.get(o)??[];n.push({ms:s,methodKey:t}),O.set(o,n)})}}function fe(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=D.get(o)??[];n.push({expr:s,methodKey:t}),D.set(o,n)})}}function me(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=A.get(n)??[];a.push({cqrsName:s,commandName:e,methodKey:o}),A.set(n,a)})}}function ve(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=S.get(n)??[];a.push({cqrsName:s,eventName:e,methodKey:o}),S.set(n,a)})}}function ye(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=H.get(n)??[];a.push({cqrsName:s,projectionName:e,methodKey:o}),H.set(n,a)})}}function ge(s,e,r){return(t,o)=>{let n=o.name;o.addInitializer(function(){let a=this.constructor,c=N.get(a)??[];c.push({cqrsName:s,eventNames:r,sagaName:e,methodKey:n}),N.set(a,c)})}}var be=0,x=class{constructor(e,r){this.graph=e;this.moduleRef=r}disposers=[];scheduleNodeNames=[];onModuleInit(){this.wireEvents(),this.wireIntervals(),this.wireCrons(),this.wireCqrsCommands(),this.wireCqrsEvents(),this.wireCqrsQueries(),this.wireCqrsSagas()}onModuleDestroy(){for(let e of this.disposers)e();this.disposers.length=0;for(let e of this.scheduleNodeNames)try{this.graph.remove(e)}catch{}this.scheduleNodeNames.length=0}wireEvents(){for(let[e,r]of G){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireEventHandler(t,o)}}wireEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),a=this.observeNode(r.nodeName).subscribe(c=>{for(let l of c)l[0]===b&&o(l[1])});this.disposers.push(a)}wireIntervals(){for(let[e,r]of O){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireIntervalHandler(t,e,o)}}wireIntervalHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ae(t.ms,{period:t.ms,name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCrons(){for(let[e,r]of D){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCronHandler(t,e,o)}}wireCronHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ie(t.expr,{name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCqrsCommands(){for(let[e,r]of A){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsCommand(t,o)}}wireCqrsCommand(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.command(r.commandName,o)}wireCqrsEvents(){for(let[e,r]of S){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsEventHandler(t,o)}}wireCqrsEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;n.event(r.eventName);let c=n.resolve(r.eventName).cache,l=c&&c.length>0?c[c.length-1].seq:0,p=this.observeNodeOn(n,r.eventName).subscribe(u=>{for(let d of u)if(d[0]===b){let g=d[1];for(let i of g)i.seq>l&&(o(i),l=i.seq)}});this.disposers.push(p)}wireCqrsQueries(){for(let[e,r]of H){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsQuery(t,o)}}wireCqrsQuery(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;let c=this.observeNodeOn(n,r.projectionName).subscribe(l=>{for(let f of l)f[0]===b&&o(f[1])});this.disposers.push(c)}wireCqrsSagas(){for(let[e,r]of N){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsSaga(t,o)}}wireCqrsSaga(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.saga(r.sagaName,r.eventNames,o)}observeNode(e){return this.graph.observe(e)}observeNodeOn(e,r){return e.observe(r)}resolveCqrsGraph(e){try{return this.moduleRef.get(m(e),{strict:!1})}catch{return console.warn(`[GraphReFly] CqrsGraph "${e}" not found in DI \u2014 did you import GraphReflyModule.forCqrs({ name: "${e}" })?`),null}}resolveInstance(e){try{return this.moduleRef.get(e,{strict:!1})}catch{return null}}};function Me(s,e,r){let{actor:t,serialize:o=De,keepAliveMs:n,signal:a}=r??{},c=new TextEncoder,l,f=r?.highWaterMark!=null,p,u,d=[],g=!1;return new ReadableStream({start(i){let h,w=()=>{},M=()=>{if(!g){g=!0,h!==void 0&&clearInterval(h),a?.removeEventListener("abort",K),w(),p?.dispose(),u?.(),u=void 0;for(let k of d)i.enqueue(k.frame);d.length=0,i.close()}};l=M;let K=()=>M(),ee=s.observe(e,{actor:t});f&&(p=P(k=>ee.up(k),{highWaterMark:r.highWaterMark,lowWaterMark:r.lowWaterMark??Math.floor(r.highWaterMark/2)})),w=ee.subscribe(k=>{for(let $ of k){if(g)return;let q=$[0];if(q===b){let C=c.encode(Y("data",o($[1])));f?(d.push({frame:C,counted:!0}),p.onEnqueue(),u?.(),u=void 0):i.enqueue(C)}else if(q===W){let C=c.encode(Y("error",o($[1])));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C),M();return}else if(q===T||q===_){if(q===T){let C=c.encode(Y("complete"));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C)}M();return}}}),n!==void 0&&n>0&&(h=setInterval(()=>{g||(f?(d.push({frame:c.encode(`: keepalive
2
+
3
+ `),counted:!1}),u?.(),u=void 0):i.enqueue(c.encode(`: keepalive
4
+
5
+ `)))},n)),a?.aborted?K():a?.addEventListener("abort",K,{once:!0})},pull(i){if(f&&!g){if(d.length>0){let h=d.shift();i.enqueue(h.frame),h.counted&&p.onDequeue();return}return new Promise(h=>{u=h})}},cancel(){try{l?.()}catch{}}})}function Ce(s,e,r){let{actor:t,filter:o}=r??{},n=[],a=[],c=!1,l=s.observe(e,{actor:t}),f=r?.highWaterMark!=null?P(i=>l.up(i),{highWaterMark:r.highWaterMark,lowWaterMark:r.lowWaterMark??Math.floor(r.highWaterMark/2)}):void 0,p=()=>{c||(c=!0,f?.dispose(),d())},u=i=>{if(!c)if(a.length>0){let h=a.shift();i.done&&i.error?h.reject(i.error):i.done?h.resolve({done:!0,value:void 0}):h.resolve({done:!1,value:i.value})}else n.push(i),i.done||f?.onEnqueue()},d=l.subscribe(i=>{for(let h of i){let w=h[0];if(w===b){let M=h[1];if(o&&!o(M))continue;u({done:!1,value:M})}else if(w===W){let M=h[1]instanceof Error?h[1]:new Error(String(h[1]));u({done:!0,error:M}),p();return}else if(w===T||w===_){u({done:!0}),p();return}}});return{next(){if(n.length>0){let i=n.shift();return i.done||f?.onDequeue(),i.done&&i.error?Promise.reject(i.error):Promise.resolve(i.done?{done:!0,value:void 0}:{done:!1,value:i.value})}return c?Promise.resolve({done:!0,value:void 0}):new Promise((i,h)=>{a.push({resolve:i,reject:h})})},return(){p();for(let i of a)i.resolve({done:!0,value:void 0});return a.length=0,Promise.resolve({done:!0,value:void 0})},throw(i){return p(),Promise.reject(i)},[Symbol.asyncIterator](){return this}}}var B=class{constructor(e,r){this.graph=e;this.extractActor=r?.extractActor??(()=>{}),this.parse=r?.parse??Ae,this.highWaterMark=r?.highWaterMark,this.lowWaterMark=r?.lowWaterMark}clients=new Map;extractActor;parse;highWaterMark;lowWaterMark;handleConnection(e){this.clients.has(e)||this.clients.set(e,new Map)}handleDisconnect(e){let r=this.clients.get(e);if(r){for(let t of r.values())t.wm?.dispose(),t.unsub();this.clients.delete(e)}}handleMessage(e,r,t){let o=t??Se.bind(null,e),n;try{n=typeof r=="string"?this.parse(r):r}catch{o({type:"err",message:"invalid command"});return}n.type==="subscribe"?this.subscribe(e,n.path,o):n.type==="unsubscribe"?this.unsubscribe(e,n.path,o):n.type==="ack"?this.ack(e,n.path,n.count??1):o({type:"err",message:`unknown command type: ${n.type}`})}subscriptionCount(e){return this.clients.get(e)?.size??0}destroy(){for(let[e]of this.clients)this.handleDisconnect(e)}subscribe(e,r,t){let o=this.clients.get(e);if(o||(o=new Map,this.clients.set(e,o)),o.has(r)){t({type:"subscribed",path:r});return}let n=this.extractActor(e),a;try{a=this.graph.observe(r,{actor:n})}catch(p){let u=p instanceof Error?p.message:String(p);t({type:"err",message:u});return}let c=this.highWaterMark!=null?P(p=>a.up(p),{highWaterMark:this.highWaterMark,lowWaterMark:this.lowWaterMark??Math.floor(this.highWaterMark/2)}):void 0,l=()=>{c?.dispose(),f(),o.delete(r)},f=a.subscribe(p=>{for(let u of p){let d=u[0];if(d===b)c?.onEnqueue(),z(t,{type:"data",path:r,value:u[1]});else if(d===W){let g=u[1]instanceof Error?u[1].message:String(u[1]);z(t,{type:"error",path:r,error:g}),l();return}else if(d===T||d===_){z(t,{type:"complete",path:r}),l();return}}});o.set(r,{unsub:f,wm:c}),t({type:"subscribed",path:r})}unsubscribe(e,r,t){let o=this.clients.get(e),n=o?.get(r);n&&(n.wm?.dispose(),n.unsub(),o.delete(r)),t({type:"unsubscribed",path:r})}ack(e,r,t){let o=this.clients.get(e)?.get(r);if(!o?.wm)return;let n=Math.min(Math.max(0,Math.floor(t)),1024);for(let a=0;a<n;a++)o.wm.onDequeue()}};function De(s){if(s instanceof Error)return s.message;try{return JSON.stringify(s)}catch{return String(s)}}function Y(s,e){let r=`event: ${s}
6
+ `;if(e!==void 0)for(let t of e.split(`
7
+ `))r+=`data: ${t}
8
+ `;return r+=`
9
+ `,r}function Ae(s){return JSON.parse(s)}function Se(s,e){try{s.send(JSON.stringify(e))}catch{}}function z(s,e){try{s(e)}catch{}}var F="graphReflyActor";function V(s){return e=>{let t=e.switchToHttp().getRequest()?.user;if(t!=null)return s?s(t):t}}function Ee(s="x-graphrefly-actor"){return e=>{let t=e.switchToHttp().getRequest()?.headers?.[s.toLowerCase()];if(!(typeof t!="string"||t.length===0))try{return JSON.parse(t)}catch{return}}}function we(s){let e=s?.[F];return e!=null?U(e):ne}var I=class{constructor(e){this.extractor=e}canActivate(e){let r=U(this.extractor(e)),t=e.switchToHttp().getRequest();return t!=null&&(t[F]=r),!0}};function Re(s){return new I(s??V())}import{Module as He,Scope as xe}from"@nestjs/common";import{ModuleRef as Ne}from"@nestjs/core";var X=class{constructor(e){this.graph=e}onModuleDestroy(){this.graph.destroy()}},Z=class{graph=new L("request");onModuleDestroy(){this.graph.destroy()}},Ge,J;Ge=[He({})];var E=class E{static forRoot(e){let r=e??{},t=r.name??"root",o=[{provide:v,useFactory:()=>{let n=new L(t);return r.build&&r.build(n),r.snapshot&&n.restore(r.snapshot),n}},{provide:Symbol.for("graphrefly:root-lifecycle"),useFactory:n=>new X(n),inject:[v]},{provide:x,useFactory:(n,a)=>new x(n,a),inject:[v,Ne]}];if(r.nodes)for(let n of r.nodes)o.push({provide:y(n),useFactory:a=>a.resolve(n),inject:[v]});return r.requestScope&&o.push({provide:Symbol.for("graphrefly:request-lifecycle"),useFactory:()=>new Z,scope:xe.REQUEST},{provide:R,useFactory:n=>n.graph,inject:[Symbol.for("graphrefly:request-lifecycle")],scope:xe.REQUEST}),{module:E,global:!0,providers:o,exports:[v,...(r.nodes??[]).map(y),...r.requestScope?[R]:[]]}}static forFeature(e){let r=[{provide:m(e.name),useFactory:t=>{let o=new L(e.name);return e.build&&e.build(o),e.snapshot&&o.restore(e.snapshot),t.mount(e.name,o),o},inject:[v]}];if(e.nodes)for(let t of e.nodes)r.push({provide:y(`${e.name}::${t}`),useFactory:o=>o.resolve(t),inject:[m(e.name)]});return{module:E,providers:r,exports:[m(e.name),...(e.nodes??[]).map(t=>y(`${e.name}::${t}`))]}}static forCqrs(e){let r=[{provide:m(e.name),useFactory:t=>{let o=ce(e.name,e.cqrs);return e.eventStore&&o.useEventStore(e.eventStore),e.build&&e.build(o),t.mount(e.name,o),o},inject:[v]}];if(e.nodes)for(let t of e.nodes)r.push({provide:y(`${e.name}::${t}`),useFactory:o=>o.resolve(t),inject:[m(e.name)]});return{module:E,providers:r,exports:[m(e.name),...(e.nodes??[]).map(t=>y(`${e.name}::${t}`))]}}};J=re(null),E=oe(J,0,"GraphReflyModule",Ge,E),te(J,1,E);var Q=E;export{v as a,R as b,m as c,y as d,G as e,O as f,D as g,A as h,S as i,H as j,N as k,ue as l,de as m,pe as n,le as o,he as p,fe as q,me as r,ve as s,ye as t,ge as u,x as v,Me as w,Ce as x,B as y,F as z,V as A,Ee as B,we as C,I as D,Re as E,Q as F,ke as G};