@graphrefly/graphrefly 0.37.0 → 0.38.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 (248) hide show
  1. package/dist/{chunk-CZIQ6JCE.js → chunk-2YFDSYEF.js} +1 -1
  2. package/dist/{chunk-YVYSO5CW.js → chunk-4BDQXBXE.js} +1 -1
  3. package/dist/chunk-5BGFS2XH.js +1 -0
  4. package/dist/chunk-6773HURD.js +1 -0
  5. package/dist/{chunk-U3COB5WU.js → chunk-6KZZ6XQE.js} +1 -1
  6. package/dist/{chunk-5CPPC75H.js → chunk-6VFC334U.js} +1 -1
  7. package/dist/{chunk-KUVDFOJH.js → chunk-7KZZLWZ6.js} +1 -1
  8. package/dist/{chunk-Q7EUZ6NN.js → chunk-B5S7KTGP.js} +1 -1
  9. package/dist/chunk-CMTN3KPT.js +80 -0
  10. package/dist/chunk-DQJLC6YY.js +1 -0
  11. package/dist/chunk-DSOVKKTI.js +1 -0
  12. package/dist/chunk-FAYEMS5M.js +1 -0
  13. package/dist/chunk-FWGIZP3W.js +1 -0
  14. package/dist/{chunk-FMI4CWFL.js → chunk-G7JN6LCB.js} +1 -1
  15. package/dist/{chunk-PCD2MU7X.js → chunk-IBGE62GZ.js} +1 -1
  16. package/dist/{chunk-MYFR67PY.js → chunk-K5C67OGE.js} +1 -1
  17. package/dist/chunk-KJEAIIIY.js +43 -0
  18. package/dist/chunk-LV3ACS5J.js +1 -0
  19. package/dist/{chunk-LOQRPP4Y.js → chunk-NBGPXQSP.js} +1 -1
  20. package/dist/chunk-NN3QPJ6U.js +1 -0
  21. package/dist/{chunk-QWVQIL3T.js → chunk-NSAZ6PR6.js} +1 -1
  22. package/dist/{chunk-MC5LZG3U.js → chunk-NV63VQHI.js} +1 -1
  23. package/dist/{chunk-2C4NESZE.js → chunk-O245YLM5.js} +1 -1
  24. package/dist/{chunk-TLS7M7H4.js → chunk-O2BLVQU4.js} +1 -1
  25. package/dist/chunk-PHXZRR6C.js +1 -0
  26. package/dist/{chunk-K6ZFJ473.js → chunk-POCWFIJ7.js} +1 -1
  27. package/dist/{chunk-C5CBVOCB.js → chunk-QEVSIVSF.js} +1 -1
  28. package/dist/chunk-QMC2PLNM.js +7 -0
  29. package/dist/chunk-QOJFR6GS.js +1 -0
  30. package/dist/{chunk-MQZWA3DF.js → chunk-RZ5HKPGI.js} +1 -1
  31. package/dist/{chunk-WSLN4JFO.js → chunk-SFK7MN7S.js} +1 -1
  32. package/dist/{chunk-QP5TH523.js → chunk-SP5O2MIX.js} +1 -1
  33. package/dist/chunk-TB7JKSVS.js +61 -0
  34. package/dist/{chunk-T4U24DXX.js → chunk-TMVY7OWG.js} +1 -1
  35. package/dist/{chunk-UODQF4EY.js → chunk-UAXFKMAG.js} +1 -1
  36. package/dist/{chunk-TFK4P4CX.js → chunk-UVLZX2OU.js} +1 -1
  37. package/dist/chunk-XIMFHEKV.js +1 -0
  38. package/dist/{chunk-XIJKEXWR.js → chunk-XLMYQB6F.js} +1 -1
  39. package/dist/{chunk-4EATTNAE.js → chunk-XLYF4LBH.js} +1 -1
  40. package/dist/compat/index.cjs +9 -9
  41. package/dist/compat/index.d.cts +7 -7
  42. package/dist/compat/index.d.ts +7 -7
  43. package/dist/compat/index.js +1 -1
  44. package/dist/compat/nestjs/index.cjs +11 -11
  45. package/dist/compat/nestjs/index.d.cts +5 -5
  46. package/dist/compat/nestjs/index.d.ts +5 -5
  47. package/dist/compat/nestjs/index.js +1 -1
  48. package/dist/compat/zustand/index.cjs +7 -7
  49. package/dist/compat/zustand/index.d.cts +3 -3
  50. package/dist/compat/zustand/index.d.ts +3 -3
  51. package/dist/compat/zustand/index.js +1 -1
  52. package/dist/{composite-_XckYx2e.d.cts → composite-CgG0MqHm.d.cts} +8 -1
  53. package/dist/{composite-CT_mApQD.d.ts → composite-DTOlDuch.d.ts} +8 -1
  54. package/dist/core/index.cjs +1 -1
  55. package/dist/core/index.d.cts +2 -2
  56. package/dist/core/index.d.ts +2 -2
  57. package/dist/core/index.js +1 -1
  58. package/dist/extra/index.cjs +19 -19
  59. package/dist/extra/index.d.cts +5 -5
  60. package/dist/extra/index.d.ts +5 -5
  61. package/dist/extra/index.js +1 -1
  62. package/dist/extra/node.cjs +2 -2
  63. package/dist/extra/node.d.cts +107 -1
  64. package/dist/extra/node.d.ts +107 -1
  65. package/dist/extra/node.js +2 -2
  66. package/dist/extra/operators.cjs +1 -1
  67. package/dist/extra/operators.js +1 -1
  68. package/dist/extra/reactive.d.cts +1 -1
  69. package/dist/extra/reactive.d.ts +1 -1
  70. package/dist/extra/reactive.js +1 -1
  71. package/dist/extra/sources.cjs +1 -1
  72. package/dist/extra/sources.js +1 -1
  73. package/dist/extra/storage-tiers-browser.d.cts +76 -5
  74. package/dist/extra/storage-tiers-browser.d.ts +76 -5
  75. package/dist/extra/storage-tiers-node.d.cts +137 -13
  76. package/dist/extra/storage-tiers-node.d.ts +137 -13
  77. package/dist/extra/storage-tiers.d.cts +151 -23
  78. package/dist/extra/storage-tiers.d.ts +151 -23
  79. package/dist/graph/index.cjs +7 -7
  80. package/dist/graph/index.d.cts +4 -4
  81. package/dist/graph/index.d.ts +4 -4
  82. package/dist/graph/index.js +1 -1
  83. package/dist/{graph-YQXDndFy.d.ts → graph-BjW1taJl.d.ts} +217 -10
  84. package/dist/{graph-CaNXUc3c.d.cts → graph-CHsVwf9S.d.cts} +217 -10
  85. package/dist/{index-CUTHDZ7Q.d.ts → index-5dNRlW7J.d.ts} +3 -3
  86. package/dist/{index-Bpzw8hx3.d.ts → index-AUqWe_fX.d.ts} +7 -4
  87. package/dist/{index-fHKHdAso.d.ts → index-B-ORMr3k.d.ts} +2 -2
  88. package/dist/{index-DcWbx58m.d.cts → index-B2IUcH13.d.cts} +2 -2
  89. package/dist/{index-DuhOdNyg.d.ts → index-BFaALJxR.d.ts} +2 -2
  90. package/dist/{index-DPqR3wdW.d.ts → index-BI1wMfyc.d.ts} +2 -2
  91. package/dist/{index-D0ZxFXYl.d.ts → index-BUFCHvOR.d.ts} +2 -2
  92. package/dist/{index-CLPQyYY5.d.cts → index-BWUMIt7J.d.cts} +3 -3
  93. package/dist/{index-CkN8CZlT.d.cts → index-BaSy4L6w.d.cts} +37 -17
  94. package/dist/{index-B1IcU--K.d.cts → index-BgzPO43H.d.cts} +2 -2
  95. package/dist/{index-D6tRNEKz.d.cts → index-BhzwpIJc.d.cts} +1 -1
  96. package/dist/{index-4IwO4mH2.d.cts → index-BkQqf1EF.d.cts} +80 -7
  97. package/dist/{index-CajEOoAN.d.ts → index-BmWuVdER.d.ts} +2 -2
  98. package/dist/{index-0qOD-421.d.ts → index-Bn0uZEL4.d.ts} +2 -2
  99. package/dist/{index-DAKm44My.d.cts → index-BpMZzX9P.d.cts} +2 -2
  100. package/dist/{index-CrpjECS6.d.cts → index-Bpr0Pwgl.d.cts} +2 -2
  101. package/dist/{index-BECJ8M0T.d.cts → index-BqcgiSQg.d.cts} +2 -2
  102. package/dist/{index-DfAo9WKr.d.ts → index-BsZk9T8y.d.ts} +1 -1
  103. package/dist/{index-CU3z8Cel.d.cts → index-BsgxnHN8.d.cts} +2 -2
  104. package/dist/index-Bub6x_D4.d.cts +427 -0
  105. package/dist/{index-C-pFD_FV.d.ts → index-BwOsJfLJ.d.ts} +2 -2
  106. package/dist/{index-CRycrNfn.d.ts → index-Byp771zP.d.ts} +1 -1
  107. package/dist/{index-e1m3ZHgc.d.cts → index-C-3UXnHT.d.cts} +1 -1
  108. package/dist/{index-DTYIRT_v.d.cts → index-C56XZiDe.d.cts} +2 -2
  109. package/dist/{index-D11pGlaI.d.cts → index-CAV-3RpJ.d.cts} +2 -2
  110. package/dist/{index-D_DThl_J.d.cts → index-CAbHN_rP.d.cts} +1 -1
  111. package/dist/{index-BhLA9feT.d.ts → index-CEVzBWeB.d.ts} +2 -2
  112. package/dist/{index-Ci358GSC.d.cts → index-CM-i58FY.d.cts} +2 -2
  113. package/dist/{index-B9qJmmv3.d.cts → index-CQsqqEVz.d.cts} +1 -1
  114. package/dist/{index-C0tga1_x.d.ts → index-CijfwEWx.d.ts} +2 -2
  115. package/dist/{index-BwtIbzSV.d.cts → index-Ckil6miL.d.cts} +2 -2
  116. package/dist/{index-BokynmA4.d.cts → index-CpdnP-0y.d.cts} +1 -1
  117. package/dist/{index-BmLkcDlj.d.ts → index-CrlHFsiT.d.ts} +37 -17
  118. package/dist/{index-DCAuN9u5.d.cts → index-Czk3r0yA.d.cts} +37 -3
  119. package/dist/{index-C4N-dg5U.d.cts → index-D-B7U42V.d.cts} +2 -2
  120. package/dist/{index-CKcnuQ2c.d.ts → index-D-HZ7sP4.d.ts} +2 -2
  121. package/dist/{index-D6pwWiOc.d.cts → index-D7-RSD93.d.cts} +2 -2
  122. package/dist/{index-9mbs_PIG.d.ts → index-D9vBTuzo.d.ts} +2 -2
  123. package/dist/{index-C_qi0WlF.d.cts → index-DJNAWzcH.d.cts} +2 -2
  124. package/dist/{index-Ae6L8liv.d.ts → index-DJVQ-t07.d.ts} +2 -2
  125. package/dist/{index-D_d1erkR.d.ts → index-DKrIuF-r.d.ts} +2 -2
  126. package/dist/{index-DXz9uwcs.d.ts → index-DOU1Ee_k.d.ts} +1 -1
  127. package/dist/{index-D1E1tqHT.d.ts → index-DTDVDzhA.d.ts} +37 -3
  128. package/dist/{index-B5UR87KG.d.ts → index-DY2f2b9z.d.ts} +4 -2
  129. package/dist/{index-D8IyqHvT.d.cts → index-DeSsvHDD.d.cts} +4 -2
  130. package/dist/index-Di7OdwlO.d.ts +427 -0
  131. package/dist/{index-CzIWlnPp.d.ts → index-DqICM_I7.d.ts} +80 -7
  132. package/dist/{index-BOfHwQc1.d.ts → index-ML6vHKXK.d.ts} +1 -1
  133. package/dist/{index-DqtXA3yX.d.cts → index-UsU9ptzs.d.cts} +7 -4
  134. package/dist/{index-B46GWgk3.d.ts → index-Vz7KPfgz.d.ts} +1 -1
  135. package/dist/index.cjs +50 -50
  136. package/dist/index.d.cts +32 -32
  137. package/dist/index.d.ts +32 -32
  138. package/dist/index.js +1 -1
  139. package/dist/meta-BYqlATmg.d.ts +98 -0
  140. package/dist/meta-DreaEM_a.d.cts +98 -0
  141. package/dist/patterns/ai/browser.cjs +2 -2
  142. package/dist/patterns/ai/browser.js +1 -1
  143. package/dist/patterns/ai/index.cjs +21 -21
  144. package/dist/patterns/ai/index.d.cts +9 -9
  145. package/dist/patterns/ai/index.d.ts +9 -9
  146. package/dist/patterns/ai/index.js +1 -1
  147. package/dist/patterns/ai/node.js +1 -1
  148. package/dist/patterns/audit/index.cjs +7 -7
  149. package/dist/patterns/audit/index.d.cts +5 -5
  150. package/dist/patterns/audit/index.d.ts +5 -5
  151. package/dist/patterns/audit/index.js +1 -1
  152. package/dist/patterns/cqrs/index.cjs +7 -7
  153. package/dist/patterns/cqrs/index.d.cts +4 -4
  154. package/dist/patterns/cqrs/index.d.ts +4 -4
  155. package/dist/patterns/cqrs/index.js +1 -1
  156. package/dist/patterns/demo-shell/index.cjs +8 -8
  157. package/dist/patterns/demo-shell/index.d.cts +4 -4
  158. package/dist/patterns/demo-shell/index.d.ts +4 -4
  159. package/dist/patterns/demo-shell/index.js +1 -1
  160. package/dist/patterns/domain-templates/index.cjs +7 -7
  161. package/dist/patterns/domain-templates/index.d.cts +3 -3
  162. package/dist/patterns/domain-templates/index.d.ts +3 -3
  163. package/dist/patterns/domain-templates/index.js +1 -1
  164. package/dist/patterns/graphspec/index.cjs +21 -21
  165. package/dist/patterns/graphspec/index.d.cts +3 -3
  166. package/dist/patterns/graphspec/index.d.ts +3 -3
  167. package/dist/patterns/graphspec/index.js +1 -1
  168. package/dist/patterns/guarded-execution/index.cjs +7 -7
  169. package/dist/patterns/guarded-execution/index.d.cts +6 -6
  170. package/dist/patterns/guarded-execution/index.d.ts +6 -6
  171. package/dist/patterns/guarded-execution/index.js +1 -1
  172. package/dist/patterns/harness/index.cjs +12 -12
  173. package/dist/patterns/harness/index.d.cts +8 -8
  174. package/dist/patterns/harness/index.d.ts +8 -8
  175. package/dist/patterns/harness/index.js +1 -1
  176. package/dist/patterns/job-queue/index.cjs +7 -7
  177. package/dist/patterns/job-queue/index.d.cts +4 -4
  178. package/dist/patterns/job-queue/index.d.ts +4 -4
  179. package/dist/patterns/job-queue/index.js +1 -1
  180. package/dist/patterns/lens/index.cjs +7 -7
  181. package/dist/patterns/lens/index.d.cts +4 -4
  182. package/dist/patterns/lens/index.d.ts +4 -4
  183. package/dist/patterns/lens/index.js +1 -1
  184. package/dist/patterns/memory/index.cjs +7 -7
  185. package/dist/patterns/memory/index.d.cts +6 -4
  186. package/dist/patterns/memory/index.d.ts +6 -4
  187. package/dist/patterns/memory/index.js +1 -1
  188. package/dist/patterns/messaging/index.cjs +7 -7
  189. package/dist/patterns/messaging/index.d.cts +4 -4
  190. package/dist/patterns/messaging/index.d.ts +4 -4
  191. package/dist/patterns/messaging/index.js +1 -1
  192. package/dist/patterns/orchestration/index.cjs +7 -7
  193. package/dist/patterns/orchestration/index.d.cts +4 -4
  194. package/dist/patterns/orchestration/index.d.ts +4 -4
  195. package/dist/patterns/orchestration/index.js +1 -1
  196. package/dist/patterns/process/index.d.cts +5 -5
  197. package/dist/patterns/process/index.d.ts +5 -5
  198. package/dist/patterns/process/index.js +1 -1
  199. package/dist/patterns/reactive-layout/index.cjs +8 -8
  200. package/dist/patterns/reactive-layout/index.d.cts +4 -4
  201. package/dist/patterns/reactive-layout/index.d.ts +4 -4
  202. package/dist/patterns/reactive-layout/index.js +1 -1
  203. package/dist/patterns/reduction/index.cjs +7 -7
  204. package/dist/patterns/reduction/index.d.cts +3 -3
  205. package/dist/patterns/reduction/index.d.ts +3 -3
  206. package/dist/patterns/reduction/index.js +1 -1
  207. package/dist/patterns/refine-loop/index.cjs +8 -8
  208. package/dist/patterns/refine-loop/index.d.cts +5 -5
  209. package/dist/patterns/refine-loop/index.d.ts +5 -5
  210. package/dist/patterns/refine-loop/index.js +1 -1
  211. package/dist/patterns/resilient-pipeline/index.cjs +1 -1
  212. package/dist/patterns/resilient-pipeline/index.d.cts +4 -4
  213. package/dist/patterns/resilient-pipeline/index.d.ts +4 -4
  214. package/dist/patterns/resilient-pipeline/index.js +1 -1
  215. package/dist/patterns/surface/index.cjs +14 -14
  216. package/dist/patterns/surface/index.d.cts +4 -4
  217. package/dist/patterns/surface/index.d.ts +4 -4
  218. package/dist/patterns/surface/index.js +1 -1
  219. package/dist/{pipeline-graph-DX2Twdj-.d.ts → pipeline-graph-9JBbmRxA.d.ts} +2 -2
  220. package/dist/{pipeline-graph-BrrYGjuZ.d.cts → pipeline-graph-DuHpXSOn.d.cts} +2 -2
  221. package/dist/{reactive-layout-DrGjuwyC.d.cts → reactive-layout-BMLDB4Vd.d.cts} +1 -1
  222. package/dist/{reactive-layout-BDdngW56.d.ts → reactive-layout-D-tRiNhg.d.ts} +1 -1
  223. package/dist/{reactive-log-jirQsxMY.d.ts → reactive-log-BgWSA1fg.d.ts} +28 -1
  224. package/dist/{reactive-log-ScpWyqny.d.cts → reactive-log-C3IMAGpT.d.cts} +28 -1
  225. package/dist/resilience-LGBK236C.js +1 -0
  226. package/dist/{topology-tree-BI665P0L.d.ts → topology-tree-D47-nI6Z.d.ts} +1 -1
  227. package/dist/{topology-tree-BkhmMg2a.d.cts → topology-tree-jrZue3ao.d.cts} +1 -1
  228. package/package.json +1 -1
  229. package/dist/chunk-533RQFF6.js +0 -1
  230. package/dist/chunk-6SVKZ7VI.js +0 -1
  231. package/dist/chunk-A5HZZYRK.js +0 -1
  232. package/dist/chunk-B4L5X2QO.js +0 -7
  233. package/dist/chunk-FJ6IEMOS.js +0 -1
  234. package/dist/chunk-G6Q3DUMJ.js +0 -1
  235. package/dist/chunk-GDDPCDLG.js +0 -1
  236. package/dist/chunk-GFOT6UBB.js +0 -1
  237. package/dist/chunk-JJTF75VS.js +0 -1
  238. package/dist/chunk-K2WYIVHM.js +0 -1
  239. package/dist/chunk-KTWBUJO5.js +0 -61
  240. package/dist/chunk-M27MVZCP.js +0 -1
  241. package/dist/chunk-NKKUUKPD.js +0 -43
  242. package/dist/chunk-QKBCTKH7.js +0 -1
  243. package/dist/chunk-WGST56ZH.js +0 -80
  244. package/dist/index-BCq12BqB.d.ts +0 -139
  245. package/dist/index-DbWwMWiB.d.cts +0 -139
  246. package/dist/meta-BGO6C7K9.d.cts +0 -41
  247. package/dist/meta-CC6EPdpK.d.ts +0 -41
  248. package/dist/resilience-OBU472D2.js +0 -1
