@graphrefly/graphrefly 0.37.0 → 0.39.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.
- package/dist/budget-gate-CmmVtasH.d.ts +115 -0
- package/dist/budget-gate-DiP_nK0n.d.cts +115 -0
- package/dist/{cascading-BsJ4GbnS.d.ts → cascading-BzuxW0_w.d.cts} +2 -2
- package/dist/{cascading-B25wxpRa.d.cts → cascading-g2_rhhaM.d.ts} +2 -2
- package/dist/chunk-35JTVPOX.js +1 -0
- package/dist/chunk-3G5U5QNE.js +5 -0
- package/dist/chunk-4I45FVQS.js +1 -0
- package/dist/chunk-5LK7XMEV.js +1 -0
- package/dist/chunk-5XRI6RM3.js +1 -0
- package/dist/chunk-73PBQNST.js +1 -0
- package/dist/chunk-7JRF5YEK.js +3 -0
- package/dist/{chunk-YVYSO5CW.js → chunk-7NZMZJMW.js} +1 -1
- package/dist/chunk-7QFRK3N3.js +84 -0
- package/dist/{chunk-K6ZFJ473.js → chunk-7SD73DS6.js} +1 -1
- package/dist/{chunk-LOQRPP4Y.js → chunk-A6ZSKGUG.js} +1 -1
- package/dist/{chunk-KUVDFOJH.js → chunk-AU7YTQX7.js} +1 -1
- package/dist/chunk-C72GO4IZ.js +1 -0
- package/dist/{chunk-Q7EUZ6NN.js → chunk-CGDMTXSY.js} +1 -1
- package/dist/chunk-D27JNOLZ.js +1 -0
- package/dist/chunk-D47YVDR5.js +1 -0
- package/dist/chunk-EWF7KCDJ.js +61 -0
- package/dist/{chunk-PCD2MU7X.js → chunk-GEAO3TL3.js} +1 -1
- package/dist/chunk-GX5LSSRE.js +1 -0
- package/dist/{chunk-2C4NESZE.js → chunk-HAWKGIXM.js} +1 -1
- package/dist/chunk-HX3EGQ5Z.js +1 -0
- package/dist/{chunk-MQZWA3DF.js → chunk-IA7DUNGB.js} +1 -1
- package/dist/{chunk-MYFR67PY.js → chunk-INH6FS2G.js} +2 -2
- package/dist/chunk-INHC33EH.js +1 -0
- package/dist/chunk-IUB4NYI2.js +1 -0
- package/dist/{chunk-TFK4P4CX.js → chunk-JNMC2WJ6.js} +1 -1
- package/dist/{chunk-TLS7M7H4.js → chunk-KD4NHLMU.js} +1 -1
- package/dist/chunk-L6NSJVJZ.js +1 -0
- package/dist/chunk-L7WY6TZS.js +1 -0
- package/dist/chunk-LQNOXGET.js +1 -0
- package/dist/chunk-MC4UYY2X.js +1 -0
- package/dist/{chunk-U3COB5WU.js → chunk-N7UIBZCW.js} +1 -1
- package/dist/chunk-NQI2C36M.js +1 -0
- package/dist/chunk-R75BMDLA.js +1 -0
- package/dist/chunk-RF3QZP6D.js +1 -0
- package/dist/{chunk-MC5LZG3U.js → chunk-S2U57TFC.js} +1 -1
- package/dist/{chunk-QP5TH523.js → chunk-SC7BQDNP.js} +1 -1
- package/dist/{chunk-5CPPC75H.js → chunk-TFPZLQ5H.js} +1 -1
- package/dist/chunk-VJJLIEAL.js +1 -0
- package/dist/chunk-WHIZM6JV.js +1 -0
- package/dist/chunk-XEUANKBO.js +43 -0
- package/dist/chunk-XQ55HO5N.js +1 -0
- package/dist/chunk-ZJ7SM3G2.js +1 -0
- package/dist/{chunk-T4U24DXX.js → chunk-ZOX3LBRV.js} +1 -1
- package/dist/compat/index.cjs +9 -13
- package/dist/compat/index.d.cts +16 -16
- package/dist/compat/index.d.ts +16 -16
- package/dist/compat/index.js +1 -1
- package/dist/compat/jotai/index.d.cts +2 -2
- package/dist/compat/jotai/index.d.ts +2 -2
- package/dist/compat/nanostores/index.d.cts +2 -2
- package/dist/compat/nanostores/index.d.ts +2 -2
- package/dist/compat/nestjs/index.cjs +8 -12
- package/dist/compat/nestjs/index.d.cts +8 -8
- package/dist/compat/nestjs/index.d.ts +8 -8
- package/dist/compat/nestjs/index.js +1 -1
- package/dist/compat/react/index.d.cts +2 -2
- package/dist/compat/react/index.d.ts +2 -2
- package/dist/compat/solid/index.d.cts +2 -2
- package/dist/compat/solid/index.d.ts +2 -2
- package/dist/compat/svelte/index.d.cts +2 -2
- package/dist/compat/svelte/index.d.ts +2 -2
- package/dist/compat/vue/index.d.cts +2 -2
- package/dist/compat/vue/index.d.ts +2 -2
- package/dist/compat/zustand/index.cjs +3 -7
- package/dist/compat/zustand/index.d.cts +4 -4
- package/dist/compat/zustand/index.d.ts +4 -4
- package/dist/compat/zustand/index.js +1 -1
- package/dist/{composite-_XckYx2e.d.cts → composite-CKd0e2vz.d.cts} +10 -3
- package/dist/{composite-CT_mApQD.d.ts → composite-DGatA-JK.d.ts} +10 -3
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.d.cts +4 -4
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +1 -1
- package/dist/extra/browser.d.cts +1 -1
- package/dist/extra/browser.d.ts +1 -1
- package/dist/extra/index.cjs +17 -21
- package/dist/extra/index.d.cts +11 -9
- package/dist/extra/index.d.ts +11 -9
- package/dist/extra/index.js +1 -1
- package/dist/extra/node.cjs +2 -2
- package/dist/extra/node.d.cts +108 -2
- package/dist/extra/node.d.ts +108 -2
- package/dist/extra/node.js +2 -2
- package/dist/extra/operators.cjs +1 -1
- package/dist/extra/operators.d.cts +1 -1
- package/dist/extra/operators.d.ts +1 -1
- package/dist/extra/operators.js +1 -1
- package/dist/extra/reactive.cjs +1 -1
- package/dist/extra/reactive.d.cts +3 -3
- package/dist/extra/reactive.d.ts +3 -3
- package/dist/extra/reactive.js +1 -1
- package/dist/extra/render/index.cjs +5 -0
- package/dist/extra/render/index.d.cts +183 -0
- package/dist/extra/render/index.d.ts +183 -0
- package/dist/extra/render/index.js +1 -0
- package/dist/extra/sources.cjs +1 -1
- package/dist/extra/sources.d.cts +1 -1
- package/dist/extra/sources.d.ts +1 -1
- package/dist/extra/sources.js +1 -1
- package/dist/extra/storage-browser.d.cts +1 -1
- package/dist/extra/storage-browser.d.ts +1 -1
- package/dist/extra/storage-tiers-browser.d.cts +76 -5
- package/dist/extra/storage-tiers-browser.d.ts +76 -5
- package/dist/extra/storage-tiers-node.d.cts +137 -13
- package/dist/extra/storage-tiers-node.d.ts +137 -13
- package/dist/extra/storage-tiers.d.cts +151 -23
- package/dist/extra/storage-tiers.d.ts +151 -23
- package/dist/{fallback-axI2cXwt.d.cts → fallback-8JYU8tlT.d.cts} +1 -1
- package/dist/{fallback-DuEXfA4F.d.ts → fallback-CMZl39L5.d.ts} +1 -1
- package/dist/graph/index.cjs +7 -7
- package/dist/graph/index.d.cts +5 -5
- package/dist/graph/index.d.ts +5 -5
- package/dist/graph/index.js +1 -1
- package/dist/{graph-YQXDndFy.d.ts → graph-30XSgtVX.d.ts} +287 -104
- package/dist/{graph-CaNXUc3c.d.cts → graph-BUwMAxJI.d.cts} +287 -104
- package/dist/{index-CIcu6fIR.d.ts → index-2n8Eai6M.d.ts} +1 -1
- package/dist/{index-BmLkcDlj.d.ts → index-89FczVZ_.d.ts} +47 -71
- package/dist/{index-Ci358GSC.d.cts → index-8R1vzNOx.d.cts} +9 -9
- package/dist/{index-CDvC1m5p.d.ts → index-B2RUoIUz.d.ts} +1 -1
- package/dist/{index-DuhOdNyg.d.ts → index-B41Asm7D.d.ts} +10 -8
- package/dist/{index-CKcnuQ2c.d.ts → index-B9fmw5n2.d.ts} +4 -6
- package/dist/{index-0qOD-421.d.ts → index-BAlaVimV.d.ts} +9 -9
- package/dist/{index-Ae6L8liv.d.ts → index-BC9VybQs.d.ts} +41 -48
- package/dist/{index-CUTHDZ7Q.d.ts → index-BEHmxORq.d.ts} +11 -11
- package/dist/{index-C_qi0WlF.d.cts → index-BJ26eEjs.d.cts} +26 -19
- package/dist/{index-BiomL7AW.d.ts → index-BJSZxSFX.d.ts} +1 -1
- package/dist/{index-DCAuN9u5.d.cts → index-BKMdnYnk.d.ts} +75 -39
- package/dist/{index-DfAo9WKr.d.ts → index-BM9szD8n.d.cts} +14 -6
- package/dist/{index-CajEOoAN.d.ts → index-BUPVld1w.d.ts} +2 -2
- package/dist/{index-C-pFD_FV.d.ts → index-BXd6OMEy.d.ts} +3 -3
- package/dist/index-BhUaMYm_.d.ts +113 -0
- package/dist/{index-DAKm44My.d.cts → index-BndG0cpK.d.cts} +3 -3
- package/dist/{index-Bpzw8hx3.d.ts → index-Br3WnqEn.d.ts} +84 -9
- package/dist/{index-D6tRNEKz.d.cts → index-BskfDoZ_.d.ts} +14 -6
- package/dist/{index-9mbs_PIG.d.ts → index-C19qqa38.d.ts} +4 -4
- package/dist/{index-fHKHdAso.d.ts → index-C7VV_qOs.d.ts} +4 -4
- package/dist/{index-CLPQyYY5.d.cts → index-CIRG8Hxp.d.cts} +11 -11
- package/dist/{index-B3D_z0Z6.d.cts → index-CL7oilfm.d.cts} +1 -1
- package/dist/{index-BOfHwQc1.d.ts → index-CPhBvRJU.d.ts} +1 -1
- package/dist/{index-B9qJmmv3.d.cts → index-CWHtYmSh.d.cts} +1 -1
- package/dist/{index-D_d1erkR.d.ts → index-Cey6VTnX.d.ts} +8 -5
- package/dist/{resilience-BWP2c7Af.d.cts → index-CmqiJZKM.d.ts} +141 -23
- package/dist/{index-JYtN9uqM.d.ts → index-CoM4rzyB.d.ts} +1 -1
- package/dist/{index-DTYIRT_v.d.cts → index-CpLpJb6A.d.cts} +8 -5
- package/dist/{index-BjWZARLy.d.ts → index-Ctb7_2sG.d.ts} +1 -1
- package/dist/index-CusEP3Sv.d.ts +210 -0
- package/dist/{resilience-Bys63Cpd.d.ts → index-CwP_KAMS.d.cts} +141 -23
- package/dist/{index-BFuVcqL8.d.cts → index-D3ayz3hy.d.cts} +1 -1
- package/dist/{index-CrpjECS6.d.cts → index-DCbE8fFM.d.cts} +3 -3
- package/dist/{index-D_DThl_J.d.cts → index-DIHcMLr6.d.cts} +1 -1
- package/dist/index-DINuaZlJ.d.cts +210 -0
- package/dist/{index-9xhIaM-w.d.cts → index-DOBLxOti.d.cts} +1 -1
- package/dist/index-DQUVq1_d.d.ts +374 -0
- package/dist/{index-B1IcU--K.d.cts → index-DTtBpuQy.d.cts} +4 -6
- package/dist/{index-D_QQ_dTD.d.cts → index-DYTBbF8T.d.cts} +1 -1
- package/dist/{index-DqtXA3yX.d.cts → index-DlgHqQxW.d.cts} +84 -9
- package/dist/{index-D1E1tqHT.d.ts → index-DlrWu9Hs.d.cts} +75 -39
- package/dist/{index-DcWbx58m.d.cts → index-DoYc8BWK.d.cts} +41 -48
- package/dist/{index-D0ZxFXYl.d.ts → index-DszPlZzK.d.ts} +3 -3
- package/dist/{index-BECJ8M0T.d.cts → index-DyM4tFAe.d.cts} +10 -8
- package/dist/{index-D11pGlaI.d.cts → index-FVoPvhAu.d.cts} +4 -4
- package/dist/{index-BwtIbzSV.d.cts → index-H_I66pav.d.cts} +2 -2
- package/dist/{index-e1m3ZHgc.d.cts → index-IwFqHxCs.d.cts} +2 -2
- package/dist/index-K-vl_c6A.d.cts +113 -0
- package/dist/{index-C4N-dg5U.d.cts → index-KlZ_ZUip.d.cts} +2 -2
- package/dist/index-L8XI8Zql.d.cts +374 -0
- package/dist/{index-D8IyqHvT.d.cts → index-MxYuWOrf.d.cts} +6 -4
- package/dist/{index-CpZKtdMw.d.cts → index-PgwvGWa1.d.cts} +1 -1
- package/dist/{index-B46GWgk3.d.ts → index-PlJ3MraE.d.ts} +1 -1
- package/dist/{index-DPqR3wdW.d.ts → index-PqbnoScQ.d.ts} +3 -3
- package/dist/{index-CU3z8Cel.d.cts → index-PsVHpPwP.d.cts} +3 -3
- package/dist/{index-C0tga1_x.d.ts → index-WyFKER-c.d.ts} +2 -2
- package/dist/{index-B5UR87KG.d.ts → index-eaQuGJnv.d.ts} +6 -4
- package/dist/{index-CzIWlnPp.d.ts → index-iTX5IqSP.d.ts} +140 -9
- package/dist/{index-CRycrNfn.d.ts → index-jKLph6cu.d.ts} +2 -2
- package/dist/{index-BhLA9feT.d.ts → index-jr6PuSBt.d.ts} +26 -19
- package/dist/{index-4IwO4mH2.d.cts → index-mNwgxC21.d.cts} +140 -9
- package/dist/{index-CkN8CZlT.d.cts → index-pVDQcbar.d.cts} +47 -71
- package/dist/{index-D6pwWiOc.d.cts → index-xZYcDqFH.d.cts} +4 -4
- package/dist/{index-8OxXae3g.d.ts → index-yLt-aPMp.d.ts} +1 -1
- package/dist/{index-CqSJ25A9.d.cts → index-z8WFPVI8.d.cts} +1 -1
- package/dist/index.cjs +64 -60
- package/dist/index.d.cts +48 -47
- package/dist/index.d.ts +48 -47
- package/dist/index.js +1 -1
- package/dist/meta-Ct9nqQS5.d.cts +102 -0
- package/dist/meta-D8OyedKp.d.ts +102 -0
- package/dist/{node-fSc-hCv8.d.cts → node-BYInONRr.d.cts} +3 -3
- package/dist/{node-fSc-hCv8.d.ts → node-BYInONRr.d.ts} +3 -3
- package/dist/{observable-Cqty11jG.d.cts → observable-DMIlYJV1.d.cts} +1 -1
- package/dist/{observable-EAV_rNfM.d.ts → observable-DO8DDEzv.d.ts} +1 -1
- package/dist/patterns/ai/browser.cjs +5 -5
- package/dist/patterns/ai/browser.d.cts +4 -4
- package/dist/patterns/ai/browser.d.ts +4 -4
- package/dist/patterns/ai/browser.js +1 -1
- package/dist/patterns/ai/index.cjs +17 -21
- package/dist/patterns/ai/index.d.cts +17 -17
- package/dist/patterns/ai/index.d.ts +17 -17
- package/dist/patterns/ai/index.js +1 -1
- package/dist/patterns/ai/node.cjs +1 -1
- package/dist/patterns/ai/node.d.cts +4 -4
- package/dist/patterns/ai/node.d.ts +4 -4
- package/dist/patterns/ai/node.js +1 -1
- package/dist/patterns/audit/index.cjs +3 -7
- package/dist/patterns/audit/index.d.cts +6 -6
- package/dist/patterns/audit/index.d.ts +6 -6
- package/dist/patterns/audit/index.js +1 -1
- package/dist/patterns/cqrs/index.cjs +3 -7
- package/dist/patterns/cqrs/index.d.cts +6 -6
- package/dist/patterns/cqrs/index.d.ts +6 -6
- package/dist/patterns/cqrs/index.js +1 -1
- package/dist/patterns/demo-shell/index.cjs +5 -8
- package/dist/patterns/demo-shell/index.d.cts +5 -5
- package/dist/patterns/demo-shell/index.d.ts +5 -5
- package/dist/patterns/demo-shell/index.js +1 -1
- package/dist/patterns/domain-templates/index.cjs +3 -7
- package/dist/patterns/domain-templates/index.d.cts +4 -4
- package/dist/patterns/domain-templates/index.d.ts +4 -4
- package/dist/patterns/domain-templates/index.js +1 -1
- package/dist/patterns/graphspec/index.cjs +38 -38
- package/dist/patterns/graphspec/index.d.cts +5 -5
- package/dist/patterns/graphspec/index.d.ts +5 -5
- package/dist/patterns/graphspec/index.js +1 -1
- package/dist/patterns/guarded-execution/index.cjs +3 -7
- package/dist/patterns/guarded-execution/index.d.cts +7 -7
- package/dist/patterns/guarded-execution/index.d.ts +7 -7
- package/dist/patterns/guarded-execution/index.js +1 -1
- package/dist/patterns/harness/index.cjs +8 -12
- package/dist/patterns/harness/index.d.cts +12 -12
- package/dist/patterns/harness/index.d.ts +12 -12
- package/dist/patterns/harness/index.js +1 -1
- package/dist/patterns/job-queue/index.cjs +3 -7
- package/dist/patterns/job-queue/index.d.cts +6 -6
- package/dist/patterns/job-queue/index.d.ts +6 -6
- package/dist/patterns/job-queue/index.js +1 -1
- package/dist/patterns/lens/index.cjs +3 -7
- package/dist/patterns/lens/index.d.cts +6 -6
- package/dist/patterns/lens/index.d.ts +6 -6
- package/dist/patterns/lens/index.js +1 -1
- package/dist/patterns/memory/index.cjs +3 -7
- package/dist/patterns/memory/index.d.cts +7 -5
- package/dist/patterns/memory/index.d.ts +7 -5
- package/dist/patterns/memory/index.js +1 -1
- package/dist/patterns/messaging/index.cjs +3 -7
- package/dist/patterns/messaging/index.d.cts +5 -5
- package/dist/patterns/messaging/index.d.ts +5 -5
- package/dist/patterns/messaging/index.js +1 -1
- package/dist/patterns/orchestration/index.cjs +3 -7
- package/dist/patterns/orchestration/index.d.cts +8 -8
- package/dist/patterns/orchestration/index.d.ts +8 -8
- package/dist/patterns/orchestration/index.js +1 -1
- package/dist/patterns/process/index.cjs +1 -1
- package/dist/patterns/process/index.d.cts +7 -7
- package/dist/patterns/process/index.d.ts +7 -7
- package/dist/patterns/process/index.js +1 -1
- package/dist/patterns/reactive-layout/index.cjs +4 -8
- package/dist/patterns/reactive-layout/index.d.cts +5 -5
- package/dist/patterns/reactive-layout/index.d.ts +5 -5
- package/dist/patterns/reactive-layout/index.js +1 -1
- package/dist/patterns/reduction/index.cjs +3 -7
- package/dist/patterns/reduction/index.d.cts +4 -4
- package/dist/patterns/reduction/index.d.ts +4 -4
- package/dist/patterns/reduction/index.js +1 -1
- package/dist/patterns/refine-loop/index.cjs +5 -9
- package/dist/patterns/refine-loop/index.d.cts +6 -6
- package/dist/patterns/refine-loop/index.d.ts +6 -6
- package/dist/patterns/refine-loop/index.js +1 -1
- package/dist/patterns/resilient-pipeline/index.cjs +1 -1
- package/dist/patterns/resilient-pipeline/index.d.cts +4 -8
- package/dist/patterns/resilient-pipeline/index.d.ts +4 -8
- package/dist/patterns/resilient-pipeline/index.js +1 -1
- package/dist/patterns/surface/index.cjs +13 -17
- package/dist/patterns/surface/index.d.cts +6 -6
- package/dist/patterns/surface/index.d.ts +6 -6
- package/dist/patterns/surface/index.js +1 -1
- package/dist/{pipeline-graph-BrrYGjuZ.d.cts → pipeline-graph-BQPr2Lqs.d.cts} +34 -17
- package/dist/{pipeline-graph-DX2Twdj-.d.ts → pipeline-graph-D8vKcO_p.d.ts} +34 -17
- package/dist/{reactive-layout-DrGjuwyC.d.cts → reactive-layout-8CSc0tiA.d.cts} +2 -2
- package/dist/{reactive-layout-BDdngW56.d.ts → reactive-layout-DkTXxtSy.d.ts} +2 -2
- package/dist/{reactive-log-jirQsxMY.d.ts → reactive-log-BlAsPLl2.d.ts} +30 -3
- package/dist/{reactive-log-ScpWyqny.d.cts → reactive-log-_zeEnB9H.d.cts} +30 -3
- package/dist/{reactive-map-DmgeADH8.d.cts → reactive-map-B2qfD3hb.d.cts} +1 -1
- package/dist/{reactive-map-CHyeCf4D.d.ts → reactive-map-jFIsE6Kt.d.ts} +1 -1
- package/dist/resilience-HTF2LBRS.js +1 -0
- package/dist/{sugar-D13E2M_z.d.ts → sugar-BhfjgetH.d.ts} +1 -1
- package/dist/{sugar-DgaGJcI6.d.cts → sugar-DzePN5-g.d.cts} +1 -1
- package/dist/{topology-tree-BkhmMg2a.d.cts → topology-tree-B5Ngw3j0.d.cts} +1 -1
- package/dist/{topology-tree-BI665P0L.d.ts → topology-tree-BtvbgMXJ.d.ts} +1 -1
- package/dist/{types-BMSGPlpO.d.cts → types-1Dhoi7HM.d.cts} +1 -1
- package/dist/{types-CidcBDuk.d.ts → types-39jk0kaV.d.ts} +1 -1
- package/package.json +11 -1
- package/dist/chunk-4EATTNAE.js +0 -1
- package/dist/chunk-533RQFF6.js +0 -1
- package/dist/chunk-6SVKZ7VI.js +0 -1
- package/dist/chunk-A5HZZYRK.js +0 -1
- package/dist/chunk-B4L5X2QO.js +0 -7
- package/dist/chunk-C5CBVOCB.js +0 -1
- package/dist/chunk-CZIQ6JCE.js +0 -1
- package/dist/chunk-FJ6IEMOS.js +0 -1
- package/dist/chunk-FMI4CWFL.js +0 -1
- package/dist/chunk-G6Q3DUMJ.js +0 -1
- package/dist/chunk-GDDPCDLG.js +0 -1
- package/dist/chunk-GFOT6UBB.js +0 -1
- package/dist/chunk-JJTF75VS.js +0 -1
- package/dist/chunk-K2WYIVHM.js +0 -1
- package/dist/chunk-KTWBUJO5.js +0 -61
- package/dist/chunk-M27MVZCP.js +0 -1
- package/dist/chunk-NKKUUKPD.js +0 -43
- package/dist/chunk-O32GJOUJ.js +0 -1
- package/dist/chunk-QKBCTKH7.js +0 -1
- package/dist/chunk-QWVQIL3T.js +0 -1
- package/dist/chunk-UODQF4EY.js +0 -1
- package/dist/chunk-WGST56ZH.js +0 -80
- package/dist/chunk-WSLN4JFO.js +0 -1
- package/dist/chunk-XIJKEXWR.js +0 -1
- package/dist/imperative-audit-ahAE65a9.d.cts +0 -28
- package/dist/imperative-audit-ahAE65a9.d.ts +0 -28
- package/dist/index-BCq12BqB.d.ts +0 -139
- package/dist/index-BokynmA4.d.cts +0 -186
- package/dist/index-DXz9uwcs.d.ts +0 -186
- package/dist/index-DbWwMWiB.d.cts +0 -139
- package/dist/meta-BGO6C7K9.d.cts +0 -41
- package/dist/meta-CC6EPdpK.d.ts +0 -41
- package/dist/resilience-OBU472D2.js +0 -1
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { N as Node, a as NodeOptions } from './node-BYInONRr.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `budgetGate` — numeric-constraint flow gate (Tier 2.2 promotion from
|
|
5
|
+
* `patterns/reduction/`).
|
|
6
|
+
*
|
|
7
|
+
* Lives alongside the other `extra/resilience/` flow controls (`retry`,
|
|
8
|
+
* `circuitBreaker`, `rateLimiter`, `tokenBucket`, `fallback`, `withStatus`).
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** A reactive constraint for {@link budgetGate}. */
|
|
14
|
+
type BudgetConstraint<T = unknown> = {
|
|
15
|
+
/** Constraint node whose value is checked. */
|
|
16
|
+
node: Node<T>;
|
|
17
|
+
/** Returns `true` when the constraint is satisfied (budget available). */
|
|
18
|
+
check: (value: T) => boolean;
|
|
19
|
+
};
|
|
20
|
+
/** Options for {@link budgetGate}. */
|
|
21
|
+
type BudgetGateOptions = Omit<NodeOptions<unknown>, "describeKind" | "name" | "meta"> & {
|
|
22
|
+
meta?: Record<string, unknown>;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Pass-through that respects reactive constraint nodes.
|
|
26
|
+
*
|
|
27
|
+
* DATA flows through when all constraints are satisfied. When any constraint
|
|
28
|
+
* is exceeded, `PAUSE` is sent upstream and DATA is buffered in a FIFO queue.
|
|
29
|
+
* When constraints relax, the queue drains in arrival order and `RESUME` is
|
|
30
|
+
* sent upstream.
|
|
31
|
+
*
|
|
32
|
+
* ## Invariants (do not refactor without preserving)
|
|
33
|
+
*
|
|
34
|
+
* 1. **Terminal force-flush.** On `COMPLETE` / `ERROR` arriving from `source`,
|
|
35
|
+
* every buffered item is emitted downstream BEFORE the terminal message is
|
|
36
|
+
* forwarded. The constraint is intentionally bypassed for the flush — once
|
|
37
|
+
* upstream is done, the caller must see the buffered work, not lose it.
|
|
38
|
+
* See COMPOSITION-GUIDE §19 (terminal-emission operators).
|
|
39
|
+
*
|
|
40
|
+
* 2. **PAUSE-release ordering.** When a constraint flips from saturated →
|
|
41
|
+
* released, the queue drains in FIFO order downstream BEFORE `RESUME` is
|
|
42
|
+
* sent upstream. Reversing the order (RESUME-then-drain) would let new
|
|
43
|
+
* upstream DATA interleave with the queue tail, breaking arrival-order
|
|
44
|
+
* delivery. See COMPOSITION-GUIDE §9, §9a (diamond + batch coalescing).
|
|
45
|
+
*
|
|
46
|
+
* 3. **Deferred RESOLVED.** A `RESOLVED` from `source` while the queue is
|
|
47
|
+
* non-empty is held until the queue drains, then forwarded — so downstream
|
|
48
|
+
* sees `[buffered DATA…, RESOLVED]` in causal order rather than
|
|
49
|
+
* `[RESOLVED, buffered DATA…]`.
|
|
50
|
+
*
|
|
51
|
+
* **Stall risk (qa D4):** if the constraint never relaxes AND no terminal
|
|
52
|
+
* arrives from `source`, the deferred RESOLVED is held forever. Downstream
|
|
53
|
+
* consumers that depend on `RESOLVED` for an `awaitSettled`-style
|
|
54
|
+
* coordination wait stall in this case. PAUSE is sent upstream so source
|
|
55
|
+
* backpressure stops further DATA, but the gate itself has no escape
|
|
56
|
+
* hatch — by design (the producer-pattern is fire-and-forget; recovery
|
|
57
|
+
* happens at the compositor level via timeout, retry, or cancellation).
|
|
58
|
+
*
|
|
59
|
+
* 4. **Constraint DIRTY suppression.** Constraint-node DIRTY does NOT
|
|
60
|
+
* propagate downstream — only `source`-DIRTY does. The gate's downstream
|
|
61
|
+
* semantics track `source`'s wave, not constraint waves.
|
|
62
|
+
*
|
|
63
|
+
* 5. **Lazy PAUSE (qa D3).** PAUSE is sent upstream ONLY when a `source` DATA
|
|
64
|
+
* arrives that fails the constraint check (the first blocked item). A
|
|
65
|
+
* constraint flipping closed BEFORE any source DATA arrives does NOT emit
|
|
66
|
+
* a preemptive PAUSE — upstream may push DATA freely until the first
|
|
67
|
+
* item is buffered. This matches the producer-pattern lazy-activation
|
|
68
|
+
* philosophy (don't impose backpressure for hypothetical future blocks).
|
|
69
|
+
* For eager-PAUSE semantics, wrap the gate in a compositor that watches
|
|
70
|
+
* constraints + source independently.
|
|
71
|
+
*
|
|
72
|
+
* ## Queue
|
|
73
|
+
*
|
|
74
|
+
* The internal buffer is an unbounded {@link HeadIndexQueue} (O(1) push,
|
|
75
|
+
* O(1) shift, opportunistic compaction). It does NOT use {@link RingBuffer}
|
|
76
|
+
* because RingBuffer's drop-oldest eviction would silently lose buffered
|
|
77
|
+
* items between PAUSE and RESUME. Backpressure (PAUSE) is the upstream
|
|
78
|
+
* contract for bounding the queue, not capacity-driven eviction here.
|
|
79
|
+
*
|
|
80
|
+
* ## Producer-pattern: source edge is invisible to `describe()`
|
|
81
|
+
*
|
|
82
|
+
* `budgetGate` is constructed via `node([], fn)` and subscribes to `source`
|
|
83
|
+
* and the constraint nodes manually inside its activation fn. Because no
|
|
84
|
+
* dep is declared at construction, **`describe()` shows no edge from
|
|
85
|
+
* `source` (or any constraint) into the returned node** — the gate looks
|
|
86
|
+
* like a standalone leaf source. This is intentional (see COMPOSITION-GUIDE
|
|
87
|
+
* §24 "Edges are derived, not declared"): if you want the constraint /
|
|
88
|
+
* source dependency to appear in describe output, surface it at the
|
|
89
|
+
* compositor level (e.g. annotate via `meta.ai.upstream`, or wrap the gate
|
|
90
|
+
* in a parent factory that exposes the deps as constructor args).
|
|
91
|
+
*
|
|
92
|
+
* ## Reference equality
|
|
93
|
+
*
|
|
94
|
+
* The `constraints` array reference and each `BudgetConstraint.check`
|
|
95
|
+
* function are captured at construction. The factory does NOT diff
|
|
96
|
+
* subsequent `constraints` arrays (there is no subsequent — the array is
|
|
97
|
+
* static for the gate's lifetime). To swap constraints reactively, build
|
|
98
|
+
* the swap at the compositor level above the gate (Architecture-2:
|
|
99
|
+
* compositor-only). Identity changes to `constraints` are observed only by
|
|
100
|
+
* constructing a new gate.
|
|
101
|
+
*
|
|
102
|
+
* @param source - Input node.
|
|
103
|
+
* @param constraints - Reactive constraint checks. MUST be non-empty.
|
|
104
|
+
* @param opts - Optional node options.
|
|
105
|
+
* @returns Gated node.
|
|
106
|
+
*
|
|
107
|
+
* @throws {RangeError} when `constraints.length === 0`. The gate has no
|
|
108
|
+
* meaningful identity without at least one check — degenerate to plain
|
|
109
|
+
* pass-through (e.g. via `derived([source], ([v]) => v)`) instead.
|
|
110
|
+
*
|
|
111
|
+
* @category resilience
|
|
112
|
+
*/
|
|
113
|
+
declare function budgetGate<T>(source: Node<T>, constraints: ReadonlyArray<BudgetConstraint>, opts?: BudgetGateOptions): Node<T>;
|
|
114
|
+
|
|
115
|
+
export { type BudgetConstraint as B, type BudgetGateOptions as a, budgetGate as b };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { N as Node, a as NodeOptions } from './node-BYInONRr.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `budgetGate` — numeric-constraint flow gate (Tier 2.2 promotion from
|
|
5
|
+
* `patterns/reduction/`).
|
|
6
|
+
*
|
|
7
|
+
* Lives alongside the other `extra/resilience/` flow controls (`retry`,
|
|
8
|
+
* `circuitBreaker`, `rateLimiter`, `tokenBucket`, `fallback`, `withStatus`).
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** A reactive constraint for {@link budgetGate}. */
|
|
14
|
+
type BudgetConstraint<T = unknown> = {
|
|
15
|
+
/** Constraint node whose value is checked. */
|
|
16
|
+
node: Node<T>;
|
|
17
|
+
/** Returns `true` when the constraint is satisfied (budget available). */
|
|
18
|
+
check: (value: T) => boolean;
|
|
19
|
+
};
|
|
20
|
+
/** Options for {@link budgetGate}. */
|
|
21
|
+
type BudgetGateOptions = Omit<NodeOptions<unknown>, "describeKind" | "name" | "meta"> & {
|
|
22
|
+
meta?: Record<string, unknown>;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Pass-through that respects reactive constraint nodes.
|
|
26
|
+
*
|
|
27
|
+
* DATA flows through when all constraints are satisfied. When any constraint
|
|
28
|
+
* is exceeded, `PAUSE` is sent upstream and DATA is buffered in a FIFO queue.
|
|
29
|
+
* When constraints relax, the queue drains in arrival order and `RESUME` is
|
|
30
|
+
* sent upstream.
|
|
31
|
+
*
|
|
32
|
+
* ## Invariants (do not refactor without preserving)
|
|
33
|
+
*
|
|
34
|
+
* 1. **Terminal force-flush.** On `COMPLETE` / `ERROR` arriving from `source`,
|
|
35
|
+
* every buffered item is emitted downstream BEFORE the terminal message is
|
|
36
|
+
* forwarded. The constraint is intentionally bypassed for the flush — once
|
|
37
|
+
* upstream is done, the caller must see the buffered work, not lose it.
|
|
38
|
+
* See COMPOSITION-GUIDE §19 (terminal-emission operators).
|
|
39
|
+
*
|
|
40
|
+
* 2. **PAUSE-release ordering.** When a constraint flips from saturated →
|
|
41
|
+
* released, the queue drains in FIFO order downstream BEFORE `RESUME` is
|
|
42
|
+
* sent upstream. Reversing the order (RESUME-then-drain) would let new
|
|
43
|
+
* upstream DATA interleave with the queue tail, breaking arrival-order
|
|
44
|
+
* delivery. See COMPOSITION-GUIDE §9, §9a (diamond + batch coalescing).
|
|
45
|
+
*
|
|
46
|
+
* 3. **Deferred RESOLVED.** A `RESOLVED` from `source` while the queue is
|
|
47
|
+
* non-empty is held until the queue drains, then forwarded — so downstream
|
|
48
|
+
* sees `[buffered DATA…, RESOLVED]` in causal order rather than
|
|
49
|
+
* `[RESOLVED, buffered DATA…]`.
|
|
50
|
+
*
|
|
51
|
+
* **Stall risk (qa D4):** if the constraint never relaxes AND no terminal
|
|
52
|
+
* arrives from `source`, the deferred RESOLVED is held forever. Downstream
|
|
53
|
+
* consumers that depend on `RESOLVED` for an `awaitSettled`-style
|
|
54
|
+
* coordination wait stall in this case. PAUSE is sent upstream so source
|
|
55
|
+
* backpressure stops further DATA, but the gate itself has no escape
|
|
56
|
+
* hatch — by design (the producer-pattern is fire-and-forget; recovery
|
|
57
|
+
* happens at the compositor level via timeout, retry, or cancellation).
|
|
58
|
+
*
|
|
59
|
+
* 4. **Constraint DIRTY suppression.** Constraint-node DIRTY does NOT
|
|
60
|
+
* propagate downstream — only `source`-DIRTY does. The gate's downstream
|
|
61
|
+
* semantics track `source`'s wave, not constraint waves.
|
|
62
|
+
*
|
|
63
|
+
* 5. **Lazy PAUSE (qa D3).** PAUSE is sent upstream ONLY when a `source` DATA
|
|
64
|
+
* arrives that fails the constraint check (the first blocked item). A
|
|
65
|
+
* constraint flipping closed BEFORE any source DATA arrives does NOT emit
|
|
66
|
+
* a preemptive PAUSE — upstream may push DATA freely until the first
|
|
67
|
+
* item is buffered. This matches the producer-pattern lazy-activation
|
|
68
|
+
* philosophy (don't impose backpressure for hypothetical future blocks).
|
|
69
|
+
* For eager-PAUSE semantics, wrap the gate in a compositor that watches
|
|
70
|
+
* constraints + source independently.
|
|
71
|
+
*
|
|
72
|
+
* ## Queue
|
|
73
|
+
*
|
|
74
|
+
* The internal buffer is an unbounded {@link HeadIndexQueue} (O(1) push,
|
|
75
|
+
* O(1) shift, opportunistic compaction). It does NOT use {@link RingBuffer}
|
|
76
|
+
* because RingBuffer's drop-oldest eviction would silently lose buffered
|
|
77
|
+
* items between PAUSE and RESUME. Backpressure (PAUSE) is the upstream
|
|
78
|
+
* contract for bounding the queue, not capacity-driven eviction here.
|
|
79
|
+
*
|
|
80
|
+
* ## Producer-pattern: source edge is invisible to `describe()`
|
|
81
|
+
*
|
|
82
|
+
* `budgetGate` is constructed via `node([], fn)` and subscribes to `source`
|
|
83
|
+
* and the constraint nodes manually inside its activation fn. Because no
|
|
84
|
+
* dep is declared at construction, **`describe()` shows no edge from
|
|
85
|
+
* `source` (or any constraint) into the returned node** — the gate looks
|
|
86
|
+
* like a standalone leaf source. This is intentional (see COMPOSITION-GUIDE
|
|
87
|
+
* §24 "Edges are derived, not declared"): if you want the constraint /
|
|
88
|
+
* source dependency to appear in describe output, surface it at the
|
|
89
|
+
* compositor level (e.g. annotate via `meta.ai.upstream`, or wrap the gate
|
|
90
|
+
* in a parent factory that exposes the deps as constructor args).
|
|
91
|
+
*
|
|
92
|
+
* ## Reference equality
|
|
93
|
+
*
|
|
94
|
+
* The `constraints` array reference and each `BudgetConstraint.check`
|
|
95
|
+
* function are captured at construction. The factory does NOT diff
|
|
96
|
+
* subsequent `constraints` arrays (there is no subsequent — the array is
|
|
97
|
+
* static for the gate's lifetime). To swap constraints reactively, build
|
|
98
|
+
* the swap at the compositor level above the gate (Architecture-2:
|
|
99
|
+
* compositor-only). Identity changes to `constraints` are observed only by
|
|
100
|
+
* constructing a new gate.
|
|
101
|
+
*
|
|
102
|
+
* @param source - Input node.
|
|
103
|
+
* @param constraints - Reactive constraint checks. MUST be non-empty.
|
|
104
|
+
* @param opts - Optional node options.
|
|
105
|
+
* @returns Gated node.
|
|
106
|
+
*
|
|
107
|
+
* @throws {RangeError} when `constraints.length === 0`. The gate has no
|
|
108
|
+
* meaningful identity without at least one check — degenerate to plain
|
|
109
|
+
* pass-through (e.g. via `derived([source], ([v]) => v)`) instead.
|
|
110
|
+
*
|
|
111
|
+
* @category resilience
|
|
112
|
+
*/
|
|
113
|
+
declare function budgetGate<T>(source: Node<T>, constraints: ReadonlyArray<BudgetConstraint>, opts?: BudgetGateOptions): Node<T>;
|
|
114
|
+
|
|
115
|
+
export { type BudgetConstraint as B, type BudgetGateOptions as a, budgetGate as b };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-
|
|
2
|
-
import { a as CircuitBreakerOptions, e as CircuitBreaker } from './
|
|
1
|
+
import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-1Dhoi7HM.cjs';
|
|
2
|
+
import { a as CircuitBreakerOptions, e as CircuitBreaker } from './index-CwP_KAMS.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* OpenAICompatAdapter — default fetch-backed, optional SDK-backed.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-
|
|
2
|
-
import { a as CircuitBreakerOptions, e as CircuitBreaker } from './
|
|
1
|
+
import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-39jk0kaV.js';
|
|
2
|
+
import { a as CircuitBreakerOptions, e as CircuitBreaker } from './index-CmqiJZKM.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* OpenAICompatAdapter — default fetch-backed, optional SDK-backed.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as p,v as f}from"./chunk-LYCLF26R.js";function v(t,n){if(n!=null&&n.length>0)return new Set(n);switch(t){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;case"spec":return new Set(["type","deps","meta","value"]);default:return new Set(["type","deps"])}}function b(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function D(t){let n=new WeakSet,r={};for(let[e,a]of m(t))r[e]=d(a,n);return r}function d(t,n){if(t==null)return t;let r=typeof t;if(r==="boolean"||r==="number"||r==="string")return t;if(r==="function")return"<function>";if(Array.isArray(t))return n.has(t)?"<cycle>":(n.add(t),t.map(e=>d(e,n)));if(r==="object"){let e=t;if(n.has(e))return"<cycle>";n.add(e);try{if(typeof e.subscribe=="function"&&"cache"in e)return"<Node>"}catch{return"<unserializable>"}let a={};for(let[c,i]of m(e))a[c]=d(i,n);return a}return"<unserializable>"}function m(t){let n=[],r;try{r=Object.keys(t)}catch{return n}for(let e of r)try{n.push([e,t[e]])}catch{n.push([e,"<unserializable>"])}return n}function N(t,n){let r={factory:t};return n!==void 0&&(r.factoryArgs=n),r}function h(t){let n={};for(let[r,e]of Object.entries(t.meta))try{n[r]=e.cache}catch{}return n}function R(t,n,r){let e=n==null,a=!e&&n!=null?[...n].filter(s=>s.startsWith("meta.")).map(s=>s.slice(5)):null,c=e||n.has("meta")||a!=null&&a.length>0,i="state",g=[];t instanceof p&&(i=b(t),g=t._deps.map(s=>s.node.name??""));let o={type:i,deps:g};(e||n.has("status"))&&(o.status=t.status);let u=t instanceof p?t._guard:void 0;if(c){let s={...h(t)};if(u!=null&&s.access===void 0&&(s.access=f(u)),a!=null&&a.length>0&&!n.has("meta")){let y={};for(let l of a)l in s&&(y[l]=s[l]);o.meta=y}else o.meta=s}if(t.name!=null&&(o.name=t.name),(e||n.has("value"))&&(!r||i==="state")){t.status==="sentinel"&&(o.sentinel=!0);try{o.value=t.cache}catch{}}if((e||n.has("v"))&&t.v!=null){let s={id:t.v.id,version:t.v.version};"cid"in t.v&&(s.cid=t.v.cid,s.prev=t.v.prev),o.v=s}return(e||n.has("guard"))&&u!=null&&(o.guard=f(u)),(e||n.has("lastMutation"))&&t.lastMutation!=null&&(o.lastMutation=t.lastMutation),o}export{v as a,D as b,N as c,R as d};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as S,b as _}from"./chunk-C72GO4IZ.js";var no={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"},to={horizontal:"-",vertical:"|",cornerTL:"+",cornerTR:"+",cornerBL:"+",cornerBR:"+",tDown:"+",tUp:"+",tRight:"+",tLeft:"+",cross:"+",arrowRight:">",arrowDown:"v",arrowLeft:"<",arrowUp:"^",boxTL:"+",boxTR:"+",boxBL:"+",boxBR:"+",boxH:"-",boxV:"|"};function F(o,t){let s=t.charset==="ascii"?to:no,i=o.width,r=o.height,e=Array.from({length:r},()=>Array.from({length:i},()=>" ")),n=Array.from({length:r},()=>Array.from({length:i},()=>"empty"));for(let a of o.edges)so(e,n,s,a);for(let a of o.boxes)io(e,n,s,a,t.labelOf(a.id));return e.map(a=>uo(a.join(""))).join(`
|
|
2
|
+
`)}function io(o,t,s,i,r){let{x:e,y:n,w:a,h:l}=i;if(a<2||l<2){l>0&&U(o,t,e,n,a,r);return}w(o,t,e,n,s.boxTL);for(let u=e+1;u<e+a-1;u+=1)w(o,t,u,n,s.boxH);w(o,t,e+a-1,n,s.boxTR);for(let u=n+1;u<n+l-1;u+=1){w(o,t,e,u,s.boxV);for(let f=e+1;f<e+a-1;f+=1)k(o,t,f,u," ","empty");w(o,t,e+a-1,u,s.boxV)}w(o,t,e,n+l-1,s.boxBL);for(let u=e+1;u<e+a-1;u+=1)w(o,t,u,n+l-1,s.boxH);w(o,t,e+a-1,n+l-1,s.boxBR);let c=n+Math.floor(l/2);U(o,t,e+1,c,a-2,r)}function w(o,t,s,i,r){k(o,t,s,i,r,r===" "?"empty":r==="\u2500"||r==="-"?"boxH":r==="\u2502"||r==="|"?"boxV":"boxCorner")}function k(o,t,s,i,r,e){if(i<0||i>=o.length)return;let n=o[i];s<0||s>=n.length||(n[s]=r,t[i][s]=e)}function U(o,t,s,i,r,e){if(i<0||i>=o.length)return;let n=s,a=r;for(let l of e){let c=S(l);if(c!==0){if(a<c)break;n>=0&&n<o[i].length&&(o[i][n]=l,t[i][n]="label",c===2&&n+1<o[i].length&&(o[i][n+1]="",t[i][n+1]="label")),n+=c,a-=c}}for(;a>0;)n>=0&&n<o[i].length&&(o[i][n]=" ",t[i][n]="empty"),n+=1,a-=1}function so(o,t,s,i){let r=i.points;if(r.length<2)return;for(let l=0;l+1<r.length;l+=1)ao(o,t,s,r[l],r[l+1]);for(let l=1;l+1<r.length;l+=1){let c=r[l-1],u=r[l],f=r[l+1],d=co(c,u,f,s);d&&K(o,t,u.x,u.y,d,"edgeCorner")}let e=r[r.length-1],n=r[r.length-2],a=lo(n,e,s);a&&K(o,t,e.x,e.y,a,"arrow")}function ao(o,t,s,i,r){if(!(i.x===r.x&&i.y===r.y)){if(i.y===r.y){let e=i.y,n=Math.min(i.x,r.x),a=Math.max(i.x,r.x);for(let l=n;l<=a;l+=1)z(o,t,l,e,s,"h")}else if(i.x===r.x){let e=i.x,n=Math.min(i.y,r.y),a=Math.max(i.y,r.y);for(let l=n;l<=a;l+=1)z(o,t,e,l,s,"v")}}}function z(o,t,s,i,r,e){if(i<0||i>=o.length)return;let n=o[i];if(s<0||s>=n.length)return;let a=t[i][s];if(!(a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label")){if(a==="empty"){n[s]=e==="h"?r.horizontal:r.vertical,t[i][s]=e==="h"?"edgeH":"edgeV";return}if(a==="edgeH"&&e==="v"){n[s]=r.cross,t[i][s]="edgeCorner";return}if(a==="edgeV"&&e==="h"){n[s]=r.cross,t[i][s]="edgeCorner";return}}}function K(o,t,s,i,r,e){if(i<0||i>=o.length)return;let n=o[i];if(s<0||s>=n.length)return;let a=t[i][s];a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label"||(n[s]=r,t[i][s]=e)}function co(o,t,s,i){let r=o.y===t.y,e=t.y===s.y;if(r===e)return;if(r){let l=o.x<t.x,c=s.y>t.y;return l&&c?i.cornerTR:l&&!c?i.cornerBR:!l&&c?i.cornerTL:i.cornerBL}let n=o.y<t.y,a=s.x>t.x;return n&&a?i.cornerBL:n&&!a?i.cornerBR:!n&&a?i.cornerTL:i.cornerTR}function lo(o,t,s){if(t.x>o.x)return s.arrowRight;if(t.x<o.x)return s.arrowLeft;if(t.y>o.y)return s.arrowDown;if(t.y<o.y)return s.arrowUp}function uo(o){let t=o.length;for(;t>0&&o.charCodeAt(t-1)===32;)t-=1;return o.slice(0,t)}function Y(o){let t=fo(o);po(t),ho(t),go(t),yo(t,o);let s=xo(t,o),{width:i,height:r}=wo(t),e=[];for(let n of t.layers)for(let a of n)a.isVirtual||e.push({id:a.id,layer:a.layer,order:a.order,x:a.x,y:a.y,w:a.w,h:a.h});return{boxes:e,edges:s,width:i,height:r}}function fo(o){let t=new Map;for(let r of o.nodes)t.set(r,{id:r,isVirtual:!1,layer:-1,order:0,x:0,y:0,w:o.widthCells(r),h:o.heightCells(r),in:[],out:[]});let s=[],i=0;for(let r of o.edges){if(r.from===r.to)continue;let e=t.get(r.from),n=t.get(r.to);if(!e||!n)continue;let a={chainId:i++,chainFrom:r.from,chainTo:r.to,fromId:r.from,toId:r.to,hopIndex:0,chainLen:1};e.out.push(a),n.in.push(a),s.push(a)}return{nodes:t,layers:[],hops:s}}function po(o){let t=new Map;for(let e of o.nodes.values())t.set(e.id,e.in.length);let s=[];for(let e of o.nodes.values())(t.get(e.id)??0)===0&&(e.layer=0,s.push(e));let i=new Set,r=0;for(;r<s.length;){let e=s[r++];if(!i.has(e.id)){i.add(e.id);for(let n of e.out){let a=o.nodes.get(n.toId);a.layer=Math.max(a.layer,e.layer+1);let l=(t.get(a.id)??0)-1;t.set(a.id,l),l<=0&&s.push(a)}}}for(let e of o.nodes.values())e.layer<0&&(e.layer=0)}function ho(o){let t=Math.max(0,...Array.from(o.nodes.values(),e=>e.layer)),s=Array.from({length:t+1},()=>[]);for(let e of o.nodes.values())s[e.layer].push(e);let i=[],r=0;for(let e of o.hops){let n=o.nodes.get(e.fromId),a=o.nodes.get(e.toId),l=a.layer-n.layer;if(l<=0){n.out=n.out.filter(f=>f!==e),a.in=a.in.filter(f=>f!==e);continue}if(l===1){e.hopIndex=0,e.chainLen=1,i.push(e);continue}n.out=n.out.filter(f=>f!==e),a.in=a.in.filter(f=>f!==e);let c=n;for(let f=1;f<l;f+=1){let d=`__virt_${r++}__`,h={id:d,isVirtual:!0,layer:n.layer+f,order:0,x:0,y:0,w:0,h:1,in:[],out:[]};o.nodes.set(d,h),s[h.layer].push(h);let p={chainId:e.chainId,chainFrom:e.chainFrom,chainTo:e.chainTo,fromId:c.id,toId:d,hopIndex:f-1,chainLen:l};c.out.push(p),h.in.push(p),i.push(p),c=h}let u={chainId:e.chainId,chainFrom:e.chainFrom,chainTo:e.chainTo,fromId:c.id,toId:a.id,hopIndex:l-1,chainLen:l};c.out.push(u),a.in.push(u),i.push(u)}for(let e of s)for(let n=0;n<e.length;n+=1)e[n].order=n;o.layers=s,o.hops=i}function go(o){for(let s=0;s<4;s+=1){for(let i=1;i<o.layers.length;i+=1)J(o,o.layers[i],"in"),G(o.layers[i]);for(let i=o.layers.length-2;i>=0;i-=1)J(o,o.layers[i],"out"),G(o.layers[i])}for(let s=0;s<2;s+=1){let i=!1;for(let r=1;r<o.layers.length;r+=1){let e=o.layers[r];for(let n=0;n+1<e.length;n+=1){let a=W(o,e[n],e[n+1],"in");[e[n],e[n+1]]=[e[n+1],e[n]],G(e),W(o,e[n],e[n+1],"in")<a?i=!0:([e[n],e[n+1]]=[e[n+1],e[n]],G(e))}}if(!i)break}}function J(o,t,s){let i=new Map;for(let r of t){let e=s==="in"?r.in:r.out;if(e.length===0){i.set(r.id,r.order);continue}let n=0,a=0;for(let l of e){let c=o.nodes.get(s==="in"?l.fromId:l.toId);c&&(n+=c.order,a+=1)}i.set(r.id,a===0?r.order:n/a)}t.sort((r,e)=>{let n=i.get(r.id),a=i.get(e.id);return n!==a?n-a:r.order-e.order})}function G(o){for(let t=0;t<o.length;t+=1)o[t].order=t}function W(o,t,s,i){let r=i==="in"?t.in:t.out,e=i==="in"?s.in:s.out,n=0;for(let a of r)for(let l of e){let c=o.nodes.get(i==="in"?a.fromId:a.toId)?.order??0,u=o.nodes.get(i==="in"?l.fromId:l.toId)?.order??0;(t.order<s.order&&c>u||t.order>s.order&&c<u)&&(n+=1)}return n}function yo(o,t){t.direction==="LR"?mo(o,t):bo(o,t)}function mo(o,t){let s=[],i=0;for(let r=0;r<o.layers.length;r+=1){s.push(i);let e=0;for(let n of o.layers[r])e=Math.max(e,n.w);i+=e+t.layerGap}for(let r=0;r<o.layers.length;r+=1)for(let e of o.layers[r])e.x=s[r];for(let r of o.layers){let e=0;for(let n of r)n.y=e,e+=n.h+t.nodeGap}X(o,t,"y")}function bo(o,t){let s=[],i=0;for(let r=0;r<o.layers.length;r+=1){s.push(i);let e=0;for(let n of o.layers[r])e=Math.max(e,n.h);i+=e+t.layerGap}for(let r=0;r<o.layers.length;r+=1)for(let e of o.layers[r])e.y=s[r];for(let r of o.layers){let e=0;for(let n of r)n.x=e,e+=n.w+t.nodeGap}X(o,t,"x")}function X(o,t,s){let i=e=>s==="y"?e.h:e.w,r=t.nodeGap;for(let e=0;e<2;e+=1){let n=e===0?o.layers.slice(1):o.layers.slice(0,-1).reverse();for(let a of n){let l=new Map;for(let u of a){let f=e===0?u.in:u.out;if(f.length===0)continue;let d=[];for(let p of f){let y=o.nodes.get(e===0?p.fromId:p.toId);if(!y)continue;let m=s==="y"?y.y:y.x;d.push(m+Math.floor(i(y)/2))}if(d.length===0)continue;d.sort((p,y)=>p-y);let h=d[Math.floor(d.length/2)];l.set(u.id,h-Math.floor(i(u)/2))}let c=0;for(let u of a){let f=l.get(u.id),d=s==="y"?u.y:u.x,p=Math.max(f??d,c);s==="y"?u.y=p:u.x=p,c=p+i(u)+r}}}}function xo(o,t){let s=new Map;for(let c of o.hops){let u=s.get(c.chainId);u?u.push(c):s.set(c.chainId,[c])}for(let c of s.values())c.sort((u,f)=>u.hopIndex-f.hopIndex);let i=t.direction==="LR",r=c=>i?c.x:c.y,e=c=>i?c.w:c.h,n=c=>i?c.y+Math.floor(c.h/2):c.x+Math.floor(c.w/2),a=new Map;for(let c=0;c+1<o.layers.length;c+=1){let u=o.layers[c],f=o.layers[c+1],d=0;for(let g of u)d=Math.max(d,r(g)+e(g));let h=Number.POSITIVE_INFINITY;for(let g of f)h=Math.min(h,r(g));let p=Number.isFinite(h)?h-1:d,y=Math.max(1,p-d+1),m=[];for(let g of u)for(let b of g.out)m.push(b);m.sort((g,b)=>{let x=n(o.nodes.get(g.fromId)),L=n(o.nodes.get(b.fromId));if(x!==L)return x-L;let O=n(o.nodes.get(g.toId)),M=n(o.nodes.get(b.toId));return O-M});let D=[],C=new Map;for(let g of m){let b=n(o.nodes.get(g.fromId)),x=n(o.nodes.get(g.toId)),L=Math.min(b,x),O=Math.max(b,x),M=-1;for(let R=0;R<D.length;R+=1){let j=D[R],N=!0;for(let V of j)if(V.lo<=O&&L<=V.hi){N=!1;break}if(N){j.push({lo:L,hi:O}),M=R;break}}M<0&&(D.push([{lo:L,hi:O}]),M=D.length-1),C.set(g,M)}let I=D.length,T=y>=Math.max(3,I+2),P=T?d+1:d,ro=T?p-1:p,$=Math.max(1,ro-P+1);for(let g of m){let b=C.get(g),x;if(I<=1)x=P+Math.floor($/2);else{let L=($-1)/(I-1);x=P+Math.floor(b*L)}a.set(g,Math.max(d,Math.min(p,x)))}}let l=[];for(let[,c]of s){let u=[];for(let d=0;d<c.length;d+=1){let h=c[d],p=o.nodes.get(h.fromId),y=o.nodes.get(h.toId),m=a.get(h),D=p.isVirtual?r(p):r(p)+e(p),C=y.isVirtual?r(y):r(y)-1,I=n(p),T=n(y);d===0&&v(u,i,D,I),I!==T&&(v(u,i,m,I),v(u,i,m,T)),v(u,i,C,T)}let f=c[0];l.push({from:f.chainFrom,to:f.chainTo,points:Lo(u)})}return l}function v(o,t,s,i){o.push(t?{x:s,y:i}:{x:i,y:s})}function Lo(o){let t=[];for(let s of o){let i=t[t.length-1];(!i||i.x!==s.x||i.y!==s.y)&&t.push(s)}return t}function wo(o){let t=0,s=0;for(let i of o.layers)for(let r of i)t=Math.max(t,r.x+r.w),s=Math.max(s,r.y+r.h);return{width:t,height:s}}var Do=24,Io=4,To=1,Mo=3;function Oo(o,t){let s=Co(t?.direction),i=Math.max(3,t?.maxLabelWidth??Do),r=t?.asciiCharset??"unicode",e=Object.keys(o.nodes).sort(),n=new Set(e),a=o.edges.filter(d=>n.has(d.from)&&n.has(d.to)),l=new Map,c=new Map;for(let d of e){let h=_(d,i);l.set(d,h),c.set(d,S(h)+4)}let u=Y({nodes:e,edges:a,widthCells:d=>c.get(d)??3,heightCells:()=>Mo,layerGap:Io,nodeGap:To,direction:s}),f=F(u,{charset:r,labelOf:d=>l.get(d)??d});return t?.logger?.(f),f}function Co(o){if(o===void 0||o==="LR")return"LR";if(o==="TD")return"TD";throw new Error(`ascii describe supports direction "LR" or "TD" only; got ${String(o)}`)}function E(o){if(o===null||typeof o!="object")return o;if(Array.isArray(o))return o.map(E);let t=o,s=Object.keys(t).sort(),i={};for(let r of s)i[r]=E(t[r]);return i}function q(o){return o.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Q(o){return o.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Z(o){return o==="TD"?"down":o==="BT"?"up":o==="RL"?"left":"right"}function A(o){let t=new Set,s=[];function i(r,e){let n=`${r}\0${e}`;t.has(n)||(t.add(n),s.push([r,e]))}for(let[r,e]of Object.entries(o.nodes)){let n=e.deps;if(n)for(let a of n)i(a,r)}for(let r of o.edges)i(r.from,r.to);return s}function B(o){if(o===void 0)return"LR";if(o==="TD"||o==="LR"||o==="BT"||o==="RL")return o;throw new Error(`invalid diagram direction ${String(o)}; expected one of: TD, LR, BT, RL`)}function oo(o){if(typeof o=="string")return JSON.stringify(o);if(typeof o=="number"||typeof o=="boolean"||o==null)return String(o);try{return JSON.stringify(o)}catch{return"[unserializable]"}}function Ro(o,t){let s=B(t?.direction),i=Object.keys(o.nodes).sort(),r=new Map;for(let n=0;n<i.length;n+=1)r.set(i[n],`n${n}`);let e=[`direction: ${Z(s)}`];for(let n of i){let a=r.get(n);e.push(`${a}: "${Q(n)}"`)}for(let[n,a]of A(o)){let l=r.get(n),c=r.get(a);!l||!c||e.push(`${l} -> ${c}`)}return e.join(`
|
|
3
|
+
`)}function So(o,t){let s=t?.includeEdges??!0,i=t?.includeSubgraphs??!0,{expand:r,...e}=o,n={...e,edges:s?o.edges:[],subgraphs:i?o.subgraphs:[]},a=JSON.stringify(E(n),null,t?.indent??2);return t?.logger?.(a),a}function H(o,t){let s=B(t?.direction),i=Object.keys(o.nodes).sort(),r=new Map;for(let n=0;n<i.length;n+=1)r.set(i[n],`n${n}`);let e=[`flowchart ${s}`];for(let n of i){let a=r.get(n);e.push(` ${a}["${q(n)}"]`)}for(let[n,a]of A(o)){let l=r.get(n),c=r.get(a);!l||!c||e.push(` ${l} --> ${c}`)}return e.join(`
|
|
4
|
+
`)}function eo(o,t){let s=t?.theme??"default",i=t?.autoSync??!0,e=JSON.stringify({code:o,mermaid:{theme:s},autoSync:i}),n=new TextEncoder().encode(e),a="";for(let c=0;c<n.length;c++)a+=String.fromCharCode(n[c]);return`https://mermaid.live/edit#base64:${globalThis.btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function Go(o,t){let s=H(o,t);return eo(s,t)}function vo(o,t){let s=t?.includeEdges??!0,i=t?.includeSubgraphs??!0,r=[];r.push(`Graph ${o.name}`),r.push("Nodes:");for(let n of Object.keys(o.nodes).sort()){let a=o.nodes[n];r.push(`- ${n} (${a.type}/${a.status}): ${oo(a.value)}`)}if(s){r.push("Edges:");for(let n of o.edges)r.push(`- ${n.from} -> ${n.to}`)}if(i){r.push("Subgraphs:");for(let n of o.subgraphs)r.push(`- ${n}`)}let e=r.join(`
|
|
5
|
+
`);return t?.logger?.(e),e}export{Oo as a,Ro as b,So as c,H as d,eo as e,Go as f,vo as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as w,b as U,c as K}from"./chunk-35JTVPOX.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as T,b as k}from"./chunk-SC7BQDNP.js";import{d as H}from"./chunk-3G5U5QNE.js";import{i as B}from"./chunk-7JRF5YEK.js";import{a as j,d as q}from"./chunk-35JTVPOX.js";import{E as d,G as o,H as x,m as O}from"./chunk-LYCLF26R.js";import{b as re}from"./chunk-QYADASLV.js";var oe={};re(oe,{demoShell:()=>ie});function w(h){return Math.max(0,Math.min(1,h))}function ie(h){let E=w(h?.mainRatio??.65),J=w(h?.sideSplit??.5),K=Math.max(0,h?.viewportWidth??1280),F=h?.nodeRegistry??new Map,m=h?.adapter??null,M=h?.layoutFont??"14px monospace",p=h?.onHighlight,t=new B("demo-shell"),D=d(E,{name:"pane/main-ratio"}),L=d(J,{name:"pane/side-split"}),g=d(null,{name:"pane/fullscreen"}),G=d(K,{name:"viewport/width"});t.add(D,{name:"pane/main-ratio"}),t.add(L,{name:"pane/side-split"}),t.add(g,{name:"pane/fullscreen"}),t.add(G,{name:"viewport/width"});let R=o([D,G,g],([e,a,n])=>{let l=e,r=a,i=n;return i==="main"?r:i==="graph"||i==="code"?0:Math.round(r*l)},{name:"pane/main-width"}),C=o([R,G,g],([e,a,n])=>{let l=n,r=a;return l==="main"?0:l==="graph"||l==="code"?r:r-e},{name:"pane/side-width"}),z=o([L,g],([e,a])=>{let n=a;return n==="graph"?1:n==="code"||n==="main"?0:w(e)},{name:"pane/graph-height-ratio"}),Q=o([z,g],([e,a])=>{let n=a;return n==="code"?1:n==="graph"||n==="main"?0:1-e},{name:"pane/code-height-ratio"});t.add(R,{name:"pane/main-width"}),t.add(C,{name:"pane/side-width"}),t.add(z,{name:"pane/graph-height-ratio"}),t.add(Q,{name:"pane/code-height-ratio"});let b=d(null,{name:"demo/graph-ref"}),u=d(0,{name:"demo/graph-tick"});t.add(b,{name:"demo/graph-ref"}),t.add(u,{name:"demo/graph-tick"});let U=o([b,u],([e,a])=>{let n=e;return n?H(n.describe()):""},{name:"graph/mermaid"}),P=o([b,u],([e,a])=>{let n=e;if(!n)return null;let{expand:l,...r}=n.describe({detail:"standard"});return r},{name:"graph/describe"});t.add(U,{name:"graph/mermaid"}),t.add(P,{name:"graph/describe"});let S=d(null,{name:"hover/target"});t.add(S,{name:"hover/target"});let W=o([S],([e])=>{let a=e;if(!a)return null;let n=F.get(a.id);return n?n.codeLine:null},{name:"highlight/code-scroll"}),N=o([S],([e])=>{let a=e;if(!a)return null;let n=F.get(a.id);return n?n.visualSelector:null},{name:"highlight/visual"}),_=o([S],([e])=>{let a=e;return a?a.id:null},{name:"highlight/graph"});if(t.add(W,{name:"highlight/code-scroll"}),t.add(N,{name:"highlight/visual"}),t.add(_,{name:"highlight/graph"}),p?.codeScroll){let e=p.codeScroll,a=x([W],([n])=>{e(n)});t.add(a,{name:"highlight/apply-code-scroll"})}if(p?.visual){let e=p.visual,a=x([N],([n])=>{e(n)});t.add(a,{name:"highlight/apply-visual"})}if(p?.graph){let e=p.graph,a=x([_],([n])=>{e(n)});t.add(a,{name:"highlight/apply-graph"})}let I=d(null,{name:"inspect/selected-node"});t.add(I,{name:"inspect/selected-node"});let X=j("standard"),Y=o([I,b,u],([e,a,n])=>{let l=a,r=e;if(!l||!r)return null;try{let i=l.resolve(r),s=q(i,X);return{path:r,...s,value:i.cache}}catch{return null}},{name:"inspect/node-detail"}),Z=o([b,u],([e,a])=>{let n=e;return n?n.trace():[]},{name:"inspect/trace-log"});t.add(Y,{name:"inspect/node-detail"}),t.add(Z,{name:"inspect/trace-log"});let V=d(!1,{name:"meta/debug"});t.add(V,{name:"meta/debug"});let $=o([V,u],([e,a])=>e?H(t.describe()):"",{name:"meta/shell-mermaid"});t.add($,{name:"meta/shell-mermaid"});let A=d("",{name:"layout/code-text"});if(t.add(A,{name:"layout/code-text"}),m){let e=new Map,a=o([P],([r])=>{let i=r;if(!i)return new Map;let s=new Map;for(let[c]of Object.entries(i.nodes)){let f=T(c,M,m,e),v=k(f,1/0,m,M,e),y=v.lines.reduce((ne,ae)=>Math.max(ne,ae.width),0),te=v.lineCount*20;s.set(c,{width:y,height:te})}return s},{name:"layout/graph-labels",equals:(r,i)=>{if(r===i)return!0;let s=r,c=i;if(s.size!==c.size)return!1;for(let[f,v]of s){let y=c.get(f);if(!y||y.width!==v.width||y.height!==v.height)return!1}return!0}}),n=o([A,C],([r,i])=>{let s=r;if(!s)return{lineCount:0,lines:[]};let c=T(s,M,m,e),f=i-40;return k(c,Math.max(100,f),m,M,e)},{name:"layout/code-lines"}),l=o([a],([r])=>{let i=r;if(i.size===0)return 200;let s=0;for(let{width:c}of i.values())c>s&&(s=c);return Math.max(200,Math.round(s+80))},{name:"layout/side-width-hint"});t.add(a,{name:"layout/graph-labels"}),t.add(n,{name:"layout/code-lines"}),t.add(l,{name:"layout/side-width-hint"})}let ee=0;return{graph:t,setMainRatio(e){t.set("pane/main-ratio",w(e))},setSideSplit(e){t.set("pane/side-split",w(e))},setFullscreen(e){t.set("pane/fullscreen",e)},setViewportWidth(e){t.set("viewport/width",Math.max(0,e))},setHoverTarget(e){t.set("hover/target",e)},setDemoGraph(e){t.set("demo/graph-ref",e)},bumpGraphTick(){t.set("demo/graph-tick",++ee)},selectNode(e){t.set("inspect/selected-node",e)},setMetaDebug(e){t.set("meta/debug",e)},setCodeText(e){t.set("layout/code-text",e)},batch(e){O(e)},destroy(){t.destroy()}}}export{ie as a,oe as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as Q,h as I}from"./chunk-VJJLIEAL.js";import{a as C}from"./chunk-L6NSJVJZ.js";import{i as P}from"./chunk-7JRF5YEK.js";import{b as M}from"./chunk-35JTVPOX.js";import{b as W}from"./chunk-KGKJCHEK.js";import{b as G}from"./chunk-TZQPPQEQ.js";import{b as D}from"./chunk-AU7YTQX7.js";import{C as v,m as L}from"./chunk-IA7DUNGB.js";import{D as x,G as F,m as _,p as m}from"./chunk-LYCLF26R.js";import{b as N,j as $}from"./chunk-CK2E7BTU.js";import{b as X}from"./chunk-QYADASLV.js";var te={};X(te,{JobFlowGraph:()=>w,JobQueueGraph:()=>y,jobEventKeyOf:()=>Z,jobFlow:()=>ee,jobQueue:()=>B});var H=256,Y=1024;function z(i,e){if(!Number.isFinite(i)||!Number.isInteger(i)||i<0)throw new Error(`${e} must be a non-negative integer`);return i}function T(i,e){return C("job_queue",i,e)}var Z=i=>i.action,y=class extends P{_pending;_jobs;_seqCursor;pending;jobs;depth;events;audit;constructor(e,t={}){super(e,t.graph),this._pending=W([],{name:"pending"}),this._jobs=G({name:"jobs"}),this.pending=this._pending.items,this.jobs=this._jobs.entries,this.add(this.pending,{name:"pending"}),this.add(this.jobs,{name:"jobs"}),this.depth=F([this.pending],([o])=>o.length,{name:"depth",describeKind:"derived",meta:T("queue_depth"),initial:0}),this.add(this.depth,{name:"depth"}),this.addDisposer(v(this.depth)),this.events=Q({name:"events",retainedLimit:1024,graph:this}),this.audit=this.events,this._seqCursor=I(this,"seq",0)}_bumpSeq(){let t=(this._seqCursor.cache??0)+1;return this._seqCursor.emit(t),t}attachEventStorage(e){return this.events.attachStorage(e)}enqueue(e,t={}){let o=this._bumpSeq(),n=t.id??`${this.name}-${o}`;if(this._jobs.get(n)!==void 0)throw new Error(`jobQueue("${this.name}"): duplicate job id "${n}"`);let d={id:n,payload:e,attempts:0,metadata:Object.freeze({...t.metadata??{}}),state:"queued"};return this._jobs.set(n,d),this._pending.append(n),this.events.append({action:"enqueue",id:n,payload:e,t_ns:m(),seq:o}),n}claim(e=1){let t=z(e,"job queue claim limit");if(t===0)return[];let o=[];for(;o.length<t&&this.pending.cache.length!==0;){let d=this._pending.pop(0),h=this._jobs.get(d);if(!h||h.state!=="queued")continue;let c={...h,state:"inflight",attempts:h.attempts+1};this._jobs.set(d,c),o.push(c),this.events.append({action:"claim",id:d,attempts:c.attempts,t_ns:m(),seq:this._bumpSeq()})}return o}ack(e){let t=this._jobs.get(e);return!t||t.state!=="inflight"?!1:(this._jobs.delete(e),this.events.append({action:"ack",id:e,attempts:t.attempts,t_ns:m(),seq:this._bumpSeq()}),!0)}nack(e,t={}){let o=this._jobs.get(e);return!o||o.state!=="inflight"?!1:t.requeue??!0?(this._jobs.set(e,{...o,state:"queued"}),this._pending.append(e),this.events.append({action:"nack",id:e,attempts:o.attempts,t_ns:m(),seq:this._bumpSeq()}),!0):(this._jobs.delete(e),this.events.append({action:"nack",id:e,attempts:o.attempts,t_ns:m(),seq:this._bumpSeq()}),!0)}removeById(e){let t=this._jobs.get(e);if(!t)return!1;if(t.state==="queued"){let n=this.pending.cache.indexOf(e);n>=0&&this._pending.pop(n)}return this._jobs.delete(e),this.events.append({action:"remove",id:e,attempts:t.attempts,t_ns:m(),seq:this._bumpSeq()}),!0}consumeFrom(e,t){return e.subscribe(o=>{for(let n of o){if(n[0]!==N)continue;let d=n[1];this.enqueue(d,t?{metadata:t.metadata}:void 0)}})}},w=class extends P{_stageNames;_stageWorkFns;_queues=new Map;_completed;completed;completedCount;constructor(e,t={}){super(e,t.graph);let o=t.stages??["incoming","processing","done"],n=[],d=new Map;for(let s of o){let r=typeof s=="string"?s.trim():s.name.trim();typeof s!="string"&&s.work&&d.set(r,s.work),n.push(r)}if(n.length<2)throw new Error(`jobFlow("${e}"): requires at least 2 stages`);if(new Set(n).size!==n.length)throw new Error(`jobFlow("${e}"): stage names must be unique`);this._stageNames=Object.freeze([...n]),this._stageWorkFns=d;for(let s of this._stageNames){let r=B(`${e}-${s}`);this._queues.set(s,r),this.mount(s,r)}this._completed=D([],{name:"completed",maxSize:Y}),this.completed=this._completed.entries,this.add(this.completed,{name:"completed"}),this.completedCount=F([this.completed],([s])=>s.length,{name:"completedCount",describeKind:"derived",meta:T("job_flow_completed_count"),initial:0}),this.add(this.completedCount,{name:"completedCount"}),this.addDisposer(v(this.completedCount));let c=Math.max(1,z(t.maxPerPump??H,"job flow maxPerPump"));for(let s=0;s<this._stageNames.length;s+=1){let r=this._stageNames[s],p=this.queue(r),j=s+1<this._stageNames.length?this.queue(this._stageNames[s+1]):null,R=this._stageWorkFns.get(r),S=j===null;if(R){let g=x([p.pending],()=>{let l=0;for(;l<c;){let b=p.claim(1);if(b.length===0)break;let a=b[0];if(!a)break;let q=[...a.metadata.job_flow_path??[],r],f;try{f=R(a)}catch{p.nack(a.id,{requeue:!1}),l+=1;continue}let k=L(f),E=!1,u;u=k.subscribe(U=>{if(!E){for(let J of U)if(J[0]===N){E=!0,u?u():Promise.resolve().then(()=>u?.());let A=J[1],O={...a.metadata,job_flow_path:q};if(S){let V={...a,payload:A,metadata:Object.freeze(O)};_(()=>{p.ack(a.id),this._completed.append(V)})}else _(()=>{p.ack(a.id),j.enqueue(A,{metadata:O})});return}else if(J[0]===$){E=!0,u?u():Promise.resolve().then(()=>u?.()),p.nack(a.id,{requeue:!1});return}}}),l+=1}},{name:`pump_${r}`,describeKind:"effect",meta:T("job_flow_pump",{stage:r,has_work:!0})});this.add(g,{name:`pump_${r}`}),this.addDisposer(v(g))}else{let g=x([p.pending],()=>{let l=0;for(;l<c;){let b=p.claim(1);if(b.length===0)break;let a=b[0];if(!a)break;let q=[...a.metadata.job_flow_path??[],r],f={...a.metadata,job_flow_path:q};if(S){let k={...a,metadata:Object.freeze(f)};_(()=>{p.ack(a.id),this._completed.append(k)})}else _(()=>{p.ack(a.id),j.enqueue(a.payload,{metadata:f})});l+=1}},{name:`pump_${r}`,describeKind:"effect",meta:T("job_flow_pump",{stage:r,has_work:!1})});this.add(g,{name:`pump_${r}`}),this.addDisposer(v(g))}}}stages(){return this._stageNames}queue(e){let t=this._queues.get(e);if(!t)throw new Error(`jobFlow("${this.name}"): unknown stage "${e}"`);return t}enqueue(e,t={}){return this.queue(this._stageNames[0]).enqueue(e,t)}retainedCompleted(){return this.completed.cache}};function B(i,e){return new y(i,e)}function ee(i,e){let t=new w(i,e),{factory:o,factoryArgs:n,...d}=e??{};return t.tagFactory("jobFlow",M(d)),t}export{Z as a,y as b,w as c,B as d,ee as e,te as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as w}from"./chunk-R75BMDLA.js";import{a as O}from"./chunk-L6NSJVJZ.js";import{i as R,k as S}from"./chunk-7JRF5YEK.js";import{b as _}from"./chunk-TZQPPQEQ.js";import{C as T}from"./chunk-IA7DUNGB.js";import{E as k,G as x,o as H}from"./chunk-LYCLF26R.js";import{b as M}from"./chunk-QYADASLV.js";var N={};M(N,{LensGraph:()=>C,graphLens:()=>L,watchTopologyTree:()=>w});function v(e){return O("lens",e)}function P(e){let t=Object.keys(e.nodes),o=new Map,n=new Map;for(let s of t){let a=e.nodes[s]?.deps??[];o.set(s,a);for(let h of a)n.has(h)||n.set(h,new Set),n.get(h).add(s)}let r=[],c=[];for(let s of t)(o.get(s)??[]).length===0&&r.push(s),n.has(s)||c.push(s);r.sort(),c.sort();let p=e.edges.length,f=0,m=1,g=2,d=new Map;for(let s of t)d.set(s,f);let y=!1,l=new Map,u=s=>{let a=d.get(s)??f;if(a===m)return y=!0,0;if(a===g)return l.get(s)??0;d.set(s,m);let h=0,b=n.get(s);if(b!=null)for(let F of b){let G=u(F);G+1>h&&(h=G+1)}return d.set(s,g),l.set(s,h),h},i=0;for(let s of r){let a=u(s);a>i&&(i=a)}for(let s of t)d.get(s)===f&&u(s);return{nodeCount:t.length,edgeCount:p,subgraphCount:e.subgraphs.length,sources:r,sinks:c,depth:i,hasCycles:y}}function $(e){let t=[];for(let[o,n]of Object.entries(e.nodes)){if(n.status!=="errored")continue;let r={path:o,status:"errored"},c=S(e,o,"upstream",{});for(let p of c)if(p!==o&&e.nodes[p]?.status==="errored"){r.upstreamCause=p;break}t.push(r)}return t.sort((o,n)=>o.path<n.path?-1:o.path>n.path?1:0),{ok:t.length===0,problems:t}}function E(e,t){return e.nodeCount===t.nodeCount&&e.edgeCount===t.edgeCount&&e.subgraphCount===t.subgraphCount&&e.depth===t.depth&&e.hasCycles===t.hasCycles&&D(e.sources,t.sources)&&D(e.sinks,t.sinks)}function q(e,t){if(e.ok!==t.ok||e.problems.length!==t.problems.length)return!1;for(let o=0;o<e.problems.length;o++){let n=e.problems[o],r=t.problems[o];if(n.path!==r.path||n.status!==r.status||n.upstreamCause!==r.upstreamCause)return!1}return!0}function D(e,t){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(e[o]!==t[o])return!1;return!0}var C=class extends R{stats;health;flow;_target;constructor(t,o={}){super(o.name??`${t.name}_lens`,o.graph),this._target=t;let n=0,r=0,c=k(0,{name:"stats_tick"}),p=k(0,{name:"health_tick"});this.add(c,{name:"stats_tick"}),this.add(p,{name:"health_tick"});let f={name:"flow"};o.maxFlowPaths!=null&&(f.maxSize=o.maxFlowPaths),this.flow=_(f),this.add(this.flow.entries,{name:"flow"});let m=o.pathFilter,g=w(t,(l,u,i)=>{if(n+=1,c.emit(n),r+=1,p.emit(r),l.kind==="removed")if(l.nodeKind==="node"){let s=`${i}${l.name}`;this.flow.delete(s)}else{let s=`${i}${l.name}::`,a=[];for(let h of l.audit.nodes){let b=h===""?`${i}${l.name}`:`${s}${h}`;a.push(b)}a.length>0&&this.flow.deleteMany(a)}});this.addDisposer(g);let d=t.observe({timeline:!0,structured:!0}),y=d.onEvent(l=>{let u=l.type;if((u==="error"||u==="complete"||u==="data"||u==="teardown")&&(r+=1,p.emit(r)),u==="data"){let i=l.path??"";if(!i||m!=null&&!m(i))return;let s=this.flow.get(i),a=s!=null?s.count+1:1;this.flow.set(i,{path:i,count:a,lastUpdate_ns:H()})}});this.addDisposer(()=>{y(),d.dispose()}),this.stats=x([c],()=>P(t.describe({detail:"minimal"})),{name:"stats",describeKind:"derived",equals:E,meta:v("stats")}),this.add(this.stats,{name:"stats"}),this.addDisposer(T(this.stats)),this.health=x([p],()=>$(t.describe({detail:"standard"})),{name:"health",describeKind:"derived",equals:q,meta:v("health")}),this.add(this.health,{name:"health"}),this.addDisposer(T(this.health))}why(t,o,n){let r=this._target.explain(t,o,{reactive:!0,...n});return this.addDisposer(r.dispose),r}get target(){return this._target}};function L(e,t){return new C(e,t)}export{C as a,L as b,N as c};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as we}from"./chunk-SGS4OJGS.js";import{a as Me}from"./chunk-ESMPEKEV.js";import{a as ve,d as ye}from"./chunk-35JTVPOX.js";import{C as ne}from"./chunk-IA7DUNGB.js";import{A as ge,C as M,E as Z,F as me,G as be,e as $e,f as xe,i as Q,k as Ae,l as te,m as Te,o as z,p as Pe,s as U}from"./chunk-LYCLF26R.js";import{b as q,c as le,d as pe,e as ee,f as fe,g as he,h as L,i as H,j as W}from"./chunk-CK2E7BTU.js";function Oe(o,e){if(Object.is(o,e))return!0;if(o==null||e==null||typeof o!="object"||typeof e!="object")return!1;if(Array.isArray(o)){if(!Array.isArray(e)||o.length!==e.length)return!1;for(let r=0;r<o.length;r++)if(!Oe(o[r],e[r]))return!1;return!0}if(Array.isArray(e))return!1;let t=Object.keys(o),n=Object.keys(e);if(t.length!==n.length)return!1;let s=new Set(n);for(let r of t)if(!s.has(r)||!Oe(o[r],e[r]))return!1;return!0}function je(o,e){return`${o}\0${e}`}function _e(o,e){let t=[],n=new Set(o.subgraphs),s=new Set(e.subgraphs),r=[];for(let l of s)n.has(l)||r.push(l);r.sort();for(let l of r)t.push({type:"subgraph-mounted",path:l});let i=new Set(Object.keys(o.nodes)),c=new Set(Object.keys(e.nodes)),d=[];for(let l of c)i.has(l)||d.push(l);d.sort();for(let l of d)t.push({type:"node-added",path:l,node:{...e.nodes[l]}});let a=[];for(let l of c){if(!i.has(l))continue;let O=o.nodes[l]?.meta,m=e.nodes[l]?.meta;O==null&&m==null||Oe(O??{},m??{})||a.push(l)}a.sort();for(let l of a)t.push({type:"node-meta-changed",path:l,prevMeta:o.nodes[l]?.meta??{},nextMeta:e.nodes[l]?.meta??{}});let p=new Map;for(let l of o.edges)p.set(je(l.from,l.to),l);let g=new Map;for(let l of e.edges)g.set(je(l.from,l.to),l);let h=[];for(let[l,O]of g)p.has(l)||h.push(O);h.sort((l,O)=>l.from<O.from?-1:l.from>O.from?1:l.to<O.to?-1:l.to>O.to?1:0);for(let l of h)t.push({type:"edge-added",from:l.from,to:l.to});let f=[];for(let[l,O]of p)g.has(l)||f.push(O);f.sort((l,O)=>l.from<O.from?-1:l.from>O.from?1:l.to<O.to?-1:l.to>O.to?1:0);for(let l of f)t.push({type:"edge-removed",from:l.from,to:l.to});let u=[];for(let l of i)c.has(l)||u.push(l);u.sort();for(let l of u)t.push({type:"node-removed",path:l});let y=[];for(let l of n)s.has(l)||y.push(l);y.sort();for(let l of y)t.push({type:"subgraph-unmounted",path:l});return{events:t,flushedAt_ns:z()}}function Fe(o,e,t,n={}){let s=e in o.nodes,r=t in o.nodes;if(!s)return re(e,t,"no-such-from");if(!r)return re(e,t,"no-such-to");let i=n.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===t){if(n.findCycle===!0){let a=Xe(o,e,n);if(a!=null)return a}let d=se(e,o.nodes[e],0,n);return oe(e,t,[d])}if(i===0)return re(e,t,"no-path");let c=Ie(o,e,t,i);return c.found?oe(e,t,Be(o,c.pathOrder,n)):re(e,t,c.truncated?"max-depth-exceeded":"no-path")}function Ie(o,e,t,n){let s=new Map,r=[{path:t,depth:0}],i=new Set([t]),c=0,d=!1;for(;c<r.length;){let g=r[c++];if(g.path===e)break;if(n!=null&&g.depth>=n){let y=o.nodes[g.path];y?.deps&&y.deps.length>0&&(d=!0);continue}let h=o.nodes[g.path];if(h==null)continue;let f=h.deps??[],u=new Map;for(let y=0;y<f.length;y++){let l=f[y];if(!l)continue;let O=u.get(l);O==null&&(O=[],u.set(l,O)),O.push(y)}for(let[y,l]of u)i.has(y)||(i.add(y),s.set(y,{from:g.path,depIndices:l}),r.push({path:y,depth:g.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:d};let a=[{path:e}],p=e;for(;p!==t;){let g=s.get(p);if(g==null)return{found:!1,pathOrder:[],truncated:!1};a[a.length-1].depIndices=g.depIndices,a.push({path:g.from}),p=g.from}return{found:!0,pathOrder:a,truncated:!1}}function Xe(o,e,t){let n=o.nodes[e];if(n==null)return null;let s=n.deps??[],r=[];for(let c=0;c<s.length;c++)s[c]===e&&r.push(c);if(r.length>0){let c=se(e,n,0,t);c.dep_index=r[0];let d=se(e,n,1,t);return oe(e,e,[c,d])}let i=null;for(let c=0;c<s.length;c++){let d=s[c];if(!d||d===e)continue;let a=Ie(o,d,e,t.maxDepth);a.found&&(i==null||a.pathOrder.length<i.pathOrder.length)&&(i=a,i={found:!0,pathOrder:[{path:e,depIndices:[c]},...a.pathOrder],truncated:!1})}return i==null?null:oe(e,e,Be(o,i.pathOrder,t))}function Be(o,e,t){return e.map((n,s)=>{let r=o.nodes[n.path],i=se(n.path,r,s,t);return n.depIndices!=null&&n.depIndices.length>0&&(i.dep_index=n.depIndices[0],n.depIndices.length>1&&(i.dep_indices=[...n.depIndices])),i})}function se(o,e,t,n){let s={path:o,type:e.type,hop:t};e.status!==void 0&&(s.status=e.status),"value"in e&&(s.value=e.value),e.v!=null&&(s.v=e.v);let r=n.annotations?.get(o)??e.annotation;r!=null&&(s.annotation=r);let i=n.lastMutations?.get(o)??e.lastMutation;return i!=null&&(s.lastMutation=i),s}function oe(o,e,t){return Le(o,e,!0,"ok",t)}function re(o,e,t){return Le(o,e,!1,t,[])}function Le(o,e,t,n,s){let r=et(o,e,t,n,s);return{from:o,to:e,found:t,reason:n,steps:s,text:r,toJSON(){return{from:o,to:e,found:t,reason:n,steps:s}}}}function et(o,e,t,n,s){if(!t)switch(n){case"no-such-from":return`explainPath: no node named "${o}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${o}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${o}" to "${e}"`}let r=[`Causal path: ${o} \u2192 ${e} (${s.length} step(s))`];for(let i of s){let d=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(r.push(d),"value"in i&&r.push(` value: ${tt(i.value)}`),i.annotation!=null&&r.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let a=i.lastMutation.actor;r.push(` actor: ${a.type}${a.id?`:${a.id}`:""}`)}}return r.join(`
|
|
2
|
+
`)}function tt(o){if(o===void 0)return"<sentinel>";if(o===null)return"null";if(typeof o=="string")return JSON.stringify(o);if(typeof o=="number"||typeof o=="boolean"||typeof o=="bigint")return String(o);try{let e=JSON.stringify(o);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(o)}}var A={object:56,array:64,string:40,number:8,boolean:4,null:0,undefined:0,symbol:40,bigint:16,function:120,map:72,set:72,mapEntry:40,setEntry:24,date:24,regexp:48,error:64,url:80,promise:48,weakmap:40,weakset:40},nt=Symbol.for("sizeof");function ze(o){let e=new WeakSet,t=new WeakSet,n=[o],s=0;for(;n.length>0;){let r=n.pop();s+=rt(r,e,t,n)}return s}function rt(o,e,t,n){if(o==null)return 0;switch(typeof o){case"number":return A.number;case"boolean":return A.boolean;case"string":return A.string+o.length*2;case"bigint":return A.bigint+st(o);case"symbol":return A.symbol;case"function":return e.has(o)?0:(e.add(o),A.function);case"undefined":return 0}let r=o;if(e.has(r))return 0;e.add(r);let i=r[nt];if(typeof i=="function")try{let a=i.call(r);if(typeof a=="number"&&Number.isFinite(a))return a}catch{}if(r instanceof Date)return A.date;if(r instanceof RegExp)return A.regexp+r.source.length*2;if(r instanceof Error){let a=r.message?r.message.length*2:0,p=r.stack?r.stack.length*2:0;return A.error+a+p}if(typeof URL<"u"&&r instanceof URL)return A.url+r.href.length*2;if(typeof Promise<"u"&&r instanceof Promise)return A.promise;if(r instanceof WeakMap)return A.weakmap;if(r instanceof WeakSet)return A.weakset;if(r instanceof Map){let a=A.map;for(let[p,g]of r)a+=A.mapEntry,n.push(p),n.push(g);return a}if(r instanceof Set){let a=A.set;for(let p of r)a+=A.setEntry,n.push(p);return a}if(Array.isArray(r)){let a=A.array+r.length*8;for(let p of r)n.push(p);return a}if(r instanceof ArrayBuffer)return t.has(r)?0:(t.add(r),r.byteLength);if(ArrayBuffer.isView(r)){let a=r;return t.has(a.buffer)?48:(t.add(a.buffer),a.buffer.byteLength+48)}let c=A.object,d=Object.keys(r);for(let a of d){c+=A.string+a.length*2;try{n.push(r[a])}catch{}}return c}function st(o){let e=o<0n?-o:o;if(e===0n)return 0;let t=e.toString(2).length;return Math.ceil(t/32)*8}function Ve(o,e){let t=e?.topN??10,n=o.describe({detail:"standard"}),s=[],r=o._collectObserveTargets;typeof r=="function"&&r.call(o,"",s);let i=new Map;for(let[h,f]of s)i.set(h,f);let c=[];for(let[h,f]of Object.entries(n.nodes)){let u=i.get(h),y=u instanceof M?u:null,l=y?ze(y.cache):0,O=y?y._sinkCount:0,m=f.deps?.length??0,b=f.type==="effect"&&O===0,v=O===0?f.type==="effect"?"orphan-effect":f.type==="derived"?"idle-derived":f.type==="producer"?"idle-producer":null:null;c.push({path:h,type:f.type,status:f.status??"unknown",valueSizeBytes:l,subscriberCount:O,depCount:m,isOrphanEffect:b,orphanKind:v})}let d=c.reduce((h,f)=>h+f.valueSizeBytes,0),a=(h,f)=>[...c].sort(f??((u,y)=>y[h]-u[h])).slice(0,t),p=c.filter(h=>h.orphanKind!=null),g=c.filter(h=>h.isOrphanEffect);return{nodeCount:c.length,edgeCount:n.edges.length,subgraphCount:n.subgraphs.length,nodes:c,totalValueSizeBytes:d,hotspots:{byValueSize:a("valueSizeBytes"),bySubscriberCount:a("subscriberCount"),byDepCount:a("depCount")},orphans:p,orphanEffects:g}}var $="::",B="__meta__",J=1;function qe(o,e){let t=Math.max(16,o.size*4),n=0;for(;o.size>0;){if(n++>=t){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${t}); ${o.size} disposer(s) discarded`),o.clear();return}let s=o.values().next();if(s.done)return;let r=s.value;o.delete(r);try{r()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function Ye(o){return o!=null&&typeof o=="object"&&"cache"in o&&typeof o.subscribe=="function"&&typeof o.down=="function"}function ot(o){if(o!=null)return Ye(o)?o.cache:o}function K(o){return o!=null&&typeof o=="object"&&"cache"in o&&typeof o.subscribe=="function"&&typeof o.down=="function"}function V(o){return K(o)?o.cache??"":o}function Ke(o){return K(o)?o.cache??0:o}function He(o){return K(o)?o.cache??!1:o}function it(o){let e=[];for(let t of Object.keys(o).sort()){let n=o[t].v;n!=null&&e.push(`${t} ${n.id} ${n.version}`)}return e.join(`
|
|
3
|
+
`)}function We(o){if(o.version!==J)throw new Error(`unsupported snapshot version ${String(o.version)} (expected ${J})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in o))throw new Error(`snapshot missing required key "${e}"`);if(typeof o.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof o.nodes!="object"||o.nodes===null||Array.isArray(o.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(o.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(o.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function at(o,e){let t=new WeakMap,n=(s,r)=>{if(Object.is(s,r))return!0;if(s==null||r==null||typeof s!="object"||typeof r!="object")return!1;let i=t.get(s);if(i==null&&(i=new WeakSet,t.set(s,i)),i.has(r))return!0;i.add(r);let c=s.constructor,d=r.constructor;if(c!==d)return!1;if(s instanceof Date)return s.getTime()===r.getTime();if(s instanceof RegExp)return s.source===r.source&&s.flags===r.flags;if(Array.isArray(s)){let h=r;if(s.length!==h.length)return!1;for(let f=0;f<s.length;f++)if(!n(s[f],h[f]))return!1;return!0}if(s instanceof Map){let h=r;if(s.size!==h.size)return!1;for(let[f,u]of s)if(!h.has(f)||!n(u,h.get(f)))return!1;return!0}if(s instanceof Set){let h=r;if(s.size!==h.size)return!1;for(let f of s){let u=!1;for(let y of h)if(n(f,y)){u=!0;break}if(!u)return!1}return!0}if(ArrayBuffer.isView(s)){let h=s,f=r;if(h.length!==f.length)return!1;for(let u=0;u<h.length;u++)if(h[u]!==f[u])return!1;return!0}let a=Object.keys(s),p=Object.keys(r);if(a.length!==p.length)return!1;let g=new Set(p);for(let h of a)if(!g.has(h)||!n(s[h],r[h]))return!1;return!0};return n(o,e)}function ut(o){return o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ie(o){let e="^";for(let t=0;t<o.length;t+=1){let n=o[t];if(n==="*"){e+=".*";continue}if(n==="?"){e+=".";continue}if(n==="["){let s=o.indexOf("]",t+1);if(s<=t+1){e+="\\[";continue}let r=o.slice(t+1,s);r.startsWith("!")&&(r=`^${r.slice(1)}`),r=r.replace(/\\/g,"\\\\"),e+=`[${r}]`,t=s;continue}e+=ut(n)}return e+="$",new RegExp(e)}var ct={data:"\x1B[32m",dirty:"\x1B[33m",resolved:"\x1B[36m",invalidate:"\x1B[93m",pause:"\x1B[90m",resume:"\x1B[96m",complete:"\x1B[34m",error:"\x1B[31m",teardown:"\x1B[91m",derived:"\x1B[35m",path:"\x1B[90m",reset:"\x1B[0m"},dt={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function Ee(o){if(typeof o=="string")return JSON.stringify(o);if(typeof o=="number"||typeof o=="boolean"||o==null)return String(o);try{return JSON.stringify(o)}catch{return"[unserializable]"}}function lt(o){return o==="none"?dt:o==="ansi"||o==null?ct:{data:o.data??"",dirty:o.dirty??"",resolved:o.resolved??"",invalidate:o.invalidate??"",pause:o.pause??"",resume:o.resume??"",complete:o.complete??"",error:o.error??"",teardown:o.teardown??"",derived:o.derived??"",path:o.path??"",reset:o.reset??""}}function Ue(o){if(o==null)return{};let e=o.detail;return e==="full"?{...o,structured:o.structured??!0,timeline:o.timeline??!0,causal:o.causal??!0,derived:o.derived??!0}:e==="minimal"?{...o,structured:o.structured??!0}:o.format==="stage-log"?{...o,structured:o.structured??!0,timeline:o.timeline??!0}:o}function pt(o,e,t){for(let n=0;n<o.length;n++){let s=o.charCodeAt(n);if(s<32||s===127)throw new Error(`Graph "${e}": ${t} "${o}" must not contain control character (U+${s.toString(16).padStart(4,"0").toUpperCase()} at index ${n})`)}}function ke(o,e,t){if(o==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(o.includes($))throw new Error(`Graph "${e}": ${t} "${o}" must not contain '${$}' (path separator)`);if(o===B)throw new Error(`Graph "${e}": ${t} name "${B}" is reserved for meta companion paths`);pt(o,e,t)}function ft(o,e){if(o==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=o.split($);for(let n of t)if(n==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function ht(o,e){let t=!1;for(let s of o)if(!e.isMetaPassthrough(s[0])){t=!0;break}return t?o.filter(s=>e.isMetaPassthrough(s[0])):o}function Qe(o){for(let e of o._mounts.values())Qe(e);for(let e of o._nodes.values())try{e.down([[L]],{internal:!0})}catch{}}var Se=class o{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;_factory;_factoryArgs;constructor(e,t){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes($))throw new Error(`Graph name must not contain '${$}' (got "${e}")`);if(e===B)throw new Error(`Graph name "${B}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??ge,this._traceRing=new we(t?.traceCapacity??1e3),t?.versioning!=null&&this.setVersioning(t.versioning),typeof t?.factory=="string"&&(this._factory=t.factory,t.factoryArgs!==void 0&&(this._factoryArgs=t.factoryArgs))}tagFactory(e,t){return this._factory=e,this._factoryArgs=t,this}ancestors(e=!0){let t=[],n=e?this:this._parent;for(;n!=null;)t.push(n),n=n._parent;return t}get topology(){return this._topology==null&&(this._topology=me(e=>{let t=n=>{e.emit(n)};return this._topologyEmitters.add(t),()=>{this._topologyEmitters.delete(t)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let t of this._topologyEmitters)t(e)}nameOf(e){return this._nodeToName.get(e)}add(e,t){let n=e.name,s=t?.name??n;if(s==null||s==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let r=s,i=t?.annotation;if(ke(r,this.name,"add"),this._mounts.has(r))throw new Error(`Graph "${this.name}": name "${r}" is already a mount point`);if(this._nodes.has(r))throw new Error(`Graph "${this.name}": node "${r}" already exists`);let c=this._nodeToName.get(e);if(c!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${c}"`);return this._nodes.set(r,e),this._nodeToName.set(e,r),this._emitTopology({kind:"added",name:r,nodeKind:"node"}),i!=null&&(this._annotations.set(r,i),this.config.inspectorEnabled&&this._traceRing.push({path:r,annotation:i,timestamp_ns:z()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof M&&t._applyVersioning(e)}remove(e){ke(e,this.name,"remove");let t=this._mounts.get(e);if(t){let r={kind:"mount",nodes:[],mounts:[]},i=[];t._collectObserveTargets("",i);for(let[c,d]of i)c.includes(`${$}${B}${$}`)||r.nodes.push(c);return r.nodes.sort(),r.mounts.push(e),r.mounts.push(...t._collectSubgraphs(`${e}${$}`)),this._mounts.delete(e),t._parent=void 0,Qe(t),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:r}),r}let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(n),n.down([[L]],{internal:!0});let s={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:s}),s}removeAll(e){let t=typeof e=="function"?e:(()=>{let r=ie(e);return i=>r.test(i)})(),n={kind:"mount",nodes:[],mounts:[]},s=[...this._nodes.keys(),...this._mounts.keys()].filter(r=>t(r));for(let r of s){let i=this.remove(r);n.nodes.push(...i.nodes),n.mounts.push(...i.mounts)}return n.nodes.sort(),n.mounts.sort(),n}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),t=this._nodes,n=0;return{[Symbol.iterator](){return this},next(){if(n>=e.length)return{value:void 0,done:!0};let s=e[n++];return{value:[s,t.get(s)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes($))return this.resolve(e);let t=this._nodes.get(e);if(!t)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return t}get(e){return this.node(e).cache}set(e,t,n){let s=n?.internal===!0;this.node(e).down([[q,t]],{actor:n?.actor,internal:s,delivery:"write"})}setAll(e,t){let n=Symbol.iterator in e?e:Object.entries(e);Te(()=>{for(let[s,r]of n)this.set(s,r,t)})}invalidate(e,t){let n=t?.internal===!0;this.node(e).down([[ee]],{actor:t?.actor,internal:n,delivery:"write"})}error(e,t,n){let s=n?.internal===!0;this.node(e).down([[W,t]],{actor:n?.actor,internal:s,delivery:"write"})}complete(e,t){let n=t?.internal===!0;this.node(e).down([[H]],{actor:t?.actor,internal:n,delivery:"write"})}edges(e){let t=e?.recursive===!0,n=new Map;if(!t){for(let[d,a]of this._nodes)n.set(a,d);let c=[];for(let[d,a]of this._nodes)if(a instanceof M)for(let p of a._deps){let g=n.get(p.node);g!=null&&c.push([g,d])}return c.sort((d,a)=>d[0]<a[0]?-1:d[0]>a[0]?1:d[1]<a[1]?-1:d[1]>a[1]?1:0),c}let s=[];this._collectObserveTargets("",s);let r=new Map;for(let[c,d]of s)r.set(d,c);let i=[];for(let[c,d]of s)if(d instanceof M)for(let a of d._deps){let p=r.get(a.node);p!=null&&i.push([p,c])}return i.sort((c,d)=>c[0]<d[0]?-1:c[0]>d[0]?1:c[1]<d[1]?-1:c[1]>d[1]?1:0),i}mount(e,t){if(t===void 0){let s=new o(e);return this.mount(e,s)}if(typeof t=="function"){let s=new o(e);return t(s),this.mount(e,s)}let n=t;if(ke(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let s=this;s!=null;s=s._parent)if(s===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let t=ft(e,this.name);return this._resolveFromSegments(t)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let t=e;if(t[0]===this.name&&(t=t.slice(1),t.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let n=t[0],s=t.slice(1);if(s.length===0){let c=this._nodes.get(n);if(c)return c;throw this._mounts.has(n)?new Error(`Graph "${this.name}": path ends at subgraph "${n}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${n}"`)}let r=this._nodes.get(n);if(r&&s.length>0&&s[0]===B)return this._resolveMetaChainFromNode(r,s,t.join($));let i=this._mounts.get(n);if(!i)throw this._nodes.has(n)?new Error(`Graph "${this.name}": "${n}" is a node; trailing path "${s.join($)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${n}"`);return i.resolve(s.join($))}_resolveMetaChainFromNode(e,t,n){let s=e,r=0,i=[...t];for(;r<i.length;){if(i[r]!==B)throw new Error(`Graph "${this.name}": expected ${B} segment in meta path "${n}"`);if(r+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${B} in "${n}"`);let c=i[r+1],d=s.meta[c];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${c}" in path "${n}"`);s=d,r+=2}return s}signal(e,t){if(t?.internal!==!0){for(let s of e)if(this.config.messageTier(s[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let n=[];if(this._signalDeliver(e,t??{},new Set,n),n.length>0)throw n[0]}_signalDeliver(e,t,n,s){for(let d of this._mounts.values())d._signalDeliver(e,t,n,s);let i=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},c=ht(e,this.config);for(let d of[...this._nodes.keys()].sort()){let a=this._nodes.get(d);if(!n.has(a)){n.add(a);try{a.down(e,i)}catch(p){if(p instanceof U)throw p;s.push(p)}c.length!==0&&this._signalMetaSubtree(a,c,n,i,s)}}}_signalMetaSubtree(e,t,n,s,r){for(let i of Object.keys(e.meta).sort()){let c=e.meta[i];if(!n.has(c)){n.add(c);try{c.down(t,s)}catch(d){if(d instanceof U)throw d;r.push(d)}this._signalMetaSubtree(c,t,n,s,r)}}}describe(e){if(e?.reactive==="diff")return this._describeReactiveDiff(e);if(e?.reactive===!0)return this._describeReactive(e);let t=ot(e?.actor),n=e?.filter;if(e?.detail!=null&&e?.fields!=null)throw new TypeError("Graph.describe(): pass either `detail` or `fields`, not both. `detail: 'spec'` is the canonical spec projection; use `fields` only when you need a custom subset.");let s=ve(e?.detail,e?.fields),r=e?.detail==="spec",i=s,c=[];this._collectObserveTargets("",c);let d=new Map;for(let[v,w]of c)d.set(w,v);let a=[];{let v=c.map(([,S])=>S),w=new Set(d.values()),E=0;for(;v.length>0;){let S=v.shift();if(S instanceof M)for(let R of S._deps){let G=R.node;if(d.has(G))continue;let D=G.name??"",k=D;if(!k||w.has(k))if(D){let I=2;for(;w.has(`${D}#${I}`);)I++;k=`${D}#${I}`}else for(k=`__internal__/${E++}`;w.has(k);)k=`__internal__/${E++}`;d.set(G,k),w.add(k),a.push([k,G]),v.push(G)}}}let p=[...c,...a],g={};for(let[v,w]of p){if(t!=null&&!w.allowsObserve(t))continue;let E=ye(w,i,r),S=w instanceof M?w._deps.map(k=>d.get(k.node)??k.node.name??""):[],{name:R,...G}=E,D={...G,deps:S};if(!r){let k=this._annotations.get(v);k!=null&&(D.annotation=k)}if(n!=null)if(typeof n=="function"){let k=n;if(!(k.length>=2?k(v,D):k(D)))continue}else{let k=!0;for(let[I,T]of Object.entries(n)){let x=I==="deps_includes"?"depsIncludes":I==="meta_has"?"metaHas":I;if(x==="depsIncludes"){if(!D.deps.includes(String(T))){k=!1;break}continue}if(x==="metaHas"){if(!Object.hasOwn(D.meta??{},String(T))){k=!1;break}continue}if(D[x]!==T){k=!1;break}}if(!k)continue}g[v]=D}let h=new Set(Object.keys(g)),f=[];for(let[v,w]of p)if(w instanceof M)for(let E of w._deps){let S=d.get(E.node);S!=null&&f.push([S,v])}f.sort((v,w)=>v[0]<w[0]?-1:v[0]>w[0]?1:v[1]<w[1]?-1:v[1]>w[1]?1:0);let u=f.map(([v,w])=>({from:v,to:w}));(t!=null||n!=null)&&(u=u.filter(v=>h.has(v.from)&&h.has(v.to)));let y=this._collectSubgraphs(""),l=t!=null||n!=null?y.filter(v=>{let w=`${v}${$}`;return[...h].some(E=>E===v||E.startsWith(w))}):y,O=this,m=e;return{name:this.name,nodes:g,edges:u,subgraphs:l,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(v){let w={...m};return Array.isArray(v)?(w.fields=v,w.detail=void 0):(w.detail=v,w.fields=void 0),O.describe(w)}}}_collectSubgraphs(e){let t=[];for(let n of[...this._mounts.keys()].sort()){let s=e===""?n:`${e}${n}`;t.push(s),t.push(...this._mounts.get(n)._collectSubgraphs(`${s}${$}`))}return t}resourceProfile(e){return Ve(this,e)}reachable(e,t,n={}){return n.withDetail===!0?Je(this.describe(),e,t,{...n,withDetail:!0}):Je(this.describe(),e,t,n)}explain(e,t,n){return n?.reactive===!0?this._explainReactive(e,t,n):this._explainStatic(V(e),V(t),{...n?.maxDepth!==void 0?{maxDepth:Ke(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:He(n.findCycle)}:{}})}_explainStatic(e,t,n){let s=this.describe({detail:"full"}),r=new Map(this._annotations),i=new Map;for(let[c,d]of Object.entries(s.nodes))d.lastMutation!=null&&i.set(c,d.lastMutation);return Fe(s,e,t,{...n?.maxDepth!=null?{maxDepth:n.maxDepth}:{},...n?.findCycle===!0?{findCycle:!0}:{},annotations:r,lastMutations:i})}_describeReactive(e){let t={...e,reactive:!1},n=e.reactiveName??"describe",s=0,r=Z(s,{name:`${n}_version`}),i=this.observe({timeline:!0,structured:!0}),c=!1,d=!1,a=()=>{c||d||(c=!0,te(()=>{c=!1,!d&&(s+=1,r.emit(s))}))},p=i.onEvent(m=>{let b=m.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||a()}),g=[],h=new WeakSet,f=m=>{if(h.has(m)||d)return;h.add(m);let b=m.topology.subscribe(v=>{for(let w of v){if(w[0]!==q)continue;let E=w[1];if(a(),E.kind==="added"&&E.nodeKind==="mount"){let S=m._mounts.get(E.name);S!=null&&f(S)}}});g.push(b);for(let v of m._mounts.keys()){let w=m._mounts.get(v);w!=null&&f(w)}};f(this);let u,y=e.actor;Ye(y)&&(u=y.subscribe(m=>{let b=!1,v=!1;for(let w of m){let E=w[0];E===q?b=!0:(E===H||E===W||E===L)&&(v=!0)}b&&a(),v&&(u?.(),u=void 0,a())}));let l;try{l=be([r],()=>this.describe(t),{name:n,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(m,b)=>m===b})}catch(m){p(),u?.();for(let b of g)b();throw i.dispose(),m}let O=ne(l);return{node:l,dispose(){d=!0,p(),u?.();for(let m of g)m();g.length=0,i.dispose(),O()}}}_describeReactiveDiff(e){let t={...e,reactive:!1},n=e.reactiveName??"describe-diff",s={name:this.name,nodes:{},edges:[],subgraphs:[]},r=this.describe(t),i=_e(s,r),c=Z(i,{name:n,meta:{domain:"audit",kind:"describe-diff"},equals:(h,f)=>h===f}),d=this._describeReactive({...e,reactiveName:void 0}),a=!1,p=d.node.subscribe(h=>{if(!a)for(let f of h){if(f[0]!==q)continue;let u=f[1],y=_e(r,u);r=u,y.events.length!==0&&c.emit(y)}}),g=ne(c);return{node:c,dispose(){a=!0,p(),d.dispose(),c.down([[L,"describe-diff disposed"]]),g()}}}_explainReactive(e,t,n){let s=0,r=Z(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),c=!1,d=!1,a=()=>{c||d||(c=!0,te(()=>{c=!1,!d&&(s+=1,r.emit(s))}))},p=i.onEvent(m=>{let b=m.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||a()}),g=[];e!=null&&K(e)&&g.push(e),t!=null&&K(t)&&g.push(t),n?.maxDepth!=null&&K(n.maxDepth)&&g.push(n.maxDepth),n?.findCycle!=null&&K(n.findCycle)&&g.push(n.findCycle);let h=()=>{for(let m of g)if(m.cache===void 0)return!1;return!0},f=()=>{let m=V(e),b=V(t);return{from:m,to:b,found:!1,reason:"pending",steps:[],text:"(awaiting reactive args)",toJSON:()=>({from:m,to:b,found:!1,reason:"pending",steps:[]})}},u;try{u=be([r],()=>{if(!h())return f();let m=V(e),b=V(t),v={...n?.maxDepth!==void 0?{maxDepth:Ke(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:He(n.findCycle)}:{}};return this._explainStatic(m,b,v)},{name:n?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:V(e),to:V(t)},equals:(m,b)=>m.found===b.found&&m.reason===b.reason&&m.steps.length===b.steps.length&&mt(m.steps,b.steps)})}catch(m){throw p(),i.dispose(),m}let y=ne(u),l=[],O=m=>{let b;return b=m.subscribe(v=>{let w=!1,E=!1;for(let S of v){let R=S[0];R===q?w=!0:(R===H||R===W||R===L)&&(E=!0)}(w||E)&&a(),E&&b&&(b(),b=void 0)}),()=>{b&&(b(),b=void 0)}};for(let m of g)l.push(O(m));return{node:u,dispose(){d=!0,p();for(let m of l)m?.();l.length=0,i.dispose(),y()}}}_pathsMatching(e){let t=ie(e),n=[];return this._collectObserveTargets("",n),n.map(([s])=>s).filter(s=>t.test(s))}_collectObserveTargets(e,t){for(let n of[...this._mounts.keys()].sort()){let s=e===""?n:`${e}${$}${n}`;this._mounts.get(n)._collectObserveTargets(s,t)}for(let n of[...this._nodes.keys()].sort()){let s=this._nodes.get(n),r=e===""?n:`${e}${$}${n}`;t.push([r,s]),this._appendMetaObserveTargets(r,s,t)}}_appendMetaObserveTargets(e,t,n){for(let s of Object.keys(t.meta).sort()){let r=t.meta[s],i=`${e}${$}${B}${$}${s}`;n.push([i,r]),this._appendMetaObserveTargets(i,r,n)}}observe(e,t){let n=typeof e=="string",r=Ue(n?t:e);if(r.reactive===!0)return this._observeReactive(n?e:void 0,r);let i=r.structured===!0||r.timeline===!0||r.causal===!0||r.derived===!0||r.detail==="minimal"||r.detail==="full"||r.format!=null,c=r.actor;if(n){let p=e,g=this.resolve(p);if(c!=null&&!g.allowsObserve(c))throw new U({actor:c,action:"observe",nodeName:p});return i?this._buildStructuredObserver([[p,g]],r,"one"):{subscribe(h){return g.subscribe(h)},up(h){try{g.up?.(h)}catch(f){if(f instanceof U)return;throw f}}}}let d=[];this._collectObserveTargets("",d),d.sort((p,g)=>p[0]<g[0]?-1:p[0]>g[0]?1:0);let a=c==null?d:d.filter(([,p])=>p.allowsObserve(c));return i?this._buildStructuredObserver(a,r,"all"):{subscribe:p=>{let g=a.map(([h,f])=>f.subscribe(u=>{p(h,u)}));return()=>{for(let h of g)h()}},up:(p,g)=>{try{this.resolve(p).up?.(g)}catch(h){if(h instanceof U)return;throw h}}}}_observeReactive(e,t){let n=t.tiers,s=n!=null?new Set(n):null,r=t.reactiveName??"observe";return me(i=>{let c=[],d=!1,a=!1,p=()=>{if(c.length===0||a)return;let y={events:c.slice(),flushedAt_ns:z()};c.length=0,i.emit(y)},g={...t,reactive:!1,structured:!0,timeline:!0},h=e!=null?this.observe(e,g):this.observe(g),f=y=>{a||(c.push(y),!d&&(d=!0,te(()=>{d=!1,p()})))};for(let y of h.events)f(y);let u=h.onEvent(f);return()=>{a=!0,u(),h.dispose()}},{name:r,meta:{domain:"audit",kind:"observe-reactive"}})}_buildStructuredObserver(e,t,n){let s=n==="one"?e[0]?.[0]:void 0,r=i=>{if(n==="one"&&s!=null){let p=this.resolve(s);return this._buildStructuredObserver([[s,p]],i,"one")}let c=[];this._collectObserveTargets("",c),c.sort((p,g)=>p[0]<g[0]?-1:p[0]>g[0]?1:0);let d=i.actor,a=d==null?c:c.filter(([,p])=>p.allowsObserve(d));return this._buildStructuredObserver(a,i,"all")};return this._createObserveResult(e,t,r)}_createObserveResult(e,t,n){let s=t.timeline===!0,r=t.causal===!0,i=t.derived===!0,c=t.detail==="minimal",d=this.config.inspectorEnabled,a=(r||i)&&d,p=t.maxEvents,g=p!=null&&p>0?new we(p):null,h=[],f=new Set,u=t.tiers!=null?new Set(t.tiers):null,y={},l=new Set,O=0,m=0,b=0,v=0,w=0,E=0,S=!1,R=!1,G=0,D=new Map,k=new Map,I=new Map,T=_=>{if(!(u!=null&&!u.has(_.type))){g?g.push(_):h.push(_);for(let C of f)C(_)}},x=_=>u==null||u.has(_),Re=()=>s?{timestamp_ns:z(),in_batch:Ae(),batch_id:G}:{},Ze=(_,C)=>{if(!(!a||!(_ instanceof M)))return _._setInspectorHook(j=>{if(j.kind==="dep_message")D.set(_,j.depIndex);else if(j.kind==="run"){let Y=j.batchData.map((N,P)=>N!=null&&N.length>0?N.at(-1):j.prevData[P]);k.set(_,Y);let F=j.batchData.map(N=>N!=null?[...N]:void 0);I.set(_,F),i&&T({type:"derived",path:C,dep_values:Y,dep_batches:F,...Re()})}})},Ne=_=>{let C=D.get(_),j=k.get(_);if(!r||j==null)return{};let F=(C!=null&&C>=0&&_ instanceof M?_._deps[C]:void 0)?.node,N=F?.v,P=I.get(_);return{trigger_dep_index:C,trigger_dep_name:F?.name,...N!=null?{trigger_version:{id:N.id,version:N.version}}:{},dep_values:[...j],...P!=null?{dep_batches:P}:{}}},Ge=[],De=[];for(let[_,C]of e){let j=Ze(C,_);j&&Ge.push(j),De.push(C.subscribe(Y=>{G++;for(let F of Y){let N=F[0],P=Re();if(N===q){y[_]=F[1];let de=C instanceof M?C.lastMutation?.actor??Q:Q;T({type:"data",path:_,data:F[1],actor:de,...P,...Ne(C)})}else if(c)N===le?x("dirty")&&O++:N===pe?x("resolved")&&m++:N===ee?x("invalidate")&&b++:N===fe?x("pause")&&v++:N===he?x("resume")&&w++:N===L?x("teardown")&&E++:N===H&&!l.has(_)?x("complete")&&(S=!0):N===W&&x("error")&&(R=!0,l.add(_));else if(N===le)x("dirty")&&O++,T({type:"dirty",path:_,...P});else if(N===pe)x("resolved")&&m++,T({type:"resolved",path:_,...P,...Ne(C)});else if(N===ee)x("invalidate")&&b++,T({type:"invalidate",path:_,...P});else if(N===fe)x("pause")&&v++,T({type:"pause",path:_,lockId:F[1],...P});else if(N===he)x("resume")&&w++,T({type:"resume",path:_,lockId:F[1],...P});else if(N===H)x("complete")&&!l.has(_)&&(S=!0),T({type:"complete",path:_,...P});else if(N===W){x("error")&&(R=!0,l.add(_));let de=C instanceof M?C.lastMutation?.actor??Q:Q;T({type:"error",path:_,data:F[1],actor:de,...P})}else N===L&&(x("teardown")&&E++,T({type:"teardown",path:_,...P}))}}))}let ae=!1,ue=()=>{if(!ae){ae=!0;for(let _ of De)_();for(let _ of Ge)_();for(let _ of X)_({value:void 0,done:!0});X.length=0}},ce=[],X=[];f.add(_=>{let C=X.shift();C?C({value:_,done:!1}):ce.push(_)});let Ce={get values(){return y},get dirtyCount(){return O},get resolvedCount(){return m},get invalidateCount(){return b},get pauseCount(){return v},get resumeCount(){return w},get teardownCount(){return E},get events(){return g?g.toArray():[...h]},get anyCompletedCleanly(){return S},get anyErrored(){return R},get completedWithoutErrors(){return S&&!R},onEvent(_){return f.add(_),()=>f.delete(_)},dispose:ue,expand(_){ue();let C={...t};return typeof _=="string"?C.detail=_:Object.assign(C,_),n(Ue(C))},[Symbol.asyncIterator](){return{next(){return ce.length>0?Promise.resolve({value:ce.shift(),done:!1}):ae?Promise.resolve({value:void 0,done:!0}):new Promise(_=>X.push(_))},return(){return ue(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(Ce,t),Ce}_attachFormatLogger(e,t){let n=t.format;if(n==null)return;let s=t.logger??(u=>console.log(u)),r=t.includeTypes?new Set(t.includeTypes):null,i=t.excludeTypes?new Set(t.excludeTypes):null,c=r==null&&i==null?()=>!0:u=>(r==null||r.has(u))&&(i==null||!i.has(u)),d=lt(t.theme),a=n==="stage-log"?z():0,p=u=>u==null?"":t.stageLabels?.[u]??u,g=(u,y)=>u.length>y?`${u.slice(0,y-1)}\u2026`:u,h=u=>u.type==="data"||u.type==="error"?g(Ee(u.data),120):"",f=u=>{if(n==="stage-log"){let S=(z()-a)/1e9,R=p(u.path).padEnd(9);if(u.type==="data"){let G=h(u);return`[${S.toFixed(3)}s] ${R} \u2190${G?` ${G}`:""}`}if(u.type==="error"){let G=h(u);return`[${S.toFixed(3)}s] ${R} \u2717${G?` ${G}`:""}`}return u.type==="complete"?`[${S.toFixed(3)}s] ${R} \u25A0 complete`:`[${S.toFixed(3)}s] ${R} ${u.type}`}if(n==="json")try{return JSON.stringify(u)}catch{return JSON.stringify({type:u.type,path:u.path,data:"[unserializable]"})}let y=d[u.type]??"",l=u.path?`${d.path}${u.path}${d.reset} `:"",O=u.type==="data"||u.type==="error",m=u.type==="pause"||u.type==="resume",b=O?` ${Ee(u.data)}`:m?` ${Ee(u.lockId)}`:"",v=u.type==="data"||u.type==="resolved"||u.type==="derived"?u:void 0,w=v?.trigger_dep_name!=null?` <- ${v.trigger_dep_name}`:v?.trigger_dep_index!=null?` <- #${v.trigger_dep_index}`:"",E=u.in_batch?" [batch]":"";return`${l}${y}${u.type.toUpperCase()}${d.reset}${b}${w}${E}`};e.onEvent(u=>{c(u.type)&&s(f(u),u)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){qe(this._disposers,this.name),this.signal([[L]],{internal:!0}),qe(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand:t,...n}=this.describe({detail:"full"}),s={};for(let c of Object.keys(n.nodes).sort()){let{lastMutation:d,guard:a,...p}=n.nodes[c];s[c]=p}let r=[...n.subgraphs].sort(),i={...n,version:1,nodes:s,subgraphs:r};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let c=this.config.lookupCodec(e.codec);if(c==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return $e(c,c.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let n=t?.config??ge,{codec:s,codecVersion:r,payload:i}=xe(e,n);return s.decode(i,r)}restore(e,t){if(We(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let n=t?.only==null?null:(Array.isArray(t.only)?t.only:[t.only]).map(r=>ie(r)),s=t?.includeProducers===!0;for(let r of Object.keys(e.nodes).sort()){if(n!==null&&!n.some(c=>c.test(r)))continue;let i=e.nodes[r];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&t?.onError?.(r,new Error(`restore: slice.value is undefined for "${r}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!s)){if(i.v!=null){let d=this.tryResolve(r)?.v;if(d!=null&&d.id===i.v.id&&d.version===i.v.version)continue}try{this.set(r,i.value)}catch(c){t?.onError?.(r,c)}}}}}static fromSnapshot(e,t){We(e);let n=typeof t=="function"?t:t?.build,s=typeof t=="function"?void 0:t?.factories,r=new o(e.name);if(n)return n(r),r.restore(e),r;for(let f of[...e.subgraphs].sort((u,y)=>{let l=u.split($).length,O=y.split($).length;return l!==O?l-O:u<y?-1:u>y?1:0})){let u=f.split($),y=r;for(let l of u)y._mounts.has(l)||y.mount(l,new o(l)),y=y._mounts.get(l)}let i=s?Object.entries(s).map(([f,u])=>({re:ie(f),factory:u})):[],c=f=>{for(let u of i)if(u.re.test(f))return u.factory},d=f=>{let u=f.split($),y=u.pop();if(y==null||y.length===0)throw new Error(`invalid snapshot path "${f}"`);let l=r;for(let O of u){let m=l._mounts.get(O);if(!m)throw new Error(`unknown mount "${O}" in path "${f}"`);l=m}return[l,y]},a=Object.entries(e.nodes).filter(([f])=>!f.includes(`${$}${B}${$}`)).sort((f,u)=>f[0]<u[0]?-1:f[0]>u[0]?1:0),p=new Map(a),g=new Map,h=!0;for(;p.size>0&&h;){h=!1;for(let[f,u]of[...p.entries()]){let y=u?.deps??[];if(!y.every(w=>g.has(w)))continue;let[l,O]=d(f),m={...u?.meta??{}},b=c(f),v;if(u?.type==="state")v=Z(u.value,{meta:m});else{if(b==null)continue;v=b(O,{path:f,type:u.type,value:u.value,meta:m,deps:y,resolvedDeps:y.map(w=>g.get(w))})}l.add(v,{name:O}),g.set(f,v),p.delete(f),h=!0}}if(p.size>0){let f=[...p.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${f}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return r.restore(e),r}toJSON(){return this.snapshot()}attachSnapshotStorage(e,t={}){let n=e.map(a=>({tier:a,debounceMs:Math.max(0,a.debounceMs??0),compactEvery:Math.max(1,a.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));t.autoRestore===!0&&this._cascadeRestore(e,t.onError);let s=(a,p)=>{if(a.disposed)return;let g=it(p.nodes);if(a.lastSnapshot!=null&&g!==""&&g===a.lastFingerprint)return;let h=a.seq+1,f=Pe(),l=a.lastSnapshot==null||h%a.compactEvery===0?{name:this.name,mode:"full",snapshot:p,seq:h,timestamp_ns:f,format_version:J}:{name:this.name,mode:"diff",diff:gt(a.lastSnapshot,p),seq:h,timestamp_ns:f,format_version:J};if(a.tier.filter&&!a.tier.filter(l))return;let O;try{O=a.tier.save(l)}catch(m){t.onError?.(m,a.tier);return}if(O&&typeof O.then=="function"){let v=(a.savePending??Promise.resolve()).then(()=>O,()=>O).then(()=>{a.disposed||(a.seq=h,a.lastSnapshot=p,a.lastFingerprint=g)},w=>{t.onError?.(w,a.tier)});a.savePending=v.finally(()=>{a.savePending===v&&(a.savePending=void 0)})}else a.seq=h,a.lastSnapshot=p,a.lastFingerprint=g},r=(a,p)=>{try{s(a,p)}catch(g){t.onError?.(g,a.tier)}},i=(a,p)=>{if(!p.some(u=>{let y=this.config.messageTier(u[0]);return y>=3&&y<5}))return;if(t.filter){let u=this.tryResolve(a);if(u==null)return;let y=ye(u,ve("standard"));if(!t.filter(a,y))return}let h,f=()=>(h==null&&(h=this.snapshot()),h);for(let u of n)u.disposed||(u.debounceMs===0?r(u,f()):(u.timer==null&&(u.timer=new Me),u.timer.start(u.debounceMs,()=>{u.disposed||r(u,this.snapshot())})))},c;if(t.paths!=null){let p=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(g=>{let h=this.tryResolve(g);return h==null?()=>{}:h.subscribe(f=>i(g,f))});c=()=>{for(let g of p)g()}}else c=this.observe().subscribe((a,p)=>i(a,p));let d=()=>{c();for(let a of n)a.disposed=!0,a.timer?.cancel();this._storageDisposers.delete(d)};return this._storageDisposers.add(d),{dispose:d}}async _cascadeRestore(e,t){for(let n of e){let s;try{s=await n.load?.()}catch(i){t?.(i,n);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let r=s;try{if(r.mode==="full"&&r.snapshot!=null)return this.restore(r.snapshot),!0;if(r.version===J&&r.nodes!=null)return this.restore(r),!0}catch(i){t?.(i,n)}}return!1}static async fromStorage(e,t,n){for(let s of t){let r;try{r=await s.load?.()}catch(d){n?.onError?.(d,s);continue}if(r==null||typeof r!="object"||Array.isArray(r))continue;let i=r,c=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===J&&i.nodes!=null?i:void 0;if(c!=null)try{return o.fromSnapshot(c,n)}catch(d){n?.onError?.(d,s)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${t.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,t,n){if(e!=null&&t!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,t),this.config.inspectorEnabled){let s={path:e,annotation:t,timestamp_ns:z(),...n?.actor!=null?{actor:n.actor}:{}};this._traceRing.push(s)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let t=this._traceRing.toArray().filter(s=>!e(s)),n=this._traceRing.size-t.length;this._traceRing.clear();for(let s of t)this._traceRing.push(s);return n}static diff(e,t){let n=new Set(Object.keys(e.nodes)),s=new Set(Object.keys(t.nodes)),r=[...s].filter(m=>!n.has(m)).sort(),i=[...n].filter(m=>!s.has(m)).sort(),c=[],d=[];for(let m of n){if(!s.has(m))continue;let b=e.nodes[m],v=t.nodes[m],w=b.v,E=v.v;w!=null&&E!=null&&w.id===E.id&&w.version!==E.version&&d.push({path:m,id:w.id,from:w.version,to:E.version});let S=w!=null&&E!=null&&w.id===E.id&&w.version===E.version;for(let R of["type","status","sentinel"]){let G=b[R],D=v[R];G!==D&&c.push({path:m,field:R,from:G,to:D})}if(!S)for(let R of["value","meta"]){let G=b[R],D=v[R];at(G,D)||c.push({path:m,field:R,from:G,to:D})}}let a=m=>`${m.from} ${m.to}`,p=new Set(e.edges.map(a)),g=new Set(t.edges.map(a)),h=t.edges.filter(m=>!p.has(a(m))),f=e.edges.filter(m=>!g.has(a(m))),u=new Set(e.subgraphs),y=new Set(t.subgraphs),l=[...y].filter(m=>!u.has(m)).sort(),O=[...u].filter(m=>!y.has(m)).sort();return{nodesAdded:r,nodesRemoved:i,nodesChanged:c,versionChanges:d,edgesAdded:h,edgesRemoved:f,subgraphsAdded:l,subgraphsRemoved:O}}};function gt(o,e){let t=Se.diff(o,e),n={};for(let s of t.nodesAdded){let r=e.nodes[s];r!=null&&(n[s]=r)}return{...t,nodesAddedFull:n}}function Je(o,e,t,n={}){let s={paths:[],depths:new Map,truncated:!1};if(!e)return n.withDetail?s:[];if(!n.both&&t!=="upstream"&&t!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let r=n.maxDepth;if(r!=null&&(!Number.isInteger(r)||r<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(r===0)return n.withDetail?s:[];let i=new Map,c=new Map,d=new Map,a=new Map,p=new Set;for(let[b,v]of Object.entries(o.nodes)){if(!b)continue;p.add(b);let w=v.deps??[];i.set(b,w);for(let E of w)E&&(p.add(E),c.has(E)||c.set(E,new Set),c.get(E).add(b))}for(let b of o.edges){if(b==null||typeof b!="object")continue;let v=typeof b.from=="string"?b.from:"",w=typeof b.to=="string"?b.to:"";!v||!w||(p.add(v),p.add(w),a.has(v)||a.set(v,new Set),a.get(v).add(w),d.has(w)||d.set(w,new Set),d.get(w).add(v))}if(!p.has(e))return n.withDetail?s:[];let g=n.both===!0,h=b=>{if(g){let S=i.get(b)??[],R=d.get(b),G=c.get(b),D=a.get(b),k=[...S];return R&&k.push(...R),G&&k.push(...G),D&&k.push(...D),k}if(t==="upstream"){let S=i.get(b)??[],R=d.get(b);return R?[...S,...R]:S}let v=c.get(b),w=a.get(b),E=v?[...v]:[];return w&&E.push(...w),E},f=new Set([e]),u=new Map,y=[{path:e,depth:0}],l=0,O=!1;for(;l<y.length;){let b=y[l++];if(r!=null&&b.depth>=r){h(b.path).length>0&&(O=!0);continue}for(let v of h(b.path))!v||f.has(v)||(f.add(v),u.set(v,b.depth+1),y.push({path:v,depth:b.depth+1}))}let m=[...u.keys()].sort((b,v)=>b<v?-1:b>v?1:0);return n.withDetail?{paths:m,depths:u,truncated:O}:m}function mt(o,e){if(o.length!==e.length)return!1;for(let t=0;t<o.length;t++){let n=o[t],s=e[t];if(n.path!==s.path||n.type!==s.type||n.status!==s.status||n.hop!==s.hop||n.dep_index!==s.dep_index||n.annotation!==s.annotation||n.value!==s.value||n.lastMutation!==s.lastMutation)return!1;let r=n.v,i=s.v;if(r!==i&&(r==null||i==null||r.id!==i.id||r.version!==i.version))return!1}return!0}export{_e as a,Fe as b,A as c,nt as d,ze as e,Ve as f,B as g,J as h,Se as i,gt as j,Je as k};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{i as _}from"./chunk-7JRF5YEK.js";import{D as g,E as k}from"./chunk-LYCLF26R.js";import{b as R,c as T,d,h as A,i as O,j as D}from"./chunk-CK2E7BTU.js";function L(c,y,l,a){let s=new _(c,a);s.add(y,{name:"source"});let n=k(l,{meta:{kind:"stratify_rules"}});s.add(n,{name:"rules"});for(let f of l)E(s,y,n,f);return s}function E(c,y,l,a){let s=`branch/${a.name}`,n=Symbol("noValue"),f=!1,m=!1,p=!1,N=n,r=!1,h=l.cache??[];function v(o){if(p){p=!1;let t=N;if(N=n,t!==n){let i=h.find(u=>u.name===a.name),e=!1;try{e=i?.classify(t)??!1}catch{e=!1}e?(r=!1,o.emit(t)):r&&(r=!1,o.down([[T],[d]]))}else r?(r=!1,o.down([[T],[d]])):o.down([[d]])}}let S=g([],(o,t)=>{let i=y.subscribe(u=>{for(let b of u)w(b,0,t)}),e=l.subscribe(u=>{for(let b of u)w(b,1,t)});return()=>{i(),e()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:a.name},completeWhenDepsComplete:!1});function w(o,t,i){let e=o[0];return e===T?(t===0?(f=!0,r=!0):m=!0,!0):e===R||e===d?(t===0?(f=!1,p=!0,N=e===R?o[1]:n):(e===R&&(h=o[1]),m=!1),f||m||v(i),!0):e===O||e===D||e===A?(f=!1,m=!1,p=!1,N=n,r=!1,t===0&&i.down([o]),!0):t===1}if(c.add(S,{name:s}),a.ops){let o=a.ops(S),t=`branch/${a.name}/out`;c.add(o,{name:t})}}export{L as a};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import{b as X}from"./chunk-LQNOXGET.js";import{g as Q,i as U}from"./chunk-7JRF5YEK.js";import{E as z,F as W,G as Y,H as V}from"./chunk-LYCLF26R.js";import{b as ie}from"./chunk-QYADASLV.js";var he={};ie(he,{compileSpec:()=>ue,decompileSpec:()=>me,extractFnFactory:()=>te,extractSourceFactory:()=>ne,generateCatalogPrompt:()=>oe,isRichFnEntry:()=>T,isRichSourceEntry:()=>I,llmCompose:()=>ye,llmRefine:()=>ae,specDiff:()=>ge,validateSpec:()=>q,validateSpecAgainstCatalog:()=>K});function M(n){let e=n.meta?.factory;return typeof e=="string"?e:void 0}function C(n){let e=n.meta?.factoryArgs;return e!=null&&typeof e=="object"?e:{}}function Z(n){let e=C(n);return"initial"in e?e.initial:n.value}function T(n){return typeof n=="object"&&n!==null&&"factory"in n}function I(n){return typeof n=="object"&&n!==null&&"factory"in n}function te(n){return T(n)?n.factory:n}function ne(n){return I(n)?n.factory:n}function oe(n){let e=[];if(n.fns){let o=new Map;for(let[s,f]of Object.entries(n.fns)){let p=T(f)?f.tags?.[0]??"Other":"Other";o.has(p)||o.set(p,[]),o.get(p).push(ce(s,f))}for(let[s,f]of o)e.push(`${s}:
|
|
2
|
+
${f.join(`
|
|
3
|
+
`)}`)}if(n.sources){let o=[];for(let[s,f]of Object.entries(n.sources))o.push(pe(s,f));o.length>0&&e.push(`Sources:
|
|
4
|
+
${o.join(`
|
|
5
|
+
`)}`)}return e.join(`
|
|
6
|
+
|
|
7
|
+
`)}function ce(n,e){if(!T(e))return`- ${n}`;let o=`- ${n}: ${e.description}`;if(e.configSchema){let s=Object.entries(e.configSchema).map(([f,p])=>{let u=`${f}: ${p.type}`;return p.enum&&(u+=` (${p.enum.join("|")})`),p.required===!1&&(u+="?"),u});o+=`. Config: { ${s.join(", ")} }`}return o}function pe(n,e){if(!I(e))return`- ${n}`;let o=`- ${n}: ${e.description}`;if(e.configSchema){let s=Object.entries(e.configSchema).map(([f,p])=>{let u=`${f}: ${p.type}`;return p.required===!1&&(u+="?"),u});o+=`. Config: { ${s.join(", ")} }`}return o}function K(n,e){let o=[],s=new Set(Object.keys(e.fns??{})),f=new Set(Object.keys(e.sources??{}));for(let[p,u]of Object.entries(n.nodes)){if(u.type==="template")continue;let i=u,r=M(i);if(r==null)continue;let t=i.type==="producer";if(i.type==="state"&&r==="state")continue;if(t){let h=f.has(r),l=s.has(r);if(!h&&!l&&(f.size>0||s.size>0)){let b=J(r,f)??J(r,s);o.push(`Node "${p}": source "${r}" not found in catalog`+(b?`. Did you mean "${b}"?`:""))}}else if(s.size>0&&!s.has(r))if(f.has(r))o.push(`Node "${p}": fn "${r}" is a source, not a function. Use it as a producer source instead, or use a function from: ${[...s].join(", ")}`);else{let h=J(r,s);o.push(`Node "${p}": fn "${r}" not found in catalog`+(h?`. Did you mean "${h}"?`:""))}let m=C(i);if(!t&&e.fns?.[r]){let h=e.fns[r];if(T(h)&&h.configSchema){for(let[l,b]of Object.entries(h.configSchema))if(b.required!==!1&&!(l in m)&&o.push(`Node "${p}": config missing required field "${l}"`),l in m&&b.enum){let S=m[l];b.enum.includes(S)||o.push(`Node "${p}": config.${l} = ${JSON.stringify(S)}, expected one of: ${b.enum.join(", ")}`)}}}if(t&&e.sources?.[r]){let h=e.sources[r];if(I(h)&&h.configSchema){for(let[l,b]of Object.entries(h.configSchema))if(b.required!==!1&&!(l in m)&&o.push(`Node "${p}": config missing required field "${l}"`),l in m&&b.enum){let S=m[l];b.enum.includes(S)||o.push(`Node "${p}": config.${l} = ${JSON.stringify(S)}, expected one of: ${b.enum.join(", ")}`)}}}}if(n.templates)for(let[p,u]of Object.entries(n.templates))for(let[i,r]of Object.entries(u.nodes)){let t=M(r);if(t!=null&&!(r.type==="state"&&t==="state")&&r.type!=="producer"&&s.size>0&&!s.has(t)){let m=J(t,s);o.push(`Template "${p}" node "${i}": fn "${t}" not found in catalog`+(m?`. Did you mean "${m}"?`:""))}}return{valid:o.length===0,errors:o,warnings:[]}}function J(n,e){let o=null,s=1/0,f=n.toLowerCase();for(let p of e){let u=fe(f,p.toLowerCase());u<s&&u<=Math.max(3,Math.floor(n.length/2))&&(s=u,o=p)}return o}function fe(n,e){let o=n.length,s=e.length,f=Array.from({length:o+1},(p,u)=>Array.from({length:s+1},(i,r)=>u===0?r:r===0?u:0));for(let p=1;p<=o;p++)for(let u=1;u<=s;u++)f[p][u]=n[p-1]===e[u-1]?f[p-1][u-1]:1+Math.min(f[p-1][u],f[p][u-1],f[p-1][u-1]);return f[o][s]}var ee=new Set(["state","producer","derived","effect","operator","template"]),de=new Set(["state","producer","derived","effect","operator"]);function q(n){let e=[],o=[];if(n==null||typeof n!="object")return{valid:!1,errors:["GraphSpec must be a non-null object"],warnings:o};let s=n;if((typeof s.name!="string"||s.name.length===0)&&e.push("Missing or empty 'name' field"),s.nodes==null||typeof s.nodes!="object"||Array.isArray(s.nodes))return e.push("Missing or invalid 'nodes' field (must be an object)"),{valid:!1,errors:e,warnings:o};let f=new Set(Object.keys(s.nodes)),p=new Map,u=new Map;if(s.templates!=null&&typeof s.templates=="object"&&!Array.isArray(s.templates)){for(let[i,r]of Object.entries(s.templates))if(r!=null&&typeof r=="object"){let t=r;u.set(i,{params:Array.isArray(t.params)?t.params:[]})}}if(s.templates!=null)if(typeof s.templates!="object"||Array.isArray(s.templates))e.push("'templates' must be an object");else for(let[i,r]of Object.entries(s.templates)){if(r==null||typeof r!="object"){e.push(`Template "${i}": must be an object`);continue}let t=r;if(Array.isArray(t.params)||e.push(`Template "${i}": missing 'params' array`),t.nodes==null||typeof t.nodes!="object"||Array.isArray(t.nodes))e.push(`Template "${i}": missing or invalid 'nodes' object`);else{let m=new Set(Array.isArray(t.params)?t.params:[]),h=new Set(Object.keys(t.nodes));for(let[l,b]of Object.entries(t.nodes)){if(b==null||typeof b!="object"){e.push(`Template "${i}" node "${l}": must be an object`);continue}let S=b;if((typeof S.type!="string"||!de.has(S.type))&&e.push(`Template "${i}" node "${l}": invalid type`),Array.isArray(S.deps))for(let g of S.deps)!h.has(g)&&!m.has(g)&&e.push(`Template "${i}" node "${l}": dep "${g}" is not an inner node or param`)}typeof t.output!="string"?e.push(`Template "${i}": missing 'output' string`):t.nodes[t.output]||e.push(`Template "${i}": output "${t.output}" is not a declared node`)}}for(let[i,r]of Object.entries(s.nodes)){if(r==null||typeof r!="object"){e.push(`Node "${i}": must be an object`);continue}let t=r;if(typeof t.type!="string"||!ee.has(t.type)){e.push(`Node "${i}": invalid type "${String(t.type)}" (expected: ${[...ee].join(", ")})`);continue}if(p.set(i,t.type),t.type==="template")if(typeof t.template!="string"||!u.has(t.template))e.push(`Node "${i}": template "${String(t.template)}" not found in templates`);else if(t.bind==null||typeof t.bind!="object"||Array.isArray(t.bind))e.push(`Node "${i}": template ref requires 'bind' object`);else{let m=u.get(t.template),h=t.bind;for(let l of m.params)l in h||e.push(`Node "${i}": template param "${l}" is not bound (template "${t.template}")`);for(let[,l]of Object.entries(h))typeof l=="string"&&!f.has(l)&&e.push(`Node "${i}": bind target "${l}" does not reference an existing node`)}else{if(Array.isArray(t.deps))for(let m of t.deps)m===i?e.push(`Node "${i}": self-referencing dep`):f.has(m)||e.push(`Node "${i}": dep "${m}" does not reference an existing node`);(t.type==="derived"||t.type==="effect"||t.type==="operator")&&!Array.isArray(t.deps)&&e.push(`Node "${i}": ${t.type} node should have a 'deps' array`)}}if(s.feedback!=null)if(!Array.isArray(s.feedback))e.push("'feedback' must be an array");else for(let i=0;i<s.feedback.length;i++){let r=s.feedback[i];if(r==null||typeof r!="object"){e.push(`Feedback [${i}]: must be an object`);continue}let t=r;typeof t.from!="string"||!f.has(t.from)?e.push(`Feedback [${i}]: 'from' "${String(t.from)}" does not reference an existing node`):p.get(t.from)==="effect"&&o.push(`Feedback [${i}]: 'from' "${t.from}" is an effect node \u2014 effects emit no DATA, so the feedback edge will never fire. Did you mean a derived/state node upstream?`),typeof t.from=="string"&&t.from===t.to&&e.push(`Feedback [${i}]: 'from' and 'to' must be different nodes`),typeof t.to!="string"||!f.has(t.to)?e.push(`Feedback [${i}]: 'to' "${String(t.to)}" does not reference an existing node`):typeof t.to=="string"&&p.get(t.to)!=="state"&&e.push(`Feedback [${i}]: 'to' node "${t.to}" must be a state node (got "${p.get(t.to)??"unknown"}")`)}return{valid:e.length===0,errors:e,warnings:o}}function ue(n,e){let o=q(n);if(!o.valid)throw new Error(`compileSpec: invalid GraphSpec:
|
|
8
|
+
${o.errors.join(`
|
|
9
|
+
`)}`);let s=n.factory,f=n.factoryArgs;if(typeof s=="string"){let a=e?.catalog?.graphFactories?.[s];if(a)return a(f)}let p=e?.catalog??{},u=e?.onMissing??"placeholder",i=new U(n.name),r=n.templates??{},t=K(n,p);if(!t.valid)throw new Error(`compileSpec: catalog validation errors:
|
|
10
|
+
${t.errors.join(`
|
|
11
|
+
`)}`);let m=[],h=(a,d,y)=>{m.push({path:a,kind:d,name:y})},l=a=>{let d=p.fns?.[a];return d?te(d):void 0},b=a=>{let d=p.sources?.[a];return d?ne(d):void 0},S=a=>{if(!a)return;let d={};for(let[y,w]of Object.entries(a))y==="factory"||y==="factoryArgs"||(d[y]=w);return Object.keys(d).length>0?d:void 0},g=new Map,x=[];for(let[a,d]of Object.entries(n.nodes)){if(d.type==="template")continue;let y=d,w=M(y),k=C(y);if(y.type==="state"){let v=Z(y),R=z(v,{name:a,meta:S(y.meta)});i.add(R,{name:a}),g.set(a,R)}else if(y.type==="producer"){let v=w?b(w):void 0,R=w?l(w):void 0;if(v){let N=v(k);i.add(N,{name:a}),g.set(a,N)}else if(R){let N=R([],k);i.add(N,{name:a}),g.set(a,N)}else{w&&h(a,"source",w);let N=W(()=>{},{name:a,meta:{...S(y.meta),_specSource:w}});i.add(N,{name:a}),g.set(a,N)}}else x.push([a,y])}let L=!0,c=new Map(x);for(;c.size>0&&L;){L=!1;for(let[a,d]of[...c.entries()]){let y=d.deps??[];if(!y.every(F=>g.has(F)))continue;let w=y.map(F=>g.get(F)),k=M(d),v=C(d),R=k?l(k):void 0,N;R?N=R(w,v):d.type==="effect"?(k&&h(a,"fn",k),N=V(w,()=>{})):(k&&h(a,"fn",k),N=Y(w,F=>F[0])),i.add(N,{name:a}),g.set(a,N),c.delete(a),L=!0}}if(c.size>0){let a=[...c.keys()].sort().join(", ");throw new Error(`compileSpec: unresolvable deps for nodes: ${a}`)}for(let[a,d]of Object.entries(n.nodes)){if(d.type!=="template")continue;let y=d,w=r[y.template],k=new U(a),v=new Map,R=[];for(let[$,j]of Object.entries(w.nodes)){let P=(j.deps??[]).map(A=>A.startsWith("$")&&y.bind[A]?y.bind[A]:A),H={...j,deps:P},G=M(j),E=C(j);if(j.type==="state"){let A=Z(j),_=z(A,{name:$,meta:S(j.meta)});k.add(_,{name:$}),v.set($,_)}else if(j.type==="producer"){let A=G?b(G):void 0,_=G?l(G):void 0;if(A){let O=A(E);k.add(O,{name:$}),v.set($,O)}else if(_){let O=_([],E);k.add(O,{name:$}),v.set($,O)}else{G&&h(`${a}.${$}`,"source",G);let O=W(()=>{},{name:$,meta:{...S(j.meta),_specSource:G}});k.add(O,{name:$}),v.set($,O)}}else R.push([$,H])}let N=!0,F=new Map(R);for(;F.size>0&&N;){N=!1;for(let[$,j]of[...F.entries()]){let P=j.deps??[];if(!P.every(D=>v.has(D)||g.has(D)))continue;let G=P.map(D=>v.get(D)??g.get(D)),E=M(j),A=C(j),_=E?l(E):void 0,O;_?O=_(G,A):j.type==="effect"?(E&&h(`${a}.${$}`,"fn",E),O=V(G,()=>{})):(E&&h(`${a}.${$}`,"fn",E),O=Y(G,D=>D[0])),k.add(O,{name:$}),v.set($,O),F.delete($),N=!0}}if(F.size>0){let $=[...F.keys()].sort().join(", ");throw new Error(`compileSpec: template "${y.template}" has unresolvable deps: ${$}`)}i.mount(a,k);let B=`${a}::${w.output}`;g.set(a,i.resolve(B));try{let $=i.resolve(B);$.meta._templateName?.emit(y.template),$.meta._templateBind?.emit(y.bind)}catch{}}for(let a of n.feedback??[])X(i,a.from,a.to,{maxIterations:a.maxIterations});if(m.length>0){if(u==="error"){let a=m.map(d=>` - ${d.path}: missing ${d.kind} "${d.name}"`);throw new Error(`compileSpec: ${m.length} catalog entr${m.length===1?"y":"ies"} missing \u2014 pass them via opts.catalog or set opts.onMissing to "warn"/"placeholder":
|
|
12
|
+
${a.join(`
|
|
13
|
+
`)}`)}if(u==="warn"){let a=e?.onWarn??(d=>console.warn(d));for(let d of m)a(`compileSpec: ${d.path} references missing ${d.kind} "${d.name}" \u2014 substituted placeholder`)}}return i}var le=new Set(["reduction","reduction_type","_specFn","_specSource","_templateName","_templateBind","feedbackFrom","feedbackTo","_internal"]);function me(n){let e=n.describe({detail:"spec"}),o=`::${Q}::`,s=/^__feedback_(?!effect_)(.+)$/,f=[],p=new Set;for(let[r,t]of Object.entries(e.nodes))t.meta?.factory!=null&&!r.includes("::")&&p.add(r);let u={};for(let[r,t]of Object.entries(e.nodes)){if(r.includes(o))continue;let m=r.indexOf("::");if(m>0&&p.has(r.slice(0,m)))continue;if(s.exec(r)){let g=t.meta;g?.feedbackFrom&&g?.feedbackTo&&f.push({from:g.feedbackFrom,to:g.feedbackTo,...g.maxIterations?{maxIterations:g.maxIterations}:{}});continue}if(t.meta?._internal||r.startsWith("__feedback_effect_")||r.startsWith("__bridge_"))continue;let l=t.meta,b=l;if(l&&Object.keys(l).length>0){let g={};for(let[x,L]of Object.entries(l))le.has(x)||(g[x]=L);g.factory==="withStatus"?(delete g.status,delete g.error):g.factory==="withBreaker"?delete g.breakerState:g.factory==="verifiable"&&delete g.sourceVersion,b=Object.keys(g).length>0?g:void 0}let S={...t};b===void 0?delete S.meta:S.meta=b,u[r]=S}let i={...e,nodes:u};return delete i.expand,f.length>0&&(i.feedback=f),i}function ge(n,e){let o=[];n.name!==e.name&&o.push({type:"changed",path:"name",detail:`"${n.name}" \u2192 "${e.name}"`});let s=new Set(Object.keys(n.nodes)),f=new Set(Object.keys(e.nodes));for(let c of f)if(!s.has(c)){let a=e.nodes[c];o.push({type:"added",path:`nodes.${c}`,detail:`type: ${a.type}`})}for(let c of s)f.has(c)||o.push({type:"removed",path:`nodes.${c}`});for(let c of s){if(!f.has(c))continue;let a=n.nodes[c],d=e.nodes[c];if(JSON.stringify(a)!==JSON.stringify(d)){let y=[];a.type!==d.type&&y.push(`type: ${a.type} \u2192 ${d.type}`),JSON.stringify(a.deps)!==JSON.stringify(d.deps)&&y.push("deps changed");let w=a.type==="template"?void 0:M(a),k=d.type==="template"?void 0:M(d);w!==k&&y.push(`fn: ${w} \u2192 ${k}`);let v=a.type==="template"?void 0:C(a),R=d.type==="template"?void 0:C(d);JSON.stringify(v)!==JSON.stringify(R)&&y.push("config changed"),o.push({type:"changed",path:`nodes.${c}`,detail:y.join("; ")||"modified"})}}let p=n.templates??{},u=e.templates??{},i=new Set(Object.keys(p)),r=new Set(Object.keys(u));for(let c of r)i.has(c)||o.push({type:"added",path:`templates.${c}`});for(let c of i)r.has(c)||o.push({type:"removed",path:`templates.${c}`});for(let c of i)r.has(c)&&JSON.stringify(p[c])!==JSON.stringify(u[c])&&o.push({type:"changed",path:`templates.${c}`,detail:"template definition changed"});let t=n.feedback??[],m=e.feedback??[],h=new Set(t.map(c=>`${c.from}->${c.to}`)),l=new Set(m.map(c=>`${c.from}->${c.to}`));for(let c of m){let a=`${c.from}->${c.to}`;h.has(a)||o.push({type:"added",path:`feedback.${a}`,detail:`maxIterations: ${c.maxIterations??10}`})}for(let c of t){let a=`${c.from}->${c.to}`;l.has(a)||o.push({type:"removed",path:`feedback.${a}`})}for(let c of t){let a=`${c.from}->${c.to}`,d=m.find(y=>y.from===c.from&&y.to===c.to);d&&JSON.stringify(c)!==JSON.stringify(d)&&o.push({type:"changed",path:`feedback.${a}`,detail:`maxIterations: ${c.maxIterations??10} \u2192 ${d.maxIterations??10}`})}let b=o.filter(c=>c.type==="added").length,S=o.filter(c=>c.type==="removed").length,g=o.filter(c=>c.type==="changed").length,x=[];b&&x.push(`${b} added`),S&&x.push(`${S} removed`),g&&x.push(`${g} changed`);let L=x.length>0?x.join(", "):"no changes";return{entries:o,summary:L}}var se=`You are a graph architect for GraphReFly, a reactive graph protocol.
|
|
14
|
+
|
|
15
|
+
Given a natural-language description, produce a JSON GraphSpec with this structure:
|
|
16
|
+
|
|
17
|
+
{
|
|
18
|
+
"name": "<graph_name>",
|
|
19
|
+
"nodes": {
|
|
20
|
+
"<node_name>": {
|
|
21
|
+
"type": "state" | "derived" | "producer" | "effect",
|
|
22
|
+
"deps": ["<dep_node_name>", ...],
|
|
23
|
+
"value": <initial_value>,
|
|
24
|
+
"meta": {
|
|
25
|
+
"factory": "<catalog_factory_name>",
|
|
26
|
+
"factoryArgs": { ... },
|
|
27
|
+
"description": "<purpose>"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"<template_instance>": {
|
|
31
|
+
"type": "template",
|
|
32
|
+
"template": "<template_name>",
|
|
33
|
+
"bind": { "$param": "node_name" }
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"templates": {
|
|
37
|
+
"<template_name>": {
|
|
38
|
+
"params": ["$param1", "$param2"],
|
|
39
|
+
"nodes": { ... },
|
|
40
|
+
"output": "<output_node>"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"feedback": [
|
|
44
|
+
{ "from": "<condition_node>", "to": "<state_node>", "maxIterations": 10 }
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
Rules:
|
|
49
|
+
- "state" nodes hold user/LLM-writable values (knobs). Stamp the initial value
|
|
50
|
+
in "meta.factoryArgs.initial" (or as the top-level "value" field \u2014 both work).
|
|
51
|
+
- "derived" nodes compute from deps using a catalog function named in
|
|
52
|
+
"meta.factory"; pass any config via "meta.factoryArgs".
|
|
53
|
+
- "effect" nodes produce side effects from deps; same meta.factory shape as derived.
|
|
54
|
+
- "producer" nodes generate values from a catalog source named in "meta.factory";
|
|
55
|
+
pass any config via "meta.factoryArgs".
|
|
56
|
+
- Use "templates" when the same subgraph pattern repeats (e.g., per-source resilience).
|
|
57
|
+
- Use "feedback" for bounded cycles where a derived value writes back to a state node.
|
|
58
|
+
- meta.description is required for every node.
|
|
59
|
+
- Return ONLY valid JSON, no markdown fences or commentary.`;function re(n){let e=n.match(/^```(?:json)?\s*([\s\S]*?)\s*```[\s\S]*$/);return e?e[1]:n}async function ye(n,e,o){let s=se,f=o?.catalogDescription??(o?.catalog?oe(o.catalog):void 0);f&&(s+=`
|
|
60
|
+
|
|
61
|
+
Available catalog (use ONLY these names):
|
|
62
|
+
${f}`),o?.systemPromptExtra&&(s+=`
|
|
63
|
+
|
|
64
|
+
${o.systemPromptExtra}`);let p=[{role:"system",content:s},{role:"user",content:n}],r=(await e.invoke(p,{model:o?.model,temperature:o?.temperature??0,maxTokens:o?.maxTokens})).content.trim();r.startsWith("```")&&(r=re(r));let t;try{t=JSON.parse(r)}catch{throw new Error(`llmCompose: LLM response is not valid JSON: ${r.slice(0,200)}`)}let m=q(t);if(!m.valid)throw new Error(`llmCompose: invalid GraphSpec:
|
|
65
|
+
${m.errors.join(`
|
|
66
|
+
`)}`);let h=t;if(o?.catalog){let l=o.maxAutoRefine??0;for(let b=0;b<=l;b++){let S=K(h,o.catalog);if(S.valid)break;if(b===l)throw new Error(`llmCompose: catalog validation failed after ${l} refine attempts:
|
|
67
|
+
${S.errors.join(`
|
|
68
|
+
`)}`);h=await ae(h,`Fix these catalog errors:
|
|
69
|
+
${S.errors.join(`
|
|
70
|
+
`)}
|
|
71
|
+
|
|
72
|
+
Use ONLY functions and sources from the catalog.`,e,{...o,catalogDescription:f})}}return h}async function ae(n,e,o,s){let f=se;s?.catalogDescription&&(f+=`
|
|
73
|
+
|
|
74
|
+
Available catalog:
|
|
75
|
+
${s.catalogDescription}`),s?.systemPromptExtra&&(f+=`
|
|
76
|
+
|
|
77
|
+
${s.systemPromptExtra}`);let p=[{role:"system",content:f},{role:"user",content:`Current GraphSpec:
|
|
78
|
+
${JSON.stringify(n,null,2)}
|
|
79
|
+
|
|
80
|
+
Modification request: ${e}
|
|
81
|
+
|
|
82
|
+
Return the complete modified GraphSpec as JSON.`}],r=(await o.invoke(p,{model:s?.model,temperature:s?.temperature??0,maxTokens:s?.maxTokens})).content.trim();r.startsWith("```")&&(r=re(r));let t;try{t=JSON.parse(r)}catch{throw new Error(`llmRefine: LLM response is not valid JSON: ${r.slice(0,200)}`)}let m=q(t);if(!m.valid)throw new Error(`llmRefine: invalid GraphSpec:
|
|
83
|
+
${m.errors.join(`
|
|
84
|
+
`)}`);return t}export{T as a,I as b,te as c,ne as d,oe as e,K as f,q as g,ue as h,me as i,ge as j,ye as k,ae as l,he as m};
|