@graphrefly/graphrefly 0.41.0 → 0.42.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 (296) hide show
  1. package/dist/{cascading-Cxs1eztH.d.cts → cascading-CH-_VwG9.d.cts} +2 -2
  2. package/dist/{cascading-BNfxffgc.d.ts → cascading-OgKQZjsa.d.ts} +2 -2
  3. package/dist/{chunk-L77I47VU.js → chunk-2K5RXLAH.js} +1 -1
  4. package/dist/chunk-3ERTUW2J.js +45 -0
  5. package/dist/chunk-3K7HA4Y6.js +1 -0
  6. package/dist/chunk-3ZZX7M25.js +1 -0
  7. package/dist/chunk-4QH6VJF4.js +1 -0
  8. package/dist/{chunk-M3FQSXEW.js → chunk-5QRRKBUT.js} +1 -1
  9. package/dist/chunk-5ST42ESJ.js +1 -0
  10. package/dist/{chunk-AK5RHMC5.js → chunk-6YFZMUMR.js} +1 -1
  11. package/dist/{chunk-SC27WTSG.js → chunk-7ARY3Y3T.js} +1 -1
  12. package/dist/chunk-7B7ELAT2.js +1 -0
  13. package/dist/{chunk-F7VUYPP6.js → chunk-7VKFXLZQ.js} +1 -1
  14. package/dist/chunk-ACMJ2ZPS.js +3 -0
  15. package/dist/{chunk-7PQLZMOG.js → chunk-AGNM6RS6.js} +1 -1
  16. package/dist/chunk-AS3TV2TV.js +1 -0
  17. package/dist/{chunk-CGNOWGV6.js → chunk-CISGGAIF.js} +1 -1
  18. package/dist/{chunk-ZAJ7J7TO.js → chunk-DEJTNNQC.js} +1 -1
  19. package/dist/{chunk-AI7QC7J6.js → chunk-FDZAZNRO.js} +1 -1
  20. package/dist/{chunk-OV5AA6HJ.js → chunk-FUZ6S2DY.js} +1 -1
  21. package/dist/{chunk-G3M3IMEV.js → chunk-G5VBJ5K6.js} +1 -1
  22. package/dist/{chunk-KNVCCBIU.js → chunk-HZKW2AAB.js} +1 -1
  23. package/dist/{chunk-CYOSWFT2.js → chunk-IZM3UEH3.js} +3 -3
  24. package/dist/{chunk-UISPDFJ3.js → chunk-KCACBSJH.js} +1 -1
  25. package/dist/{chunk-GI4Q7PNY.js → chunk-KT5DTRBP.js} +1 -1
  26. package/dist/{chunk-33N4TU3X.js → chunk-KY2LMAXU.js} +1 -1
  27. package/dist/{chunk-TT4C7DXW.js → chunk-LDQ3IUIP.js} +1 -1
  28. package/dist/chunk-LPRWATHB.js +61 -0
  29. package/dist/{chunk-X7QKTXXC.js → chunk-NWXQIOIB.js} +3 -3
  30. package/dist/{chunk-VV62MIG4.js → chunk-Q7QQQA3I.js} +1 -1
  31. package/dist/chunk-VE5SIZEM.js +1 -0
  32. package/dist/chunk-VRALOYRD.js +1 -0
  33. package/dist/{chunk-5VEZLQFN.js → chunk-WHMUB5QB.js} +1 -1
  34. package/dist/chunk-XLQPNNIC.js +1 -0
  35. package/dist/{chunk-YQRN4CIV.js → chunk-YGL7FPVQ.js} +1 -1
  36. package/dist/compat/index.cjs +5 -5
  37. package/dist/compat/index.d.cts +16 -16
  38. package/dist/compat/index.d.ts +16 -16
  39. package/dist/compat/index.js +1 -1
  40. package/dist/compat/jotai/index.d.cts +2 -2
  41. package/dist/compat/jotai/index.d.ts +2 -2
  42. package/dist/compat/nanostores/index.d.cts +2 -2
  43. package/dist/compat/nanostores/index.d.ts +2 -2
  44. package/dist/compat/nestjs/index.cjs +5 -5
  45. package/dist/compat/nestjs/index.d.cts +8 -8
  46. package/dist/compat/nestjs/index.d.ts +8 -8
  47. package/dist/compat/nestjs/index.js +1 -1
  48. package/dist/compat/react/index.d.cts +2 -2
  49. package/dist/compat/react/index.d.ts +2 -2
  50. package/dist/compat/solid/index.d.cts +2 -2
  51. package/dist/compat/solid/index.d.ts +2 -2
  52. package/dist/compat/svelte/index.d.cts +2 -2
  53. package/dist/compat/svelte/index.d.ts +2 -2
  54. package/dist/compat/vue/index.d.cts +2 -2
  55. package/dist/compat/vue/index.d.ts +2 -2
  56. package/dist/compat/zustand/index.cjs +3 -3
  57. package/dist/compat/zustand/index.d.cts +4 -4
  58. package/dist/compat/zustand/index.d.ts +4 -4
  59. package/dist/compat/zustand/index.js +1 -1
  60. package/dist/core/index.d.cts +4 -4
  61. package/dist/core/index.d.ts +4 -4
  62. package/dist/{decay-C25AyNAj.d.cts → decay-2ZukgQ4o.d.cts} +2 -2
  63. package/dist/{decay-BnrlbxSv.d.ts → decay-CdEBmDIs.d.ts} +2 -2
  64. package/dist/extra/browser.d.cts +1 -1
  65. package/dist/extra/browser.d.ts +1 -1
  66. package/dist/extra/index.cjs +14 -14
  67. package/dist/extra/index.d.cts +10 -11
  68. package/dist/extra/index.d.ts +10 -11
  69. package/dist/extra/index.js +1 -1
  70. package/dist/extra/node.cjs +2 -2
  71. package/dist/extra/node.d.cts +1 -1
  72. package/dist/extra/node.d.ts +1 -1
  73. package/dist/extra/node.js +1 -1
  74. package/dist/extra/operators.cjs +1 -1
  75. package/dist/extra/operators.d.cts +1 -1
  76. package/dist/extra/operators.d.ts +1 -1
  77. package/dist/extra/operators.js +1 -1
  78. package/dist/extra/reactive.d.cts +3 -3
  79. package/dist/extra/reactive.d.ts +3 -3
  80. package/dist/extra/reactive.js +1 -1
  81. package/dist/extra/render/index.d.cts +3 -3
  82. package/dist/extra/render/index.d.ts +3 -3
  83. package/dist/extra/sources.cjs +3 -1
  84. package/dist/extra/sources.d.cts +1 -1
  85. package/dist/extra/sources.d.ts +1 -1
  86. package/dist/extra/sources.js +1 -1
  87. package/dist/extra/storage-browser.d.cts +1 -1
  88. package/dist/extra/storage-browser.d.ts +1 -1
  89. package/dist/{fallback-CMZl39L5.d.ts → fallback-CqYVLL6X.d.ts} +1 -1
  90. package/dist/{fallback-8JYU8tlT.d.cts → fallback-Ctlj2tMY.d.cts} +1 -1
  91. package/dist/graph/index.cjs +7 -7
  92. package/dist/graph/index.d.cts +5 -5
  93. package/dist/graph/index.d.ts +5 -5
  94. package/dist/graph/index.js +1 -1
  95. package/dist/{graph-BkIkog4h.d.ts → graph-7VguS7a4.d.ts} +3 -3
  96. package/dist/{graph-E6likq7w.d.cts → graph-C4SHb3Ly.d.cts} +3 -3
  97. package/dist/{index-DktLSZOc.d.cts → index-2B7u2pVn.d.cts} +4 -4
  98. package/dist/{index-DGD4_fj6.d.cts → index-3NmAfcH0.d.cts} +8 -5
  99. package/dist/{index-DfOK_oL5.d.ts → index-4Uz-e_fL.d.ts} +372 -17
  100. package/dist/{index-BAQrjuZF.d.ts → index-B-i4_g3k.d.ts} +2 -2
  101. package/dist/{index-DpiGqtrs.d.cts → index-B11anra4.d.cts} +441 -381
  102. package/dist/{index-WSlcjhQF.d.ts → index-B3OTH1dV.d.ts} +124 -13
  103. package/dist/{index-2n8Eai6M.d.ts → index-BG0BN3PB.d.ts} +1 -1
  104. package/dist/{index-z8WFPVI8.d.cts → index-BJX94aud.d.cts} +1 -1
  105. package/dist/{index-DhLyOHYZ.d.ts → index-BP8a88zx.d.ts} +11 -4
  106. package/dist/{index-Cnr1WrlX.d.cts → index-BTQtTb_H.d.cts} +14 -3
  107. package/dist/{index-BaA-xpSw.d.ts → index-BUYXac2c.d.ts} +3 -3
  108. package/dist/{index-DOBLxOti.d.cts → index-BVpm6noz.d.cts} +1 -1
  109. package/dist/{index-DhnsQfa3.d.ts → index-Bbkgpt5t.d.ts} +441 -381
  110. package/dist/{index-Cczxgd2D.d.ts → index-Bc41FuHp.d.cts} +3 -3
  111. package/dist/{index-BiHUBEKq.d.cts → index-BdGtBX-X.d.cts} +3 -3
  112. package/dist/index-BeT2r7sk.d.ts +760 -0
  113. package/dist/{index-da2V5vPy.d.ts → index-Bf7eqeSF.d.ts} +2 -2
  114. package/dist/{index-bXXLSvor.d.ts → index-Bn4zHYLj.d.ts} +4 -4
  115. package/dist/{index-DGTo1yka.d.cts → index-BoLv_OfD.d.cts} +2 -2
  116. package/dist/{index-B72TQQHd.d.cts → index-BsT7F2et.d.ts} +3 -3
  117. package/dist/{index-Bd91Nmf4.d.cts → index-BtAsBp8K.d.cts} +4 -4
  118. package/dist/{index-DgJc8Zgc.d.cts → index-C0-Jv1kP.d.cts} +81 -5
  119. package/dist/{index-C6ZUaos7.d.ts → index-C7O6r5fV.d.ts} +1 -1
  120. package/dist/{index-CL7oilfm.d.cts → index-C9kSENB4.d.cts} +1 -1
  121. package/dist/{index-yLt-aPMp.d.ts → index-CCq87F7t.d.ts} +1 -1
  122. package/dist/{index-DQQCOIt8.d.cts → index-CEMx8n40.d.cts} +10 -5
  123. package/dist/{index-BilOa6AE.d.cts → index-CJIuLu2f.d.cts} +124 -13
  124. package/dist/{index-B2RUoIUz.d.ts → index-CJK1JkYy.d.ts} +1 -1
  125. package/dist/{index-CG33HeBW.d.ts → index-CJQm0g38.d.ts} +8 -5
  126. package/dist/index-CPNSy-U0.d.cts +760 -0
  127. package/dist/{index-A3U3CSve.d.cts → index-CZjOhcBy.d.cts} +2 -2
  128. package/dist/{index-CAP3UGsq.d.ts → index-CZmcDtFn.d.ts} +1 -1
  129. package/dist/{index-DYTBbF8T.d.cts → index-ChOyVLKm.d.cts} +1 -1
  130. package/dist/{index-eaQuGJnv.d.ts → index-CpyNFqkB.d.ts} +3 -3
  131. package/dist/{index-BJSZxSFX.d.ts → index-CvrqGfNS.d.ts} +1 -1
  132. package/dist/{index-DuRsN9ae.d.cts → index-D-Xs74HZ.d.cts} +372 -17
  133. package/dist/{index-C5cQ7Gfx.d.ts → index-D6egPFAL.d.ts} +4 -4
  134. package/dist/{index-CD2dBMet.d.ts → index-D8l8hNXn.d.ts} +10 -5
  135. package/dist/{index-40ZT4MHj.d.ts → index-DBHK8O6H.d.ts} +14 -3
  136. package/dist/{index-DVDapw2k.d.cts → index-DBIqYS43.d.cts} +35 -21
  137. package/dist/{index-3k4Gg6-n.d.ts → index-DBevwHj_.d.ts} +3 -3
  138. package/dist/{index-Ctb7_2sG.d.ts → index-DIOoAZUX.d.ts} +1 -1
  139. package/dist/{index-BQ1fR4li.d.ts → index-DO9XxMzS.d.ts} +35 -21
  140. package/dist/{index-CQtWm7jS.d.ts → index-DQo8xBgd.d.ts} +9 -9
  141. package/dist/{index-DH4fm2Ck.d.ts → index-Dgs8zcj7.d.ts} +2 -2
  142. package/dist/{index-CtFNGe-m.d.cts → index-Dhc7a7Xo.d.cts} +2 -2
  143. package/dist/{index-MxYuWOrf.d.cts → index-DmAgG5CI.d.cts} +3 -3
  144. package/dist/{index-CoM4rzyB.d.ts → index-Dmqp7KjD.d.ts} +1 -1
  145. package/dist/{index-B6iTqKtJ.d.ts → index-Dn-wI9g4.d.ts} +2 -2
  146. package/dist/{index-C-dkXOpB.d.cts → index-Du7u1lSf.d.cts} +11 -4
  147. package/dist/{index-DVAlsmEU.d.cts → index-HoU88d5U.d.cts} +3 -3
  148. package/dist/{index-CRm0YIzC.d.cts → index-LIpQQE9f.d.cts} +9 -9
  149. package/dist/{index-CgnCFhr2.d.cts → index-f5IivDUX.d.cts} +1 -1
  150. package/dist/{index-PgwvGWa1.d.cts → index-hHcaFlJX.d.cts} +1 -1
  151. package/dist/{index-I1cCY3ZI.d.ts → index-pT8sCpOJ.d.ts} +81 -5
  152. package/dist/{index-D4uimgee.d.cts → index-sl4NyzQx.d.cts} +1 -1
  153. package/dist/{index-tV3AA9hI.d.cts → index-tJoTcnHh.d.cts} +2 -2
  154. package/dist/{index-D3ayz3hy.d.cts → index-z96luz5O.d.cts} +1 -1
  155. package/dist/index.cjs +48 -48
  156. package/dist/index.d.cts +45 -50
  157. package/dist/index.d.ts +45 -50
  158. package/dist/index.js +1 -1
  159. package/dist/{meta-D8OyedKp.d.ts → meta-BgVAsg9j.d.ts} +1 -1
  160. package/dist/{meta-Ct9nqQS5.d.cts → meta-vE8bxW1E.d.cts} +1 -1
  161. package/dist/{node-BYInONRr.d.cts → node-ClS5yC-B.d.cts} +1 -1
  162. package/dist/{node-BYInONRr.d.ts → node-ClS5yC-B.d.ts} +1 -1
  163. package/dist/{observable-DO8DDEzv.d.ts → observable-BsBzUrcI.d.ts} +1 -1
  164. package/dist/{observable-DMIlYJV1.d.cts → observable-DLGPPtb8.d.cts} +1 -1
  165. package/dist/patterns/ai/browser.d.cts +4 -4
  166. package/dist/patterns/ai/browser.d.ts +4 -4
  167. package/dist/patterns/ai/browser.js +1 -1
  168. package/dist/patterns/ai/index.cjs +17 -17
  169. package/dist/patterns/ai/index.d.cts +17 -17
  170. package/dist/patterns/ai/index.d.ts +17 -17
  171. package/dist/patterns/ai/index.js +1 -1
  172. package/dist/patterns/ai/node.d.cts +4 -4
  173. package/dist/patterns/ai/node.d.ts +4 -4
  174. package/dist/patterns/ai/node.js +1 -1
  175. package/dist/patterns/cqrs/index.cjs +3 -3
  176. package/dist/patterns/cqrs/index.d.cts +6 -6
  177. package/dist/patterns/cqrs/index.d.ts +6 -6
  178. package/dist/patterns/cqrs/index.js +1 -1
  179. package/dist/patterns/demo-shell/index.cjs +5 -5
  180. package/dist/patterns/demo-shell/index.d.cts +5 -5
  181. package/dist/patterns/demo-shell/index.d.ts +5 -5
  182. package/dist/patterns/demo-shell/index.js +1 -1
  183. package/dist/patterns/domain-templates/index.cjs +3 -3
  184. package/dist/patterns/domain-templates/index.d.cts +4 -4
  185. package/dist/patterns/domain-templates/index.d.ts +4 -4
  186. package/dist/patterns/domain-templates/index.js +1 -1
  187. package/dist/patterns/graphspec/index.cjs +12 -12
  188. package/dist/patterns/graphspec/index.d.cts +5 -5
  189. package/dist/patterns/graphspec/index.d.ts +5 -5
  190. package/dist/patterns/graphspec/index.js +1 -1
  191. package/dist/patterns/harness/index.cjs +10 -8
  192. package/dist/patterns/harness/index.d.cts +11 -12
  193. package/dist/patterns/harness/index.d.ts +11 -12
  194. package/dist/patterns/harness/index.js +1 -1
  195. package/dist/patterns/inspect/index.cjs +3 -0
  196. package/dist/patterns/inspect/index.d.cts +9 -0
  197. package/dist/patterns/inspect/index.d.ts +9 -0
  198. package/dist/patterns/inspect/index.js +1 -0
  199. package/dist/patterns/job-queue/index.cjs +3 -3
  200. package/dist/patterns/job-queue/index.d.cts +6 -6
  201. package/dist/patterns/job-queue/index.d.ts +6 -6
  202. package/dist/patterns/job-queue/index.js +1 -1
  203. package/dist/patterns/memory/index.cjs +3 -3
  204. package/dist/patterns/memory/index.d.cts +6 -6
  205. package/dist/patterns/memory/index.d.ts +6 -6
  206. package/dist/patterns/memory/index.js +1 -1
  207. package/dist/patterns/messaging/index.cjs +3 -3
  208. package/dist/patterns/messaging/index.d.cts +5 -5
  209. package/dist/patterns/messaging/index.d.ts +5 -5
  210. package/dist/patterns/messaging/index.js +1 -1
  211. package/dist/patterns/orchestration/index.cjs +3 -3
  212. package/dist/patterns/orchestration/index.d.cts +7 -7
  213. package/dist/patterns/orchestration/index.d.ts +7 -7
  214. package/dist/patterns/orchestration/index.js +1 -1
  215. package/dist/patterns/process/index.cjs +1 -1
  216. package/dist/patterns/process/index.d.cts +7 -7
  217. package/dist/patterns/process/index.d.ts +7 -7
  218. package/dist/patterns/process/index.js +1 -1
  219. package/dist/patterns/reactive-layout/index.cjs +4 -4
  220. package/dist/patterns/reactive-layout/index.d.cts +5 -5
  221. package/dist/patterns/reactive-layout/index.d.ts +5 -5
  222. package/dist/patterns/reactive-layout/index.js +1 -1
  223. package/dist/patterns/reduction/index.cjs +3 -3
  224. package/dist/patterns/reduction/index.d.cts +4 -4
  225. package/dist/patterns/reduction/index.d.ts +4 -4
  226. package/dist/patterns/reduction/index.js +1 -1
  227. package/dist/patterns/surface/index.cjs +8 -8
  228. package/dist/patterns/surface/index.d.cts +6 -6
  229. package/dist/patterns/surface/index.d.ts +6 -6
  230. package/dist/patterns/surface/index.js +1 -1
  231. package/dist/{pipeline-graph-MWrQZXCq.d.cts → pipeline-graph-WBlobVhU.d.cts} +5 -5
  232. package/dist/{pipeline-graph-CB4La-UW.d.ts → pipeline-graph-v8fMvqNk.d.ts} +5 -5
  233. package/dist/{reactive-layout-BtZfUKuL.d.cts → reactive-layout-Dsvob4zD.d.cts} +2 -2
  234. package/dist/{reactive-layout-KJj4E2dT.d.ts → reactive-layout-v7KPvxoc.d.ts} +2 -2
  235. package/dist/{reactive-log-_zeEnB9H.d.cts → reactive-log-B00laMSQ.d.cts} +1 -1
  236. package/dist/{reactive-log-BlAsPLl2.d.ts → reactive-log-BezYsbA_.d.ts} +1 -1
  237. package/dist/{reactive-map-6P_k3AQM.d.cts → reactive-map-48mnZ-nu.d.cts} +1 -1
  238. package/dist/{reactive-map-CjXByDV-.d.ts → reactive-map-BVVPdvmi.d.ts} +1 -1
  239. package/dist/resilience-445VFFXQ.js +1 -0
  240. package/dist/{sugar-BhfjgetH.d.ts → sugar-CH-2ZY90.d.ts} +1 -1
  241. package/dist/{sugar-DzePN5-g.d.cts → sugar-DStZfUEK.d.cts} +1 -1
  242. package/dist/{topology-tree-mF7Emqzm.d.ts → topology-tree-BNGvuG82.d.ts} +1 -1
  243. package/dist/{topology-tree-3LBKFsUo.d.cts → topology-tree-BSdfSwMi.d.cts} +1 -1
  244. package/dist/{types-1Dhoi7HM.d.cts → types-B1jDWVsM.d.cts} +1 -1
  245. package/dist/{types-39jk0kaV.d.ts → types-DkzUUs0H.d.ts} +1 -1
  246. package/package.json +11 -51
  247. package/dist/budget-gate-CmmVtasH.d.ts +0 -115
  248. package/dist/budget-gate-DiP_nK0n.d.cts +0 -115
  249. package/dist/chunk-2W553JJC.js +0 -1
  250. package/dist/chunk-4MKL6Q3K.js +0 -1
  251. package/dist/chunk-5B3JDG5F.js +0 -1
  252. package/dist/chunk-5QSXEMXG.js +0 -1
  253. package/dist/chunk-5TEFC2ZX.js +0 -1
  254. package/dist/chunk-5TOPVRN6.js +0 -1
  255. package/dist/chunk-EC2WNSZ7.js +0 -1
  256. package/dist/chunk-ELAASRBT.js +0 -3
  257. package/dist/chunk-H5SCWHWP.js +0 -1
  258. package/dist/chunk-OLIKJUKI.js +0 -1
  259. package/dist/chunk-POXANAJ6.js +0 -3
  260. package/dist/chunk-RSMEXK53.js +0 -43
  261. package/dist/chunk-SGS4OJGS.js +0 -1
  262. package/dist/chunk-URJ2VFNC.js +0 -1
  263. package/dist/chunk-VXPLLA4P.js +0 -1
  264. package/dist/chunk-WZYB3JQS.js +0 -1
  265. package/dist/chunk-Z6X7B6A4.js +0 -61
  266. package/dist/index-8s-Qm-gz.d.ts +0 -218
  267. package/dist/index-BgjS2b8N.d.ts +0 -366
  268. package/dist/index-BmSQLAZo.d.cts +0 -244
  269. package/dist/index-CGhMJNHb.d.cts +0 -128
  270. package/dist/index-CUIkE1l9.d.cts +0 -230
  271. package/dist/index-Ck35nA-T.d.ts +0 -244
  272. package/dist/index-CuPUehFa.d.cts +0 -218
  273. package/dist/index-D1Gc7wV5.d.ts +0 -230
  274. package/dist/index-N2MAxt7_.d.ts +0 -128
  275. package/dist/index-t6L2qpHh.d.cts +0 -366
  276. package/dist/patterns/audit/index.cjs +0 -3
  277. package/dist/patterns/audit/index.d.cts +0 -8
  278. package/dist/patterns/audit/index.d.ts +0 -8
  279. package/dist/patterns/audit/index.js +0 -1
  280. package/dist/patterns/guarded-execution/index.cjs +0 -3
  281. package/dist/patterns/guarded-execution/index.d.cts +0 -9
  282. package/dist/patterns/guarded-execution/index.d.ts +0 -9
  283. package/dist/patterns/guarded-execution/index.js +0 -1
  284. package/dist/patterns/lens/index.cjs +0 -3
  285. package/dist/patterns/lens/index.d.cts +0 -7
  286. package/dist/patterns/lens/index.d.ts +0 -7
  287. package/dist/patterns/lens/index.js +0 -1
  288. package/dist/patterns/refine-loop/index.cjs +0 -5
  289. package/dist/patterns/refine-loop/index.d.cts +0 -9
  290. package/dist/patterns/refine-loop/index.d.ts +0 -9
  291. package/dist/patterns/refine-loop/index.js +0 -1
  292. package/dist/patterns/resilient-pipeline/index.cjs +0 -3
  293. package/dist/patterns/resilient-pipeline/index.d.cts +0 -8
  294. package/dist/patterns/resilient-pipeline/index.d.ts +0 -8
  295. package/dist/patterns/resilient-pipeline/index.js +0 -1
  296. package/dist/resilience-JISHQD2F.js +0 -1