@@ -0,0 +1,43 @@
1
+ import{a as Fe}from"./chunk-O245YLM5.js";import{d as _e}from"./chunk-FWGIZP3W.js";import{u as X}from"./chunk-TB7JKSVS.js";import{a as Me}from"./chunk-LV3ACS5J.js";import{c as $e}from"./chunk-QOJFR6GS.js";import{g as Ce,i as ue}from"./chunk-6KZZ6XQE.js";import{b as ie,d as U}from"./chunk-O32GJOUJ.js";import{g as Ae,k as Se}from"./chunk-QMC2PLNM.js";import{b as S,s as q,t as we,x as F}from"./chunk-6773HURD.js";import{b as Ne}from"./chunk-DQJLC6YY.js";import{b as Oe}from"./chunk-TZQPPQEQ.js";import{m as z}from"./chunk-RZ5HKPGI.js";import{D as ke,E as A,F as Q,G as k,H as M,o as V}from"./chunk-LYCLF26R.js";import{b as _,i as P,j as W}from"./chunk-CK2E7BTU.js";import{b as et}from"./chunk-QYADASLV.js";var St={};et(St,{DEFAULT_DECAY_RATE:()=>D,DEFAULT_EXECUTE_PROMPT:()=>ce,DEFAULT_QUEUE_CONFIGS:()=>Z,DEFAULT_SEVERITY_WEIGHTS:()=>L,DEFAULT_TRIAGE_PROMPT:()=>le,DEFAULT_VERIFY_PROMPT:()=>de,HarnessGraph:()=>te,QUEUE_NAMES:()=>b,actuatorExecutor:()=>Pe,affectedTaskFilter:()=>dt,autoSolidify:()=>at,beforeAfterCompare:()=>ct,codeChangeBridge:()=>pt,createIntakeBridge:()=>it,defaultErrorClassifier:()=>ee,defaultLlmExecutor:()=>He,defaultLlmVerifier:()=>Qe,dispatchActuator:()=>st,evalIntakeBridge:()=>ut,evalSource:()=>lt,evalVerifier:()=>Ve,harnessEvalPair:()=>Rt,harnessLoop:()=>ht,harnessProfile:()=>bt,harnessTrace:()=>Nt,notifyEffect:()=>ft,priorityScore:()=>vt,refineExecutor:()=>pe,resolvePromptFn:()=>B,strategyKey:()=>j,strategyModel:()=>fe});function tt(e,t){return{outcome:"success",detail:`actuator applied ${t.intervention} for ${ot(t.summary)}`,artifact:e}}function rt(e,t){let n=e instanceof Error?e.message:String(e);return{outcome:"failure",detail:`actuator threw on ${t.intervention}: ${n}`}}function nt(e){return`actuator skipped ${e.intervention} (shouldApply returned false)`}function ot(e,t=80){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}function Pe(e){let t=e.name??"actuator-executor",n=e.toOutput??tt,o=e.onError??rt,r=e.skipDetail??nt;return c=>{let s=S(c,i=>i!=null,{name:`${t}/gate-in`}),a=F(s,i=>e.shouldApply&&!e.shouldApply(i)?Q(d=>(d.down([[_,{outcome:"failure",detail:r(i)}],[P]]),()=>{}),{name:`${t}/skip`}):Q(d=>{let m=new AbortController,f=!1,l=null,g=v=>{f||(f=!0,d.down([[_,v],[P]]),l?.(),l=null)},y;try{let v=e.apply(i,{signal:m.signal});y=z(v,{signal:m.signal})}catch(v){return g(o(v,i)),()=>{m.abort()}}return l=y.subscribe(v=>{for(let E of v){if(f)return;if(E[0]===_){g(n(E[1],i));return}if(E[0]===W){g(o(E[1],i));return}if(E[0]===P){g(o(new Error("actuator inner completed without emitting DATA"),i));return}}}),f&&l&&(l(),l=null),()=>{m.abort(),l?.(),l=null}},{name:`${t}/inner`}),{name:t});return S(a,i=>i!=null,{name:`${t}/gate-out`})}}function st(e){let t=e.name??"dispatch-actuator",n=e.default??null,o=n!=null;return Pe({apply:(r,c)=>{let s=Object.hasOwn(e.routes,r.intervention)?e.routes[r.intervention]:n;if(!s)throw new Error(`dispatchActuator: no route for intervention '${r.intervention}'`);return s(r,c)},shouldApply:r=>Object.hasOwn(e.routes,r.intervention)||o,skipDetail:r=>`no route for intervention '${r.intervention}'`,name:t})}function at(e){let t=e.name??"auto-solidify",n=e.extract??(r=>r.execution.artifact??null),o=e.predicate??(()=>!0);return Q(r=>{let c=null,s=!1,a=()=>{s||(s=!0,c?.(),c=null)},i=d=>{s||(r.down([[W,d]]),a())};return c=e.verifyResults.subscribe(d=>{if(!s)for(let m of d){if(s)return;if(m[0]!==_){if(m[0]===P){r.down([[P]]),a();return}continue}let f=m[1];if(f==null||!f.verified)continue;let l;try{l=o(f)}catch(y){i(y);return}if(!l)continue;let g;try{g=n(f)}catch(y){i(y);return}if(g!=null){try{e.write(g,f)}catch(y){i(y);return}r.down([[_,g]])}}}),s&&c&&(c(),c=null),()=>{a()}},{name:t})}function it(e,t,n,o){return M([e],([r])=>{if(r==null)return;let c=n(r);for(let s of c)t.publish(s)},{name:o?.name??"intake-bridge"})}function ut(e,t,n){let o=n?.defaultSeverity??"medium";return M([e],([r])=>{if(r==null)return;let c=Array.isArray(r)?r:[r];for(let s of c)for(let a of s.tasks)if(!(a.valid&&a.judge_scores?.every(i=>i.pass))){if(!a.valid&&(!a.judge_scores||a.judge_scores.length===0)){t.publish({source:"eval",summary:`Task ${a.task_id} invalid (model: ${s.model})`,evidence:`Run ${s.run_id}: task produced invalid output`,affectsAreas:["graphspec"],affectsEvalTasks:[a.task_id],severity:o});continue}if(a.judge_scores)for(let i of a.judge_scores)i.pass||t.publish({source:"eval",summary:`${a.task_id}: ${i.claim} (model: ${s.model})`,evidence:i.reasoning,affectsAreas:["graphspec"],affectsEvalTasks:[a.task_id],severity:o})}},{name:n?.name??"eval-intake-bridge"})}function lt(e,t){return F(e,()=>z(t()))}function ct(e,t){return k([e,t],([n,o])=>{let r=n,c=o,s=new Map(r.tasks.map(l=>[l.task_id,l])),a=new Map(c.tasks.map(l=>[l.task_id,l])),i=new Set([...s.keys(),...a.keys()]),d=[],m=[],f=[];for(let l of i){let g=s.get(l),y=a.get(l),v=g?.valid??!1,E=y?.valid??!1,I=g?.judge_scores?g.judge_scores.filter(O=>O.pass).length:void 0,N=y?.judge_scores?y.judge_scores.filter(O=>O.pass).length:void 0,w=I!==void 0&&N!==void 0?N-I:void 0;d.push({taskId:l,before:v,after:E,scoreDiff:w}),v&&!E&&m.push(l),!v&&E&&f.push(l)}return{newFailures:m,resolved:f,taskDeltas:d,overallImproved:f.length>m.length}},{name:"eval-delta"})}function dt(e,t){let n=t==null?null:Array.isArray(t)?A(t):t,o=[e];return n&&o.push(n),k(o,r=>{let c=r[0],s=n?new Set(r[1]):null,a=new Set;for(let i of c)for(let d of i.affectsEvalTasks??[])(s==null||s.has(d))&&a.add(d);return[...a].sort()},{name:"affected-task-filter"})}function pt(e,t,n,o){let r=o?.defaultSeverity??"high";function c(a){let i=[];for(let d of a.lintErrors??[])i.push({source:"code-change",summary:`Lint: ${d.rule} in ${d.file}:${d.line}`,evidence:d.message,affectsAreas:[d.file],severity:r});for(let d of a.testFailures??[])i.push({source:"test",summary:`Test failure: ${d.testId}`,evidence:d.message,affectsAreas:[d.file],affectsEvalTasks:[d.testId],severity:r});return i}let s=n??c;return M([e],([a])=>{if(a!=null)for(let i of s(a))t.publish(i)},{name:o?.name??"code-change-bridge"})}function ft(e,t,n){return M([e.latest],([o])=>{o!=null&&t(o)},{name:n?.name??"notify-effect"})}var b=["auto-fix","needs-decision","investigation","backlog"],Z={"auto-fix":{gated:!1},"needs-decision":{gated:!0},investigation:{gated:!0},backlog:{gated:!1}},L={critical:100,high:70,medium:40,low:10},D=Math.LN2/(168*3600);function j(e,t){return`${e}\u2192${t}`}var mt=/\b(parse|json|config|validation|syntax)\b/i,ee=e=>mt.test(e.detail)?"self-correctable":"structural",le=`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}}`,ce=`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
+ }`,de=`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 B(e,t,n){if(typeof e=="function")return e;let o=e??t;return r=>n(o,r)}function gt(e){let{best:t,score:n,status:o}=e,r=Number.isFinite(n)?n.toFixed(3):String(n),c=t??void 0;return o==="converged"?{outcome:"success",detail:`refineLoop converged at score ${r}`,artifact:c}:o==="budget"?{outcome:"partial",detail:`refineLoop hit budget at score ${r}`,artifact:c}:{outcome:"failure",detail:`refineLoop errored (status=${o})`,artifact:c}}function pe(e){let t=e.name??"refine-executor",n=e.toOutput??gt;return o=>{let r=S(o,s=>s!=null,{name:`${t}/gate-in`}),c=F(r,s=>{let a=Fe(e.seedFrom(s),e.evaluator,e.strategy,{...e.refine,dataset:e.datasetFor(s),name:`${t}/inner`});return k([a.status,a.best,a.score],([i,d,m])=>{let f=i;return f!=="converged"&&f!=="budget"&&f!=="errored"?null:n({best:d,score:m,status:f})},{name:`${t}/output`})},{name:t});return S(c,s=>s!=null,{name:`${t}/gate-out`})}}function yt(e){if(e.length===0)return Number.NEGATIVE_INFINITY;let t=0;for(let n of e)t+=n.score;return t/e.length}function Tt(e){let{passCount:t,total:n,meanScore:o,threshold:r,missingArtifact:c}=e,s=Number.isFinite(o)?o.toFixed(3):String(o),a=!c&&n>0&&o>=r,i=c?["EXECUTE stage did not emit an artifact; cannot verify reactively"]:a?[`${t}/${n} eval tasks passed; mean score ${s} \u2265 ${r}`]:n===0?["No eval tasks were selected for this item \u2014 cannot verify"]:[`${t}/${n} eval tasks passed; mean score ${s} < threshold ${r}`];return a?{verified:!0,findings:i}:{verified:!1,findings:i,errorClass:"structural"}}function Et(e){return e.artifact??null}function Ve(e){let t=e.name??"eval-verifier",n=e.threshold??.5,o=e.toOutput??Tt,r=e.extractArtifact??Et;return c=>{let s=S(c,i=>i!=null&&i[0]!=null&&i[1]!=null,{name:`${t}/gate-in`}),a=F(s,i=>{let[d,m]=i,f=r(d,m);if(f==null)return A(o({scores:[],meanScore:Number.NEGATIVE_INFINITY,passCount:0,total:0,threshold:n,missingArtifact:!0}));let l=A([f],{name:`${t}/candidates`}),g=A(e.datasetFor(m),{name:`${t}/dataset`}),y=e.evaluator(l,g);return k([y],([v])=>{let E=v;if(E==null)return null;let I=yt(E),N=E.filter(w=>w.score>=n).length;return o({scores:E,meanScore:I,passCount:N,total:E.length,threshold:n})},{name:`${t}/output`})},{name:t});return S(a,i=>i!=null,{name:`${t}/gate-out`})}}function Rt(e){let t=e.name??"harness-pair",n=pe({name:`${t}-exec`,seedFrom:e.seedFrom,evaluator:e.evaluator,strategy:e.strategy,datasetFor:e.datasetFor,refine:e.refine}),o=Ve({name:`${t}-verify`,evaluator:e.evaluator,datasetFor:e.datasetFor,threshold:e.threshold});return{executor:n,verifier:o}}function fe(){let e=Oe({name:"strategy-entries"}),t=k([e.entries],([s])=>{let a=s;return new Map(a)},{name:"strategy-model",equals:(s,a)=>{let i=s,d=a;if(i.size!==d.size)return!1;for(let[m,f]of i){let l=d.get(m);if(!l||f.attempts!==l.attempts||f.successes!==l.successes)return!1}return!0}});function n(s,a,i){let d=j(s,a),m=e.get(d),f=(m?.attempts??0)+1,l=(m?.successes??0)+(i?1:0);e.set(d,{rootCause:s,intervention:a,attempts:f,successes:l,successRate:l/f})}function o(s,a){return e.get(j(s,a))}let r=t.subscribe(()=>{});function c(){r()}return{node:t,record:n,lookup:o,dispose:c}}function vt(e,t,n,o,r){let c={...L,...r?.severityWeights},s=r?.decayRate??D,a=r?.effectivenessThreshold??.7,i=r?.effectivenessBoost??15,d=[e,t,n];return o&&d.push(o),k(d,m=>{let f=m[0],l=m[1],g=m[2],y=o?m[3]:0,v=c[f.severity??"medium"],E=(V()-g)/1e9,I=Me(v,E,s,0),N=j(f.rootCause,f.intervention),w=l.get(N);return w&&w.successRate>=a&&(I+=i),I+=y*20,I},{name:"priority-score"})}var Le="intake",xt="triage-output",De="retry",je="verify-results",Ge="__unrouted";function He(e,t){let n=B(t,ce,(o,r)=>o.replace("{{item}}",JSON.stringify(r)));return o=>X(e,[o],n,{name:"execute",format:"json"})}function Qe(e,t){let n=B(t,de,(o,r)=>{let[c,s]=r;return o.replace("{{execution}}",JSON.stringify(c)).replace("{{item}}",JSON.stringify(s))});return o=>X(e,[o],r=>r==null?"":n(r),{name:"verify",format:"json"})}var te=class extends Se{queues;jobs;gates;queueTopics;strategy;totalRetries;totalReingestions;priorityScores;constructor(t,n,o,r,c,s,a,i,d){super(t),this.queues=n,this.queueTopics=o,this.jobs=r,this.gates=c,this.strategy=s,this.totalRetries=a,this.totalReingestions=i,this.priorityScores=d}get intake(){return this.queues.topic(Le)}get verifyResults(){return this.queues.topic(je)}get retry(){return this.queues.topic(De)}get unrouted(){return this.queues.topic(Ge)}stageNodes(){let t=this.queues,n=s=>t.has(s)?`queues::${s}::latest`:null,o=s=>s==null?[]:[s],r=b.flatMap(s=>o(n(s))),c=[];for(let[s]of this.gates)c.push(`gates::${s}/gate`);return[{label:"INTAKE",paths:o(n("intake"))},{label:"TRIAGE",paths:["triage"]},{label:"QUEUE",paths:r},{label:"GATE",paths:c},{label:"EXECUTE",paths:["execute"]},{label:"VERIFY",paths:o(n("verify-results"))},{label:"REFLECT",paths:["reflect"]},{label:"STRATEGY",paths:["strategy"]}]}};function ht(e,t){let n=t.adapter,o=t.maxRetries??2,r=t.retainedLimit??1e3,c=t.errorClassifier??ee,s=new Map;for(let u of b)s.set(u,{...Z[u],...t.queues?.[u]});let a=Ce(`${e}/queues`,{defaultTopicOptions:{retainedLimit:r}}),i=a.topic(Le),d=a.topic(xt),m=a.topic(De),f=a.topic(je),l=new Map;for(let u of b)l.set(u,a.topic(u));let g=a.topic(Ge),y=fe(),v=q(i.latest,y.node),E=B(t.triagePrompt,le,(u,p)=>{let[T,x]=p;return u.replace("{{strategy}}",JSON.stringify(Array.from(x.entries()))).replace("{{item}}",JSON.stringify(T))}),I=X(n,[v],u=>{let p=u;return!p||!p[0]?"":E(p)},{name:"triage",format:"json"}),N=q(I,v),O=M([N],([u])=>{if(u==null)return;let[p,T]=u;if(!p?.route)return;let x=T?.[0],C={...p,...x};d.publish(C)}).subscribe(()=>{}),qe=new Set(b);for(let u of b)ue(`bridge/${u}`,d,l.get(u),{map:p=>p.route===u?p:void 0});ue("bridge/__unrouted",d,g,{map:u=>qe.has(u.route)?void 0:u});let G=new Map,re=new Map;for(let u of b)G.set(u,_e(`jobs/${u}`));let me=[];for(let u of b){let p=l.get(u),T=G.get(u),x=new WeakSet,C=M([p.events],([ae])=>{let H=ae??[];for(let h of H){if(x.has(h))continue;x.add(h);let $=T.enqueue(h);re.set(U(h),{route:u,id:$})}},{name:`jobs/${u}-mirror`});me.push(C.subscribe(()=>{}))}function ge(u){let p=U(u),T=re.get(p);T&&(G.get(T.route)?.removeById(T.id),re.delete(p))}let ye=$e("gates"),Y=new Map;for(let u of b){let p=s.get(u);if(!p.gated)continue;let T=l.get(u),x=ye.gate(`${u}/gate`,T.latest,{maxPending:p.maxPending,startOpen:p.startOpen});Y.set(u,x)}let J=[];for(let u of b)s.get(u).gated&&Y.has(u)?J.push(Y.get(u).node):J.push(l.get(u).latest);J.push(m.latest);let ne=we(...J),Te=(t.executor??He(n,t.executePrompt))(ne),oe=q(Te,ne),Ee=(t.verifier??Qe(n,t.verifyPrompt))(oe),Re=q(Ee,oe),ve=t.maxReingestions??1,Be=Math.min(t.maxTotalRetries??o*10,100),Ye=Math.min(t.maxTotalReingestions??ve*10,100),xe=A(0),he=A(0);function Je(u,p,T){let x={item:T,outcome:p?.outcome??"failure",detail:p?.detail??"unknown",artifact:p?.artifact};return{item:T,execution:x,verified:u.verified,findings:u.findings??[],errorClass:u.errorClass}}function Ke(u,p){y.record(p.rootCause,p.intervention,!0),f.publish(u),ge(p)}function We(u,p){let T=U(p),x=p.$retries??0,C={...p,$retries:x+1,summary:`[RETRY ${x+1}/${o}] ${T} \u2014 Previous attempt failed: ${u.findings.join("; ")}`,relatedTo:[T]};m.publish(C)}function Ie(u,p){y.record(p.rootCause,p.intervention,!1),f.publish(u),ge(p);let T=U(p),x=p.$reingestions??0;x<ve&&ie(he,Ye)&&i.publish({source:p.source,summary:`Verification failed for: ${T}`,evidence:u.findings.join(`
43
+ `),affectsAreas:p.affectsAreas,affectsEvalTasks:p.affectsEvalTasks,severity:p.severity??"high",relatedTo:[T],$reingestions:x+1})}let se=ke([Re],(u,p)=>{let T=u[0];if(T==null||T.length===0)return;let x=T[T.length-1];if(x==null)return;let[C,ae]=x,[H,h]=ae??[null,null];if(!C||!h)return;if(H==null){Ie({item:h,execution:{item:h,outcome:"failure",detail:"executor returned null"},verified:!1,findings:["executor returned null"],errorClass:"structural"},h);return}let $=Je(C,H,h);if($.verified){Ke($,h);return}let Xe=$.errorClass??c({item:h,outcome:H.outcome,detail:$.findings.join("; ")}),Ze=h.$retries??0;Xe==="self-correctable"&&Ze<o&&ie(xe,Be)?We($,h):Ie($,h)}),ze=se.subscribe(()=>{}),be=k([se],()=>null,{name:"reflect",equals:()=>!1}),K;t.priority&&(K=It(l,y,t));let R=new te(e,a,l,G,Y,y,xe,he,K);R.addDisposer(O),R.addDisposer(ze),R.addDisposer(y.dispose);for(let u of me)R.addDisposer(u);if(R.add(I,{name:"triage"}),R.add(ne,{name:"execute-input"}),R.add(Te,{name:"execute"}),R.add(oe,{name:"execute-context"}),R.add(Ee,{name:"verify"}),R.add(Re,{name:"verify-context"}),R.add(se,{name:"verify-dispatch"}),R.add(be,{name:"reflect"}),R.add(y.node,{name:"strategy"}),R.addDisposer(be.subscribe(()=>{})),K)for(let[u,p]of K)R.add(p,{name:`priority/${u}`}),R.addDisposer(p.subscribe(()=>{}));R.mount("queues",a),R.mount("gates",ye);for(let[u,p]of G)R.mount(`jobs/${u}`,p);return R.tagFactory("harnessLoop",Ne(t)),R}function It(e,t,n){if(!n.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 o=n.lastInteractionNs,r=n.priority??{},c={...L,...r.severityWeights},s=r.decayRate??D,a=r.effectivenessThreshold??.7,i=r.effectivenessBoost??15,d=new Map;for(let[m,f]of e){let l=k([f.latest,t.node,o],g=>{let y=g[0];if(y==null)return 0;let v=c[y.severity??"medium"]??40,E=(V()-g[2])/1e9,I=v*Math.exp(-s*Math.max(0,E)),N=`${y.rootCause}\u2192${y.intervention}`,O=g[1]?.get(N);return O&&O.successRate>=a&&(I+=i),I},{name:`priority/${m}`});d.set(m,l)}return d}function bt(e,t){let n=Ae(e,t),o={};for(let r of b){let c=e.queues.has(r)?e.queues.topic(r):null;o[r]=c?.retained().length??0}return{...n,queueDepths:o,strategyEntries:e.strategy.node.cache?.size??0,totalRetries:e.totalRetries.cache??0,totalReingestions:e.totalReingestions.cache??0}}function kt(e){let t={};for(let{label:n,paths:o}of e.stageNodes())for(let r of o)t[r]=n;return t}function Nt(e,t){let n=t?.logger===null?null:t?.logger??console.log,o=t?.detail??"summary",r=V(),c=[],s=[],a=kt(e);function i(){return(V()-r)/1e9}function d(m,f,l){let g={elapsed:i(),stage:m,type:f};o!=="summary"&&(g.summary=At(l)),o==="full"&&(g.data=l),s.push(g)}for(let[m,f]of Object.entries(a))try{let l=e.observe(m,{format:"stage-log",stageLabels:a,logger:n?g=>n(g):()=>{},includeTypes:["data","error","complete"]});l.onEvent(g=>{g.type==="data"?d(f,"data",g.data):g.type==="error"?d(f,"error",g.data):g.type==="complete"&&d(f,"complete",void 0)}),c.push(l)}catch(l){let g=l instanceof Error?l.message:String(l);d(f,"error",`observe-unavailable: ${m} \u2014 ${g}`),n&&n(`[${i().toFixed(3)}s] ${f.padEnd(9)} \u2717 observe-unavailable: ${g}`)}return{get events(){return s},dispose(){for(let m of c)m.dispose();c.length=0}}}function At(e){if(e==null)return"null";if(typeof e=="string")return Ue(e,80);if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return String(e);try{let t=JSON.stringify(e);return Ue(t,120)}catch{return String(e)}}function Ue(e,t){return e.length>t?`${e.slice(0,t-1)}\u2026`:e}export{Pe as a,st as b,at as c,it as d,ut as e,lt as f,ct as g,dt as h,pt as i,ft as j,b as k,Z as l,L as m,D as n,j as o,ee as p,le as q,ce as r,de as s,B as t,pe as u,Ve as v,Rt as w,fe as x,vt as y,He as z,Qe as A,te as B,ht as C,bt as D,Nt as E,St as F};
@@ -0,0 +1 @@
1
+ import{a as H,b as Z,c as E,e as J}from"./chunk-NN3QPJ6U.js";import{c as oe}from"./chunk-O32GJOUJ.js";import{k as W}from"./chunk-QMC2PLNM.js";import{b as O}from"./chunk-TZQPPQEQ.js";import{C as I,f as te}from"./chunk-RZ5HKPGI.js";import{C as Y,E as ne,G as C,o as V,p as X}from"./chunk-LYCLF26R.js";import{b as ce}from"./chunk-QYADASLV.js";var he={};ce(he,{collection:()=>ye,cosineSimilarity:()=>de,decay:()=>ee,knowledgeGraph:()=>pe,lightCollection:()=>ge,vectorIndex:()=>me});var le=1e9;function S(t,e){return oe("memory",t,e)}function L(t,e){return t instanceof Y?t:ne(t,e?{name:e}:void 0)}function re(t,e){return(t-e)/le}function ee(t,e,d,o=0){if(!Number.isFinite(t))return o;if(!Number.isFinite(e)||e<=0||!Number.isFinite(d)||d<=0)return Math.max(o,t);let s=t*Math.exp(-d*e);return Math.max(o,s)}function de(t,e){let d=Math.max(t.length,e.length),o=0,s=0,f=0;for(let y=0;y<d;y+=1){let b=t[y]??0,M=e[y]??0;o+=b*M,s+=b*b,f+=M*M}if(s===0||f===0)return 0;let u=o/Math.sqrt(s*f);return Number.isFinite(u)?u:0}function ue(t,e){if(t===e)return!0;if(t==null||e==null||t.length!==e.length)return!1;for(let d=0;d<t.length;d+=1){let o=t[d],s=e[d];if(o.id!==s.id||o.score!==s.score||o.meta!==s.meta)return!1}return!0}function ge(t={}){let e=t.maxSize;if(e!==void 0&&e<1)throw new RangeError("lightCollection: maxSize must be >= 1");let d=O({name:t.name,...e!==void 0?{maxSize:e}:{}}),o=d.entries,s=H({name:t.name?`${t.name}_events`:"events",retainedLimit:1024}),f=(m,h)=>{let v=V(),x=o.cache?.get(m);d.set(m,{id:m,value:h,createdAtNs:x?.createdAtNs??v,lastAccessNs:v})},u=m=>{d.has(m)&&d.delete(m)},y=()=>{d.size!==0&&d.clear()},b=E(f,{audit:s,onSuccess:([m],h,v)=>({action:"upsert",id:m,t_ns:v.t_ns}),onFailure:(m,h,v)=>({action:"upsert",t_ns:v.t_ns,handlerVersion:{id:"lightCollection.upsert",version:1}})}),M=E(u,{audit:s,onSuccess:([m],h,v)=>({action:"remove",id:m,t_ns:v.t_ns})}),k=E(y,{audit:s,onSuccess:(m,h,v)=>({action:"clear",t_ns:v.t_ns})});function p(m){let h=L(m,"id");return C([o,h],([v,x])=>v?.get(x),{describeKind:"derived",meta:S("light_collection_item")})}function N(m){let h=L(m,"id");return C([o,h],([v,x])=>v?.has(x)??!1,{describeKind:"derived",meta:S("light_collection_has")})}return{entries:o,events:s,upsert:b,remove:M,clear:k,itemNode:p,hasNode:N}}function fe(t,e){if(t===e)return!0;if(t==null||e==null||t.length!==e.length)return!1;for(let d=0;d<t.length;d+=1){let o=t[d],s=e[d];if(o.id!==s.id||o.score!==s.score||o.lastAccessNs!==s.lastAccessNs||o.value!==s.value)return!1}return!0}function ye(t,e={}){let d=e.maxSize,o=e.decayRate??0,s=e.minScore??0;if(d!==void 0&&d<1)throw new RangeError("collection: maxSize must be >= 1");let f=()=>1,u=e.score??f,y=u instanceof Y?u:void 0,b=()=>y?y.cache??f:u,M=new W(t),p=O({name:"items",...d!==void 0?{retention:{score:(i,r)=>ee(r.baseScore,re(V(),r.lastAccessNs),o,s),maxSize:d}}:{}});M.add(p.entries,{name:"items"});let N;if(o>0){let i=e.refreshIntervalMs??Math.max(1,1e3*Math.LN2/(10*o)),r=te(i,{period:i});N=C([r],()=>V(),{name:"refresh_tick_ns",describeKind:"derived",initial:V(),meta:S("clock")}),M.add(N,{name:"refresh_tick_ns"})}let m=[p.entries];N&&m.push(N),y&&m.push(y);let h=C(m,i=>{let r=i[0],g;if(N){let T=i[1];g=typeof T=="number"?T:V()}else g=V();if(!r||r.size===0)return[];let R=[];for(let T of r.values())R.push({...T,score:ee(T.baseScore,re(g,T.lastAccessNs),o,s)});return R.sort((T,w)=>w.score-T.score||w.lastAccessNs-T.lastAccessNs),R},{name:"ranked",describeKind:"derived",equals:fe,meta:S("ranked")});M.add(h,{name:"ranked"});let v=C([p.entries],([i])=>(i??new Map).size,{name:"size",describeKind:"derived",initial:0,meta:S("size")});M.add(v,{name:"size"}),M.addDisposer(I(v));let x=H({name:"events",retainedLimit:1024,graph:M}),K=J(M,"seq",0),G=(i,r,g)=>{let R=V(),T=p.get(i),w=g?.score??b()(r);p.set(i,{id:i,value:r,baseScore:w,createdAtNs:T?.createdAtNs??R,lastAccessNs:R})},F=i=>{p.has(i)&&p.delete(i)},j=()=>{p.size!==0&&p.clear()},D=()=>{let i=b(),r=p.entries.cache;if(!r||r.size===0)return;let g=[];for(let R of r.values())g.push([R.id,{...R,baseScore:i(R.value)}]);p.setMany(g)},B=E(G,{audit:x,seq:K,onSuccess:([i],r,g)=>({action:"upsert",id:i,t_ns:g.t_ns,seq:g.seq})}),P=E(F,{audit:x,seq:K,onSuccess:([i],r,g)=>({action:"remove",id:i,t_ns:g.t_ns,seq:g.seq})}),c=E(j,{audit:x,seq:K,onSuccess:(i,r,g)=>({action:"clear",t_ns:g.t_ns,seq:g.seq})}),n=E(D,{audit:x,seq:K,onSuccess:(i,r,g)=>({action:"rescore",t_ns:g.t_ns,seq:g.seq})});function a(i){let r=L(i,"id");return C([p.entries,r],([g,R])=>g?.get(R),{describeKind:"derived",meta:S("collection_item")})}return Object.assign(M,{events:x,items:p.entries,ranked:h,size:v,upsert:B,remove:P,clear:c,rescore:n,itemNode:a})}function me(t={}){let e=t.backend??"flat",d=t.dimension,o=t.strictDimension??!0,s=t.maxSize,f=t.retentionScore,u;if(e==="hnsw"&&(u=t.hnswFactory?.(),!u))throw new Error('vectorIndex backend "hnsw" requires an optional dependency adapter; install your HNSW package and provide `hnswFactory`.');let y=new W(t.name??"vector_index"),b;function M(n){if(d!==void 0){if(n.length!==d)throw new RangeError(`vector dimension mismatch: expected ${d}, got ${n.length}`);return}if(o){if(b===void 0){b=n.length;return}if(n.length!==b)throw new RangeError(`vector dimension mismatch: inferred ${b} from first upsert, got ${n.length}. Pass \`strictDimension: false\` to opt into zero-pad behavior, or set an explicit \`dimension\`.`)}}let k=f??(n=>n.upsertedAtNs),p=!1,N=H({name:"events",retainedLimit:1024,graph:y}),m=J(y,"seq",0),h=O({name:"entries",...s!==void 0?{retention:{score:(n,a)=>k(a),maxSize:s,onArchive:n=>{p||(e==="hnsw"&&u.remove(n),N.append({action:"evict",id:n,t_ns:X(),seq:Z(m)}))}}}:{}});if(y.add(h.entries,{name:"entries"}),y.addDisposer(I(h.entries)),u?.dispose){let n=u.dispose.bind(u);y.addDisposer(()=>n())}let v=(n,a,l)=>{M(a),e==="hnsw"&&u.upsert(n,a,l);let i=(()=>{if(l!==void 0)return l===null||typeof l!="object"?l:Array.isArray(l)?[...l]:{...l}})(),r={id:n,vector:[...a],...i!==void 0?{meta:i}:{},upsertedAtNs:V()};h.set(n,r)},x=n=>{h.has(n)&&(e==="hnsw"&&u.remove(n),h.delete(n))},K=()=>{if(h.size!==0){p=!0;try{h.clear(),e==="hnsw"&&u.clear()}finally{p=!1}b=void 0}},G=()=>{if(e!=="hnsw")return;let n=h.entries.cache;if(n){u.clear();for(let a of n.values())u.upsert(a.id,a.vector,a.meta)}},F=E(v,{audit:N,freeze:!1,seq:m,onSuccess:([n],a,l)=>({action:"upsert",id:n,t_ns:l.t_ns,seq:l.seq})}),j=E(x,{audit:N,seq:m,onSuccess:([n],a,l)=>({action:"remove",id:n,t_ns:l.t_ns,seq:l.seq})}),D=E(K,{audit:N,seq:m,onSuccess:(n,a,l)=>({action:"clear",t_ns:l.t_ns,seq:l.seq})}),B=E(G,{audit:N,seq:m,onSuccess:(n,a,l)=>({action:"reindex",t_ns:l.t_ns,seq:l.seq})});function P(n,a=5){let l=L(a,"k");return C([h.entries,n,l],i=>{let r=i[0],g=i[1],R=i[2],T=Number.isFinite(R)?Math.max(0,Math.floor(R)):0;if(!r||r.size===0||T<=0)return[];if(g==null||g.length===0)return[];let w=d??(o?b:void 0);return w!==void 0&&g.length!==w?[]:e==="hnsw"?[...u.search(g,T)]:[...r.values()].map(_=>({id:_.id,score:de(g,_.vector),..._.meta!==void 0?{meta:_.meta}:{}})).sort((_,A)=>A.score-_.score).slice(0,T)},{describeKind:"derived",equals:(i,r)=>ue(i,r),meta:S("vector_search")})}return Object.assign(y,{backend:e,events:N,entries:h.entries,upsert:F,remove:j,clear:D,reindex:B,searchNode:P})}var ie="\0";function Q(t,e,d){return`${t}${ie}${e}${ie}${d}`}function se(t,e){if(!t||t.size===0)return new Map;let d=new Map;for(let s of t.values()){let f=e==="from"?s.from:s.to,u=d.get(f);u||(u=[],d.set(f,u)),u.push(s)}let o=new Map;for(let[s,f]of d)o.set(s,Object.freeze(f));return o}function ae(t,e){if(t===e)return!0;if(t==null||e==null||t.size!==e.size)return!1;for(let[d,o]of t){let s=e.get(d);if(!s||o.length!==s.length)return!1;for(let f=0;f<o.length;f+=1){let u=o[f],y=s[f];if(u.from!==y.from||u.to!==y.to||u.relation!==y.relation||u.weight!==y.weight)return!1}}return!0}function pe(t,e={}){let d=e.orphanGC??"keep";if(e.entitiesMaxSize!==void 0&&e.entitiesMaxSize<1)throw new RangeError("knowledgeGraph: entitiesMaxSize must be >= 1");if(e.edgesMaxSize!==void 0&&e.edgesMaxSize<1)throw new RangeError("knowledgeGraph: edgesMaxSize must be >= 1");let o=new W(t),s=O({name:"entities",...e.entitiesMaxSize!==void 0?{maxSize:e.entitiesMaxSize}:{}}),f=O({name:"edges",...e.edgesMaxSize!==void 0?{maxSize:e.edgesMaxSize}:{}});o.add(s.entries,{name:"entities"}),o.add(f.entries,{name:"edges"});let u=C([f.entries],([c])=>se(c,"from"),{name:"adjacencyOut",describeKind:"derived",initial:new Map,equals:ae,meta:S("adjacency_out")}),y=C([f.entries],([c])=>se(c,"to"),{name:"adjacencyIn",describeKind:"derived",initial:new Map,equals:ae,meta:S("adjacency_in")});o.add(u,{name:"adjacencyOut"}),o.add(y,{name:"adjacencyIn"}),o.addDisposer(I(u)),o.addDisposer(I(y));let b=C([s.entries],([c])=>(c??new Map).size,{name:"entityCount",describeKind:"derived",initial:0,meta:S("entity_count")}),M=C([f.entries],([c])=>(c??new Map).size,{name:"edgeCount",describeKind:"derived",initial:0,meta:S("edge_count")});o.add(b,{name:"entityCount"}),o.add(M,{name:"edgeCount"}),o.addDisposer(I(b)),o.addDisposer(I(M));let k=H({name:"events",retainedLimit:1024,graph:o}),p=J(o,"seq",0);function N(c){let n=u.cache,a=y.cache;return(n?.get(c)?.length??0)>0||(a?.get(c)?.length??0)>0}function m(c){if(d==="remove")for(let n of c)s.has(n)&&(N(n)||(s.delete(n),k.append({action:"orphanRemove",id:n,t_ns:X(),seq:Z(p)})))}let h=(c,n)=>{s.set(c,n)},v=c=>{let n=f.entries.cache,a=new Set;if(n){let l=[];for(let[i,r]of n)(r.from===c||r.to===c)&&(l.push(i),r.from!==c&&a.add(r.from),r.to!==c&&a.add(r.to));l.length>0&&f.deleteMany(l)}s.has(c)&&s.delete(c),m([...a])},x=(c,n,a,l=1)=>{f.set(Q(c,n,a),{from:c,to:n,relation:a,weight:l})},K=(c,n,a)=>{if(a!==void 0)f.delete(Q(c,n,a));else{let l=f.entries.cache;if(!l)return;let i=[];for(let[r,g]of l)g.from===c&&g.to===n&&i.push(r);i.length>0&&f.deleteMany(i)}m([c,n])},G=E(h,{audit:k,seq:p,onSuccess:([c],n,a)=>({action:"upsertEntity",id:c,t_ns:a.t_ns,seq:a.seq})}),F=E(v,{audit:k,seq:p,onSuccess:([c],n,a)=>({action:"removeEntity",id:c,t_ns:a.t_ns,seq:a.seq})}),j=E(x,{audit:k,seq:p,onSuccess:([c,n,a,l],i,r)=>({action:"link",from:c,to:n,relation:a,weight:l??1,t_ns:r.t_ns,seq:r.seq})}),D=E(K,{audit:k,seq:p,onSuccess:([c,n,a],l,i)=>({action:"unlink",from:c,to:n,...a!==void 0?{relation:a}:{},t_ns:i.t_ns,seq:i.seq})});function B(c,n){let a=L(c,"id"),l=n!==void 0?L(n,"relation"):void 0;return C(l?[u,y,a,l]:[u,y,a],r=>{let g=r[0],R=r[1],T=r[2],w=l?r[3]:void 0,z=g.get(T)??[],_=R.get(T)??[],A=new Set,U=[];for(let q of z){let $=Q(q.from,q.to,q.relation);A.has($)||w!==void 0&&q.relation!==w||(A.add($),U.push(q))}for(let q of _){let $=Q(q.from,q.to,q.relation);A.has($)||w!==void 0&&q.relation!==w||(A.add($),U.push(q))}return U},{describeKind:"derived",equals:(r,g)=>{let R=r,T=g;if(R===T)return!0;if(R==null||T==null||R.length!==T.length)return!1;for(let w=0;w<R.length;w+=1){let z=R[w],_=T[w];if(z.from!==_.from||z.to!==_.to||z.relation!==_.relation||z.weight!==_.weight)return!1}return!0},meta:S("related")})}return Object.assign(o,{events:k,entities:s.entries,edges:f.entries,adjacencyOut:u,adjacencyIn:y,entityCount:b,edgeCount:M,upsertEntity:G,removeEntity:F,link:j,unlink:D,relatedNode:B})}export{ee as a,de as b,ge as c,ye as d,me as e,pe as f,he as g};
@@ -1 +1 @@
1
- import{d as n}from"./chunk-4EATTNAE.js";import{j as a}from"./chunk-B4L5X2QO.js";import{b as c}from"./chunk-QYADASLV.js";var s={};c(s,{GuardedExecutionGraph:()=>o,guardedExecution:()=>p});var o=class extends a{enforcer;violations;_target;_defaultActor;constructor(r,e){super(e.name??`${r.name}_guarded`,e.graph),this._target=r,this._defaultActor=e.actor;let t={mode:e.mode??"enforce",name:"enforcer"};e.violationsLimit!=null&&(t.violationsLimit=e.violationsLimit),this.enforcer=n(r,e.policies,t),this.violations=this.enforcer.violations,this.mount("enforcer",this.enforcer)}scopedDescribe(r){let e=r?.actor??this._defaultActor,t={...r,...e!=null?{actor:e}:{}};return this._target.describe(t)}get target(){return this._target}};function p(i,r){return new o(i,r)}export{o as a,p as b,s as c};
1
+ import{d as n}from"./chunk-XLYF4LBH.js";import{k as a}from"./chunk-QMC2PLNM.js";import{b as c}from"./chunk-QYADASLV.js";var s={};c(s,{GuardedExecutionGraph:()=>o,guardedExecution:()=>p});var o=class extends a{enforcer;violations;_target;_defaultActor;constructor(r,e){super(e.name??`${r.name}_guarded`,e.graph),this._target=r,this._defaultActor=e.actor;let t={mode:e.mode??"enforce",name:"enforcer"};e.violationsLimit!=null&&(t.violationsLimit=e.violationsLimit),this.enforcer=n(r,e.policies,t),this.violations=this.enforcer.violations,this.mount("enforcer",this.enforcer)}scopedDescribe(r){let e=r?.actor??this._defaultActor,t={...r,...e!=null?{actor:e}:{}};return this._target.describe(t)}get target(){return this._target}};function p(i,r){return new o(i,r)}export{o as a,p as b,s as c};
@@ -0,0 +1 @@
1
+ import{k as y}from"./chunk-QMC2PLNM.js";import{b}from"./chunk-7KZZLWZ6.js";import{E as m,m as A,p as R,t as x}from"./chunk-LYCLF26R.js";import{b as f,c as p}from"./chunk-CK2E7BTU.js";var h=x((r,e)=>{r("observe"),r("signal"),e("write")});function N(r){let e=b([],{name:r.name,maxSize:r.retainedLimit??1024,guard:r.guard??h,...r.versioning!=null?{versioning:r.versioning}:{}});return e.withLatest(),r.graph&&r.graph.add(e.entries,{name:r.name}),e}function T(r){if(r===null||typeof r!="object"||Object.isFrozen(r))return r;for(let e of Object.keys(r))T(r[e]);return Object.freeze(r)}function w(r){let e=r.cache,o=(typeof e=="number"&&Number.isFinite(e)?e:0)+1;return r.down([[p],[f,o]]),o}function g(r,e,a,o,i,t){let s=e(a,o,i);if(s===void 0)return;let u=t!=null?{...s,handlerVersion:t}:s;r.append(u)}function q(r,e){let a=e.freeze??!0;return function(...i){let t=a?i.map(T):i,s=R(),u=e.seq?w(e.seq):void 0;try{let n=r(...t);return e.onSuccess&&g(e.audit,e.onSuccess,t,n,{t_ns:s,seq:u},e.handlerVersion),n}catch(n){if(e.onFailure){let d=n instanceof Error?n.name:typeof n;g(e.audit,e.onFailure,t,n,{t_ns:s,seq:u,errorType:d},e.handlerVersion)}throw n}}}function z(r,e){let a=e.freeze??!0;return function(...i){let t=a?i.map(T):i,s=R(),u,n,d=!1,l;try{A(()=>{e.seq&&(l=w(e.seq));try{u=r(...t),e.onSuccess&&g(e.audit,e.onSuccess,t,u,{t_ns:s,seq:l},e.handlerVersion)}catch(c){throw n=c,d=!0,c}})}catch(c){if(d&&e.onFailure){let M=n instanceof Error?n.name:typeof n;g(e.audit,e.onFailure,t,n,{t_ns:s,seq:l,errorType:M},e.handlerVersion)}throw d?n:c}return u}}function G(r,e,a=0){let o=m(a,{name:e,describeKind:"state"});return r.add(o,{name:e}),o}function V(r,e,a,o=0){let i={},t=new y(e);for(let s of a){let u=m(o,{name:s,describeKind:"state"});t.add(u,{name:s}),i[s]=u}return r.mount(e,t),i}export{N as a,w as b,q as c,z as d,G as e,V as f};
@@ -1 +1 @@
1
- import{b as x,c as D,d as $,e as S,f as A,g as R,h as T,i as F,j as y,k as P,l as V}from"./chunk-B4L5X2QO.js";import{a as m,b as g,c as k,d as v,e as O,f as G,g as E,h as C}from"./chunk-LYCLF26R.js";import{b as u}from"./chunk-CK2E7BTU.js";import{b as _}from"./chunk-QYADASLV.js";var j={};_(j,{ENVELOPE_VERSION:()=>v,GRAPH_META_SEGMENT:()=>R,Graph:()=>y,JsonCodec:()=>m,SIZEOF_OVERHEAD:()=>D,SIZEOF_SYMBOL:()=>$,SNAPSHOT_VERSION:()=>T,createDagCborCodec:()=>g,createDagCborZstdCodec:()=>k,decodeEnvelope:()=>G,diffForWAL:()=>P,encodeEnvelope:()=>O,explainPath:()=>x,graphProfile:()=>A,mermaidLiveUrl:()=>F,reachable:()=>V,registerBuiltinCodecs:()=>E,replayWAL:()=>C,sizeof:()=>S,validateGraphObservability:()=>L,watchTopologyTree:()=>N});function N(p,n){let o=new Map,d=(s,a)=>{if(o.has(s))return;let c={off:()=>{},prefix:a};o.set(s,c);let f=s.topology.subscribe(l=>{for(let r of l){if(r[0]!==u)continue;let e=r[1];if(n(e,s,a),e.kind==="added"&&e.nodeKind==="mount"){let t=s._mounts.get(e.name);if(t instanceof y){let i=`${a}${e.name}::`;d(t,i)}}else if(e.kind==="removed"&&e.nodeKind==="mount"){let t=`${a}${e.name}::`;for(let[i,h]of Array.from(o.entries()))i!==p&&h.prefix.startsWith(t)&&(h.off(),o.delete(i))}}});c.off=f;for(let[l,r]of s._mounts)if(r instanceof y){let e=`${a}${l}::`;d(r,e)}};return d(p,""),()=>{for(let s of o.values())s.off();o.clear()}}function L(p,n={}){let o=[],d=n.requireFound??!0;if(n.skipDescribe!==!0)try{let r=p.describe(),e=new Set(Object.keys(r.nodes)),t=[];for(let[i,h]of Object.entries(r.nodes))for(let b of h.deps)b!==""&&!e.has(b)&&t.push(`${i} \u2192 ${b}`);for(let i of r.edges)e.has(i.from)||t.push(`edge.from: ${i.from}`),e.has(i.to)||t.push(`edge.to: ${i.to}`);t.length>0?o.push({kind:"describe",ok:!1,reason:`describe() has ${t.length} dangling pointer(s); nodes \u2289 deps`,danglingDeps:t}):o.push({kind:"describe",ok:!0,nodeCount:e.size,edgeCount:r.edges.length})}catch(r){o.push({kind:"describe",ok:!1,reason:`describe() threw: ${r instanceof Error?r.message:String(r)}`})}for(let r of n.formats??[])try{let e=p.describe({format:r});typeof e!="string"||e.length===0?o.push({kind:"describe-format",ok:!1,format:r,reason:`describe({ format: "${r}" }) returned empty or non-string output`}):o.push({kind:"describe-format",ok:!0,format:r,length:e.length})}catch(e){o.push({kind:"describe-format",ok:!1,format:r,reason:e instanceof Error?e.message:String(e)})}for(let r of n.paths??[])try{p.resolve(r),o.push({kind:"observe",ok:!0,path:r})}catch(e){o.push({kind:"observe",ok:!1,path:r,reason:e instanceof Error?e.message:String(e)})}for(let[r,e]of n.pairs??[])try{let t=p.explain(r,e);d&&t.found===!1?o.push({kind:"explain",ok:!1,from:r,to:e,reason:`explain(${r} \u2192 ${e}) found no path${t.reason?`: ${t.reason}`:""}`}):o.push({kind:"explain",ok:!0,from:r,to:e,found:t.found,steps:t.steps.length})}catch(t){o.push({kind:"explain",ok:!1,from:r,to:e,reason:t instanceof Error?t.message:String(t)})}let s=o.filter(r=>!r.ok),a=s.length===0,c=n.paths?.length??0,f=n.pairs?.length??0,l=n.formats?.length??0;return{ok:a,checks:o,failures:s,summary(){let r=[n.skipDescribe===!0?null:"describe",l>0?`${l} format${l===1?"":"s"}`:null,c>0?`${c} observe path${c===1?"":"s"}`:null,f>0?`${f} explain pair${f===1?"":"s"}`:null].filter(t=>t!=null),e=r.length>0?r.join(", "):"describe-only";return a?`validateGraphObservability: OK (${e})`:`validateGraphObservability: ${s.length} failure(s) across ${e}`}}}export{N as a,L as b,j as c};
1
+ import{c as x,d as D,e as $,f as S,g as A,h as R,i as T,j as F,k as y,l as P,m as V}from"./chunk-QMC2PLNM.js";import{a as m,b as g,c as k,d as v,e as O,f as G,g as E,h as C}from"./chunk-LYCLF26R.js";import{b as u}from"./chunk-CK2E7BTU.js";import{b as _}from"./chunk-QYADASLV.js";var j={};_(j,{ENVELOPE_VERSION:()=>v,GRAPH_META_SEGMENT:()=>R,Graph:()=>y,JsonCodec:()=>m,SIZEOF_OVERHEAD:()=>D,SIZEOF_SYMBOL:()=>$,SNAPSHOT_VERSION:()=>T,createDagCborCodec:()=>g,createDagCborZstdCodec:()=>k,decodeEnvelope:()=>G,diffForWAL:()=>P,encodeEnvelope:()=>O,explainPath:()=>x,graphProfile:()=>A,mermaidLiveUrl:()=>F,reachable:()=>V,registerBuiltinCodecs:()=>E,replayWAL:()=>C,sizeof:()=>S,validateGraphObservability:()=>L,watchTopologyTree:()=>N});function N(p,n){let o=new Map,d=(s,a)=>{if(o.has(s))return;let c={off:()=>{},prefix:a};o.set(s,c);let f=s.topology.subscribe(l=>{for(let r of l){if(r[0]!==u)continue;let e=r[1];if(n(e,s,a),e.kind==="added"&&e.nodeKind==="mount"){let t=s._mounts.get(e.name);if(t instanceof y){let i=`${a}${e.name}::`;d(t,i)}}else if(e.kind==="removed"&&e.nodeKind==="mount"){let t=`${a}${e.name}::`;for(let[i,h]of Array.from(o.entries()))i!==p&&h.prefix.startsWith(t)&&(h.off(),o.delete(i))}}});c.off=f;for(let[l,r]of s._mounts)if(r instanceof y){let e=`${a}${l}::`;d(r,e)}};return d(p,""),()=>{for(let s of o.values())s.off();o.clear()}}function L(p,n={}){let o=[],d=n.requireFound??!0;if(n.skipDescribe!==!0)try{let r=p.describe(),e=new Set(Object.keys(r.nodes)),t=[];for(let[i,h]of Object.entries(r.nodes))for(let b of h.deps)b!==""&&!e.has(b)&&t.push(`${i} \u2192 ${b}`);for(let i of r.edges)e.has(i.from)||t.push(`edge.from: ${i.from}`),e.has(i.to)||t.push(`edge.to: ${i.to}`);t.length>0?o.push({kind:"describe",ok:!1,reason:`describe() has ${t.length} dangling pointer(s); nodes \u2289 deps`,danglingDeps:t}):o.push({kind:"describe",ok:!0,nodeCount:e.size,edgeCount:r.edges.length})}catch(r){o.push({kind:"describe",ok:!1,reason:`describe() threw: ${r instanceof Error?r.message:String(r)}`})}for(let r of n.formats??[])try{let e=p.describe({format:r});typeof e!="string"||e.length===0?o.push({kind:"describe-format",ok:!1,format:r,reason:`describe({ format: "${r}" }) returned empty or non-string output`}):o.push({kind:"describe-format",ok:!0,format:r,length:e.length})}catch(e){o.push({kind:"describe-format",ok:!1,format:r,reason:e instanceof Error?e.message:String(e)})}for(let r of n.paths??[])try{p.resolve(r),o.push({kind:"observe",ok:!0,path:r})}catch(e){o.push({kind:"observe",ok:!1,path:r,reason:e instanceof Error?e.message:String(e)})}for(let[r,e]of n.pairs??[])try{let t=p.explain(r,e);d&&t.found===!1?o.push({kind:"explain",ok:!1,from:r,to:e,reason:`explain(${r} \u2192 ${e}) found no path${t.reason?`: ${t.reason}`:""}`}):o.push({kind:"explain",ok:!0,from:r,to:e,found:t.found,steps:t.steps.length})}catch(t){o.push({kind:"explain",ok:!1,from:r,to:e,reason:t instanceof Error?t.message:String(t)})}let s=o.filter(r=>!r.ok),a=s.length===0,c=n.paths?.length??0,f=n.pairs?.length??0,l=n.formats?.length??0;return{ok:a,checks:o,failures:s,summary(){let r=[n.skipDescribe===!0?null:"describe",l>0?`${l} format${l===1?"":"s"}`:null,c>0?`${c} observe path${c===1?"":"s"}`:null,f>0?`${f} explain pair${f===1?"":"s"}`:null].filter(t=>t!=null),e=r.length>0?r.join(", "):"describe-only";return a?`validateGraphObservability: OK (${e})`:`validateGraphObservability: ${s.length} failure(s) across ${e}`}}}export{N as a,L as b,j as c};
@@ -1,4 +1,4 @@
1
- import{e as ce}from"./chunk-GDDPCDLG.js";import{a as se,b as P}from"./chunk-5QDBSZBV.js";import{j as L}from"./chunk-B4L5X2QO.js";import{f as ae,h as ie}from"./chunk-MQZWA3DF.js";import{i as ne,j as U}from"./chunk-LYCLF26R.js";import{b,h as _,i as T,j as W}from"./chunk-CK2E7BTU.js";import{b as Oe,c as re,d as te,e as oe}from"./chunk-QYADASLV.js";var ke={};Oe(ke,{ACTOR_KEY:()=>F,COMMAND_HANDLERS:()=>A,CQRS_EVENT_HANDLERS:()=>S,CRON_HANDLERS:()=>D,CommandHandler:()=>me,EVENT_HANDLERS:()=>G,EventHandler:()=>ve,GRAPHREFLY_REQUEST_GRAPH:()=>R,GRAPHREFLY_ROOT_GRAPH:()=>v,GraphCron:()=>fe,GraphInterval:()=>he,GraphReflyEventExplorer:()=>x,GraphReflyGuard:()=>Re,GraphReflyGuardImpl:()=>I,GraphReflyModule:()=>Q,INTERVAL_HANDLERS:()=>O,InjectCqrsGraph:()=>de,InjectGraph:()=>ue,InjectNode:()=>pe,ObserveGateway:()=>B,OnGraphEvent:()=>le,QUERY_HANDLERS:()=>H,QueryHandler:()=>ye,SAGA_HANDLERS:()=>N,SagaHandler:()=>ge,fromHeader:()=>Ee,fromJwtPayload:()=>V,getActor:()=>we,getGraphToken:()=>m,getNodeToken:()=>y,observeSSE:()=>Me,observeSubscription:()=>Ce,toObservable:()=>se});import{Inject as j}from"@nestjs/common";var v=Symbol.for("graphrefly:root-graph");var R=Symbol.for("graphrefly:request-graph");function m(s){return Symbol.for(`graphrefly:graph:${s}`)}function y(s){return Symbol.for(`graphrefly:node:${s}`)}var G=new Map,O=new Map,D=new Map,A=new Map,S=new Map,H=new Map,N=new Map;function ue(s){return s==="request"?j(R):j(s?m(s):v)}function de(s){return j(m(s))}function pe(s){return j(y(s))}function le(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=G.get(o)??[];n.push({nodeName:s,methodKey:t}),G.set(o,n)})}}function he(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=O.get(o)??[];n.push({ms:s,methodKey:t}),O.set(o,n)})}}function fe(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=D.get(o)??[];n.push({expr:s,methodKey:t}),D.set(o,n)})}}function me(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=A.get(n)??[];a.push({cqrsName:s,commandName:e,methodKey:o}),A.set(n,a)})}}function ve(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=S.get(n)??[];a.push({cqrsName:s,eventName:e,methodKey:o}),S.set(n,a)})}}function ye(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=H.get(n)??[];a.push({cqrsName:s,projectionName:e,methodKey:o}),H.set(n,a)})}}function ge(s,e,r){return(t,o)=>{let n=o.name;o.addInitializer(function(){let a=this.constructor,c=N.get(a)??[];c.push({cqrsName:s,eventNames:r,sagaName:e,methodKey:n}),N.set(a,c)})}}var be=0,x=class{constructor(e,r){this.graph=e;this.moduleRef=r}disposers=[];scheduleNodeNames=[];onModuleInit(){this.wireEvents(),this.wireIntervals(),this.wireCrons(),this.wireCqrsCommands(),this.wireCqrsEvents(),this.wireCqrsQueries(),this.wireCqrsSagas()}onModuleDestroy(){for(let e of this.disposers)e();this.disposers.length=0;for(let e of this.scheduleNodeNames)try{this.graph.remove(e)}catch{}this.scheduleNodeNames.length=0}wireEvents(){for(let[e,r]of G){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireEventHandler(t,o)}}wireEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),a=this.observeNode(r.nodeName).subscribe(c=>{for(let l of c)l[0]===b&&o(l[1])});this.disposers.push(a)}wireIntervals(){for(let[e,r]of O){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireIntervalHandler(t,e,o)}}wireIntervalHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ae(t.ms,{period:t.ms,name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCrons(){for(let[e,r]of D){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCronHandler(t,e,o)}}wireCronHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ie(t.expr,{name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCqrsCommands(){for(let[e,r]of A){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsCommand(t,o)}}wireCqrsCommand(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.command(r.commandName,o)}wireCqrsEvents(){for(let[e,r]of S){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsEventHandler(t,o)}}wireCqrsEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;n.event(r.eventName);let c=n.resolve(r.eventName).cache,l=c&&c.length>0?c[c.length-1].seq:0,p=this.observeNodeOn(n,r.eventName).subscribe(u=>{for(let d of u)if(d[0]===b){let g=d[1];for(let i of g)i.seq>l&&(o(i),l=i.seq)}});this.disposers.push(p)}wireCqrsQueries(){for(let[e,r]of H){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsQuery(t,o)}}wireCqrsQuery(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;let c=this.observeNodeOn(n,r.projectionName).subscribe(l=>{for(let f of l)f[0]===b&&o(f[1])});this.disposers.push(c)}wireCqrsSagas(){for(let[e,r]of N){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsSaga(t,o)}}wireCqrsSaga(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.saga(r.sagaName,r.eventNames,o)}observeNode(e){return this.graph.observe(e)}observeNodeOn(e,r){return e.observe(r)}resolveCqrsGraph(e){try{return this.moduleRef.get(m(e),{strict:!1})}catch{return console.warn(`[GraphReFly] CqrsGraph "${e}" not found in DI \u2014 did you import GraphReflyModule.forCqrs({ name: "${e}" })?`),null}}resolveInstance(e){try{return this.moduleRef.get(e,{strict:!1})}catch{return null}}};function Me(s,e,r){let{actor:t,serialize:o=De,keepAliveMs:n,signal:a}=r??{},c=new TextEncoder,l,f=r?.highWaterMark!=null,p,u,d=[],g=!1;return new ReadableStream({start(i){let h,w=()=>{},M=()=>{if(!g){g=!0,h!==void 0&&clearInterval(h),a?.removeEventListener("abort",K),w(),p?.dispose(),u?.(),u=void 0;for(let k of d)i.enqueue(k.frame);d.length=0,i.close()}};l=M;let K=()=>M(),ee=s.observe(e,{actor:t});f&&(p=P(k=>ee.up(k),{highWaterMark:r.highWaterMark,lowWaterMark:r.lowWaterMark??Math.floor(r.highWaterMark/2)})),w=ee.subscribe(k=>{for(let $ of k){if(g)return;let q=$[0];if(q===b){let C=c.encode(Y("data",o($[1])));f?(d.push({frame:C,counted:!0}),p.onEnqueue(),u?.(),u=void 0):i.enqueue(C)}else if(q===W){let C=c.encode(Y("error",o($[1])));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C),M();return}else if(q===T||q===_){if(q===T){let C=c.encode(Y("complete"));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C)}M();return}}}),n!==void 0&&n>0&&(h=setInterval(()=>{g||(f?(d.push({frame:c.encode(`: keepalive
1
+ import{e as ce}from"./chunk-DSOVKKTI.js";import{a as se,b as P}from"./chunk-5QDBSZBV.js";import{k as L}from"./chunk-QMC2PLNM.js";import{f as ae,h as ie}from"./chunk-RZ5HKPGI.js";import{i as ne,j as U}from"./chunk-LYCLF26R.js";import{b,h as _,i as T,j as W}from"./chunk-CK2E7BTU.js";import{b as Oe,c as re,d as te,e as oe}from"./chunk-QYADASLV.js";var ke={};Oe(ke,{ACTOR_KEY:()=>F,COMMAND_HANDLERS:()=>A,CQRS_EVENT_HANDLERS:()=>S,CRON_HANDLERS:()=>D,CommandHandler:()=>me,EVENT_HANDLERS:()=>G,EventHandler:()=>ve,GRAPHREFLY_REQUEST_GRAPH:()=>R,GRAPHREFLY_ROOT_GRAPH:()=>v,GraphCron:()=>fe,GraphInterval:()=>he,GraphReflyEventExplorer:()=>x,GraphReflyGuard:()=>Re,GraphReflyGuardImpl:()=>I,GraphReflyModule:()=>Q,INTERVAL_HANDLERS:()=>O,InjectCqrsGraph:()=>de,InjectGraph:()=>ue,InjectNode:()=>pe,ObserveGateway:()=>B,OnGraphEvent:()=>le,QUERY_HANDLERS:()=>H,QueryHandler:()=>ye,SAGA_HANDLERS:()=>N,SagaHandler:()=>ge,fromHeader:()=>Ee,fromJwtPayload:()=>V,getActor:()=>we,getGraphToken:()=>m,getNodeToken:()=>y,observeSSE:()=>Me,observeSubscription:()=>Ce,toObservable:()=>se});import{Inject as j}from"@nestjs/common";var v=Symbol.for("graphrefly:root-graph");var R=Symbol.for("graphrefly:request-graph");function m(s){return Symbol.for(`graphrefly:graph:${s}`)}function y(s){return Symbol.for(`graphrefly:node:${s}`)}var G=new Map,O=new Map,D=new Map,A=new Map,S=new Map,H=new Map,N=new Map;function ue(s){return s==="request"?j(R):j(s?m(s):v)}function de(s){return j(m(s))}function pe(s){return j(y(s))}function le(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=G.get(o)??[];n.push({nodeName:s,methodKey:t}),G.set(o,n)})}}function he(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=O.get(o)??[];n.push({ms:s,methodKey:t}),O.set(o,n)})}}function fe(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=D.get(o)??[];n.push({expr:s,methodKey:t}),D.set(o,n)})}}function me(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=A.get(n)??[];a.push({cqrsName:s,commandName:e,methodKey:o}),A.set(n,a)})}}function ve(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=S.get(n)??[];a.push({cqrsName:s,eventName:e,methodKey:o}),S.set(n,a)})}}function ye(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=H.get(n)??[];a.push({cqrsName:s,projectionName:e,methodKey:o}),H.set(n,a)})}}function ge(s,e,r){return(t,o)=>{let n=o.name;o.addInitializer(function(){let a=this.constructor,c=N.get(a)??[];c.push({cqrsName:s,eventNames:r,sagaName:e,methodKey:n}),N.set(a,c)})}}var be=0,x=class{constructor(e,r){this.graph=e;this.moduleRef=r}disposers=[];scheduleNodeNames=[];onModuleInit(){this.wireEvents(),this.wireIntervals(),this.wireCrons(),this.wireCqrsCommands(),this.wireCqrsEvents(),this.wireCqrsQueries(),this.wireCqrsSagas()}onModuleDestroy(){for(let e of this.disposers)e();this.disposers.length=0;for(let e of this.scheduleNodeNames)try{this.graph.remove(e)}catch{}this.scheduleNodeNames.length=0}wireEvents(){for(let[e,r]of G){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireEventHandler(t,o)}}wireEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),a=this.observeNode(r.nodeName).subscribe(c=>{for(let l of c)l[0]===b&&o(l[1])});this.disposers.push(a)}wireIntervals(){for(let[e,r]of O){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireIntervalHandler(t,e,o)}}wireIntervalHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ae(t.ms,{period:t.ms,name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCrons(){for(let[e,r]of D){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCronHandler(t,e,o)}}wireCronHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ie(t.expr,{name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCqrsCommands(){for(let[e,r]of A){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsCommand(t,o)}}wireCqrsCommand(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.command(r.commandName,o)}wireCqrsEvents(){for(let[e,r]of S){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsEventHandler(t,o)}}wireCqrsEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;n.event(r.eventName);let c=n.resolve(r.eventName).cache,l=c&&c.length>0?c[c.length-1].seq:0,p=this.observeNodeOn(n,r.eventName).subscribe(u=>{for(let d of u)if(d[0]===b){let g=d[1];for(let i of g)i.seq>l&&(o(i),l=i.seq)}});this.disposers.push(p)}wireCqrsQueries(){for(let[e,r]of H){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsQuery(t,o)}}wireCqrsQuery(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;let c=this.observeNodeOn(n,r.projectionName).subscribe(l=>{for(let f of l)f[0]===b&&o(f[1])});this.disposers.push(c)}wireCqrsSagas(){for(let[e,r]of N){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsSaga(t,o)}}wireCqrsSaga(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.saga(r.sagaName,r.eventNames,o)}observeNode(e){return this.graph.observe(e)}observeNodeOn(e,r){return e.observe(r)}resolveCqrsGraph(e){try{return this.moduleRef.get(m(e),{strict:!1})}catch{return console.warn(`[GraphReFly] CqrsGraph "${e}" not found in DI \u2014 did you import GraphReflyModule.forCqrs({ name: "${e}" })?`),null}}resolveInstance(e){try{return this.moduleRef.get(e,{strict:!1})}catch{return null}}};function Me(s,e,r){let{actor:t,serialize:o=De,keepAliveMs:n,signal:a}=r??{},c=new TextEncoder,l,f=r?.highWaterMark!=null,p,u,d=[],g=!1;return new ReadableStream({start(i){let h,w=()=>{},M=()=>{if(!g){g=!0,h!==void 0&&clearInterval(h),a?.removeEventListener("abort",K),w(),p?.dispose(),u?.(),u=void 0;for(let k of d)i.enqueue(k.frame);d.length=0,i.close()}};l=M;let K=()=>M(),ee=s.observe(e,{actor:t});f&&(p=P(k=>ee.up(k),{highWaterMark:r.highWaterMark,lowWaterMark:r.lowWaterMark??Math.floor(r.highWaterMark/2)})),w=ee.subscribe(k=>{for(let $ of k){if(g)return;let q=$[0];if(q===b){let C=c.encode(Y("data",o($[1])));f?(d.push({frame:C,counted:!0}),p.onEnqueue(),u?.(),u=void 0):i.enqueue(C)}else if(q===W){let C=c.encode(Y("error",o($[1])));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C),M();return}else if(q===T||q===_){if(q===T){let C=c.encode(Y("complete"));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C)}M();return}}}),n!==void 0&&n>0&&(h=setInterval(()=>{g||(f?(d.push({frame:c.encode(`: keepalive
2
2
 
3
3
  `),counted:!1}),u?.(),u=void 0):i.enqueue(c.encode(`: keepalive
4
4
 
@@ -1,3 +1,3 @@
1
- import{g as he}from"./chunk-U3COB5WU.js";import{j as fe}from"./chunk-B4L5X2QO.js";import{x as ye}from"./chunk-JJTF75VS.js";import{D as be,E as T,G as v,H as q,m as ee,o as z}from"./chunk-LYCLF26R.js";import{b as P,j as Z}from"./chunk-CK2E7BTU.js";import{b as Ne}from"./chunk-QYADASLV.js";var we={};Ne(we,{blindVariation:()=>De,errorCritique:()=>Re,refineLoop:()=>Se});function Ie(n){if(typeof n!="object"||n===null)return!1;let l=n;return typeof l.subscribe=="function"&&typeof l.down=="function"&&typeof l.emit=="function"}function pe(n,l){if(n.length===0)return{best:null,bestScore:Number.NEGATIVE_INFINITY};if(n.length===1){let e=ne(l);return{best:n[0],bestScore:e}}if(l.some(e=>typeof e.candidateIndex=="number")){let e=new Array(n.length);for(let i=0;i<n.length;i++)e[i]={sum:0,count:0};for(let i of l){let d=i.candidateIndex;typeof d=="number"&&d>=0&&d<n.length&&(e[d].sum+=i.score,e[d].count+=1)}let s=n[0],o=e[0].count>0?e[0].sum/e[0].count:Number.NEGATIVE_INFINITY;for(let i=1;i<n.length;i++){let d=e[i].count>0?e[i].sum/e[i].count:Number.NEGATIVE_INFINITY;d>o&&(o=d,s=n[i])}return{best:s,bestScore:o}}let t=n[0],m=l[0]?.score??Number.NEGATIVE_INFINITY;for(let e=1;e<n.length;e++){let s=l[e]?.score??Number.NEGATIVE_INFINITY;s>m&&(m=s,t=n[e])}return{best:t,bestScore:m}}function ne(n){if(n.length===0)return Number.NEGATIVE_INFINITY;let l=0;for(let x of n)l+=x.score;return l/n.length}function Se(n,l,x,t){let m=t.name??"refine-loop",e=new fe(m,t.graph),s=Ie(t.dataset)?t.dataset:T(t.dataset,{name:"dataset"});e.add(s,{name:"dataset"});let o=T(0,{name:"iteration"});e.add(o,{name:"iteration"});let i=T(x,{name:"strategy",equals:()=>!1});e.add(i,{name:"strategy"});let d=T(null,{name:"lastFeedback"});e.add(d,{name:"lastFeedback"});let k=T([],{name:"prevCandidates"});e.add(k,{name:"prevCandidates"});let y=T(!1,{name:"paused"});e.add(y,{name:"paused"});let b=T("running",{name:"status"});e.add(b,{name:"status"});let E=T([],{name:"history",equals:()=>!1});e.add(E,{name:"history"});let h=T(null,{name:"best"});e.add(h,{name:"best"});let N=T(Number.NEGATIVE_INFINITY,{name:"score"});e.add(N,{name:"score"});let C=T(0,{name:"budget-used"});e.add(C,{name:"budget-used"});let R=he("stages");e.mount("stages",R);let A=R.topic("generate"),p=R.topic("evaluate"),G=R.topic("analyze"),te=R.topic("decide"),$=x,B=null,re=[];e.addDisposer(i.subscribe(r=>{for(let a of r)a[0]===P&&($=a[1])})),e.addDisposer(d.subscribe(r=>{for(let a of r)a[0]===P&&(B=a[1])})),e.addDisposer(k.subscribe(r=>{for(let a of r)a[0]===P&&(re=a[1])}));let I=ye(o,r=>{let a=$,c=r===0||B==null;return be([],(u,f)=>{let S=!1;try{let D=c?a.seed(n):a.generate(B,re);if(D instanceof Promise)return D.then(_=>{S||f.emit(_)},_=>{S||f.down([[Z,_]])}),()=>{S=!0};f.emit(D)}catch(D){S=!0,f.down([[Z,D]])}},{describeKind:"producer"})},{name:"candidates"});e.add(I,{name:"candidates"});let ae=q([I],(r,a,c)=>{let u=c.terminalDeps[0];u!==void 0&&u!==!0&&b.emit("errored")},{name:"error-watcher",errorWhenDepsError:!1});e.add(ae,{name:"error-watcher"}),e.addDisposer(ae.subscribe(()=>{}));let Y=v([I,o],([r,a])=>({iteration:a,candidates:r,timestamp_ns:z()}),{name:"generate-event"});e.add(Y,{name:"generate-event"}),e.addDisposer(Y.subscribe(()=>{}));let oe=q([Y],([r])=>{A.publish(r)},{name:"generate-publish"});e.add(oe,{name:"generate-publish"}),e.addDisposer(oe.subscribe(()=>{}));let ie=q([I],([r])=>{k.emit(r)},{name:"generate-mirror"});e.add(ie,{name:"generate-mirror"}),e.addDisposer(ie.subscribe(()=>{}));let V=l(I,s);e.add(V,{name:"scores"});let j=v([V,I,o],([r,a,c])=>({iteration:c,candidates:a,scores:r,timestamp_ns:z()}),{name:"evaluate-event"});e.add(j,{name:"evaluate-event"}),e.addDisposer(j.subscribe(()=>{}));let se=q([j],([r])=>{p.publish(r)},{name:"evaluate-publish"});e.add(se,{name:"evaluate-publish"}),e.addDisposer(se.subscribe(()=>{}));let L=v([V,I],([r,a])=>$.analyze(r,a),{name:"feedback"});e.add(L,{name:"feedback"});let M=v([L,I,o],([r,a,c])=>({iteration:c,candidates:a,feedback:r,timestamp_ns:z()}),{name:"analyze-event"});e.add(M,{name:"analyze-event"}),e.addDisposer(M.subscribe(()=>{}));let de=q([M],([r])=>{G.publish(r)},{name:"analyze-publish"});e.add(de,{name:"analyze-publish"}),e.addDisposer(de.subscribe(()=>{}));let H=v([E],([r])=>{let a=r;if(t.patience==null||a.length<=t.patience)return!1;let c=a.slice(-(t.patience+1)),u=c[0].bestScore;return c.slice(1).every(f=>f.bestScore<=u)},{name:"patience-check"});e.add(H,{name:"patience-check"});let W=v([N],([r])=>t.minScore!=null&&r>=t.minScore,{name:"min-score-check"});e.add(W,{name:"min-score-check"});let K=v([E],([r])=>{let a=r;if(t.minDelta==null||a.length<2)return!1;let c=a[a.length-2].bestScore,u=a[a.length-1].bestScore;return Math.abs(u-c)<t.minDelta},{name:"min-delta-check"});e.add(K,{name:"min-delta-check"});let U=v([C],([r])=>t.maxEvaluations!=null&&r>=t.maxEvaluations,{name:"max-evaluations-check"});e.add(U,{name:"max-evaluations-check"});let J=v([o],([r])=>t.maxIterations!=null&&r>=t.maxIterations,{name:"max-iterations-check"});e.add(J,{name:"max-iterations-check"});let le=v([C],([r])=>t.budget!=null&&r>=t.budget,{name:"budget-exhausted-check"});e.add(le,{name:"budget-exhausted-check"}),e.addDisposer(H.subscribe(()=>{})),e.addDisposer(W.subscribe(()=>{})),e.addDisposer(K.subscribe(()=>{})),e.addDisposer(U.subscribe(()=>{})),e.addDisposer(J.subscribe(()=>{})),e.addDisposer(le.subscribe(()=>{}));let ce=v([H,W,K,U,J],([r,a,c,u,f])=>r?{converged:!0,reason:"patience"}:a?{converged:!0,reason:"min-score"}:c?{converged:!0,reason:"min-delta"}:u?{converged:!0,reason:"max-evaluations"}:f?{converged:!0,reason:"max-iterations"}:{converged:!1},{name:"converged"});e.add(ce,{name:"converged"}),e.addDisposer(ce.subscribe(()=>{}));let ue=-1,me=q([L,V,I],([r,a,c])=>{let u=o.cache,f=r,S=c,D=a;if(u<=ue)return;ue=u;let{best:_,bestScore:ge}=pe(S,D),Te=E.cache,ve={n:u,candidates:S,scores:D,feedback:f,best:_,bestScore:ge,timestamp_ns:z()},F=[...Te,ve],Q=C.cache+S.length,g="continue",w,Ee=t.budget!=null&&Q>=t.budget,ke=y.cache;if(Ee)g="budget",w="budget";else if(t.minScore!=null&&f.score>=t.minScore)g="converged",w="min-score";else if(t.maxIterations!=null&&u>=t.maxIterations)g="converged",w="max-iterations";else if(t.maxEvaluations!=null&&Q>=t.maxEvaluations)g="converged",w="max-evaluations";else if(t.minDelta!=null&&F.length>=2){let O=F[F.length-2].bestScore,X=F[F.length-1].bestScore;Math.abs(X-O)<t.minDelta&&(g="converged",w="min-delta")}else if(t.patience!=null&&F.length>t.patience){let O=F.slice(-(t.patience+1)),X=O[0].bestScore;O.slice(1).every(xe=>xe.bestScore<=X)&&(g="converged",w="patience")}g==="continue"&&ke&&(g="paused"),ee(()=>{h.emit(_),N.emit(f.score),E.emit(F),C.emit(Q),d.emit(f),te.publish({iteration:u,decision:g,reason:w,timestamp_ns:z()}),g==="continue"?o.emit(u+1):b.emit(g==="converged"?"converged":g==="budget"?"budget":"paused")})},{name:"decide-bridge"});return e.add(me,{name:"decide-bridge"}),e.addDisposer(me.subscribe(()=>{})),Object.assign(e,{best:h,score:N,status:b,history:E,strategy:i,iteration:o,generate:A,evaluate:p,analyze:G,decide:te,setStrategy(r){i.emit(r)},pause(){y.emit(!0)},resume(){b.cache==="paused"&&ee(()=>{y.emit(!1),b.emit("running"),o.emit(o.cache+1)})}})}function De(n){let l=n.width??4;return{name:n.name??"blindVariation",seed(t){return[t]},analyze(t,m){let e=ne(t),s=null;for(let o of t)(!s||o.score<s.score)&&(s=o);return{summary:`blindVariation iteration: mean=${e.toFixed(3)}, n=${t.length}`,score:e,weakTasks:s?[s.taskId]:[]}},async generate(t,m){if(m.length===0)throw new Error("blindVariation.generate: empty candidate batch \u2014 cannot derive prior for teacher");let e=m[m.length-1],s=0,i={prior:e,reportCost:d=>{s+=d}};try{if(n.parallel!==!1)return await Promise.all(Array.from({length:l},()=>n.teacher(i)));let d=[];for(let k=0;k<l;k++)d.push(await n.teacher(i));return d}finally{if(n.tokens!=null&&s>0){let d=n.tokens.cache??0;n.tokens.emit(d+s)}}}}}function Fe(n){return typeof n=="object"&&n!==null&&n.kind==="errorCritique"}function Ce(n,l){return n.length===0?`No task scored below the batch mean (${l.score.toFixed(3)}). Reinforce the current direction.`:`Failures below threshold:
1
+ import{g as he}from"./chunk-6KZZ6XQE.js";import{k as fe}from"./chunk-QMC2PLNM.js";import{x as ye}from"./chunk-6773HURD.js";import{D as be,E as T,G as v,H as q,m as ee,o as z}from"./chunk-LYCLF26R.js";import{b as P,j as Z}from"./chunk-CK2E7BTU.js";import{b as Ne}from"./chunk-QYADASLV.js";var we={};Ne(we,{blindVariation:()=>De,errorCritique:()=>Re,refineLoop:()=>Se});function Ie(n){if(typeof n!="object"||n===null)return!1;let l=n;return typeof l.subscribe=="function"&&typeof l.down=="function"&&typeof l.emit=="function"}function pe(n,l){if(n.length===0)return{best:null,bestScore:Number.NEGATIVE_INFINITY};if(n.length===1){let e=ne(l);return{best:n[0],bestScore:e}}if(l.some(e=>typeof e.candidateIndex=="number")){let e=new Array(n.length);for(let i=0;i<n.length;i++)e[i]={sum:0,count:0};for(let i of l){let d=i.candidateIndex;typeof d=="number"&&d>=0&&d<n.length&&(e[d].sum+=i.score,e[d].count+=1)}let s=n[0],o=e[0].count>0?e[0].sum/e[0].count:Number.NEGATIVE_INFINITY;for(let i=1;i<n.length;i++){let d=e[i].count>0?e[i].sum/e[i].count:Number.NEGATIVE_INFINITY;d>o&&(o=d,s=n[i])}return{best:s,bestScore:o}}let t=n[0],m=l[0]?.score??Number.NEGATIVE_INFINITY;for(let e=1;e<n.length;e++){let s=l[e]?.score??Number.NEGATIVE_INFINITY;s>m&&(m=s,t=n[e])}return{best:t,bestScore:m}}function ne(n){if(n.length===0)return Number.NEGATIVE_INFINITY;let l=0;for(let x of n)l+=x.score;return l/n.length}function Se(n,l,x,t){let m=t.name??"refine-loop",e=new fe(m,t.graph),s=Ie(t.dataset)?t.dataset:T(t.dataset,{name:"dataset"});e.add(s,{name:"dataset"});let o=T(0,{name:"iteration"});e.add(o,{name:"iteration"});let i=T(x,{name:"strategy",equals:()=>!1});e.add(i,{name:"strategy"});let d=T(null,{name:"lastFeedback"});e.add(d,{name:"lastFeedback"});let k=T([],{name:"prevCandidates"});e.add(k,{name:"prevCandidates"});let y=T(!1,{name:"paused"});e.add(y,{name:"paused"});let b=T("running",{name:"status"});e.add(b,{name:"status"});let E=T([],{name:"history",equals:()=>!1});e.add(E,{name:"history"});let h=T(null,{name:"best"});e.add(h,{name:"best"});let N=T(Number.NEGATIVE_INFINITY,{name:"score"});e.add(N,{name:"score"});let C=T(0,{name:"budget-used"});e.add(C,{name:"budget-used"});let R=he("stages");e.mount("stages",R);let A=R.topic("generate"),p=R.topic("evaluate"),G=R.topic("analyze"),te=R.topic("decide"),$=x,B=null,re=[];e.addDisposer(i.subscribe(r=>{for(let a of r)a[0]===P&&($=a[1])})),e.addDisposer(d.subscribe(r=>{for(let a of r)a[0]===P&&(B=a[1])})),e.addDisposer(k.subscribe(r=>{for(let a of r)a[0]===P&&(re=a[1])}));let I=ye(o,r=>{let a=$,c=r===0||B==null;return be([],(u,f)=>{let S=!1;try{let D=c?a.seed(n):a.generate(B,re);if(D instanceof Promise)return D.then(_=>{S||f.emit(_)},_=>{S||f.down([[Z,_]])}),()=>{S=!0};f.emit(D)}catch(D){S=!0,f.down([[Z,D]])}},{describeKind:"producer"})},{name:"candidates"});e.add(I,{name:"candidates"});let ae=q([I],(r,a,c)=>{let u=c.terminalDeps[0];u!==void 0&&u!==!0&&b.emit("errored")},{name:"error-watcher",errorWhenDepsError:!1});e.add(ae,{name:"error-watcher"}),e.addDisposer(ae.subscribe(()=>{}));let Y=v([I,o],([r,a])=>({iteration:a,candidates:r,timestamp_ns:z()}),{name:"generate-event"});e.add(Y,{name:"generate-event"}),e.addDisposer(Y.subscribe(()=>{}));let oe=q([Y],([r])=>{A.publish(r)},{name:"generate-publish"});e.add(oe,{name:"generate-publish"}),e.addDisposer(oe.subscribe(()=>{}));let ie=q([I],([r])=>{k.emit(r)},{name:"generate-mirror"});e.add(ie,{name:"generate-mirror"}),e.addDisposer(ie.subscribe(()=>{}));let V=l(I,s);e.add(V,{name:"scores"});let j=v([V,I,o],([r,a,c])=>({iteration:c,candidates:a,scores:r,timestamp_ns:z()}),{name:"evaluate-event"});e.add(j,{name:"evaluate-event"}),e.addDisposer(j.subscribe(()=>{}));let se=q([j],([r])=>{p.publish(r)},{name:"evaluate-publish"});e.add(se,{name:"evaluate-publish"}),e.addDisposer(se.subscribe(()=>{}));let L=v([V,I],([r,a])=>$.analyze(r,a),{name:"feedback"});e.add(L,{name:"feedback"});let M=v([L,I,o],([r,a,c])=>({iteration:c,candidates:a,feedback:r,timestamp_ns:z()}),{name:"analyze-event"});e.add(M,{name:"analyze-event"}),e.addDisposer(M.subscribe(()=>{}));let de=q([M],([r])=>{G.publish(r)},{name:"analyze-publish"});e.add(de,{name:"analyze-publish"}),e.addDisposer(de.subscribe(()=>{}));let H=v([E],([r])=>{let a=r;if(t.patience==null||a.length<=t.patience)return!1;let c=a.slice(-(t.patience+1)),u=c[0].bestScore;return c.slice(1).every(f=>f.bestScore<=u)},{name:"patience-check"});e.add(H,{name:"patience-check"});let W=v([N],([r])=>t.minScore!=null&&r>=t.minScore,{name:"min-score-check"});e.add(W,{name:"min-score-check"});let K=v([E],([r])=>{let a=r;if(t.minDelta==null||a.length<2)return!1;let c=a[a.length-2].bestScore,u=a[a.length-1].bestScore;return Math.abs(u-c)<t.minDelta},{name:"min-delta-check"});e.add(K,{name:"min-delta-check"});let U=v([C],([r])=>t.maxEvaluations!=null&&r>=t.maxEvaluations,{name:"max-evaluations-check"});e.add(U,{name:"max-evaluations-check"});let J=v([o],([r])=>t.maxIterations!=null&&r>=t.maxIterations,{name:"max-iterations-check"});e.add(J,{name:"max-iterations-check"});let le=v([C],([r])=>t.budget!=null&&r>=t.budget,{name:"budget-exhausted-check"});e.add(le,{name:"budget-exhausted-check"}),e.addDisposer(H.subscribe(()=>{})),e.addDisposer(W.subscribe(()=>{})),e.addDisposer(K.subscribe(()=>{})),e.addDisposer(U.subscribe(()=>{})),e.addDisposer(J.subscribe(()=>{})),e.addDisposer(le.subscribe(()=>{}));let ce=v([H,W,K,U,J],([r,a,c,u,f])=>r?{converged:!0,reason:"patience"}:a?{converged:!0,reason:"min-score"}:c?{converged:!0,reason:"min-delta"}:u?{converged:!0,reason:"max-evaluations"}:f?{converged:!0,reason:"max-iterations"}:{converged:!1},{name:"converged"});e.add(ce,{name:"converged"}),e.addDisposer(ce.subscribe(()=>{}));let ue=-1,me=q([L,V,I],([r,a,c])=>{let u=o.cache,f=r,S=c,D=a;if(u<=ue)return;ue=u;let{best:_,bestScore:ge}=pe(S,D),Te=E.cache,ve={n:u,candidates:S,scores:D,feedback:f,best:_,bestScore:ge,timestamp_ns:z()},F=[...Te,ve],Q=C.cache+S.length,g="continue",w,Ee=t.budget!=null&&Q>=t.budget,ke=y.cache;if(Ee)g="budget",w="budget";else if(t.minScore!=null&&f.score>=t.minScore)g="converged",w="min-score";else if(t.maxIterations!=null&&u>=t.maxIterations)g="converged",w="max-iterations";else if(t.maxEvaluations!=null&&Q>=t.maxEvaluations)g="converged",w="max-evaluations";else if(t.minDelta!=null&&F.length>=2){let O=F[F.length-2].bestScore,X=F[F.length-1].bestScore;Math.abs(X-O)<t.minDelta&&(g="converged",w="min-delta")}else if(t.patience!=null&&F.length>t.patience){let O=F.slice(-(t.patience+1)),X=O[0].bestScore;O.slice(1).every(xe=>xe.bestScore<=X)&&(g="converged",w="patience")}g==="continue"&&ke&&(g="paused"),ee(()=>{h.emit(_),N.emit(f.score),E.emit(F),C.emit(Q),d.emit(f),te.publish({iteration:u,decision:g,reason:w,timestamp_ns:z()}),g==="continue"?o.emit(u+1):b.emit(g==="converged"?"converged":g==="budget"?"budget":"paused")})},{name:"decide-bridge"});return e.add(me,{name:"decide-bridge"}),e.addDisposer(me.subscribe(()=>{})),Object.assign(e,{best:h,score:N,status:b,history:E,strategy:i,iteration:o,generate:A,evaluate:p,analyze:G,decide:te,setStrategy(r){i.emit(r)},pause(){y.emit(!0)},resume(){b.cache==="paused"&&ee(()=>{y.emit(!1),b.emit("running"),o.emit(o.cache+1)})}})}function De(n){let l=n.width??4;return{name:n.name??"blindVariation",seed(t){return[t]},analyze(t,m){let e=ne(t),s=null;for(let o of t)(!s||o.score<s.score)&&(s=o);return{summary:`blindVariation iteration: mean=${e.toFixed(3)}, n=${t.length}`,score:e,weakTasks:s?[s.taskId]:[]}},async generate(t,m){if(m.length===0)throw new Error("blindVariation.generate: empty candidate batch \u2014 cannot derive prior for teacher");let e=m[m.length-1],s=0,i={prior:e,reportCost:d=>{s+=d}};try{if(n.parallel!==!1)return await Promise.all(Array.from({length:l},()=>n.teacher(i)));let d=[];for(let k=0;k<l;k++)d.push(await n.teacher(i));return d}finally{if(n.tokens!=null&&s>0){let d=n.tokens.cache??0;n.tokens.emit(d+s)}}}}}function Fe(n){return typeof n=="object"&&n!==null&&n.kind==="errorCritique"}function Ce(n,l){return n.length===0?`No task scored below the batch mean (${l.score.toFixed(3)}). Reinforce the current direction.`:`Failures below threshold:
2
2
  ${n.map(t=>{let m=t.error!=null?` | error: ${t.error}`:"";return`- ${t.taskId} (score=${t.score.toFixed(3)})${m}`}).join(`
3
3
  `)}`}function Re(n){let l=n.width??4,x=n.name??"errorCritique",t=n.maxFailureSamples??5,m=n.formatCritique??Ce;return{name:x,seed(e){return[e]},analyze(e,s){let o=ne(e),i=typeof n.failureThreshold=="function"?n.failureThreshold(e):n.failureThreshold,d=i===void 0&&!Number.isFinite(o),k=i??o,y=d?[...e].sort((p,G)=>p.score-G.score):e.filter(p=>p.score<k).slice().sort((p,G)=>p.score-G.score),b=y.slice(0,t),{best:E,bestScore:h}=pe(s,e),N={summary:"",score:o,weakTasks:b.map(p=>p.taskId)},C=m(b,N),R={kind:"errorCritique",best:E,failures:b,critiqueText:C},A=y.length>b.length?` (top ${b.length} retained)`:"";return{summary:`errorCritique iteration: mean=${o.toFixed(3)}, failures=${y.length}${A}/${e.length}, bestScore=${h.toFixed(3)}`,critique:R,weakTasks:b.map(p=>p.taskId),score:o}},async generate(e,s){if(s.length===0)throw new Error("errorCritique.generate: empty candidate batch \u2014 cannot derive prior for teacher");let o=Fe(e.critique)?e.critique:void 0,i=o!==void 0?o.best:s[s.length-1],d=o?.critiqueText??e.summary,k=o?.failures??[],y=0,E={prior:i,critique:d,failures:k,reportCost:h=>{y+=h}};try{if(n.parallel!==!1)return await Promise.all(Array.from({length:l},()=>n.teacher(E)));let h=[];for(let N=0;N<l;N++)h.push(await n.teacher(E));return h}finally{if(n.tokens!=null&&y>0){let h=n.tokens.cache??0;n.tokens.emit(h+y)}}}}}export{Se as a,De as b,Re as c,we as d};
@@ -1,4 +1,4 @@
1
- import{f as F,g as j,h as A}from"./chunk-WGST56ZH.js";import{h as b,j as x}from"./chunk-B4L5X2QO.js";import{p as _}from"./chunk-LYCLF26R.js";import{b as C,d as $,i as T,j as N}from"./chunk-CK2E7BTU.js";import{b as J}from"./chunk-QYADASLV.js";var Y={};J(Y,{SNAPSHOT_WIRE_VERSION:()=>v,SurfaceError:()=>o,asSurfaceError:()=>K,createGraph:()=>R,deleteSnapshot:()=>L,diffSnapshots:()=>V,listSnapshots:()=>W,restoreSnapshot:()=>U,runReduction:()=>D,saveSnapshot:()=>M});var o=class extends Error{code;details;constructor(t,r,n){super(r),this.name="SurfaceError",this.code=t,n!==void 0&&(this.details=n)}toJSON(){let t={code:this.code,message:this.message};if(this.details!==void 0){let r=q(this.details);r!==void 0&&(t.details=r)}return t}};function q(e){try{return JSON.parse(JSON.stringify(e))}catch{return}}function K(e,t="internal-error"){if(e instanceof o)return e;let r=e instanceof Error?e.message:String(e);return new o(t,r)}function R(e,t){let r=j(e);if(!r.valid)throw new o("invalid-spec",`GraphSpec validation failed:
1
+ import{f as F,g as j,h as A}from"./chunk-CMTN3KPT.js";import{i as b,k as x}from"./chunk-QMC2PLNM.js";import{p as _}from"./chunk-LYCLF26R.js";import{b as C,d as $,i as T,j as N}from"./chunk-CK2E7BTU.js";import{b as J}from"./chunk-QYADASLV.js";var Y={};J(Y,{SNAPSHOT_WIRE_VERSION:()=>v,SurfaceError:()=>o,asSurfaceError:()=>K,createGraph:()=>R,deleteSnapshot:()=>L,diffSnapshots:()=>V,listSnapshots:()=>W,restoreSnapshot:()=>U,runReduction:()=>D,saveSnapshot:()=>M});var o=class extends Error{code;details;constructor(t,r,n){super(r),this.name="SurfaceError",this.code=t,n!==void 0&&(this.details=n)}toJSON(){let t={code:this.code,message:this.message};if(this.details!==void 0){let r=q(this.details);r!==void 0&&(t.details=r)}return t}};function q(e){try{return JSON.parse(JSON.stringify(e))}catch{return}}function K(e,t="internal-error"){if(e instanceof o)return e;let r=e instanceof Error?e.message:String(e);return new o(t,r)}function R(e,t){let r=j(e);if(!r.valid)throw new o("invalid-spec",`GraphSpec validation failed:
2
2
  ${r.errors.join(`
3
3
  `)}`,{errors:r.errors});let n=t?.catalog??{},s=F(e,n);if(!s.valid)throw new o("catalog-error",`Catalog validation failed:
4
4
  ${s.errors.join(`
@@ -0,0 +1 @@
1
+ import{a as w,b as U,c as K}from"./chunk-DQJLC6YY.js";import{A as b,B as F,C as H,D as G,E as h,F as k,G as B,H as Y,I as v,J as P,K as W,i as q,j as z,k as g,m as S,n as C,o as I,p as M,q as _,r as u,s as J,t as Q,u as X,v as Z,w as L,x as m,y as x,z as V}from"./chunk-LYCLF26R.js";import{a as e,b as t,c as o,d as p,e as r,f as n,g as s,h as i,i as y,j as a,k as d,l as c,m as N,n as T,o as E,p as O,q as l,r as A,s as D,t as f,u as R}from"./chunk-CK2E7BTU.js";import{b as j}from"./chunk-QYADASLV.js";var $={};j($,{COMPLETE:()=>y,COMPLETE_MSG:()=>E,COMPLETE_ONLY_BATCH:()=>f,DATA:()=>t,DEFAULT_ACTOR:()=>q,DIRTY:()=>o,DIRTY_MSG:()=>d,DIRTY_ONLY_BATCH:()=>l,ERROR:()=>a,GraphReFlyConfig:()=>_,GuardDenied:()=>J,INVALIDATE:()=>r,INVALIDATE_MSG:()=>N,INVALIDATE_ONLY_BATCH:()=>D,NodeImpl:()=>H,PAUSE:()=>n,RESOLVED:()=>p,RESOLVED_MSG:()=>c,RESOLVED_ONLY_BATCH:()=>A,RESUME:()=>s,START:()=>e,START_MSG:()=>T,TEARDOWN:()=>i,TEARDOWN_MSG:()=>O,TEARDOWN_ONLY_BATCH:()=>R,accessHintForGuard:()=>Z,advanceVersion:()=>x,autoTrackNode:()=>P,batch:()=>S,configure:()=>F,createVersioning:()=>m,defaultConfig:()=>b,defaultHash:()=>L,derived:()=>B,downWithBatch:()=>C,dynamicNode:()=>v,effect:()=>Y,factoryTag:()=>K,isBatching:()=>g,isV1:()=>V,monotonicNs:()=>I,node:()=>G,normalizeActor:()=>z,pipe:()=>W,placeholderArgs:()=>U,policy:()=>Q,policyFromRules:()=>X,producer:()=>k,registerBuiltins:()=>u,resolveDescribeFields:()=>w,state:()=>h,wallClockNs:()=>M});export{$ as a};
@@ -1 +1 @@
1
- import{b as G,d as F}from"./chunk-XIJKEXWR.js";import{c as E}from"./chunk-O32GJOUJ.js";import{a as A}from"./chunk-YVYSO5CW.js";import{j as I}from"./chunk-B4L5X2QO.js";import{b as q}from"./chunk-KUVDFOJH.js";import{C as M}from"./chunk-MQZWA3DF.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 s(u,a){return E("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:s("observability",{stage:"correlate"})});n.add(_,{name:"correlate"});let N=a.sloCheck??(()=>({pass:!0})),w=o([_],e=>e[0],{meta:s("observability",{stage:"slo_value"})}),f=o([w],e=>N(e[0]),{meta:s("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:s("observability",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:s("observability",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let r=o([f],e=>{let i=e[0];return i&&i.pass===!1?i:null},{meta:s("observability",{stage:"feedback_condition"})});return n.add(r,{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:s("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:s("issue_tracker",{stage:"verify"})});n.add(l,{name:"verify"});let _=d([],{meta:s("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:s("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:s("issue_tracker",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:s("issue_tracker",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let r=o([l],e=>{let i=e[0];if(i){let x=i.verification;if(x&&x.valid===!1)return i}return null},{meta:s("issue_tracker",{stage:"feedback_condition"})});return n.add(r,{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=r=>({label:"review",confidence:.5,original:r}),m=a.classify??h,y=o([a.source],r=>m(r[0]),{meta:s("content_moderation",{stage:"classify"})});n.add(y,{name:"classify"});let c=A("stratify",y,[{name:"safe",classify:r=>r.label==="safe"},{name:"review",classify:r=>r.label==="review"},{name:"block",classify:r=>r.label==="block"}]);n.mount("stratify",c);let k=q([],{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],r=>{let e=r[0];e&&k.append(e)});n.add(_,{name:"__review_accumulator"}),n.addDisposer(M(_));let N=d({},{meta:s("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],r=>r[0]?.confidence??0),v=o([y],r=>{let e=r[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],r=>({classification:r[0],priority:r[1]}),{meta:s("content_moderation",{stage:"output"})});n.add(g,{name:"output"});let R=o([k.entries,N],r=>{let e=r[0];if(e&&e.length>0){let i=e[e.length-1];if(i&&i.falsePositive)return i}return null},{meta:s("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:s("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:s("data_quality",{stage:"anomaly"})});n.add(c,{name:"anomaly"});let k=d(null,{meta:s("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:s("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:s("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:s("data_quality",{stage:"output"})});n.add(v,{name:"output"});let b=d([],{meta:s("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:s("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,d as F}from"./chunk-XLMYQB6F.js";import{c as E}from"./chunk-O32GJOUJ.js";import{a as A}from"./chunk-4BDQXBXE.js";import{k as I}from"./chunk-QMC2PLNM.js";import{b as q}from"./chunk-7KZZLWZ6.js";import{C as M}from"./chunk-RZ5HKPGI.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 s(u,a){return E("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:s("observability",{stage:"correlate"})});n.add(_,{name:"correlate"});let N=a.sloCheck??(()=>({pass:!0})),w=o([_],e=>e[0],{meta:s("observability",{stage:"slo_value"})}),f=o([w],e=>N(e[0]),{meta:s("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:s("observability",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:s("observability",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let r=o([f],e=>{let i=e[0];return i&&i.pass===!1?i:null},{meta:s("observability",{stage:"feedback_condition"})});return n.add(r,{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:s("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:s("issue_tracker",{stage:"verify"})});n.add(l,{name:"verify"});let _=d([],{meta:s("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:s("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:s("issue_tracker",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:s("issue_tracker",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let r=o([l],e=>{let i=e[0];if(i){let x=i.verification;if(x&&x.valid===!1)return i}return null},{meta:s("issue_tracker",{stage:"feedback_condition"})});return n.add(r,{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=r=>({label:"review",confidence:.5,original:r}),m=a.classify??h,y=o([a.source],r=>m(r[0]),{meta:s("content_moderation",{stage:"classify"})});n.add(y,{name:"classify"});let c=A("stratify",y,[{name:"safe",classify:r=>r.label==="safe"},{name:"review",classify:r=>r.label==="review"},{name:"block",classify:r=>r.label==="block"}]);n.mount("stratify",c);let k=q([],{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],r=>{let e=r[0];e&&k.append(e)});n.add(_,{name:"__review_accumulator"}),n.addDisposer(M(_));let N=d({},{meta:s("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],r=>r[0]?.confidence??0),v=o([y],r=>{let e=r[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],r=>({classification:r[0],priority:r[1]}),{meta:s("content_moderation",{stage:"output"})});n.add(g,{name:"output"});let R=o([k.entries,N],r=>{let e=r[0];if(e&&e.length>0){let i=e[e.length-1];if(i&&i.falsePositive)return i}return null},{meta:s("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:s("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:s("data_quality",{stage:"anomaly"})});n.add(c,{name:"anomaly"});let k=d(null,{meta:s("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:s("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:s("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:s("data_quality",{stage:"output"})});n.add(v,{name:"output"});let b=d([],{meta:s("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:s("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 +1 @@
1
- import{c as f}from"./chunk-XIJKEXWR.js";import{a as l,c as o,d,g as s,h as m,j as b,k as c}from"./chunk-A5HZZYRK.js";import{a as r,b as u}from"./chunk-4VVTGLXJ.js";import{b as y}from"./chunk-QYADASLV.js";var R={};y(R,{NS_PER_MS:()=>r,NS_PER_SEC:()=>u,resilientPipeline:()=>O});function O(p,e={}){let t=p;e.rateLimit!=null&&(t=s(t,e.rateLimit)),e.budget!=null&&e.budget.length>0&&(t=f(t,e.budget));let n;if(e.breaker!=null){let k=o(e.breaker),S=e.breakerOnOpen??"skip",a=d(k,{onOpen:S})(t);t=a.node,n=a.breakerState}if(e.timeoutMs!=null){if(e.timeoutMs<=0)throw new RangeError("timeoutMs must be > 0");if(e.timeoutMs>9e6)throw new RangeError("timeoutMs must be <= 9_000_000 (\u22482.5h) to stay within safe ns arithmetic");t=c(t,e.timeoutMs*1e6)}e.retry!=null&&(t=l(t,e.retry)),e.fallback!==void 0&&(t=b(t,e.fallback));let i=m(t,{initialStatus:e.initialStatus??"pending"});return{node:i.node,status:i.status,error:i.error,breakerState:n}}export{O as a,R as b};
1
+ import{c as f}from"./chunk-XLMYQB6F.js";import{a as l,c as o,d,g as s,h as m,j as b,k as c}from"./chunk-XIMFHEKV.js";import{a as r,b as u}from"./chunk-4VVTGLXJ.js";import{b as y}from"./chunk-QYADASLV.js";var R={};y(R,{NS_PER_MS:()=>r,NS_PER_SEC:()=>u,resilientPipeline:()=>O});function O(p,e={}){let t=p;e.rateLimit!=null&&(t=s(t,e.rateLimit)),e.budget!=null&&e.budget.length>0&&(t=f(t,e.budget));let n;if(e.breaker!=null){let k=o(e.breaker),S=e.breakerOnOpen??"skip",a=d(k,{onOpen:S})(t);t=a.node,n=a.breakerState}if(e.timeoutMs!=null){if(e.timeoutMs<=0)throw new RangeError("timeoutMs must be > 0");if(e.timeoutMs>9e6)throw new RangeError("timeoutMs must be <= 9_000_000 (\u22482.5h) to stay within safe ns arithmetic");t=c(t,e.timeoutMs*1e6)}e.retry!=null&&(t=l(t,e.retry)),e.fallback!==void 0&&(t=b(t,e.fallback));let i=m(t,{initialStatus:e.initialStatus??"pending"});return{node:i.node,status:i.status,error:i.error,breakerState:n}}export{O as a,R as b};
@@ -0,0 +1,7 @@
1
+ import{a as Re}from"./chunk-SGS4OJGS.js";import{a as Fe}from"./chunk-ESMPEKEV.js";import{a as se,d as De}from"./chunk-DQJLC6YY.js";import{C as oe}from"./chunk-RZ5HKPGI.js";import{A as Oe,C as L,E as ee,F as _e,G as Ee,e as Pe,f as Le,i as Z,k as Ie,l as re,m as je,o as H,p as Be,s as q}from"./chunk-LYCLF26R.js";import{b as W,c as ye,d as ve,e as ne,f as xe,g as we,h as z,i as X,j as Q}from"./chunk-CK2E7BTU.js";function Se(e,t){if(Object.is(e,t))return!0;if(e==null||t==null||typeof e!="object"||typeof t!="object")return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(!Se(e[s],t[s]))return!1;return!0}if(Array.isArray(t))return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;let o=new Set(r);for(let s of n)if(!o.has(s)||!Se(e[s],t[s]))return!1;return!0}function He(e,t){return`${e}\0${t}`}function Ge(e,t){let n=[],r=new Set(e.subgraphs),o=new Set(t.subgraphs),s=[];for(let g of o)r.has(g)||s.push(g);s.sort();for(let g of s)n.push({type:"subgraph-mounted",path:g});let i=new Set(Object.keys(e.nodes)),a=new Set(Object.keys(t.nodes)),c=[];for(let g of a)i.has(g)||c.push(g);c.sort();for(let g of c)n.push({type:"node-added",path:g,node:{...t.nodes[g]}});let u=[];for(let g of a){if(!i.has(g))continue;let x=e.nodes[g]?.meta,y=t.nodes[g]?.meta;x==null&&y==null||Se(x??{},y??{})||u.push(g)}u.sort();for(let g of u)n.push({type:"node-meta-changed",path:g,prevMeta:e.nodes[g]?.meta??{},nextMeta:t.nodes[g]?.meta??{}});let d=new Map;for(let g of e.edges)d.set(He(g.from,g.to),g);let h=new Map;for(let g of t.edges)h.set(He(g.from,g.to),g);let p=[];for(let[g,x]of h)d.has(g)||p.push(x);p.sort((g,x)=>g.from<x.from?-1:g.from>x.from?1:g.to<x.to?-1:g.to>x.to?1:0);for(let g of p)n.push({type:"edge-added",from:g.from,to:g.to});let f=[];for(let[g,x]of d)h.has(g)||f.push(x);f.sort((g,x)=>g.from<x.from?-1:g.from>x.from?1:g.to<x.to?-1:g.to>x.to?1:0);for(let g of f)n.push({type:"edge-removed",from:g.from,to:g.to});let l=[];for(let g of i)a.has(g)||l.push(g);l.sort();for(let g of l)n.push({type:"node-removed",path:g});let m=[];for(let g of r)o.has(g)||m.push(g);m.sort();for(let g of m)n.push({type:"subgraph-unmounted",path:g});return{events:n,flushedAt_ns:H()}}function Ve(e,t,n,r={}){let o=t in e.nodes,s=n in e.nodes;if(!o)return ie(t,n,"no-such-from");if(!s)return ie(t,n,"no-such-to");let i=r.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(t===n){if(r.findCycle===!0){let u=gt(e,t,r);if(u!=null)return u}let c=ae(t,e.nodes[t],0,r);return ue(t,n,[c])}if(i===0)return ie(t,n,"no-path");let a=ze(e,t,n,i);return a.found?ue(t,n,Ke(e,a.pathOrder,r)):ie(t,n,a.truncated?"max-depth-exceeded":"no-path")}function ze(e,t,n,r){let o=new Map,s=[{path:n,depth:0}],i=new Set([n]),a=0,c=!1;for(;a<s.length;){let h=s[a++];if(h.path===t)break;if(r!=null&&h.depth>=r){let m=e.nodes[h.path];m?.deps&&m.deps.length>0&&(c=!0);continue}let p=e.nodes[h.path];if(p==null)continue;let f=p.deps??[],l=new Map;for(let m=0;m<f.length;m++){let g=f[m];if(!g)continue;let x=l.get(g);x==null&&(x=[],l.set(g,x)),x.push(m)}for(let[m,g]of l)i.has(m)||(i.add(m),o.set(m,{from:h.path,depIndices:g}),s.push({path:m,depth:h.depth+1}))}if(!o.has(t))return{found:!1,pathOrder:[],truncated:c};let u=[{path:t}],d=t;for(;d!==n;){let h=o.get(d);if(h==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=h.depIndices,u.push({path:h.from}),d=h.from}return{found:!0,pathOrder:u,truncated:!1}}function gt(e,t,n){let r=e.nodes[t];if(r==null)return null;let o=r.deps??[],s=[];for(let a=0;a<o.length;a++)o[a]===t&&s.push(a);if(s.length>0){let a=ae(t,r,0,n);a.dep_index=s[0];let c=ae(t,r,1,n);return ue(t,t,[a,c])}let i=null;for(let a=0;a<o.length;a++){let c=o[a];if(!c||c===t)continue;let u=ze(e,c,t,n.maxDepth);u.found&&(i==null||u.pathOrder.length<i.pathOrder.length)&&(i=u,i={found:!0,pathOrder:[{path:t,depIndices:[a]},...u.pathOrder],truncated:!1})}return i==null?null:ue(t,t,Ke(e,i.pathOrder,n))}function Ke(e,t,n){return t.map((r,o)=>{let s=e.nodes[r.path],i=ae(r.path,s,o,n);return r.depIndices!=null&&r.depIndices.length>0&&(i.dep_index=r.depIndices[0],r.depIndices.length>1&&(i.dep_indices=[...r.depIndices])),i})}function ae(e,t,n,r){let o={path:e,type:t.type,hop:n};t.status!==void 0&&(o.status=t.status),"value"in t&&(o.value=t.value),t.v!=null&&(o.v=t.v);let s=r.annotations?.get(e)??t.annotation;s!=null&&(o.annotation=s);let i=r.lastMutations?.get(e)??t.lastMutation;return i!=null&&(o.lastMutation=i),o}function ue(e,t,n){return We(e,t,!0,"ok",n)}function ie(e,t,n){return We(e,t,!1,n,[])}function We(e,t,n,r,o){let s=mt(e,t,n,r,o);return{from:e,to:t,found:n,reason:r,steps:o,text:s,toJSON(){return{from:e,to:t,found:n,reason:r,steps:o}}}}function mt(e,t,n,r,o){if(!n)switch(r){case"no-such-from":return`explainPath: no node named "${e}"`;case"no-such-to":return`explainPath: no node named "${t}"`;case"max-depth-exceeded":return`explainPath: no path from "${e}" to "${t}" within maxDepth`;default:return`explainPath: no path from "${e}" to "${t}"`}let s=[`Causal path: ${e} \u2192 ${t} (${o.length} step(s))`];for(let i of o){let c=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(s.push(c),"value"in i&&s.push(` value: ${bt(i.value)}`),i.annotation!=null&&s.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let u=i.lastMutation.actor;s.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return s.join(`
2
+ `)}function bt(e){if(e===void 0)return"<sentinel>";if(e===null)return"null";if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return String(e);try{let t=JSON.stringify(e);return t.length>80?`${t.slice(0,77)}...`:t}catch{return String(e)}}var M={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},yt=Symbol.for("sizeof");function qe(e){let t=new WeakSet,n=new WeakSet,r=[e],o=0;for(;r.length>0;){let s=r.pop();o+=vt(s,t,n,r)}return o}function vt(e,t,n,r){if(e==null)return 0;switch(typeof e){case"number":return M.number;case"boolean":return M.boolean;case"string":return M.string+e.length*2;case"bigint":return M.bigint+xt(e);case"symbol":return M.symbol;case"function":return t.has(e)?0:(t.add(e),M.function);case"undefined":return 0}let s=e;if(t.has(s))return 0;t.add(s);let i=s[yt];if(typeof i=="function")try{let u=i.call(s);if(typeof u=="number"&&Number.isFinite(u))return u}catch{}if(s instanceof Date)return M.date;if(s instanceof RegExp)return M.regexp+s.source.length*2;if(s instanceof Error){let u=s.message?s.message.length*2:0,d=s.stack?s.stack.length*2:0;return M.error+u+d}if(typeof URL<"u"&&s instanceof URL)return M.url+s.href.length*2;if(typeof Promise<"u"&&s instanceof Promise)return M.promise;if(s instanceof WeakMap)return M.weakmap;if(s instanceof WeakSet)return M.weakset;if(s instanceof Map){let u=M.map;for(let[d,h]of s)u+=M.mapEntry,r.push(d),r.push(h);return u}if(s instanceof Set){let u=M.set;for(let d of s)u+=M.setEntry,r.push(d);return u}if(Array.isArray(s)){let u=M.array+s.length*8;for(let d of s)r.push(d);return u}if(s instanceof ArrayBuffer)return n.has(s)?0:(n.add(s),s.byteLength);if(ArrayBuffer.isView(s)){let u=s;return n.has(u.buffer)?48:(n.add(u.buffer),u.buffer.byteLength+48)}let a=M.object,c=Object.keys(s);for(let u of c){a+=M.string+u.length*2;try{r.push(s[u])}catch{}}return a}function xt(e){let t=e<0n?-e:e;if(t===0n)return 0;let n=t.toString(2).length;return Math.ceil(n/32)*8}function Ue(e,t){let n=t?.topN??10,r=e.describe({detail:"standard"}),o=[],s=e._collectObserveTargets;typeof s=="function"&&s.call(e,"",o);let i=new Map;for(let[p,f]of o)i.set(p,f);let a=[];for(let[p,f]of Object.entries(r.nodes)){let l=i.get(p),m=l instanceof L?l:null,g=m?qe(m.cache):0,x=m?m._sinkCount:0,y=f.deps?.length??0,b=f.type==="effect"&&x===0,v=x===0?f.type==="effect"?"orphan-effect":f.type==="derived"?"idle-derived":f.type==="producer"?"idle-producer":null:null;a.push({path:p,type:f.type,status:f.status??"unknown",valueSizeBytes:g,subscriberCount:x,depCount:y,isOrphanEffect:b,orphanKind:v})}let c=a.reduce((p,f)=>p+f.valueSizeBytes,0),u=(p,f)=>[...a].sort(f??((l,m)=>m[p]-l[p])).slice(0,n),d=a.filter(p=>p.orphanKind!=null),h=a.filter(p=>p.isOrphanEffect);return{nodeCount:a.length,edgeCount:r.edges.length,subgraphCount:r.subgraphs.length,nodes:a,totalValueSizeBytes:c,hotspots:{byValueSize:u("valueSizeBytes"),bySubscriberCount:u("subscriberCount"),byDepCount:u("depCount")},orphans:d,orphanEffects:h}}function ke(e){return e>=768&&e<=879||e>=1155&&e<=1161||e>=1425&&e<=1469||e>=1552&&e<=1562||e>=1611&&e<=1631||e>=1648&&e===1648||e>=1750&&e<=1756||e>=1759&&e<=1764||e>=1767&&e<=1768||e>=1770&&e<=1773||e>=1840&&e<=1866||e>=1958&&e<=1968||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2641||e>=2672&&e<=2673||e>=2677&&e===2677||e>=3633&&e===3633||e>=3636&&e<=3642||e>=3655&&e<=3662||e>=3761&&e===3761||e>=3764&&e<=3772||e>=3784&&e<=3790||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65024&&e<=65039||e>=65056&&e<=65071||e===8205?0:e>=4352&&e<=4447||e>=8986&&e<=8987||e>=9001&&e<=9002||e>=9193&&e<=9203||e>=9208&&e<=9210||e>=9725&&e<=9726||e>=9748&&e<=9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e>=9898&&e<=9899||e>=9917&&e<=9918||e>=9924&&e<=9925||e===9934||e===9940||e===9962||e>=9970&&e<=9971||e===9973||e===9978||e===9981||e===9986||e===9989||e>=9992&&e<=9997||e===9999||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e>=10548&&e<=10549||e>=11013&&e<=11015||e>=11035&&e<=11036||e===11088||e===11093||e>=11904&&e<=12350||e>=12352&&e<=12447||e>=12448&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12784&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=19968&&e<=40959||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65131||e>=65281&&e<=65376||e>=65504&&e<=65510||e>=126980&&e===126980||e===127183||e>=127344&&e<=127345||e===127358||e===127359||e===127374||e>=127377&&e<=127386||e>=127456&&e<=127487||e>=127488&&e<=127490||e===127514||e===127535||e>=127538&&e<=127546||e>=127568&&e<=127569||e>=127744&&e<=129535||e>=129536&&e<=129791||e>=129792&&e<=130047||e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}function ce(e){let t=0;for(let n of e)t+=ke(n.codePointAt(0));return t}function Je(e,t){if(t<=0)return"";let n=0,r="";for(let o of e){let s=ke(o.codePointAt(0));if(n+s>t){if(t<=1)return"\u2026";for(;n+1>t&&r.length>0;){let i=[...r].pop();r=r.slice(0,-i.length),n-=ke(i.codePointAt(0))}return`${r}\u2026`}r+=o,n+=s}return r}var wt={horizontal:"\u2500",vertical:"\u2502",cornerTL:"\u250C",cornerTR:"\u2510",cornerBL:"\u2514",cornerBR:"\u2518",tDown:"\u252C",tUp:"\u2534",tRight:"\u251C",tLeft:"\u2524",cross:"\u253C",arrowRight:"\u25B6",arrowDown:"\u25BC",arrowLeft:"\u25C0",arrowUp:"\u25B2",boxTL:"\u250C",boxTR:"\u2510",boxBL:"\u2514",boxBR:"\u2518",boxH:"\u2500",boxV:"\u2502"},Ot={horizontal:"-",vertical:"|",cornerTL:"+",cornerTR:"+",cornerBL:"+",cornerBR:"+",tDown:"+",tUp:"+",tRight:"+",tLeft:"+",cross:"+",arrowRight:">",arrowDown:"v",arrowLeft:"<",arrowUp:"^",boxTL:"+",boxTR:"+",boxBL:"+",boxBR:"+",boxH:"-",boxV:"|"};function Ze(e,t){let n=t.charset==="ascii"?Ot:wt,r=e.width,o=e.height,s=Array.from({length:o},()=>Array.from({length:r},()=>" ")),i=Array.from({length:o},()=>Array.from({length:r},()=>"empty"));for(let a of e.edges)Et(s,i,n,a);for(let a of e.boxes)_t(s,i,n,a,t.labelOf(a.id));return s.map(a=>Gt(a.join(""))).join(`
3
+ `)}function _t(e,t,n,r,o){let{x:s,y:i,w:a,h:c}=r;if(a<2||c<2){c>0&&Ye(e,t,s,i,a,o);return}K(e,t,s,i,n.boxTL);for(let d=s+1;d<s+a-1;d+=1)K(e,t,d,i,n.boxH);K(e,t,s+a-1,i,n.boxTR);for(let d=i+1;d<i+c-1;d+=1){K(e,t,s,d,n.boxV);for(let h=s+1;h<s+a-1;h+=1)et(e,t,h,d," ","empty");K(e,t,s+a-1,d,n.boxV)}K(e,t,s,i+c-1,n.boxBL);for(let d=s+1;d<s+a-1;d+=1)K(e,t,d,i+c-1,n.boxH);K(e,t,s+a-1,i+c-1,n.boxBR);let u=i+Math.floor(c/2);Ye(e,t,s+1,u,a-2,o)}function K(e,t,n,r,o){et(e,t,n,r,o,o===" "?"empty":o==="\u2500"||o==="-"?"boxH":o==="\u2502"||o==="|"?"boxV":"boxCorner")}function et(e,t,n,r,o,s){if(r<0||r>=e.length)return;let i=e[r];n<0||n>=i.length||(i[n]=o,t[r][n]=s)}function Ye(e,t,n,r,o,s){if(r<0||r>=e.length)return;let i=n,a=o;for(let c of s){let u=ce(c);if(u!==0){if(a<u)break;i>=0&&i<e[r].length&&(e[r][i]=c,t[r][i]="label",u===2&&i+1<e[r].length&&(e[r][i+1]="",t[r][i+1]="label")),i+=u,a-=u}}for(;a>0;)i>=0&&i<e[r].length&&(e[r][i]=" ",t[r][i]="empty"),i+=1,a-=1}function Et(e,t,n,r){let o=r.points;if(o.length<2)return;for(let c=0;c+1<o.length;c+=1)Dt(e,t,n,o[c],o[c+1]);for(let c=1;c+1<o.length;c+=1){let u=o[c-1],d=o[c],h=o[c+1],p=Rt(u,d,h,n);p&&Qe(e,t,d.x,d.y,p,"edgeCorner")}let s=o[o.length-1],i=o[o.length-2],a=St(i,s,n);a&&Qe(e,t,s.x,s.y,a,"arrow")}function Dt(e,t,n,r,o){if(!(r.x===o.x&&r.y===o.y)){if(r.y===o.y){let s=r.y,i=Math.min(r.x,o.x),a=Math.max(r.x,o.x);for(let c=i;c<=a;c+=1)Xe(e,t,c,s,n,"h")}else if(r.x===o.x){let s=r.x,i=Math.min(r.y,o.y),a=Math.max(r.y,o.y);for(let c=i;c<=a;c+=1)Xe(e,t,s,c,n,"v")}}}function Xe(e,t,n,r,o,s){if(r<0||r>=e.length)return;let i=e[r];if(n<0||n>=i.length)return;let a=t[r][n];if(!(a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label")){if(a==="empty"){i[n]=s==="h"?o.horizontal:o.vertical,t[r][n]=s==="h"?"edgeH":"edgeV";return}if(a==="edgeH"&&s==="v"){i[n]=o.cross,t[r][n]="edgeCorner";return}if(a==="edgeV"&&s==="h"){i[n]=o.cross,t[r][n]="edgeCorner";return}}}function Qe(e,t,n,r,o,s){if(r<0||r>=e.length)return;let i=e[r];if(n<0||n>=i.length)return;let a=t[r][n];a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label"||(i[n]=o,t[r][n]=s)}function Rt(e,t,n,r){let o=e.y===t.y,s=t.y===n.y;if(o===s)return;if(o){let c=e.x<t.x,u=n.y>t.y;return c&&u?r.cornerTR:c&&!u?r.cornerBR:!c&&u?r.cornerTL:r.cornerBL}let i=e.y<t.y,a=n.x>t.x;return i&&a?r.cornerBL:i&&!a?r.cornerBR:!i&&a?r.cornerTL:r.cornerTR}function St(e,t,n){if(t.x>e.x)return n.arrowRight;if(t.x<e.x)return n.arrowLeft;if(t.y>e.y)return n.arrowDown;if(t.y<e.y)return n.arrowUp}function Gt(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===32;)t-=1;return e.slice(0,t)}function rt(e){let t=kt(e);Ct(t),At(t),Nt(t),$t(t,e);let n=Pt(t,e),{width:r,height:o}=It(t),s=[];for(let i of t.layers)for(let a of i)a.isVirtual||s.push({id:a.id,layer:a.layer,order:a.order,x:a.x,y:a.y,w:a.w,h:a.h});return{boxes:s,edges:n,width:r,height:o}}function kt(e){let t=new Map;for(let o of e.nodes)t.set(o,{id:o,isVirtual:!1,layer:-1,order:0,x:0,y:0,w:e.widthCells(o),h:e.heightCells(o),in:[],out:[]});let n=[],r=0;for(let o of e.edges){if(o.from===o.to)continue;let s=t.get(o.from),i=t.get(o.to);if(!s||!i)continue;let a={chainId:r++,chainFrom:o.from,chainTo:o.to,fromId:o.from,toId:o.to,hopIndex:0,chainLen:1};s.out.push(a),i.in.push(a),n.push(a)}return{nodes:t,layers:[],hops:n}}function Ct(e){let t=new Map;for(let s of e.nodes.values())t.set(s.id,s.in.length);let n=[];for(let s of e.nodes.values())(t.get(s.id)??0)===0&&(s.layer=0,n.push(s));let r=new Set,o=0;for(;o<n.length;){let s=n[o++];if(!r.has(s.id)){r.add(s.id);for(let i of s.out){let a=e.nodes.get(i.toId);a.layer=Math.max(a.layer,s.layer+1);let c=(t.get(a.id)??0)-1;t.set(a.id,c),c<=0&&n.push(a)}}}for(let s of e.nodes.values())s.layer<0&&(s.layer=0)}function At(e){let t=Math.max(0,...Array.from(e.nodes.values(),s=>s.layer)),n=Array.from({length:t+1},()=>[]);for(let s of e.nodes.values())n[s.layer].push(s);let r=[],o=0;for(let s of e.hops){let i=e.nodes.get(s.fromId),a=e.nodes.get(s.toId),c=a.layer-i.layer;if(c<=0){i.out=i.out.filter(h=>h!==s),a.in=a.in.filter(h=>h!==s);continue}if(c===1){s.hopIndex=0,s.chainLen=1,r.push(s);continue}i.out=i.out.filter(h=>h!==s),a.in=a.in.filter(h=>h!==s);let u=i;for(let h=1;h<c;h+=1){let p=`__virt_${o++}__`,f={id:p,isVirtual:!0,layer:i.layer+h,order:0,x:0,y:0,w:0,h:1,in:[],out:[]};e.nodes.set(p,f),n[f.layer].push(f);let l={chainId:s.chainId,chainFrom:s.chainFrom,chainTo:s.chainTo,fromId:u.id,toId:p,hopIndex:h-1,chainLen:c};u.out.push(l),f.in.push(l),r.push(l),u=f}let d={chainId:s.chainId,chainFrom:s.chainFrom,chainTo:s.chainTo,fromId:u.id,toId:a.id,hopIndex:c-1,chainLen:c};u.out.push(d),a.in.push(d),r.push(d)}for(let s of n)for(let i=0;i<s.length;i+=1)s[i].order=i;e.layers=n,e.hops=r}function Nt(e){for(let n=0;n<4;n+=1){for(let r=1;r<e.layers.length;r+=1)tt(e,e.layers[r],"in"),le(e.layers[r]);for(let r=e.layers.length-2;r>=0;r-=1)tt(e,e.layers[r],"out"),le(e.layers[r])}for(let n=0;n<2;n+=1){let r=!1;for(let o=1;o<e.layers.length;o+=1){let s=e.layers[o];for(let i=0;i+1<s.length;i+=1){let a=nt(e,s[i],s[i+1],"in");[s[i],s[i+1]]=[s[i+1],s[i]],le(s),nt(e,s[i],s[i+1],"in")<a?r=!0:([s[i],s[i+1]]=[s[i+1],s[i]],le(s))}}if(!r)break}}function tt(e,t,n){let r=new Map;for(let o of t){let s=n==="in"?o.in:o.out;if(s.length===0){r.set(o.id,o.order);continue}let i=0,a=0;for(let c of s){let u=e.nodes.get(n==="in"?c.fromId:c.toId);u&&(i+=u.order,a+=1)}r.set(o.id,a===0?o.order:i/a)}t.sort((o,s)=>{let i=r.get(o.id),a=r.get(s.id);return i!==a?i-a:o.order-s.order})}function le(e){for(let t=0;t<e.length;t+=1)e[t].order=t}function nt(e,t,n,r){let o=r==="in"?t.in:t.out,s=r==="in"?n.in:n.out,i=0;for(let a of o)for(let c of s){let u=e.nodes.get(r==="in"?a.fromId:a.toId)?.order??0,d=e.nodes.get(r==="in"?c.fromId:c.toId)?.order??0;(t.order<n.order&&u>d||t.order>n.order&&u<d)&&(i+=1)}return i}function $t(e,t){t.direction==="LR"?Tt(e,t):Mt(e,t)}function Tt(e,t){let n=[],r=0;for(let o=0;o<e.layers.length;o+=1){n.push(r);let s=0;for(let i of e.layers[o])s=Math.max(s,i.w);r+=s+t.layerGap}for(let o=0;o<e.layers.length;o+=1)for(let s of e.layers[o])s.x=n[o];for(let o of e.layers){let s=0;for(let i of o)i.y=s,s+=i.h+t.nodeGap}st(e,t,"y")}function Mt(e,t){let n=[],r=0;for(let o=0;o<e.layers.length;o+=1){n.push(r);let s=0;for(let i of e.layers[o])s=Math.max(s,i.h);r+=s+t.layerGap}for(let o=0;o<e.layers.length;o+=1)for(let s of e.layers[o])s.y=n[o];for(let o of e.layers){let s=0;for(let i of o)i.x=s,s+=i.w+t.nodeGap}st(e,t,"x")}function st(e,t,n){let r=s=>n==="y"?s.h:s.w,o=t.nodeGap;for(let s=0;s<2;s+=1){let i=s===0?e.layers.slice(1):e.layers.slice(0,-1).reverse();for(let a of i){let c=new Map;for(let d of a){let h=s===0?d.in:d.out;if(h.length===0)continue;let p=[];for(let l of h){let m=e.nodes.get(s===0?l.fromId:l.toId);if(!m)continue;let g=n==="y"?m.y:m.x;p.push(g+Math.floor(r(m)/2))}if(p.length===0)continue;p.sort((l,m)=>l-m);let f=p[Math.floor(p.length/2)];c.set(d.id,f-Math.floor(r(d)/2))}let u=0;for(let d of a){let h=c.get(d.id),p=n==="y"?d.y:d.x,l=Math.max(h??p,u);n==="y"?d.y=l:d.x=l,u=l+r(d)+o}}}}function Pt(e,t){let n=new Map;for(let u of e.hops){let d=n.get(u.chainId);d?d.push(u):n.set(u.chainId,[u])}for(let u of n.values())u.sort((d,h)=>d.hopIndex-h.hopIndex);let r=t.direction==="LR",o=u=>r?u.x:u.y,s=u=>r?u.w:u.h,i=u=>r?u.y+Math.floor(u.h/2):u.x+Math.floor(u.w/2),a=new Map;for(let u=0;u+1<e.layers.length;u+=1){let d=e.layers[u],h=e.layers[u+1],p=0;for(let D of d)p=Math.max(p,o(D)+s(D));let f=Number.POSITIVE_INFINITY;for(let D of h)f=Math.min(f,o(D));let l=Number.isFinite(f)?f-1:p,m=Math.max(1,l-p+1),g=[];for(let D of d)for(let S of D.out)g.push(S);g.sort((D,S)=>{let C=i(e.nodes.get(D.fromId)),A=i(e.nodes.get(S.fromId));if(C!==A)return C-A;let T=i(e.nodes.get(D.toId)),R=i(e.nodes.get(S.toId));return T-R});let x=[],y=new Map;for(let D of g){let S=i(e.nodes.get(D.fromId)),C=i(e.nodes.get(D.toId)),A=Math.min(S,C),T=Math.max(S,C),R=-1;for(let G=0;G<x.length;G+=1){let F=x[G],V=!0;for(let J of F)if(J.lo<=T&&A<=J.hi){V=!1;break}if(V){F.push({lo:A,hi:T}),R=G;break}}R<0&&(x.push([{lo:A,hi:T}]),R=x.length-1),y.set(D,R)}let b=x.length,v=m>=Math.max(3,b+2),O=v?p+1:p,w=v?l-1:l,_=Math.max(1,w-O+1);for(let D of g){let S=y.get(D),C;if(b<=1)C=O+Math.floor(_/2);else{let A=(_-1)/(b-1);C=O+Math.floor(S*A)}a.set(D,Math.max(p,Math.min(l,C)))}}let c=[];for(let[,u]of n){let d=[];for(let p=0;p<u.length;p+=1){let f=u[p],l=e.nodes.get(f.fromId),m=e.nodes.get(f.toId),g=a.get(f),x=l.isVirtual?o(l):o(l)+s(l),y=m.isVirtual?o(m):o(m)-1,b=i(l),v=i(m);p===0&&de(d,r,x,b),b!==v&&(de(d,r,g,b),de(d,r,g,v)),de(d,r,y,v)}let h=u[0];c.push({from:h.chainFrom,to:h.chainTo,points:Lt(d)})}return c}function de(e,t,n,r){e.push(t?{x:n,y:r}:{x:r,y:n})}function Lt(e){let t=[];for(let n of e){let r=t[t.length-1];(!r||r.x!==n.x||r.y!==n.y)&&t.push(n)}return t}function It(e){let t=0,n=0;for(let r of e.layers)for(let o of r)t=Math.max(t,o.x+o.w),n=Math.max(n,o.y+o.h);return{width:t,height:n}}var jt=24,Bt=4,Ft=1,Ht=3;function ot(e,t){let n=Vt(t.direction),r=Math.max(3,t.maxLabelWidth??jt),o=t.asciiCharset??"unicode",s=Object.keys(e.nodes).sort(),i=new Set(s),a=e.edges.filter(f=>i.has(f.from)&&i.has(f.to)),c=new Map,u=new Map;for(let f of s){let l=Je(f,r);c.set(f,l),u.set(f,ce(l)+4)}let d=rt({nodes:s,edges:a,widthCells:f=>u.get(f)??3,heightCells:()=>Ht,layerGap:Bt,nodeGap:Ft,direction:n}),h=Ze(d,{charset:o,labelOf:f=>c.get(f)??f}),p=t.logger;return p&&p(h),h}function Vt(e){if(e===void 0||e==="LR")return"LR";if(e==="TD")return"TD";throw new Error(`ascii describe supports direction "LR" or "TD" only; got ${String(e)}`)}var $="::",B="__meta__",U=1;function it(e,t){let n=Math.max(16,e.size*4),r=0;for(;e.size>0;){if(r++>=n){console.error(`[Graph "${t}".destroy] disposer drain exceeded cap (${n}); ${e.size} disposer(s) discarded`),e.clear();return}let o=e.values().next();if(o.done)return;let s=o.value;e.delete(s);try{s()}catch(i){console.error(`[Graph "${t}".destroy] disposer threw:`,i)}}}function lt(e){return e!=null&&typeof e=="object"&&"cache"in e&&typeof e.subscribe=="function"&&typeof e.down=="function"}function zt(e){if(e!=null)return lt(e)?e.cache:e}function Kt(e){let t=[];for(let n of Object.keys(e).sort()){let r=e[n].v;r!=null&&t.push(`${n} ${r.id} ${r.version}`)}return t.join(`
4
+ `)}function at(e){if(e.version!==U)throw new Error(`unsupported snapshot version ${String(e.version)} (expected ${U})`);for(let t of["name","nodes","edges","subgraphs"])if(!(t in e))throw new Error(`snapshot missing required key "${t}"`);if(typeof e.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof e.nodes!="object"||e.nodes===null||Array.isArray(e.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(e.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(e.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function Wt(e,t){let n=new WeakMap,r=(o,s)=>{if(Object.is(o,s))return!0;if(o==null||s==null||typeof o!="object"||typeof s!="object")return!1;let i=n.get(o);if(i==null&&(i=new WeakSet,n.set(o,i)),i.has(s))return!0;i.add(s);let a=o.constructor,c=s.constructor;if(a!==c)return!1;if(o instanceof Date)return o.getTime()===s.getTime();if(o instanceof RegExp)return o.source===s.source&&o.flags===s.flags;if(Array.isArray(o)){let p=s;if(o.length!==p.length)return!1;for(let f=0;f<o.length;f++)if(!r(o[f],p[f]))return!1;return!0}if(o instanceof Map){let p=s;if(o.size!==p.size)return!1;for(let[f,l]of o)if(!p.has(f)||!r(l,p.get(f)))return!1;return!0}if(o instanceof Set){let p=s;if(o.size!==p.size)return!1;for(let f of o){let l=!1;for(let m of p)if(r(f,m)){l=!0;break}if(!l)return!1}return!0}if(ArrayBuffer.isView(o)){let p=o,f=s;if(p.length!==f.length)return!1;for(let l=0;l<p.length;l++)if(p[l]!==f[l])return!1;return!0}let u=Object.keys(o),d=Object.keys(s);if(u.length!==d.length)return!1;let h=new Set(d);for(let p of u)if(!h.has(p)||!r(o[p],s[p]))return!1;return!0};return r(e,t)}function Ae(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ae);let t=e,n=Object.keys(t).sort(),r={};for(let o of n)r[o]=Ae(t[o]);return r}function qt(e){return e.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Ut(e){return e.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Jt(e){return e==="TD"?"down":e==="BT"?"up":e==="RL"?"left":"right"}function dt(e){let t=new Set,n=[];function r(o,s){let i=`${o}\0${s}`;t.has(i)||(t.add(i),n.push([o,s]))}for(let[o,s]of Object.entries(e.nodes)){let i=s.deps;if(i)for(let a of i)r(a,o)}for(let o of e.edges)r(o.from,o.to);return n}function ft(e){if(e===void 0)return"LR";if(e==="TD"||e==="LR"||e==="BT"||e==="RL")return e;throw new Error(`invalid diagram direction ${String(e)}; expected one of: TD, LR, BT, RL`)}function Yt(e,t){let n=t.includeEdges??!0,r=t.includeSubgraphs??!0,{expand:o,...s}=e,i={...s,edges:n?e.edges:[],subgraphs:r?e.subgraphs:[]},a=JSON.stringify(Ae(i),null,t.indent??2);return t.logger?.(a),a}function Xt(e,t){let n=t.includeEdges??!0,r=t.includeSubgraphs??!0,o=[];o.push(`Graph ${e.name}`),o.push("Nodes:");for(let i of Object.keys(e.nodes).sort()){let a=e.nodes[i];o.push(`- ${i} (${a.type}/${a.status}): ${pe(a.value)}`)}if(n){o.push("Edges:");for(let i of e.edges)o.push(`- ${i.from} -> ${i.to}`)}if(r){o.push("Subgraphs:");for(let i of e.subgraphs)o.push(`- ${i}`)}let s=o.join(`
5
+ `);return t.logger?.(s),s}function pt(e,t){let n=ft(t.direction),r=Object.keys(e.nodes).sort(),o=new Map;for(let i=0;i<r.length;i+=1)o.set(r[i],`n${i}`);let s=[`flowchart ${n}`];for(let i of r){let a=o.get(i);s.push(` ${a}["${qt(i)}"]`)}for(let[i,a]of dt(e)){let c=o.get(i),u=o.get(a);!c||!u||s.push(` ${c} --> ${u}`)}return s.join(`
6
+ `)}function Qt(e,t){let n=pt(e,t);return Zt(n)}function Zt(e,t){let n=t?.theme??"default",r=t?.autoSync??!0,s=JSON.stringify({code:e,mermaid:{theme:n},autoSync:r}),i=new TextEncoder().encode(s),a="";for(let u=0;u<i.length;u++)a+=String.fromCharCode(i[u]);return`https://mermaid.live/edit#base64:${globalThis.btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function en(e,t){let n=ft(t.direction),r=Object.keys(e.nodes).sort(),o=new Map;for(let i=0;i<r.length;i+=1)o.set(r[i],`n${i}`);let s=[`direction: ${Jt(n)}`];for(let i of r){let a=o.get(i);s.push(`${a}: "${Ut(i)}"`)}for(let[i,a]of dt(e)){let c=o.get(i),u=o.get(a);!c||!u||s.push(`${c} -> ${u}`)}return s.join(`
7
+ `)}function tn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fe(e){let t="^";for(let n=0;n<e.length;n+=1){let r=e[n];if(r==="*"){t+=".*";continue}if(r==="?"){t+=".";continue}if(r==="["){let o=e.indexOf("]",n+1);if(o<=n+1){t+="\\[";continue}let s=e.slice(n+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),t+=`[${s}]`,n=o;continue}t+=tn(r)}return t+="$",new RegExp(t)}var nn={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"},rn={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function pe(e){if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean"||e==null)return String(e);try{return JSON.stringify(e)}catch{return"[unserializable]"}}function sn(e){return e==="none"?rn:e==="ansi"||e==null?nn:{data:e.data??"",dirty:e.dirty??"",resolved:e.resolved??"",invalidate:e.invalidate??"",pause:e.pause??"",resume:e.resume??"",complete:e.complete??"",error:e.error??"",teardown:e.teardown??"",derived:e.derived??"",path:e.path??"",reset:e.reset??""}}function ut(e){if(e==null)return{};let t=e.detail;return t==="full"?{...e,structured:e.structured??!0,timeline:e.timeline??!0,causal:e.causal??!0,derived:e.derived??!0}:t==="minimal"?{...e,structured:e.structured??!0}:e.format==="stage-log"?{...e,structured:e.structured??!0,timeline:e.timeline??!0}:e}function on(e,t,n){for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);if(o<32||o===127)throw new Error(`Graph "${t}": ${n} "${e}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function Ce(e,t,n){if(e==="")throw new Error(`Graph "${t}": ${n} name must be non-empty`);if(e.includes($))throw new Error(`Graph "${t}": ${n} "${e}" must not contain '${$}' (path separator)`);if(e===B)throw new Error(`Graph "${t}": ${n} name "${B}" is reserved for meta companion paths`);on(e,t,n)}function an(e,t){if(e==="")throw new Error(`Graph "${t}": resolve path must be non-empty`);let n=e.split($);for(let r of n)if(r==="")throw new Error(`Graph "${t}": resolve path has empty segment`);return n}function un(e,t){let n=!1;for(let o of e)if(!t.isMetaPassthrough(o[0])){n=!0;break}return n?e.filter(o=>t.isMetaPassthrough(o[0])):e}function ht(e){for(let t of e._mounts.values())ht(t);for(let t of e._nodes.values())try{t.down([[z]],{internal:!0})}catch{}}var Ne=class e{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(t,n){if(t==="")throw new Error("Graph name must be non-empty");if(t.includes($))throw new Error(`Graph name must not contain '${$}' (got "${t}")`);if(t===B)throw new Error(`Graph name "${B}" is reserved for meta companion paths`);this.name=t,this.opts=Object.freeze({...n??{}}),this.config=n?.config??Oe,this._traceRing=new Re(n?.traceCapacity??1e3),n?.versioning!=null&&this.setVersioning(n.versioning),typeof n?.factory=="string"&&(this._factory=n.factory,n.factoryArgs!==void 0&&(this._factoryArgs=n.factoryArgs))}tagFactory(t,n){return this._factory=t,this._factoryArgs=n,this}ancestors(t=!0){let n=[],r=t?this:this._parent;for(;r!=null;)n.push(r),r=r._parent;return n}get topology(){return this._topology==null&&(this._topology=_e(t=>{let n=r=>{t.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(t){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(t)}nameOf(t){return this._nodeToName.get(t)}add(t,n){let r=t.name,o=n?.name??r;if(o==null||o==="")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 s=o,i=n?.annotation;if(Ce(s,this.name,"add"),this._mounts.has(s))throw new Error(`Graph "${this.name}": name "${s}" is already a mount point`);if(this._nodes.has(s))throw new Error(`Graph "${this.name}": node "${s}" already exists`);let a=this._nodeToName.get(t);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(s,t),this._nodeToName.set(t,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),i!=null&&(this._annotations.set(s,i),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:i,timestamp_ns:H()})),t}setVersioning(t){if(t!=null)for(let n of this._nodes.values())n instanceof L&&n._applyVersioning(t)}remove(t){Ce(t,this.name,"remove");let n=this._mounts.get(t);if(n){let s={kind:"mount",nodes:[],mounts:[]},i=[];n._collectObserveTargets("",i);for(let[a,c]of i)a.includes(`${$}${B}${$}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(t),s.mounts.push(...n._collectSubgraphs(`${t}${$}`)),this._mounts.delete(t),n._parent=void 0,ht(n),this._emitTopology({kind:"removed",name:t,nodeKind:"mount",audit:s}),s}let r=this._nodes.get(t);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${t}"`);this._nodes.delete(t),this._nodeToName.delete(r),r.down([[z]],{internal:!0});let o={kind:"node",nodes:[t],mounts:[]};return this._emitTopology({kind:"removed",name:t,nodeKind:"node",audit:o}),o}removeAll(t){let n=typeof t=="function"?t:(()=>{let s=fe(t);return i=>s.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>n(s));for(let s of o){let i=this.remove(s);r.nodes.push(...i.nodes),r.mounts.push(...i.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let t=[...this._nodes.keys()].sort(),n=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=t.length)return{value:void 0,done:!0};let o=t[r++];return{value:[o,n.get(o)],done:!1}}}}node(t){if(t==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(t.includes($))return this.resolve(t);let n=this._nodes.get(t);if(!n)throw new Error(`Graph "${this.name}": unknown node "${t}"`);return n}get(t){return this.node(t).cache}set(t,n,r){let o=r?.internal===!0;this.node(t).down([[W,n]],{actor:r?.actor,internal:o,delivery:"write"})}setAll(t,n){let r=Symbol.iterator in t?t:Object.entries(t);je(()=>{for(let[o,s]of r)this.set(o,s,n)})}invalidate(t,n){let r=n?.internal===!0;this.node(t).down([[ne]],{actor:n?.actor,internal:r,delivery:"write"})}error(t,n,r){let o=r?.internal===!0;this.node(t).down([[Q,n]],{actor:r?.actor,internal:o,delivery:"write"})}complete(t,n){let r=n?.internal===!0;this.node(t).down([[X]],{actor:n?.actor,internal:r,delivery:"write"})}edges(t){let n=t?.recursive===!0,r=new Map;if(!n){for(let[c,u]of this._nodes)r.set(u,c);let a=[];for(let[c,u]of this._nodes)if(u instanceof L)for(let d of u._deps){let h=r.get(d.node);h!=null&&a.push([h,c])}return a.sort((c,u)=>c[0]<u[0]?-1:c[0]>u[0]?1:c[1]<u[1]?-1:c[1]>u[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,c]of o)s.set(c,a);let i=[];for(let[a,c]of o)if(c instanceof L)for(let u of c._deps){let d=s.get(u.node);d!=null&&i.push([d,a])}return i.sort((a,c)=>a[0]<c[0]?-1:a[0]>c[0]?1:a[1]<c[1]?-1:a[1]>c[1]?1:0),i}mount(t,n){if(n===void 0){let o=new e(t);return this.mount(t,o)}if(typeof n=="function"){let o=new e(t);return n(o),this.mount(t,o)}let r=n;if(Ce(t,this.name,"mount"),this._nodes.has(t))throw new Error(`Graph "${this.name}": cannot mount at "${t}" \u2014 node with that name exists`);if(this._mounts.has(t))throw new Error(`Graph "${this.name}": mount "${t}" already exists`);if(r===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(r._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${r._parent.name}"`);for(let o=this;o!=null;o=o._parent)if(o===r)throw new Error(`Graph "${this.name}": mount("${t}", \u2026) would create a mount cycle`);return this._mounts.set(t,r),r._parent=this,this._emitTopology({kind:"added",name:t,nodeKind:"mount"}),r}resolve(t){let n=an(t,this.name);return this._resolveFromSegments(n)}tryResolve(t){try{return this.resolve(t)}catch{return}}_resolveFromSegments(t){let n=t;if(n[0]===this.name&&(n=n.slice(1),n.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=n[0],o=n.slice(1);if(o.length===0){let a=this._nodes.get(r);if(a)return a;throw this._mounts.has(r)?new Error(`Graph "${this.name}": path ends at subgraph "${r}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${r}"`)}let s=this._nodes.get(r);if(s&&o.length>0&&o[0]===B)return this._resolveMetaChainFromNode(s,o,n.join($));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${o.join($)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(o.join($))}_resolveMetaChainFromNode(t,n,r){let o=t,s=0,i=[...n];for(;s<i.length;){if(i[s]!==B)throw new Error(`Graph "${this.name}": expected ${B} segment in meta path "${r}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${B} in "${r}"`);let a=i[s+1],c=o.meta[a];if(!c)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);o=c,s+=2}return o}signal(t,n){if(n?.internal!==!0){for(let o of t)if(this.config.messageTier(o[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 r=[];if(this._signalDeliver(t,n??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(t,n,r,o){for(let c of this._mounts.values())c._signalDeliver(t,n,r,o);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=un(t,this.config);for(let c of[...this._nodes.keys()].sort()){let u=this._nodes.get(c);if(!r.has(u)){r.add(u);try{u.down(t,i)}catch(d){if(d instanceof q)throw d;o.push(d)}a.length!==0&&this._signalMetaSubtree(u,a,r,i,o)}}}_signalMetaSubtree(t,n,r,o,s){for(let i of Object.keys(t.meta).sort()){let a=t.meta[i];if(!r.has(a)){r.add(a);try{a.down(n,o)}catch(c){if(c instanceof q)throw c;s.push(c)}this._signalMetaSubtree(a,n,r,o,s)}}}describe(t){if(t?.reactive==="diff")return this._describeReactiveDiff(t);if(t?.reactive===!0)return this._describeReactive(t);let n=zt(t?.actor),r=t?.filter,o=se(t?.detail,t?.fields),s=t?.format==="spec",i=s?se("minimal"):o,a=[];this._collectObserveTargets("",a);let c=new Map;for(let[w,_]of a)c.set(_,w);let u=[];{let w=a.map(([,S])=>S),_=new Set(c.values()),D=0;for(;w.length>0;){let S=w.shift();if(S instanceof L)for(let C of S._deps){let A=C.node;if(c.has(A))continue;let T=A.name??"",R=T;if(!R||_.has(R))if(T){let G=2;for(;_.has(`${T}#${G}`);)G++;R=`${T}#${G}`}else for(R=`__internal__/${D++}`;_.has(R);)R=`__internal__/${D++}`;c.set(A,R),_.add(R),u.push([R,A]),w.push(A)}}}let d=[...a,...u],h={};for(let[w,_]of d){if(n!=null&&!_.allowsObserve(n))continue;let D=De(_,i),S=_ instanceof L?_._deps.map(R=>c.get(R.node)??R.node.name??""):[],{name:C,...A}=D,T={...A,deps:S};if(!s){let R=this._annotations.get(w);R!=null&&(T.annotation=R)}if(r!=null)if(typeof r=="function"){let R=r;if(!(R.length>=2?R(w,T):R(T)))continue}else{let R=!0;for(let[G,F]of Object.entries(r)){let V=G==="deps_includes"?"depsIncludes":G==="meta_has"?"metaHas":G;if(V==="depsIncludes"){if(!T.deps.includes(String(F))){R=!1;break}continue}if(V==="metaHas"){if(!Object.hasOwn(T.meta??{},String(F))){R=!1;break}continue}if(T[V]!==F){R=!1;break}}if(!R)continue}h[w]=T}let p=new Set(Object.keys(h)),f=[];for(let[w,_]of d)if(_ instanceof L)for(let D of _._deps){let S=c.get(D.node);S!=null&&f.push([S,w])}f.sort((w,_)=>w[0]<_[0]?-1:w[0]>_[0]?1:w[1]<_[1]?-1:w[1]>_[1]?1:0);let l=f.map(([w,_])=>({from:w,to:_}));(n!=null||r!=null)&&(l=l.filter(w=>p.has(w.from)&&p.has(w.to)));let m=this._collectSubgraphs(""),g=n!=null||r!=null?m.filter(w=>{let _=`${w}${$}`;return[...p].some(D=>D===w||D.startsWith(_))}):m,x=this,y=t,b={name:this.name,nodes:h,edges:l,subgraphs:g,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(w){let _={...y,format:void 0};return Array.isArray(w)?(_.fields=w,_.detail=void 0):(_.detail=w,_.fields=void 0),x.describe(_)}},v=t??{},O=v.format;return O==="json"?Yt(b,v):O==="pretty"?Xt(b,v):O==="mermaid"?pt(b,v):O==="mermaid-url"?Qt(b,v):O==="d2"?en(b,v):O==="ascii"?ot(b,v):b}_collectSubgraphs(t){let n=[];for(let r of[...this._mounts.keys()].sort()){let o=t===""?r:`${t}${r}`;n.push(o),n.push(...this._mounts.get(r)._collectSubgraphs(`${o}${$}`))}return n}resourceProfile(t){return Ue(this,t)}reachable(t,n,r={}){return r.withDetail===!0?ct(this.describe(),t,n,{...r,withDetail:!0}):ct(this.describe(),t,n,r)}explain(t,n,r){return r?.reactive===!0?this._explainReactive(t,n,r):this._explainStatic(t,n,r)}_explainStatic(t,n,r){let o=this.describe({detail:"full"}),s=new Map(this._annotations),i=new Map;for(let[a,c]of Object.entries(o.nodes))c.lastMutation!=null&&i.set(a,c.lastMutation);return Ve(o,t,n,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:i})}_describeReactive(t){let n={...t,reactive:!1},r=t.reactiveName??"describe",o=0,s=ee(o,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,c=!1,u=()=>{a||c||(a=!0,re(()=>{a=!1,!c&&(o+=1,s.emit(o))}))},d=i.onEvent(y=>{let b=y.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||u()}),h=[],p=new WeakSet,f=y=>{if(p.has(y)||c)return;p.add(y);let b=y.topology.subscribe(v=>{for(let O of v){if(O[0]!==W)continue;let w=O[1];if(u(),w.kind==="added"&&w.nodeKind==="mount"){let _=y._mounts.get(w.name);_!=null&&f(_)}}});h.push(b);for(let v of y._mounts.keys()){let O=y._mounts.get(v);O!=null&&f(O)}};f(this);let l,m=t.actor;lt(m)&&(l=m.subscribe(y=>{let b=!1,v=!1;for(let O of y){let w=O[0];w===W?b=!0:(w===X||w===Q||w===z)&&(v=!0)}b&&u(),v&&(l?.(),l=void 0,u())}));let g;try{g=Ee([s],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(y,b)=>y===b})}catch(y){d(),l?.();for(let b of h)b();throw i.dispose(),y}let x=oe(g);return{node:g,dispose(){c=!0,d(),l?.();for(let y of h)y();h.length=0,i.dispose(),x()}}}_describeReactiveDiff(t){let n={...t,format:void 0,reactive:!1},r=t.reactiveName??"describe-diff",o={name:this.name,nodes:{},edges:[],subgraphs:[]},s=this.describe(n),i=Ge(o,s),a=ee(i,{name:r,meta:{domain:"audit",kind:"describe-diff"},equals:(p,f)=>p===f}),c=this._describeReactive({...t,format:void 0,reactiveName:void 0}),u=!1,d=c.node.subscribe(p=>{if(!u)for(let f of p){if(f[0]!==W)continue;let l=f[1],m=Ge(s,l);s=l,m.events.length!==0&&a.emit(m)}}),h=oe(a);return{node:a,dispose(){u=!0,d(),c.dispose(),a.down([[z,"describe-diff disposed"]]),h()}}}_explainReactive(t,n,r){let o=0,s=ee(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,c=!1,u=i.onEvent(f=>{let l=f.type;l!=="data"&&l!=="error"&&l!=="complete"&&l!=="teardown"||a||c||(a=!0,re(()=>{a=!1,!c&&(o+=1,s.emit(o))}))}),d={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},h;try{h=Ee([s],()=>this._explainStatic(t,n,d),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:t,to:n},equals:(f,l)=>f.found===l.found&&f.reason===l.reason&&f.steps.length===l.steps.length&&ln(f.steps,l.steps)})}catch(f){throw u(),i.dispose(),f}let p=oe(h);return{node:h,dispose(){c=!0,u(),i.dispose(),p()}}}_pathsMatching(t){let n=fe(t),r=[];return this._collectObserveTargets("",r),r.map(([o])=>o).filter(o=>n.test(o))}_collectObserveTargets(t,n){for(let r of[...this._mounts.keys()].sort()){let o=t===""?r:`${t}${$}${r}`;this._mounts.get(r)._collectObserveTargets(o,n)}for(let r of[...this._nodes.keys()].sort()){let o=this._nodes.get(r),s=t===""?r:`${t}${$}${r}`;n.push([s,o]),this._appendMetaObserveTargets(s,o,n)}}_appendMetaObserveTargets(t,n,r){for(let o of Object.keys(n.meta).sort()){let s=n.meta[o],i=`${t}${$}${B}${$}${o}`;r.push([i,s]),this._appendMetaObserveTargets(i,s,r)}}observe(t,n){let r=typeof t=="string",s=ut(r?n:t);if(s.reactive===!0)return this._observeReactive(r?t:void 0,s);let i=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,a=s.actor;if(r){let d=t,h=this.resolve(d);if(a!=null&&!h.allowsObserve(a))throw new q({actor:a,action:"observe",nodeName:d});return i?this._buildStructuredObserver([[d,h]],s,"one"):{subscribe(p){return h.subscribe(p)},up(p){try{h.up?.(p)}catch(f){if(f instanceof q)return;throw f}}}}let c=[];this._collectObserveTargets("",c),c.sort((d,h)=>d[0]<h[0]?-1:d[0]>h[0]?1:0);let u=a==null?c:c.filter(([,d])=>d.allowsObserve(a));return i?this._buildStructuredObserver(u,s,"all"):{subscribe:d=>{let h=u.map(([p,f])=>f.subscribe(l=>{d(p,l)}));return()=>{for(let p of h)p()}},up:(d,h)=>{try{this.resolve(d).up?.(h)}catch(p){if(p instanceof q)return;throw p}}}}_observeReactive(t,n){let r=n.tiers,o=r!=null?new Set(r):null,s=n.reactiveName??"observe";return _e(i=>{let a=[],c=!1,u=!1,d=()=>{if(a.length===0||u)return;let m={events:a.slice(),flushedAt_ns:H()};a.length=0,i.emit(m)},h={...n,reactive:!1,structured:!0,timeline:!0},p=t!=null?this.observe(t,h):this.observe(h),f=m=>{u||(a.push(m),!c&&(c=!0,re(()=>{c=!1,d()})))};for(let m of p.events)f(m);let l=p.onEvent(f);return()=>{u=!0,l(),p.dispose()}},{name:s,meta:{domain:"audit",kind:"observe-reactive"}})}_buildStructuredObserver(t,n,r){let o=r==="one"?t[0]?.[0]:void 0,s=i=>{if(r==="one"&&o!=null){let d=this.resolve(o);return this._buildStructuredObserver([[o,d]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((d,h)=>d[0]<h[0]?-1:d[0]>h[0]?1:0);let c=i.actor,u=c==null?a:a.filter(([,d])=>d.allowsObserve(c));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(t,n,s)}_createObserveResult(t,n,r){let o=n.timeline===!0,s=n.causal===!0,i=n.derived===!0,a=n.detail==="minimal",c=this.config.inspectorEnabled,u=(s||i)&&c,d=n.maxEvents,h=d!=null&&d>0?new Re(d):null,p=[],f=new Set,l=n.tiers!=null?new Set(n.tiers):null,m={},g=new Set,x=0,y=0,b=0,v=0,O=0,w=0,_=!1,D=!1,S=0,C=new Map,A=new Map,T=new Map,R=E=>{if(!(l!=null&&!l.has(E.type))){h?h.push(E):p.push(E);for(let N of f)N(E)}},G=E=>l==null||l.has(E),F=()=>o?{timestamp_ns:H(),in_batch:Ie(),batch_id:S}:{},V=(E,N)=>{if(!(!u||!(E instanceof L)))return E._setInspectorHook(I=>{if(I.kind==="dep_message")C.set(E,I.depIndex);else if(I.kind==="run"){let Y=I.batchData.map((k,P)=>k!=null&&k.length>0?k.at(-1):I.prevData[P]);A.set(E,Y);let j=I.batchData.map(k=>k!=null?[...k]:void 0);T.set(E,j),i&&R({type:"derived",path:N,dep_values:Y,dep_batches:j,...F()})}})},J=E=>{let N=C.get(E),I=A.get(E);if(!s||I==null)return{};let j=(N!=null&&N>=0&&E instanceof L?E._deps[N]:void 0)?.node,k=j?.v,P=T.get(E);return{trigger_dep_index:N,trigger_dep_name:j?.name,...k!=null?{trigger_version:{id:k.id,version:k.version}}:{},dep_values:[...I],...P!=null?{dep_batches:P}:{}}},$e=[],Te=[];for(let[E,N]of t){let I=V(N,E);I&&$e.push(I),Te.push(N.subscribe(Y=>{S++;for(let j of Y){let k=j[0],P=F();if(k===W){m[E]=j[1];let be=N instanceof L?N.lastMutation?.actor??Z:Z;R({type:"data",path:E,data:j[1],actor:be,...P,...J(N)})}else if(a)k===ye?G("dirty")&&x++:k===ve?G("resolved")&&y++:k===ne?G("invalidate")&&b++:k===xe?G("pause")&&v++:k===we?G("resume")&&O++:k===z?G("teardown")&&w++:k===X&&!g.has(E)?G("complete")&&(_=!0):k===Q&&G("error")&&(D=!0,g.add(E));else if(k===ye)G("dirty")&&x++,R({type:"dirty",path:E,...P});else if(k===ve)G("resolved")&&y++,R({type:"resolved",path:E,...P,...J(N)});else if(k===ne)G("invalidate")&&b++,R({type:"invalidate",path:E,...P});else if(k===xe)G("pause")&&v++,R({type:"pause",path:E,lockId:j[1],...P});else if(k===we)G("resume")&&O++,R({type:"resume",path:E,lockId:j[1],...P});else if(k===X)G("complete")&&!g.has(E)&&(_=!0),R({type:"complete",path:E,...P});else if(k===Q){G("error")&&(D=!0,g.add(E));let be=N instanceof L?N.lastMutation?.actor??Z:Z;R({type:"error",path:E,data:j[1],actor:be,...P})}else k===z&&(G("teardown")&&w++,R({type:"teardown",path:E,...P}))}}))}let he=!1,ge=()=>{if(!he){he=!0;for(let E of Te)E();for(let E of $e)E();for(let E of te)E({value:void 0,done:!0});te.length=0}},me=[],te=[];f.add(E=>{let N=te.shift();N?N({value:E,done:!1}):me.push(E)});let Me={get values(){return m},get dirtyCount(){return x},get resolvedCount(){return y},get invalidateCount(){return b},get pauseCount(){return v},get resumeCount(){return O},get teardownCount(){return w},get events(){return h?h.toArray():[...p]},get anyCompletedCleanly(){return _},get anyErrored(){return D},get completedWithoutErrors(){return _&&!D},onEvent(E){return f.add(E),()=>f.delete(E)},dispose:ge,expand(E){ge();let N={...n};return typeof E=="string"?N.detail=E:Object.assign(N,E),r(ut(N))},[Symbol.asyncIterator](){return{next(){return me.length>0?Promise.resolve({value:me.shift(),done:!1}):he?Promise.resolve({value:void 0,done:!0}):new Promise(E=>te.push(E))},return(){return ge(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(Me,n),Me}_attachFormatLogger(t,n){let r=n.format;if(r==null)return;let o=n.logger??(l=>console.log(l)),s=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=s==null&&i==null?()=>!0:l=>(s==null||s.has(l))&&(i==null||!i.has(l)),c=sn(n.theme),u=r==="stage-log"?H():0,d=l=>l==null?"":n.stageLabels?.[l]??l,h=(l,m)=>l.length>m?`${l.slice(0,m-1)}\u2026`:l,p=l=>l.type==="data"||l.type==="error"?h(pe(l.data),120):"",f=l=>{if(r==="stage-log"){let _=(H()-u)/1e9,D=d(l.path).padEnd(9);if(l.type==="data"){let S=p(l);return`[${_.toFixed(3)}s] ${D} \u2190${S?` ${S}`:""}`}if(l.type==="error"){let S=p(l);return`[${_.toFixed(3)}s] ${D} \u2717${S?` ${S}`:""}`}return l.type==="complete"?`[${_.toFixed(3)}s] ${D} \u25A0 complete`:`[${_.toFixed(3)}s] ${D} ${l.type}`}if(r==="json")try{return JSON.stringify(l)}catch{return JSON.stringify({type:l.type,path:l.path,data:"[unserializable]"})}let m=c[l.type]??"",g=l.path?`${c.path}${l.path}${c.reset} `:"",x=l.type==="data"||l.type==="error",y=l.type==="pause"||l.type==="resume",b=x?` ${pe(l.data)}`:y?` ${pe(l.lockId)}`:"",v=l.type==="data"||l.type==="resolved"||l.type==="derived"?l:void 0,O=v?.trigger_dep_name!=null?` <- ${v.trigger_dep_name}`:v?.trigger_dep_index!=null?` <- #${v.trigger_dep_index}`:"",w=l.in_batch?" [batch]":"";return`${g}${m}${l.type.toUpperCase()}${c.reset}${b}${O}${w}`};t.onEvent(l=>{a(l.type)&&o(f(l),l)})}addDisposer(t){return this._disposers.add(t),()=>{this._disposers.delete(t)}}destroy(){it(this._disposers,this.name),this.signal([[z]],{internal:!0}),it(this._storageDisposers,this.name);for(let t of[...this._mounts.values()])t._parent=void 0,t._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let t of[...this._mounts.values()])t._parent=void 0,t._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(t){let{expand:n,...r}=this.describe({detail:"full"}),o={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:c,guard:u,...d}=r.nodes[a];o[a]=d}let s=[...r.subgraphs].sort(),i={...r,version:1,nodes:o,subgraphs:s};if(t?.format==null)return i;if(t.format==="json-string")return JSON.stringify(i);if(t.format==="bytes"){if(t.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(t.codec);if(a==null)throw new Error(`snapshot: codec "${t.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return Pe(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(t.format)}"`)}static decode(t,n){let r=n?.config??Oe,{codec:o,codecVersion:s,payload:i}=Le(t,r);return o.decode(i,s)}restore(t,n){if(at(t),t.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${t.name}" does not match this graph`);let r=n?.only==null?null:(Array.isArray(n.only)?n.only:[n.only]).map(s=>fe(s)),o=n?.includeProducers===!0;for(let s of Object.keys(t.nodes).sort()){if(r!==null&&!r.some(a=>a.test(s)))continue;let i=t.nodes[s];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&n?.onError?.(s,new Error(`restore: slice.value is undefined for "${s}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!o)){if(i.v!=null){let c=this.tryResolve(s)?.v;if(c!=null&&c.id===i.v.id&&c.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){n?.onError?.(s,a)}}}}}static fromSnapshot(t,n){at(t);let r=typeof n=="function"?n:n?.build,o=typeof n=="function"?void 0:n?.factories,s=new e(t.name);if(r)return r(s),s.restore(t),s;for(let f of[...t.subgraphs].sort((l,m)=>{let g=l.split($).length,x=m.split($).length;return g!==x?g-x:l<m?-1:l>m?1:0})){let l=f.split($),m=s;for(let g of l)m._mounts.has(g)||m.mount(g,new e(g)),m=m._mounts.get(g)}let i=o?Object.entries(o).map(([f,l])=>({re:fe(f),factory:l})):[],a=f=>{for(let l of i)if(l.re.test(f))return l.factory},c=f=>{let l=f.split($),m=l.pop();if(m==null||m.length===0)throw new Error(`invalid snapshot path "${f}"`);let g=s;for(let x of l){let y=g._mounts.get(x);if(!y)throw new Error(`unknown mount "${x}" in path "${f}"`);g=y}return[g,m]},u=Object.entries(t.nodes).filter(([f])=>!f.includes(`${$}${B}${$}`)).sort((f,l)=>f[0]<l[0]?-1:f[0]>l[0]?1:0),d=new Map(u),h=new Map,p=!0;for(;d.size>0&&p;){p=!1;for(let[f,l]of[...d.entries()]){let m=l?.deps??[];if(!m.every(O=>h.has(O)))continue;let[g,x]=c(f),y={...l?.meta??{}},b=a(f),v;if(l?.type==="state")v=ee(l.value,{meta:y});else{if(b==null)continue;v=b(x,{path:f,type:l.type,value:l.value,meta:y,deps:m,resolvedDeps:m.map(O=>h.get(O))})}g.add(v,{name:x}),h.set(f,v),d.delete(f),p=!0}}if(d.size>0){let f=[...d.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 s.restore(t),s}toJSON(){return this.snapshot()}attachSnapshotStorage(t,n={}){let r=t.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));n.autoRestore===!0&&this._cascadeRestore(t,n.onError);let o=(u,d)=>{if(u.disposed)return;let h=Kt(d.nodes);if(u.lastSnapshot!=null&&h!==""&&h===u.lastFingerprint)return;let p=u.seq+1,f=Be(),g=u.lastSnapshot==null||p%u.compactEvery===0?{name:this.name,mode:"full",snapshot:d,seq:p,timestamp_ns:f,format_version:U}:{name:this.name,mode:"diff",diff:cn(u.lastSnapshot,d),seq:p,timestamp_ns:f,format_version:U};if(u.tier.filter&&!u.tier.filter(g))return;let x;try{x=u.tier.save(g)}catch(y){n.onError?.(y,u.tier);return}if(x&&typeof x.then=="function"){let v=(u.savePending??Promise.resolve()).then(()=>x,()=>x).then(()=>{u.disposed||(u.seq=p,u.lastSnapshot=d,u.lastFingerprint=h)},O=>{n.onError?.(O,u.tier)});u.savePending=v.finally(()=>{u.savePending===v&&(u.savePending=void 0)})}else u.seq=p,u.lastSnapshot=d,u.lastFingerprint=h},s=(u,d)=>{try{o(u,d)}catch(h){n.onError?.(h,u.tier)}},i=(u,d)=>{if(!d.some(l=>{let m=this.config.messageTier(l[0]);return m>=3&&m<5}))return;if(n.filter){let l=this.tryResolve(u);if(l==null)return;let m=De(l,se("standard"));if(!n.filter(u,m))return}let p,f=()=>(p==null&&(p=this.snapshot()),p);for(let l of r)l.disposed||(l.debounceMs===0?s(l,f()):(l.timer==null&&(l.timer=new Fe),l.timer.start(l.debounceMs,()=>{l.disposed||s(l,this.snapshot())})))},a;if(n.paths!=null){let d=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(h=>{let p=this.tryResolve(h);return p==null?()=>{}:p.subscribe(f=>i(h,f))});a=()=>{for(let h of d)h()}}else a=this.observe().subscribe((u,d)=>i(u,d));let c=()=>{a();for(let u of r)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(c)};return this._storageDisposers.add(c),{dispose:c}}async _cascadeRestore(t,n){for(let r of t){let o;try{o=await r.load?.()}catch(i){n?.(i,r);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let s=o;try{if(s.mode==="full"&&s.snapshot!=null)return this.restore(s.snapshot),!0;if(s.version===U&&s.nodes!=null)return this.restore(s),!0}catch(i){n?.(i,r)}}return!1}static async fromStorage(t,n,r){for(let o of n){let s;try{s=await o.load?.()}catch(c){r?.onError?.(c,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let i=s,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===U&&i.nodes!=null?i:void 0;if(a!=null)try{return e.fromSnapshot(a,r)}catch(c){r?.onError?.(c,o)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${t}" across ${n.length} tier(s)`)}_annotations=new Map;_traceRing;trace(t,n,r){if(t!=null&&n!=null){if(this.tryResolve(t)==null)return;if(this._annotations.set(t,n),this.config.inspectorEnabled){let o={path:t,annotation:n,timestamp_ns:H(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(o)}return}return t!=null?this.config.inspectorEnabled?this._annotations.get(t):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(t){return this._annotations.get(t)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(t){let n=this._traceRing.toArray().filter(o=>!t(o)),r=this._traceRing.size-n.length;this._traceRing.clear();for(let o of n)this._traceRing.push(o);return r}static diff(t,n){let r=new Set(Object.keys(t.nodes)),o=new Set(Object.keys(n.nodes)),s=[...o].filter(y=>!r.has(y)).sort(),i=[...r].filter(y=>!o.has(y)).sort(),a=[],c=[];for(let y of r){if(!o.has(y))continue;let b=t.nodes[y],v=n.nodes[y],O=b.v,w=v.v;O!=null&&w!=null&&O.id===w.id&&O.version!==w.version&&c.push({path:y,id:O.id,from:O.version,to:w.version});let _=O!=null&&w!=null&&O.id===w.id&&O.version===w.version;for(let D of["type","status","sentinel"]){let S=b[D],C=v[D];S!==C&&a.push({path:y,field:D,from:S,to:C})}if(!_)for(let D of["value","meta"]){let S=b[D],C=v[D];Wt(S,C)||a.push({path:y,field:D,from:S,to:C})}}let u=y=>`${y.from} ${y.to}`,d=new Set(t.edges.map(u)),h=new Set(n.edges.map(u)),p=n.edges.filter(y=>!d.has(u(y))),f=t.edges.filter(y=>!h.has(u(y))),l=new Set(t.subgraphs),m=new Set(n.subgraphs),g=[...m].filter(y=>!l.has(y)).sort(),x=[...l].filter(y=>!m.has(y)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:c,edgesAdded:p,edgesRemoved:f,subgraphsAdded:g,subgraphsRemoved:x}}};function cn(e,t){let n=Ne.diff(e,t),r={};for(let o of n.nodesAdded){let s=t.nodes[o];s!=null&&(r[o]=s)}return{...n,nodesAddedFull:r}}function ct(e,t,n,r={}){let o={paths:[],depths:new Map,truncated:!1};if(!t)return r.withDetail?o:[];if(!r.both&&n!=="upstream"&&n!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let s=r.maxDepth;if(s!=null&&(!Number.isInteger(s)||s<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(s===0)return r.withDetail?o:[];let i=new Map,a=new Map,c=new Map,u=new Map,d=new Set;for(let[b,v]of Object.entries(e.nodes)){if(!b)continue;d.add(b);let O=v.deps??[];i.set(b,O);for(let w of O)w&&(d.add(w),a.has(w)||a.set(w,new Set),a.get(w).add(b))}for(let b of e.edges){if(b==null||typeof b!="object")continue;let v=typeof b.from=="string"?b.from:"",O=typeof b.to=="string"?b.to:"";!v||!O||(d.add(v),d.add(O),u.has(v)||u.set(v,new Set),u.get(v).add(O),c.has(O)||c.set(O,new Set),c.get(O).add(v))}if(!d.has(t))return r.withDetail?o:[];let h=r.both===!0,p=b=>{if(h){let _=i.get(b)??[],D=c.get(b),S=a.get(b),C=u.get(b),A=[..._];return D&&A.push(...D),S&&A.push(...S),C&&A.push(...C),A}if(n==="upstream"){let _=i.get(b)??[],D=c.get(b);return D?[..._,...D]:_}let v=a.get(b),O=u.get(b),w=v?[...v]:[];return O&&w.push(...O),w},f=new Set([t]),l=new Map,m=[{path:t,depth:0}],g=0,x=!1;for(;g<m.length;){let b=m[g++];if(s!=null&&b.depth>=s){p(b.path).length>0&&(x=!0);continue}for(let v of p(b.path))!v||f.has(v)||(f.add(v),l.set(v,b.depth+1),m.push({path:v,depth:b.depth+1}))}let y=[...l.keys()].sort((b,v)=>b<v?-1:b>v?1:0);return r.withDetail?{paths:y,depths:l,truncated:x}:y}function ln(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],o=t[n];if(r.path!==o.path||r.type!==o.type||r.status!==o.status||r.hop!==o.hop||r.dep_index!==o.dep_index||r.annotation!==o.annotation||r.value!==o.value||r.lastMutation!==o.lastMutation)return!1;let s=r.v,i=o.v;if(s!==i&&(s==null||i==null||s.id!==i.id||s.version!==i.version))return!1}return!0}export{Ge as a,ce as b,Ve as c,M as d,yt as e,qe as f,Ue as g,B as h,U as i,Zt as j,Ne as k,cn as l,ct as m};
@@ -0,0 +1 @@
1
+ import{a as z,d as _}from"./chunk-NN3QPJ6U.js";import{c as $}from"./chunk-O32GJOUJ.js";import{k as F}from"./chunk-QMC2PLNM.js";import{b as L}from"./chunk-DQJLC6YY.js";import{D as j,E as A,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 $("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)),u=D(a,i,{name:t,describeKind:"derived",meta:N("task",e.meta)});return this.add(u,{name:t}),u}classify(t,i,e,a={}){let u=this._resolveStep(i),c=D([u],([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),u=a.map(d=>this._resolveStep(i[d])),c=D(u,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}gate(t,i,e={}){let a=e.maxPending??1e3;if(a<1&&a!==Number.POSITIVE_INFINITY)throw new RangeError("gate: maxPending must be >= 1");let u=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=A([],{name:"pending",equals:()=>!1}),s=A(u,{name:"isOpen"}),R=D([f],([n])=>n.length,{name:"count"}),T=A(0,{name:"droppedCount"}),p=z({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=u,M=s.subscribe(n=>{for(let o of n)o[0]===P&&(w=o[1])});this.addDisposer(M);function G(){f.emit([...l])}function C(n,o,r){p.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])}G()}function O(n){let o=l.splice(0,n);return G(),o}let b=j([c],(n,o,r)=>{let h=r.terminalDeps[0];if(h!==void 0){v=!0;let g=l.length;l=[],G(),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("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(`gate: ${n}() called after 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:p,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:p,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:p,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:p,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:p,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:p,audit:p,approve:Z,reject:ee,modify:ne,open:re,close:oe}}approval(t,i,e,a={}){return this.gate(t,i,{...a,approver:e,maxPending:1})}catch(t,i,e,a={}){let u=this._resolveStep(i),c=a.on??"error",d=j([u],(f,s,R)=>{let T=R.terminalDeps[0];if(T!==void 0){let l=T===!0?{kind:"complete"}:{kind:"error",error:T};if(c==="terminal"||c===l.kind){s.emit(e(l,s));return}s.down(l.kind==="complete"?[[I]]:[[K,l.error]]);return}let p=f[0];if(p==null||p.length===0){s.down([[S]]);return}for(let l of p)s.emit(l)},{name:t,describeKind:"derived",completeWhenDepsComplete:a.completeWhenDepsComplete??!(c==="complete"||c==="terminal"),errorWhenDepsError:!(c==="error"||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,...u}=t??{};return i.tagFactory("pipelineGraph",L(u)),i}export{q as a,x as b,W as c,se as d};
@@ -1 +1 @@
1
- import{D as w,E as I,F as b,p as C}from"./chunk-LYCLF26R.js";import{a as S,b as h,c as A,d as x,i as T,j as p}from"./chunk-CK2E7BTU.js";function y(e,n,t){let u=new Set;for(let o of e.split(",")){let[r,i]=o.split("/"),s=i?Number.parseInt(i,10):1;if(Number.isNaN(s)||s<1)throw new Error(`Invalid cron step: ${o}`);let a,d;if(r==="*")a=n,d=t;else if(r.includes("-")){let[f,c]=r.split("-");a=Number.parseInt(f,10),d=Number.parseInt(c,10)}else a=Number.parseInt(r,10),d=a;if(Number.isNaN(a)||Number.isNaN(d))throw new Error(`Invalid cron field: ${e}`);if(a<n||d>t)throw new Error(`Cron field out of range: ${e} (${n}-${t})`);if(a>d)throw new Error(`Invalid cron range: ${a}-${d} in ${e}`);for(let f=a;f<=d;f+=s)u.add(f)}return u}function L(e){let n=e.trim().split(/\s+/);if(n.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${n.length}`);return{minutes:y(n[0],0,59),hours:y(n[1],0,23),daysOfMonth:y(n[2],1,31),months:y(n[3],1,12),daysOfWeek:y(n[4],0,6)}}function P(e,n){return e.minutes.has(n.getMinutes())&&e.hours.has(n.getHours())&&e.daysOfMonth.has(n.getDate())&&e.months.has(n.getMonth()+1)&&e.daysOfWeek.has(n.getDay())}function m(e){return{describeKind:"producer",...e}}function $(e){return/[\\^$+?.()|[\]{}]/.test(e)?`\\${e}`:e}function X(e){let n="^";for(let t=0;t<e.length;t+=1){let u=e[t];if(u==="*"){e[t+1]==="*"?(n+=".*",t+=1):n+="[^/]*";continue}n+=$(u)}return n+="$",new RegExp(n)}function Z(e,n){for(let t of n)if(t.test(e))return!0;return!1}function K(e,n){let t=w([e],(o,r)=>{let i=o[0];if(i==null||i.length===0){r.down([[x]]);return}for(let s of i)r.emit(s)},{describeKind:"derived",initial:e.cache}),u=t.subscribe.bind(t);return t.subscribe=(o,r)=>(n(o),u(o,r)),t}function ee(e,n){let{signal:t,period:u,...o}=n??{};return b(r=>{let i=!1,s=0,a,d,f=()=>{i=!0,a!==void 0&&clearTimeout(a),d!==void 0&&clearInterval(d),t?.removeEventListener("abort",l)},c=()=>{i||(u!=null?(r.emit(s++),d=setInterval(()=>{i||r.emit(s++)},u)):(i=!0,t?.removeEventListener("abort",l),r.emit(s++),r.down([[T]])))},l=()=>{i||(f(),r.down([[p,t.reason]]))};if(t?.aborted){l();return}return a=setTimeout(c,e),t?.addEventListener("abort",l,{once:!0}),f},m(o))}function ne(e){let{signal:n,...t}=e??{};return b(u=>{let o=!1,r,i,s=!1,a=!1,d=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,f=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,c=typeof document<"u"?document:void 0,l=()=>{r!==void 0&&f&&f(r),i!==void 0&&clearTimeout(i),r=void 0,i=void 0},v=()=>{o=!0,l(),s&&(n?.removeEventListener("abort",N),s=!1),a&&c&&(c.removeEventListener("visibilitychange",k),a=!1)},N=()=>{o||(v(),u.down([[p,n.reason]]))},O=_=>{o||(u.emit(_),g())},g=()=>{o||(d&&(!c||c.visibilityState!=="hidden")?r=d(O):i=setTimeout(()=>O(performance.now()),16))},k=()=>{o||(l(),g())};return n?.aborted?(N(),v):(n?.addEventListener("abort",N,{once:!0}),s=n!==void 0,c&&d&&(c.addEventListener("visibilitychange",k),a=!0),g(),v)},m(t))}function te(e,n){let t=L(e),{tickMs:u,output:o,...r}=n??{},i=u??6e4,s=o==="date";return b(a=>{let d=-1,f=()=>{let l=new Date,v=l.getFullYear()*1e8+(l.getMonth()+1)*1e6+l.getDate()*1e4+l.getHours()*100+l.getMinutes();v!==d&&P(t,l)&&(d=v,a.emit(s?l:C()))};f();let c=setInterval(f,i);return()=>clearInterval(c)},{...m(r),name:r.name??`cron:${e}`})}function re(e,n,t){let{capture:u,passive:o,once:r,...i}=t??{};return b(s=>{let a=f=>{s.emit(f)},d={capture:u,passive:o,once:r};return e.addEventListener(n,a,d),()=>e.removeEventListener(n,a,d)},m(i))}function D(e,n){return b(t=>{let u=!1;try{for(let o of e){if(u)return;t.emit(o)}u||t.down([[T]])}catch(o){u||t.down([[p,o]])}return()=>{u=!0}},m(n))}function W(e){return e!=null&&typeof e.then=="function"}function q(e,n){let{signal:t,...u}=n??{};return b(o=>{let r=!1,i=()=>{r||(r=!0,o.down([[p,t.reason]]))};if(t?.aborted){i();return}return t?.addEventListener("abort",i,{once:!0}),Promise.resolve(e).then(s=>{r||(r=!0,t?.removeEventListener("abort",i),o.emit(s),o.down([[T]]))},s=>{r||(r=!0,t?.removeEventListener("abort",i),o.down([[p,s]]))}),()=>{r=!0,t?.removeEventListener("abort",i)}},m(u))}function H(e,n){let{signal:t,...u}=n??{};return b(o=>{let r=new AbortController,i=()=>r.abort(t?.reason);t?.aborted?r.abort(t.reason):t?.addEventListener("abort",i,{once:!0});let s=t??r.signal,a=!1,d=e[Symbol.asyncIterator](),f=()=>{a||s.aborted||Promise.resolve(d.next()).then(c=>{if(!(a||s.aborted)){if(c.done){o.down([[T]]);return}o.emit(c.value),f()}},c=>{!a&&!s.aborted&&o.down([[p,c]])})};return f(),()=>{a=!0,t?.removeEventListener("abort",i),r.abort(),Promise.resolve(d.return?.()).catch(()=>{})}},m(u))}function U(e){return e!=null&&typeof e=="object"&&"cache"in e&&typeof e.subscribe=="function"}function V(e,n){if(U(e))return e;if(W(e))return q(e,n);if(e!=null){let t=e;if(typeof t[Symbol.asyncIterator]=="function")return H(e,n);if(typeof t[Symbol.iterator]=="function")return D(e,n)}return B(e)}function B(...e){return D(e,void 0)}function oe(e){return b(n=>{n.down([[T]])},m(e))}function ie(e){return b(()=>{},m(e))}function se(e,n){return b(t=>{t.down([[p,e]])},m(n))}function ue(e,n){let{signal:t,...u}=n??{},o=m(u),r=o.resubscribable===void 0?{...o,resubscribable:!0}:o;return b(i=>{let s,a=!1;try{let d=e();s=V(d,n).subscribe(c=>{if(!a)for(let l of c){let v=l[0];if(v!==S)if(v===h)i.emit(l[1]);else if(v===T){a=!0,i.down([[T]]);break}else if(v===p){a=!0,i.down([[p,l[1]]]);break}else i.down([l])}})}catch(d){let f=d===void 0?new Error("defer: thunk threw undefined"):d;i.down([[p,f]])}return()=>{a=!0,s?.()}},r)}function ae(e,n,t){return w([e],(o,r)=>{let i=o[0];if(i!=null&&i.length>0)for(let s of i)n(s)},{describeKind:"effect",...t}).subscribe(()=>{})}function de(e,n){return w([e],(t,u,o)=>{o.store.buf||(o.store.buf=[]);let r=o.store.buf,i=t[0];if(i!=null&&i.length>0)for(let s of i)r.push(s);if(o.terminalDeps[0]===!0){u.emit([...r]),u.down([[T]]);return}(i==null||i.length===0)&&u.down([[x]])},{describeKind:"derived",completeWhenDepsComplete:!1,...n})}function fe(e,n){return b(t=>e.subscribe(u=>{t.down(u)}),{...m(n),initial:e.cache})}function F(e,n,t){if(n<1)throw new RangeError("replay expects bufferSize >= 1");let u=[],o=b(r=>e.subscribe(i=>{for(let s of i)s[0]===h&&(u.push(s[1]),u.length>n&&u.shift());r.down(i)}),{...m(t),initial:e.cache});return K(o,r=>{for(let i of u)r([[h,i]])})}function ce(e,n){return F(e,1,n)}function le(e){return new Promise((n,t)=>{let u=!1,o=!1,r;r=e.subscribe(i=>{for(let s of i){if(u)return;if(s[0]===h){u=!0,n(s[1]),r?(r(),r=void 0):o=!0;return}if(s[0]===p){u=!0,t(s[1]),r?(r(),r=void 0):o=!0;return}if(s[0]===T){u=!0,t(new Error("completed without DATA")),r?(r(),r=void 0):o=!0;return}}}),o&&(r?.(),r=void 0)})}function R(e,n,t){return new Promise((u,o)=>{let r=!1,i=!1,s,a=t?.skipCurrent===!0;s=e.subscribe(d=>{for(let f of d){if(r)return;if(!(a&&f[0]===h)){if(f[0]===h){let c=f[1];if(n(c)){r=!0,u(c),s?(s(),s=void 0):i=!0;return}}if(f[0]===p){r=!0,o(f[1]),s?(s(),s=void 0):i=!0;return}if(f[0]===T){r=!0,o(new Error("completed without matching value")),s?(s(),s=void 0):i=!0;return}}}}),a=!1,i&&(s?.(),s=void 0)})}var E,M;async function pe(e,n){let t=n?.predicate??(r=>r!=null),u=n?.skipCurrent;if(n?.timeoutMs==null||n.timeoutMs<=0)return await R(e,t,{skipCurrent:u});if(E===void 0){let[r,i]=await Promise.all([import("./resilience-OBU472D2.js"),import("./backoff-HPZMEZNF.js")]);E=r.timeout,M=i.NS_PER_MS}let o=E(e,n.timeoutMs*M);return await R(o,t,{skipCurrent:u})}function be(e,n){let t=new AbortController,u=n?.reason??new Error("cancelled via nodeSignal"),o,r=!1,i=()=>{o?(o(),o=void 0):r=!0};return o=e.subscribe(s=>{if(!t.signal.aborted)for(let a of s){if(a[0]===h&&a[1]===!0){t.abort(u),i();return}if(a[0]===p){t.abort(a[1]),i();return}if(a[0]===T){i();return}}}),r&&(o?.(),o=void 0),{signal:t.signal,dispose:()=>{o&&(o(),o=void 0)}}}var me=F;function Te(e){return e.subscribe(()=>{})}function ve(e){let n=I(0);return{node:n,increment(){let t=n.cache??0;return t>=e?!1:(n.down([[A],[h,t+1]]),!0)},get(){return n.cache??0},atCap(){return(n.cache??0)>=e}}}export{L as a,P as b,$ as c,X as d,Z as e,ee as f,ne as g,te as h,re as i,D as j,q as k,H as l,V as m,B as n,oe as o,ie as p,se as q,ue as r,ae as s,de as t,fe as u,F as v,ce as w,le as x,R as y,pe as z,be as A,me as B,Te as C,ve as D};
1
+ import{D as w,E as I,F as b,p as C}from"./chunk-LYCLF26R.js";import{a as S,b as h,c as A,d as x,i as T,j as p}from"./chunk-CK2E7BTU.js";function y(e,n,t){let u=new Set;for(let o of e.split(",")){let[r,i]=o.split("/"),s=i?Number.parseInt(i,10):1;if(Number.isNaN(s)||s<1)throw new Error(`Invalid cron step: ${o}`);let a,d;if(r==="*")a=n,d=t;else if(r.includes("-")){let[f,c]=r.split("-");a=Number.parseInt(f,10),d=Number.parseInt(c,10)}else a=Number.parseInt(r,10),d=a;if(Number.isNaN(a)||Number.isNaN(d))throw new Error(`Invalid cron field: ${e}`);if(a<n||d>t)throw new Error(`Cron field out of range: ${e} (${n}-${t})`);if(a>d)throw new Error(`Invalid cron range: ${a}-${d} in ${e}`);for(let f=a;f<=d;f+=s)u.add(f)}return u}function L(e){let n=e.trim().split(/\s+/);if(n.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${n.length}`);return{minutes:y(n[0],0,59),hours:y(n[1],0,23),daysOfMonth:y(n[2],1,31),months:y(n[3],1,12),daysOfWeek:y(n[4],0,6)}}function P(e,n){return e.minutes.has(n.getMinutes())&&e.hours.has(n.getHours())&&e.daysOfMonth.has(n.getDate())&&e.months.has(n.getMonth()+1)&&e.daysOfWeek.has(n.getDay())}function m(e){return{describeKind:"producer",...e}}function $(e){return/[\\^$+?.()|[\]{}]/.test(e)?`\\${e}`:e}function X(e){let n="^";for(let t=0;t<e.length;t+=1){let u=e[t];if(u==="*"){e[t+1]==="*"?(n+=".*",t+=1):n+="[^/]*";continue}n+=$(u)}return n+="$",new RegExp(n)}function Z(e,n){for(let t of n)if(t.test(e))return!0;return!1}function K(e,n){let t=w([e],(o,r)=>{let i=o[0];if(i==null||i.length===0){r.down([[x]]);return}for(let s of i)r.emit(s)},{describeKind:"derived",initial:e.cache}),u=t.subscribe.bind(t);return t.subscribe=(o,r)=>(n(o),u(o,r)),t}function ee(e,n){let{signal:t,period:u,...o}=n??{};return b(r=>{let i=!1,s=0,a,d,f=()=>{i=!0,a!==void 0&&clearTimeout(a),d!==void 0&&clearInterval(d),t?.removeEventListener("abort",l)},c=()=>{i||(u!=null?(r.emit(s++),d=setInterval(()=>{i||r.emit(s++)},u)):(i=!0,t?.removeEventListener("abort",l),r.emit(s++),r.down([[T]])))},l=()=>{i||(f(),r.down([[p,t.reason]]))};if(t?.aborted){l();return}return a=setTimeout(c,e),t?.addEventListener("abort",l,{once:!0}),f},m(o))}function ne(e){let{signal:n,...t}=e??{};return b(u=>{let o=!1,r,i,s=!1,a=!1,d=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,f=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,c=typeof document<"u"?document:void 0,l=()=>{r!==void 0&&f&&f(r),i!==void 0&&clearTimeout(i),r=void 0,i=void 0},v=()=>{o=!0,l(),s&&(n?.removeEventListener("abort",N),s=!1),a&&c&&(c.removeEventListener("visibilitychange",k),a=!1)},N=()=>{o||(v(),u.down([[p,n.reason]]))},O=_=>{o||(u.emit(_),g())},g=()=>{o||(d&&(!c||c.visibilityState!=="hidden")?r=d(O):i=setTimeout(()=>O(performance.now()),16))},k=()=>{o||(l(),g())};return n?.aborted?(N(),v):(n?.addEventListener("abort",N,{once:!0}),s=n!==void 0,c&&d&&(c.addEventListener("visibilitychange",k),a=!0),g(),v)},m(t))}function te(e,n){let t=L(e),{tickMs:u,output:o,...r}=n??{},i=u??6e4,s=o==="date";return b(a=>{let d=-1,f=()=>{let l=new Date,v=l.getFullYear()*1e8+(l.getMonth()+1)*1e6+l.getDate()*1e4+l.getHours()*100+l.getMinutes();v!==d&&P(t,l)&&(d=v,a.emit(s?l:C()))};f();let c=setInterval(f,i);return()=>clearInterval(c)},{...m(r),name:r.name??`cron:${e}`})}function re(e,n,t){let{capture:u,passive:o,once:r,...i}=t??{};return b(s=>{let a=f=>{s.emit(f)},d={capture:u,passive:o,once:r};return e.addEventListener(n,a,d),()=>e.removeEventListener(n,a,d)},m(i))}function D(e,n){return b(t=>{let u=!1;try{for(let o of e){if(u)return;t.emit(o)}u||t.down([[T]])}catch(o){u||t.down([[p,o]])}return()=>{u=!0}},m(n))}function W(e){return e!=null&&typeof e.then=="function"}function q(e,n){let{signal:t,...u}=n??{};return b(o=>{let r=!1,i=()=>{r||(r=!0,o.down([[p,t.reason]]))};if(t?.aborted){i();return}return t?.addEventListener("abort",i,{once:!0}),Promise.resolve(e).then(s=>{r||(r=!0,t?.removeEventListener("abort",i),o.emit(s),o.down([[T]]))},s=>{r||(r=!0,t?.removeEventListener("abort",i),o.down([[p,s]]))}),()=>{r=!0,t?.removeEventListener("abort",i)}},m(u))}function H(e,n){let{signal:t,...u}=n??{};return b(o=>{let r=new AbortController,i=()=>r.abort(t?.reason);t?.aborted?r.abort(t.reason):t?.addEventListener("abort",i,{once:!0});let s=t??r.signal,a=!1,d=e[Symbol.asyncIterator](),f=()=>{a||s.aborted||Promise.resolve(d.next()).then(c=>{if(!(a||s.aborted)){if(c.done){o.down([[T]]);return}o.emit(c.value),f()}},c=>{!a&&!s.aborted&&o.down([[p,c]])})};return f(),()=>{a=!0,t?.removeEventListener("abort",i),r.abort(),Promise.resolve(d.return?.()).catch(()=>{})}},m(u))}function U(e){return e!=null&&typeof e=="object"&&"cache"in e&&typeof e.subscribe=="function"}function V(e,n){if(U(e))return e;if(W(e))return q(e,n);if(e!=null){let t=e;if(typeof t[Symbol.asyncIterator]=="function")return H(e,n);if(typeof t[Symbol.iterator]=="function")return D(e,n)}return B(e)}function B(...e){return D(e,void 0)}function oe(e){return b(n=>{n.down([[T]])},m(e))}function ie(e){return b(()=>{},m(e))}function se(e,n){return b(t=>{t.down([[p,e]])},m(n))}function ue(e,n){let{signal:t,...u}=n??{},o=m(u),r=o.resubscribable===void 0?{...o,resubscribable:!0}:o;return b(i=>{let s,a=!1;try{let d=e();s=V(d,n).subscribe(c=>{if(!a)for(let l of c){let v=l[0];if(v!==S)if(v===h)i.emit(l[1]);else if(v===T){a=!0,i.down([[T]]);break}else if(v===p){a=!0,i.down([[p,l[1]]]);break}else i.down([l])}})}catch(d){let f=d===void 0?new Error("defer: thunk threw undefined"):d;i.down([[p,f]])}return()=>{a=!0,s?.()}},r)}function ae(e,n,t){return w([e],(o,r)=>{let i=o[0];if(i!=null&&i.length>0)for(let s of i)n(s)},{describeKind:"effect",...t}).subscribe(()=>{})}function de(e,n){return w([e],(t,u,o)=>{o.store.buf||(o.store.buf=[]);let r=o.store.buf,i=t[0];if(i!=null&&i.length>0)for(let s of i)r.push(s);if(o.terminalDeps[0]===!0){u.emit([...r]),u.down([[T]]);return}(i==null||i.length===0)&&u.down([[x]])},{describeKind:"derived",completeWhenDepsComplete:!1,...n})}function fe(e,n){return b(t=>e.subscribe(u=>{t.down(u)}),{...m(n),initial:e.cache})}function F(e,n,t){if(n<1)throw new RangeError("replay expects bufferSize >= 1");let u=[],o=b(r=>e.subscribe(i=>{for(let s of i)s[0]===h&&(u.push(s[1]),u.length>n&&u.shift());r.down(i)}),{...m(t),initial:e.cache});return K(o,r=>{for(let i of u)r([[h,i]])})}function ce(e,n){return F(e,1,n)}function le(e){return new Promise((n,t)=>{let u=!1,o=!1,r;r=e.subscribe(i=>{for(let s of i){if(u)return;if(s[0]===h){u=!0,n(s[1]),r?(r(),r=void 0):o=!0;return}if(s[0]===p){u=!0,t(s[1]),r?(r(),r=void 0):o=!0;return}if(s[0]===T){u=!0,t(new Error("completed without DATA")),r?(r(),r=void 0):o=!0;return}}}),o&&(r?.(),r=void 0)})}function R(e,n,t){return new Promise((u,o)=>{let r=!1,i=!1,s,a=t?.skipCurrent===!0;s=e.subscribe(d=>{for(let f of d){if(r)return;if(!(a&&f[0]===h)){if(f[0]===h){let c=f[1];if(n(c)){r=!0,u(c),s?(s(),s=void 0):i=!0;return}}if(f[0]===p){r=!0,o(f[1]),s?(s(),s=void 0):i=!0;return}if(f[0]===T){r=!0,o(new Error("completed without matching value")),s?(s(),s=void 0):i=!0;return}}}}),a=!1,i&&(s?.(),s=void 0)})}var E,M;async function pe(e,n){let t=n?.predicate??(r=>r!=null),u=n?.skipCurrent;if(n?.timeoutMs==null||n.timeoutMs<=0)return await R(e,t,{skipCurrent:u});if(E===void 0){let[r,i]=await Promise.all([import("./resilience-LGBK236C.js"),import("./backoff-HPZMEZNF.js")]);E=r.timeout,M=i.NS_PER_MS}let o=E(e,n.timeoutMs*M);return await R(o,t,{skipCurrent:u})}function be(e,n){let t=new AbortController,u=n?.reason??new Error("cancelled via nodeSignal"),o,r=!1,i=()=>{o?(o(),o=void 0):r=!0};return o=e.subscribe(s=>{if(!t.signal.aborted)for(let a of s){if(a[0]===h&&a[1]===!0){t.abort(u),i();return}if(a[0]===p){t.abort(a[1]),i();return}if(a[0]===T){i();return}}}),r&&(o?.(),o=void 0),{signal:t.signal,dispose:()=>{o&&(o(),o=void 0)}}}var me=F;function Te(e){return e.subscribe(()=>{})}function ve(e){let n=I(0);return{node:n,increment(){let t=n.cache??0;return t>=e?!1:(n.down([[A],[h,t+1]]),!0)},get(){return n.cache??0},atCap(){return(n.cache??0)>=e}}}export{L as a,P as b,$ as c,X as d,Z as e,ee as f,ne as g,te as h,re as i,D as j,q as k,H as l,V as m,B as n,oe as o,ie as p,se as q,ue as r,ae as s,de as t,fe as u,F as v,ce as w,le as x,R as y,pe as z,be as A,me as B,Te as C,ve as D};
@@ -1 +1 @@
1
- import{a as H,b as T}from"./chunk-QP5TH523.js";import{j as q}from"./chunk-B4L5X2QO.js";import{a as O,b as j}from"./chunk-533RQFF6.js";import{E as d,G as o,H as x,m as A}from"./chunk-LYCLF26R.js";import{b as ae}from"./chunk-QYADASLV.js";var ie={};ae(ie,{demoShell:()=>re});function w(h){return Math.max(0,Math.min(1,h))}function re(h){let B=w(h?.mainRatio??.65),E=w(h?.sideSplit??.5),J=Math.max(0,h?.viewportWidth??1280),k=h?.nodeRegistry??new Map,p=h?.adapter??null,S=h?.layoutFont??"14px monospace",u=h?.onHighlight,t=new q("demo-shell"),F=d(B,{name:"pane/main-ratio"}),D=d(E,{name:"pane/side-split"}),g=d(null,{name:"pane/fullscreen"}),G=d(J,{name:"viewport/width"});t.add(F,{name:"pane/main-ratio"}),t.add(D,{name:"pane/side-split"}),t.add(g,{name:"pane/fullscreen"}),t.add(G,{name:"viewport/width"});let L=o([F,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"}),R=o([L,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"}),C=o([D,g],([e,a])=>{let n=a;return n==="graph"?1:n==="code"||n==="main"?0:w(e)},{name:"pane/graph-height-ratio"}),K=o([C,g],([e,a])=>{let n=a;return n==="code"?1:n==="graph"||n==="main"?0:1-e},{name:"pane/code-height-ratio"});t.add(L,{name:"pane/main-width"}),t.add(R,{name:"pane/side-width"}),t.add(C,{name:"pane/graph-height-ratio"}),t.add(K,{name:"pane/code-height-ratio"});let b=d(null,{name:"demo/graph-ref"}),m=d(0,{name:"demo/graph-tick"});t.add(b,{name:"demo/graph-ref"}),t.add(m,{name:"demo/graph-tick"});let Q=o([b,m],([e,a])=>{let n=e;return n?n.describe({format:"mermaid"}):""},{name:"graph/mermaid"}),z=o([b,m],([e,a])=>{let n=e;if(!n)return null;let{expand:l,...r}=n.describe({detail:"standard"});return r},{name:"graph/describe"});t.add(Q,{name:"graph/mermaid"}),t.add(z,{name:"graph/describe"});let M=d(null,{name:"hover/target"});t.add(M,{name:"hover/target"});let P=o([M],([e])=>{let a=e;if(!a)return null;let n=k.get(a.id);return n?n.codeLine:null},{name:"highlight/code-scroll"}),W=o([M],([e])=>{let a=e;if(!a)return null;let n=k.get(a.id);return n?n.visualSelector:null},{name:"highlight/visual"}),N=o([M],([e])=>{let a=e;return a?a.id:null},{name:"highlight/graph"});if(t.add(P,{name:"highlight/code-scroll"}),t.add(W,{name:"highlight/visual"}),t.add(N,{name:"highlight/graph"}),u?.codeScroll){let e=u.codeScroll,a=x([P],([n])=>{e(n)});t.add(a,{name:"highlight/apply-code-scroll"})}if(u?.visual){let e=u.visual,a=x([W],([n])=>{e(n)});t.add(a,{name:"highlight/apply-visual"})}if(u?.graph){let e=u.graph,a=x([N],([n])=>{e(n)});t.add(a,{name:"highlight/apply-graph"})}let _=d(null,{name:"inspect/selected-node"});t.add(_,{name:"inspect/selected-node"});let U=O("standard"),X=o([_,b,m],([e,a,n])=>{let l=a,r=e;if(!l||!r)return null;try{let i=l.resolve(r),s=j(i,U);return{path:r,...s,value:i.cache}}catch{return null}},{name:"inspect/node-detail"}),Y=o([b,m],([e,a])=>{let n=e;return n?n.trace():[]},{name:"inspect/trace-log"});t.add(X,{name:"inspect/node-detail"}),t.add(Y,{name:"inspect/trace-log"});let I=d(!1,{name:"meta/debug"});t.add(I,{name:"meta/debug"});let Z=o([I,m],([e,a])=>e?t.describe({format:"mermaid"}):"",{name:"meta/shell-mermaid"});t.add(Z,{name:"meta/shell-mermaid"});let V=d("",{name:"layout/code-text"});if(t.add(V,{name:"layout/code-text"}),p){let e=new Map,a=o([z],([r])=>{let i=r;if(!i)return new Map;let s=new Map;for(let[c]of Object.entries(i.nodes)){let f=H(c,S,p,e),v=T(f,1/0,p,S,e),y=v.lines.reduce((te,ne)=>Math.max(te,ne.width),0),ee=v.lineCount*20;s.set(c,{width:y,height:ee})}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([V,R],([r,i])=>{let s=r;if(!s)return{lineCount:0,lines:[]};let c=H(s,S,p,e),f=i-40;return T(c,Math.max(100,f),p,S,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 $=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",++$)},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){A(e)},destroy(){t.destroy()}}}export{re as a,ie as b};
1
+ import{a as H,b as T}from"./chunk-SP5O2MIX.js";import{k as q}from"./chunk-QMC2PLNM.js";import{a as O,d as j}from"./chunk-DQJLC6YY.js";import{E as d,G as o,H as x,m as A}from"./chunk-LYCLF26R.js";import{b as ae}from"./chunk-QYADASLV.js";var ie={};ae(ie,{demoShell:()=>re});function w(h){return Math.max(0,Math.min(1,h))}function re(h){let B=w(h?.mainRatio??.65),E=w(h?.sideSplit??.5),J=Math.max(0,h?.viewportWidth??1280),k=h?.nodeRegistry??new Map,p=h?.adapter??null,S=h?.layoutFont??"14px monospace",u=h?.onHighlight,t=new q("demo-shell"),F=d(B,{name:"pane/main-ratio"}),D=d(E,{name:"pane/side-split"}),g=d(null,{name:"pane/fullscreen"}),G=d(J,{name:"viewport/width"});t.add(F,{name:"pane/main-ratio"}),t.add(D,{name:"pane/side-split"}),t.add(g,{name:"pane/fullscreen"}),t.add(G,{name:"viewport/width"});let L=o([F,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"}),R=o([L,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"}),C=o([D,g],([e,a])=>{let n=a;return n==="graph"?1:n==="code"||n==="main"?0:w(e)},{name:"pane/graph-height-ratio"}),K=o([C,g],([e,a])=>{let n=a;return n==="code"?1:n==="graph"||n==="main"?0:1-e},{name:"pane/code-height-ratio"});t.add(L,{name:"pane/main-width"}),t.add(R,{name:"pane/side-width"}),t.add(C,{name:"pane/graph-height-ratio"}),t.add(K,{name:"pane/code-height-ratio"});let b=d(null,{name:"demo/graph-ref"}),m=d(0,{name:"demo/graph-tick"});t.add(b,{name:"demo/graph-ref"}),t.add(m,{name:"demo/graph-tick"});let Q=o([b,m],([e,a])=>{let n=e;return n?n.describe({format:"mermaid"}):""},{name:"graph/mermaid"}),z=o([b,m],([e,a])=>{let n=e;if(!n)return null;let{expand:l,...r}=n.describe({detail:"standard"});return r},{name:"graph/describe"});t.add(Q,{name:"graph/mermaid"}),t.add(z,{name:"graph/describe"});let M=d(null,{name:"hover/target"});t.add(M,{name:"hover/target"});let P=o([M],([e])=>{let a=e;if(!a)return null;let n=k.get(a.id);return n?n.codeLine:null},{name:"highlight/code-scroll"}),W=o([M],([e])=>{let a=e;if(!a)return null;let n=k.get(a.id);return n?n.visualSelector:null},{name:"highlight/visual"}),N=o([M],([e])=>{let a=e;return a?a.id:null},{name:"highlight/graph"});if(t.add(P,{name:"highlight/code-scroll"}),t.add(W,{name:"highlight/visual"}),t.add(N,{name:"highlight/graph"}),u?.codeScroll){let e=u.codeScroll,a=x([P],([n])=>{e(n)});t.add(a,{name:"highlight/apply-code-scroll"})}if(u?.visual){let e=u.visual,a=x([W],([n])=>{e(n)});t.add(a,{name:"highlight/apply-visual"})}if(u?.graph){let e=u.graph,a=x([N],([n])=>{e(n)});t.add(a,{name:"highlight/apply-graph"})}let _=d(null,{name:"inspect/selected-node"});t.add(_,{name:"inspect/selected-node"});let U=O("standard"),X=o([_,b,m],([e,a,n])=>{let l=a,r=e;if(!l||!r)return null;try{let i=l.resolve(r),s=j(i,U);return{path:r,...s,value:i.cache}}catch{return null}},{name:"inspect/node-detail"}),Y=o([b,m],([e,a])=>{let n=e;return n?n.trace():[]},{name:"inspect/trace-log"});t.add(X,{name:"inspect/node-detail"}),t.add(Y,{name:"inspect/trace-log"});let I=d(!1,{name:"meta/debug"});t.add(I,{name:"meta/debug"});let Z=o([I,m],([e,a])=>e?t.describe({format:"mermaid"}):"",{name:"meta/shell-mermaid"});t.add(Z,{name:"meta/shell-mermaid"});let V=d("",{name:"layout/code-text"});if(t.add(V,{name:"layout/code-text"}),p){let e=new Map,a=o([z],([r])=>{let i=r;if(!i)return new Map;let s=new Map;for(let[c]of Object.entries(i.nodes)){let f=H(c,S,p,e),v=T(f,1/0,p,S,e),y=v.lines.reduce((te,ne)=>Math.max(te,ne.width),0),ee=v.lineCount*20;s.set(c,{width:y,height:ee})}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([V,R],([r,i])=>{let s=r;if(!s)return{lineCount:0,lines:[]};let c=H(s,S,p,e),f=i-40;return T(c,Math.max(100,f),p,S,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 $=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",++$)},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){A(e)},destroy(){t.destroy()}}}export{re as a,ie as b};