@graphrefly/graphrefly 0.41.0 → 0.43.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-3XDYJRYU.js +1 -0
  4. package/dist/{chunk-AI7QC7J6.js → chunk-4YAN45KM.js} +1 -1
  5. package/dist/chunk-626TESAC.js +3 -0
  6. package/dist/chunk-6HOSXQKF.js +1 -0
  7. package/dist/{chunk-G3M3IMEV.js → chunk-CUNIRONA.js} +1 -1
  8. package/dist/chunk-EBW4V6JN.js +1 -0
  9. package/dist/chunk-FDQGFWLF.js +1 -0
  10. package/dist/{chunk-33N4TU3X.js → chunk-FG4TKHMC.js} +1 -1
  11. package/dist/{chunk-YQRN4CIV.js → chunk-I7IGYPSL.js} +1 -1
  12. package/dist/chunk-INQD2KRQ.js +1 -0
  13. package/dist/{chunk-7PQLZMOG.js → chunk-JNWRYDJN.js} +1 -1
  14. package/dist/{chunk-TT4C7DXW.js → chunk-JQFH2DV6.js} +1 -1
  15. package/dist/{chunk-M3FQSXEW.js → chunk-K2Q24F5T.js} +1 -1
  16. package/dist/chunk-KVV66NN2.js +1 -0
  17. package/dist/chunk-NON4NLIC.js +45 -0
  18. package/dist/{chunk-CYOSWFT2.js → chunk-O2BLLH7M.js} +3 -3
  19. package/dist/{chunk-OV5AA6HJ.js → chunk-OCKEEPRJ.js} +1 -1
  20. package/dist/{chunk-X7QKTXXC.js → chunk-OFZG3TB3.js} +3 -3
  21. package/dist/chunk-OYJKFY7V.js +1 -0
  22. package/dist/{chunk-SC27WTSG.js → chunk-P6C4WHZO.js} +1 -1
  23. package/dist/{chunk-VV62MIG4.js → chunk-PT7W5FCD.js} +1 -1
  24. package/dist/{chunk-UISPDFJ3.js → chunk-Q4U3A3L5.js} +1 -1
  25. package/dist/chunk-QE4IGY7I.js +61 -0
  26. package/dist/{chunk-5VEZLQFN.js → chunk-QYVXF7GW.js} +1 -1
  27. package/dist/{chunk-ZAJ7J7TO.js → chunk-S3EEIPO7.js} +1 -1
  28. package/dist/{chunk-GI4Q7PNY.js → chunk-SUWT3ZON.js} +1 -1
  29. package/dist/{chunk-CGNOWGV6.js → chunk-TPKQW72B.js} +1 -1
  30. package/dist/{chunk-L77I47VU.js → chunk-V5A7M7RJ.js} +1 -1
  31. package/dist/chunk-VNC3TMVY.js +1 -0
  32. package/dist/{chunk-AK5RHMC5.js → chunk-VOPGGIL7.js} +1 -1
  33. package/dist/chunk-VQ4A6T2A.js +1 -0
  34. package/dist/{chunk-KNVCCBIU.js → chunk-XG62INFA.js} +1 -1
  35. package/dist/{chunk-F7VUYPP6.js → chunk-Y4NI3X7O.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-DgJc8Zgc.d.cts → index-0rKFCVFp.d.cts} +90 -5
  98. package/dist/{index-BAQrjuZF.d.ts → index-B-i4_g3k.d.ts} +2 -2
  99. package/dist/{index-DpiGqtrs.d.cts → index-B5iz82A3.d.cts} +441 -381
  100. package/dist/{index-Bd91Nmf4.d.cts → index-BAOD98JD.d.cts} +4 -4
  101. package/dist/{index-2n8Eai6M.d.ts → index-BG0BN3PB.d.ts} +1 -1
  102. package/dist/{index-z8WFPVI8.d.cts → index-BJX94aud.d.cts} +1 -1
  103. package/dist/{index-DhLyOHYZ.d.ts → index-BP8a88zx.d.ts} +11 -4
  104. package/dist/{index-Cnr1WrlX.d.cts → index-BTQtTb_H.d.cts} +14 -3
  105. package/dist/{index-DOBLxOti.d.cts → index-BVpm6noz.d.cts} +1 -1
  106. package/dist/{index-Cczxgd2D.d.ts → index-Bc41FuHp.d.cts} +3 -3
  107. package/dist/{index-BiHUBEKq.d.cts → index-BdGtBX-X.d.cts} +3 -3
  108. package/dist/{index-da2V5vPy.d.ts → index-Bf7eqeSF.d.ts} +2 -2
  109. package/dist/{index-DuRsN9ae.d.cts → index-BiX1Nkgx.d.cts} +383 -18
  110. package/dist/{index-DGTo1yka.d.cts → index-BoLv_OfD.d.cts} +2 -2
  111. package/dist/{index-DVAlsmEU.d.cts → index-BojK2fwH.d.cts} +3 -3
  112. package/dist/{index-B72TQQHd.d.cts → index-BsT7F2et.d.ts} +3 -3
  113. package/dist/{index-DGD4_fj6.d.cts → index-BwLvVVsy.d.cts} +8 -5
  114. package/dist/{index-CQtWm7jS.d.ts → index-C59mYFKp.d.ts} +9 -9
  115. package/dist/{index-C6ZUaos7.d.ts → index-C7O6r5fV.d.ts} +1 -1
  116. package/dist/{index-CL7oilfm.d.cts → index-C9kSENB4.d.cts} +1 -1
  117. package/dist/{index-DVDapw2k.d.cts → index-C9pjcz3l.d.cts} +35 -36
  118. package/dist/{index-CG33HeBW.d.ts → index-CAC_rNzm.d.ts} +8 -5
  119. package/dist/{index-yLt-aPMp.d.ts → index-CCq87F7t.d.ts} +1 -1
  120. package/dist/{index-D4uimgee.d.cts → index-CDXc9zKM.d.cts} +1 -1
  121. package/dist/{index-B2RUoIUz.d.ts → index-CJK1JkYy.d.ts} +1 -1
  122. package/dist/{index-DktLSZOc.d.cts → index-CLon-IWF.d.cts} +4 -4
  123. package/dist/{index-DQQCOIt8.d.cts → index-COD1kVoS.d.cts} +10 -5
  124. package/dist/{index-bXXLSvor.d.ts → index-CPT7C_f1.d.ts} +4 -4
  125. package/dist/{index-CD2dBMet.d.ts → index-CQG3D1cp.d.ts} +10 -5
  126. package/dist/{index-BQ1fR4li.d.ts → index-CZQXo5tH.d.ts} +35 -36
  127. package/dist/{index-A3U3CSve.d.cts → index-CZjOhcBy.d.cts} +2 -2
  128. package/dist/{index-DYTBbF8T.d.cts → index-ChOyVLKm.d.cts} +1 -1
  129. package/dist/{index-BJSZxSFX.d.ts → index-CvrqGfNS.d.ts} +1 -1
  130. package/dist/{index-DhnsQfa3.d.ts → index-D-AEQVLo.d.ts} +441 -381
  131. package/dist/{index-CAP3UGsq.d.ts → index-D4Y1cMG0.d.ts} +1 -1
  132. package/dist/{index-40ZT4MHj.d.ts → index-DBHK8O6H.d.ts} +14 -3
  133. package/dist/{index-3k4Gg6-n.d.ts → index-DBevwHj_.d.ts} +3 -3
  134. package/dist/{index-Ctb7_2sG.d.ts → index-DIOoAZUX.d.ts} +1 -1
  135. package/dist/{index-WSlcjhQF.d.ts → index-DSZ3ZCHF.d.ts} +124 -13
  136. package/dist/{index-DH4fm2Ck.d.ts → index-Dgs8zcj7.d.ts} +2 -2
  137. package/dist/{index-BaA-xpSw.d.ts → index-Dh_HJ82K.d.ts} +3 -3
  138. package/dist/{index-CtFNGe-m.d.cts → index-Dhc7a7Xo.d.cts} +2 -2
  139. package/dist/{index-CoM4rzyB.d.ts → index-Dmqp7KjD.d.ts} +1 -1
  140. package/dist/{index-B6iTqKtJ.d.ts → index-Dn-wI9g4.d.ts} +2 -2
  141. package/dist/{index-C-dkXOpB.d.cts → index-Du7u1lSf.d.cts} +11 -4
  142. package/dist/{index-DfOK_oL5.d.ts → index-DwigL4lY.d.ts} +383 -18
  143. package/dist/index-DyR7eU5S.d.cts +779 -0
  144. package/dist/index-JZUPJIJy.d.ts +779 -0
  145. package/dist/{index-I1cCY3ZI.d.ts → index-K0_0eR8g.d.ts} +90 -5
  146. package/dist/{index-BilOa6AE.d.cts → index-O16yXPK4.d.cts} +124 -13
  147. package/dist/{index-CRm0YIzC.d.cts → index-O7fucFrU.d.cts} +9 -9
  148. package/dist/{index-MxYuWOrf.d.cts → index-RV_yDjOX.d.cts} +3 -3
  149. package/dist/{index-C5cQ7Gfx.d.ts → index-cm1GNcWE.d.ts} +4 -4
  150. package/dist/{index-CgnCFhr2.d.cts → index-f5IivDUX.d.cts} +1 -1
  151. package/dist/{index-PgwvGWa1.d.cts → index-hHcaFlJX.d.cts} +1 -1
  152. package/dist/{index-tV3AA9hI.d.cts → index-tJoTcnHh.d.cts} +2 -2
  153. package/dist/{index-eaQuGJnv.d.ts → index-wAzD9yVj.d.ts} +3 -3
  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-DPqKDk59.d.cts} +5 -5
  232. package/dist/{pipeline-graph-CB4La-UW.d.ts → pipeline-graph-loP57TBA.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-YIWPK4YC.js +1 -0
  240. package/dist/{sugar-DzePN5-g.d.cts → sugar-DLwvMr3F.d.ts} +24 -4
  241. package/dist/{sugar-BhfjgetH.d.ts → sugar-DyVGtczU.d.cts} +24 -4
  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 { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-1Dhoi7HM.cjs';
2
- import { b as CircuitBreakerOptions, f as CircuitBreaker } from './index-DGTo1yka.cjs';
1
+ import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-B1jDWVsM.cjs';
2
+ import { b as CircuitBreakerOptions, C as CircuitBreaker } from './index-BoLv_OfD.cjs';
3
3
 
4
4
  /**
5
5
  * OpenAICompatAdapter — default fetch-backed, optional SDK-backed.
@@ -1,5 +1,5 @@
1
- import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-39jk0kaV.js';
2
- import { b as CircuitBreakerOptions, f as CircuitBreaker } from './index-BAQrjuZF.js';
1
+ import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-DkzUUs0H.js';
2
+ import { b as CircuitBreakerOptions, C as CircuitBreaker } from './index-B-i4_g3k.js';
3
3
 
4
4
  /**
5
5
  * OpenAICompatAdapter — default fetch-backed, optional SDK-backed.
@@ -0,0 +1 @@
1
+ import{c as B,d as G,f as v,h as W}from"./chunk-FDQGFWLF.js";import{a as L}from"./chunk-L6NSJVJZ.js";import{j as I}from"./chunk-626TESAC.js";import{b as D}from"./chunk-35JTVPOX.js";import{b as U}from"./chunk-KGKJCHEK.js";import{b as K}from"./chunk-TZQPPQEQ.js";import{b as Q}from"./chunk-JQFH2DV6.js";import{C as _,m as z}from"./chunk-V5A7M7RJ.js";import{D as P,G as N,m as f,p as $}from"./chunk-LYCLF26R.js";import{b as x,j as S}from"./chunk-CK2E7BTU.js";import{b as ee}from"./chunk-QYADASLV.js";var re={};ee(re,{JobFlowGraph:()=>w,JobQueueGraph:()=>y,jobEventKeyOf:()=>oe,jobFlow:()=>se,jobQueue:()=>V});var te=256,ne=1024;function F(p,e){if(!Number.isFinite(p)||!Number.isInteger(p)||p<0)throw new Error(`${e} must be a non-negative integer`);return p}function T(p,e){return L("job_queue",p,e)}var oe=p=>p.action,y=class extends I{_pending;_jobs;_seqCursor;pending;jobs;depth;events;audit;_enqueueImpl;_ackImpl;_nackImpl;_removeByIdImpl;constructor(e,n={}){super(e,n.graph),this._pending=U([],{name:"pending"}),this._jobs=K({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],([t])=>t.length,{name:"depth",describeKind:"derived",meta:T("queue_depth"),initial:0}),this.add(this.depth,{name:"depth"}),this.addDisposer(_(this.depth)),this.events=B({name:"events",retainedLimit:1024,graph:this}),this.audit=this.events,this._seqCursor=W(this,"seq",0),this._enqueueImpl=v((t,o)=>{let a=this._seqCursor.cache,s=o.id??`${this.name}-${a}`;if(this._jobs.get(s)!==void 0)throw new Error(`jobQueue("${this.name}"): duplicate job id "${s}"`);let u={id:s,payload:t,attempts:0,metadata:Object.freeze({...o.metadata??{}}),state:"queued"};return this._jobs.set(s,u),this._pending.append(s),s},{audit:this.events,seq:this._seqCursor,freeze:!1,onSuccess:([t],o,{t_ns:a,seq:s})=>({action:"enqueue",id:o,payload:t,t_ns:a,seq:s??0})}),this._ackImpl=v((t,o)=>{this._jobs.delete(t)},{audit:this.events,seq:this._seqCursor,freeze:!1,onSuccess:([t,o],a,{t_ns:s,seq:u})=>({action:"ack",id:t,attempts:o.attempts,t_ns:s,seq:u??0})}),this._nackImpl=v((t,o,a)=>{a?(this._jobs.set(t,{...o,state:"queued"}),this._pending.append(t)):this._jobs.delete(t)},{audit:this.events,seq:this._seqCursor,freeze:!1,onSuccess:([t,o],a,{t_ns:s,seq:u})=>({action:"nack",id:t,attempts:o.attempts,t_ns:s,seq:u??0})}),this._removeByIdImpl=v((t,o)=>{if(o.state==="queued"){let s=this.pending.cache.indexOf(t);s>=0&&this._pending.pop(s)}this._jobs.delete(t)},{audit:this.events,seq:this._seqCursor,freeze:!1,onSuccess:([t,o],a,{t_ns:s,seq:u})=>({action:"remove",id:t,attempts:o.attempts,t_ns:s,seq:u??0})})}attachEventStorage(e){return this.events.attachStorage(e)}enqueue(e,n={}){return this._enqueueImpl(e,n)}claim(e=1){let n=F(e,"job queue claim limit");if(n===0)return[];let t=[];for(;t.length<n&&this.pending.cache.length!==0;){let a=this._pending.pop(0),s=this._jobs.get(a);if(!s||s.state!=="queued")continue;let u={...s,state:"inflight",attempts:s.attempts+1};this._jobs.set(a,u),t.push(u),this.events.append({action:"claim",id:a,attempts:u.attempts,t_ns:$(),seq:G(this._seqCursor)})}return t}ack(e){let n=this._jobs.get(e);return!n||n.state!=="inflight"?!1:(this._ackImpl(e,n),!0)}nack(e,n={}){let t=this._jobs.get(e);return!t||t.state!=="inflight"?!1:(this._nackImpl(e,t,n.requeue??!0),!0)}removeById(e){let n=this._jobs.get(e);return n?(this._removeByIdImpl(e,n),!0):!1}consumeFrom(e,n){return e.subscribe(t=>{for(let o of t){if(o[0]!==x)continue;let a=o[1];this.enqueue(a,n?{metadata:n.metadata}:void 0)}})}},w=class extends I{_stageNames;_stageWorkFns;_queues=new Map;_completed;completed;completedCount;constructor(e,n={}){super(e,n.graph);let t=n.stages??["incoming","processing","done"],o=[],a=new Map,s=new Map;for(let r of t){let i=typeof r=="string"?r.trim():r.name.trim();typeof r!="string"&&r.work&&a.set(i,r.work),typeof r!="string"&&r.maxPerPump!=null&&s.set(i,Math.max(1,F(r.maxPerPump,`job flow stage "${i}" maxPerPump`))),o.push(i)}if(o.length<2)throw new Error(`jobFlow("${e}"): requires at least 2 stages`);if(new Set(o).size!==o.length)throw new Error(`jobFlow("${e}"): stage names must be unique`);this._stageNames=Object.freeze([...o]),this._stageWorkFns=a;for(let r of this._stageNames){let i=V(`${e}-${r}`);this._queues.set(r,i),this.mount(r,i)}this._completed=Q([],{name:"completed",maxSize:ne}),this.completed=this._completed.entries,this.add(this.completed,{name:"completed"}),this.completedCount=N([this.completed],([r])=>r.length,{name:"completedCount",describeKind:"derived",meta:T("job_flow_completed_count"),initial:0}),this.add(this.completedCount,{name:"completedCount"}),this.addDisposer(_(this.completedCount));let X=Math.max(1,F(n.maxPerPump??te,"job flow maxPerPump"));for(let r=0;r<this._stageNames.length;r+=1){let i=this._stageNames[r],l=this.queue(i),j=r+1<this._stageNames.length?this.queue(this._stageNames[r+1]):null,R=this._stageWorkFns.get(i),C=s.get(i)??X,M=j===null;if(R){let h=P([l.pending],()=>{let c=0;for(;c<C;){let g=l.claim(1);if(g.length===0)break;let d=g[0];if(!d)break;let q=[...d.metadata.job_flow_path??[],i],b;try{b=R(d)}catch{l.nack(d.id,{requeue:!1}),c+=1;continue}let k=z(b),E=!1,m;m=k.subscribe(Y=>{if(!E){for(let J of Y)if(J[0]===x){E=!0,m?m():Promise.resolve().then(()=>m?.());let A=J[1],O={...d.metadata,job_flow_path:q};if(M){let Z={...d,payload:A,metadata:Object.freeze(O)};f(()=>{l.ack(d.id),this._completed.append(Z)})}else f(()=>{l.ack(d.id),j.enqueue(A,{metadata:O})});return}else if(J[0]===S){E=!0,m?m():Promise.resolve().then(()=>m?.()),l.nack(d.id,{requeue:!1});return}}}),c+=1}},{name:`pump_${i}`,describeKind:"effect",meta:T("job_flow_pump",{stage:i,has_work:!0})});this.add(h,{name:`pump_${i}`}),this.addDisposer(_(h))}else{let h=P([l.pending],()=>{let c=0;for(;c<C;){let g=l.claim(1);if(g.length===0)break;let d=g[0];if(!d)break;let q=[...d.metadata.job_flow_path??[],i],b={...d.metadata,job_flow_path:q};if(M){let k={...d,metadata:Object.freeze(b)};f(()=>{l.ack(d.id),this._completed.append(k)})}else f(()=>{l.ack(d.id),j.enqueue(d.payload,{metadata:b})});c+=1}},{name:`pump_${i}`,describeKind:"effect",meta:T("job_flow_pump",{stage:i,has_work:!1})});this.add(h,{name:`pump_${i}`}),this.addDisposer(_(h))}}}stages(){return this._stageNames}queue(e){let n=this._queues.get(e);if(!n)throw new Error(`jobFlow("${this.name}"): unknown stage "${e}"`);return n}enqueue(e,n={}){return this.queue(this._stageNames[0]).enqueue(e,n)}retainedCompleted(){return this.completed.cache}};function V(p,e){return new y(p,e)}function se(p,e){let n=new w(p,e),{factory:t,factoryArgs:o,...a}=e??{};return n.tagFactory("jobFlow",D(a)),n}export{oe as a,y as b,w as c,V as d,se as e,re as f};
@@ -1 +1 @@
1
- import{i as _}from"./chunk-POXANAJ6.js";import{D as g,E as k}from"./chunk-LYCLF26R.js";import{b as R,c as T,d,h as A,i as O,j as D}from"./chunk-CK2E7BTU.js";function L(c,y,l,a){let s=new _(c,a);s.add(y,{name:"source"});let n=k(l,{meta:{kind:"stratify_rules"}});s.add(n,{name:"rules"});for(let f of l)E(s,y,n,f);return s}function E(c,y,l,a){let s=`branch/${a.name}`,n=Symbol("noValue"),f=!1,m=!1,p=!1,N=n,r=!1,h=l.cache??[];function v(o){if(p){p=!1;let t=N;if(N=n,t!==n){let i=h.find(u=>u.name===a.name),e=!1;try{e=i?.classify(t)??!1}catch{e=!1}e?(r=!1,o.emit(t)):r&&(r=!1,o.down([[T],[d]]))}else r?(r=!1,o.down([[T],[d]])):o.down([[d]])}}let S=g([],(o,t)=>{let i=y.subscribe(u=>{for(let b of u)w(b,0,t)}),e=l.subscribe(u=>{for(let b of u)w(b,1,t)});return()=>{i(),e()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:a.name},completeWhenDepsComplete:!1});function w(o,t,i){let e=o[0];return e===T?(t===0?(f=!0,r=!0):m=!0,!0):e===R||e===d?(t===0?(f=!1,p=!0,N=e===R?o[1]:n):(e===R&&(h=o[1]),m=!1),f||m||v(i),!0):e===O||e===D||e===A?(f=!1,m=!1,p=!1,N=n,r=!1,t===0&&i.down([o]),!0):t===1}if(c.add(S,{name:s}),a.ops){let o=a.ops(S),t=`branch/${a.name}/out`;c.add(o,{name:t})}}export{L as a};
1
+ import{j as _}from"./chunk-626TESAC.js";import{D as g,E as k}from"./chunk-LYCLF26R.js";import{b as R,c as T,d,h as A,i as O,j as D}from"./chunk-CK2E7BTU.js";function L(c,y,l,a){let s=new _(c,a);s.add(y,{name:"source"});let n=k(l,{meta:{kind:"stratify_rules"}});s.add(n,{name:"rules"});for(let f of l)E(s,y,n,f);return s}function E(c,y,l,a){let s=`branch/${a.name}`,n=Symbol("noValue"),f=!1,m=!1,p=!1,N=n,r=!1,h=l.cache??[];function v(o){if(p){p=!1;let t=N;if(N=n,t!==n){let i=h.find(u=>u.name===a.name),e=!1;try{e=i?.classify(t)??!1}catch{e=!1}e?(r=!1,o.emit(t)):r&&(r=!1,o.down([[T],[d]]))}else r?(r=!1,o.down([[T],[d]])):o.down([[d]])}}let S=g([],(o,t)=>{let i=y.subscribe(u=>{for(let b of u)w(b,0,t)}),e=l.subscribe(u=>{for(let b of u)w(b,1,t)});return()=>{i(),e()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:a.name},completeWhenDepsComplete:!1});function w(o,t,i){let e=o[0];return e===T?(t===0?(f=!0,r=!0):m=!0,!0):e===R||e===d?(t===0?(f=!1,p=!0,N=e===R?o[1]:n):(e===R&&(h=o[1]),m=!1),f||m||v(i),!0):e===O||e===D||e===A?(f=!1,m=!1,p=!1,N=n,r=!1,t===0&&i.down([o]),!0):t===1}if(c.add(S,{name:s}),a.ops){let o=a.ops(S),t=`branch/${a.name}/out`;c.add(o,{name:t})}}export{L as a};
@@ -0,0 +1,3 @@
1
+ import{a as Me}from"./chunk-ESMPEKEV.js";import{a as ye,d as we}from"./chunk-35JTVPOX.js";import{C as re}from"./chunk-V5A7M7RJ.js";import{A as me,C as M,E as Z,F as be,G as ve,e as xe,f as $e,i as Q,k as Ae,l as ne,m as Te,o as L,p as Pe,s as U}from"./chunk-LYCLF26R.js";import{b as q,c as pe,d as fe,e as te,f as he,g as ge,h as B,i as H,j as W}from"./chunk-CK2E7BTU.js";var A={object:56,array:64,string:40,number:8,boolean:4,null:0,undefined:0,symbol:40,bigint:16,function:120,map:72,set:72,mapEntry:40,setEntry:24,date:24,regexp:48,error:64,url:80,promise:48,weakmap:40,weakset:40},Xe=Symbol.for("sizeof");function je(o){let e=new WeakSet,t=new WeakSet,n=[o],s=0;for(;n.length>0;){let r=n.pop();s+=et(r,e,t,n)}return s}function et(o,e,t,n){if(o==null)return 0;switch(typeof o){case"number":return A.number;case"boolean":return A.boolean;case"string":return A.string+o.length*2;case"bigint":return A.bigint+tt(o);case"symbol":return A.symbol;case"function":return e.has(o)?0:(e.add(o),A.function);case"undefined":return 0}let r=o;if(e.has(r))return 0;e.add(r);let i=r[Xe];if(typeof i=="function")try{let a=i.call(r);if(typeof a=="number"&&Number.isFinite(a))return a}catch{}if(r instanceof Date)return A.date;if(r instanceof RegExp)return A.regexp+r.source.length*2;if(r instanceof Error){let a=r.message?r.message.length*2:0,p=r.stack?r.stack.length*2:0;return A.error+a+p}if(typeof URL<"u"&&r instanceof URL)return A.url+r.href.length*2;if(typeof Promise<"u"&&r instanceof Promise)return A.promise;if(r instanceof WeakMap)return A.weakmap;if(r instanceof WeakSet)return A.weakset;if(r instanceof Map){let a=A.map;for(let[p,g]of r)a+=A.mapEntry,n.push(p),n.push(g);return a}if(r instanceof Set){let a=A.set;for(let p of r)a+=A.setEntry,n.push(p);return a}if(Array.isArray(r)){let a=A.array+r.length*8;for(let p of r)n.push(p);return a}if(r instanceof ArrayBuffer)return t.has(r)?0:(t.add(r),r.byteLength);if(ArrayBuffer.isView(r)){let a=r;return t.has(a.buffer)?48:(t.add(a.buffer),a.buffer.byteLength+48)}let c=A.object,d=Object.keys(r);for(let a of d){c+=A.string+a.length*2;try{n.push(r[a])}catch{}}return c}function tt(o){let e=o<0n?-o:o;if(e===0n)return 0;let t=e.toString(2).length;return Math.ceil(t/32)*8}function Fe(o,e,t,n={}){let s=e in o.nodes,r=t in o.nodes;if(!s)return se(e,t,"no-such-from");if(!r)return se(e,t,"no-such-to");let i=n.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===t){if(n.findCycle===!0){let a=nt(o,e,n);if(a!=null)return a}let d=oe(e,o.nodes[e],0,n);return ie(e,t,[d])}if(i===0)return se(e,t,"no-path");let c=Ie(o,e,t,i);return c.found?ie(e,t,ze(o,c.pathOrder,n)):se(e,t,c.truncated?"max-depth-exceeded":"no-path")}function Ie(o,e,t,n){let s=new Map,r=[{path:t,depth:0}],i=new Set([t]),c=0,d=!1;for(;c<r.length;){let g=r[c++];if(g.path===e)break;if(n!=null&&g.depth>=n){let y=o.nodes[g.path];y?.deps&&y.deps.length>0&&(d=!0);continue}let h=o.nodes[g.path];if(h==null)continue;let f=h.deps??[],u=new Map;for(let y=0;y<f.length;y++){let l=f[y];if(!l)continue;let O=u.get(l);O==null&&(O=[],u.set(l,O)),O.push(y)}for(let[y,l]of u)i.has(y)||(i.add(y),s.set(y,{from:g.path,depIndices:l}),r.push({path:y,depth:g.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:d};let a=[{path:e}],p=e;for(;p!==t;){let g=s.get(p);if(g==null)return{found:!1,pathOrder:[],truncated:!1};a[a.length-1].depIndices=g.depIndices,a.push({path:g.from}),p=g.from}return{found:!0,pathOrder:a,truncated:!1}}function nt(o,e,t){let n=o.nodes[e];if(n==null)return null;let s=n.deps??[],r=[];for(let c=0;c<s.length;c++)s[c]===e&&r.push(c);if(r.length>0){let c=oe(e,n,0,t);c.dep_index=r[0];let d=oe(e,n,1,t);return ie(e,e,[c,d])}let i=null;for(let c=0;c<s.length;c++){let d=s[c];if(!d||d===e)continue;let a=Ie(o,d,e,t.maxDepth);a.found&&(i==null||a.pathOrder.length<i.pathOrder.length)&&(i=a,i={found:!0,pathOrder:[{path:e,depIndices:[c]},...a.pathOrder],truncated:!1})}return i==null?null:ie(e,e,ze(o,i.pathOrder,t))}function ze(o,e,t){return e.map((n,s)=>{let r=o.nodes[n.path],i=oe(n.path,r,s,t);return n.depIndices!=null&&n.depIndices.length>0&&(i.dep_index=n.depIndices[0],n.depIndices.length>1&&(i.dep_indices=[...n.depIndices])),i})}function oe(o,e,t,n){let s={path:o,type:e.type,hop:t};e.status!==void 0&&(s.status=e.status),"value"in e&&(s.value=e.value),e.v!=null&&(s.v=e.v);let r=n.annotations?.get(o)??e.annotation;r!=null&&(s.annotation=r);let i=n.lastMutations?.get(o)??e.lastMutation;return i!=null&&(s.lastMutation=i),s}function ie(o,e,t){return Be(o,e,!0,"ok",t)}function se(o,e,t){return Be(o,e,!1,t,[])}function Be(o,e,t,n,s){let r=rt(o,e,t,n,s);return{from:o,to:e,found:t,reason:n,steps:s,text:r,toJSON(){return{from:o,to:e,found:t,reason:n,steps:s}}}}function rt(o,e,t,n,s){if(!t)switch(n){case"no-such-from":return`explainPath: no node named "${o}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${o}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${o}" to "${e}"`}let r=[`Causal path: ${o} \u2192 ${e} (${s.length} step(s))`];for(let i of s){let d=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(r.push(d),"value"in i&&r.push(` value: ${st(i.value)}`),i.annotation!=null&&r.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let a=i.lastMutation.actor;r.push(` actor: ${a.type}${a.id?`:${a.id}`:""}`)}}return r.join(`
2
+ `)}function st(o){if(o===void 0)return"<sentinel>";if(o===null)return"null";if(typeof o=="string")return JSON.stringify(o);if(typeof o=="number"||typeof o=="boolean"||typeof o=="bigint")return String(o);try{let e=JSON.stringify(o);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(o)}}function Oe(o,e){if(Object.is(o,e))return!0;if(o==null||e==null||typeof o!="object"||typeof e!="object")return!1;if(Array.isArray(o)){if(!Array.isArray(e)||o.length!==e.length)return!1;for(let r=0;r<o.length;r++)if(!Oe(o[r],e[r]))return!1;return!0}if(Array.isArray(e))return!1;let t=Object.keys(o),n=Object.keys(e);if(t.length!==n.length)return!1;let s=new Set(n);for(let r of t)if(!s.has(r)||!Oe(o[r],e[r]))return!1;return!0}function Le(o,e){return`${o}\0${e}`}function _e(o,e){let t=[],n=new Set(o.subgraphs),s=new Set(e.subgraphs),r=[];for(let l of s)n.has(l)||r.push(l);r.sort();for(let l of r)t.push({type:"subgraph-mounted",path:l});let i=new Set(Object.keys(o.nodes)),c=new Set(Object.keys(e.nodes)),d=[];for(let l of c)i.has(l)||d.push(l);d.sort();for(let l of d)t.push({type:"node-added",path:l,node:{...e.nodes[l]}});let a=[];for(let l of c){if(!i.has(l))continue;let O=o.nodes[l]?.meta,m=e.nodes[l]?.meta;O==null&&m==null||Oe(O??{},m??{})||a.push(l)}a.sort();for(let l of a)t.push({type:"node-meta-changed",path:l,prevMeta:o.nodes[l]?.meta??{},nextMeta:e.nodes[l]?.meta??{}});let p=new Map;for(let l of o.edges)p.set(Le(l.from,l.to),l);let g=new Map;for(let l of e.edges)g.set(Le(l.from,l.to),l);let h=[];for(let[l,O]of g)p.has(l)||h.push(O);h.sort((l,O)=>l.from<O.from?-1:l.from>O.from?1:l.to<O.to?-1:l.to>O.to?1:0);for(let l of h)t.push({type:"edge-added",from:l.from,to:l.to});let f=[];for(let[l,O]of p)g.has(l)||f.push(O);f.sort((l,O)=>l.from<O.from?-1:l.from>O.from?1:l.to<O.to?-1:l.to>O.to?1:0);for(let l of f)t.push({type:"edge-removed",from:l.from,to:l.to});let u=[];for(let l of i)c.has(l)||u.push(l);u.sort();for(let l of u)t.push({type:"node-removed",path:l});let y=[];for(let l of n)s.has(l)||y.push(l);y.sort();for(let l of y)t.push({type:"subgraph-unmounted",path:l});return{events:t,flushedAt_ns:L()}}function Ve(o,e){let t=e?.topN??10,n=o.describe({detail:"standard"}),s=[],r=o._collectObserveTargets;typeof r=="function"&&r.call(o,"",s);let i=new Map;for(let[h,f]of s)i.set(h,f);let c=[];for(let[h,f]of Object.entries(n.nodes)){let u=i.get(h),y=u instanceof M?u:null,l=y?je(y.cache):0,O=y?y._sinkCount:0,m=f.deps?.length??0,b=f.type==="effect"&&O===0,v=O===0?f.type==="effect"?"orphan-effect":f.type==="derived"?"idle-derived":f.type==="producer"?"idle-producer":null:null;c.push({path:h,type:f.type,status:f.status??"unknown",valueSizeBytes:l,subscriberCount:O,depCount:m,isOrphanEffect:b,orphanKind:v})}let d=c.reduce((h,f)=>h+f.valueSizeBytes,0),a=(h,f)=>[...c].sort(f??((u,y)=>y[h]-u[h])).slice(0,t),p=c.filter(h=>h.orphanKind!=null),g=c.filter(h=>h.isOrphanEffect);return{nodeCount:c.length,edgeCount:n.edges.length,subgraphCount:n.subgraphs.length,nodes:c,totalValueSizeBytes:d,hotspots:{byValueSize:a("valueSizeBytes"),bySubscriberCount:a("subscriberCount"),byDepCount:a("depCount")},orphans:p,orphanEffects:g}}var X=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let t=(this.head+this._size)%this.capacity;this.buf[t]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let t=e<0?this._size+e:e;if(!(t<0||t>=this._size))return this.buf[(this.head+t)%this.capacity]}toArray(){let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this.buf[(this.head+t)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}};var x="::",z="__meta__",J=1;function qe(o,e){let t=Math.max(16,o.size*4),n=0;for(;o.size>0;){if(n++>=t){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${t}); ${o.size} disposer(s) discarded`),o.clear();return}let s=o.values().next();if(s.done)return;let r=s.value;o.delete(r);try{r()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function Ye(o){return o!=null&&typeof o=="object"&&"cache"in o&&typeof o.subscribe=="function"&&typeof o.down=="function"}function ot(o){if(o!=null)return Ye(o)?o.cache:o}function K(o){return o!=null&&typeof o=="object"&&"cache"in o&&typeof o.subscribe=="function"&&typeof o.down=="function"}function V(o){return K(o)?o.cache??"":o}function Ke(o){return K(o)?o.cache??0:o}function He(o){return K(o)?o.cache??!1:o}function it(o){let e=[];for(let t of Object.keys(o).sort()){let n=o[t].v;n!=null&&e.push(`${t} ${n.id} ${n.version}`)}return e.join(`
3
+ `)}function We(o){if(o.version!==J)throw new Error(`unsupported snapshot version ${String(o.version)} (expected ${J})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in o))throw new Error(`snapshot missing required key "${e}"`);if(typeof o.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof o.nodes!="object"||o.nodes===null||Array.isArray(o.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(o.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(o.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function at(o,e){let t=new WeakMap,n=(s,r)=>{if(Object.is(s,r))return!0;if(s==null||r==null||typeof s!="object"||typeof r!="object")return!1;let i=t.get(s);if(i==null&&(i=new WeakSet,t.set(s,i)),i.has(r))return!0;i.add(r);let c=s.constructor,d=r.constructor;if(c!==d)return!1;if(s instanceof Date)return s.getTime()===r.getTime();if(s instanceof RegExp)return s.source===r.source&&s.flags===r.flags;if(Array.isArray(s)){let h=r;if(s.length!==h.length)return!1;for(let f=0;f<s.length;f++)if(!n(s[f],h[f]))return!1;return!0}if(s instanceof Map){let h=r;if(s.size!==h.size)return!1;for(let[f,u]of s)if(!h.has(f)||!n(u,h.get(f)))return!1;return!0}if(s instanceof Set){let h=r;if(s.size!==h.size)return!1;for(let f of s){let u=!1;for(let y of h)if(n(f,y)){u=!0;break}if(!u)return!1}return!0}if(ArrayBuffer.isView(s)){let h=s,f=r;if(h.length!==f.length)return!1;for(let u=0;u<h.length;u++)if(h[u]!==f[u])return!1;return!0}let a=Object.keys(s),p=Object.keys(r);if(a.length!==p.length)return!1;let g=new Set(p);for(let h of a)if(!g.has(h)||!n(s[h],r[h]))return!1;return!0};return n(o,e)}function ut(o){return o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ae(o){let e="^";for(let t=0;t<o.length;t+=1){let n=o[t];if(n==="*"){e+=".*";continue}if(n==="?"){e+=".";continue}if(n==="["){let s=o.indexOf("]",t+1);if(s<=t+1){e+="\\[";continue}let r=o.slice(t+1,s);r.startsWith("!")&&(r=`^${r.slice(1)}`),r=r.replace(/\\/g,"\\\\"),e+=`[${r}]`,t=s;continue}e+=ut(n)}return e+="$",new RegExp(e)}var ct={data:"\x1B[32m",dirty:"\x1B[33m",resolved:"\x1B[36m",invalidate:"\x1B[93m",pause:"\x1B[90m",resume:"\x1B[96m",complete:"\x1B[34m",error:"\x1B[31m",teardown:"\x1B[91m",derived:"\x1B[35m",path:"\x1B[90m",reset:"\x1B[0m"},dt={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function Ee(o){if(typeof o=="string")return JSON.stringify(o);if(typeof o=="number"||typeof o=="boolean"||o==null)return String(o);try{return JSON.stringify(o)}catch{return"[unserializable]"}}function lt(o){return o==="none"?dt:o==="ansi"||o==null?ct:{data:o.data??"",dirty:o.dirty??"",resolved:o.resolved??"",invalidate:o.invalidate??"",pause:o.pause??"",resume:o.resume??"",complete:o.complete??"",error:o.error??"",teardown:o.teardown??"",derived:o.derived??"",path:o.path??"",reset:o.reset??""}}function Ue(o){if(o==null)return{};let e=o.detail;return e==="full"?{...o,structured:o.structured??!0,timeline:o.timeline??!0,causal:o.causal??!0,derived:o.derived??!0}:e==="minimal"?{...o,structured:o.structured??!0}:o.format==="stage-log"?{...o,structured:o.structured??!0,timeline:o.timeline??!0}:o}function pt(o,e,t){for(let n=0;n<o.length;n++){let s=o.charCodeAt(n);if(s<32||s===127)throw new Error(`Graph "${e}": ${t} "${o}" must not contain control character (U+${s.toString(16).padStart(4,"0").toUpperCase()} at index ${n})`)}}function ke(o,e,t){if(o==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(o.includes(x))throw new Error(`Graph "${e}": ${t} "${o}" must not contain '${x}' (path separator)`);if(o===z)throw new Error(`Graph "${e}": ${t} name "${z}" is reserved for meta companion paths`);pt(o,e,t)}function ft(o,e){if(o==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=o.split(x);for(let n of t)if(n==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function ht(o,e){let t=!1;for(let s of o)if(!e.isMetaPassthrough(s[0])){t=!0;break}return t?o.filter(s=>e.isMetaPassthrough(s[0])):o}function Qe(o){for(let e of o._mounts.values())Qe(e);for(let e of o._nodes.values())try{e.down([[B]],{internal:!0})}catch{}}var Se=class o{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;_factory;_factoryArgs;constructor(e,t){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(x))throw new Error(`Graph name must not contain '${x}' (got "${e}")`);if(e===z)throw new Error(`Graph name "${z}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??me,this._traceRing=new X(t?.traceCapacity??1e3),t?.versioning!=null&&this.setVersioning(t.versioning),typeof t?.factory=="string"&&(this._factory=t.factory,t.factoryArgs!==void 0&&(this._factoryArgs=t.factoryArgs))}tagFactory(e,t){return this._factory=e,this._factoryArgs=t,this}ancestors(e=!0){let t=[],n=e?this:this._parent;for(;n!=null;)t.push(n),n=n._parent;return t}get topology(){return this._topology==null&&(this._topology=be(e=>{let t=n=>{e.emit(n)};return this._topologyEmitters.add(t),()=>{this._topologyEmitters.delete(t)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let t of this._topologyEmitters)t(e)}nameOf(e){return this._nodeToName.get(e)}add(e,t){let n=e.name,s=t?.name??n;if(s==null||s==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let r=s,i=t?.annotation;if(ke(r,this.name,"add"),this._mounts.has(r))throw new Error(`Graph "${this.name}": name "${r}" is already a mount point`);if(this._nodes.has(r))throw new Error(`Graph "${this.name}": node "${r}" already exists`);let c=this._nodeToName.get(e);if(c!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${c}"`);return this._nodes.set(r,e),this._nodeToName.set(e,r),this._emitTopology({kind:"added",name:r,nodeKind:"node"}),i!=null&&(this._annotations.set(r,i),this.config.inspectorEnabled&&this._traceRing.push({path:r,annotation:i,timestamp_ns:L()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof M&&t._applyVersioning(e)}remove(e){ke(e,this.name,"remove");let t=this._mounts.get(e);if(t){let r={kind:"mount",nodes:[],mounts:[]},i=[];t._collectObserveTargets("",i);for(let[c,d]of i)c.includes(`${x}${z}${x}`)||r.nodes.push(c);return r.nodes.sort(),r.mounts.push(e),r.mounts.push(...t._collectSubgraphs(`${e}${x}`)),this._mounts.delete(e),t._parent=void 0,Qe(t),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:r}),r}let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(n),n.down([[B]],{internal:!0});let s={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:s}),s}removeAll(e){let t=typeof e=="function"?e:(()=>{let r=ae(e);return i=>r.test(i)})(),n={kind:"mount",nodes:[],mounts:[]},s=[...this._nodes.keys(),...this._mounts.keys()].filter(r=>t(r));for(let r of s){let i=this.remove(r);n.nodes.push(...i.nodes),n.mounts.push(...i.mounts)}return n.nodes.sort(),n.mounts.sort(),n}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),t=this._nodes,n=0;return{[Symbol.iterator](){return this},next(){if(n>=e.length)return{value:void 0,done:!0};let s=e[n++];return{value:[s,t.get(s)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(x))return this.resolve(e);let t=this._nodes.get(e);if(!t)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return t}get(e){return this.node(e).cache}set(e,t,n){let s=n?.internal===!0;this.node(e).down([[q,t]],{actor:n?.actor,internal:s,delivery:"write"})}setAll(e,t){let n=Symbol.iterator in e?e:Object.entries(e);Te(()=>{for(let[s,r]of n)this.set(s,r,t)})}invalidate(e,t){let n=t?.internal===!0;this.node(e).down([[te]],{actor:t?.actor,internal:n,delivery:"write"})}error(e,t,n){let s=n?.internal===!0;this.node(e).down([[W,t]],{actor:n?.actor,internal:s,delivery:"write"})}complete(e,t){let n=t?.internal===!0;this.node(e).down([[H]],{actor:t?.actor,internal:n,delivery:"write"})}edges(e){let t=e?.recursive===!0,n=new Map;if(!t){for(let[d,a]of this._nodes)n.set(a,d);let c=[];for(let[d,a]of this._nodes)if(a instanceof M)for(let p of a._deps){let g=n.get(p.node);g!=null&&c.push([g,d])}return c.sort((d,a)=>d[0]<a[0]?-1:d[0]>a[0]?1:d[1]<a[1]?-1:d[1]>a[1]?1:0),c}let s=[];this._collectObserveTargets("",s);let r=new Map;for(let[c,d]of s)r.set(d,c);let i=[];for(let[c,d]of s)if(d instanceof M)for(let a of d._deps){let p=r.get(a.node);p!=null&&i.push([p,c])}return i.sort((c,d)=>c[0]<d[0]?-1:c[0]>d[0]?1:c[1]<d[1]?-1:c[1]>d[1]?1:0),i}mount(e,t){if(t===void 0){let s=new o(e);return this.mount(e,s)}if(typeof t=="function"){let s=new o(e);return t(s),this.mount(e,s)}let n=t;if(ke(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let s=this;s!=null;s=s._parent)if(s===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let t=ft(e,this.name);return this._resolveFromSegments(t)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let t=e;if(t[0]===this.name&&(t=t.slice(1),t.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let n=t[0],s=t.slice(1);if(s.length===0){let c=this._nodes.get(n);if(c)return c;throw this._mounts.has(n)?new Error(`Graph "${this.name}": path ends at subgraph "${n}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${n}"`)}let r=this._nodes.get(n);if(r&&s.length>0&&s[0]===z)return this._resolveMetaChainFromNode(r,s,t.join(x));let i=this._mounts.get(n);if(!i)throw this._nodes.has(n)?new Error(`Graph "${this.name}": "${n}" is a node; trailing path "${s.join(x)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${n}"`);return i.resolve(s.join(x))}_resolveMetaChainFromNode(e,t,n){let s=e,r=0,i=[...t];for(;r<i.length;){if(i[r]!==z)throw new Error(`Graph "${this.name}": expected ${z} segment in meta path "${n}"`);if(r+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${z} in "${n}"`);let c=i[r+1],d=s.meta[c];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${c}" in path "${n}"`);s=d,r+=2}return s}signal(e,t){if(t?.internal!==!0){for(let s of e)if(this.config.messageTier(s[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let n=[];if(this._signalDeliver(e,t??{},new Set,n),n.length>0)throw n[0]}_signalDeliver(e,t,n,s){for(let d of this._mounts.values())d._signalDeliver(e,t,n,s);let i=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},c=ht(e,this.config);for(let d of[...this._nodes.keys()].sort()){let a=this._nodes.get(d);if(!n.has(a)){n.add(a);try{a.down(e,i)}catch(p){if(p instanceof U)throw p;s.push(p)}c.length!==0&&this._signalMetaSubtree(a,c,n,i,s)}}}_signalMetaSubtree(e,t,n,s,r){for(let i of Object.keys(e.meta).sort()){let c=e.meta[i];if(!n.has(c)){n.add(c);try{c.down(t,s)}catch(d){if(d instanceof U)throw d;r.push(d)}this._signalMetaSubtree(c,t,n,s,r)}}}describe(e){if(e?.reactive==="diff")return this._describeReactiveDiff(e);if(e?.reactive===!0)return this._describeReactive(e);let t=ot(e?.actor),n=e?.filter;if(e?.detail!=null&&e?.fields!=null)throw new TypeError("Graph.describe(): pass either `detail` or `fields`, not both. `detail: 'spec'` is the canonical spec projection; use `fields` only when you need a custom subset.");let s=ye(e?.detail,e?.fields),r=e?.detail==="spec",i=s,c=[];this._collectObserveTargets("",c);let d=new Map;for(let[v,w]of c)d.set(w,v);let a=[];{let v=c.map(([,S])=>S),w=new Set(d.values()),E=0;for(;v.length>0;){let S=v.shift();if(S instanceof M)for(let R of S._deps){let G=R.node;if(d.has(G))continue;let D=G.name??"",k=D;if(!k||w.has(k))if(D){let I=2;for(;w.has(`${D}#${I}`);)I++;k=`${D}#${I}`}else for(k=`__internal__/${E++}`;w.has(k);)k=`__internal__/${E++}`;d.set(G,k),w.add(k),a.push([k,G]),v.push(G)}}}let p=[...c,...a],g={};for(let[v,w]of p){if(t!=null&&!w.allowsObserve(t))continue;let E=we(w,i,r),S=w instanceof M?w._deps.map(k=>d.get(k.node)??k.node.name??""):[],{name:R,...G}=E,D={...G,deps:S};if(!r){let k=this._annotations.get(v);k!=null&&(D.annotation=k)}if(n!=null)if(typeof n=="function"){let k=n;if(!(k.length>=2?k(v,D):k(D)))continue}else{let k=!0;for(let[I,T]of Object.entries(n)){let $=I==="deps_includes"?"depsIncludes":I==="meta_has"?"metaHas":I;if($==="depsIncludes"){if(!D.deps.includes(String(T))){k=!1;break}continue}if($==="metaHas"){if(!Object.hasOwn(D.meta??{},String(T))){k=!1;break}continue}if(D[$]!==T){k=!1;break}}if(!k)continue}g[v]=D}let h=new Set(Object.keys(g)),f=[];for(let[v,w]of p)if(w instanceof M)for(let E of w._deps){let S=d.get(E.node);S!=null&&f.push([S,v])}f.sort((v,w)=>v[0]<w[0]?-1:v[0]>w[0]?1:v[1]<w[1]?-1:v[1]>w[1]?1:0);let u=f.map(([v,w])=>({from:v,to:w}));(t!=null||n!=null)&&(u=u.filter(v=>h.has(v.from)&&h.has(v.to)));let y=this._collectSubgraphs(""),l=t!=null||n!=null?y.filter(v=>{let w=`${v}${x}`;return[...h].some(E=>E===v||E.startsWith(w))}):y,O=this,m=e;return{name:this.name,nodes:g,edges:u,subgraphs:l,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(v){let w={...m};return Array.isArray(v)?(w.fields=v,w.detail=void 0):(w.detail=v,w.fields=void 0),O.describe(w)}}}_collectSubgraphs(e){let t=[];for(let n of[...this._mounts.keys()].sort()){let s=e===""?n:`${e}${n}`;t.push(s),t.push(...this._mounts.get(n)._collectSubgraphs(`${s}${x}`))}return t}resourceProfile(e){return Ve(this,e)}reachable(e,t,n={}){return n.withDetail===!0?Je(this.describe(),e,t,{...n,withDetail:!0}):Je(this.describe(),e,t,n)}explain(e,t,n){return n?.reactive===!0?this._explainReactive(e,t,n):this._explainStatic(V(e),V(t),{...n?.maxDepth!==void 0?{maxDepth:Ke(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:He(n.findCycle)}:{}})}_explainStatic(e,t,n){let s=this.describe({detail:"full"}),r=new Map(this._annotations),i=new Map;for(let[c,d]of Object.entries(s.nodes))d.lastMutation!=null&&i.set(c,d.lastMutation);return Fe(s,e,t,{...n?.maxDepth!=null?{maxDepth:n.maxDepth}:{},...n?.findCycle===!0?{findCycle:!0}:{},annotations:r,lastMutations:i})}_describeReactive(e){let t={...e,reactive:!1},n=e.reactiveName??"describe",s=0,r=Z(s,{name:`${n}_version`}),i=this.observe({timeline:!0,structured:!0}),c=!1,d=!1,a=()=>{c||d||(c=!0,ne(()=>{c=!1,!d&&(s+=1,r.emit(s))}))},p=i.onEvent(m=>{let b=m.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||a()}),g=[],h=new WeakSet,f=m=>{if(h.has(m)||d)return;h.add(m);let b=m.topology.subscribe(v=>{for(let w of v){if(w[0]!==q)continue;let E=w[1];if(a(),E.kind==="added"&&E.nodeKind==="mount"){let S=m._mounts.get(E.name);S!=null&&f(S)}}});g.push(b);for(let v of m._mounts.keys()){let w=m._mounts.get(v);w!=null&&f(w)}};f(this);let u,y=e.actor;Ye(y)&&(u=y.subscribe(m=>{let b=!1,v=!1;for(let w of m){let E=w[0];E===q?b=!0:(E===H||E===W||E===B)&&(v=!0)}b&&a(),v&&(u?.(),u=void 0,a())}));let l;try{l=ve([r],()=>this.describe(t),{name:n,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(m,b)=>m===b})}catch(m){p(),u?.();for(let b of g)b();throw i.dispose(),m}let O=re(l);return{node:l,dispose(){d=!0,p(),u?.();for(let m of g)m();g.length=0,i.dispose(),O()}}}_describeReactiveDiff(e){let t={...e,reactive:!1},n=e.reactiveName??"describe-diff",s={name:this.name,nodes:{},edges:[],subgraphs:[]},r=this.describe(t),i=_e(s,r),c=Z(i,{name:n,meta:{domain:"audit",kind:"describe-diff"},equals:(h,f)=>h===f}),d=this._describeReactive({...e,reactiveName:void 0}),a=!1,p=d.node.subscribe(h=>{if(!a)for(let f of h){if(f[0]!==q)continue;let u=f[1],y=_e(r,u);r=u,y.events.length!==0&&c.emit(y)}}),g=re(c);return{node:c,dispose(){a=!0,p(),d.dispose(),c.down([[B,"describe-diff disposed"]]),g()}}}_explainReactive(e,t,n){let s=0,r=Z(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),c=!1,d=!1,a=()=>{c||d||(c=!0,ne(()=>{c=!1,!d&&(s+=1,r.emit(s))}))},p=i.onEvent(m=>{let b=m.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||a()}),g=[];e!=null&&K(e)&&g.push(e),t!=null&&K(t)&&g.push(t),n?.maxDepth!=null&&K(n.maxDepth)&&g.push(n.maxDepth),n?.findCycle!=null&&K(n.findCycle)&&g.push(n.findCycle);let h=()=>{for(let m of g)if(m.cache===void 0)return!1;return!0},f=()=>{let m=V(e),b=V(t);return{from:m,to:b,found:!1,reason:"pending",steps:[],text:"(awaiting reactive args)",toJSON:()=>({from:m,to:b,found:!1,reason:"pending",steps:[]})}},u;try{u=ve([r],()=>{if(!h())return f();let m=V(e),b=V(t),v={...n?.maxDepth!==void 0?{maxDepth:Ke(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:He(n.findCycle)}:{}};return this._explainStatic(m,b,v)},{name:n?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:V(e),to:V(t)},equals:(m,b)=>m.found===b.found&&m.reason===b.reason&&m.steps.length===b.steps.length&&mt(m.steps,b.steps)})}catch(m){throw p(),i.dispose(),m}let y=re(u),l=[],O=m=>{let b;return b=m.subscribe(v=>{let w=!1,E=!1;for(let S of v){let R=S[0];R===q?w=!0:(R===H||R===W||R===B)&&(E=!0)}(w||E)&&a(),E&&b&&(b(),b=void 0)}),()=>{b&&(b(),b=void 0)}};for(let m of g)l.push(O(m));return{node:u,dispose(){d=!0,p();for(let m of l)m?.();l.length=0,i.dispose(),y()}}}_pathsMatching(e){let t=ae(e),n=[];return this._collectObserveTargets("",n),n.map(([s])=>s).filter(s=>t.test(s))}_collectObserveTargets(e,t){for(let n of[...this._mounts.keys()].sort()){let s=e===""?n:`${e}${x}${n}`;this._mounts.get(n)._collectObserveTargets(s,t)}for(let n of[...this._nodes.keys()].sort()){let s=this._nodes.get(n),r=e===""?n:`${e}${x}${n}`;t.push([r,s]),this._appendMetaObserveTargets(r,s,t)}}_appendMetaObserveTargets(e,t,n){for(let s of Object.keys(t.meta).sort()){let r=t.meta[s],i=`${e}${x}${z}${x}${s}`;n.push([i,r]),this._appendMetaObserveTargets(i,r,n)}}observe(e,t){let n=typeof e=="string",r=Ue(n?t:e);if(r.reactive===!0)return this._observeReactive(n?e:void 0,r);let i=r.structured===!0||r.timeline===!0||r.causal===!0||r.derived===!0||r.detail==="minimal"||r.detail==="full"||r.format!=null,c=r.actor;if(n){let p=e,g=this.resolve(p);if(c!=null&&!g.allowsObserve(c))throw new U({actor:c,action:"observe",nodeName:p});return i?this._buildStructuredObserver([[p,g]],r,"one"):{subscribe(h){return g.subscribe(h)},up(h){try{g.up?.(h)}catch(f){if(f instanceof U)return;throw f}}}}let d=[];this._collectObserveTargets("",d),d.sort((p,g)=>p[0]<g[0]?-1:p[0]>g[0]?1:0);let a=c==null?d:d.filter(([,p])=>p.allowsObserve(c));return i?this._buildStructuredObserver(a,r,"all"):{subscribe:p=>{let g=a.map(([h,f])=>f.subscribe(u=>{p(h,u)}));return()=>{for(let h of g)h()}},up:(p,g)=>{try{this.resolve(p).up?.(g)}catch(h){if(h instanceof U)return;throw h}}}}_observeReactive(e,t){let n=t.tiers,s=n!=null?new Set(n):null,r=t.reactiveName??"observe";return be(i=>{let c=[],d=!1,a=!1,p=()=>{if(c.length===0||a)return;let y={events:c.slice(),flushedAt_ns:L()};c.length=0,i.emit(y)},g={...t,reactive:!1,structured:!0,timeline:!0},h=e!=null?this.observe(e,g):this.observe(g),f=y=>{a||(c.push(y),!d&&(d=!0,ne(()=>{d=!1,p()})))};for(let y of h.events)f(y);let u=h.onEvent(f);return()=>{a=!0,u(),h.dispose()}},{name:r,meta:{domain:"audit",kind:"observe-reactive"}})}_buildStructuredObserver(e,t,n){let s=n==="one"?e[0]?.[0]:void 0,r=i=>{if(n==="one"&&s!=null){let p=this.resolve(s);return this._buildStructuredObserver([[s,p]],i,"one")}let c=[];this._collectObserveTargets("",c),c.sort((p,g)=>p[0]<g[0]?-1:p[0]>g[0]?1:0);let d=i.actor,a=d==null?c:c.filter(([,p])=>p.allowsObserve(d));return this._buildStructuredObserver(a,i,"all")};return this._createObserveResult(e,t,r)}_createObserveResult(e,t,n){let s=t.timeline===!0,r=t.causal===!0,i=t.derived===!0,c=t.detail==="minimal",d=this.config.inspectorEnabled,a=(r||i)&&d,p=t.maxEvents,g=p!=null&&p>0?new X(p):null,h=[],f=new Set,u=t.tiers!=null?new Set(t.tiers):null,y={},l=new Set,O=0,m=0,b=0,v=0,w=0,E=0,S=!1,R=!1,G=0,D=new Map,k=new Map,I=new Map,T=_=>{if(!(u!=null&&!u.has(_.type))){g?g.push(_):h.push(_);for(let C of f)C(_)}},$=_=>u==null||u.has(_),Re=()=>s?{timestamp_ns:L(),in_batch:Ae(),batch_id:G}:{},Ze=(_,C)=>{if(!(!a||!(_ instanceof M)))return _._setInspectorHook(j=>{if(j.kind==="dep_message")D.set(_,j.depIndex);else if(j.kind==="run"){let Y=j.batchData.map((N,P)=>N!=null&&N.length>0?N.at(-1):j.prevData[P]);k.set(_,Y);let F=j.batchData.map(N=>N!=null?[...N]:void 0);I.set(_,F),i&&T({type:"derived",path:C,dep_values:Y,dep_batches:F,...Re()})}})},Ne=_=>{let C=D.get(_),j=k.get(_);if(!r||j==null)return{};let F=(C!=null&&C>=0&&_ instanceof M?_._deps[C]:void 0)?.node,N=F?.v,P=I.get(_);return{trigger_dep_index:C,trigger_dep_name:F?.name,...N!=null?{trigger_version:{id:N.id,version:N.version}}:{},dep_values:[...j],...P!=null?{dep_batches:P}:{}}},Ge=[],De=[];for(let[_,C]of e){let j=Ze(C,_);j&&Ge.push(j),De.push(C.subscribe(Y=>{G++;for(let F of Y){let N=F[0],P=Re();if(N===q){y[_]=F[1];let le=C instanceof M?C.lastMutation?.actor??Q:Q;T({type:"data",path:_,data:F[1],actor:le,...P,...Ne(C)})}else if(c)N===pe?$("dirty")&&O++:N===fe?$("resolved")&&m++:N===te?$("invalidate")&&b++:N===he?$("pause")&&v++:N===ge?$("resume")&&w++:N===B?$("teardown")&&E++:N===H&&!l.has(_)?$("complete")&&(S=!0):N===W&&$("error")&&(R=!0,l.add(_));else if(N===pe)$("dirty")&&O++,T({type:"dirty",path:_,...P});else if(N===fe)$("resolved")&&m++,T({type:"resolved",path:_,...P,...Ne(C)});else if(N===te)$("invalidate")&&b++,T({type:"invalidate",path:_,...P});else if(N===he)$("pause")&&v++,T({type:"pause",path:_,lockId:F[1],...P});else if(N===ge)$("resume")&&w++,T({type:"resume",path:_,lockId:F[1],...P});else if(N===H)$("complete")&&!l.has(_)&&(S=!0),T({type:"complete",path:_,...P});else if(N===W){$("error")&&(R=!0,l.add(_));let le=C instanceof M?C.lastMutation?.actor??Q:Q;T({type:"error",path:_,data:F[1],actor:le,...P})}else N===B&&($("teardown")&&E++,T({type:"teardown",path:_,...P}))}}))}let ue=!1,ce=()=>{if(!ue){ue=!0;for(let _ of De)_();for(let _ of Ge)_();for(let _ of ee)_({value:void 0,done:!0});ee.length=0}},de=[],ee=[];f.add(_=>{let C=ee.shift();C?C({value:_,done:!1}):de.push(_)});let Ce={get values(){return y},get dirtyCount(){return O},get resolvedCount(){return m},get invalidateCount(){return b},get pauseCount(){return v},get resumeCount(){return w},get teardownCount(){return E},get events(){return g?g.toArray():[...h]},get anyCompletedCleanly(){return S},get anyErrored(){return R},get completedWithoutErrors(){return S&&!R},onEvent(_){return f.add(_),()=>f.delete(_)},dispose:ce,expand(_){ce();let C={...t};return typeof _=="string"?C.detail=_:Object.assign(C,_),n(Ue(C))},[Symbol.asyncIterator](){return{next(){return de.length>0?Promise.resolve({value:de.shift(),done:!1}):ue?Promise.resolve({value:void 0,done:!0}):new Promise(_=>ee.push(_))},return(){return ce(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(Ce,t),Ce}_attachFormatLogger(e,t){let n=t.format;if(n==null)return;let s=t.logger??(u=>console.log(u)),r=t.includeTypes?new Set(t.includeTypes):null,i=t.excludeTypes?new Set(t.excludeTypes):null,c=r==null&&i==null?()=>!0:u=>(r==null||r.has(u))&&(i==null||!i.has(u)),d=lt(t.theme),a=n==="stage-log"?L():0,p=u=>u==null?"":t.stageLabels?.[u]??u,g=(u,y)=>u.length>y?`${u.slice(0,y-1)}\u2026`:u,h=u=>u.type==="data"||u.type==="error"?g(Ee(u.data),120):"",f=u=>{if(n==="stage-log"){let S=(L()-a)/1e9,R=p(u.path).padEnd(9);if(u.type==="data"){let G=h(u);return`[${S.toFixed(3)}s] ${R} \u2190${G?` ${G}`:""}`}if(u.type==="error"){let G=h(u);return`[${S.toFixed(3)}s] ${R} \u2717${G?` ${G}`:""}`}return u.type==="complete"?`[${S.toFixed(3)}s] ${R} \u25A0 complete`:`[${S.toFixed(3)}s] ${R} ${u.type}`}if(n==="json")try{return JSON.stringify(u)}catch{return JSON.stringify({type:u.type,path:u.path,data:"[unserializable]"})}let y=d[u.type]??"",l=u.path?`${d.path}${u.path}${d.reset} `:"",O=u.type==="data"||u.type==="error",m=u.type==="pause"||u.type==="resume",b=O?` ${Ee(u.data)}`:m?` ${Ee(u.lockId)}`:"",v=u.type==="data"||u.type==="resolved"||u.type==="derived"?u:void 0,w=v?.trigger_dep_name!=null?` <- ${v.trigger_dep_name}`:v?.trigger_dep_index!=null?` <- #${v.trigger_dep_index}`:"",E=u.in_batch?" [batch]":"";return`${l}${y}${u.type.toUpperCase()}${d.reset}${b}${w}${E}`};e.onEvent(u=>{c(u.type)&&s(f(u),u)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){qe(this._disposers,this.name),this.signal([[B]],{internal:!0}),qe(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand:t,...n}=this.describe({detail:"full"}),s={};for(let c of Object.keys(n.nodes).sort()){let{lastMutation:d,guard:a,...p}=n.nodes[c];s[c]=p}let r=[...n.subgraphs].sort(),i={...n,version:1,nodes:s,subgraphs:r};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let c=this.config.lookupCodec(e.codec);if(c==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return xe(c,c.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let n=t?.config??me,{codec:s,codecVersion:r,payload:i}=$e(e,n);return s.decode(i,r)}restore(e,t){if(We(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let n=t?.only==null?null:(Array.isArray(t.only)?t.only:[t.only]).map(r=>ae(r)),s=t?.includeProducers===!0;for(let r of Object.keys(e.nodes).sort()){if(n!==null&&!n.some(c=>c.test(r)))continue;let i=e.nodes[r];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&t?.onError?.(r,new Error(`restore: slice.value is undefined for "${r}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!s)){if(i.v!=null){let d=this.tryResolve(r)?.v;if(d!=null&&d.id===i.v.id&&d.version===i.v.version)continue}try{this.set(r,i.value)}catch(c){t?.onError?.(r,c)}}}}}static fromSnapshot(e,t){We(e);let n=typeof t=="function"?t:t?.build,s=typeof t=="function"?void 0:t?.factories,r=new o(e.name);if(n)return n(r),r.restore(e),r;for(let f of[...e.subgraphs].sort((u,y)=>{let l=u.split(x).length,O=y.split(x).length;return l!==O?l-O:u<y?-1:u>y?1:0})){let u=f.split(x),y=r;for(let l of u)y._mounts.has(l)||y.mount(l,new o(l)),y=y._mounts.get(l)}let i=s?Object.entries(s).map(([f,u])=>({re:ae(f),factory:u})):[],c=f=>{for(let u of i)if(u.re.test(f))return u.factory},d=f=>{let u=f.split(x),y=u.pop();if(y==null||y.length===0)throw new Error(`invalid snapshot path "${f}"`);let l=r;for(let O of u){let m=l._mounts.get(O);if(!m)throw new Error(`unknown mount "${O}" in path "${f}"`);l=m}return[l,y]},a=Object.entries(e.nodes).filter(([f])=>!f.includes(`${x}${z}${x}`)).sort((f,u)=>f[0]<u[0]?-1:f[0]>u[0]?1:0),p=new Map(a),g=new Map,h=!0;for(;p.size>0&&h;){h=!1;for(let[f,u]of[...p.entries()]){let y=u?.deps??[];if(!y.every(w=>g.has(w)))continue;let[l,O]=d(f),m={...u?.meta??{}},b=c(f),v;if(u?.type==="state")v=Z(u.value,{meta:m});else{if(b==null)continue;v=b(O,{path:f,type:u.type,value:u.value,meta:m,deps:y,resolvedDeps:y.map(w=>g.get(w))})}l.add(v,{name:O}),g.set(f,v),p.delete(f),h=!0}}if(p.size>0){let f=[...p.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${f}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return r.restore(e),r}toJSON(){return this.snapshot()}attachSnapshotStorage(e,t={}){let n=e.map(a=>({tier:a,debounceMs:Math.max(0,a.debounceMs??0),compactEvery:Math.max(1,a.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));t.autoRestore===!0&&this._cascadeRestore(e,t.onError);let s=(a,p)=>{if(a.disposed)return;let g=it(p.nodes);if(a.lastSnapshot!=null&&g!==""&&g===a.lastFingerprint)return;let h=a.seq+1,f=Pe(),l=a.lastSnapshot==null||h%a.compactEvery===0?{name:this.name,mode:"full",snapshot:p,seq:h,timestamp_ns:f,format_version:J}:{name:this.name,mode:"diff",diff:gt(a.lastSnapshot,p),seq:h,timestamp_ns:f,format_version:J};if(a.tier.filter&&!a.tier.filter(l))return;let O;try{O=a.tier.save(l)}catch(m){t.onError?.(m,a.tier);return}if(O&&typeof O.then=="function"){let v=(a.savePending??Promise.resolve()).then(()=>O,()=>O).then(()=>{a.disposed||(a.seq=h,a.lastSnapshot=p,a.lastFingerprint=g)},w=>{t.onError?.(w,a.tier)});a.savePending=v.finally(()=>{a.savePending===v&&(a.savePending=void 0)})}else a.seq=h,a.lastSnapshot=p,a.lastFingerprint=g},r=(a,p)=>{try{s(a,p)}catch(g){t.onError?.(g,a.tier)}},i=(a,p)=>{if(!p.some(u=>{let y=this.config.messageTier(u[0]);return y>=3&&y<5}))return;if(t.filter){let u=this.tryResolve(a);if(u==null)return;let y=we(u,ye("standard"));if(!t.filter(a,y))return}let h,f=()=>(h==null&&(h=this.snapshot()),h);for(let u of n)u.disposed||(u.debounceMs===0?r(u,f()):(u.timer==null&&(u.timer=new Me),u.timer.start(u.debounceMs,()=>{u.disposed||r(u,this.snapshot())})))},c;if(t.paths!=null){let p=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(g=>{let h=this.tryResolve(g);return h==null?()=>{}:h.subscribe(f=>i(g,f))});c=()=>{for(let g of p)g()}}else c=this.observe().subscribe((a,p)=>i(a,p));let d=()=>{c();for(let a of n)a.disposed=!0,a.timer?.cancel();this._storageDisposers.delete(d)};return this._storageDisposers.add(d),{dispose:d}}async _cascadeRestore(e,t){for(let n of e){let s;try{s=await n.load?.()}catch(i){t?.(i,n);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let r=s;try{if(r.mode==="full"&&r.snapshot!=null)return this.restore(r.snapshot),!0;if(r.version===J&&r.nodes!=null)return this.restore(r),!0}catch(i){t?.(i,n)}}return!1}static async fromStorage(e,t,n){for(let s of t){let r;try{r=await s.load?.()}catch(d){n?.onError?.(d,s);continue}if(r==null||typeof r!="object"||Array.isArray(r))continue;let i=r,c=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===J&&i.nodes!=null?i:void 0;if(c!=null)try{return o.fromSnapshot(c,n)}catch(d){n?.onError?.(d,s)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${t.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,t,n){if(e!=null&&t!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,t),this.config.inspectorEnabled){let s={path:e,annotation:t,timestamp_ns:L(),...n?.actor!=null?{actor:n.actor}:{}};this._traceRing.push(s)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let t=this._traceRing.toArray().filter(s=>!e(s)),n=this._traceRing.size-t.length;this._traceRing.clear();for(let s of t)this._traceRing.push(s);return n}static diff(e,t){let n=new Set(Object.keys(e.nodes)),s=new Set(Object.keys(t.nodes)),r=[...s].filter(m=>!n.has(m)).sort(),i=[...n].filter(m=>!s.has(m)).sort(),c=[],d=[];for(let m of n){if(!s.has(m))continue;let b=e.nodes[m],v=t.nodes[m],w=b.v,E=v.v;w!=null&&E!=null&&w.id===E.id&&w.version!==E.version&&d.push({path:m,id:w.id,from:w.version,to:E.version});let S=w!=null&&E!=null&&w.id===E.id&&w.version===E.version;for(let R of["type","status","sentinel"]){let G=b[R],D=v[R];G!==D&&c.push({path:m,field:R,from:G,to:D})}if(!S)for(let R of["value","meta"]){let G=b[R],D=v[R];at(G,D)||c.push({path:m,field:R,from:G,to:D})}}let a=m=>`${m.from} ${m.to}`,p=new Set(e.edges.map(a)),g=new Set(t.edges.map(a)),h=t.edges.filter(m=>!p.has(a(m))),f=e.edges.filter(m=>!g.has(a(m))),u=new Set(e.subgraphs),y=new Set(t.subgraphs),l=[...y].filter(m=>!u.has(m)).sort(),O=[...u].filter(m=>!y.has(m)).sort();return{nodesAdded:r,nodesRemoved:i,nodesChanged:c,versionChanges:d,edgesAdded:h,edgesRemoved:f,subgraphsAdded:l,subgraphsRemoved:O}}};function gt(o,e){let t=Se.diff(o,e),n={};for(let s of t.nodesAdded){let r=e.nodes[s];r!=null&&(n[s]=r)}return{...t,nodesAddedFull:n}}function Je(o,e,t,n={}){let s={paths:[],depths:new Map,truncated:!1};if(!e)return n.withDetail?s:[];if(!n.both&&t!=="upstream"&&t!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let r=n.maxDepth;if(r!=null&&(!Number.isInteger(r)||r<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(r===0)return n.withDetail?s:[];let i=new Map,c=new Map,d=new Map,a=new Map,p=new Set;for(let[b,v]of Object.entries(o.nodes)){if(!b)continue;p.add(b);let w=v.deps??[];i.set(b,w);for(let E of w)E&&(p.add(E),c.has(E)||c.set(E,new Set),c.get(E).add(b))}for(let b of o.edges){if(b==null||typeof b!="object")continue;let v=typeof b.from=="string"?b.from:"",w=typeof b.to=="string"?b.to:"";!v||!w||(p.add(v),p.add(w),a.has(v)||a.set(v,new Set),a.get(v).add(w),d.has(w)||d.set(w,new Set),d.get(w).add(v))}if(!p.has(e))return n.withDetail?s:[];let g=n.both===!0,h=b=>{if(g){let S=i.get(b)??[],R=d.get(b),G=c.get(b),D=a.get(b),k=[...S];return R&&k.push(...R),G&&k.push(...G),D&&k.push(...D),k}if(t==="upstream"){let S=i.get(b)??[],R=d.get(b);return R?[...S,...R]:S}let v=c.get(b),w=a.get(b),E=v?[...v]:[];return w&&E.push(...w),E},f=new Set([e]),u=new Map,y=[{path:e,depth:0}],l=0,O=!1;for(;l<y.length;){let b=y[l++];if(r!=null&&b.depth>=r){h(b.path).length>0&&(O=!0);continue}for(let v of h(b.path))!v||f.has(v)||(f.add(v),u.set(v,b.depth+1),y.push({path:v,depth:b.depth+1}))}let m=[...u.keys()].sort((b,v)=>b<v?-1:b>v?1:0);return n.withDetail?{paths:m,depths:u,truncated:O}:m}function mt(o,e){if(o.length!==e.length)return!1;for(let t=0;t<o.length;t++){let n=o[t],s=e[t];if(n.path!==s.path||n.type!==s.type||n.status!==s.status||n.hop!==s.hop||n.dep_index!==s.dep_index||n.annotation!==s.annotation||n.value!==s.value||n.lastMutation!==s.lastMutation)return!1;let r=n.v,i=s.v;if(r!==i&&(r==null||i==null||r.id!==i.id||r.version!==i.version))return!1}return!0}export{A as a,Xe as b,je as c,Fe as d,_e as e,X as f,Ve as g,z as h,J as i,Se as j,gt as k,Je as l};
@@ -0,0 +1 @@
1
+ import{t as I,x as w}from"./chunk-VOPGGIL7.js";import{c as O}from"./chunk-35JTVPOX.js";import{b as E}from"./chunk-TZQPPQEQ.js";import{m as f,s as M}from"./chunk-V5A7M7RJ.js";import{E as R,G as V,m as h}from"./chunk-LYCLF26R.js";import{b as v}from"./chunk-CK2E7BTU.js";function C(n){return typeof n=="object"&&n!==null&&"cache"in n&&typeof n.subscribe=="function"}function H(n,u,e){let i=f(n),o=i.v!=null,p=R(e?.initialVerified??null,{meta:{...O("verifiable"),...o?{sourceVersion:null}:{}}}),x=e?.trigger!==void 0&&e.trigger!==null,c=null;if(x&&e?.autoVerify?c=I(f(e.trigger),i):x?c=f(e.trigger):e?.autoVerify&&(c=i),c!==null){let y;if(c===i)y=w(i,l=>u(l));else{let l=i.cache;i.subscribe(m=>{for(let N of m)N[0]===v&&(l=N[1])}),y=w(c,()=>u(l))}M(y,l=>{h(()=>{if(p.down([[v,l]]),o){let m=i.v;m!=null&&p.meta.sourceVersion.down([[v,{id:m.id,version:m.version}]])}})})}return{node:i,verified:p,trigger:c}}function B(n){n.subscribe(()=>{})}function k(n){return n instanceof Map?n:new Map}function S(n,u){if(!Array.isArray(u.upsert))throw new TypeError("distill extraction requires upsert: Array<{ key, value }>");h(()=>{for(let{key:e,value:i}of u.upsert)n.set(e,i);for(let e of u.remove??[])n.delete(e)})}function J(n,u,e){let i=f(n),o=E(e.mapOptions??{}),p=e.budget??2e3,c=e.context!==void 0&&e.context!==null?f(e.context):R(null),y=k(o.entries.cache);o.entries.subscribe(t=>{for(let d of t)d[0]===v&&(y=k(d[1]))});let l=f(u(i,o.entries));if(M(l,t=>{S(o,t)}),e.evict){let t=new Map,d=V([o.entries],([g])=>{let T=[],b=k(g);for(let r of t.keys())b.has(r)||(t.get(r)(),t.delete(r));for(let[r,s]of b){let a=e.evict(r,s);if(C(a)){if(!t.has(r)){let D=M(a,z=>{z===!0&&o.has(r)&&o.delete(r)});t.set(r,D)}continue}if(typeof a=="boolean"){a&&T.push(r);continue}throw new TypeError("distill evict() must return boolean or Node<boolean>")}return T});M(d,g=>{for(let T of g)o.delete(T)})}let m=e.consolidateTrigger!==void 0&&e.consolidateTrigger!==null;if(e.consolidate&&m){let t=f(e.consolidateTrigger),d=w(t,()=>e.consolidate(y));M(d,g=>{S(o,g)})}let N=V([o.entries,c],([t,d])=>{let T=[...k(t).entries()].map(([s,a])=>({key:s,value:a,score:e.score(a,d),cost:e.cost(a)}));T.sort((s,a)=>a.score-s.score);let b=[],r=p;for(let s of T)s.cost<=r&&(b.push({key:s.key,value:s.value,score:s.score}),r-=s.cost);return b},{meta:{...O("distill",{budget:p})}}),A=V([o.entries],([t])=>k(t).size);return B(N),B(A),{store:o,compact:N,size:A}}export{H as a,J as b};
@@ -1 +1 @@
1
- import{a as T}from"./chunk-VXPLLA4P.js";import{a as F}from"./chunk-L6NSJVJZ.js";import{i as y}from"./chunk-POXANAJ6.js";import{t as I}from"./chunk-AK5RHMC5.js";import{C as h}from"./chunk-L77I47VU.js";import{D as v,E as x,G as S,H as E,m as _}from"./chunk-LYCLF26R.js";import{b as R,i as O,j as k}from"./chunk-CK2E7BTU.js";import{b as A}from"./chunk-QYADASLV.js";var M={};A(M,{feedback:()=>G,funnel:()=>$,scorer:()=>q});function N(e,n){return F("reduction",e,n)}function $(e,n,t,l){if(n.length===0)throw new RangeError("funnel requires at least one source");if(t.length===0)throw new RangeError("funnel requires at least one stage");let r=new y(e,l),m=n.length===1?n[0]:I(...n);r.add(m,{name:"merged"});let a="merged";for(let c=0;c<t.length;c++){let o=t[c],s=new y(o.name);o.build(s);try{s.resolve("input")}catch{throw new Error(`funnel stage "${o.name}" must define an "input" node`)}try{s.resolve("output")}catch{throw new Error(`funnel stage "${o.name}" must define an "output" node`)}r.mount(o.name,s);let i=r.resolve(a),u=`${o.name}::input`,p=r.resolve(u),f=`__bridge_${a}\u2192${o.name}_input`,b=E([i],([d])=>{p.emit(d)},{name:f});r.add(b,{name:f}),r.addDisposer(h(b)),a=`${o.name}::output`}return r}function G(e,n,t,l){let r=l?.maxIterations??10,m=`__feedback_${n}`,a=x(0,{meta:N("feedback_counter",{maxIterations:r,feedbackFrom:n,feedbackTo:t})});e.add(a,{name:m});let c=e.resolve(n),o=e.resolve(t),s=`__feedback_effect_${n}`,i=v([],(u,p)=>{let f=c.subscribe(b=>{for(let d of b){let g=d[0];if(g===R){let w=d[1];if(w==null)return;_(()=>{T(a,r)&&o.emit(w)})}else if(g===O||g===k){let w=g===k&&d.length>1?[k,d[1]]:[g];a.down([w])}}});return()=>f()},{name:s,describeKind:"effect",meta:{...N("feedback_effect",{feedbackFrom:n,feedbackTo:t}),_internal:!0}});return e.add(i,{name:s}),e.addDisposer(h(i)),e}function q(e,n,t){if(e.length===0)throw new RangeError("scorer requires at least one source");if(e.length!==n.length)throw new RangeError("scorer requires the same number of sources and weights");let l=[...e,...n],r=e.length,m=t?.scoreFns;return S(l,a=>{let c=a.slice(0,r),o=a.slice(r),s=[],i=0;for(let u=0;u<r;u++){let p=c[u]??0,f=o[u]??0,d=(m?.[u]?m[u](p):p)*f;s.push(d),i+=d}return{value:c,score:i,breakdown:s}},{...t?{equals:t.equals,resubscribable:t.resubscribable,resetOnTeardown:t.resetOnTeardown}:{},describeKind:"derived",meta:N("scorer",t?.meta)})}export{$ as a,G as b,q as c,M as d};
1
+ import{a as I}from"./chunk-FDQGFWLF.js";import{a as F}from"./chunk-L6NSJVJZ.js";import{j as h}from"./chunk-626TESAC.js";import{t as T}from"./chunk-VOPGGIL7.js";import{C as y}from"./chunk-V5A7M7RJ.js";import{D as v,E as x,G as S,H as E,m as _}from"./chunk-LYCLF26R.js";import{b as R,i as O,j as k}from"./chunk-CK2E7BTU.js";import{b as A}from"./chunk-QYADASLV.js";var M={};A(M,{feedback:()=>G,funnel:()=>$,scorer:()=>q});function N(e,n){return F("reduction",e,n)}function $(e,n,t,l){if(n.length===0)throw new RangeError("funnel requires at least one source");if(t.length===0)throw new RangeError("funnel requires at least one stage");let r=new h(e,l),m=n.length===1?n[0]:T(...n);r.add(m,{name:"merged"});let a="merged";for(let c=0;c<t.length;c++){let o=t[c],s=new h(o.name);o.build(s);try{s.resolve("input")}catch{throw new Error(`funnel stage "${o.name}" must define an "input" node`)}try{s.resolve("output")}catch{throw new Error(`funnel stage "${o.name}" must define an "output" node`)}r.mount(o.name,s);let i=r.resolve(a),u=`${o.name}::input`,p=r.resolve(u),f=`__bridge_${a}\u2192${o.name}_input`,b=E([i],([d])=>{p.emit(d)},{name:f});r.add(b,{name:f}),r.addDisposer(y(b)),a=`${o.name}::output`}return r}function G(e,n,t,l){let r=l?.maxIterations??10,m=`__feedback_${n}`,a=x(0,{meta:N("feedback_counter",{maxIterations:r,feedbackFrom:n,feedbackTo:t})});e.add(a,{name:m});let c=e.resolve(n),o=e.resolve(t),s=`__feedback_effect_${n}`,i=v([],(u,p)=>{let f=c.subscribe(b=>{for(let d of b){let g=d[0];if(g===R){let w=d[1];if(w==null)return;_(()=>{I(a,r)&&o.emit(w)})}else if(g===O||g===k){let w=g===k&&d.length>1?[k,d[1]]:[g];a.down([w])}}});return()=>f()},{name:s,describeKind:"effect",meta:{...N("feedback_effect",{feedbackFrom:n,feedbackTo:t}),_internal:!0}});return e.add(i,{name:s}),e.addDisposer(y(i)),e}function q(e,n,t){if(e.length===0)throw new RangeError("scorer requires at least one source");if(e.length!==n.length)throw new RangeError("scorer requires the same number of sources and weights");let l=[...e,...n],r=e.length,m=t?.scoreFns;return S(l,a=>{let c=a.slice(0,r),o=a.slice(r),s=[],i=0;for(let u=0;u<r;u++){let p=c[u]??0,f=o[u]??0,d=(m?.[u]?m[u](p):p)*f;s.push(d),i+=d}return{value:c,score:i,breakdown:s}},{...t?{equals:t.equals,resubscribable:t.resubscribable,resetOnTeardown:t.resetOnTeardown}:{},describeKind:"derived",meta:N("scorer",t?.meta)})}export{$ as a,G as b,q as c,M as d};
@@ -0,0 +1 @@
1
+ import{a as T}from"./chunk-OYJKFY7V.js";import{a as k}from"./chunk-L6NSJVJZ.js";import{a as C}from"./chunk-KVV66NN2.js";import{j as N,l as W}from"./chunk-626TESAC.js";import{b as S}from"./chunk-35JTVPOX.js";import{b as Y}from"./chunk-JQFH2DV6.js";import{C as D}from"./chunk-V5A7M7RJ.js";import{C as Q,E,G as A,m as B,o as R,p as O,u as $,w as J}from"./chunk-LYCLF26R.js";import{b as P}from"./chunk-CK2E7BTU.js";import{b as ne}from"./chunk-QYADASLV.js";var ue={};ne(ue,{AuditTrailGraph:()=>L,GuardedExecutionGraph:()=>V,InspectGraph:()=>M,PolicyGateGraph:()=>j,auditTrail:()=>H,complianceSnapshot:()=>I,computeHealthReport:()=>te,graphLens:()=>z,guardedExecution:()=>de,healthReportEqual:()=>oe,inspect:()=>ce,policyGate:()=>K,watchTopologyTree:()=>C});function ee(o,e){return k("audit",o,e)}var ie=new Set(["data","error","complete","teardown"]),L=class extends N{entries;count;includeTypes;_log;_target;constructor(e,t){super(t.name??`${e.name}_audit`,t.graph),this._target=e,this._log=Y([],{name:"entries",...t.maxSize!=null?{maxSize:t.maxSize}:{}}),this.entries=this._log.entries,this.add(this.entries,{name:"entries"}),this.count=A([this.entries],([s])=>s.length,{name:"count",describeKind:"derived",meta:ee("count")}),this.add(this.count,{name:"count"}),this.addDisposer(D(this.count));let n=t.includeTypes!=null?new Set(t.includeTypes):new Set(ie);this.includeTypes=n;let r=t.filter,i=0,u=e.observe({timeline:!0,structured:!0}),h=u.onEvent(s=>{if(s.type==="derived")return;let d=s.type;if(!n.has(d))return;let y=s.path??"",g={seq:i++,timestamp_ns:s.timestamp_ns??R(),wall_clock_ns:O(),path:y,type:d},b=(y?F(e,y):void 0)?.lastMutation;b!=null&&(g.actor=b.actor),d==="data"&&(g.value=s.data),d==="error"&&(g.error=s.data);let l=y?re(e,y):void 0;l!=null&&(g.annotation=l),!(r!=null&&!r(g))&&this._log.append(g)});this.addDisposer(()=>{h(),u.dispose()}),this.addDisposer(()=>this._log.disposeAllViews())}all(){return this.entries.cache??[]}byNode(e){return this.all().filter(t=>t.path===e)}byActor(e){return this.all().filter(t=>t.actor?.id===e)}byActorType(e){return this.all().filter(t=>t.actor?.type===e)}byTimeRange(e,t){return this.all().filter(n=>!(n.timestamp_ns<e||t!=null&&n.timestamp_ns>=t))}get target(){return this._target}};function H(o,e={}){return new L(o,e)}var j=class extends N{policies;violations;violationCount;_target;_mode;_currentGuard;constructor(e,t,n){super(n.name??`${e.name}_policy`,n.graph),this._target=e,this._mode=n.mode??"audit";let r=X(t)?t:E(t,{name:"policies"});this.policies=r,this.add(this.policies,{name:"policies"}),this.violations=new T("violations",{retainedLimit:n.violationsLimit??1e3}),this.mount("violations",this.violations),this.violationCount=A([this.violations.events],([l])=>l.length,{name:"violationCount",describeKind:"derived",meta:ee("policy_violation_count")}),this.add(this.violationCount,{name:"violationCount"}),this.addDisposer(D(this.violationCount));let u=r.cache??[];this._currentGuard=$(u);let h=r.subscribe(l=>{for(let m of l)m[0]===P&&(u=m[1]??[],this._currentGuard=$(u))});this.addDisposer(h);let s=n.paths,d=X(s)?s:void 0,y=s!=null,w=d!=null?d.cache??[]:y?[...s]:void 0,b=w??Z(e);if(this._mode!=="enforce"&&d!=null){let l=d.subscribe(m=>{for(let a of m)a[0]===P&&(w=a[1]??[])});this.addDisposer(l)}if(this._mode==="enforce"){let l=new Map,m=a=>{if(l.has(a))return;let c=F(e,a);if(!(c instanceof Q))return;let _=(p,f)=>{let G=this._currentGuard(p,f);return G||this._publishViolation(p,f,a,"blocked"),G};l.set(a,c._pushGuard(_))};for(let a of b)m(a);if(d!=null){let a=d.subscribe(c=>{for(let _ of c){if(_[0]!==P)continue;let p=_[1]??[],f=new Set(p),G=new Set(w??[]);B(()=>{for(let v of G){if(f.has(v))continue;let x=l.get(v);x!=null&&(x(),l.delete(v))}for(let v of f)G.has(v)||m(v);w=p})}});this.addDisposer(a)}if(y){let a=e.topology.subscribe(c=>{for(let _ of c){if(_[0]!==P)continue;let p=_[1];if(p.kind!=="removed"||p.nodeKind!=="node")continue;let f=l.get(p.name);f!=null&&(f(),l.delete(p.name))}});this.addDisposer(a)}else{let a=C(e,(c,_,p)=>{if(c.kind==="added")if(c.nodeKind==="node")m(`${p}${c.name}`);else{let f=_._mounts.get(c.name);if(!(f instanceof N))return;let G=`${p}${c.name}::`,v=Z(f);for(let x of v)m(x===""?`${p}${c.name}`:`${G}${x}`)}else if(c.kind==="removed")if(c.nodeKind==="node"){let f=`${p}${c.name}`,G=l.get(f);G!=null&&(G(),l.delete(f))}else{let f=`${p}${c.name}`,G=`${f}::`;for(let[v,x]of l)(v===f||v.startsWith(G))&&(x(),l.delete(v))}});this.addDisposer(a)}this.addDisposer(()=>{for(let a of l.values())a();l.clear()})}else{let l=e.observe({timeline:!0,structured:!0}),m=l.onEvent(a=>{if(a.type!=="data"&&a.type!=="error")return;let c=a.path??"";if(!c||w!=null&&!w.includes(c))return;let _=a.actor??F(e,c)?.lastMutation?.actor;if(_==null)return;let p="write";this._currentGuard(_,p)||this._publishViolation(_,p,c,"observed")});this.addDisposer(()=>{m(),l.dispose()})}}_publishViolation(e,t,n,r){this.violations.publish({timestamp_ns:R(),wall_clock_ns:O(),path:n,actor:e,action:t,mode:this._mode,result:r})}all(){return this.violations.retained()}get mode(){return this._mode}get target(){return this._target}};function K(o,e,t={}){let n=new j(o,e,t);return n.tagFactory("policyGate",S(t)),n}function I(o,e={}){let t={format_version:1,timestamp_ns:R(),wall_clock_ns:O(),graph:o.snapshot()};if(e.actor!=null&&(t.actor=e.actor),e.audit!=null){let r=[...e.audit.all()];t.audit={count:r.length,entries:r}}if(e.policies!=null){let r=e.policies.policies.cache??[];t.policies={mode:e.policies.mode,rules:r,violations:[...e.policies.all()]}}let n=ae(t);return{...t,fingerprint:n}}function X(o){return typeof o=="object"&&o!==null&&"subscribe"in o}function F(o,e){try{return o.node(e)}catch{return}}function re(o,e){try{return o.annotation(e)}catch{return}}function Z(o){let e=o.describe({detail:"minimal"});return Object.keys(e.nodes)}function ae(o){return J(JSON.stringify(se(o)))}function se(o){let e=new Set,t=n=>{if(n===void 0)return{__undefined:!0};if(n===null)return null;let r=typeof n;if(r==="bigint")return{__bigint:n.toString()};if(r!=="object")return n;let i=n;if(e.has(i))return{__circular:!0};e.add(i);try{if(Array.isArray(i))return i.map(t);if(i instanceof Date)return{__date:i.toISOString()};if(i instanceof RegExp)return{__regexp:{source:i.source,flags:i.flags}};if(i instanceof Map)return{__map:[...i.entries()].map(([s,d])=>[t(s),t(d)])};if(i instanceof Set)return{__set:[...i].map(t)};if(ArrayBuffer.isView(i)){let h=i,s=new Array(h.length);for(let d=0;d<h.length;d++)s[d]=h[d]??0;return{__typed_array:{ctor:i.constructor.name,data:s}}}let u={};for(let h of Object.keys(i).sort())u[h]=t(i[h]);return u}finally{e.delete(i)}};return t(o)}function q(o){return typeof o=="object"&&o!==null&&"subscribe"in o&&"down"in o}function le(o){return k("guarded",o)}var V=class extends N{enforcer;violations;lints;scope;scopedDescribe;_target;_actorNode;_mode;_firedLintKinds=new Set;constructor(e,t){super(t.name??`${e.name}_guarded`,t.graph),this._target=e,this._mode=t.mode??"enforce";let n=t.policies,r=q(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 T("lints",{retainedLimit:t.lintsLimit??64}),this.mount("lints",this.lints);let i=t.actor;i==null?this._actorNode=E(null,{name:"actor"}):q(i)?this._actorNode=A([i],([s])=>s??null,{name:"actor",initial:null}):this._actorNode=E(i,{name:"actor"});let u={mode:this._mode,name:"enforcer"};if(t.violationsLimit!=null&&(u.violationsLimit=t.violationsLimit),this.enforcer=K(e,t.policies,u),this.violations=this.enforcer.violations,this.mount("enforcer",this.enforcer),r&&this._mode==="enforce"){let s=n,d=s.cache;d!=null&&d.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 y=s.subscribe(g=>{for(let w of g){if(w[0]!==P)continue;let b=w[1];(b==null||b.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(y)}if(this._mode==="audit"){let s=e.describe({detail:"full"});Object.values(s.nodes).some(y=>y.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.')}i==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=A([this._actorNode,this.enforcer.policies],([s,d])=>({actor:s??null,mode:this._mode,policiesCount:d.length}),{name:"scope",describeKind:"derived",meta:le("scope")}),this.add(this.scope,{name:"scope"}),this.addDisposer(D(this.scope));let h=e.describe({reactive:!0,actor:this._actorNode,reactiveName:"scopedDescribe"});this.scopedDescribe=h.node,this.add(this.scopedDescribe,{name:"scopedDescribe"}),this.addDisposer(h.dispose)}_fireLint(e,t){this._firedLintKinds.has(e)||(this._firedLintKinds.add(e),this.lints.publish({kind:e,message:t,timestamp_ns:R()}))}scopedDescribeNode(e,t){let n=e==null?this._actorNode:q(e)?e:E(e,{name:"actor_override"}),r=this._target.describe({reactive:!0,actor:n,...t??{}});return this.addDisposer(r.dispose),{node:r.node,dispose:r.dispose}}get target(){return this._target}};function de(o,e){return new V(o,e)}function te(o){let e=[];for(let[t,n]of Object.entries(o.nodes)){if(n.status!=="errored")continue;let r={path:t,status:"errored"},i=W(o,t,"upstream",{});for(let u of i)if(u!==t&&o.nodes[u]?.status==="errored"){r.upstreamCause=u;break}e.push(r)}return e.sort((t,n)=>t.path<n.path?-1:t.path>n.path?1:0),{ok:e.length===0,problems:e}}function oe(o,e){if(o.ok!==e.ok||o.problems.length!==e.problems.length)return!1;for(let t=0;t<o.problems.length;t++){let n=o.problems[t],r=e.problems[t];if(n.path!==r.path||n.status!==r.status||n.upstreamCause!==r.upstreamCause)return!1}return!0}function z(o){let e=o.describe({reactive:!0,detail:"standard",reactiveName:"graphLens.topology"}),t=e.node,n=A([t],([g])=>te(g),{name:"graphLens.health",describeKind:"derived",equals:oe,meta:k("lens","health")}),r=D(n),i=new Map,u=-1,h=o.observe({reactive:!0,tiers:["data"]}),s=A([h,t],([g,w])=>{let b=g,l=w;if(b!=null&&b.flushedAt_ns>u){u=b.flushedAt_ns;for(let m of b.events){if(m.type!=="data")continue;let a=m.path;if(a==null||a==="")continue;let c=i.get(a);i.set(a,{path:a,count:(c?.count??0)+1,lastUpdate_ns:b.flushedAt_ns})}}if(l!=null&&i.size>0){let m=new Set(Object.keys(l.nodes));for(let a of[...i.keys()])m.has(a)||i.delete(a)}return new Map(i)},{name:"graphLens.flow",describeKind:"derived",meta:k("lens","flow")}),d=D(s),y=!1;return{topology:t,health:n,flow:s,dispose(){y||(y=!0,d(),r(),e.dispose())}}}var U=class extends N{view;constructor(e){super("lens"),this.view=z(e),this.add(this.view.topology,{name:"topology"}),this.add(this.view.health,{name:"health"}),this.add(this.view.flow,{name:"flow"})}},M=class extends N{target;lens;audit;_defaultActor;_lensSubgraph;constructor(e,t={}){super(t.name??`inspect(${e.name})`),this.target=e,this._defaultActor=t.actor,this._lensSubgraph=new U(e),this.lens=this._lensSubgraph.view,this.mount("lens",this._lensSubgraph),this.audit=H(e,t.audit??{}),this.mount("audit",this.audit),this.addDisposer(()=>this.lens.dispose())}explainTarget(e,t,n){return this.target.explain(e,t,n)}complianceSnapshot(e){let t=e?.actor??this._defaultActor;return I(this.target,{audit:this.audit,...t!=null?{actor:t}:{},...e?.policies!=null?{policies:e.policies}:{}})}};function ce(o,e={}){let t=new M(o,e);return t.tagFactory("inspect",S(e)),t}export{L as a,H as b,j as c,K as d,I as e,V as f,de as g,te as h,oe as i,z as j,M as k,ce as l,ue as m};
@@ -0,0 +1 @@
1
+ import{j as y}from"./chunk-626TESAC.js";import{b as x}from"./chunk-JQFH2DV6.js";import{E as T,m as A,p as f,t as b}from"./chunk-LYCLF26R.js";import{b as m,c as R}from"./chunk-CK2E7BTU.js";function z(r,e){let n=r.cache??0;return n>=e?!1:(r.down([[R],[m,n+1]]),!0)}var k=b((r,e)=>{r("observe"),r("signal"),e("write")});function q(r){let e=x([],{name:r.name,maxSize:r.retainedLimit??1024,guard:r.guard??k,...r.versioning!=null?{versioning:r.versioning}:{}});return e.withLatest(),r.graph&&r.graph.add(e.entries,{name:r.name}),e}function p(r){if(r===null||typeof r!="object"||Object.isFrozen(r))return r;for(let e of Object.keys(r))p(r[e]);return Object.freeze(r)}var h=new WeakSet;function w(r){let e=r.cache,n=typeof e=="number"&&Number.isFinite(e);!n&&e!==void 0&&!h.has(r)&&(h.add(r),console.warn(`bumpCursor: cursor cache held a non-numeric value (${String(e)}); resetting to 0. Causes include: a snapshot codec round-tripping the cursor as a string / null / NaN, OR a malformed initial seed (e.g. state<number>(NaN)). Audit consumers may see colliding seq values after this point.`));let s=(n?e:0)+1;return r.down([[R],[m,s]]),s}function l(r,e,n,i,s,u){let o=e(n,i,s);if(o===void 0)return;let a=u!=null?{...o,handlerVersion:u}:o;r.append(a)}function G(r,e){let n=e.freeze??!0;return function(...s){let u=n?s.map(p):s,o=f(),a=e.seq?w(e.seq):void 0;try{let t=r(...u);return e.audit&&e.onSuccess&&l(e.audit,e.onSuccess,u,t,{t_ns:o,seq:a},e.handlerVersion),t}catch(t){if(e.audit&&e.onFailure){let d=t instanceof Error?t.name:typeof t;l(e.audit,e.onFailure,u,t,{t_ns:o,seq:a,errorType:d},e.handlerVersion)}throw t}}}function V(r,e){let n=e.freeze??!0;return function(...s){let u=n?s.map(p):s,o=f(),a,t,d=!1,g;try{A(()=>{e.seq&&(g=w(e.seq));try{a=r(...u),e.audit&&e.onSuccess&&l(e.audit,e.onSuccess,u,a,{t_ns:o,seq:g},e.handlerVersion)}catch(c){throw t=c,d=!0,c}})}catch(c){if(d&&e.audit&&e.onFailure){let M=t instanceof Error?t.name:typeof t;l(e.audit,e.onFailure,u,t,{t_ns:o,seq:g,errorType:M},e.handlerVersion)}throw d?t:c}return a}}function _(r,e,n=0){let i=T(n,{name:e,describeKind:"state"});return r.add(i,{name:e}),i}function C(r,e,n,i=0){let s={},u=new y(e);for(let o of n){let a=T(i,{name:o,describeKind:"state"});u.add(a,{name:o}),s[o]=a}return r.mount(e,u),s}export{z as a,k as b,q as c,w as d,l as e,G as f,V as g,_ as h,C as i};
@@ -1 +1 @@
1
- import{a as T,b as k}from"./chunk-OV5AA6HJ.js";import{d as H}from"./chunk-3G5U5QNE.js";import{i as B}from"./chunk-POXANAJ6.js";import{a as j,d as q}from"./chunk-35JTVPOX.js";import{E as d,G as o,H as x,m as O}from"./chunk-LYCLF26R.js";import{b as re}from"./chunk-QYADASLV.js";var oe={};re(oe,{demoShell:()=>ie});function w(h){return Math.max(0,Math.min(1,h))}function ie(h){let E=w(h?.mainRatio??.65),J=w(h?.sideSplit??.5),K=Math.max(0,h?.viewportWidth??1280),F=h?.nodeRegistry??new Map,m=h?.adapter??null,M=h?.layoutFont??"14px monospace",p=h?.onHighlight,t=new B("demo-shell"),D=d(E,{name:"pane/main-ratio"}),L=d(J,{name:"pane/side-split"}),g=d(null,{name:"pane/fullscreen"}),G=d(K,{name:"viewport/width"});t.add(D,{name:"pane/main-ratio"}),t.add(L,{name:"pane/side-split"}),t.add(g,{name:"pane/fullscreen"}),t.add(G,{name:"viewport/width"});let R=o([D,G,g],([e,a,n])=>{let l=e,r=a,i=n;return i==="main"?r:i==="graph"||i==="code"?0:Math.round(r*l)},{name:"pane/main-width"}),C=o([R,G,g],([e,a,n])=>{let l=n,r=a;return l==="main"?0:l==="graph"||l==="code"?r:r-e},{name:"pane/side-width"}),z=o([L,g],([e,a])=>{let n=a;return n==="graph"?1:n==="code"||n==="main"?0:w(e)},{name:"pane/graph-height-ratio"}),Q=o([z,g],([e,a])=>{let n=a;return n==="code"?1:n==="graph"||n==="main"?0:1-e},{name:"pane/code-height-ratio"});t.add(R,{name:"pane/main-width"}),t.add(C,{name:"pane/side-width"}),t.add(z,{name:"pane/graph-height-ratio"}),t.add(Q,{name:"pane/code-height-ratio"});let b=d(null,{name:"demo/graph-ref"}),u=d(0,{name:"demo/graph-tick"});t.add(b,{name:"demo/graph-ref"}),t.add(u,{name:"demo/graph-tick"});let U=o([b,u],([e,a])=>{let n=e;return n?H(n.describe()):""},{name:"graph/mermaid"}),P=o([b,u],([e,a])=>{let n=e;if(!n)return null;let{expand:l,...r}=n.describe({detail:"standard"});return r},{name:"graph/describe"});t.add(U,{name:"graph/mermaid"}),t.add(P,{name:"graph/describe"});let S=d(null,{name:"hover/target"});t.add(S,{name:"hover/target"});let W=o([S],([e])=>{let a=e;if(!a)return null;let n=F.get(a.id);return n?n.codeLine:null},{name:"highlight/code-scroll"}),N=o([S],([e])=>{let a=e;if(!a)return null;let n=F.get(a.id);return n?n.visualSelector:null},{name:"highlight/visual"}),_=o([S],([e])=>{let a=e;return a?a.id:null},{name:"highlight/graph"});if(t.add(W,{name:"highlight/code-scroll"}),t.add(N,{name:"highlight/visual"}),t.add(_,{name:"highlight/graph"}),p?.codeScroll){let e=p.codeScroll,a=x([W],([n])=>{e(n)});t.add(a,{name:"highlight/apply-code-scroll"})}if(p?.visual){let e=p.visual,a=x([N],([n])=>{e(n)});t.add(a,{name:"highlight/apply-visual"})}if(p?.graph){let e=p.graph,a=x([_],([n])=>{e(n)});t.add(a,{name:"highlight/apply-graph"})}let I=d(null,{name:"inspect/selected-node"});t.add(I,{name:"inspect/selected-node"});let X=j("standard"),Y=o([I,b,u],([e,a,n])=>{let l=a,r=e;if(!l||!r)return null;try{let i=l.resolve(r),s=q(i,X);return{path:r,...s,value:i.cache}}catch{return null}},{name:"inspect/node-detail"}),Z=o([b,u],([e,a])=>{let n=e;return n?n.trace():[]},{name:"inspect/trace-log"});t.add(Y,{name:"inspect/node-detail"}),t.add(Z,{name:"inspect/trace-log"});let V=d(!1,{name:"meta/debug"});t.add(V,{name:"meta/debug"});let $=o([V,u],([e,a])=>e?H(t.describe()):"",{name:"meta/shell-mermaid"});t.add($,{name:"meta/shell-mermaid"});let A=d("",{name:"layout/code-text"});if(t.add(A,{name:"layout/code-text"}),m){let e=new Map,a=o([P],([r])=>{let i=r;if(!i)return new Map;let s=new Map;for(let[c]of Object.entries(i.nodes)){let f=T(c,M,m,e),v=k(f,1/0,m,M,e),y=v.lines.reduce((ne,ae)=>Math.max(ne,ae.width),0),te=v.lineCount*20;s.set(c,{width:y,height:te})}return s},{name:"layout/graph-labels",equals:(r,i)=>{if(r===i)return!0;let s=r,c=i;if(s.size!==c.size)return!1;for(let[f,v]of s){let y=c.get(f);if(!y||y.width!==v.width||y.height!==v.height)return!1}return!0}}),n=o([A,C],([r,i])=>{let s=r;if(!s)return{lineCount:0,lines:[]};let c=T(s,M,m,e),f=i-40;return k(c,Math.max(100,f),m,M,e)},{name:"layout/code-lines"}),l=o([a],([r])=>{let i=r;if(i.size===0)return 200;let s=0;for(let{width:c}of i.values())c>s&&(s=c);return Math.max(200,Math.round(s+80))},{name:"layout/side-width-hint"});t.add(a,{name:"layout/graph-labels"}),t.add(n,{name:"layout/code-lines"}),t.add(l,{name:"layout/side-width-hint"})}let ee=0;return{graph:t,setMainRatio(e){t.set("pane/main-ratio",w(e))},setSideSplit(e){t.set("pane/side-split",w(e))},setFullscreen(e){t.set("pane/fullscreen",e)},setViewportWidth(e){t.set("viewport/width",Math.max(0,e))},setHoverTarget(e){t.set("hover/target",e)},setDemoGraph(e){t.set("demo/graph-ref",e)},bumpGraphTick(){t.set("demo/graph-tick",++ee)},selectNode(e){t.set("inspect/selected-node",e)},setMetaDebug(e){t.set("meta/debug",e)},setCodeText(e){t.set("layout/code-text",e)},batch(e){O(e)},destroy(){t.destroy()}}}export{ie as a,oe as b};
1
+ import{a as T,b as k}from"./chunk-OCKEEPRJ.js";import{d as H}from"./chunk-3G5U5QNE.js";import{j as B}from"./chunk-626TESAC.js";import{a as j,d as q}from"./chunk-35JTVPOX.js";import{E as d,G as o,H as x,m as O}from"./chunk-LYCLF26R.js";import{b as re}from"./chunk-QYADASLV.js";var oe={};re(oe,{demoShell:()=>ie});function w(h){return Math.max(0,Math.min(1,h))}function ie(h){let E=w(h?.mainRatio??.65),J=w(h?.sideSplit??.5),K=Math.max(0,h?.viewportWidth??1280),F=h?.nodeRegistry??new Map,m=h?.adapter??null,M=h?.layoutFont??"14px monospace",p=h?.onHighlight,t=new B("demo-shell"),D=d(E,{name:"pane/main-ratio"}),L=d(J,{name:"pane/side-split"}),g=d(null,{name:"pane/fullscreen"}),G=d(K,{name:"viewport/width"});t.add(D,{name:"pane/main-ratio"}),t.add(L,{name:"pane/side-split"}),t.add(g,{name:"pane/fullscreen"}),t.add(G,{name:"viewport/width"});let R=o([D,G,g],([e,a,n])=>{let l=e,r=a,i=n;return i==="main"?r:i==="graph"||i==="code"?0:Math.round(r*l)},{name:"pane/main-width"}),C=o([R,G,g],([e,a,n])=>{let l=n,r=a;return l==="main"?0:l==="graph"||l==="code"?r:r-e},{name:"pane/side-width"}),z=o([L,g],([e,a])=>{let n=a;return n==="graph"?1:n==="code"||n==="main"?0:w(e)},{name:"pane/graph-height-ratio"}),Q=o([z,g],([e,a])=>{let n=a;return n==="code"?1:n==="graph"||n==="main"?0:1-e},{name:"pane/code-height-ratio"});t.add(R,{name:"pane/main-width"}),t.add(C,{name:"pane/side-width"}),t.add(z,{name:"pane/graph-height-ratio"}),t.add(Q,{name:"pane/code-height-ratio"});let b=d(null,{name:"demo/graph-ref"}),u=d(0,{name:"demo/graph-tick"});t.add(b,{name:"demo/graph-ref"}),t.add(u,{name:"demo/graph-tick"});let U=o([b,u],([e,a])=>{let n=e;return n?H(n.describe()):""},{name:"graph/mermaid"}),P=o([b,u],([e,a])=>{let n=e;if(!n)return null;let{expand:l,...r}=n.describe({detail:"standard"});return r},{name:"graph/describe"});t.add(U,{name:"graph/mermaid"}),t.add(P,{name:"graph/describe"});let S=d(null,{name:"hover/target"});t.add(S,{name:"hover/target"});let W=o([S],([e])=>{let a=e;if(!a)return null;let n=F.get(a.id);return n?n.codeLine:null},{name:"highlight/code-scroll"}),N=o([S],([e])=>{let a=e;if(!a)return null;let n=F.get(a.id);return n?n.visualSelector:null},{name:"highlight/visual"}),_=o([S],([e])=>{let a=e;return a?a.id:null},{name:"highlight/graph"});if(t.add(W,{name:"highlight/code-scroll"}),t.add(N,{name:"highlight/visual"}),t.add(_,{name:"highlight/graph"}),p?.codeScroll){let e=p.codeScroll,a=x([W],([n])=>{e(n)});t.add(a,{name:"highlight/apply-code-scroll"})}if(p?.visual){let e=p.visual,a=x([N],([n])=>{e(n)});t.add(a,{name:"highlight/apply-visual"})}if(p?.graph){let e=p.graph,a=x([_],([n])=>{e(n)});t.add(a,{name:"highlight/apply-graph"})}let I=d(null,{name:"inspect/selected-node"});t.add(I,{name:"inspect/selected-node"});let X=j("standard"),Y=o([I,b,u],([e,a,n])=>{let l=a,r=e;if(!l||!r)return null;try{let i=l.resolve(r),s=q(i,X);return{path:r,...s,value:i.cache}}catch{return null}},{name:"inspect/node-detail"}),Z=o([b,u],([e,a])=>{let n=e;return n?n.trace():[]},{name:"inspect/trace-log"});t.add(Y,{name:"inspect/node-detail"}),t.add(Z,{name:"inspect/trace-log"});let V=d(!1,{name:"meta/debug"});t.add(V,{name:"meta/debug"});let $=o([V,u],([e,a])=>e?H(t.describe()):"",{name:"meta/shell-mermaid"});t.add($,{name:"meta/shell-mermaid"});let A=d("",{name:"layout/code-text"});if(t.add(A,{name:"layout/code-text"}),m){let e=new Map,a=o([P],([r])=>{let i=r;if(!i)return new Map;let s=new Map;for(let[c]of Object.entries(i.nodes)){let f=T(c,M,m,e),v=k(f,1/0,m,M,e),y=v.lines.reduce((ne,ae)=>Math.max(ne,ae.width),0),te=v.lineCount*20;s.set(c,{width:y,height:te})}return s},{name:"layout/graph-labels",equals:(r,i)=>{if(r===i)return!0;let s=r,c=i;if(s.size!==c.size)return!1;for(let[f,v]of s){let y=c.get(f);if(!y||y.width!==v.width||y.height!==v.height)return!1}return!0}}),n=o([A,C],([r,i])=>{let s=r;if(!s)return{lineCount:0,lines:[]};let c=T(s,M,m,e),f=i-40;return k(c,Math.max(100,f),m,M,e)},{name:"layout/code-lines"}),l=o([a],([r])=>{let i=r;if(i.size===0)return 200;let s=0;for(let{width:c}of i.values())c>s&&(s=c);return Math.max(200,Math.round(s+80))},{name:"layout/side-width-hint"});t.add(a,{name:"layout/graph-labels"}),t.add(n,{name:"layout/code-lines"}),t.add(l,{name:"layout/side-width-hint"})}let ee=0;return{graph:t,setMainRatio(e){t.set("pane/main-ratio",w(e))},setSideSplit(e){t.set("pane/side-split",w(e))},setFullscreen(e){t.set("pane/fullscreen",e)},setViewportWidth(e){t.set("viewport/width",Math.max(0,e))},setHoverTarget(e){t.set("hover/target",e)},setDemoGraph(e){t.set("demo/graph-ref",e)},bumpGraphTick(){t.set("demo/graph-tick",++ee)},selectNode(e){t.set("inspect/selected-node",e)},setMetaDebug(e){t.set("meta/debug",e)},setCodeText(e){t.set("layout/code-text",e)},batch(e){O(e)},destroy(){t.destroy()}}}export{ie as a,oe as b};
@@ -1 +1 @@
1
- import{b as G,c as F}from"./chunk-G3M3IMEV.js";import{a as A}from"./chunk-AI7QC7J6.js";import{a as q}from"./chunk-L6NSJVJZ.js";import{b as E}from"./chunk-TT4C7DXW.js";import{i as I}from"./chunk-POXANAJ6.js";import{C as M}from"./chunk-L77I47VU.js";import{E as d,G as o,H as O,m as S}from"./chunk-LYCLF26R.js";import{b as V}from"./chunk-QYADASLV.js";var $={};V($,{contentModerationGraph:()=>Q,dataQualityGraph:()=>T,issueTrackerGraph:()=>B,observabilityGraph:()=>D});function r(u,a){return q("domain_template",u,a)}function D(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=[{name:"errors",classify:e=>C(e,"error")},{name:"traces",classify:e=>C(e,"trace")},{name:"metrics",classify:e=>C(e,"metric")}],m=a.branches??h,y=m.map(e=>({name:e.name,classify:e.classify})),c=A("stratify",a.source,y);n.mount("stratify",c);let k=m.map(e=>{try{let i=n.resolve(`stratify::branch/${e.name}`);return o([i],([x])=>x,{initial:null})}catch{return d(null)}}),l=a.correlate??(e=>e),_=o(k,e=>l(e),{meta:r("observability",{stage:"correlate"})});n.add(_,{name:"correlate"});let N=a.sloCheck??(()=>({pass:!0})),w=o([_],e=>e[0],{meta:r("observability",{stage:"slo_value"})}),f=o([w],e=>N(e[0]),{meta:r("observability",{stage:"slo_verified"})});n.add(w,{name:"slo_value"}),n.add(f,{name:"slo_verified"});let v=a.weights??m.map(()=>1),b=k.map(e=>o([e],i=>i[0]!=null?1:0)),p=v.map(e=>d(e));for(let e=0;e<b.length;e++)n.add(b[e],{name:`__signal_${e}`}),n.add(p[e],{name:`__weight_${e}`});let t=F(b,p);n.add(t,{name:"alerts"});let g=o([t,f],e=>({scored:e[0],slo:e[1]}),{meta:r("observability",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:r("observability",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let s=o([f],e=>{let i=e[0];return i&&i.pass===!1?i:null},{meta:r("observability",{stage:"feedback_condition"})});return n.add(s,{name:"feedback_condition"}),G(n,"feedback_condition","feedback_reentry",{maxIterations:a.maxFeedbackIterations??5}),n}function B(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=0,m=e=>({id:`issue-${++h}`,title:String(e),severity:1,source:"unknown",raw:e}),y=a.extract??m,c=o([a.source],e=>y(e[0]),{meta:r("issue_tracker",{stage:"extract"})});n.add(c,{name:"extract"});let k=a.verify??(()=>({valid:!0})),l=o([c],e=>{let i=e[0];return{issue:i,verification:k(i)}},{meta:r("issue_tracker",{stage:"verify"})});n.add(l,{name:"verify"});let _=d([],{meta:r("issue_tracker",{stage:"known_patterns"})});n.add(_,{name:"known_patterns"});let N=a.detectRegression??(()=>({regression:!1})),w=o([c,_],e=>{let i=e[0],x=e[1];return{issue:i,regression:N(i,x)}},{meta:r("issue_tracker",{stage:"regression"})});n.add(w,{name:"regression"});let f=o([c],e=>e[0]?.severity??0),v=o([w],e=>e[0]?.regression?2:0);n.add(f,{name:"__severity_signal"}),n.add(v,{name:"__regression_signal"});let b=d(1),p=d(1.5);n.add(b,{name:"__severity_weight"}),n.add(p,{name:"__regression_weight"});let t=F([f,v],[b,p]);n.add(t,{name:"priority"});let g=o([l,w,t],e=>({verified:e[0],regression:e[1],priority:e[2]}),{meta:r("issue_tracker",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:r("issue_tracker",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let s=o([l],e=>{let i=e[0];if(i){let x=i.verification;if(x&&x.valid===!1)return i}return null},{meta:r("issue_tracker",{stage:"feedback_condition"})});return n.add(s,{name:"feedback_condition"}),G(n,"feedback_condition","feedback_reentry",{maxIterations:a.maxFeedbackIterations??3}),n}function Q(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=s=>({label:"review",confidence:.5,original:s}),m=a.classify??h,y=o([a.source],s=>m(s[0]),{meta:r("content_moderation",{stage:"classify"})});n.add(y,{name:"classify"});let c=A("stratify",y,[{name:"safe",classify:s=>s.label==="safe"},{name:"review",classify:s=>s.label==="review"},{name:"block",classify:s=>s.label==="block"}]);n.mount("stratify",c);let k=E([],{name:"review_queue",maxSize:a.maxQueueSize});n.add(k.entries,{name:"review_queue"});let l;try{l=n.resolve("stratify::branch/review")}catch{l=d(null),n.add(l,{name:"__review_fallback"})}let _=O([l],s=>{let e=s[0];e&&k.append(e)});n.add(_,{name:"__review_accumulator"}),n.addDisposer(M(_));let N=d({},{meta:r("content_moderation",{stage:"policy",access:"both",description:"Moderation policy rules \u2014 updated via feedback"})});n.add(N,{name:"policy"});let w=a.weights??[.1,1,2],f=o([y],s=>s[0]?.confidence??0),v=o([y],s=>{let e=s[0];return e?e.label==="block"?w[2]:e.label==="review"?w[1]:w[0]:0});n.add(f,{name:"__confidence_signal"}),n.add(v,{name:"__severity_signal"});let b=d(1),p=d(1);n.add(b,{name:"__w_confidence"}),n.add(p,{name:"__w_severity"});let t=F([f,v],[b,p]);n.add(t,{name:"priority"});let g=o([y,t],s=>({classification:s[0],priority:s[1]}),{meta:r("content_moderation",{stage:"output"})});n.add(g,{name:"output"});let R=o([k.entries,N],s=>{let e=s[0];if(e&&e.length>0){let i=e[e.length-1];if(i&&i.falsePositive)return i}return null},{meta:r("content_moderation",{stage:"feedback_condition"})});return n.add(R,{name:"feedback_condition"}),G(n,"feedback_condition","policy",{maxIterations:a.maxFeedbackIterations??5}),n}function T(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=a.validate??(t=>({valid:!0,errors:[],record:t})),m=o([a.source],t=>t[0]!=null?h(t[0]):void 0,{meta:r("data_quality",{stage:"validate"})});n.add(m,{name:"validate"});let y=a.detectAnomaly??(t=>({anomaly:!1,score:0,record:t})),c=o([a.source],t=>t[0]!=null?y(t[0]):void 0,{meta:r("data_quality",{stage:"anomaly"})});n.add(c,{name:"anomaly"});let k=d(null,{meta:r("data_quality",{stage:"baseline",description:"Rolling baseline for drift detection"})});n.add(k,{name:"baseline"});let l=O([m],t=>{let g=t[0];g?.valid&&S(()=>{k.emit(g.record)})});n.add(l,{name:"__baseline_updater"}),M(l);let _=a.detectDrift??(()=>({drift:!1})),N=o([a.source,k],t=>_(t[0],t[1]),{meta:r("data_quality",{stage:"drift"})});n.add(N,{name:"drift"});let w=a.suggest??(()=>null),f=o([m,c],t=>w({validation:t[0],anomaly:t[1]}),{meta:r("data_quality",{stage:"remediate"})});n.add(f,{name:"remediate"});let v=o([m,c,N,f],t=>({validation:t[0],anomaly:t[1],drift:t[2],remediation:t[3]}),{meta:r("data_quality",{stage:"output"})});n.add(v,{name:"output"});let b=d([],{meta:r("data_quality",{stage:"validation_rules"})});n.add(b,{name:"validation_rules"});let p=o([c],t=>{let g=t[0];return g?.anomaly?g:null},{meta:r("data_quality",{stage:"feedback_condition"})});return n.add(p,{name:"feedback_condition"}),G(n,"feedback_condition","validation_rules",{maxIterations:a.maxFeedbackIterations??3}),n}function C(u,a){if(u==null||typeof u!="object")return!1;let n=u;return n.type===a||n.kind===a}export{D as a,B as b,Q as c,T as d,$ as e};
1
+ import{b as G,c as F}from"./chunk-CUNIRONA.js";import{a as A}from"./chunk-4YAN45KM.js";import{a as q}from"./chunk-L6NSJVJZ.js";import{j as I}from"./chunk-626TESAC.js";import{b as E}from"./chunk-JQFH2DV6.js";import{C as M}from"./chunk-V5A7M7RJ.js";import{E as d,G as o,H as O,m as S}from"./chunk-LYCLF26R.js";import{b as V}from"./chunk-QYADASLV.js";var $={};V($,{contentModerationGraph:()=>Q,dataQualityGraph:()=>T,issueTrackerGraph:()=>B,observabilityGraph:()=>D});function r(u,a){return q("domain_template",u,a)}function D(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=[{name:"errors",classify:e=>C(e,"error")},{name:"traces",classify:e=>C(e,"trace")},{name:"metrics",classify:e=>C(e,"metric")}],m=a.branches??h,y=m.map(e=>({name:e.name,classify:e.classify})),c=A("stratify",a.source,y);n.mount("stratify",c);let k=m.map(e=>{try{let i=n.resolve(`stratify::branch/${e.name}`);return o([i],([x])=>x,{initial:null})}catch{return d(null)}}),l=a.correlate??(e=>e),_=o(k,e=>l(e),{meta:r("observability",{stage:"correlate"})});n.add(_,{name:"correlate"});let N=a.sloCheck??(()=>({pass:!0})),w=o([_],e=>e[0],{meta:r("observability",{stage:"slo_value"})}),f=o([w],e=>N(e[0]),{meta:r("observability",{stage:"slo_verified"})});n.add(w,{name:"slo_value"}),n.add(f,{name:"slo_verified"});let v=a.weights??m.map(()=>1),b=k.map(e=>o([e],i=>i[0]!=null?1:0)),p=v.map(e=>d(e));for(let e=0;e<b.length;e++)n.add(b[e],{name:`__signal_${e}`}),n.add(p[e],{name:`__weight_${e}`});let t=F(b,p);n.add(t,{name:"alerts"});let g=o([t,f],e=>({scored:e[0],slo:e[1]}),{meta:r("observability",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:r("observability",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let s=o([f],e=>{let i=e[0];return i&&i.pass===!1?i:null},{meta:r("observability",{stage:"feedback_condition"})});return n.add(s,{name:"feedback_condition"}),G(n,"feedback_condition","feedback_reentry",{maxIterations:a.maxFeedbackIterations??5}),n}function B(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=0,m=e=>({id:`issue-${++h}`,title:String(e),severity:1,source:"unknown",raw:e}),y=a.extract??m,c=o([a.source],e=>y(e[0]),{meta:r("issue_tracker",{stage:"extract"})});n.add(c,{name:"extract"});let k=a.verify??(()=>({valid:!0})),l=o([c],e=>{let i=e[0];return{issue:i,verification:k(i)}},{meta:r("issue_tracker",{stage:"verify"})});n.add(l,{name:"verify"});let _=d([],{meta:r("issue_tracker",{stage:"known_patterns"})});n.add(_,{name:"known_patterns"});let N=a.detectRegression??(()=>({regression:!1})),w=o([c,_],e=>{let i=e[0],x=e[1];return{issue:i,regression:N(i,x)}},{meta:r("issue_tracker",{stage:"regression"})});n.add(w,{name:"regression"});let f=o([c],e=>e[0]?.severity??0),v=o([w],e=>e[0]?.regression?2:0);n.add(f,{name:"__severity_signal"}),n.add(v,{name:"__regression_signal"});let b=d(1),p=d(1.5);n.add(b,{name:"__severity_weight"}),n.add(p,{name:"__regression_weight"});let t=F([f,v],[b,p]);n.add(t,{name:"priority"});let g=o([l,w,t],e=>({verified:e[0],regression:e[1],priority:e[2]}),{meta:r("issue_tracker",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:r("issue_tracker",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let s=o([l],e=>{let i=e[0];if(i){let x=i.verification;if(x&&x.valid===!1)return i}return null},{meta:r("issue_tracker",{stage:"feedback_condition"})});return n.add(s,{name:"feedback_condition"}),G(n,"feedback_condition","feedback_reentry",{maxIterations:a.maxFeedbackIterations??3}),n}function Q(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=s=>({label:"review",confidence:.5,original:s}),m=a.classify??h,y=o([a.source],s=>m(s[0]),{meta:r("content_moderation",{stage:"classify"})});n.add(y,{name:"classify"});let c=A("stratify",y,[{name:"safe",classify:s=>s.label==="safe"},{name:"review",classify:s=>s.label==="review"},{name:"block",classify:s=>s.label==="block"}]);n.mount("stratify",c);let k=E([],{name:"review_queue",maxSize:a.maxQueueSize});n.add(k.entries,{name:"review_queue"});let l;try{l=n.resolve("stratify::branch/review")}catch{l=d(null),n.add(l,{name:"__review_fallback"})}let _=O([l],s=>{let e=s[0];e&&k.append(e)});n.add(_,{name:"__review_accumulator"}),n.addDisposer(M(_));let N=d({},{meta:r("content_moderation",{stage:"policy",access:"both",description:"Moderation policy rules \u2014 updated via feedback"})});n.add(N,{name:"policy"});let w=a.weights??[.1,1,2],f=o([y],s=>s[0]?.confidence??0),v=o([y],s=>{let e=s[0];return e?e.label==="block"?w[2]:e.label==="review"?w[1]:w[0]:0});n.add(f,{name:"__confidence_signal"}),n.add(v,{name:"__severity_signal"});let b=d(1),p=d(1);n.add(b,{name:"__w_confidence"}),n.add(p,{name:"__w_severity"});let t=F([f,v],[b,p]);n.add(t,{name:"priority"});let g=o([y,t],s=>({classification:s[0],priority:s[1]}),{meta:r("content_moderation",{stage:"output"})});n.add(g,{name:"output"});let R=o([k.entries,N],s=>{let e=s[0];if(e&&e.length>0){let i=e[e.length-1];if(i&&i.falsePositive)return i}return null},{meta:r("content_moderation",{stage:"feedback_condition"})});return n.add(R,{name:"feedback_condition"}),G(n,"feedback_condition","policy",{maxIterations:a.maxFeedbackIterations??5}),n}function T(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=a.validate??(t=>({valid:!0,errors:[],record:t})),m=o([a.source],t=>t[0]!=null?h(t[0]):void 0,{meta:r("data_quality",{stage:"validate"})});n.add(m,{name:"validate"});let y=a.detectAnomaly??(t=>({anomaly:!1,score:0,record:t})),c=o([a.source],t=>t[0]!=null?y(t[0]):void 0,{meta:r("data_quality",{stage:"anomaly"})});n.add(c,{name:"anomaly"});let k=d(null,{meta:r("data_quality",{stage:"baseline",description:"Rolling baseline for drift detection"})});n.add(k,{name:"baseline"});let l=O([m],t=>{let g=t[0];g?.valid&&S(()=>{k.emit(g.record)})});n.add(l,{name:"__baseline_updater"}),M(l);let _=a.detectDrift??(()=>({drift:!1})),N=o([a.source,k],t=>_(t[0],t[1]),{meta:r("data_quality",{stage:"drift"})});n.add(N,{name:"drift"});let w=a.suggest??(()=>null),f=o([m,c],t=>w({validation:t[0],anomaly:t[1]}),{meta:r("data_quality",{stage:"remediate"})});n.add(f,{name:"remediate"});let v=o([m,c,N,f],t=>({validation:t[0],anomaly:t[1],drift:t[2],remediation:t[3]}),{meta:r("data_quality",{stage:"output"})});n.add(v,{name:"output"});let b=d([],{meta:r("data_quality",{stage:"validation_rules"})});n.add(b,{name:"validation_rules"});let p=o([c],t=>{let g=t[0];return g?.anomaly?g:null},{meta:r("data_quality",{stage:"feedback_condition"})});return n.add(p,{name:"feedback_condition"}),G(n,"feedback_condition","validation_rules",{maxIterations:a.maxFeedbackIterations??3}),n}function C(u,a){if(u==null||typeof u!="object")return!1;let n=u;return n.type===a||n.kind===a}export{D as a,B as b,Q as c,T as d,$ as e};
@@ -0,0 +1 @@
1
+ import{c as O,f as V,h as j}from"./chunk-FDQGFWLF.js";import{f as B,m as K}from"./chunk-V5A7M7RJ.js";import{p as N}from"./chunk-LYCLF26R.js";import{b as M,i as L,j as $}from"./chunk-CK2E7BTU.js";import{b as J}from"./chunk-QYADASLV.js";var G={};J(G,{processInstanceKeyOf:()=>X,processManager:()=>Z});var X=i=>i.correlationId;function D(i){if(i==null)return Promise.resolve(void 0);let p=K(i);return new Promise((s,v)=>{let c=!1,m,r=()=>{m&&m()};m=p.subscribe(a=>{if(!c)for(let o of a){if(o[0]===M){c=!0,Promise.resolve().then(r),s(o[1]);return}if(o[0]===$){c=!0,Promise.resolve().then(r),v(o[1]);return}if(o[0]===L){c=!0,Promise.resolve().then(r),s(void 0);return}}})})}async function Y(i,p,s,v,c){let m;for(let r=0;r<=v;r++){if(r>0){let a=c[Math.min(r-1,c.length-1)]??0;a>0&&await new Promise(o=>setTimeout(o,a))}try{return await D(i(p,s))}catch(a){m=a}}return{outcome:"failure",error:m}}function Z(i,p,s){let v=s.retryMax??0,c=s.backoffMs??[0],m=1024,r=new Map,a=new Set,o=new Map,b=`${p}_process_instances`,C=`${p}_process_seq`;if(i.tryResolve(b)!==void 0||i.tryResolve(C)!==void 0)throw new Error(`processManager: name "${p}" is already in use on this CQRS graph (collides on "${b}" / "${C}"). Pick a different name or destroy the previous CQRS graph before re-creating the manager.`);let R=O({name:b,retainedLimit:m,graph:i}),Q=j(i,C,0),y=V(()=>{},{audit:R,seq:Q,freeze:!0,...s.handlerVersion!==void 0?{handlerVersion:s.handlerVersion}:{},onSuccess:([e,t,n,d],g,{t_ns:u,seq:f})=>({correlationId:e,state:t,status:n,startedAt:o.get(e)??u,updatedAt:u,t_ns:u,seq:f??0,...d!==void 0?{reason:d}:{}})}),_=`_process_${p}_started`;i.event(_),s.persistence?.eventStorage&&i.attachEventStorage(s.persistence.eventStorage);async function k(e,t,n,d){if(a.delete(e),r.delete(e),o.delete(e),s.compensate)try{await D(s.compensate(t,n)),y(e,t,"compensated",d)}catch{y(e,t,"errored",void 0)}else y(e,t,"errored",void 0)}async function z(e,t){if(a.has(e)){if(t.outcome==="failure"){let n=r.get(e)??s.initial;await k(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(y(e,t.state,"running",void 0),s.isTerminal?.(t.state)){a.delete(e),r.delete(e),o.delete(e),y(e,t.state,"terminated",void 0);return}if(t.schedule){let{afterMs:n,eventType:d}=t.schedule,g,u=B(n),f=l=>{for(let T of l)if(T[0]===M){if(g?g():queueMicrotask(()=>g?.()),!a.has(e))return;let h=r.get(e);if(h===void 0)return;let S=s.steps[d];if(!S)return;let w={type:d,payload:null,timestampNs:N(),seq:Number.NaN,correlationId:e,aggregateId:e};q(e,S,h,w)}};g=u.subscribe(f)}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),y(e,t.state,"terminated",void 0)}}}let E=new Map;function q(e,t,n,d){let u=(E.get(e)??Promise.resolve()).then(async()=>{let f=r.get(e);if(f===void 0||!a.has(e))return;let l;try{l=await Y(t,f,d,v,c)}catch(T){await k(e,r.get(e)??s.initial,T);return}await z(e,l)});E.set(e,u),u.finally(()=>{E.get(e)===u&&E.delete(e)})}let P=!1,x=[];for(let e of s.watching){let t=i.event(e),n=0;n=(t.cache??[]).length;let g=t.subscribe(u=>{for(let f of u){if(f[0]!==M)continue;let l=f[1];if(l.length<=n)continue;let T=l.slice(n);n=l.length;for(let h of T){let S=h.correlationId;if(S===void 0||!a.has(S))continue;let w=s.steps[e];if(!w)continue;let A=r.get(S);A!==void 0&&q(S,w,A,h)}}});x.push(g)}function F(e,t){if(P||a.has(e))return;let n=N();o.set(e,n),r.set(e,s.initial),a.add(e);try{i._appendEvent(_,t??null,{correlationId:e,aggregateId:e})}catch{}y(e,s.initial,"running",void 0)}function U(e,t){if(P||!a.has(e))return;let n=r.get(e)??s.initial;k(e,n,new Error(`cancelled: ${t??"no reason given"}`),t)}function W(e){return r.get(e)}function H(){if(!P){P=!0;for(let e of x)try{e()}catch{}x.length=0}}return{instances:R,audit:R,start:F,cancel:U,getState:W,dispose:H}}export{X as a,Z as b,G as c};
@@ -1 +1 @@
1
- import{c as $,g as _}from"./chunk-VXPLLA4P.js";import{a as L}from"./chunk-L6NSJVJZ.js";import{i as F}from"./chunk-POXANAJ6.js";import{b as z}from"./chunk-35JTVPOX.js";import{D as j,E as G,G as D,m as E,p as B}from"./chunk-LYCLF26R.js";import{b as P,d as S,i as I,j as K}from"./chunk-CK2E7BTU.js";import{b as ie}from"./chunk-QYADASLV.js";var se={};ie(se,{PipelineGraph:()=>x,decisionKeyOf:()=>q,pipelineGraph:()=>W});function N(y,t){return L("orchestration",y,t)}var q=y=>y.action,x=class extends F{constructor(t,i){super(t,i)}task(t,i,e={}){let a=(e.deps??[]).map(c=>this._resolveStep(c)),p=D(a,i,{name:t,describeKind:"derived",meta:N("task",e.meta)});return this.add(p,{name:t}),p}classify(t,i,e,a={}){let p=this._resolveStep(i),c=D([p],([d])=>{try{return{tag:e(d),value:d}}catch(f){return{tag:"error",value:d,error:f}}},{name:t,describeKind:"derived",meta:N("classify",a.meta)});return this.add(c,{name:t}),c}combine(t,i,e={}){let a=Object.keys(i),p=a.map(d=>this._resolveStep(i[d])),c=D(p,d=>{let f={};for(let s=0;s<a.length;s++)f[a[s]]=d[s];return f},{name:t,describeKind:"derived",meta:N("combine",e.meta)});return this.add(c,{name:t}),c}approvalGate(t,i,e={}){let a=e.maxPending??1e3;if(a<1&&a!==Number.POSITIVE_INFINITY)throw new RangeError("approvalGate: maxPending must be >= 1");let p=e.startOpen??!1;typeof i!="string"&&this.nameOf(i)===void 0&&this.add(i,{name:`${t}/source`});let c=this._resolveStep(i),d=new F(`${t}_state`),f=G([],{name:"pending",equals:()=>!1}),s=G(p,{name:"isOpen"}),R=D([f],([n])=>n.length,{name:"count"}),T=G(0,{name:"droppedCount"}),u=$({name:"decisions",retainedLimit:1024,graph:d});d.add(f,{name:"pending"}),d.add(s,{name:"isOpen"}),d.add(R,{name:"count"}),d.add(T,{name:"droppedCount"}),this.mount(`${t}_state`,d);let l=[],v=!1,k=!1,w=p,M=s.subscribe(n=>{for(let o of n)o[0]===P&&(w=o[1])});this.addDisposer(M);function A(){f.emit([...l])}function C(n,o,r){u.append({action:n,t_ns:B(),...o!==void 0?{items:o,count:o.length}:{},...r!==void 0?{unflushed:r}:{},...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}function U(n){if(l.push(n),l.length>a){let o=l.shift();T.emit(T.cache+1),C("drop",[o])}A()}function O(n){let o=l.splice(0,n);return A(),o}let b=j([c],(n,o,r)=>{let h=r.terminalDeps[0];if(h!==void 0){v=!0;let g=l.length;l=[],A(),C("teardown",void 0,g),o.down(h===!0?[[I]]:[[K,h]]);return}let m=n[0];if(m==null||m.length===0){o.down([[S]]);return}for(let g of m)w?o.emit(g):(U(g),o.down([[S]]))},{name:t,describeKind:"derived",meta:N("approval_gate",e.meta)});if(this.add(b,{name:t}),e.approver!=null){e.approver.cache&&(s.emit(!0),w=!0,e.onceOnly&&(k=!0));let o=e.approver.subscribe(r=>{for(let h of r){if(h[0]!==P)continue;let m=!!h[1];if(m&&!w){if(e.onceOnly){if(k)continue;k=!0}E(()=>{s.emit(!0);let g=O(l.length);C("open",g);for(let te of g){if(v)break;b.emit(te)}})}else if(!m&&w){if(e.onceOnly&&k)continue;E(()=>{s.emit(!1),C("close")})}}});this.addDisposer(o)}let V=n=>{if(v)throw new Error(`approvalGate: ${n}() called after the gate was torn down`)},Y=(n=1)=>{V("approve");let o=O(n);for(let r of o){if(v)break;b.emit(r)}},H=(n=1)=>{V("reject"),O(n)},J=(n,o=1)=>{V("modify");let r=[...l],h=O(o);for(let m=0;m<h.length&&!v;m++)b.emit(n(h[m],m,r))},Q=()=>{V("open"),s.emit(!0);let n=O(l.length);for(let o of n){if(v)break;b.emit(o)}},X=()=>{V("close"),!(e.onceOnly&&k)&&s.emit(!1)},Z=_(Y,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"approve",count:n[0]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),ee=_(H,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"reject",count:n[0]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),ne=_(J,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"modify",count:n[1]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),re=_(Q,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"open",t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),oe=_(X,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"close",t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})});return this.addDisposer(R.subscribe(()=>{})),{node:b,pending:f,count:R,isOpen:s,droppedCount:T,decisions:u,audit:u,approve:Z,reject:ee,modify:ne,open:re,close:oe}}approval(t,i,e,a={}){return this.approvalGate(t,i,{...a,approver:e,maxPending:1})}catch(t,i,e,a={}){let p=this._resolveStep(i),c=a.on??"errored",d=j([p],(f,s,R)=>{let T=R.terminalDeps[0];if(T!==void 0){let l=T===!0?{kind:"completed"}:{kind:"errored",error:T};if(c==="terminal"||c===l.kind){s.emit(e(l,s));return}s.down(l.kind==="completed"?[[I]]:[[K,l.error]]);return}let u=f[0];if(u==null||u.length===0){s.down([[S]]);return}for(let l of u)s.emit(l)},{name:t,describeKind:"derived",completeWhenDepsComplete:a.completeWhenDepsComplete??!(c==="completed"||c==="terminal"),errorWhenDepsError:!(c==="errored"||c==="terminal"),meta:N("catch",a.meta)});return this.add(d,{name:t}),d}_resolveStep(t){if(typeof t=="string")return this.resolve(t);if(this.nameOf(t)===void 0)throw new Error(`PipelineGraph "${this.name}": Node dep is not registered. Pass a string path or call graph.add(node) first.`);return t}};function W(y,t){let i=new x(y,t),{factory:e,factoryArgs:a,...p}=t??{};return i.tagFactory("pipelineGraph",z(p)),i}export{q as a,x as b,W as c,se as d};
1
+ import{c as $,g as _}from"./chunk-FDQGFWLF.js";import{a as L}from"./chunk-L6NSJVJZ.js";import{j as F}from"./chunk-626TESAC.js";import{b as z}from"./chunk-35JTVPOX.js";import{D as j,E as G,G as D,m as E,p as B}from"./chunk-LYCLF26R.js";import{b as P,d as S,i as I,j as K}from"./chunk-CK2E7BTU.js";import{b as ie}from"./chunk-QYADASLV.js";var se={};ie(se,{PipelineGraph:()=>x,decisionKeyOf:()=>q,pipelineGraph:()=>W});function N(y,t){return L("orchestration",y,t)}var q=y=>y.action,x=class extends F{constructor(t,i){super(t,i)}task(t,i,e={}){let a=(e.deps??[]).map(c=>this._resolveStep(c)),p=D(a,i,{name:t,describeKind:"derived",meta:N("task",e.meta)});return this.add(p,{name:t}),p}classify(t,i,e,a={}){let p=this._resolveStep(i),c=D([p],([d])=>{try{return{tag:e(d),value:d}}catch(f){return{tag:"error",value:d,error:f}}},{name:t,describeKind:"derived",meta:N("classify",a.meta)});return this.add(c,{name:t}),c}combine(t,i,e={}){let a=Object.keys(i),p=a.map(d=>this._resolveStep(i[d])),c=D(p,d=>{let f={};for(let s=0;s<a.length;s++)f[a[s]]=d[s];return f},{name:t,describeKind:"derived",meta:N("combine",e.meta)});return this.add(c,{name:t}),c}approvalGate(t,i,e={}){let a=e.maxPending??1e3;if(a<1&&a!==Number.POSITIVE_INFINITY)throw new RangeError("approvalGate: maxPending must be >= 1");let p=e.startOpen??!1;typeof i!="string"&&this.nameOf(i)===void 0&&this.add(i,{name:`${t}/source`});let c=this._resolveStep(i),d=new F(`${t}_state`),f=G([],{name:"pending",equals:()=>!1}),s=G(p,{name:"isOpen"}),R=D([f],([n])=>n.length,{name:"count"}),T=G(0,{name:"droppedCount"}),u=$({name:"decisions",retainedLimit:1024,graph:d});d.add(f,{name:"pending"}),d.add(s,{name:"isOpen"}),d.add(R,{name:"count"}),d.add(T,{name:"droppedCount"}),this.mount(`${t}_state`,d);let l=[],v=!1,k=!1,w=p,M=s.subscribe(n=>{for(let o of n)o[0]===P&&(w=o[1])});this.addDisposer(M);function A(){f.emit([...l])}function C(n,o,r){u.append({action:n,t_ns:B(),...o!==void 0?{items:o,count:o.length}:{},...r!==void 0?{unflushed:r}:{},...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}function U(n){if(l.push(n),l.length>a){let o=l.shift();T.emit(T.cache+1),C("drop",[o])}A()}function O(n){let o=l.splice(0,n);return A(),o}let b=j([c],(n,o,r)=>{let h=r.terminalDeps[0];if(h!==void 0){v=!0;let g=l.length;l=[],A(),C("teardown",void 0,g),o.down(h===!0?[[I]]:[[K,h]]);return}let m=n[0];if(m==null||m.length===0){o.down([[S]]);return}for(let g of m)w?o.emit(g):(U(g),o.down([[S]]))},{name:t,describeKind:"derived",meta:N("approval_gate",e.meta)});if(this.add(b,{name:t}),e.approver!=null){e.approver.cache&&(s.emit(!0),w=!0,e.onceOnly&&(k=!0));let o=e.approver.subscribe(r=>{for(let h of r){if(h[0]!==P)continue;let m=!!h[1];if(m&&!w){if(e.onceOnly){if(k)continue;k=!0}E(()=>{s.emit(!0);let g=O(l.length);C("open",g);for(let te of g){if(v)break;b.emit(te)}})}else if(!m&&w){if(e.onceOnly&&k)continue;E(()=>{s.emit(!1),C("close")})}}});this.addDisposer(o)}let V=n=>{if(v)throw new Error(`approvalGate: ${n}() called after the gate was torn down`)},Y=(n=1)=>{V("approve");let o=O(n);for(let r of o){if(v)break;b.emit(r)}},H=(n=1)=>{V("reject"),O(n)},J=(n,o=1)=>{V("modify");let r=[...l],h=O(o);for(let m=0;m<h.length&&!v;m++)b.emit(n(h[m],m,r))},Q=()=>{V("open"),s.emit(!0);let n=O(l.length);for(let o of n){if(v)break;b.emit(o)}},X=()=>{V("close"),!(e.onceOnly&&k)&&s.emit(!1)},Z=_(Y,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"approve",count:n[0]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),ee=_(H,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"reject",count:n[0]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),ne=_(J,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"modify",count:n[1]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),re=_(Q,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"open",t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),oe=_(X,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"close",t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})});return this.addDisposer(R.subscribe(()=>{})),{node:b,pending:f,count:R,isOpen:s,droppedCount:T,decisions:u,audit:u,approve:Z,reject:ee,modify:ne,open:re,close:oe}}approval(t,i,e,a={}){return this.approvalGate(t,i,{...a,approver:e,maxPending:1})}catch(t,i,e,a={}){let p=this._resolveStep(i),c=a.on??"errored",d=j([p],(f,s,R)=>{let T=R.terminalDeps[0];if(T!==void 0){let l=T===!0?{kind:"completed"}:{kind:"errored",error:T};if(c==="terminal"||c===l.kind){s.emit(e(l,s));return}s.down(l.kind==="completed"?[[I]]:[[K,l.error]]);return}let u=f[0];if(u==null||u.length===0){s.down([[S]]);return}for(let l of u)s.emit(l)},{name:t,describeKind:"derived",completeWhenDepsComplete:a.completeWhenDepsComplete??!(c==="completed"||c==="terminal"),errorWhenDepsError:!(c==="errored"||c==="terminal"),meta:N("catch",a.meta)});return this.add(d,{name:t}),d}_resolveStep(t){if(typeof t=="string")return this.resolve(t);if(this.nameOf(t)===void 0)throw new Error(`PipelineGraph "${this.name}": Node dep is not registered. Pass a string path or call graph.add(node) first.`);return t}};function W(y,t){let i=new x(y,t),{factory:e,factoryArgs:a,...p}=t??{};return i.tagFactory("pipelineGraph",z(p)),i}export{q as a,x as b,W as c,se as d};
@@ -1 +1 @@
1
- import{C as O}from"./chunk-L77I47VU.js";import{D as H,E as A,G as k,m as D}from"./chunk-LYCLF26R.js";import{b as N,c as $,d as K,i as B,j as E}from"./chunk-CK2E7BTU.js";var C=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(n,t){if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=t,t!==void 0){if(this._buf=new Array(t),n&&n.length>0){let s=Math.min(n.length,t),h=n.length-s;for(let o=0;o<s;o++)this._buf[o]=n[h+o];this._size=s}}else this._buf=n?[...n]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(n){if(!Number.isInteger(n))return;let t=n>=0?n:this._size+n;if(!(t<0||t>=this._size))return this._maxSize!==void 0?this._buf[(this._head+t)%this._maxSize]:this._buf[t]}append(n){this._rawAppend(n),this._version+=1}appendMany(n){if(n.length===0)return;let t=this._maxSize!==void 0&&n.length>this._maxSize?n.length-this._maxSize:0;for(let s=t;s<n.length;s++)this._rawAppend(n[s]);this._version+=1}clear(){if(this._size===0)return 0;let n=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let t=0;t<n;t++)this._buf[(this._head+t)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,n}trimHead(n){if(!Number.isInteger(n)||n<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${n})`);if(n===0||this._size===0)return 0;let t=Math.min(n,this._size);if(this._maxSize===void 0)this._buf.splice(0,t);else{for(let s=0;s<t;s++)this._buf[(this._head+s)%this._maxSize]=void 0;this._head=(this._head+t)%this._maxSize}return this._size-=t,this._version+=1,t}slice(n,t){if(!Number.isInteger(n)||n<0)throw new RangeError(`slice: start must be a non-negative integer (got ${n})`);if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${t})`);let s=t===void 0?this._size:Math.min(Math.max(t,0),this._size),h=Math.min(n,this._size);if(h>=s)return[];let o=s-h;if(this._maxSize===void 0)return this._buf.slice(h,s);let b=new Array(o);for(let r=0;r<o;r++)b[r]=this._buf[(this._head+h+r)%this._maxSize];return b}tail(n){if(!Number.isInteger(n)||n<0)throw new RangeError(`tail: n must be a non-negative integer (got ${n})`);if(n===0||this._size===0)return[];let t=Math.min(n,this._size);return this.slice(this._size-t,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let n=new Array(this._size);for(let t=0;t<this._size;t++)n[t]=this._buf[(this._head+t)%this._maxSize];return n}snapshot(){return this.toArray()}restore(n){if(this._maxSize===void 0){this._buf.length=0;for(let t=0;t<n.length;t++)this._buf.push(n[t]);this._size=this._buf.length}else{let t=this._maxSize;for(let o=0;o<t;o++)this._buf[o]=void 0;this._head=0;let s=Math.min(n.length,t),h=n.length-s;for(let o=0;o<s;o++)this._buf[o]=n[h+o];this._size=s}this._version+=1}_rawAppend(n){if(this._maxSize===void 0){this._buf.push(n),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=n,this._size+=1):(this._buf[this._head]=n,this._head=(this._head+1)%this._maxSize)}};function x(g){return g.subscribe(()=>{})}var G=64;function Q(g,n={}){let{name:t,maxSize:s,versioning:h,guard:o,backend:b}=n,r=b??new C(g,s),m=A(r.toArray(),{name:t,describeKind:"state",equals:(e,i)=>e===i,...h!=null?{versioning:h}:{},...o!=null?{guard:o}:{}});function w(){let e=r.toArray();D(()=>{m.down([[$]],{internal:!0}),m.down([[N,e]],{internal:!0})})}let u=new Map,l=new Map,_=new Map;function M(e,i){return`${e}:${i===void 0?"END":i}`}function y(e){if(e.size<G)return;let i=e.keys().next();if(i.done)return;let d=e.get(i.value);d!==void 0&&d.dispose(),e.delete(i.value)}function v(e){let i=r.version;try{return e()}finally{r.version!==i&&w()}}function P(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);let i=u.get(e);if(i!==void 0)return u.delete(e),u.set(e,i),i.node;y(u);let d=k([m],([f])=>{let c=f;return e===0||c.length===0?[]:c.slice(Math.max(0,c.length-e))},{initial:r.tail(e),describeKind:"derived"}),a=x(d);return u.set(e,{node:d,dispose:a}),d}function j(e,i){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(i!==void 0&&(!Number.isInteger(i)||i<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${i})`);let d=M(e,i),a=l.get(d);if(a!==void 0)return l.delete(d),l.set(d,a),a.node;y(l);let f=k([m],([p])=>{let T=p;return i===void 0?T.slice(e):T.slice(e,i)},{initial:r.slice(e,i),describeKind:"derived"}),c=x(f);return l.set(d,{node:f,dispose:c}),f}function q(e){let i=_.get(e);if(i!==void 0)return i.node;let d=k([m,e],([f,c])=>{let p=f,T=Math.max(0,Math.trunc(c??0));return p.slice(T)},{initial:[],describeKind:"derived"}),a=x(d);return _.set(e,{node:d,dispose:a}),d}let L,S;function R(){L===void 0&&(L=H([m],(e,i,d)=>{let a=e[0],c=a!=null&&a.length>0?a.at(-1):d.prevData[0];if(c==null||c.length===0){i.down([[K]]);return}i.emit(c[c.length-1])},{name:t!=null?`${t}::lastValue`:"lastValue",describeKind:"derived",initial:r.size===0?void 0:r.at(r.size-1)}),S=k([m],([e])=>e.length>0,{name:t!=null?`${t}::hasLatest`:"hasLatest",describeKind:"derived",initial:r.size>0}),x(L),x(S))}let I={entries:m,get size(){return r.size},at(e){return r.at(e)},append(e){v(()=>r.append(e))},appendMany(e){e.length!==0&&v(()=>r.appendMany(e))},clear(){v(()=>r.clear())},trimHead(e){v(()=>r.trimHead(e))},withLatest(){return R(),m},get lastValue(){return R(),L},get hasLatest(){return R(),S},view(e){switch(e.kind){case"tail":return P(e.n);case"slice":return j(e.start,e.stop);case"fromCursor":return q(e.cursor)}},attach(e){let i=e.subscribe(d=>{for(let a of d)a[0]===N&&I.append(a[1])});return()=>i()},attachStorage(e){if(e.length===0)return()=>{};let i=new Map;for(let a of e)i.set(a,r.size);(async()=>{for(let a of e)if(typeof a.loadEntries=="function")try{let f=await Promise.resolve(a.loadEntries());f.entries.length>0&&r.size===0&&(r.restore(f.entries),i.set(a,f.entries.length),w());break}catch{}})();let d=m.subscribe(a=>{for(let f of a){if(f[0]!==N)continue;let c=f[1];for(let p of e){let T=i.get(p)??0;if(c.length<T){try{let z=p.appendEntries(c);z instanceof Promise&&z.catch(()=>{})}catch{}i.set(p,c.length);continue}if(c.length===T)continue;let F=c.slice(T);i.set(p,c.length);try{let z=p.appendEntries(F);z instanceof Promise&&z.catch(()=>{})}catch{}}}});return()=>d()},disposeAllViews(){for(let e of u.values())e.dispose();u.clear();for(let e of l.values())e.dispose();l.clear();for(let e of _.values())e.dispose();_.clear()},dispose(){for(let e of u.values())e.dispose();u.clear();for(let e of l.values())e.dispose();l.clear();for(let e of _.values())e.dispose();_.clear()}};return I}var V=new WeakMap;function Z(g){let n=V.get(g);if(n)return n;let t=g.map(u=>u.cache??[]),s=t.flat(),h=A(s,{name:"mergeReactiveLogs",describeKind:"state",equals:(u,l)=>u===l}),o=g.map((u,l)=>[...t[l]??[]]),b=[];for(let u=0;u<g.length;u++){let l=u,_=g[l].subscribe(M=>{for(let y of M)if(y[0]===N)o[l]=[...y[1]],h.emit(o.flat());else if(y[0]===B){o[l]=[];let v=b[l];v!==void 0&&(b[l]=void 0,v())}else y[0]===E&&h.down([[E,y[1]]])});b.push(_)}let r=O(h),m=!1,w={node:h,dispose(){if(!m){m=!0;for(let u of b)u?.();b.length=0,r(),V.delete(g)}}};return V.set(g,w),w}export{C as a,Q as b,Z as c};
1
+ import{C as O}from"./chunk-V5A7M7RJ.js";import{D as H,E as A,G as k,m as D}from"./chunk-LYCLF26R.js";import{b as N,c as $,d as K,i as B,j as E}from"./chunk-CK2E7BTU.js";var C=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(n,t){if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=t,t!==void 0){if(this._buf=new Array(t),n&&n.length>0){let s=Math.min(n.length,t),h=n.length-s;for(let o=0;o<s;o++)this._buf[o]=n[h+o];this._size=s}}else this._buf=n?[...n]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(n){if(!Number.isInteger(n))return;let t=n>=0?n:this._size+n;if(!(t<0||t>=this._size))return this._maxSize!==void 0?this._buf[(this._head+t)%this._maxSize]:this._buf[t]}append(n){this._rawAppend(n),this._version+=1}appendMany(n){if(n.length===0)return;let t=this._maxSize!==void 0&&n.length>this._maxSize?n.length-this._maxSize:0;for(let s=t;s<n.length;s++)this._rawAppend(n[s]);this._version+=1}clear(){if(this._size===0)return 0;let n=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let t=0;t<n;t++)this._buf[(this._head+t)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,n}trimHead(n){if(!Number.isInteger(n)||n<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${n})`);if(n===0||this._size===0)return 0;let t=Math.min(n,this._size);if(this._maxSize===void 0)this._buf.splice(0,t);else{for(let s=0;s<t;s++)this._buf[(this._head+s)%this._maxSize]=void 0;this._head=(this._head+t)%this._maxSize}return this._size-=t,this._version+=1,t}slice(n,t){if(!Number.isInteger(n)||n<0)throw new RangeError(`slice: start must be a non-negative integer (got ${n})`);if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${t})`);let s=t===void 0?this._size:Math.min(Math.max(t,0),this._size),h=Math.min(n,this._size);if(h>=s)return[];let o=s-h;if(this._maxSize===void 0)return this._buf.slice(h,s);let b=new Array(o);for(let r=0;r<o;r++)b[r]=this._buf[(this._head+h+r)%this._maxSize];return b}tail(n){if(!Number.isInteger(n)||n<0)throw new RangeError(`tail: n must be a non-negative integer (got ${n})`);if(n===0||this._size===0)return[];let t=Math.min(n,this._size);return this.slice(this._size-t,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let n=new Array(this._size);for(let t=0;t<this._size;t++)n[t]=this._buf[(this._head+t)%this._maxSize];return n}snapshot(){return this.toArray()}restore(n){if(this._maxSize===void 0){this._buf.length=0;for(let t=0;t<n.length;t++)this._buf.push(n[t]);this._size=this._buf.length}else{let t=this._maxSize;for(let o=0;o<t;o++)this._buf[o]=void 0;this._head=0;let s=Math.min(n.length,t),h=n.length-s;for(let o=0;o<s;o++)this._buf[o]=n[h+o];this._size=s}this._version+=1}_rawAppend(n){if(this._maxSize===void 0){this._buf.push(n),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=n,this._size+=1):(this._buf[this._head]=n,this._head=(this._head+1)%this._maxSize)}};function x(g){return g.subscribe(()=>{})}var G=64;function Q(g,n={}){let{name:t,maxSize:s,versioning:h,guard:o,backend:b}=n,r=b??new C(g,s),m=A(r.toArray(),{name:t,describeKind:"state",equals:(e,i)=>e===i,...h!=null?{versioning:h}:{},...o!=null?{guard:o}:{}});function w(){let e=r.toArray();D(()=>{m.down([[$]],{internal:!0}),m.down([[N,e]],{internal:!0})})}let u=new Map,l=new Map,_=new Map;function M(e,i){return`${e}:${i===void 0?"END":i}`}function y(e){if(e.size<G)return;let i=e.keys().next();if(i.done)return;let d=e.get(i.value);d!==void 0&&d.dispose(),e.delete(i.value)}function v(e){let i=r.version;try{return e()}finally{r.version!==i&&w()}}function P(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);let i=u.get(e);if(i!==void 0)return u.delete(e),u.set(e,i),i.node;y(u);let d=k([m],([f])=>{let c=f;return e===0||c.length===0?[]:c.slice(Math.max(0,c.length-e))},{initial:r.tail(e),describeKind:"derived"}),a=x(d);return u.set(e,{node:d,dispose:a}),d}function j(e,i){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(i!==void 0&&(!Number.isInteger(i)||i<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${i})`);let d=M(e,i),a=l.get(d);if(a!==void 0)return l.delete(d),l.set(d,a),a.node;y(l);let f=k([m],([p])=>{let T=p;return i===void 0?T.slice(e):T.slice(e,i)},{initial:r.slice(e,i),describeKind:"derived"}),c=x(f);return l.set(d,{node:f,dispose:c}),f}function q(e){let i=_.get(e);if(i!==void 0)return i.node;let d=k([m,e],([f,c])=>{let p=f,T=Math.max(0,Math.trunc(c??0));return p.slice(T)},{initial:[],describeKind:"derived"}),a=x(d);return _.set(e,{node:d,dispose:a}),d}let L,S;function R(){L===void 0&&(L=H([m],(e,i,d)=>{let a=e[0],c=a!=null&&a.length>0?a.at(-1):d.prevData[0];if(c==null||c.length===0){i.down([[K]]);return}i.emit(c[c.length-1])},{name:t!=null?`${t}::lastValue`:"lastValue",describeKind:"derived",initial:r.size===0?void 0:r.at(r.size-1)}),S=k([m],([e])=>e.length>0,{name:t!=null?`${t}::hasLatest`:"hasLatest",describeKind:"derived",initial:r.size>0}),x(L),x(S))}let I={entries:m,get size(){return r.size},at(e){return r.at(e)},append(e){v(()=>r.append(e))},appendMany(e){e.length!==0&&v(()=>r.appendMany(e))},clear(){v(()=>r.clear())},trimHead(e){v(()=>r.trimHead(e))},withLatest(){return R(),m},get lastValue(){return R(),L},get hasLatest(){return R(),S},view(e){switch(e.kind){case"tail":return P(e.n);case"slice":return j(e.start,e.stop);case"fromCursor":return q(e.cursor)}},attach(e){let i=e.subscribe(d=>{for(let a of d)a[0]===N&&I.append(a[1])});return()=>i()},attachStorage(e){if(e.length===0)return()=>{};let i=new Map;for(let a of e)i.set(a,r.size);(async()=>{for(let a of e)if(typeof a.loadEntries=="function")try{let f=await Promise.resolve(a.loadEntries());f.entries.length>0&&r.size===0&&(r.restore(f.entries),i.set(a,f.entries.length),w());break}catch{}})();let d=m.subscribe(a=>{for(let f of a){if(f[0]!==N)continue;let c=f[1];for(let p of e){let T=i.get(p)??0;if(c.length<T){try{let z=p.appendEntries(c);z instanceof Promise&&z.catch(()=>{})}catch{}i.set(p,c.length);continue}if(c.length===T)continue;let F=c.slice(T);i.set(p,c.length);try{let z=p.appendEntries(F);z instanceof Promise&&z.catch(()=>{})}catch{}}}});return()=>d()},disposeAllViews(){for(let e of u.values())e.dispose();u.clear();for(let e of l.values())e.dispose();l.clear();for(let e of _.values())e.dispose();_.clear()},dispose(){for(let e of u.values())e.dispose();u.clear();for(let e of l.values())e.dispose();l.clear();for(let e of _.values())e.dispose();_.clear()}};return I}var V=new WeakMap;function Z(g){let n=V.get(g);if(n)return n;let t=g.map(u=>u.cache??[]),s=t.flat(),h=A(s,{name:"mergeReactiveLogs",describeKind:"state",equals:(u,l)=>u===l}),o=g.map((u,l)=>[...t[l]??[]]),b=[];for(let u=0;u<g.length;u++){let l=u,_=g[l].subscribe(M=>{for(let y of M)if(y[0]===N)o[l]=[...y[1]],h.emit(o.flat());else if(y[0]===B){o[l]=[];let v=b[l];v!==void 0&&(b[l]=void 0,v())}else y[0]===E&&h.down([[E,y[1]]])});b.push(_)}let r=O(h),m=!1,w={node:h,dispose(){if(!m){m=!0;for(let u of b)u?.();b.length=0,r(),V.delete(g)}}};return V.set(g,w),w}export{C as a,Q as b,Z as c};
@@ -1 +1 @@
1
- import{b as v}from"./chunk-KRH66M4O.js";import{i as y}from"./chunk-CLD3F4R5.js";import{G as x}from"./chunk-X7QKTXXC.js";import{d as S}from"./chunk-VJLMUKOI.js";import{d as O}from"./chunk-VIMF6LGM.js";import{d as k}from"./chunk-6QZNQS5B.js";import{d as A}from"./chunk-GPW2V3RE.js";import{b as N}from"./chunk-CGNOWGV6.js";import{E as b,J as g,m as _}from"./chunk-LYCLF26R.js";import{b as a,c as p,i as h,j as m}from"./chunk-CK2E7BTU.js";import{b as f}from"./chunk-QYADASLV.js";var j={};f(j,{jotai:()=>v,nanostores:()=>y,nestjs:()=>x,react:()=>S,signals:()=>T,solid:()=>O,svelte:()=>k,vue:()=>A,zustand:()=>N});var T={};f(T,{Signal:()=>q});var s=[];function i(n){let e=n.cache;return n.subscribe(o=>{for(let[d,r]of o)d===a&&(e=r)})(),e}var u=class{_node;_equals;constructor(e,t){this._equals=t?.equals??Object.is,this._node=b(e,{...t,resubscribable:!0,resetOnTeardown:!0})}get(){let e=s[s.length-1];return e?(this._node.status==="sentinel"&&i(this._node),e(this._node)):this._node.status==="sentinel"?i(this._node):this._node.cache}set(e){this._equals(this.get(),e)||_(()=>{this._node.down([[p],[a,e]])})}},l=class{_node;constructor(e,t){this._node=g(o=>{s.push(o);try{return e()}finally{s.pop()}},{...t,describeKind:"derived",resubscribable:!0,resetOnTeardown:!0})}get(){let e=s[s.length-1];return e?(this._node.status==="sentinel"&&i(this._node),e(this._node)):this._node.status==="sentinel"?i(this._node):this._node.cache}},q={State:u,Computed:l,sub:(n,e)=>{let t=typeof e=="function"?{data:e,error:void 0,complete:void 0}:e,o=!0;return n._node.subscribe(d=>{for(let[r,c]of d){if(r===a){if(o){o=!1;continue}t.data?.(c)}r===m&&t.error?.(c),r===h&&t.complete?.()}})}};export{T as a,j as b};
1
+ import{b as v}from"./chunk-KRH66M4O.js";import{i as y}from"./chunk-CLD3F4R5.js";import{G as x}from"./chunk-OFZG3TB3.js";import{d as S}from"./chunk-VJLMUKOI.js";import{d as O}from"./chunk-VIMF6LGM.js";import{d as k}from"./chunk-6QZNQS5B.js";import{d as A}from"./chunk-GPW2V3RE.js";import{b as N}from"./chunk-TPKQW72B.js";import{E as b,J as g,m as _}from"./chunk-LYCLF26R.js";import{b as a,c as p,i as h,j as m}from"./chunk-CK2E7BTU.js";import{b as f}from"./chunk-QYADASLV.js";var j={};f(j,{jotai:()=>v,nanostores:()=>y,nestjs:()=>x,react:()=>S,signals:()=>T,solid:()=>O,svelte:()=>k,vue:()=>A,zustand:()=>N});var T={};f(T,{Signal:()=>q});var s=[];function i(n){let e=n.cache;return n.subscribe(o=>{for(let[d,r]of o)d===a&&(e=r)})(),e}var u=class{_node;_equals;constructor(e,t){this._equals=t?.equals??Object.is,this._node=b(e,{...t,resubscribable:!0,resetOnTeardown:!0})}get(){let e=s[s.length-1];return e?(this._node.status==="sentinel"&&i(this._node),e(this._node)):this._node.status==="sentinel"?i(this._node):this._node.cache}set(e){this._equals(this.get(),e)||_(()=>{this._node.down([[p],[a,e]])})}},l=class{_node;constructor(e,t){this._node=g(o=>{s.push(o);try{return e()}finally{s.pop()}},{...t,describeKind:"derived",resubscribable:!0,resetOnTeardown:!0})}get(){let e=s[s.length-1];return e?(this._node.status==="sentinel"&&i(this._node),e(this._node)):this._node.status==="sentinel"?i(this._node):this._node.cache}},q={State:u,Computed:l,sub:(n,e)=>{let t=typeof e=="function"?{data:e,error:void 0,complete:void 0}:e,o=!0;return n._node.subscribe(d=>{for(let[r,c]of d){if(r===a){if(o){o=!1;continue}t.data?.(c)}r===m&&t.error?.(c),r===h&&t.complete?.()}})}};export{T as a,j as b};
@@ -0,0 +1 @@
1
+ import{a as I,b as P,c as V,d as _,f as j,g as w}from"./chunk-3G5U5QNE.js";import{a as C,b as D,c as $,d as R,g as A,h as S,i as N,j as h,k as T,l as F}from"./chunk-626TESAC.js";import{a as m,b as g,c as k,d as v,e as O,f as E,g as G,h as x}from"./chunk-LYCLF26R.js";import{b as u}from"./chunk-CK2E7BTU.js";import{b as H}from"./chunk-QYADASLV.js";var q={};H(q,{ENVELOPE_VERSION:()=>v,GRAPH_META_SEGMENT:()=>S,Graph:()=>h,JsonCodec:()=>m,SIZEOF_OVERHEAD:()=>C,SIZEOF_SYMBOL:()=>D,SNAPSHOT_VERSION:()=>N,createDagCborCodec:()=>g,createDagCborZstdCodec:()=>k,decodeEnvelope:()=>E,diffForWAL:()=>T,encodeEnvelope:()=>O,explainPath:()=>R,graphProfile:()=>A,reachable:()=>F,registerBuiltinCodecs:()=>G,replayWAL:()=>x,sizeof:()=>$,validateGraphObservability:()=>W,validateNoIslands:()=>M,watchTopologyTree:()=>L});function L(n,p){let o=new Map,c=(s,a)=>{if(o.has(s))return;let i={off:()=>{},prefix:a};o.set(s,i);let f=s.topology.subscribe(l=>{for(let t of l){if(t[0]!==u)continue;let e=t[1];if(p(e,s,a),e.kind==="added"&&e.nodeKind==="mount"){let r=s._mounts.get(e.name);if(r instanceof h){let d=`${a}${e.name}::`;c(r,d)}}else if(e.kind==="removed"&&e.nodeKind==="mount"){let r=`${a}${e.name}::`;for(let[d,y]of Array.from(o.entries()))d!==n&&y.prefix.startsWith(r)&&(y.off(),o.delete(d))}}});i.off=f;for(let[l,t]of s._mounts)if(t instanceof h){let e=`${a}${l}::`;c(t,e)}};return c(n,""),()=>{for(let s of o.values())s.off();o.clear()}}function M(n){let p=n.describe({detail:"minimal"}),o=Object.keys(p.nodes),c=new Set;for(let a of o){let i=p.nodes[a];if(!i)continue;let f=i.deps??[];for(let l of f)c.add(l)}let s=[];for(let a of o){let i=p.nodes[a];if(!i||a.startsWith("__internal__/"))continue;let l=(i.deps??[]).length,t=c.has(a);if(l===0&&!t){let e=i.type??"unknown";s.push({path:a,kind:e})}}return s.sort((a,i)=>a.path<i.path?-1:a.path>i.path?1:0),{ok:s.length===0,orphans:s,summary(){if(s.length===0)return"validateNoIslands: ok (no islands)";let a=s.slice(0,3).map(i=>`${i.path} (${i.kind})`).join(", ");return`validateNoIslands: ${s.length} island node(s) \u2014 ${a}${s.length>3?", \u2026":""}`}}}var K={json:n=>V(n),pretty:n=>w(n),mermaid:n=>_(n),"mermaid-url":n=>j(n),d2:n=>P(n),ascii:n=>I(n)};function W(n,p={}){let o=[],c=p.requireFound??!0;if(p.skipDescribe!==!0)try{let t=n.describe(),e=new Set(Object.keys(t.nodes)),r=[];for(let[d,y]of Object.entries(t.nodes))for(let b of y.deps)b!==""&&!e.has(b)&&r.push(`${d} \u2192 ${b}`);for(let d of t.edges)e.has(d.from)||r.push(`edge.from: ${d.from}`),e.has(d.to)||r.push(`edge.to: ${d.to}`);r.length>0?o.push({kind:"describe",ok:!1,reason:`describe() has ${r.length} dangling pointer(s); nodes \u2289 deps`,danglingDeps:r}):o.push({kind:"describe",ok:!0,nodeCount:e.size,edgeCount:t.edges.length})}catch(t){o.push({kind:"describe",ok:!1,reason:`describe() threw: ${t instanceof Error?t.message:String(t)}`})}if((p.formats?.length??0)>0){let t=n.describe();for(let e of p.formats)try{let r=K[e](t);typeof r!="string"||r.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:r.length})}catch(r){o.push({kind:"describe-format",ok:!1,format:e,reason:r instanceof Error?r.message:String(r)})}}for(let t of p.paths??[])try{n.resolve(t),o.push({kind:"observe",ok:!0,path:t})}catch(e){o.push({kind:"observe",ok:!1,path:t,reason:e instanceof Error?e.message:String(e)})}for(let[t,e]of p.pairs??[])try{let r=n.explain(t,e);c&&r.found===!1?o.push({kind:"explain",ok:!1,from:t,to:e,reason:`explain(${t} \u2192 ${e}) found no path${r.reason?`: ${r.reason}`:""}`}):o.push({kind:"explain",ok:!0,from:t,to:e,found:r.found,steps:r.steps.length})}catch(r){o.push({kind:"explain",ok:!1,from:t,to:e,reason:r instanceof Error?r.message:String(r)})}let s=o.filter(t=>!t.ok),a=s.length===0,i=p.paths?.length??0,f=p.pairs?.length??0,l=p.formats?.length??0;return{ok:a,checks:o,failures:s,summary(){let t=[p.skipDescribe===!0?null:"describe",l>0?`${l} format${l===1?"":"s"}`:null,i>0?`${i} observe path${i===1?"":"s"}`:null,f>0?`${f} explain pair${f===1?"":"s"}`:null].filter(r=>r!=null),e=t.length>0?t.join(", "):"describe-only";return a?`validateGraphObservability: OK (${e})`:`validateGraphObservability: ${s.length} failure(s) across ${e}`}}}export{L as a,M as b,W as c,q as d};
@@ -0,0 +1,45 @@
1
+ import{d as tt,e as rt}from"./chunk-3XDYJRYU.js";import{s as $e,t as Me,v as Ze}from"./chunk-QE4IGY7I.js";import{g as Se,i as Ge}from"./chunk-OYJKFY7V.js";import{c as et}from"./chunk-JNWRYDJN.js";import{b as me}from"./chunk-D27JNOLZ.js";import{b as Xe}from"./chunk-TSOYJ743.js";import{a as _e}from"./chunk-FDQGFWLF.js";import{g as ze,j as xe}from"./chunk-626TESAC.js";import{b as Re,s as De,t as Ke,x as Ie}from"./chunk-VOPGGIL7.js";import{b as Ye}from"./chunk-35JTVPOX.js";import{b as Ne}from"./chunk-TZQPPQEQ.js";import{C as We,m as ke}from"./chunk-V5A7M7RJ.js";import{D as Be,E as S,F as Ee,G as h,H as O,m as fe,o as H}from"./chunk-LYCLF26R.js";import{b as V,i as X,j as Y}from"./chunk-CK2E7BTU.js";import{b as pt}from"./chunk-QYADASLV.js";var Yt={};pt(Yt,{DEFAULT_DECAY_RATE:()=>ee,DEFAULT_EXECUTE_PROMPT:()=>Ve,DEFAULT_QUEUE_CONFIGS:()=>Ae,DEFAULT_SEVERITY_WEIGHTS:()=>Z,DEFAULT_TRIAGE_PROMPT:()=>He,DEFAULT_VERIFY_PROMPT:()=>Le,HarnessGraph:()=>Ce,QUEUE_NAMES:()=>M,actuatorExecutor:()=>nt,affectedTaskFilter:()=>kt,autoSolidify:()=>ht,beforeAfterCompare:()=>It,blindVariation:()=>Pt,codeChangeBridge:()=>Nt,createIntakeBridge:()=>Et,defaultErrorClassifier:()=>we,defaultLlmExecutor:()=>lt,defaultLlmVerifier:()=>dt,dispatchActuator:()=>vt,effectivenessTracker:()=>wt,errorCritique:()=>Dt,evalIntakeBridge:()=>xt,evalSource:()=>Rt,evalVerifier:()=>at,harnessEvalPair:()=>Ht,harnessLoop:()=>qt,harnessProfile:()=>Jt,harnessTrace:()=>Ut,notifyEffect:()=>St,priorityScore:()=>Vt,refineExecutor:()=>Je,refineLoop:()=>je,resolvePromptFn:()=>pe,strategyKey:()=>te,strategyModel:()=>Qe});function yt(e,r){return{outcome:"success",detail:`actuator applied ${r.intervention} for ${Tt(r.summary)}`,artifact:e}}function gt(e,r){let c=e instanceof Error?e.message:String(e);return{outcome:"failure",detail:`actuator threw on ${r.intervention}: ${c}`}}function bt(e){return`actuator skipped ${e.intervention} (shouldApply returned false)`}function Tt(e,r=80){return e.length<=r?e:`${e.slice(0,r-1)}\u2026`}function nt(e){let r=e.name??"actuator-executor",c=e.toOutput??yt,n=e.onError??gt,i=e.skipDetail??bt;return t=>{let o=t.payload.item;return e.shouldApply&&!e.shouldApply(o)?{...t.payload,execution:{item:o,outcome:"failure",detail:i(o)}}:Ee(a=>{let u=new AbortController,s=!1,l=null,m=y=>{s||(s=!0,a.down([[V,{...t.payload,execution:{item:o,...y}}],[X]]),l?.(),l=null)},f;try{let y=e.apply(o,{signal:u.signal});f=ke(y,{signal:u.signal})}catch(y){return m(n(y,o)),()=>{u.abort()}}return l=f.subscribe(y=>{for(let g of y){if(s)return;if(g[0]===V){m(c(g[1],o));return}if(g[0]===Y){m(n(g[1],o));return}if(g[0]===X){m(n(new Error("actuator inner completed without emitting DATA"),o));return}}}),s&&l&&(l(),l=null),()=>{u.abort(),l?.(),l=null}},{name:`${r}/inner`})}}function vt(e){let r=e.name??"dispatch-actuator",c=e.default??null,n=c!=null;return nt({apply:(i,t)=>{let o=Object.hasOwn(e.routes,i.intervention)?e.routes[i.intervention]:c;if(!o)throw new Error(`dispatchActuator: no route for intervention '${i.intervention}'`);return o(i,t)},shouldApply:i=>Object.hasOwn(e.routes,i.intervention)||n,skipDetail:i=>`no route for intervention '${i.intervention}'`,name:r})}function ht(e){let r=e.name??"auto-solidify",c=e.extract??(i=>i.execution.artifact??null),n=e.predicate??(()=>!0);return Ee(i=>{let t=null,o=!1,a=()=>{o||(o=!0,t?.(),t=null)},u=s=>{o||(i.down([[Y,s]]),a())};return t=e.verifyResults.subscribe(s=>{if(!o)for(let l of s){if(o)return;if(l[0]!==V){if(l[0]===X){i.down([[X]]),a();return}continue}let m=l[1];if(m==null||!m.verified)continue;let f;try{f=n(m)}catch(g){u(g);return}if(!f)continue;let y;try{y=c(m)}catch(g){u(g);return}if(y!=null){try{e.write(y,m)}catch(g){u(g);return}i.down([[V,y]])}}}),o&&t&&(t(),t=null),()=>{a()}},{name:r})}function Et(e,r,c,n){return O([e],([i])=>{if(i==null)return;let t=c(i);for(let o of t)r.publish(o)},{name:n?.name??"intake-bridge"})}function xt(e,r,c){let n=c?.defaultSeverity??"medium";return O([e],([i])=>{if(i==null)return;let t=Array.isArray(i)?i:[i];for(let o of t)for(let a of o.tasks)if(!(a.valid&&a.judge_scores?.every(u=>u.pass))){if(!a.valid&&(!a.judge_scores||a.judge_scores.length===0)){r.publish({source:"eval",summary:`Task ${a.task_id} invalid (model: ${o.model})`,evidence:`Run ${o.run_id}: task produced invalid output`,affectsAreas:["graphspec"],affectsEvalTasks:[a.task_id],severity:n});continue}if(a.judge_scores)for(let u of a.judge_scores)u.pass||r.publish({source:"eval",summary:`${a.task_id}: ${u.claim} (model: ${o.model})`,evidence:u.reasoning,affectsAreas:["graphspec"],affectsEvalTasks:[a.task_id],severity:n})}},{name:c?.name??"eval-intake-bridge"})}function Rt(e,r){return Ie(e,()=>ke(r()))}function It(e,r){return h([e,r],([c,n])=>{let i=c,t=n,o=new Map(i.tasks.map(f=>[f.task_id,f])),a=new Map(t.tasks.map(f=>[f.task_id,f])),u=new Set([...o.keys(),...a.keys()]),s=[],l=[],m=[];for(let f of u){let y=o.get(f),g=a.get(f),E=y?.valid??!1,A=g?.valid??!1,R=y?.judge_scores?y.judge_scores.filter(_=>_.pass).length:void 0,$=g?.judge_scores?g.judge_scores.filter(_=>_.pass).length:void 0,w=R!==void 0&&$!==void 0?$-R:void 0;s.push({taskId:f,before:E,after:A,scoreDiff:w}),E&&!A&&l.push(f),!E&&A&&m.push(f)}return{newFailures:l,resolved:m,taskDeltas:s,overallImproved:m.length>l.length}},{name:"eval-delta"})}function kt(e,r){let c=r==null?null:Array.isArray(r)?S(r):r,n=[e];return c&&n.push(c),h(n,i=>{let t=i[0],o=c?new Set(i[1]):null,a=new Set;for(let u of t)for(let s of u.affectsEvalTasks??[])(o==null||o.has(s))&&a.add(s);return[...a].sort()},{name:"affected-task-filter"})}function Nt(e,r,c,n){let i=n?.defaultSeverity??"high";function t(a){let u=[];for(let s of a.lintErrors??[])u.push({source:"code-change",summary:`Lint: ${s.rule} in ${s.file}:${s.line}`,evidence:s.message,affectsAreas:[s.file],severity:i});for(let s of a.testFailures??[])u.push({source:"test",summary:`Test failure: ${s.testId}`,evidence:s.message,affectsAreas:[s.file],affectsEvalTasks:[s.testId],severity:i});return u}let o=c??t;return O([e],([a])=>{if(a!=null)for(let u of o(a))r.publish(u)},{name:n?.name??"code-change-bridge"})}function St(e,r,c){return O([e.latest],([n])=>{n!=null&&r(n)},{name:c?.name??"notify-effect"})}var M=["auto-fix","needs-decision","investigation","backlog"],Ae={"auto-fix":{gated:!1},"needs-decision":{gated:!0},investigation:{gated:!0},backlog:{gated:!1}},Z={critical:100,high:70,medium:40,low:10},ee=Math.LN2/(168*3600);function te(e,r){return`${e}\u2192${r}`}var At=/\b(parse|json|config|validation|syntax)\b/i,we=e=>At.test(e.detail)?"self-correctable":"structural",He=`You are a triage classifier for a reactive collaboration harness.
2
+
3
+ Given an intake item, classify it and output JSON:
4
+ {
5
+ "rootCause": "composition" | "missing-fn" | "bad-docs" | "schema-gap" | "regression" | "unknown",
6
+ "intervention": "template" | "catalog-fn" | "docs" | "wrapper" | "schema-change" | "investigate",
7
+ "route": "auto-fix" | "needs-decision" | "investigation" | "backlog",
8
+ "priority": <number 0-100>,
9
+ "triageReasoning": "<one sentence>"
10
+ }
11
+
12
+ Strategy model (past effectiveness):
13
+ {{strategy}}
14
+
15
+ Intake item:
16
+ {{item}}`,Ve=`You are an implementation agent.
17
+
18
+ Given a triaged issue with root cause and intervention type, produce a fix.
19
+
20
+ Issue:
21
+ {{item}}
22
+
23
+ Output JSON:
24
+ {
25
+ "outcome": "success" | "failure" | "partial",
26
+ "detail": "<description of what was done or what failed>"
27
+ }`,Le=`You are a QA reviewer.
28
+
29
+ Given an execution result, verify whether the fix is correct.
30
+
31
+ Execution:
32
+ {{execution}}
33
+
34
+ Original issue:
35
+ {{item}}
36
+
37
+ Output JSON:
38
+ {
39
+ "verified": true/false,
40
+ "findings": ["<finding1>", ...],
41
+ "errorClass": "self-correctable" | "structural" // only if verified=false
42
+ }`;function pe(e,r,c){if(typeof e=="function")return e;let n=e??r;return i=>c(n,i)}function wt(e){let r=Ne({name:e?.name??"effectiveness-entries"}),c=h([r.entries],([o])=>new Map(o),{name:`${e?.name??"effectiveness"}-snapshot`,equals:(o,a)=>{let u=o,s=a;if(u.size!==s.size)return!1;for(let[l,m]of u){let f=s.get(l);if(!f||m.attempts!==f.attempts||m.successes!==f.successes)return!1}return!0}});function n(o,a){let u=r.get(o),s=(u?.attempts??0)+1,l=(u?.successes??0)+(a?1:0);r.set(o,{key:o,attempts:s,successes:l,successRate:l/s})}function i(o){return r.get(o)}let t=We(c);return{node:c,record:n,lookup:i,dispose:()=>{t(),r.dispose()}}}function Ct(e){if(typeof e!="object"||e===null)return!1;let r=e;return typeof r.subscribe=="function"&&typeof r.down=="function"&&typeof r.emit=="function"}function ot(e,r){if(e.length===0)return{best:null,bestScore:Number.NEGATIVE_INFINITY};if(e.length===1){let t=qe(r);return{best:e[0],bestScore:t}}if(r.some(t=>typeof t.candidateIndex=="number")){let t=new Array(e.length);for(let u=0;u<e.length;u++)t[u]={sum:0,count:0};for(let u of r){let s=u.candidateIndex;typeof s=="number"&&s>=0&&s<e.length&&(t[s].sum+=u.score,t[s].count+=1)}let o=e[0],a=t[0].count>0?t[0].sum/t[0].count:Number.NEGATIVE_INFINITY;for(let u=1;u<e.length;u++){let s=t[u].count>0?t[u].sum/t[u].count:Number.NEGATIVE_INFINITY;s>a&&(a=s,o=e[u])}return{best:o,bestScore:a}}let n=e[0],i=r[0]?.score??Number.NEGATIVE_INFINITY;for(let t=1;t<e.length;t++){let o=r[t]?.score??Number.NEGATIVE_INFINITY;o>i&&(i=o,n=e[t])}return{best:n,bestScore:i}}function qe(e){if(e.length===0)return Number.NEGATIVE_INFINITY;let r=0;for(let c of e)r+=c.score;return r/e.length}function je(e,r,c,n){let i=n.name??"refine-loop",t=new xe(i,n.graph),o=Ct(n.dataset)?n.dataset:S(n.dataset,{name:"dataset"});t.add(o,{name:"dataset"});let a=S(0,{name:"iteration"});t.add(a,{name:"iteration"});let u=S(c,{name:"strategy",equals:()=>!1});t.add(u,{name:"strategy"});let s=S(null,{name:"lastFeedback"});t.add(s,{name:"lastFeedback"});let l=S([],{name:"prevCandidates"});t.add(l,{name:"prevCandidates"});let m=S(!1,{name:"paused"});t.add(m,{name:"paused"});let f=S("running",{name:"status"});t.add(f,{name:"status"});let y=S([],{name:"history",equals:()=>!1});t.add(y,{name:"history"});let g=S(null,{name:"best"});t.add(g,{name:"best"});let E=S(Number.NEGATIVE_INFINITY,{name:"score"});t.add(E,{name:"score"});let A=S(0,{name:"budget-used"});t.add(A,{name:"budget-used"});let R=Se("stages");t.mount("stages",R);let $=R.topic("generate"),w=R.topic("evaluate"),_=R.topic("analyze"),ye=R.topic("decide"),L=c,U=null,re=[];t.addDisposer(u.subscribe(b=>{for(let T of b)T[0]===V&&(L=T[1])})),t.addDisposer(s.subscribe(b=>{for(let T of b)T[0]===V&&(U=T[1])})),t.addDisposer(l.subscribe(b=>{for(let T of b)T[0]===V&&(re=T[1])}));let G=Ie(a,b=>{let T=L,C=b===0||U==null;return Be([],(I,P)=>{let v=!1;try{let d=C?T.seed(e):T.generate(U,re);if(d instanceof Promise)return d.then(p=>{v||P.emit(p)},p=>{v||P.down([[Y,p]])}),()=>{v=!0};P.emit(d)}catch(d){v=!0,P.down([[Y,d]])}},{describeKind:"producer"})},{name:"candidates"});t.add(G,{name:"candidates"});let ne=O([G],(b,T,C)=>{let I=C.terminalDeps[0];I!==void 0&&I!==!0&&f.emit("errored")},{name:"error-watcher",errorWhenDepsError:!1});t.add(ne,{name:"error-watcher"}),t.addDisposer(ne.subscribe(()=>{}));let Q=h([G,a],([b,T])=>({iteration:T,candidates:b,timestamp_ns:H()}),{name:"generate-event"});t.add(Q,{name:"generate-event"}),t.addDisposer(Q.subscribe(()=>{}));let B=O([Q],([b])=>{$.publish(b)},{name:"generate-publish"});t.add(B,{name:"generate-publish"}),t.addDisposer(B.subscribe(()=>{}));let oe=O([G],([b])=>{l.emit(b)},{name:"generate-mirror"});t.add(oe,{name:"generate-mirror"}),t.addDisposer(oe.subscribe(()=>{}));let z=r(G,o);t.add(z,{name:"scores"});let ae=h([z,G,a],([b,T,C])=>({iteration:C,candidates:T,scores:b,timestamp_ns:H()}),{name:"evaluate-event"});t.add(ae,{name:"evaluate-event"}),t.addDisposer(ae.subscribe(()=>{}));let ge=O([ae],([b])=>{w.publish(b)},{name:"evaluate-publish"});t.add(ge,{name:"evaluate-publish"}),t.addDisposer(ge.subscribe(()=>{}));let se=h([z,G],([b,T])=>L.analyze(b,T),{name:"feedback"});t.add(se,{name:"feedback"});let q=h([se,G,a],([b,T,C])=>({iteration:C,candidates:T,feedback:b,timestamp_ns:H()}),{name:"analyze-event"});t.add(q,{name:"analyze-event"}),t.addDisposer(q.subscribe(()=>{}));let ie=O([q],([b])=>{_.publish(b)},{name:"analyze-publish"});t.add(ie,{name:"analyze-publish"}),t.addDisposer(ie.subscribe(()=>{}));let ue=h([y],([b])=>{let T=b;if(n.patience==null||T.length<=n.patience)return!1;let C=T.slice(-(n.patience+1)),I=C[0].bestScore;return C.slice(1).every(P=>P.bestScore<=I)},{name:"patience-check"});t.add(ue,{name:"patience-check"});let K=h([E],([b])=>n.minScore!=null&&b>=n.minScore,{name:"min-score-check"});t.add(K,{name:"min-score-check"});let ce=h([y],([b])=>{let T=b;if(n.minDelta==null||T.length<2)return!1;let C=T[T.length-2].bestScore,I=T[T.length-1].bestScore;return Math.abs(I-C)<n.minDelta},{name:"min-delta-check"});t.add(ce,{name:"min-delta-check"});let le=h([A],([b])=>n.maxEvaluations!=null&&b>=n.maxEvaluations,{name:"max-evaluations-check"});t.add(le,{name:"max-evaluations-check"});let W=h([a],([b])=>n.maxIterations!=null&&b>=n.maxIterations,{name:"max-iterations-check"});t.add(W,{name:"max-iterations-check"});let de=h([A],([b])=>n.budget!=null&&b>=n.budget,{name:"budget-exhausted-check"});t.add(de,{name:"budget-exhausted-check"}),t.addDisposer(ue.subscribe(()=>{})),t.addDisposer(K.subscribe(()=>{})),t.addDisposer(ce.subscribe(()=>{})),t.addDisposer(le.subscribe(()=>{})),t.addDisposer(W.subscribe(()=>{})),t.addDisposer(de.subscribe(()=>{}));let be=h([ue,K,ce,le,W],([b,T,C,I,P])=>b?{converged:!0,reason:"patience"}:T?{converged:!0,reason:"min-score"}:C?{converged:!0,reason:"min-delta"}:I?{converged:!0,reason:"max-evaluations"}:P?{converged:!0,reason:"max-iterations"}:{converged:!1},{name:"converged"});t.add(be,{name:"converged"}),t.addDisposer(be.subscribe(()=>{}));let Te=-1,ve=O([se,z,G],([b,T,C])=>{let I=a.cache,P=b,v=C,d=T;if(I<=Te)return;Te=I;let{best:p,bestScore:x}=ot(v,d),k=y.cache,j={n:I,candidates:v,scores:d,feedback:P,best:p,bestScore:x,timestamp_ns:H()},F=[...k,j],J=A.cache+v.length,N="continue",D,Pe=n.budget!=null&&J>=n.budget,Fe=m.cache;if(Pe)N="budget",D="budget";else if(n.minScore!=null&&P.score>=n.minScore)N="converged",D="min-score";else if(n.maxIterations!=null&&I>=n.maxIterations)N="converged",D="max-iterations";else if(n.maxEvaluations!=null&&J>=n.maxEvaluations)N="converged",D="max-evaluations";else if(n.minDelta!=null&&F.length>=2){let he=F[F.length-2].bestScore,Oe=F[F.length-1].bestScore;Math.abs(Oe-he)<n.minDelta&&(N="converged",D="min-delta")}else if(n.patience!=null&&F.length>n.patience){let he=F.slice(-(n.patience+1)),Oe=he[0].bestScore;he.slice(1).every(mt=>mt.bestScore<=Oe)&&(N="converged",D="patience")}N==="continue"&&Fe&&(N="paused"),fe(()=>{g.emit(p),E.emit(P.score),y.emit(F),A.emit(J),s.emit(P),ye.publish({iteration:I,decision:N,reason:D,timestamp_ns:H()}),N==="continue"?a.emit(I+1):f.emit(N==="converged"?"converged":N==="budget"?"budget":"paused")})},{name:"decide-bridge"});return t.add(ve,{name:"decide-bridge"}),t.addDisposer(ve.subscribe(()=>{})),Object.assign(t,{best:g,score:E,status:f,history:y,strategy:u,iteration:a,generate:$,evaluate:w,analyze:_,decide:ye,setStrategy(b){u.emit(b)},pause(){m.emit(!0)},resume(){f.cache==="paused"&&fe(()=>{m.emit(!1),f.emit("running"),a.emit(a.cache+1)})}})}function Pt(e){let r=e.width??4;return{name:e.name??"blindVariation",seed(n){return[n]},analyze(n,i){let t=qe(n),o=null;for(let a of n)(!o||a.score<o.score)&&(o=a);return{summary:`blindVariation iteration: mean=${t.toFixed(3)}, n=${n.length}`,score:t,weakTasks:o?[o.taskId]:[]}},async generate(n,i){if(i.length===0)throw new Error("blindVariation.generate: empty candidate batch \u2014 cannot derive prior for teacher");let t=i[i.length-1],o=0,u={prior:t,reportCost:s=>{o+=s}};try{if(e.parallel!==!1)return await Promise.all(Array.from({length:r},()=>e.teacher(u)));let s=[];for(let l=0;l<r;l++)s.push(await e.teacher(u));return s}finally{if(e.tokens!=null&&o>0){let s=e.tokens.cache??0;e.tokens.emit(s+o)}}}}}function Ft(e){return typeof e=="object"&&e!==null&&e.kind==="errorCritique"}function Ot(e,r){return e.length===0?`No task scored below the batch mean (${r.score.toFixed(3)}). Reinforce the current direction.`:`Failures below threshold:
43
+ ${e.map(n=>{let i=n.error!=null?` | error: ${n.error}`:"";return`- ${n.taskId} (score=${n.score.toFixed(3)})${i}`}).join(`
44
+ `)}`}function Dt(e){let r=e.width??4,c=e.name??"errorCritique",n=e.maxFailureSamples??5,i=e.formatCritique??Ot;return{name:c,seed(t){return[t]},analyze(t,o){let a=qe(t),u=typeof e.failureThreshold=="function"?e.failureThreshold(t):e.failureThreshold,s=u===void 0&&!Number.isFinite(a),l=u??a,m=s?[...t].sort((w,_)=>w.score-_.score):t.filter(w=>w.score<l).slice().sort((w,_)=>w.score-_.score),f=m.slice(0,n),{best:y,bestScore:g}=ot(o,t),E={summary:"",score:a,weakTasks:f.map(w=>w.taskId)},A=i(f,E),R={kind:"errorCritique",best:y,failures:f,critiqueText:A},$=m.length>f.length?` (top ${f.length} retained)`:"";return{summary:`errorCritique iteration: mean=${a.toFixed(3)}, failures=${m.length}${$}/${t.length}, bestScore=${g.toFixed(3)}`,critique:R,weakTasks:f.map(w=>w.taskId),score:a}},async generate(t,o){if(o.length===0)throw new Error("errorCritique.generate: empty candidate batch \u2014 cannot derive prior for teacher");let a=Ft(t.critique)?t.critique:void 0,u=a!==void 0?a.best:o[o.length-1],s=a?.critiqueText??t.summary,l=a?.failures??[],m=0,y={prior:u,critique:s,failures:l,reportCost:g=>{m+=g}};try{if(e.parallel!==!1)return await Promise.all(Array.from({length:r},()=>e.teacher(y)));let g=[];for(let E=0;E<r;E++)g.push(await e.teacher(y));return g}finally{if(e.tokens!=null&&m>0){let g=e.tokens.cache??0;e.tokens.emit(g+m)}}}}}function _t(e){let{best:r,score:c,status:n}=e,i=Number.isFinite(c)?c.toFixed(3):String(c),t=r??void 0;return n==="converged"?{outcome:"success",detail:`refineLoop converged at score ${i}`,artifact:t}:n==="budget"?{outcome:"partial",detail:`refineLoop hit budget at score ${i}`,artifact:t}:{outcome:"failure",detail:`refineLoop errored (status=${n})`,artifact:t}}function Je(e){let r=e.name??"refine-executor",c=e.toOutput??_t;return n=>{let i=n.payload.item,t=je(e.seedFrom(i),e.evaluator,e.strategy,{...e.refine,dataset:e.datasetFor(i),name:`${r}/inner`}),o=h([t.status,t.best,t.score],([a,u,s])=>{let l=a;if(l!=="converged"&&l!=="budget"&&l!=="errored")return null;let m=c({best:u,score:s,status:l});return{...n.payload,execution:{item:i,...m}}},{name:`${r}/output`});return Re(o,a=>a!=null,{name:`${r}/gate-out`})}}function $t(e){if(e.length===0)return Number.NEGATIVE_INFINITY;let r=0;for(let c of e)r+=c.score;return r/e.length}function Mt(e){let{passCount:r,total:c,meanScore:n,threshold:i,missingArtifact:t}=e,o=Number.isFinite(n)?n.toFixed(3):String(n),a=!t&&c>0&&n>=i,u=t?["EXECUTE stage did not emit an artifact; cannot verify reactively"]:a?[`${r}/${c} eval tasks passed; mean score ${o} \u2265 ${i}`]:c===0?["No eval tasks were selected for this item \u2014 cannot verify"]:[`${r}/${c} eval tasks passed; mean score ${o} < threshold ${i}`];return a?{verified:!0,findings:u}:{verified:!1,findings:u,errorClass:"structural"}}function Gt(e){return e.artifact??null}function at(e){let r=e.name??"eval-verifier",c=e.threshold??.5,n=e.toOutput??Mt,i=e.extractArtifact??Gt;return t=>{let{item:o,execution:a}=t.payload;if(a==null)return{...t.payload,verify:{verified:!1,findings:["evalVerifier: prior execute stage produced no execution"],errorClass:"structural"}};let u=i(a,o);if(u==null)return{...t.payload,verify:n({scores:[],meanScore:Number.NEGATIVE_INFINITY,passCount:0,total:0,threshold:c,missingArtifact:!0})};let s=S([u],{name:`${r}/candidates`}),l=S(e.datasetFor(o),{name:`${r}/dataset`}),m;fe(()=>{m=e.evaluator(s,l)});let f=h([m],([y])=>{let g=y;if(g==null)return null;let E=$t(g),A=g.filter(R=>R.score>=c).length;return{...t.payload,verify:n({scores:g,meanScore:E,passCount:A,total:g.length,threshold:c})}},{name:`${r}/output`});return Re(f,y=>y!=null,{name:`${r}/gate-out`})}}function Ht(e){let r=e.name??"harness-pair",c=Je({name:`${r}-exec`,seedFrom:e.seedFrom,evaluator:e.evaluator,strategy:e.strategy,datasetFor:e.datasetFor,refine:e.refine}),n=at({name:`${r}-verify`,evaluator:e.evaluator,datasetFor:e.datasetFor,threshold:e.threshold});return{executor:c,verifier:n}}function Qe(){let e=Ne({name:"strategy-entries"}),r=h([e.entries],([o])=>{let a=o;return new Map(a)},{name:"strategy-model",equals:(o,a)=>{let u=o,s=a;if(u.size!==s.size)return!1;for(let[l,m]of u){let f=s.get(l);if(!f||m.attempts!==f.attempts||m.successes!==f.successes)return!1}return!0}});function c(o,a,u){let s=te(o,a),l=e.get(s),m=(l?.attempts??0)+1,f=(l?.successes??0)+(u?1:0);e.set(s,{rootCause:o,intervention:a,attempts:m,successes:f,successRate:f/m})}function n(o,a){return e.get(te(o,a))}let i=r.subscribe(()=>{});function t(){i()}return{node:r,record:c,lookup:n,dispose:t}}function Vt(e,r,c,n,i){let t={...Z,...i?.severityWeights},o=i?.decayRate??ee,a=i?.effectivenessThreshold??.7,u=i?.effectivenessBoost??15,s=[e,r,c];return n&&s.push(n),h(s,l=>{let m=l[0],f=l[1],y=l[2],g=n?l[3]:0,E=t[m.severity??"medium"],A=(H()-y)/1e9,R=Xe(E,A,o,0),$=te(m.rootCause,m.intervention),w=f.get($);return w&&w.successRate>=a&&(R+=u),R+=g*20,R},{name:"priority-score"})}var st="intake",Lt="triage-output",it="retry",ut="verify-results",ct="__unrouted";function lt(e,r){let c=pe(r,Ve,(n,i)=>n.replace("{{item}}",JSON.stringify(i)));return n=>{let i=n.payload.item,t=[{role:"user",content:c(i)}],o=u=>({...n.payload,execution:{item:i,outcome:"failure",detail:u}}),a=u=>u instanceof Error?u.message:String(u);return Me(e,t,{onSuccess:u=>{let s;try{s=JSON.parse($e(String(u.content)))}catch(m){return o(`execute parse error: ${a(m)}`)}if(s==null||typeof s!="object"||Array.isArray(s))return o(`execute parse error: non-object response: ${JSON.stringify(s)}`);let l=s;return{...n.payload,execution:{item:i,outcome:l.outcome??"failure",detail:l.detail??"unknown",artifact:l.artifact}}},onFailure:(u,s)=>o(u==="complete"?"adapter completed without emitting DATA":`executor failed: ${a(s)}`)})}}function dt(e,r){let c=pe(r,Le,(n,i)=>{let[t,o]=i;return n.replace("{{execution}}",JSON.stringify(t)).replace("{{item}}",JSON.stringify(o))});return n=>{let{item:i,execution:t}=n.payload;if(t==null)return{...n.payload,verify:{verified:!1,findings:["verifier: prior execute stage produced no execution"],errorClass:"structural"}};let o=[{role:"user",content:c([t,i])}],a=s=>({...n.payload,verify:{verified:!1,findings:[s],errorClass:"self-correctable"}}),u=s=>s instanceof Error?s.message:String(s);return Me(e,o,{onSuccess:s=>{let l;try{l=JSON.parse($e(String(s.content)))}catch(f){return a(`verify parse error: ${u(f)}`)}if(l==null||typeof l!="object"||Array.isArray(l))return a(`verify parse error: non-object response: ${JSON.stringify(l)}`);let m=l;return{...n.payload,verify:{verified:m.verified===!0,findings:m.findings??[],errorClass:m.errorClass}}},onFailure:(s,l)=>a(s==="complete"?"verifier completed without emitting DATA":`verifier failed: ${u(l)}`)})}}var Ce=class extends xe{queues;executeFlow;jobs;gates;queueTopics;strategy;totalRetries;totalReingestions;priorityScores;reflect;constructor(r,c,n,i,t,o,a,u,s,l,m){super(r),this.queues=c,this.executeFlow=n,this.queueTopics=i,this.jobs=t,this.gates=o,this.strategy=a,this.totalRetries=u,this.totalReingestions=s,this.reflect=l,this.priorityScores=m}get intake(){return this.queues.topic(st)}get verifyResults(){return this.queues.topic(ut)}get retry(){return this.queues.topic(it)}get unrouted(){return this.queues.topic(ct)}stageNodes(){let r=this.queues,c=o=>r.has(o)?`queues::${o}::latest`:null,n=o=>o==null?[]:[o],i=M.flatMap(o=>n(c(o))),t=[];for(let[o]of this.gates)t.push(`gates::${o}/gate`);return[{label:"INTAKE",paths:n(c("intake"))},{label:"TRIAGE",paths:["triage"]},{label:"QUEUE",paths:i},{label:"GATE",paths:t},{label:"EXECUTE",paths:["executeFlow::execute::events"]},{label:"VERIFY",paths:["executeFlow::verify::events"]},{label:"REFLECT",paths:["reflect"]},{label:"STRATEGY",paths:["strategy"]}]}};function qt(e,r){let c=r.adapter,n=r.maxRetries??2,i=r.retainedLimit??1e3,t=r.errorClassifier??we,o=new Map;for(let d of M)o.set(d,{...Ae[d],...r.queues?.[d]});let a=Se(`${e}/queues`,{defaultTopicOptions:{retainedLimit:i}}),u=a.topic(st),s=a.topic(Lt),l=a.topic(it),m=a.topic(ut),f=new Map;for(let d of M)f.set(d,a.topic(d));let y=a.topic(ct),g=Qe(),E=De(u.latest,g.node),A=pe(r.triagePrompt,He,(d,p)=>{let[x,k]=p;return d.replace("{{strategy}}",JSON.stringify(Array.from(k.entries()))).replace("{{item}}",JSON.stringify(x))}),R=Ze(c,[E],d=>{let p=d;return!p||!p[0]?"":A(p)},{name:"triage",format:"json"}),$=De(R,E),_=O([$],([d])=>{if(d==null)return;let[p,x]=d;if(!p?.route)return;let k=x?.[0],j={...p,...k};s.publish(j)}).subscribe(()=>{}),ye=new Set(M);for(let d of M)Ge(`bridge/${d}`,s,f.get(d),{map:p=>p.route===d?p:void 0});Ge("bridge/__unrouted",s,y,{map:d=>ye.has(d.route)?void 0:d});let L=new Map,U=new Map;for(let d of M)L.set(d,tt(`jobs/${d}`));let re=[];for(let d of M){let p=f.get(d),x=L.get(d),k=new WeakSet,j=O([p.events],([F])=>{let J=F??[];for(let N of J){if(k.has(N))continue;k.add(N);let D=x.enqueue(N);U.set(me(N),{route:d,id:D})}},{name:`jobs/${d}-mirror`});re.push(j.subscribe(()=>{}))}function G(d){let p=me(d),x=U.get(p);x&&(L.get(x.route)?.removeById(x.id),U.delete(p))}let ne=et("gates"),Q=new Map;for(let d of M){let p=o.get(d);if(!p.gated)continue;let x=f.get(d),k=ne.approvalGate(`${d}/gate`,x.latest,{maxPending:p.maxPending,startOpen:p.startOpen});Q.set(d,k)}let B=[];for(let d of M)o.get(d).gated&&Q.has(d)?B.push(Q.get(d).node):B.push(f.get(d).latest);B.push(l.latest);let oe=Ke(...B),z=r.executor??lt(c,r.executePrompt),ae=r.verifier??dt(c,r.verifyPrompt),ge=r.executeMaxPerPump??Number.MAX_SAFE_INTEGER,se=r.verifyMaxPerPump??Number.MAX_SAFE_INTEGER,q=rt(`${e}/executeFlow`,{stages:[{name:"execute",work:d=>z(d),maxPerPump:ge},{name:"verify",work:d=>ae(d),maxPerPump:se}]}),ie=O([oe],([d])=>{d!=null&&q.enqueue({item:d})},{name:"execute-enqueue"}),ue=ie.subscribe(()=>{}),K=r.maxReingestions??1,ce=Math.min(r.maxTotalRetries??n*10,100),le=Math.min(r.maxTotalReingestions??K*10,100),W=S(0),de=S(0);function be(d,p,x){return{item:x,execution:d,verified:p.verified,findings:p.findings??[],errorClass:p.errorClass}}function Te(d,p){g.record(p.rootCause,p.intervention,!0),m.publish(d),G(p)}function ve(d,p){let x=me(p),k=p.$retries??0,j={...p,$retries:k+1,summary:`[RETRY ${k+1}/${n}] ${x} \u2014 Previous attempt failed: ${d.findings.join("; ")}`,relatedTo:[x]};l.publish(j)}function Ue(d,p){g.record(p.rootCause,p.intervention,!1),m.publish(d),G(p);let x=me(p),k=p.$reingestions??0;k<K&&_e(de,le)&&u.publish({source:p.source,summary:`Verification failed for: ${x}`,evidence:d.findings.join(`
45
+ `),affectsAreas:p.affectsAreas,affectsEvalTasks:p.affectsEvalTasks,severity:p.severity??"high",relatedTo:[x],$reingestions:k+1})}let b=0,T=O([q.completed],([d])=>{let p=d??[];b>p.length&&(b=p.length);let x=b;b=p.length;for(let k=x;k<p.length;k++){let j=p[k],{item:F,execution:J,verify:N}=j.payload;if(J==null||N==null){G(F);continue}let D=be(J,N,F);if(D.verified){Te(D,F);continue}let Pe=D.errorClass??t({item:F,outcome:J.outcome,detail:D.findings.join("; ")}),Fe=F.$retries??0;Pe==="self-correctable"&&Fe<n&&_e(W,ce)?ve(D,F):Ue(D,F)}},{name:"verify-dispatch"}),C=T.subscribe(()=>{}),I=h([q.completed],()=>null,{name:"reflect",equals:()=>!1}),P;r.priority&&(P=jt(f,g,r));let v=new Ce(e,a,q,f,L,Q,g,W,de,I,P);v.addDisposer(_),v.addDisposer(ue),v.addDisposer(C),v.addDisposer(g.dispose);for(let d of re)v.addDisposer(d);if(v.add(E,{name:"triage-input"}),v.add(R,{name:"triage"}),v.add($,{name:"router-input"}),v.add(oe,{name:"execute-input"}),v.add(ie,{name:"execute-enqueue"}),v.add(T,{name:"verify-dispatch"}),v.add(I,{name:"reflect"}),v.add(g.node,{name:"strategy"}),v.addDisposer(I.subscribe(()=>{})),P)for(let[d,p]of P)v.add(p,{name:`priority/${d}`}),v.addDisposer(p.subscribe(()=>{}));v.mount("queues",a),v.mount("gates",ne),v.mount("executeFlow",q);for(let[d,p]of L)v.mount(`jobs/${d}`,p);return v.tagFactory("harnessLoop",Ye(r)),v}function jt(e,r,c){if(!c.lastInteractionNs)throw new Error("harnessLoop: `opts.priority` requires `opts.lastInteractionNs` \u2014 pass a Node<number> (e.g. `fromTimer(60_000)` or a `state(monotonicNs())` you bump on human interaction). Priority scores only decay when this node settles; an internal default would freeze age at construction time.");let n=c.lastInteractionNs,i=c.priority??{},t={...Z,...i.severityWeights},o=i.decayRate??ee,a=i.effectivenessThreshold??.7,u=i.effectivenessBoost??15,s=new Map;for(let[l,m]of e){let f=h([m.latest,r.node,n],y=>{let g=y[0];if(g==null)return 0;let E=t[g.severity??"medium"]??40,A=(H()-y[2])/1e9,R=E*Math.exp(-o*Math.max(0,A)),$=`${g.rootCause}\u2192${g.intervention}`,_=y[1]?.get($);return _&&_.successRate>=a&&(R+=u),R},{name:`priority/${l}`});s.set(l,f)}return s}function Jt(e,r){let c=ze(e,r),n={};for(let i of M){let t=e.queues.has(i)?e.queues.topic(i):null;n[i]=t?.retained().length??0}return{...c,queueDepths:n,strategyEntries:e.strategy.node.cache?.size??0,totalRetries:e.totalRetries.cache??0,totalReingestions:e.totalReingestions.cache??0}}function Qt(e){let r={};for(let{label:c,paths:n}of e.stageNodes())for(let i of n)r[i]=c;return r}function Ut(e,r){let c=r?.logger===null?null:r?.logger??console.log,n=r?.detail??"summary",i=H(),t=[],o=[],a=Qt(e);function u(){return(H()-i)/1e9}function s(l,m,f){let y={elapsed:u(),stage:l,type:m};n!=="summary"&&(y.summary=Bt(f)),n==="full"&&(y.data=f),o.push(y)}for(let[l,m]of Object.entries(a))try{let f=e.observe(l,{format:"stage-log",stageLabels:a,logger:c?y=>c(y):()=>{},includeTypes:["data","error","complete"]});f.onEvent(y=>{y.type==="data"?s(m,"data",y.data):y.type==="error"?s(m,"error",y.data):y.type==="complete"&&s(m,"complete",void 0)}),t.push(f)}catch(f){let y=f instanceof Error?f.message:String(f);s(m,"error",`observe-unavailable: ${l} \u2014 ${y}`),c&&c(`[${u().toFixed(3)}s] ${m.padEnd(9)} \u2717 observe-unavailable: ${y}`)}return{get events(){return o},dispose(){for(let l of t)l.dispose();t.length=0}}}function Bt(e){if(e==null)return"null";if(typeof e=="string")return ft(e,80);if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return String(e);try{let r=JSON.stringify(e);return ft(r,120)}catch{return String(e)}}function ft(e,r){return e.length>r?`${e.slice(0,r-1)}\u2026`:e}export{nt as a,vt as b,ht as c,Et as d,xt as e,Rt as f,It as g,kt as h,Nt as i,St as j,M as k,Ae as l,Z as m,ee as n,te as o,we as p,He as q,Ve as r,Le as s,pe as t,wt as u,je as v,Pt as w,Dt as x,Je as y,at as z,Ht as A,Qe as B,Vt as C,lt as D,dt as E,Ce as F,qt as G,Jt as H,Ut as I,Yt as J};