@@ -1,5 +1,5 @@
1
- import { N as Node } from './node-BYInONRr.js';
2
- import { G as Graph } from './graph-BkIkog4h.js';
1
+ import { N as Node } from './node-ClS5yC-B.js';
2
+ import { G as Graph } from './graph-7VguS7a4.js';
3
3
 
4
4
  /** Pluggable measurement backend. */
5
5
  interface MeasurementAdapter {
@@ -1,4 +1,4 @@
1
- import { V as VersioningLevel, b as NodeGuard, N as Node } from './node-BYInONRr.cjs';
1
+ import { V as VersioningLevel, b as NodeGuard, N as Node } from './node-ClS5yC-B.cjs';
2
2
  import { AppendLogStorageTier } from './extra/storage-tiers.cjs';
3
3
 
4
4
  type ReactiveLogOptions<T> = {
@@ -1,4 +1,4 @@
1
- import { V as VersioningLevel, b as NodeGuard, N as Node } from './node-BYInONRr.js';
1
+ import { V as VersioningLevel, b as NodeGuard, N as Node } from './node-ClS5yC-B.js';
2
2
  import { AppendLogStorageTier } from './extra/storage-tiers.js';
3
3
 
4
4
  type ReactiveLogOptions<T> = {
@@ -1,4 +1,4 @@
1
- import { N as Node, V as VersioningLevel, a as NodeOptions } from './node-BYInONRr.cjs';
1
+ import { N as Node, V as VersioningLevel, a as NodeOptions } from './node-ClS5yC-B.cjs';
2
2
 
3
3
  type ReactiveMapOptions<K, V> = {
4
4
  /** Optional registry name for `describe()` / debugging. */
@@ -1,4 +1,4 @@
1
- import { N as Node, V as VersioningLevel, a as NodeOptions } from './node-BYInONRr.js';
1
+ import { N as Node, V as VersioningLevel, a as NodeOptions } from './node-ClS5yC-B.js';
2
2
 
3
3
  type ReactiveMapOptions<K, V> = {
4
4
  /** Optional registry name for `describe()` / debugging. */
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n}from"./chunk-AS3TV2TV.js";import"./chunk-L6NSJVJZ.js";import"./chunk-XLQPNNIC.js";import"./chunk-3G5U5QNE.js";import"./chunk-C72GO4IZ.js";import"./chunk-ACMJ2ZPS.js";import"./chunk-ESMPEKEV.js";import"./chunk-6YFZMUMR.js";import"./chunk-4VVTGLXJ.js";import"./chunk-2K5RXLAH.js";import"./chunk-35JTVPOX.js";import"./chunk-LYCLF26R.js";import"./chunk-CK2E7BTU.js";import"./chunk-QYADASLV.js";export{e as CircuitOpenError,i as RateLimiterOverflowError,b as ResilientPipelineGraph,l as TimeoutError,a as budgetGate,f as circuitBreaker,m as fallback,j as rateLimiter,c as resilientPipeline,d as retry,n as timeout,h as tokenBucket,g as withBreaker,k as withStatus};
@@ -1,4 +1,4 @@
1
- import { a as NodeOptions, F as FnCtx, N as Node, c as NodeActions, d as NodeFnCleanup } from './node-BYInONRr.js';
1
+ import { a as NodeOptions, F as FnCtx, N as Node, c as NodeActions, d as NodeFnCleanup } from './node-ClS5yC-B.js';
2
2
 
3
3
  /**
4
4
  * Sugar constructors over the raw `node()` primitive.
@@ -1,4 +1,4 @@
1
- import { a as NodeOptions, F as FnCtx, N as Node, c as NodeActions, d as NodeFnCleanup } from './node-BYInONRr.cjs';
1
+ import { a as NodeOptions, F as FnCtx, N as Node, c as NodeActions, d as NodeFnCleanup } from './node-ClS5yC-B.cjs';
2
2
 
3
3
  /**
4
4
  * Sugar constructors over the raw `node()` primitive.
@@ -1,4 +1,4 @@
1
- import { G as Graph, T as TopologyEvent } from './graph-BkIkog4h.js';
1
+ import { G as Graph, T as TopologyEvent } from './graph-7VguS7a4.js';
2
2
 
3
3
  /**
4
4
  * Subscribe to structural changes across `graph` and every transitively
@@ -1,4 +1,4 @@
1
- import { G as Graph, T as TopologyEvent } from './graph-E6likq7w.cjs';
1
+ import { G as Graph, T as TopologyEvent } from './graph-C4SHb3Ly.cjs';
2
2
 
3
3
  /**
4
4
  * Subscribe to structural changes across `graph` and every transitively
@@ -1,4 +1,4 @@
1
- import { N as Node } from './node-BYInONRr.cjs';
1
+ import { N as Node } from './node-ClS5yC-B.cjs';
2
2
  import { NodeInput } from './extra/sources.cjs';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { N as Node } from './node-BYInONRr.js';
1
+ import { N as Node } from './node-ClS5yC-B.js';
2
2
  import { NodeInput } from './extra/sources.js';
3
3
 
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphrefly/graphrefly",
3
- "version": "0.41.0",
3
+ "version": "0.42.0",
4
4
  "packageManager": "pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319",
5
5
  "description": "Reactive harness layer for agent workflows. Describe automations in plain language, trace every decision, enforce policies, persist checkpoints. Zero dependencies.",
6
6
  "repository": {
@@ -307,16 +307,6 @@
307
307
  "default": "./dist/patterns/ai/browser.cjs"
308
308
  }
309
309
  },
310
- "./patterns/audit": {
311
- "import": {
312
- "types": "./dist/patterns/audit/index.d.ts",
313
- "default": "./dist/patterns/audit/index.js"
314
- },
315
- "require": {
316
- "types": "./dist/patterns/audit/index.d.cts",
317
- "default": "./dist/patterns/audit/index.cjs"
318
- }
319
- },
320
310
  "./patterns/cqrs": {
321
311
  "import": {
322
312
  "types": "./dist/patterns/cqrs/index.d.ts",
@@ -357,16 +347,6 @@
357
347
  "default": "./dist/patterns/graphspec/index.cjs"
358
348
  }
359
349
  },
360
- "./patterns/guarded-execution": {
361
- "import": {
362
- "types": "./dist/patterns/guarded-execution/index.d.ts",
363
- "default": "./dist/patterns/guarded-execution/index.js"
364
- },
365
- "require": {
366
- "types": "./dist/patterns/guarded-execution/index.d.cts",
367
- "default": "./dist/patterns/guarded-execution/index.cjs"
368
- }
369
- },
370
350
  "./patterns/harness": {
371
351
  "import": {
372
352
  "types": "./dist/patterns/harness/index.d.ts",
@@ -377,24 +357,24 @@
377
357
  "default": "./dist/patterns/harness/index.cjs"
378
358
  }
379
359
  },
380
- "./patterns/job-queue": {
360
+ "./patterns/inspect": {
381
361
  "import": {
382
- "types": "./dist/patterns/job-queue/index.d.ts",
383
- "default": "./dist/patterns/job-queue/index.js"
362
+ "types": "./dist/patterns/inspect/index.d.ts",
363
+ "default": "./dist/patterns/inspect/index.js"
384
364
  },
385
365
  "require": {
386
- "types": "./dist/patterns/job-queue/index.d.cts",
387
- "default": "./dist/patterns/job-queue/index.cjs"
366
+ "types": "./dist/patterns/inspect/index.d.cts",
367
+ "default": "./dist/patterns/inspect/index.cjs"
388
368
  }
389
369
  },
390
- "./patterns/lens": {
370
+ "./patterns/job-queue": {
391
371
  "import": {
392
- "types": "./dist/patterns/lens/index.d.ts",
393
- "default": "./dist/patterns/lens/index.js"
372
+ "types": "./dist/patterns/job-queue/index.d.ts",
373
+ "default": "./dist/patterns/job-queue/index.js"
394
374
  },
395
375
  "require": {
396
- "types": "./dist/patterns/lens/index.d.cts",
397
- "default": "./dist/patterns/lens/index.cjs"
376
+ "types": "./dist/patterns/job-queue/index.d.cts",
377
+ "default": "./dist/patterns/job-queue/index.cjs"
398
378
  }
399
379
  },
400
380
  "./patterns/memory": {
@@ -457,26 +437,6 @@
457
437
  "default": "./dist/patterns/reduction/index.cjs"
458
438
  }
459
439
  },
460
- "./patterns/refine-loop": {
461
- "import": {
462
- "types": "./dist/patterns/refine-loop/index.d.ts",
463
- "default": "./dist/patterns/refine-loop/index.js"
464
- },
465
- "require": {
466
- "types": "./dist/patterns/refine-loop/index.d.cts",
467
- "default": "./dist/patterns/refine-loop/index.cjs"
468
- }
469
- },
470
- "./patterns/resilient-pipeline": {
471
- "import": {
472
- "types": "./dist/patterns/resilient-pipeline/index.d.ts",
473
- "default": "./dist/patterns/resilient-pipeline/index.js"
474
- },
475
- "require": {
476
- "types": "./dist/patterns/resilient-pipeline/index.d.cts",
477
- "default": "./dist/patterns/resilient-pipeline/index.cjs"
478
- }
479
- },
480
440
  "./patterns/surface": {
481
441
  "import": {
482
442
  "types": "./dist/patterns/surface/index.d.ts",
@@ -1,115 +0,0 @@
1
- import { N as Node, a as NodeOptions } from './node-BYInONRr.js';
2
-
3
- /**
4
- * `budgetGate` — numeric-constraint flow gate (Tier 2.2 promotion from
5
- * `patterns/reduction/`).
6
- *
7
- * Lives alongside the other `extra/resilience/` flow controls (`retry`,
8
- * `circuitBreaker`, `rateLimiter`, `tokenBucket`, `fallback`, `withStatus`).
9
- *
10
- * @module
11
- */
12
-
13
- /** A reactive constraint for {@link budgetGate}. */
14
- type BudgetConstraint<T = unknown> = {
15
- /** Constraint node whose value is checked. */
16
- node: Node<T>;
17
- /** Returns `true` when the constraint is satisfied (budget available). */
18
- check: (value: T) => boolean;
19
- };
20
- /** Options for {@link budgetGate}. */
21
- type BudgetGateOptions = Omit<NodeOptions<unknown>, "describeKind" | "name" | "meta"> & {
22
- meta?: Record<string, unknown>;
23
- };
24
- /**
25
- * Pass-through that respects reactive constraint nodes.
26
- *
27
- * DATA flows through when all constraints are satisfied. When any constraint
28
- * is exceeded, `PAUSE` is sent upstream and DATA is buffered in a FIFO queue.
29
- * When constraints relax, the queue drains in arrival order and `RESUME` is
30
- * sent upstream.
31
- *
32
- * ## Invariants (do not refactor without preserving)
33
- *
34
- * 1. **Terminal force-flush.** On `COMPLETE` / `ERROR` arriving from `source`,
35
- * every buffered item is emitted downstream BEFORE the terminal message is
36
- * forwarded. The constraint is intentionally bypassed for the flush — once
37
- * upstream is done, the caller must see the buffered work, not lose it.
38
- * See COMPOSITION-GUIDE §19 (terminal-emission operators).
39
- *
40
- * 2. **PAUSE-release ordering.** When a constraint flips from saturated →
41
- * released, the queue drains in FIFO order downstream BEFORE `RESUME` is
42
- * sent upstream. Reversing the order (RESUME-then-drain) would let new
43
- * upstream DATA interleave with the queue tail, breaking arrival-order
44
- * delivery. See COMPOSITION-GUIDE §9, §9a (diamond + batch coalescing).
45
- *
46
- * 3. **Deferred RESOLVED.** A `RESOLVED` from `source` while the queue is
47
- * non-empty is held until the queue drains, then forwarded — so downstream
48
- * sees `[buffered DATA…, RESOLVED]` in causal order rather than
49
- * `[RESOLVED, buffered DATA…]`.
50
- *
51
- * **Stall risk (qa D4):** if the constraint never relaxes AND no terminal
52
- * arrives from `source`, the deferred RESOLVED is held forever. Downstream
53
- * consumers that depend on `RESOLVED` for an `awaitSettled`-style
54
- * coordination wait stall in this case. PAUSE is sent upstream so source
55
- * backpressure stops further DATA, but the gate itself has no escape
56
- * hatch — by design (the producer-pattern is fire-and-forget; recovery
57
- * happens at the compositor level via timeout, retry, or cancellation).
58
- *
59
- * 4. **Constraint DIRTY suppression.** Constraint-node DIRTY does NOT
60
- * propagate downstream — only `source`-DIRTY does. The gate's downstream
61
- * semantics track `source`'s wave, not constraint waves.
62
- *
63
- * 5. **Lazy PAUSE (qa D3).** PAUSE is sent upstream ONLY when a `source` DATA
64
- * arrives that fails the constraint check (the first blocked item). A
65
- * constraint flipping closed BEFORE any source DATA arrives does NOT emit
66
- * a preemptive PAUSE — upstream may push DATA freely until the first
67
- * item is buffered. This matches the producer-pattern lazy-activation
68
- * philosophy (don't impose backpressure for hypothetical future blocks).
69
- * For eager-PAUSE semantics, wrap the gate in a compositor that watches
70
- * constraints + source independently.
71
- *
72
- * ## Queue
73
- *
74
- * The internal buffer is an unbounded {@link HeadIndexQueue} (O(1) push,
75
- * O(1) shift, opportunistic compaction). It does NOT use {@link RingBuffer}
76
- * because RingBuffer's drop-oldest eviction would silently lose buffered
77
- * items between PAUSE and RESUME. Backpressure (PAUSE) is the upstream
78
- * contract for bounding the queue, not capacity-driven eviction here.
79
- *
80
- * ## Producer-pattern: source edge is invisible to `describe()`
81
- *
82
- * `budgetGate` is constructed via `node([], fn)` and subscribes to `source`
83
- * and the constraint nodes manually inside its activation fn. Because no
84
- * dep is declared at construction, **`describe()` shows no edge from
85
- * `source` (or any constraint) into the returned node** — the gate looks
86
- * like a standalone leaf source. This is intentional (see COMPOSITION-GUIDE
87
- * §24 "Edges are derived, not declared"): if you want the constraint /
88
- * source dependency to appear in describe output, surface it at the
89
- * compositor level (e.g. annotate via `meta.ai.upstream`, or wrap the gate
90
- * in a parent factory that exposes the deps as constructor args).
91
- *
92
- * ## Reference equality
93
- *
94
- * The `constraints` array reference and each `BudgetConstraint.check`
95
- * function are captured at construction. The factory does NOT diff
96
- * subsequent `constraints` arrays (there is no subsequent — the array is
97
- * static for the gate's lifetime). To swap constraints reactively, build
98
- * the swap at the compositor level above the gate (Architecture-2:
99
- * compositor-only). Identity changes to `constraints` are observed only by
100
- * constructing a new gate.
101
- *
102
- * @param source - Input node.
103
- * @param constraints - Reactive constraint checks. MUST be non-empty.
104
- * @param opts - Optional node options.
105
- * @returns Gated node.
106
- *
107
- * @throws {RangeError} when `constraints.length === 0`. The gate has no
108
- * meaningful identity without at least one check — degenerate to plain
109
- * pass-through (e.g. via `derived([source], ([v]) => v)`) instead.
110
- *
111
- * @category resilience
112
- */
113
- declare function budgetGate<T>(source: Node<T>, constraints: ReadonlyArray<BudgetConstraint>, opts?: BudgetGateOptions): Node<T>;
114
-
115
- export { type BudgetConstraint as B, type BudgetGateOptions as a, budgetGate as b };
@@ -1,115 +0,0 @@
1
- import { N as Node, a as NodeOptions } from './node-BYInONRr.cjs';
2
-
3
- /**
4
- * `budgetGate` — numeric-constraint flow gate (Tier 2.2 promotion from
5
- * `patterns/reduction/`).
6
- *
7
- * Lives alongside the other `extra/resilience/` flow controls (`retry`,
8
- * `circuitBreaker`, `rateLimiter`, `tokenBucket`, `fallback`, `withStatus`).
9
- *
10
- * @module
11
- */
12
-
13
- /** A reactive constraint for {@link budgetGate}. */
14
- type BudgetConstraint<T = unknown> = {
15
- /** Constraint node whose value is checked. */
16
- node: Node<T>;
17
- /** Returns `true` when the constraint is satisfied (budget available). */
18
- check: (value: T) => boolean;
19
- };
20
- /** Options for {@link budgetGate}. */
21
- type BudgetGateOptions = Omit<NodeOptions<unknown>, "describeKind" | "name" | "meta"> & {
22
- meta?: Record<string, unknown>;
23
- };
24
- /**
25
- * Pass-through that respects reactive constraint nodes.
26
- *
27
- * DATA flows through when all constraints are satisfied. When any constraint
28
- * is exceeded, `PAUSE` is sent upstream and DATA is buffered in a FIFO queue.
29
- * When constraints relax, the queue drains in arrival order and `RESUME` is
30
- * sent upstream.
31
- *
32
- * ## Invariants (do not refactor without preserving)
33
- *
34
- * 1. **Terminal force-flush.** On `COMPLETE` / `ERROR` arriving from `source`,
35
- * every buffered item is emitted downstream BEFORE the terminal message is
36
- * forwarded. The constraint is intentionally bypassed for the flush — once
37
- * upstream is done, the caller must see the buffered work, not lose it.
38
- * See COMPOSITION-GUIDE §19 (terminal-emission operators).
39
- *
40
- * 2. **PAUSE-release ordering.** When a constraint flips from saturated →
41
- * released, the queue drains in FIFO order downstream BEFORE `RESUME` is
42
- * sent upstream. Reversing the order (RESUME-then-drain) would let new
43
- * upstream DATA interleave with the queue tail, breaking arrival-order
44
- * delivery. See COMPOSITION-GUIDE §9, §9a (diamond + batch coalescing).
45
- *
46
- * 3. **Deferred RESOLVED.** A `RESOLVED` from `source` while the queue is
47
- * non-empty is held until the queue drains, then forwarded — so downstream
48
- * sees `[buffered DATA…, RESOLVED]` in causal order rather than
49
- * `[RESOLVED, buffered DATA…]`.
50
- *
51
- * **Stall risk (qa D4):** if the constraint never relaxes AND no terminal
52
- * arrives from `source`, the deferred RESOLVED is held forever. Downstream
53
- * consumers that depend on `RESOLVED` for an `awaitSettled`-style
54
- * coordination wait stall in this case. PAUSE is sent upstream so source
55
- * backpressure stops further DATA, but the gate itself has no escape
56
- * hatch — by design (the producer-pattern is fire-and-forget; recovery
57
- * happens at the compositor level via timeout, retry, or cancellation).
58
- *
59
- * 4. **Constraint DIRTY suppression.** Constraint-node DIRTY does NOT
60
- * propagate downstream — only `source`-DIRTY does. The gate's downstream
61
- * semantics track `source`'s wave, not constraint waves.
62
- *
63
- * 5. **Lazy PAUSE (qa D3).** PAUSE is sent upstream ONLY when a `source` DATA
64
- * arrives that fails the constraint check (the first blocked item). A
65
- * constraint flipping closed BEFORE any source DATA arrives does NOT emit
66
- * a preemptive PAUSE — upstream may push DATA freely until the first
67
- * item is buffered. This matches the producer-pattern lazy-activation
68
- * philosophy (don't impose backpressure for hypothetical future blocks).
69
- * For eager-PAUSE semantics, wrap the gate in a compositor that watches
70
- * constraints + source independently.
71
- *
72
- * ## Queue
73
- *
74
- * The internal buffer is an unbounded {@link HeadIndexQueue} (O(1) push,
75
- * O(1) shift, opportunistic compaction). It does NOT use {@link RingBuffer}
76
- * because RingBuffer's drop-oldest eviction would silently lose buffered
77
- * items between PAUSE and RESUME. Backpressure (PAUSE) is the upstream
78
- * contract for bounding the queue, not capacity-driven eviction here.
79
- *
80
- * ## Producer-pattern: source edge is invisible to `describe()`
81
- *
82
- * `budgetGate` is constructed via `node([], fn)` and subscribes to `source`
83
- * and the constraint nodes manually inside its activation fn. Because no
84
- * dep is declared at construction, **`describe()` shows no edge from
85
- * `source` (or any constraint) into the returned node** — the gate looks
86
- * like a standalone leaf source. This is intentional (see COMPOSITION-GUIDE
87
- * §24 "Edges are derived, not declared"): if you want the constraint /
88
- * source dependency to appear in describe output, surface it at the
89
- * compositor level (e.g. annotate via `meta.ai.upstream`, or wrap the gate
90
- * in a parent factory that exposes the deps as constructor args).
91
- *
92
- * ## Reference equality
93
- *
94
- * The `constraints` array reference and each `BudgetConstraint.check`
95
- * function are captured at construction. The factory does NOT diff
96
- * subsequent `constraints` arrays (there is no subsequent — the array is
97
- * static for the gate's lifetime). To swap constraints reactively, build
98
- * the swap at the compositor level above the gate (Architecture-2:
99
- * compositor-only). Identity changes to `constraints` are observed only by
100
- * constructing a new gate.
101
- *
102
- * @param source - Input node.
103
- * @param constraints - Reactive constraint checks. MUST be non-empty.
104
- * @param opts - Optional node options.
105
- * @returns Gated node.
106
- *
107
- * @throws {RangeError} when `constraints.length === 0`. The gate has no
108
- * meaningful identity without at least one check — degenerate to plain
109
- * pass-through (e.g. via `derived([source], ([v]) => v)`) instead.
110
- *
111
- * @category resilience
112
- */
113
- declare function budgetGate<T>(source: Node<T>, constraints: ReadonlyArray<BudgetConstraint>, opts?: BudgetGateOptions): Node<T>;
114
-
115
- export { type BudgetConstraint as B, type BudgetGateOptions as a, budgetGate as b };
@@ -1 +0,0 @@
1
- import{d as g}from"./chunk-EC2WNSZ7.js";import{a as v}from"./chunk-URJ2VFNC.js";import{a as N}from"./chunk-L6NSJVJZ.js";import{i as _}from"./chunk-POXANAJ6.js";import{C as D}from"./chunk-L77I47VU.js";import{E as c,G as p,o as G}from"./chunk-LYCLF26R.js";import{b}from"./chunk-CK2E7BTU.js";import{b as L}from"./chunk-QYADASLV.js";var P={};L(P,{GuardedExecutionGraph:()=>d,guardedExecution:()=>x});function u(o){return typeof o=="object"&&o!==null&&"subscribe"in o&&"down"in o}function w(o){return N("guarded",o)}var d=class extends _{enforcer;violations;lints;scope;scopedDescribe;_target;_actorNode;_mode;_firedLintKinds=new Set;constructor(e,i){super(i.name??`${e.name}_guarded`,i.graph),this._target=e,this._mode=i.mode??"enforce";let n=i.policies,r=u(n);if(!r&&this._mode==="enforce"&&n.length===0)throw new RangeError('guardedExecution: empty `policies` in `mode: "enforce"` denies every action. Pass at least `{ effect: "allow", action: "*" }` and layer deny rules on top.');this.lints=new v("lints",{retainedLimit:i.lintsLimit??64}),this.mount("lints",this.lints);let a=i.actor;a==null?this._actorNode=c(null,{name:"actor"}):u(a)?this._actorNode=p([a],([t])=>t??null,{name:"actor",initial:null}):this._actorNode=c(a,{name:"actor"});let m={mode:this._mode,name:"enforcer"};if(i.violationsLimit!=null&&(m.violationsLimit=i.violationsLimit),this.enforcer=g(e,i.policies,m),this.violations=this.enforcer.violations,this.mount("enforcer",this.enforcer),r&&this._mode==="enforce"){let t=n,s=t.cache;s!=null&&s.length===0&&this._fireLint("empty-policies",'`policies` Node cached an empty array in `mode: "enforce"` \u2014 every action will be denied. Add at least one allow rule.');let l=t.subscribe(A=>{for(let h of A){if(h[0]!==b)continue;let y=h[1];(y==null||y.length===0)&&this._fireLint("empty-policies",'`policies` Node emitted an empty array in `mode: "enforce"` \u2014 every action will be denied. Add at least one allow rule.')}});this.addDisposer(l)}if(this._mode==="audit"){let t=e.describe({detail:"full"});Object.values(t.nodes).some(l=>l.guard!=null)||this._fireLint("audit-no-effect",'`mode: "audit"` + target has no per-node guards \u2014 `scopedDescribeNode` filters by per-node guards only, so policy rules will not affect describe() visibility. Policies still populate the `violations` topic on writes.')}a==null&&this._fireLint("no-actor","no actor configured \u2014 `wrapper.scopedDescribe` and `scopedDescribeNode()` will return an unscoped describe (full visibility) unless a per-call actor is supplied."),this.scope=p([this._actorNode,this.enforcer.policies],([t,s])=>({actor:t??null,mode:this._mode,policiesCount:s.length}),{name:"scope",describeKind:"derived",meta:w("scope")}),this.add(this.scope,{name:"scope"}),this.addDisposer(D(this.scope));let f=e.describe({reactive:!0,actor:this._actorNode,reactiveName:"scopedDescribe"});this.scopedDescribe=f.node,this.add(this.scopedDescribe,{name:"scopedDescribe"}),this.addDisposer(f.dispose)}_fireLint(e,i){this._firedLintKinds.has(e)||(this._firedLintKinds.add(e),this.lints.publish({kind:e,message:i,timestamp_ns:G()}))}scopedDescribeNode(e,i){let n=e==null?this._actorNode:u(e)?e:c(e,{name:"actor_override"}),r=this._target.describe({reactive:!0,actor:n,...i??{}});return this.addDisposer(r.dispose),{node:r.node,dispose:r.dispose}}get target(){return this._target}};function x(o,e){return new d(o,e)}export{d as a,x as b,P as c};
@@ -1 +0,0 @@
1
- import{a as Q}from"./chunk-L6NSJVJZ.js";import{a as X}from"./chunk-SGS4OJGS.js";import{a as I}from"./chunk-ESMPEKEV.js";import{a as M,b as z,i as J}from"./chunk-4VVTGLXJ.js";import{m as Z}from"./chunk-L77I47VU.js";import{c as N}from"./chunk-35JTVPOX.js";import{D as A,F as x,m as W,o as G}from"./chunk-LYCLF26R.js";import{b as T,c as k,d as h,f as D,g as V,h as L,i as y,j as g}from"./chunk-CK2E7BTU.js";var U=class{buf=[];head=0;get size(){return this.buf.length-this.head}push(t){this.buf.push(t)}shift(){if(this.head>=this.buf.length)return;let t=this.buf[this.head];return this.buf[this.head]=void 0,this.head++,this.head>32&&this.head*2>this.buf.length&&(this.buf=this.buf.slice(this.head),this.head=0),t}clear(){this.buf=[],this.head=0}};function re(e,t,u){if(t.length===0)throw new RangeError("budgetGate requires at least one constraint");let c=t.map(l=>l.node),n=[e,...c],s=new U,r=!1,i=!1,a=Symbol("budget-gate"),d=new Array(t.length);function f(){return t.every((l,b)=>l.check(d[b]))}function o(l){for(;s.size>0&&f();){let b=s.shift();l.emit(b)}s.size===0&&i&&(i=!1,l.down([[h]]))}return A([],(l,b)=>{for(let m=0;m<t.length;m++)d[m]=t[m].node.cache;let w=[];for(let m=0;m<n.length;m++){let R=n[m];w.push(R.subscribe(B=>{for(let C of B)p(C,m,b)}))}return()=>{for(let m of w)m()}},{...u,describeKind:"derived",meta:Q("resilience","budget_gate",u?.meta)});function p(l,b,w){let m=l[0];if(b===0){if(m===T)return f()&&s.size===0?w.emit(l[1]):(s.push(l[1]),r||(r=!0,w.up([[D,a]]))),!0;if(m===k)return w.down([[k]]),!0;if(m===h)return s.size===0?w.down([[h]]):i=!0,!0;if(m===y||m===g){for(;s.size>0;)w.emit(s.shift());return i=!1,r&&(r=!1,w.up([[V,a]])),w.down([l]),!0}return!1}if(m===T&&(d[b-1]=l[1]),m===T||m===h){let R=f();return R&&s.size>0?(o(w),s.size===0&&r&&(r=!1,w.up([[V,a]]))):!R&&!r&&s.size>0&&(r=!0,w.up([[D,a]])),!0}return m===k?!0:m===g?(w.down([l]),!0):m===y}}function v(e){return{describeKind:"derived",...e}}function oe(e){return e<0?0:e}function Y(e){return e[1]}function ie(e){if(typeof e!="number"||!Number.isFinite(e))throw new TypeError("backoff strategy must return a finite number");return e<0?0:e}function H(e){let t=e?.count,u=e?.backoff;if(u!==void 0&&t===void 0)throw new RangeError("retry({ backoff }) requires explicit count to prevent unbounded retries; pass { count: <n>, backoff: ... }");let c=t!==void 0?t:0;if(c<0)throw new RangeError("retry count must be >= 0");let n=u===void 0?null:typeof u=="string"?J(u):u;return{maxRetries:c,strategy:n}}function ee(e){let t={};return e?.count!==void 0&&(t.count=e.count),typeof e?.backoff=="string"&&(t.backoff=e.backoff),Object.keys(t).length>0?t:void 0}function te(e,t,u){let c=0,n=!1,s=null,r,i=new I;function a(){r?.(),r=void 0}function d(o){if(n)return;if(c>=e.maxRetries){a(),u.down([[g,o]]);return}let p=e.strategy===null?0:e.strategy(c,o,s);if(p==null){a(),u.down([[g,o]]);return}let l;try{l=ie(p)}catch{a(),u.down([[g,o]]);return}s=l,c+=1,a();let b=l>0?l/1e6:1;i.start(b,()=>{n||f()})}function f(){i.cancel(),a();let o;try{o=t()}catch(p){d(p);return}r=o.subscribe(p=>{if(!n)for(let l of p){let b=l[0];if(b===k)u.down([[k]]);else if(b===T)c=0,s=null,u.emit(l[1]);else if(b===h)u.down([[h]]);else if(b===y)a(),u.down([[y]]);else if(b===g){d(Y(l));return}else u.down([l])}})}return f(),()=>{n=!0,i.cancel(),a()}}function Ce(e,t){return typeof e=="function"?se(e,t):ue(e,t)}function ue(e,t){let u=H(t);return x(c=>te(u,()=>e,c),{...v(),initial:e.cache,meta:{...t?.meta??{},...N("retry",ee(t))}})}function se(e,t){let u=H(t);return x(c=>te(u,e,c),{...v(),initial:t?.initial,meta:{...t?.meta??{},...N("retry",ee(t))}})}var j=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};function Ee(e){let t=Math.max(1,e?.failureThreshold??5),u=oe(e?.cooldownNs??30*1e9),c=e?.cooldown??null,n=Math.max(1,e?.halfOpenMax??1),s=e?.now??G,r="closed",i=0,a=0,d=0,f=u,o=0;function p(){if(!c)return u;let w=c(a);return w!==null?w:u}function l(){r="open",f=p(),d=s(),o=0}return{canExecute(){return r==="closed"?!0:r==="open"?s()-d>=f?(r="half-open",o=1,!0):!1:o<n?(o++,!0):!1},recordSuccess(){r==="half-open"?(r="closed",i=0,a=0):r==="closed"&&(i=0)},recordFailure(w){if(r==="half-open"){a++,l();return}r==="closed"&&(i++,i>=t&&l())},get state(){return r},get failureCount(){return i},reset(){r="closed",i=0,a=0,o=0}}}function Le(e,t){let u=t?.onOpen??"skip",c=t?.meta;return n=>{let s=A([],(r,i)=>{function a(){s.meta.breakerState.down([[T,e.state]])}let d=n.subscribe(f=>{for(let o of f){let p=o[0];p===k?i.down([[k]]):p===T?e.canExecute()?(a(),i.emit(o[1])):(a(),u==="error"?i.down([[g,new j]]):i.down([[h]])):p===h?i.down([[h]]):p===y?(e.recordSuccess(),a(),i.down([[y]])):p===g?(e.recordFailure(Y(o)),a(),i.down([o])):i.down([o])}});return a(),d},{...v(),meta:{...c??{},breakerState:e.state,...N("withBreaker",{onOpen:u})},completeWhenDepsComplete:!1,initial:n.cache});return{node:s,breakerState:s.meta.breakerState}}}function ae(e,t,u){if(e<=0)throw new RangeError("capacity must be > 0");if(t<0)throw new RangeError("refillPerSecond must be >= 0");let c=u?.clock??G,n=e,s=c();function r(i){if(t>0){let a=i-s;n=Math.min(e,n+a/1e9*t)}s=i}return{available(){return r(c()),n},tryConsume(i=1){if(i<=0)return!0;let a=c();return r(a),n>=i?(n-=i,!0):!1},putBack(i=1){i<=0||(r(c()),n=Math.min(e,n+i))}}}var q=class extends Error{name="RateLimiterOverflowError";constructor(t){super(`rateLimiter buffer overflow (maxBuffer=${t})`)}};function de(e,t){return e.droppedCount===t.droppedCount&&e.pendingCount===t.pendingCount&&e.paused===t.paused}var F=Object.freeze({droppedCount:0,pendingCount:0,paused:!1});function Ae(e,t){let{maxEvents:u,windowNs:c}=t;if(u<=0)throw new RangeError("maxEvents must be > 0");if(c<=0)throw new RangeError("windowNs must be > 0");let n=t.maxBuffer;if(n===void 0)throw new RangeError("rateLimiter requires explicit maxBuffer (use Infinity to opt in to unbounded)");let s=n===1/0;if(!s&&(!Number.isInteger(n)||n<1))throw new RangeError("maxBuffer must be a positive integer (or Infinity for unbounded)");let r=t.onOverflow??"drop-newest",i=u*1e9/c,a=x(d=>{let f=ae(u,i),o=s?ce():fe(n),p=new I,l=!1,b=0,w=1e9/i,m=a.meta.droppedCount,R=a.meta.rateLimitState,B=F;function C(){m.emit(b);let E={droppedCount:b,pendingCount:o.size,paused:o.size>0};de(B,E)||(B=E,R.emit(E))}B=F,m.emit(0),R.emit(F);function $(){for(;o.size>0;)if(f.tryConsume(1))d.emit(o.shift()),C();else{p.start(Math.max(1,w/1e6),$);return}}function P(){b+=1,C()}function _(){for(l=!0,p.cancel();o.size>0;)o.shift();b=0}let ne=e.subscribe(E=>{for(let S of E){if(l)return;let O=S[0];if(O===k)d.down([[k]]);else if(O===T){if(!s&&o.size>=n)if(r==="drop-newest")P();else if(r==="drop-oldest")o.shift(),o.push(S[1]),P();else{P(),_(),d.down([[g,new q(n)]]);return}else o.push(S[1]),C();$()}else if(O===h)d.down([[h]]);else if(O===y)_(),d.down([[y]]);else if(O===g)_(),d.down([S]);else if(O===L){_(),d.down([S]);return}else d.down([S])}});return()=>{l=!0,p.cancel(),ne()}},{...v(),initial:e.cache,meta:{...t.meta??{},droppedCount:0,rateLimitState:F,...N("rateLimiter",t)}});return{node:a,droppedCount:a.meta.droppedCount,rateLimitState:a.meta.rateLimitState}}function fe(e){let t=new X(e);return{push:u=>t.push(u),shift:()=>t.shift(),get size(){return t.size}}}function ce(){let e=[];return{push:t=>{e.push(t)},shift:()=>e.shift(),get size(){return e.length}}}function Me(e,t){let u=t?.initialStatus??"pending",c=t?.meta,n=A([],(s,r)=>{let i=u;return n.meta.status.down([[T,u]]),n.meta.error.down([[T,null]]),e.subscribe(d=>{for(let f of d){let o=f[0];if(o===k)r.down([[k]]);else if(o===T)i==="errored"?W(()=>{n.meta.error.down([[T,null]]),n.meta.status.down([[T,"running"]])}):n.meta.status.down([[T,"running"]]),i="running",r.emit(f[1]);else if(o===h)r.down([[h]]);else if(o===y)n.meta.status.down([[T,"completed"]]),i="completed",r.down([[y]]);else if(o===g){let p=Y(f);W(()=>{n.meta.error.down([[T,p]]),n.meta.status.down([[T,"errored"]])}),i="errored",r.down([f])}else r.down([f])}})},{...v(),meta:{...c??{},status:u,error:null,...N("withStatus",{initialStatus:u})},completeWhenDepsComplete:!1,resubscribable:!0,initial:e.cache});return{node:n,status:n.meta.status,error:n.meta.error}}var K=class extends Error{name="TimeoutError";constructor(t){super(`Timed out after ${t/1e6}ms`)}};function le(e){return e!=null&&typeof e=="object"&&"cache"in e&&typeof e.subscribe=="function"}function me(e){return e!=null&&typeof e.then=="function"}function pe(e){return e!=null&&typeof e=="object"&&typeof e[Symbol.asyncIterator]=="function"}function ze(e,t,u){let c=u?.meta;return x(n=>{let s,r;function i(){r?.(),r=void 0,le(t)||me(t)||pe(t)?s=Z(t).subscribe(d=>{n.down(d);for(let f of d){let o=f[0];if(o===y||o===g||o===L){s=void 0;return}}}):(n.emit(t),n.down([[y]]))}return r=e.subscribe(a=>{for(let d of a){let f=d[0];if(f===k)n.down([[k]]);else if(f===T)n.emit(d[1]);else if(f===h)n.down([[h]]);else if(f===y)n.down([[y]]);else if(f===g){i();return}else if(f===L){s?.(),n.down([d]);return}else n.down([d])}}),()=>{r?.(),s?.()}},{...v(),initial:e.cache,meta:{...c??{},...N("fallback")}})}function _e(e,t,u){if(t<=0)throw new RangeError("timeoutNs must be > 0");let c=u?.meta;return x(n=>{let s=!1,r=new I;function i(){let d=t/1e6;r.start(d,()=>{s||(s=!0,a(),n.down([[g,new K(t)]]))})}let a=e.subscribe(d=>{for(let f of d){if(s)return;let o=f[0];if(o===k)n.down([[k]]);else if(o===T)i(),n.emit(f[1]);else if(o===h)n.down([[h]]);else if(o===y){r.cancel(),s=!0,n.down([[y]]);return}else if(o===g){r.cancel(),s=!0,n.down([f]);return}else if(o===L){r.cancel(),s=!0,n.down([f]);return}else n.down([f])}});return i(),()=>{s=!0,r.cancel(),a()}},{...v(),initial:e.cache,meta:{...c??{},...N("timeout",{timeoutNs:t})}})}export{re as a,Ce as b,j as c,Ee as d,Le as e,ae as f,q as g,Ae as h,Me as i,K as j,ze as k,_e as l};
@@ -1 +0,0 @@
1
- import{b as B}from"./chunk-KGKJCHEK.js";import{b as z}from"./chunk-TZQPPQEQ.js";import{c as G,h as W}from"./chunk-VXPLLA4P.js";import{a as L}from"./chunk-L6NSJVJZ.js";import{b as I}from"./chunk-TT4C7DXW.js";import{i as F}from"./chunk-POXANAJ6.js";import{C as _,m as Q}from"./chunk-L77I47VU.js";import{b as D}from"./chunk-35JTVPOX.js";import{D as P,G as N,m as f,p as c}from"./chunk-LYCLF26R.js";import{b as x,j as C}from"./chunk-CK2E7BTU.js";import{b as Y}from"./chunk-QYADASLV.js";var oe={};Y(oe,{JobFlowGraph:()=>w,JobQueueGraph:()=>y,jobEventKeyOf:()=>te,jobFlow:()=>ne,jobQueue:()=>K});var Z=256,ee=1024;function R(i,e){if(!Number.isFinite(i)||!Number.isInteger(i)||i<0)throw new Error(`${e} must be a non-negative integer`);return i}function T(i,e){return L("job_queue",i,e)}var te=i=>i.action,y=class extends F{_pending;_jobs;_seqCursor;pending;jobs;depth;events;audit;constructor(e,t={}){super(e,t.graph),this._pending=B([],{name:"pending"}),this._jobs=z({name:"jobs"}),this.pending=this._pending.items,this.jobs=this._jobs.entries,this.add(this.pending,{name:"pending"}),this.add(this.jobs,{name:"jobs"}),this.depth=N([this.pending],([s])=>s.length,{name:"depth",describeKind:"derived",meta:T("queue_depth"),initial:0}),this.add(this.depth,{name:"depth"}),this.addDisposer(_(this.depth)),this.events=G({name:"events",retainedLimit:1024,graph:this}),this.audit=this.events,this._seqCursor=W(this,"seq",0)}_bumpSeq(){let t=(this._seqCursor.cache??0)+1;return this._seqCursor.emit(t),t}attachEventStorage(e){return this.events.attachStorage(e)}enqueue(e,t={}){let s=this._bumpSeq(),n=t.id??`${this.name}-${s}`;if(this._jobs.get(n)!==void 0)throw new Error(`jobQueue("${this.name}"): duplicate job id "${n}"`);let p={id:n,payload:e,attempts:0,metadata:Object.freeze({...t.metadata??{}}),state:"queued"};return this._jobs.set(n,p),this._pending.append(n),this.events.append({action:"enqueue",id:n,payload:e,t_ns:c(),seq:s}),n}claim(e=1){let t=R(e,"job queue claim limit");if(t===0)return[];let s=[];for(;s.length<t&&this.pending.cache.length!==0;){let p=this._pending.pop(0),u=this._jobs.get(p);if(!u||u.state!=="queued")continue;let v={...u,state:"inflight",attempts:u.attempts+1};this._jobs.set(p,v),s.push(v),this.events.append({action:"claim",id:p,attempts:v.attempts,t_ns:c(),seq:this._bumpSeq()})}return s}ack(e){let t=this._jobs.get(e);return!t||t.state!=="inflight"?!1:(this._jobs.delete(e),this.events.append({action:"ack",id:e,attempts:t.attempts,t_ns:c(),seq:this._bumpSeq()}),!0)}nack(e,t={}){let s=this._jobs.get(e);return!s||s.state!=="inflight"?!1:t.requeue??!0?(this._jobs.set(e,{...s,state:"queued"}),this._pending.append(e),this.events.append({action:"nack",id:e,attempts:s.attempts,t_ns:c(),seq:this._bumpSeq()}),!0):(this._jobs.delete(e),this.events.append({action:"nack",id:e,attempts:s.attempts,t_ns:c(),seq:this._bumpSeq()}),!0)}removeById(e){let t=this._jobs.get(e);if(!t)return!1;if(t.state==="queued"){let n=this.pending.cache.indexOf(e);n>=0&&this._pending.pop(n)}return this._jobs.delete(e),this.events.append({action:"remove",id:e,attempts:t.attempts,t_ns:c(),seq:this._bumpSeq()}),!0}consumeFrom(e,t){return e.subscribe(s=>{for(let n of s){if(n[0]!==x)continue;let p=n[1];this.enqueue(p,t?{metadata:t.metadata}:void 0)}})}},w=class extends F{_stageNames;_stageWorkFns;_queues=new Map;_completed;completed;completedCount;constructor(e,t={}){super(e,t.graph);let s=t.stages??["incoming","processing","done"],n=[],p=new Map,u=new Map;for(let o of s){let a=typeof o=="string"?o.trim():o.name.trim();typeof o!="string"&&o.work&&p.set(a,o.work),typeof o!="string"&&o.maxPerPump!=null&&u.set(a,Math.max(1,R(o.maxPerPump,`job flow stage "${a}" maxPerPump`))),n.push(a)}if(n.length<2)throw new Error(`jobFlow("${e}"): requires at least 2 stages`);if(new Set(n).size!==n.length)throw new Error(`jobFlow("${e}"): stage names must be unique`);this._stageNames=Object.freeze([...n]),this._stageWorkFns=p;for(let o of this._stageNames){let a=K(`${e}-${o}`);this._queues.set(o,a),this.mount(o,a)}this._completed=I([],{name:"completed",maxSize:ee}),this.completed=this._completed.entries,this.add(this.completed,{name:"completed"}),this.completedCount=N([this.completed],([o])=>o.length,{name:"completedCount",describeKind:"derived",meta:T("job_flow_completed_count"),initial:0}),this.add(this.completedCount,{name:"completedCount"}),this.addDisposer(_(this.completedCount));let U=Math.max(1,R(t.maxPerPump??Z,"job flow maxPerPump"));for(let o=0;o<this._stageNames.length;o+=1){let a=this._stageNames[o],d=this.queue(a),j=o+1<this._stageNames.length?this.queue(this._stageNames[o+1]):null,S=this._stageWorkFns.get(a),M=u.get(a)??U,A=j===null;if(S){let h=P([d.pending],()=>{let l=0;for(;l<M;){let g=d.claim(1);if(g.length===0)break;let r=g[0];if(!r)break;let q=[...r.metadata.job_flow_path??[],a],b;try{b=S(r)}catch{d.nack(r.id,{requeue:!1}),l+=1;continue}let k=Q(b),E=!1,m;m=k.subscribe(X=>{if(!E){for(let J of X)if(J[0]===x){E=!0,m?m():Promise.resolve().then(()=>m?.());let O=J[1],$={...r.metadata,job_flow_path:q};if(A){let H={...r,payload:O,metadata:Object.freeze($)};f(()=>{d.ack(r.id),this._completed.append(H)})}else f(()=>{d.ack(r.id),j.enqueue(O,{metadata:$})});return}else if(J[0]===C){E=!0,m?m():Promise.resolve().then(()=>m?.()),d.nack(r.id,{requeue:!1});return}}}),l+=1}},{name:`pump_${a}`,describeKind:"effect",meta:T("job_flow_pump",{stage:a,has_work:!0})});this.add(h,{name:`pump_${a}`}),this.addDisposer(_(h))}else{let h=P([d.pending],()=>{let l=0;for(;l<M;){let g=d.claim(1);if(g.length===0)break;let r=g[0];if(!r)break;let q=[...r.metadata.job_flow_path??[],a],b={...r.metadata,job_flow_path:q};if(A){let k={...r,metadata:Object.freeze(b)};f(()=>{d.ack(r.id),this._completed.append(k)})}else f(()=>{d.ack(r.id),j.enqueue(r.payload,{metadata:b})});l+=1}},{name:`pump_${a}`,describeKind:"effect",meta:T("job_flow_pump",{stage:a,has_work:!1})});this.add(h,{name:`pump_${a}`}),this.addDisposer(_(h))}}}stages(){return this._stageNames}queue(e){let t=this._queues.get(e);if(!t)throw new Error(`jobFlow("${this.name}"): unknown stage "${e}"`);return t}enqueue(e,t={}){return this.queue(this._stageNames[0]).enqueue(e,t)}retainedCompleted(){return this.completed.cache}};function K(i,e){return new y(i,e)}function ne(i,e){let t=new w(i,e),{factory:s,factoryArgs:n,...p}=e??{};return t.tagFactory("jobFlow",D(p)),t}export{te as a,y as b,w as c,K as d,ne as e,oe as f};
@@ -1 +0,0 @@
1
- import{a as g}from"./chunk-5TEFC2ZX.js";import{a as c}from"./chunk-L6NSJVJZ.js";import{k as y}from"./chunk-POXANAJ6.js";import{C as d}from"./chunk-L77I47VU.js";import{G as h}from"./chunk-LYCLF26R.js";import{b as x}from"./chunk-QYADASLV.js";var E={};x(E,{computeHealthReport:()=>v,graphLens:()=>G,healthReportEqual:()=>w,watchTopologyTree:()=>g});function v(t){let o=[];for(let[e,r]of Object.entries(t.nodes)){if(r.status!=="errored")continue;let s={path:e,status:"errored"},n=y(t,e,"upstream",{});for(let p of n)if(p!==e&&t.nodes[p]?.status==="errored"){s.upstreamCause=p;break}o.push(s)}return o.sort((e,r)=>e.path<r.path?-1:e.path>r.path?1:0),{ok:o.length===0,problems:o}}function w(t,o){if(t.ok!==o.ok||t.problems.length!==o.problems.length)return!1;for(let e=0;e<t.problems.length;e++){let r=t.problems[e],s=o.problems[e];if(r.path!==s.path||r.status!==s.status||r.upstreamCause!==s.upstreamCause)return!1}return!0}function G(t){let o=t.describe({reactive:!0,detail:"standard",reactiveName:"graphLens.topology"}),e=o.node,r=h([e],([u])=>v(u),{name:"graphLens.health",describeKind:"derived",equals:w,meta:c("lens","health")}),s=d(r),n=new Map,p=-1,H=t.observe({reactive:!0,tiers:["data"]}),f=h([H,e],([u,R])=>{let l=u,b=R;if(l!=null&&l.flushedAt_ns>p){p=l.flushedAt_ns;for(let i of l.events){if(i.type!=="data")continue;let a=i.path;if(a==null||a==="")continue;let k=n.get(a);n.set(a,{path:a,count:(k?.count??0)+1,lastUpdate_ns:l.flushedAt_ns})}}if(b!=null&&n.size>0){let i=new Set(Object.keys(b.nodes));for(let a of[...n.keys()])i.has(a)||n.delete(a)}return new Map(n)},{name:"graphLens.flow",describeKind:"derived",meta:c("lens","flow")}),O=d(f),m=!1;return{topology:e,health:r,flow:f,dispose(){m||(m=!0,O(),s(),o.dispose())}}}export{v as a,w as b,G as c,E as d};
@@ -1 +0,0 @@
1
- import{a as V,b as N,c as _,d as j,f as L,g as M}from"./chunk-3G5U5QNE.js";import{b as D,c as x,d as $,e as R,f as A,g as S,h as T,i as y,j as F,k as P}from"./chunk-POXANAJ6.js";import{a as m,b as g,c as v,d as O,e as k,f as E,g as G,h as C}from"./chunk-LYCLF26R.js";import{b as u}from"./chunk-CK2E7BTU.js";import{b as W}from"./chunk-QYADASLV.js";var K={};W(K,{ENVELOPE_VERSION:()=>O,GRAPH_META_SEGMENT:()=>S,Graph:()=>y,JsonCodec:()=>m,SIZEOF_OVERHEAD:()=>x,SIZEOF_SYMBOL:()=>$,SNAPSHOT_VERSION:()=>T,createDagCborCodec:()=>g,createDagCborZstdCodec:()=>v,decodeEnvelope:()=>E,diffForWAL:()=>F,encodeEnvelope:()=>k,explainPath:()=>D,graphProfile:()=>A,reachable:()=>P,registerBuiltinCodecs:()=>G,replayWAL:()=>C,sizeof:()=>R,validateGraphObservability:()=>I,watchTopologyTree:()=>w});function w(s,n){let o=new Map,d=(i,p)=>{if(o.has(i))return;let c={off:()=>{},prefix:p};o.set(i,c);let f=i.topology.subscribe(l=>{for(let r of l){if(r[0]!==u)continue;let e=r[1];if(n(e,i,p),e.kind==="added"&&e.nodeKind==="mount"){let t=i._mounts.get(e.name);if(t instanceof y){let a=`${p}${e.name}::`;d(t,a)}}else if(e.kind==="removed"&&e.nodeKind==="mount"){let t=`${p}${e.name}::`;for(let[a,h]of Array.from(o.entries()))a!==s&&h.prefix.startsWith(t)&&(h.off(),o.delete(a))}}});c.off=f;for(let[l,r]of i._mounts)if(r instanceof y){let e=`${p}${l}::`;d(r,e)}};return d(s,""),()=>{for(let i of o.values())i.off();o.clear()}}var H={json:s=>_(s),pretty:s=>M(s),mermaid:s=>j(s),"mermaid-url":s=>L(s),d2:s=>N(s),ascii:s=>V(s)};function I(s,n={}){let o=[],d=n.requireFound??!0;if(n.skipDescribe!==!0)try{let r=s.describe(),e=new Set(Object.keys(r.nodes)),t=[];for(let[a,h]of Object.entries(r.nodes))for(let b of h.deps)b!==""&&!e.has(b)&&t.push(`${a} \u2192 ${b}`);for(let a of r.edges)e.has(a.from)||t.push(`edge.from: ${a.from}`),e.has(a.to)||t.push(`edge.to: ${a.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)}`})}if((n.formats?.length??0)>0){let r=s.describe();for(let e of n.formats)try{let t=H[e](r);typeof t!="string"||t.length===0?o.push({kind:"describe-format",ok:!1,format:e,reason:`${e} renderer returned empty or non-string output`}):o.push({kind:"describe-format",ok:!0,format:e,length:t.length})}catch(t){o.push({kind:"describe-format",ok:!1,format:e,reason:t instanceof Error?t.message:String(t)})}}for(let r of n.paths??[])try{s.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 n.pairs??[])try{let t=s.explain(r,e);d&&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 i=o.filter(r=>!r.ok),p=i.length===0,c=n.paths?.length??0,f=n.pairs?.length??0,l=n.formats?.length??0;return{ok:p,checks:o,failures:i,summary(){let r=[n.skipDescribe===!0?null:"describe",l>0?`${l} format${l===1?"":"s"}`:null,c>0?`${c} observe path${c===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 p?`validateGraphObservability: OK (${e})`:`validateGraphObservability: ${i.length} failure(s) across ${e}`}}}export{w as a,I as b,K as c};
@@ -1 +0,0 @@
1
- import{a as h,b as O,d as g,e as S,h as L,i as B,k as C,l as R}from"./chunk-4MKL6Q3K.js";import{a as n}from"./chunk-L6NSJVJZ.js";import{i as w}from"./chunk-POXANAJ6.js";import{x as u}from"./chunk-AK5RHMC5.js";import{a as m,b as T}from"./chunk-4VVTGLXJ.js";import{b as k,c as N}from"./chunk-35JTVPOX.js";import{b as V}from"./chunk-QYADASLV.js";var F={};V(F,{NS_PER_MS:()=>m,NS_PER_SEC:()=>T,ResilientPipelineGraph:()=>l,factoryTag:()=>N,placeholderArgs:()=>k,resilientPipeline:()=>E});function d(o){return typeof o=="object"&&o!==null&&"subscribe"in o&&"down"in o}function x(o){if(o<=0)throw new RangeError("timeoutMs must be > 0");if(o>9e6)throw new RangeError("timeoutMs must be <= 9_000_000 (\u22482.5h) to stay within safe ns arithmetic")}var l=class extends w{output;status;lastError;breakerState;droppedCount;rateLimitState;constructor(s,t={}){super(t.name??"resilient_pipeline",t.graph);let e=s,p,c,f;if(t.rateLimit!=null)if(d(t.rateLimit)){let a=e,r=t.rateLimit;e=u(r,i=>{let y={...i,maxBuffer:i.maxBuffer??1/0,meta:n("resilient","rate-limit")};return L(a,y).node}),this.add(e,{name:"rateLimited"})}else{let a={...t.rateLimit,maxBuffer:t.rateLimit.maxBuffer??1/0,meta:n("resilient","rate-limit")},r=L(e,a);e=r.node,p=r.droppedCount,c=r.rateLimitState,this.add(e,{name:"rateLimited"}),this.add(p,{name:"droppedCount"}),this.add(c,{name:"rateLimitState"})}if(t.budget!=null)if(d(t.budget)){let a=e,r=t.budget;e=u(r,i=>i.length>0?h(a,i,{meta:n("resilient","budget")}):a),this.add(e,{name:"budgetGated"})}else t.budget.length>0&&(e=h(e,t.budget,{meta:n("resilient","budget")}),this.add(e,{name:"budgetGated"}));if(t.breaker!=null)if(d(t.breaker)){let a=e,r=t.breaker,i=t.breakerOnOpen??"skip";e=u(r,y=>{let M=g(y);return S(M,{onOpen:i,meta:n("resilient","breaker")})(a).node}),this.add(e,{name:"breakerWrapped"})}else{let a=g(t.breaker),r=t.breakerOnOpen??"skip",i=S(a,{onOpen:r,meta:n("resilient","breaker")})(e);e=i.node,f=i.breakerState,this.add(e,{name:"breakerWrapped"}),this.add(f,{name:"breakerState"})}if(t.timeoutMs!=null)if(d(t.timeoutMs)){let a=e,r=t.timeoutMs;e=u(r,i=>(x(i),R(a,i*1e6,{meta:n("resilient","timeout")}))),this.add(e,{name:"timeoutWrapped"})}else x(t.timeoutMs),e=R(e,t.timeoutMs*1e6,{meta:n("resilient","timeout")}),this.add(e,{name:"timeoutWrapped"});if(t.retry!=null)if(d(t.retry)){let a=e,r=t.retry;e=u(r,i=>O(a,{...i,meta:n("resilient","retry")})),this.add(e,{name:"retryWrapped"})}else e=O(e,{...t.retry,meta:n("resilient","retry")}),this.add(e,{name:"retryWrapped"});t.fallback!==void 0&&(e=C(e,t.fallback,{meta:n("resilient","fallback")}),this.add(e,{name:"fallbackWrapped"}));let b=B(e,{initialStatus:t.initialStatus??"pending",meta:n("resilient","status")});this.output=b.node,this.status=b.status,this.lastError=b.error,this.breakerState=f,this.droppedCount=p,this.rateLimitState=c,this.add(this.output,{name:"output"}),this.add(this.status,{name:"status"}),this.add(this.lastError,{name:"lastError"})}};function E(o,s={}){let t=new l(o,s);return t.tagFactory("resilientPipeline",k(s)),t}export{l as a,E as b,F as c};
@@ -1 +0,0 @@
1
- import{a as q}from"./chunk-URJ2VFNC.js";import{a as K}from"./chunk-5TEFC2ZX.js";import{a as M}from"./chunk-L6NSJVJZ.js";import{b as z}from"./chunk-TT4C7DXW.js";import{i as S}from"./chunk-POXANAJ6.js";import{C as x}from"./chunk-L77I47VU.js";import{b as L}from"./chunk-35JTVPOX.js";import{C as j,E as V,G as T,m as $,o as v,p as R,u as N,w as C}from"./chunk-LYCLF26R.js";import{b as k}from"./chunk-CK2E7BTU.js";import{b as B}from"./chunk-QYADASLV.js";var tt={};B(tt,{AuditTrailGraph:()=>D,PolicyGateGraph:()=>E,auditTrail:()=>J,complianceSnapshot:()=>W,policyGate:()=>Q});function U(i,t){return M("audit",i,t)}var H=new Set(["data","error","complete","teardown"]),D=class extends S{entries;count;_log;_target;constructor(t,n){super(n.name??`${t.name}_audit`,n.graph),this._target=t,this._log=z([],{name:"entries",...n.maxSize!=null?{maxSize:n.maxSize}:{}}),this.entries=this._log.entries,this.add(this.entries,{name:"entries"}),this.count=T([this.entries],([d])=>d.length,{name:"count",describeKind:"derived",meta:U("count")}),this.add(this.count,{name:"count"}),this.addDisposer(x(this.count));let e=n.includeTypes!=null?new Set(n.includeTypes):H,p=n.filter,r=0,_=t.observe({timeline:!0,structured:!0}),m=_.onEvent(d=>{if(d.type==="derived")return;let u=d.type;if(!e.has(u))return;let b=d.path??"",w={seq:r++,timestamp_ns:d.timestamp_ns??v(),wall_clock_ns:R(),path:b,type:u},P=(b?O(t,b):void 0)?.lastMutation;P!=null&&(w.actor=P.actor),u==="data"&&(w.value=d.data),u==="error"&&(w.error=d.data);let o=b?Y(t,b):void 0;o!=null&&(w.annotation=o),!(p!=null&&!p(w))&&this._log.append(w)});this.addDisposer(()=>{m(),_.dispose()}),this.addDisposer(()=>this._log.disposeAllViews())}all(){return this.entries.cache??[]}byNode(t){return this.all().filter(n=>n.path===t)}byActor(t){return this.all().filter(n=>n.actor?.id===t)}byActorType(t){return this.all().filter(n=>n.actor?.type===t)}byTimeRange(t,n){return this.all().filter(e=>!(e.timestamp_ns<t||n!=null&&e.timestamp_ns>=n))}get target(){return this._target}};function J(i,t={}){return new D(i,t)}var E=class extends S{policies;violations;violationCount;_target;_mode;_currentGuard;constructor(t,n,e){super(e.name??`${t.name}_policy`,e.graph),this._target=t,this._mode=e.mode??"audit";let p=F(n)?n:V(n,{name:"policies"});this.policies=p,this.add(this.policies,{name:"policies"}),this.violations=new q("violations",{retainedLimit:e.violationsLimit??1e3}),this.mount("violations",this.violations),this.violationCount=T([this.violations.events],([o])=>o.length,{name:"violationCount",describeKind:"derived",meta:U("policy_violation_count")}),this.add(this.violationCount,{name:"violationCount"}),this.addDisposer(x(this.violationCount));let _=p.cache??[];this._currentGuard=N(_);let m=p.subscribe(o=>{for(let g of o)g[0]===k&&(_=g[1]??[],this._currentGuard=N(_))});this.addDisposer(m);let d=e.paths,u=F(d)?d:void 0,b=d!=null,A=u!=null?u.cache??[]:b?[...d]:void 0,P=A??I(t);if(this._mode!=="enforce"&&u!=null){let o=u.subscribe(g=>{for(let a of g)a[0]===k&&(A=a[1]??[])});this.addDisposer(o)}if(this._mode==="enforce"){let o=new Map,g=a=>{if(o.has(a))return;let s=O(t,a);if(!(s instanceof j))return;let f=(l,c)=>{let h=this._currentGuard(l,c);return h||this._publishViolation(l,c,a,"blocked"),h};o.set(a,s._pushGuard(f))};for(let a of P)g(a);if(u!=null){let a=u.subscribe(s=>{for(let f of s){if(f[0]!==k)continue;let l=f[1]??[],c=new Set(l),h=new Set(A??[]);$(()=>{for(let y of h){if(c.has(y))continue;let G=o.get(y);G!=null&&(G(),o.delete(y))}for(let y of c)h.has(y)||g(y);A=l})}});this.addDisposer(a)}if(b){let a=t.topology.subscribe(s=>{for(let f of s){if(f[0]!==k)continue;let l=f[1];if(l.kind!=="removed"||l.nodeKind!=="node")continue;let c=o.get(l.name);c!=null&&(c(),o.delete(l.name))}});this.addDisposer(a)}else{let a=K(t,(s,f,l)=>{if(s.kind==="added")if(s.nodeKind==="node")g(`${l}${s.name}`);else{let c=f._mounts.get(s.name);if(!(c instanceof S))return;let h=`${l}${s.name}::`,y=I(c);for(let G of y)g(G===""?`${l}${s.name}`:`${h}${G}`)}else if(s.kind==="removed")if(s.nodeKind==="node"){let c=`${l}${s.name}`,h=o.get(c);h!=null&&(h(),o.delete(c))}else{let c=`${l}${s.name}`,h=`${c}::`;for(let[y,G]of o)(y===c||y.startsWith(h))&&(G(),o.delete(y))}});this.addDisposer(a)}this.addDisposer(()=>{for(let a of o.values())a();o.clear()})}else{let o=t.observe({timeline:!0,structured:!0}),g=o.onEvent(a=>{if(a.type!=="data"&&a.type!=="error")return;let s=a.path??"";if(!s||A!=null&&!A.includes(s))return;let f=a.actor??O(t,s)?.lastMutation?.actor;if(f==null)return;let l="write";this._currentGuard(f,l)||this._publishViolation(f,l,s,"observed")});this.addDisposer(()=>{g(),o.dispose()})}}_publishViolation(t,n,e,p){this.violations.publish({timestamp_ns:v(),wall_clock_ns:R(),path:e,actor:t,action:n,mode:this._mode,result:p})}all(){return this.violations.retained()}get mode(){return this._mode}get target(){return this._target}};function Q(i,t,n={}){let e=new E(i,t,n);return e.tagFactory("policyGate",L(n)),e}function W(i,t={}){let n={format_version:1,timestamp_ns:v(),wall_clock_ns:R(),graph:i.snapshot()};if(t.actor!=null&&(n.actor=t.actor),t.audit!=null){let p=[...t.audit.all()];n.audit={count:p.length,entries:p}}if(t.policies!=null){let p=t.policies.policies.cache??[];n.policies={mode:t.policies.mode,rules:p,violations:[...t.policies.all()]}}let e=X(n);return{...n,fingerprint:e}}function F(i){return typeof i=="object"&&i!==null&&"subscribe"in i}function O(i,t){try{return i.node(t)}catch{return}}function Y(i,t){try{return i.annotation(t)}catch{return}}function I(i){let t=i.describe({detail:"minimal"});return Object.keys(t.nodes)}function X(i){return C(JSON.stringify(Z(i)))}function Z(i){let t=new Set,n=e=>{if(e===void 0)return{__undefined:!0};if(e===null)return null;let p=typeof e;if(p==="bigint")return{__bigint:e.toString()};if(p!=="object")return e;let r=e;if(t.has(r))return{__circular:!0};t.add(r);try{if(Array.isArray(r))return r.map(n);if(r instanceof Date)return{__date:r.toISOString()};if(r instanceof RegExp)return{__regexp:{source:r.source,flags:r.flags}};if(r instanceof Map)return{__map:[...r.entries()].map(([d,u])=>[n(d),n(u)])};if(r instanceof Set)return{__set:[...r].map(n)};if(ArrayBuffer.isView(r)){let m=r,d=new Array(m.length);for(let u=0;u<m.length;u++)d[u]=m[u]??0;return{__typed_array:{ctor:r.constructor.name,data:d}}}let _={};for(let m of Object.keys(r).sort())_[m]=n(r[m]);return _}finally{t.delete(r)}};return n(i)}export{D as a,J as b,E as c,Q as d,W as e,tt as f};
@@ -1,3 +0,0 @@
1
- import{g as he}from"./chunk-URJ2VFNC.js";import{i as fe}from"./chunk-POXANAJ6.js";import{x as ye}from"./chunk-AK5RHMC5.js";import{D as be,E as T,G as v,H as q,m as ee,o as z}from"./chunk-LYCLF26R.js";import{b as P,j as Z}from"./chunk-CK2E7BTU.js";import{b as Ne}from"./chunk-QYADASLV.js";var we={};Ne(we,{blindVariation:()=>De,errorCritique:()=>Re,refineLoop:()=>Se});function Ie(n){if(typeof n!="object"||n===null)return!1;let l=n;return typeof l.subscribe=="function"&&typeof l.down=="function"&&typeof l.emit=="function"}function pe(n,l){if(n.length===0)return{best:null,bestScore:Number.NEGATIVE_INFINITY};if(n.length===1){let e=ne(l);return{best:n[0],bestScore:e}}if(l.some(e=>typeof e.candidateIndex=="number")){let e=new Array(n.length);for(let i=0;i<n.length;i++)e[i]={sum:0,count:0};for(let i of l){let d=i.candidateIndex;typeof d=="number"&&d>=0&&d<n.length&&(e[d].sum+=i.score,e[d].count+=1)}let s=n[0],o=e[0].count>0?e[0].sum/e[0].count:Number.NEGATIVE_INFINITY;for(let i=1;i<n.length;i++){let d=e[i].count>0?e[i].sum/e[i].count:Number.NEGATIVE_INFINITY;d>o&&(o=d,s=n[i])}return{best:s,bestScore:o}}let t=n[0],m=l[0]?.score??Number.NEGATIVE_INFINITY;for(let e=1;e<n.length;e++){let s=l[e]?.score??Number.NEGATIVE_INFINITY;s>m&&(m=s,t=n[e])}return{best:t,bestScore:m}}function ne(n){if(n.length===0)return Number.NEGATIVE_INFINITY;let l=0;for(let x of n)l+=x.score;return l/n.length}function Se(n,l,x,t){let m=t.name??"refine-loop",e=new fe(m,t.graph),s=Ie(t.dataset)?t.dataset:T(t.dataset,{name:"dataset"});e.add(s,{name:"dataset"});let o=T(0,{name:"iteration"});e.add(o,{name:"iteration"});let i=T(x,{name:"strategy",equals:()=>!1});e.add(i,{name:"strategy"});let d=T(null,{name:"lastFeedback"});e.add(d,{name:"lastFeedback"});let k=T([],{name:"prevCandidates"});e.add(k,{name:"prevCandidates"});let y=T(!1,{name:"paused"});e.add(y,{name:"paused"});let b=T("running",{name:"status"});e.add(b,{name:"status"});let E=T([],{name:"history",equals:()=>!1});e.add(E,{name:"history"});let h=T(null,{name:"best"});e.add(h,{name:"best"});let N=T(Number.NEGATIVE_INFINITY,{name:"score"});e.add(N,{name:"score"});let C=T(0,{name:"budget-used"});e.add(C,{name:"budget-used"});let R=he("stages");e.mount("stages",R);let A=R.topic("generate"),p=R.topic("evaluate"),G=R.topic("analyze"),te=R.topic("decide"),$=x,B=null,re=[];e.addDisposer(i.subscribe(r=>{for(let a of r)a[0]===P&&($=a[1])})),e.addDisposer(d.subscribe(r=>{for(let a of r)a[0]===P&&(B=a[1])})),e.addDisposer(k.subscribe(r=>{for(let a of r)a[0]===P&&(re=a[1])}));let I=ye(o,r=>{let a=$,c=r===0||B==null;return be([],(u,f)=>{let S=!1;try{let D=c?a.seed(n):a.generate(B,re);if(D instanceof Promise)return D.then(_=>{S||f.emit(_)},_=>{S||f.down([[Z,_]])}),()=>{S=!0};f.emit(D)}catch(D){S=!0,f.down([[Z,D]])}},{describeKind:"producer"})},{name:"candidates"});e.add(I,{name:"candidates"});let ae=q([I],(r,a,c)=>{let u=c.terminalDeps[0];u!==void 0&&u!==!0&&b.emit("errored")},{name:"error-watcher",errorWhenDepsError:!1});e.add(ae,{name:"error-watcher"}),e.addDisposer(ae.subscribe(()=>{}));let Y=v([I,o],([r,a])=>({iteration:a,candidates:r,timestamp_ns:z()}),{name:"generate-event"});e.add(Y,{name:"generate-event"}),e.addDisposer(Y.subscribe(()=>{}));let oe=q([Y],([r])=>{A.publish(r)},{name:"generate-publish"});e.add(oe,{name:"generate-publish"}),e.addDisposer(oe.subscribe(()=>{}));let ie=q([I],([r])=>{k.emit(r)},{name:"generate-mirror"});e.add(ie,{name:"generate-mirror"}),e.addDisposer(ie.subscribe(()=>{}));let V=l(I,s);e.add(V,{name:"scores"});let j=v([V,I,o],([r,a,c])=>({iteration:c,candidates:a,scores:r,timestamp_ns:z()}),{name:"evaluate-event"});e.add(j,{name:"evaluate-event"}),e.addDisposer(j.subscribe(()=>{}));let se=q([j],([r])=>{p.publish(r)},{name:"evaluate-publish"});e.add(se,{name:"evaluate-publish"}),e.addDisposer(se.subscribe(()=>{}));let L=v([V,I],([r,a])=>$.analyze(r,a),{name:"feedback"});e.add(L,{name:"feedback"});let M=v([L,I,o],([r,a,c])=>({iteration:c,candidates:a,feedback:r,timestamp_ns:z()}),{name:"analyze-event"});e.add(M,{name:"analyze-event"}),e.addDisposer(M.subscribe(()=>{}));let de=q([M],([r])=>{G.publish(r)},{name:"analyze-publish"});e.add(de,{name:"analyze-publish"}),e.addDisposer(de.subscribe(()=>{}));let H=v([E],([r])=>{let a=r;if(t.patience==null||a.length<=t.patience)return!1;let c=a.slice(-(t.patience+1)),u=c[0].bestScore;return c.slice(1).every(f=>f.bestScore<=u)},{name:"patience-check"});e.add(H,{name:"patience-check"});let W=v([N],([r])=>t.minScore!=null&&r>=t.minScore,{name:"min-score-check"});e.add(W,{name:"min-score-check"});let K=v([E],([r])=>{let a=r;if(t.minDelta==null||a.length<2)return!1;let c=a[a.length-2].bestScore,u=a[a.length-1].bestScore;return Math.abs(u-c)<t.minDelta},{name:"min-delta-check"});e.add(K,{name:"min-delta-check"});let U=v([C],([r])=>t.maxEvaluations!=null&&r>=t.maxEvaluations,{name:"max-evaluations-check"});e.add(U,{name:"max-evaluations-check"});let J=v([o],([r])=>t.maxIterations!=null&&r>=t.maxIterations,{name:"max-iterations-check"});e.add(J,{name:"max-iterations-check"});let le=v([C],([r])=>t.budget!=null&&r>=t.budget,{name:"budget-exhausted-check"});e.add(le,{name:"budget-exhausted-check"}),e.addDisposer(H.subscribe(()=>{})),e.addDisposer(W.subscribe(()=>{})),e.addDisposer(K.subscribe(()=>{})),e.addDisposer(U.subscribe(()=>{})),e.addDisposer(J.subscribe(()=>{})),e.addDisposer(le.subscribe(()=>{}));let ce=v([H,W,K,U,J],([r,a,c,u,f])=>r?{converged:!0,reason:"patience"}:a?{converged:!0,reason:"min-score"}:c?{converged:!0,reason:"min-delta"}:u?{converged:!0,reason:"max-evaluations"}:f?{converged:!0,reason:"max-iterations"}:{converged:!1},{name:"converged"});e.add(ce,{name:"converged"}),e.addDisposer(ce.subscribe(()=>{}));let ue=-1,me=q([L,V,I],([r,a,c])=>{let u=o.cache,f=r,S=c,D=a;if(u<=ue)return;ue=u;let{best:_,bestScore:ge}=pe(S,D),Te=E.cache,ve={n:u,candidates:S,scores:D,feedback:f,best:_,bestScore:ge,timestamp_ns:z()},F=[...Te,ve],Q=C.cache+S.length,g="continue",w,Ee=t.budget!=null&&Q>=t.budget,ke=y.cache;if(Ee)g="budget",w="budget";else if(t.minScore!=null&&f.score>=t.minScore)g="converged",w="min-score";else if(t.maxIterations!=null&&u>=t.maxIterations)g="converged",w="max-iterations";else if(t.maxEvaluations!=null&&Q>=t.maxEvaluations)g="converged",w="max-evaluations";else if(t.minDelta!=null&&F.length>=2){let O=F[F.length-2].bestScore,X=F[F.length-1].bestScore;Math.abs(X-O)<t.minDelta&&(g="converged",w="min-delta")}else if(t.patience!=null&&F.length>t.patience){let O=F.slice(-(t.patience+1)),X=O[0].bestScore;O.slice(1).every(xe=>xe.bestScore<=X)&&(g="converged",w="patience")}g==="continue"&&ke&&(g="paused"),ee(()=>{h.emit(_),N.emit(f.score),E.emit(F),C.emit(Q),d.emit(f),te.publish({iteration:u,decision:g,reason:w,timestamp_ns:z()}),g==="continue"?o.emit(u+1):b.emit(g==="converged"?"converged":g==="budget"?"budget":"paused")})},{name:"decide-bridge"});return e.add(me,{name:"decide-bridge"}),e.addDisposer(me.subscribe(()=>{})),Object.assign(e,{best:h,score:N,status:b,history:E,strategy:i,iteration:o,generate:A,evaluate:p,analyze:G,decide:te,setStrategy(r){i.emit(r)},pause(){y.emit(!0)},resume(){b.cache==="paused"&&ee(()=>{y.emit(!1),b.emit("running"),o.emit(o.cache+1)})}})}function De(n){let l=n.width??4;return{name:n.name??"blindVariation",seed(t){return[t]},analyze(t,m){let e=ne(t),s=null;for(let o of t)(!s||o.score<s.score)&&(s=o);return{summary:`blindVariation iteration: mean=${e.toFixed(3)}, n=${t.length}`,score:e,weakTasks:s?[s.taskId]:[]}},async generate(t,m){if(m.length===0)throw new Error("blindVariation.generate: empty candidate batch \u2014 cannot derive prior for teacher");let e=m[m.length-1],s=0,i={prior:e,reportCost:d=>{s+=d}};try{if(n.parallel!==!1)return await Promise.all(Array.from({length:l},()=>n.teacher(i)));let d=[];for(let k=0;k<l;k++)d.push(await n.teacher(i));return d}finally{if(n.tokens!=null&&s>0){let d=n.tokens.cache??0;n.tokens.emit(d+s)}}}}}function Fe(n){return typeof n=="object"&&n!==null&&n.kind==="errorCritique"}function Ce(n,l){return n.length===0?`No task scored below the batch mean (${l.score.toFixed(3)}). Reinforce the current direction.`:`Failures below threshold:
2
- ${n.map(t=>{let m=t.error!=null?` | error: ${t.error}`:"";return`- ${t.taskId} (score=${t.score.toFixed(3)})${m}`}).join(`
3
- `)}`}function Re(n){let l=n.width??4,x=n.name??"errorCritique",t=n.maxFailureSamples??5,m=n.formatCritique??Ce;return{name:x,seed(e){return[e]},analyze(e,s){let o=ne(e),i=typeof n.failureThreshold=="function"?n.failureThreshold(e):n.failureThreshold,d=i===void 0&&!Number.isFinite(o),k=i??o,y=d?[...e].sort((p,G)=>p.score-G.score):e.filter(p=>p.score<k).slice().sort((p,G)=>p.score-G.score),b=y.slice(0,t),{best:E,bestScore:h}=pe(s,e),N={summary:"",score:o,weakTasks:b.map(p=>p.taskId)},C=m(b,N),R={kind:"errorCritique",best:E,failures:b,critiqueText:C},A=y.length>b.length?` (top ${b.length} retained)`:"";return{summary:`errorCritique iteration: mean=${o.toFixed(3)}, failures=${y.length}${A}/${e.length}, bestScore=${h.toFixed(3)}`,critique:R,weakTasks:b.map(p=>p.taskId),score:o}},async generate(e,s){if(s.length===0)throw new Error("errorCritique.generate: empty candidate batch \u2014 cannot derive prior for teacher");let o=Fe(e.critique)?e.critique:void 0,i=o!==void 0?o.best:s[s.length-1],d=o?.critiqueText??e.summary,k=o?.failures??[],y=0,E={prior:i,critique:d,failures:k,reportCost:h=>{y+=h}};try{if(n.parallel!==!1)return await Promise.all(Array.from({length:l},()=>n.teacher(E)));let h=[];for(let N=0;N<l;N++)h.push(await n.teacher(E));return h}finally{if(n.tokens!=null&&y>0){let h=n.tokens.cache??0;n.tokens.emit(h+y)}}}}}export{Se as a,De as b,Re as c,we as d};
@@ -1 +0,0 @@
1
- import{c as M,h as oe,i as ae}from"./chunk-VXPLLA4P.js";import{a as ne}from"./chunk-L6NSJVJZ.js";import{b as J}from"./chunk-TT4C7DXW.js";import{i as se}from"./chunk-POXANAJ6.js";import{C as z}from"./chunk-L77I47VU.js";import{b as re}from"./chunk-35JTVPOX.js";import{D as ee,E as te,G as j,m as Y,p as R,t as D}from"./chunk-LYCLF26R.js";import{b as X}from"./chunk-CK2E7BTU.js";import{b as ce}from"./chunk-QYADASLV.js";var me={};ce(me,{CqrsGraph:()=>G,cqrs:()=>fe,cqrsEventKeyOf:()=>pe,dispatchKeyOf:()=>he,sagaInvocationKeyOf:()=>ve});var k=class extends Error{constructor(e,n){super(e,n),this.name=this.constructor.name}},B=class extends k{constructor(n,t){super(`Duplicate ${n} registration: "${t}"`);this.kind=n;this.registrationName=t}},N=class extends k{constructor(n,t,r){super(`Command "${n}" emitted undeclared event "${t}". Declared emits: [${r.join(", ")}]`);this.commandName=n;this.eventName=t;this.declaredEmits=r}},K=class extends k{constructor(n,t,r){super(`Optimistic concurrency conflict on aggregate "${n}": expected version ${t}, got ${r}`);this.aggregateId=n;this.expected=t;this.actual=r}},H=class extends k{constructor(n){super(`Unknown command: "${n}". Register with command() first.`);this.commandName=n}},O=class extends k{constructor(n,t){super(`Command handler "${n}" threw: ${t instanceof Error?t.message:String(t)}`,{cause:t});this.commandName=n}};var P=class extends k{constructor(n,t){super(`Projection "${n}" rebuild failed: ${t instanceof Error?t.message:String(t)}`,{cause:t});this.projectionName=n}};var le=D((o,e)=>{o("write"),o("signal"),e("observe")}),ue=D((o,e)=>{o("observe"),o("signal"),e("write")}),ie=D((o,e)=>{o("observe"),o("signal"),e("write")});function $(o,e){return ne("cqrs",o,e)}function Z(o){if(o===null||typeof o!="object"||Object.isFrozen(o))return o;for(let e of Object.keys(o))Z(o[e]);return Object.freeze(o)}var pe=o=>`${o.type}::${o.aggregateId??"__default__"}`,he=o=>o.commandName,ve=o=>o.eventType,G=class extends se{_eventLogs=new Map;_eventLogsByAggregate=new Map;_aggregateVersions=new Map;_aggregateLru=new Map;_commandRegs=new Map;_projections=new Set;_sagas=new Set;_keepaliveDisposers=[];_seq=0;_retainedLimit;_freezeCommandPayload;_freezeEventPayload;_maxAggregates;_dispatchSeqCursor;dispatches;audit;aggregateEvictions;constructor(e,n={}){super(e,n.graph),this._retainedLimit=n.retainedLimit??1024,this._freezeCommandPayload=n.freezeCommandPayload??!0,this._freezeEventPayload=n.freezeEventPayload??!0,this._maxAggregates=n.maxAggregates??1e4,this.dispatches=M({name:"dispatches",retainedLimit:this._retainedLimit,graph:this}),this.audit=this.dispatches,this.aggregateEvictions=M({name:"aggregateEvictions",retainedLimit:this._retainedLimit,graph:this}),this._dispatchSeqCursor=oe(this,"dispatch_seq",0)}aggregateVersion(e,n){return this._aggregateVersions.get(`${e}::${n}`)??0}_touchAggregate(e){this._aggregateLru.delete(e),this._aggregateLru.set(e,!0)}_enforceAggregateLru(){for(;this._aggregateLru.size>this._maxAggregates;){let e=this._aggregateLru.keys().next();if(e.done)break;let n=e.value;this._aggregateLru.delete(n);let t=n.indexOf("::");if(t<0)continue;let r=n.slice(0,t),s=n.slice(t+2),a=this._aggregateVersions.get(n)??0;this._aggregateVersions.delete(n);let i=this._eventLogsByAggregate.get(r);i&&(i.delete(s),i.size===0&&this._eventLogsByAggregate.delete(r)),this.aggregateEvictions.append({aggregateId:s,type:r,lastVersion:a,t_ns:R()})}}destroy(){for(let e of this._keepaliveDisposers)e();this._keepaliveDisposers.length=0,super.destroy()}_attachedEventTiers=[];_attachedTierDisposers=new Map;attachEventStorage(e){this._attachedEventTiers.push(e);for(let[n,t]of this._eventLogs){let r=t.log.attachStorage(e),s=this._attachedTierDisposers.get(n);s||(s=[],this._attachedTierDisposers.set(n,s)),s.push(r)}for(let[n,t]of this._eventLogsByAggregate)for(let[r,s]of t){let a=`${n}::${r}`,i=s.log.attachStorage(e),c=this._attachedTierDisposers.get(a);c||(c=[],this._attachedTierDisposers.set(a,c)),c.push(i)}return()=>{let n=this._attachedEventTiers.indexOf(e);n>=0&&this._attachedEventTiers.splice(n,1)}}_autoWireStreamStorage(e,n){if(this._attachedEventTiers.length===0)return;let t=this._attachedTierDisposers.get(e);t||(t=[],this._attachedTierDisposers.set(e,t));for(let r of this._attachedEventTiers)t.push(n.attachStorage(r))}_bumpDispatchSeq(){let n=(this._dispatchSeqCursor.cache??0)+1;return this._dispatchSeqCursor.emit(n),n}event(e,n){if(n!==void 0)return this._ensureAggregateStream(e,n).node;let t=this._eventLogs.get(e);if(t)return t.node;let r=J([],{name:e,versioning:0,maxSize:this._retainedLimit});r.withLatest();let s=r.entries,a=j([s],([i])=>i,{name:e,describeKind:"state",meta:$("event",{event_name:e}),guard:ie,initial:s.cache});return this.add(a,{name:e}),this._keepaliveDisposers.push(z(a)),this._eventLogs.set(e,{log:r,node:a}),this._autoWireStreamStorage(e,r),a}_ensureAggregateStream(e,n){this._eventLogs.has(e)||this.event(e);let t=this._eventLogsByAggregate.get(e);t||(t=new Map,this._eventLogsByAggregate.set(e,t));let r=`${e}::${n}`;this._touchAggregate(r);let s=t.get(n);if(s)return s;let a=`${e}_${n.replace(/[^a-zA-Z0-9_-]/g,"_")}`,i=J([],{name:a,versioning:0,maxSize:this._retainedLimit});i.withLatest();let c=i.entries,h=j([c],([p])=>p,{name:a,describeKind:"state",meta:$("event_aggregate",{event_name:e,aggregate_id:n}),guard:ie,initial:c.cache}),l=a,m=0;for(;this.nameOf(this.resolveOptional(l)??h)===l&&(m+=1,l=`${a}_${m}`,this.resolveOptional(l)!==void 0););try{this.add(h,{name:l})}catch{}this._keepaliveDisposers.push(z(h));let u={log:i,node:h};return t.set(n,u),this._autoWireStreamStorage(`${e}::${n}`,i),this._enforceAggregateLru(),u}resolveOptional(e){try{return this.resolve(e)}catch{return}}_appendEvent(e,n,t){let r=this._eventLogs.get(e);if(r||(this.event(e),r=this._eventLogs.get(e)),r.node.status==="completed"||r.node.status==="errored")throw new Error(`Cannot dispatch to terminated event stream "${e}" (status: ${r.node.status}).`);let s,a;if(t?.aggregateId!==void 0){let l=`${e}::${t.aggregateId}`;s=(this._aggregateVersions.get(l)??0)+1,this._aggregateVersions.set(l,s),a=this._ensureAggregateStream(e,t.aggregateId)}let i=r.log.entries.v,c=this._freezeEventPayload?Z(n):n,h={type:e,payload:c,timestampNs:R(),seq:++this._seq,...t?.aggregateId!==void 0?{aggregateId:t.aggregateId}:{},...s!==void 0?{aggregateVersion:s}:{},...t?.correlationId!==void 0?{correlationId:t.correlationId}:{},...t?.causationId!==void 0?{causationId:t.causationId}:{},...t?.metadata!==void 0?{metadata:Object.freeze({...t.metadata})}:{},...t?.handlerVersion!==void 0?{handlerVersion:t.handlerVersion}:{},...i!=null?{v0:{id:i.id,version:i.version}}:{}};return r.log.append(h),a&&a.log.append(h),h}command(e,n){if(this._commandRegs.has(e))throw new B("command",e);let t=typeof n=="function"?{handler:n}:n,r=te(void 0,{name:e,describeKind:"state",meta:{...$("command",{command_name:e}),error:null},guard:le});if(this.add(r,{name:e}),this._commandRegs.set(e,{handler:t.handler,...t.emits!==void 0?{emits:t.emits}:{},...t.handlerVersion!==void 0?{handlerVersion:t.handlerVersion}:{}}),t.emits)for(let s of t.emits)this._eventLogs.has(s)||this.event(s);return r}dispatch(e,n,t){let r=this._commandRegs.get(e);if(!r)throw new H(e);if(t?.aggregateId!==void 0&&t.expectedAggregateVersion!==void 0&&r.emits!==void 0){let u=0;for(let p of r.emits){let _=this._aggregateVersions.get(`${p}::${t.aggregateId}`);_!==void 0&&_>u&&(u=_)}if(u!==t.expectedAggregateVersion)throw new K(t.aggregateId,t.expectedAggregateVersion,u)}let s=this.resolve(e),a=this._freezeCommandPayload?Z(n):n,i=[],c=R(),h=0,l,m=!1;try{Y(()=>{h=this._bumpDispatchSeq(),s.emit(a,{internal:!0});try{r.handler(a,{emit:(u,p)=>{if(r.emits!==void 0&&!r.emits.includes(u))throw new N(e,u,r.emits);i.push(u),this._appendEvent(u,p,{...t?.aggregateId!==void 0?{aggregateId:t.aggregateId}:{},...t?.correlationId!==void 0?{correlationId:t.correlationId}:{},...t?.causationId!==void 0?{causationId:t.causationId}:{},...t?.metadata!==void 0?{metadata:Object.freeze({...t.metadata})}:{},...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}})}}),s.meta.error.emit(null,{internal:!0}),this.dispatches.append({commandName:e,payload:a,outcome:"success",emittedEvents:[...i],t_ns:c,seq:h,...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}})}catch(u){throw l=u,m=!0,u}})}catch(u){if(m){s.meta.error.emit(l,{internal:!0});let p=l instanceof Error?l.name:typeof l,_=l instanceof O?l:new O(e,l);this.dispatches.append({commandName:e,payload:a,outcome:"failure",error:_,errorType:p,emittedEvents:[...i],t_ns:c,seq:h,...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}})}throw m?l:u}}projection(e){let{name:n,events:t,reducer:r,initial:s}=e,a=e.mode??"scan",i=e.freezeInputs??!0,c=e.snapshot,h=t.map(d=>(this._eventLogs.has(d)||this.event(d),this._eventLogs.get(d).node));function l(d){d.sort((g,v)=>g.timestampNs-v.timestampNs||g.seq-v.seq||(g.aggregateId??"").localeCompare(v.aggregateId??""))}function m(d){let g=[];for(let v of d)g.push(...v);return l(g),g}let u=h.map(d=>d.cache??[]),p=m(u),_=i?Object.freeze(p):p,C=0,y=s;a==="scan"&&p.length>0&&(y=r(s,_),C=p.length);let q=a==="replay"?r(s,_):y,V=c?.saveDebounceMs??1e3,A=c?.saveEvery??1e3,E,L=0;function F(d){if(c?.save){if(L+=1,L>=A){L=0,E!==void 0&&(clearTimeout(E),E=void 0);let g=c.save(d);g instanceof Promise&&g.catch(()=>{});return}E!==void 0&&clearTimeout(E),E=setTimeout(()=>{E=void 0,L=0;let g=c.save(d);g instanceof Promise&&g.catch(()=>{})},V)}}let S=j(h,d=>{let g=m(d),v;if(a==="replay"){let w=i?Object.freeze(g):g;v=r(s,w)}else{let w=g.slice(C);C=g.length;let f=i?Object.freeze(w):w;v=r(y,f),y=v}return F(v),v},{name:n,describeKind:"derived",meta:$("projection",{projection_name:n,source_events:t}),guard:ue,initial:q});return this.add(S,{name:n}),this._keepaliveDisposers.push(z(S)),this._keepaliveDisposers.push(()=>{E!==void 0&&(clearTimeout(E),E=void 0)}),this._projections.add(n),{node:S,rebuild:async d=>{try{let g=d?.pageSize??1e3,v=d?.fromTier??this._attachedEventTiers[0]?.[0],w=m(h.map(T=>T.cache??[])).length,f=s;if(c?.load){let T=await c.load();T!==void 0&&(f=T)}if(!v||!v.loadEntries){let T=m(h.map(I=>I.cache??[])),b=i?Object.freeze(T):T;f=r(f,b)}else{let T=new Set(t),b,I=!1;for(;!I;){let U=await v.loadEntries({cursor:b,pageSize:g}),W=[...U.entries].filter(ge=>T.has(ge.type));l(W);let de=i?Object.freeze(W):W;f=r(f,de),b=U.cursor,I=!b||U.entries.length===0}}if(a==="scan"){let T=m(h.map(I=>I.cache??[])),b=T.slice(w);if(b.length>0){let I=i?Object.freeze(b):b;f=r(f,I)}y=f,C=T.length}return S.emit(f,{internal:!0}),f}catch(g){throw new P(n,g)}},reset:async()=>{try{let d=s;if(c?.load){let f=await c.load();f!==void 0&&(d=f)}let g=m(h.map(f=>f.cache??[])),v=i?Object.freeze(g):g,w=r(d,v);return a==="scan"&&(y=w,C=g.length),S.emit(w,{internal:!0}),w}catch(d){throw new P(n,d)}}}}saga(e,n,t,r={}){let s=n.map(p=>(this._eventLogs.has(p)||this.event(p),this._eventLogs.get(p).node)),a=ae(this,`${e}_cursor`,n,0),i=M({name:`${e}_invocations`,retainedLimit:this._retainedLimit,graph:this}),c=r.aggregateId,h=r.errorPolicy??"advance",l=new Map;for(let p of n){let _=a[p];l.set(p,_.cache??0);let C=_.subscribe(y=>{for(let q of y)q[0]===X&&l.set(p,q[1])});this._keepaliveDisposers.push(C)}let m={},u=ee(s,(p,_)=>{let C=m.n.meta.error;for(let y=0;y<p.length;y++){let q=p[y];if(q==null||q.length===0)continue;let V=q.at(-1);if(!V)continue;let A=n[y],E=a[A],L=l.get(A)??0;if(V.length>L){let F=V.slice(L),S=L;for(let Q of F){let x=Q;if(c!==void 0&&x.aggregateId!==c){S+=1;continue}try{t(x),C.emit(null,{internal:!0}),i.append({eventType:A,outcome:"success",aggregateId:x.aggregateId,event:x,t_ns:R(),...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}}),S+=1}catch(d){if(C.emit(d,{internal:!0}),i.append({eventType:A,outcome:"failure",error:d,errorType:d instanceof Error?d.name:typeof d,aggregateId:x.aggregateId,event:x,t_ns:R(),...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}}),h==="hold")break;S+=1}}E.emit(S)}}},{name:e,describeKind:"effect",meta:{...$("saga",{saga_name:e,source_events:n}),error:null}});return m.n=u,this.add(u,{name:e}),this._keepaliveDisposers.push(z(u)),this._sagas.add(e),{node:u,invocations:i,audit:i,cursors:a}}};function fe(o,e){let n=new G(o,e),{factory:t,factoryArgs:r,...s}=e??{};return n.tagFactory("cqrs",re(s)),n}export{pe as a,he as b,ve as c,G as d,fe as e,me as f};
@@ -1 +0,0 @@
1
- import{c as O}from"./chunk-VXPLLA4P.js";import{f as B,m as K}from"./chunk-L77I47VU.js";import{p as b}from"./chunk-LYCLF26R.js";import{b as M,i as A,j as L}from"./chunk-CK2E7BTU.js";import{b as H}from"./chunk-QYADASLV.js";var Y={};H(Y,{processInstanceKeyOf:()=>J,processManager:()=>X});var J=i=>i.correlationId;function V(i){if(i==null)return Promise.resolve(void 0);let y=K(i);return new Promise((s,v)=>{let u=!1,f,r=()=>{f&&f()};f=y.subscribe(a=>{if(!u)for(let o of a){if(o[0]===M){u=!0,Promise.resolve().then(r),s(o[1]);return}if(o[0]===L){u=!0,Promise.resolve().then(r),v(o[1]);return}if(o[0]===A){u=!0,Promise.resolve().then(r),s(void 0);return}}})})}async function Q(i,y,s,v,u){let f;for(let r=0;r<=v;r++){if(r>0){let a=u[Math.min(r-1,u.length-1)]??0;a>0&&await new Promise(o=>setTimeout(o,a))}try{return await V(i(y,s))}catch(a){f=a}}return{outcome:"failure",error:f}}function X(i,y,s){let v=s.retryMax??0,u=s.backoffMs??[0],f=1024,r=new Map,a=new Set,o=new Map,k=O({name:`${y}_process_instances`,retainedLimit:f,graph:i}),j=0;function $(){return++j}function S(e,t,n){C(e,t,n,void 0)}function C(e,t,n,c){let d=b(),g={correlationId:e,state:t,status:n,startedAt:o.get(e)??d,updatedAt:d,t_ns:d,seq:$(),...s.handlerVersion!==void 0?{handlerVersion:s.handlerVersion}:{},...c!==void 0?{reason:c}:{}};k.append(g)}let _=`_process_${y}_started`;i.event(_),s.persistence?.eventStorage&&i.attachEventStorage(s.persistence.eventStorage);async function x(e,t,n,c){if(a.delete(e),r.delete(e),o.delete(e),s.compensate)try{await V(s.compensate(t,n)),C(e,t,"compensated",c)}catch{S(e,t,"errored")}else S(e,t,"errored")}async function D(e,t){if(a.has(e)){if(t.outcome==="failure"){let n=r.get(e)??s.initial;await x(e,n,t.error);return}if(t.outcome==="success"){if(r.set(e,t.state),t.emit)for(let n of t.emit)try{i._appendEvent(n.type,n.payload,{correlationId:e,aggregateId:e})}catch{}if(S(e,t.state,"running"),s.isTerminal?.(t.state)){a.delete(e),r.delete(e),o.delete(e),S(e,t.state,"terminated");return}if(t.schedule){let{afterMs:n,eventType:c}=t.schedule,d,g=B(n),m=p=>{for(let T of p)if(T[0]===M){if(d?d():queueMicrotask(()=>d?.()),!a.has(e))return;let E=r.get(e);if(E===void 0)return;let l=s.steps[c];if(!l)return;let w={type:c,payload:null,timestampNs:b(),seq:Number.NaN,correlationId:e,aggregateId:e};q(e,l,E,w)}};d=g.subscribe(m)}return}if(t.outcome==="terminate"){if(r.set(e,t.state),t.emit)for(let n of t.emit)try{i._appendEvent(n.type,n.payload,{correlationId:e,aggregateId:e})}catch{}a.delete(e),r.delete(e),o.delete(e),S(e,t.state,"terminated")}}}let h=new Map;function q(e,t,n,c){let g=(h.get(e)??Promise.resolve()).then(async()=>{let m=r.get(e);if(m===void 0||!a.has(e))return;let p;try{p=await Q(t,m,c,v,u)}catch(T){await x(e,r.get(e)??s.initial,T);return}await D(e,p)});h.set(e,g),g.finally(()=>{h.get(e)===g&&h.delete(e)})}let P=!1,R=[];for(let e of s.watching){let t=i.event(e),n=0;n=(t.cache??[]).length;let d=t.subscribe(g=>{for(let m of g){if(m[0]!==M)continue;let p=m[1];if(p.length<=n)continue;let T=p.slice(n);n=p.length;for(let E of T){let l=E.correlationId;if(l===void 0||!a.has(l))continue;let w=s.steps[e];if(!w)continue;let N=r.get(l);N!==void 0&&q(l,w,N,E)}}});R.push(d)}function W(e,t){if(P||a.has(e))return;let n=b();o.set(e,n),r.set(e,s.initial),a.add(e);try{i._appendEvent(_,t??null,{correlationId:e,aggregateId:e})}catch{}S(e,s.initial,"running")}function F(e,t){if(P||!a.has(e))return;let n=r.get(e)??s.initial;x(e,n,new Error(`cancelled: ${t??"no reason given"}`),t)}function U(e){return r.get(e)}function z(){if(!P){P=!0;for(let e of R)try{e()}catch{}R.length=0}}return{instances:k,audit:k,start:W,cancel:F,getState:U,dispose:z}}export{J as a,X as b,Y as c};