@graphrefly/graphrefly 0.32.0 → 0.34.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/{cascading-D3sapjue.d.ts → cascading-Bg0a4VSf.d.ts} +2 -2
- package/dist/{cascading-BfQmSmjU.d.cts → cascading-DKIb6Pk8.d.cts} +2 -2
- package/dist/{chunk-4JBKKUCJ.js → chunk-2JO6LXFT.js} +1 -1
- package/dist/{chunk-FTA5TB2A.js → chunk-2LZ6DL45.js} +1 -1
- package/dist/chunk-3Y4BXFFR.js +1 -0
- package/dist/{chunk-WQ7I7JVU.js → chunk-4F564IPP.js} +1 -1
- package/dist/{chunk-M2VFLRPJ.js → chunk-4NYSEUKV.js} +1 -1
- package/dist/{chunk-N2KKISCE.js → chunk-533RQFF6.js} +1 -1
- package/dist/{chunk-BU4SUZSA.js → chunk-55T3K37W.js} +1 -1
- package/dist/chunk-65WWQ5CB.js +43 -0
- package/dist/chunk-6HQ6HVTF.js +1 -0
- package/dist/{chunk-4VXL3UZK.js → chunk-7Q2WPFQ7.js} +1 -1
- package/dist/chunk-A3GDELMY.js +61 -0
- package/dist/{chunk-5PBXUVHI.js → chunk-BY4WKPKM.js} +1 -1
- package/dist/{chunk-JYMNVEH6.js → chunk-C5DINHNP.js} +1 -1
- package/dist/{chunk-7QS77X6G.js → chunk-CJMFZXIZ.js} +1 -1
- package/dist/{chunk-W6FQIFVE.js → chunk-CLD3F4R5.js} +1 -1
- package/dist/{chunk-RWGJQQLT.js → chunk-FKRPIRE6.js} +1 -1
- package/dist/{chunk-UXEB35L4.js → chunk-GAOX6OPT.js} +1 -1
- package/dist/{chunk-TOCCHQI6.js → chunk-GCUYSIM4.js} +1 -1
- package/dist/{chunk-XRSHMHEG.js → chunk-HTBOCKVD.js} +1 -1
- package/dist/{chunk-LJGPOJHS.js → chunk-IB64M7VP.js} +1 -1
- package/dist/{chunk-Q2SY7M7K.js → chunk-IJFSR4NU.js} +1 -1
- package/dist/{chunk-X4OOM6QU.js → chunk-INXDSJRC.js} +1 -1
- package/dist/{chunk-4YGJ7KZ6.js → chunk-IPNJDNE7.js} +1 -1
- package/dist/{chunk-4UUDNFYG.js → chunk-KGKJCHEK.js} +1 -1
- package/dist/chunk-KN2UMFT6.js +5 -0
- package/dist/{chunk-A4JT4SAD.js → chunk-KRH66M4O.js} +1 -1
- package/dist/{chunk-K54OKWNY.js → chunk-L3KUKDZC.js} +1 -1
- package/dist/{chunk-Y26UN6J5.js → chunk-LOF5HSD3.js} +1 -1
- package/dist/chunk-LYCLF26R.js +1 -0
- package/dist/{chunk-CZVYLXFK.js → chunk-M27MVZCP.js} +1 -1
- package/dist/{chunk-DWIAG62L.js → chunk-NNKJUORL.js} +1 -1
- package/dist/{chunk-WF3V5X2L.js → chunk-PBN426RU.js} +1 -1
- package/dist/{chunk-MFNOZ5E6.js → chunk-Q46YJCQH.js} +1 -1
- package/dist/{chunk-KD3IYBTD.js → chunk-SFIM774L.js} +1 -1
- package/dist/{chunk-VXJX3ZZP.js → chunk-T2TB37TW.js} +1 -1
- package/dist/{chunk-UMH3HSP7.js → chunk-T7EQPKOP.js} +1 -1
- package/dist/{chunk-JAHAJU4G.js → chunk-TONEKQM3.js} +1 -1
- package/dist/{chunk-CNXUW2CU.js → chunk-TZLEMGAK.js} +1 -1
- package/dist/{chunk-LWGLBCMU.js → chunk-TZQPPQEQ.js} +1 -1
- package/dist/{chunk-7JZ3YORY.js → chunk-U2T2XWDA.js} +1 -1
- package/dist/{chunk-WE32AFFA.js → chunk-UF746BQ4.js} +1 -1
- package/dist/{chunk-7QMVU3IX.js → chunk-WBWBY6LI.js} +1 -1
- package/dist/{chunk-7EMUF2RY.js → chunk-Y63GWRHO.js} +1 -1
- package/dist/{chunk-PWKLZ2XU.js → chunk-YDWTVO4E.js} +1 -1
- package/dist/{chunk-EIFHFDFD.js → chunk-YUBV7EEE.js} +1 -1
- package/dist/compat/index.cjs +5 -5
- package/dist/compat/index.d.cts +14 -14
- package/dist/compat/index.d.ts +14 -14
- package/dist/compat/index.js +1 -1
- package/dist/compat/jotai/index.cjs +1 -1
- package/dist/compat/jotai/index.d.cts +2 -2
- package/dist/compat/jotai/index.d.ts +2 -2
- package/dist/compat/jotai/index.js +1 -1
- package/dist/compat/nanostores/index.cjs +1 -1
- package/dist/compat/nanostores/index.d.cts +2 -2
- package/dist/compat/nanostores/index.d.ts +2 -2
- package/dist/compat/nanostores/index.js +1 -1
- package/dist/compat/nestjs/index.cjs +5 -5
- package/dist/compat/nestjs/index.d.cts +6 -6
- package/dist/compat/nestjs/index.d.ts +6 -6
- 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 -3
- 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-BY9hMxN7.d.ts → composite-BPDU_XV1.d.ts} +2 -2
- package/dist/{composite-CH0S8DFn.d.cts → composite-CmvdhTJe.d.cts} +2 -2
- 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.cjs +1 -1
- package/dist/extra/browser.d.cts +1 -1
- package/dist/extra/browser.d.ts +1 -1
- package/dist/extra/browser.js +1 -1
- package/dist/extra/index.cjs +16 -16
- package/dist/extra/index.d.cts +9 -9
- package/dist/extra/index.d.ts +9 -9
- package/dist/extra/index.js +1 -1
- package/dist/extra/node.cjs +1 -1
- package/dist/extra/node.d.cts +1 -1
- package/dist/extra/node.d.ts +1 -1
- package/dist/extra/node.js +1 -1
- 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/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.cjs +1 -1
- package/dist/extra/storage-browser.d.cts +1 -1
- package/dist/extra/storage-browser.d.ts +1 -1
- package/dist/extra/storage-browser.js +1 -1
- package/dist/{fallback-Cb3GH1O7.d.cts → fallback-9YznPvPP.d.cts} +1 -1
- package/dist/{fallback-DRjJ_ZM8.d.ts → fallback-mYSd8vQo.d.ts} +1 -1
- package/dist/graph/index.cjs +4 -4
- 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-BOhEGJ6E.d.ts → graph-BROUZPG9.d.ts} +2 -2
- package/dist/{graph-CdJeX7O7.d.cts → graph-DaoydJ_u.d.cts} +2 -2
- package/dist/{index-C22aTC1X.d.cts → index-3L3RC3VJ.d.ts} +578 -108
- package/dist/{index-BmZb8fNF.d.cts → index-B-KCkW4M.d.cts} +4 -4
- package/dist/{index-CDK5RsV5.d.cts → index-B1hFhK1K.d.cts} +1 -1
- package/dist/{index-C7RqYbOZ.d.ts → index-B5eS17Bz.d.ts} +7 -7
- package/dist/{index-DSawGt8n.d.cts → index-BDEhWLF4.d.cts} +3 -3
- package/dist/{index-CZUzi6Dy.d.ts → index-BFHpNSsV.d.ts} +4 -4
- package/dist/{index-DDo-eqQ4.d.cts → index-BO6t0HjV.d.cts} +1 -1
- package/dist/{index-CrC7urhX.d.ts → index-BRisOxlx.d.ts} +1 -1
- package/dist/{index-CHfBm51k.d.ts → index-BUtCR0k6.d.ts} +4 -4
- package/dist/{index-BydMDMf7.d.cts → index-BVTjuKeP.d.cts} +1 -1
- package/dist/{index-BX22kvjh.d.ts → index-BWiX5foT.d.ts} +1 -1
- package/dist/{index-Dxk-pUQI.d.ts → index-Bd2AjMQY.d.ts} +2 -2
- package/dist/{index-Dbmj0iYR.d.ts → index-Bi4ZP6Hc.d.ts} +2 -2
- package/dist/{index-j33Lfb1G.d.cts → index-BkfL5MXh.d.cts} +3 -3
- package/dist/{index-CnjUhRbs.d.cts → index-BpjQanLs.d.cts} +2 -2
- package/dist/{index-LGzAYqdR.d.ts → index-BsxqmV6u.d.ts} +2 -2
- package/dist/{index-CCdg0JLX.d.cts → index-C2Dey3L-.d.cts} +12 -3
- package/dist/{index-gXTVbSax.d.ts → index-C5uMGVJw.d.ts} +4 -4
- package/dist/{index-C-Gsh-0a.d.cts → index-C8_bnDBZ.d.cts} +3 -3
- package/dist/{index-C9qCLIN4.d.ts → index-CD7qmvSf.d.ts} +3 -3
- package/dist/{index-wIx1Jisk.d.ts → index-CI5fULSz.d.ts} +1 -1
- package/dist/{index-BUZPTPSQ.d.ts → index-CNxdDb2e.d.ts} +3 -3
- package/dist/{index-FBqTfL_S.d.cts → index-CQ1gt4rn.d.cts} +1 -1
- package/dist/{index-CNyiYQWF.d.ts → index-CQtnGFrZ.d.cts} +578 -108
- package/dist/{index-DhlAMlm9.d.ts → index-CbCNoogR.d.ts} +218 -66
- package/dist/{index-BDLy6CQ9.d.cts → index-Ccv_61jG.d.cts} +2 -2
- package/dist/{index-MV2yGIAq.d.ts → index-Ced0dphF.d.ts} +9 -9
- package/dist/{index-BzxU4yhV.d.cts → index-ChZvMC4M.d.cts} +4 -4
- package/dist/{index-zMQIQuDu.d.ts → index-Chi9IiHJ.d.ts} +3 -3
- package/dist/{index-DUkuH3jP.d.cts → index-ClJUZAOr.d.cts} +18 -3
- package/dist/{index-D7XxY1Ff.d.cts → index-ClKm7CFB.d.cts} +1 -1
- package/dist/{index-D3HcdZ4d.d.cts → index-Cn3taOmp.d.cts} +2 -2
- package/dist/{index-C4QTaDli.d.cts → index-CoR-tOZA.d.cts} +4 -4
- package/dist/{index-BpFWP7Bq.d.cts → index-Cp91Sxbo.d.cts} +5 -4
- package/dist/{index-DD1czHj3.d.ts → index-Cq7Uqgu4.d.ts} +2 -2
- package/dist/{index-EGjF6iSY.d.cts → index-D23g00HE.d.cts} +4 -4
- package/dist/{index-Bnmttu35.d.ts → index-D80nGRb9.d.ts} +3 -3
- package/dist/{index-DY2QbdoP.d.cts → index-DR3XqZlV.d.cts} +1 -1
- package/dist/{index-BANwzwBV.d.ts → index-Db21wuaD.d.ts} +5 -4
- package/dist/{index-CIXaiYDE.d.cts → index-DhWrMTI6.d.cts} +1 -1
- package/dist/{index-Dp_pS7Bw.d.ts → index-DheNs40A.d.ts} +2 -2
- package/dist/{index-CVevMZ0n.d.ts → index-Dia4yc2y.d.ts} +3 -3
- package/dist/{index-_BXz9K7b.d.cts → index-Ds3Rz9m9.d.cts} +3 -3
- package/dist/{index-Ckl03Q0s.d.ts → index-Dtpr2FIB.d.ts} +18 -3
- package/dist/{index-ByPnK85n.d.ts → index-DupIl9wI.d.ts} +1 -1
- package/dist/{index-CEoU-r-g.d.ts → index-DuvQAU02.d.ts} +2 -2
- package/dist/{index-D0C_USMR.d.ts → index-DxEcY7Om.d.ts} +1 -1
- package/dist/{index-eYHRkoK-.d.ts → index-HvJ90_tX.d.ts} +12 -3
- package/dist/{index-BuN2wGJs.d.cts → index-IxinNgAH.d.cts} +218 -66
- package/dist/{index-LzCJ0kMT.d.cts → index-Jgl7ev9I.d.cts} +9 -9
- package/dist/{index-DlGaEBW5.d.cts → index-RJX4snyi.d.cts} +2 -2
- package/dist/{index-DNhTQReY.d.cts → index-ZIQaKIdY.d.cts} +7 -7
- package/dist/{index-lpGUhTBn.d.ts → index-b4a6Sg0R.d.ts} +4 -4
- package/dist/{index-BiGeETJs.d.cts → index-iKsmdnq6.d.cts} +2 -2
- package/dist/{index-CmSjld-4.d.ts → index-nP13Qe6T.d.ts} +1 -1
- package/dist/{index-BJDXj9Wf.d.cts → index-p0bkNfby.d.cts} +3 -3
- package/dist/{index-aBqZUx3B.d.cts → index-wcfc7W-f.d.cts} +2 -2
- package/dist/{index-BwdPDWI4.d.cts → index-yJY9thRY.d.cts} +2 -2
- package/dist/{index-BbcSZCAG.d.ts → index-ygRFoyrN.d.ts} +2 -2
- package/dist/{index-Ip3q9T9x.d.ts → index-zA1uVtk0.d.ts} +1 -1
- package/dist/index.cjs +57 -57
- package/dist/index.d.cts +44 -44
- package/dist/index.d.ts +44 -44
- package/dist/index.js +1 -1
- package/dist/{meta-COtmHLwT.d.cts → meta-BdjSt8ky.d.cts} +1 -1
- package/dist/{meta-BMwx3ExI.d.ts → meta-CtDjj7cU.d.ts} +1 -1
- package/dist/{node-BVV7G1bq.d.cts → node-8qx0kgYt.d.cts} +49 -1
- package/dist/{node-BVV7G1bq.d.ts → node-8qx0kgYt.d.ts} +49 -1
- package/dist/{observable-BrUAPeH_.d.cts → observable-B6Ba-TTI.d.cts} +1 -1
- package/dist/{observable-ITikPXz3.d.ts → observable-DOniYM2B.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 +19 -19
- package/dist/patterns/ai/index.d.cts +16 -16
- package/dist/patterns/ai/index.d.ts +16 -16
- package/dist/patterns/ai/index.js +1 -1
- package/dist/patterns/ai/node.cjs +2 -2
- 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 +7 -7
- package/dist/patterns/audit/index.d.cts +5 -5
- package/dist/patterns/audit/index.d.ts +5 -5
- package/dist/patterns/audit/index.js +1 -1
- package/dist/patterns/cqrs/index.cjs +3 -3
- package/dist/patterns/cqrs/index.d.cts +4 -4
- package/dist/patterns/cqrs/index.d.ts +4 -4
- package/dist/patterns/cqrs/index.js +1 -1
- package/dist/patterns/demo-shell/index.cjs +6 -6
- 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 +6 -6
- 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 +8 -8
- 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 +7 -7
- package/dist/patterns/guarded-execution/index.d.cts +6 -6
- package/dist/patterns/guarded-execution/index.d.ts +6 -6
- package/dist/patterns/guarded-execution/index.js +1 -1
- package/dist/patterns/harness/index.cjs +12 -12
- package/dist/patterns/harness/index.d.cts +11 -10
- package/dist/patterns/harness/index.d.ts +11 -10
- package/dist/patterns/harness/index.js +1 -1
- package/dist/patterns/job-queue/index.cjs +7 -7
- package/dist/patterns/job-queue/index.d.cts +4 -4
- package/dist/patterns/job-queue/index.d.ts +4 -4
- package/dist/patterns/job-queue/index.js +1 -1
- package/dist/patterns/lens/index.cjs +5 -5
- 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 +4 -4
- package/dist/patterns/memory/index.d.cts +4 -4
- package/dist/patterns/memory/index.d.ts +4 -4
- package/dist/patterns/memory/index.js +1 -1
- package/dist/patterns/messaging/index.cjs +4 -4
- package/dist/patterns/messaging/index.d.cts +4 -4
- package/dist/patterns/messaging/index.d.ts +4 -4
- package/dist/patterns/messaging/index.js +1 -1
- package/dist/patterns/orchestration/index.cjs +7 -7
- package/dist/patterns/orchestration/index.d.cts +5 -5
- package/dist/patterns/orchestration/index.d.ts +5 -5
- package/dist/patterns/orchestration/index.js +1 -1
- package/dist/patterns/reactive-layout/index.cjs +1 -1
- 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 +1 -1
- 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 +7 -7
- package/dist/patterns/refine-loop/index.d.cts +5 -5
- package/dist/patterns/refine-loop/index.d.ts +5 -5
- 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 +6 -6
- package/dist/patterns/resilient-pipeline/index.d.ts +6 -6
- package/dist/patterns/resilient-pipeline/index.js +1 -1
- package/dist/patterns/surface/index.cjs +7 -7
- 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/{reactive-layout-Bq0rA2Wb.d.ts → reactive-layout-DBJ3Vz-m.d.ts} +2 -2
- package/dist/{reactive-layout-Dhhe54Oj.d.cts → reactive-layout-Dk9AOQb_.d.cts} +2 -2
- package/dist/{reactive-log-5jFeNRmd.d.cts → reactive-log-CWC7jO4J.d.cts} +1 -1
- package/dist/{reactive-log-BOJDCI5x.d.ts → reactive-log-CqaBg8nf.d.ts} +1 -1
- package/dist/{reactive-map-IJIfZxoh.d.cts → reactive-map-Cm89Hk0c.d.cts} +1 -1
- package/dist/{reactive-map-CtRaCddO.d.ts → reactive-map-LjwjcFaW.d.ts} +1 -1
- package/dist/{resilience-IVNDYORD.js → resilience-7UZHSSGC.js} +1 -1
- package/dist/{resilience-Q6Bt_7y0.d.cts → resilience-N_VtLf7W.d.cts} +1 -1
- package/dist/{resilience-CludlzcP.d.ts → resilience-RjDIHZNZ.d.ts} +1 -1
- package/dist/{sugar-BHbAACDG.d.ts → sugar-CQkn_rxB.d.ts} +1 -1
- package/dist/{sugar-CqR6DJ7v.d.cts → sugar-DVEYhR7a.d.cts} +1 -1
- package/dist/{topology-tree-CpSjvIXp.d.cts → topology-tree-BB6oJxMz.d.cts} +1 -1
- package/dist/{topology-tree-DAbCV2Yw.d.ts → topology-tree-CAFOG5S5.d.ts} +1 -1
- package/dist/{types-CdfO2QTt.d.ts → types-B2LfBvNc.d.ts} +16 -2
- package/dist/{types-BgMqbc7N.d.cts → types-Cp_4coR_.d.cts} +16 -2
- package/package.json +1 -1
- package/dist/chunk-2JNT5NDF.js +0 -61
- package/dist/chunk-2RH4QNDQ.js +0 -1
- package/dist/chunk-7AJKUA36.js +0 -1
- package/dist/chunk-LG73TUF4.js +0 -43
- package/dist/chunk-PNTBXOQ6.js +0 -5
- package/dist/chunk-ZWETYYQG.js +0 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as O,f as v,k as P}from"./chunk-2LZ6DL45.js";import{ba as _,k as A}from"./chunk-LOF5HSD3.js";import{d as E}from"./chunk-FKRPIRE6.js";import{m as U,w as T}from"./chunk-T7EQPKOP.js";import{o as y}from"./chunk-LYCLF26R.js";function G(e={}){return e.sdk?V(e):H(e)}function b(e,t,o,r){let s=t?.model??o;if(!s)throw new Error("anthropicAdapter: model must be set via options.model or invokeOpts.model");let{system:n,chat:i}=J(e,t?.systemPrompt),a={model:s,messages:i.map(F),max_tokens:t?.maxTokens??4096};return n&&(a.system=n),t?.temperature!=null&&(a.temperature=t.temperature),t?.tools&&t.tools.length>0&&(a.tools=t.tools.map(Y)),t?.maxReasoningTokens!=null&&(a.thinking={type:"enabled",budget_tokens:t.maxReasoningTokens}),t?.cacheHint,r&&(a.stream=!0),t?.providerExtras&&Object.assign(a,t.providerExtras),a}function J(e,t){let o=[];t&&o.push(t);let r=[];for(let s of e)s.role==="system"?o.push(s.content):r.push(s);return{system:o.length>0?o.join(`
|
|
2
|
+
|
|
3
|
+
`):void 0,chat:r}}function F(e){if(e.role==="tool")return{role:"user",content:[{type:"tool_result",tool_use_id:e.toolCallId,content:e.content}]};if(e.role==="assistant"&&e.toolCalls&&e.toolCalls.length>0){let t=[];e.content&&t.push({type:"text",text:e.content});for(let o of e.toolCalls)t.push({type:"tool_use",id:o.id,name:o.name,input:o.arguments});return{role:"assistant",content:t}}return{role:e.role,content:e.content}}function Y(e){return{name:e.name,description:e.description,input_schema:e.parameters}}function R(e,t){if(!e)return{...t};let o={...e};return t.input_tokens!=null&&(o.input_tokens=t.input_tokens),t.output_tokens!=null&&(o.output_tokens=t.output_tokens),t.cache_read_input_tokens!=null&&(o.cache_read_input_tokens=t.cache_read_input_tokens),t.cache_creation_input_tokens!=null&&(o.cache_creation_input_tokens=t.cache_creation_input_tokens),t.cache_creation&&(o.cache_creation={...e.cache_creation??{},...t.cache_creation}),t.server_tool_use&&(o.server_tool_use={...e.server_tool_use??{},...t.server_tool_use}),o}function x(e){let t={input:{regular:e?.input_tokens??0},output:{regular:e?.output_tokens??0},raw:e};return e?.cache_read_input_tokens&&(t.input.cacheRead=e.cache_read_input_tokens),e?.cache_creation?(e.cache_creation.ephemeral_5m_input_tokens&&(t.input.cacheWrite5m=e.cache_creation.ephemeral_5m_input_tokens),e.cache_creation.ephemeral_1h_input_tokens&&(t.input.cacheWrite1h=e.cache_creation.ephemeral_1h_input_tokens)):e?.cache_creation_input_tokens&&(t.input.cacheWrite5m=e.cache_creation_input_tokens),e?.server_tool_use?.web_search_requests&&(t.auxiliary={webSearchRequests:e.server_tool_use.web_search_requests}),t}function K(e,t){let o=[],r=[];for(let s of e.content)if(s.type==="text"&&typeof s.text=="string")o.push(s.text);else if(s.type==="tool_use"){let n=s;r.push({id:n.id,name:n.name,arguments:n.input??{}})}return{content:o.join(""),toolCalls:r.length>0?r:void 0,usage:x(e.usage),finishReason:e.stop_reason,latencyMs:t,model:e.model,provider:"anthropic"}}function H(e){let t=e.apiKey??globalThis.process?.env?.ANTHROPIC_API_KEY,o=e.baseURL??"https://api.anthropic.com",r=e.anthropicVersion??"2023-06-01",s=e.fetchImpl??fetch,n=()=>{if(!t)throw new Error("anthropicAdapter: apiKey required for invoke/stream (or provide opts.sdk)");return{"x-api-key":t,"anthropic-version":r,"content-type":"application/json",...e.headers??{}}};return{provider:"anthropic",model:e.model,async invoke(i,a){let d=b(i,a,e.model,!1),g=y(),l=await s(`${o}/v1/messages`,{method:"POST",headers:n(),body:JSON.stringify(d),signal:a?.signal});if(!l.ok)throw await _(l,"Anthropic");let c=await l.json(),p=Math.max(0,(y()-g)/1e6);return K(c,p)},async*stream(i,a){let d=b(i,a,e.model,!0),g=await s(`${o}/v1/messages`,{method:"POST",headers:{...n(),accept:"text/event-stream"},body:JSON.stringify(d),signal:a?.signal});if(!g.ok)throw await _(g,"Anthropic");if(!g.body)throw new Error("anthropicAdapter: streaming response has no body");let l,c,p=new Map;for await(let m of A(g.body,{signal:a?.signal})){let h=m.data;if(!h)continue;let k;try{k=JSON.parse(h)}catch{continue}switch(k.type){case"message_start":{l=R(l,k.message.usage);break}case"content_block_start":{let u=k,f=u.content_block;f.type==="tool_use"&&(p.set(u.index,{id:String(f.id??""),name:String(f.name??""),argBuf:""}),yield{type:"tool-call-delta",delta:{id:String(f.id??""),name:String(f.name??"")}});break}case"content_block_delta":{let u=k,f=u.delta;if(f.type==="text_delta"&&typeof f.text=="string")yield{type:"token",delta:f.text};else if(f.type==="input_json_delta"&&typeof f.partial_json=="string"){let S=p.get(u.index);S&&(S.argBuf+=f.partial_json),yield{type:"tool-call-delta",delta:{argumentsDelta:f.partial_json}}}else f.type==="thinking_delta"&&typeof f.thinking=="string"&&(yield{type:"thinking",delta:f.thinking});break}case"message_delta":{let u=k;u.delta.stop_reason&&(c=u.delta.stop_reason),u.delta.usage&&(l=R(l,u.delta.usage));break}case"message_stop":break}}l&&(yield{type:"usage",usage:x(l)}),yield{type:"finish",reason:c??"stop"}}}}function V(e){let t=e.sdk;if(!t)throw new Error("sdkBackedAnthropic: sdk instance required");return{provider:"anthropic",model:e.model,async invoke(o,r){let s=b(o,r,e.model,!1),n=y(),i=await t.messages.create(s,{signal:r?.signal}),a=Math.max(0,(y()-n)/1e6);return K(i,a)},async*stream(o,r){if(!t.messages.stream)throw new Error("sdkBackedAnthropic: SDK instance does not expose .messages.stream");let s=b(o,r,e.model,!0),n,i;for await(let a of t.messages.stream(s,{signal:r?.signal}))switch(a.type){case"message_start":n=R(n,a.message.usage);break;case"content_block_delta":{let d=a.delta;d?.type==="text_delta"&&typeof d.text=="string"?yield{type:"token",delta:d.text}:d?.type==="input_json_delta"&&typeof d.partial_json=="string"?yield{type:"tool-call-delta",delta:{argumentsDelta:d.partial_json}}:d?.type==="thinking_delta"&&typeof d.thinking=="string"&&(yield{type:"thinking",delta:d.thinking});break}case"message_delta":{let d=a;d.delta.stop_reason&&(i=d.delta.stop_reason),d.delta.usage&&(n=R(n,d.delta.usage));break}}n&&(yield{type:"usage",usage:x(n)}),yield{type:"finish",reason:i??"stop"}}}}function D(e={}){return e.sdk?X(e):Q(e)}function w(e,t){let o=[],r=[];t?.systemPrompt&&o.push(t.systemPrompt);for(let i of e){if(i.role==="system"){o.push(i.content);continue}if(i.role==="tool"){r.push({role:"user",parts:[{functionResponse:{name:i.name??i.toolCallId??"tool",response:{result:i.content}}}]});continue}if(i.role==="assistant"&&i.toolCalls&&i.toolCalls.length>0){let a=[];i.content&&a.push({text:i.content});for(let d of i.toolCalls)a.push({functionCall:{name:d.name,args:d.arguments}});r.push({role:"model",parts:a});continue}r.push({role:i.role==="assistant"?"model":"user",parts:[{text:i.content}]})}let s={contents:r};o.length>0&&(s.systemInstruction={role:"system",parts:[{text:o.join(`
|
|
4
|
+
|
|
5
|
+
`)}]});let n={};return t?.maxTokens!=null&&(n.maxOutputTokens=t.maxTokens),t?.temperature!=null&&(n.temperature=t.temperature),t?.maxReasoningTokens!=null&&(n.thinkingConfig={thinkingBudget:t.maxReasoningTokens}),Object.keys(n).length>0&&(s.generationConfig=n),t?.tools&&t.tools.length>0&&(s.tools=[{functionDeclarations:t.tools.map(W)}]),t?.providerExtras&&Object.assign(s,t.providerExtras),s}function W(e){return{name:e.name,description:e.description,parameters:e.parameters}}function j(e,t,o){let r={},s=e.generationConfig;s&&(typeof s.maxOutputTokens=="number"&&(r.maxOutputTokens=s.maxOutputTokens),typeof s.temperature=="number"&&(r.temperature=s.temperature),s.thinkingConfig&&(r.thinkingConfig=s.thinkingConfig)),e.systemInstruction&&(r.systemInstruction=e.systemInstruction),e.tools&&(r.tools=e.tools);for(let[n,i]of Object.entries(e))n==="contents"||n==="generationConfig"||n==="systemInstruction"||n==="tools"||n==="abortSignal"||n==="model"||(r[n]=i);return o&&(r.abortSignal=o),{model:t,contents:e.contents,config:Object.keys(r).length>0?r:void 0}}function M(e){let t={input:{regular:0},output:{regular:0},raw:e};if(!e)return t;let o=e.promptTokenCount??0,r=e.cachedContentTokenCount??0;if(t.input.regular=Math.max(0,o-r),r>0&&(t.input.cacheRead=r),e.toolUsePromptTokenCount&&(t.input.toolUse=e.toolUsePromptTokenCount),e.promptTokensDetails)for(let s of e.promptTokensDetails){let n=s.modality?.toLowerCase();n==="image"?t.input.image=(t.input.image??0)+s.tokenCount:n==="audio"?t.input.audio=(t.input.audio??0)+s.tokenCount:n==="video"&&(t.input.video=(t.input.video??0)+s.tokenCount)}return t.output.regular=e.candidatesTokenCount??0,e.thoughtsTokenCount&&(t.output.reasoning=e.thoughtsTokenCount),t}function B(e,t){let o=e.candidates?.[0],r=o?.content?.parts??[],s=[],n=[],i=0;for(let a of r)typeof a.text=="string"&&s.push(a.text),a.functionCall&&n.push({id:`${a.functionCall.name}-${i++}`,name:a.functionCall.name,arguments:a.functionCall.args??{}});return{content:s.join(""),toolCalls:n.length>0?n:void 0,usage:M(e.usageMetadata),finishReason:o?.finishReason,latencyMs:t,model:e.modelVersion,provider:"google"}}function z(e){if(e.apiKey)return e.apiKey;let t=globalThis.process?.env;return t?.GOOGLE_API_KEY??t?.GEMINI_API_KEY}function Q(e){let t=e.baseURL??"https://generativelanguage.googleapis.com/v1beta",o=e.fetchImpl??fetch,r=n=>{let i=n?.model??e.model;if(!i)throw new Error("googleAdapter: model must be set via options.model or invokeOpts.model");return i},s=()=>{let n=z(e);if(!n)throw new Error("googleAdapter: apiKey required for invoke/stream");return`key=${encodeURIComponent(n)}`};return{provider:"google",model:e.model,async invoke(n,i){let a=r(i),d=w(n,i),g=y(),l=`${t}/models/${encodeURIComponent(a)}:generateContent?${s()}`,c=await o(l,{method:"POST",headers:{"content-type":"application/json",...e.headers??{}},body:JSON.stringify(d),signal:i?.signal});if(!c.ok)throw await _(c,"Google");let p=await c.json(),m=Math.max(0,(y()-g)/1e6);return B(p,m)},async*stream(n,i){let a=r(i),d=w(n,i),g=`${t}/models/${encodeURIComponent(a)}:streamGenerateContent?alt=sse&${s()}`,l=await o(g,{method:"POST",headers:{"content-type":"application/json",accept:"text/event-stream",...e.headers??{}},body:JSON.stringify(d),signal:i?.signal});if(!l.ok)throw await _(l,"Google");if(!l.body)throw new Error("googleAdapter: streaming response has no body");let c,p;for await(let m of A(l.body,{signal:i?.signal})){if(!m.data)continue;let h;try{h=JSON.parse(m.data)}catch{continue}let k=h.candidates?.[0];for(let u of k?.content?.parts??[])typeof u.text=="string"&&(u.thought?yield{type:"thinking",delta:u.text}:yield{type:"token",delta:u.text}),u.functionCall&&(yield{type:"tool-call-delta",delta:{name:u.functionCall.name,argumentsDelta:JSON.stringify(u.functionCall.args??{})}});k?.finishReason&&(p=k.finishReason),h.usageMetadata&&(c=h.usageMetadata)}c&&(yield{type:"usage",usage:M(c)}),yield{type:"finish",reason:p??"stop"}}}}function X(e){let t=e.sdk;if(!t)throw new Error("sdkBackedGoogle: sdk instance required");return{provider:"google",model:e.model,async invoke(o,r){let s=w(o,r),n=r?.model??e.model;if(!n)throw new Error("googleAdapter: model required");let i=j(s,n,r?.signal),a=y(),d=await t.models.generateContent(i),g=Math.max(0,(y()-a)/1e6);return B(d,g)},async*stream(o,r){if(!t.models.generateContentStream)throw new Error("sdkBackedGoogle: SDK instance does not expose generateContentStream");let s=w(o,r),n=r?.model??e.model;if(!n)throw new Error("googleAdapter: model required");let i=j(s,n,r?.signal),a,d,g=await t.models.generateContentStream(i);for await(let l of g){let c=l.candidates?.[0];for(let p of c?.content?.parts??[])typeof p.text=="string"&&(p.thought?yield{type:"thinking",delta:p.text}:yield{type:"token",delta:p.text}),p.functionCall&&(yield{type:"tool-call-delta",delta:{name:p.functionCall.name,argumentsDelta:JSON.stringify(p.functionCall.args??{})}});c?.finishReason&&(d=c.finishReason),l.usageMetadata&&(a=l.usageMetadata)}a&&(yield{type:"usage",usage:M(a)}),yield{type:"finish",reason:d??"stop"}}}}var Z={openai:{baseURL:"https://api.openai.com/v1",apiKeyEnv:"OPENAI_API_KEY",provider:"openai"},openrouter:{baseURL:"https://openrouter.ai/api/v1",apiKeyEnv:"OPENROUTER_API_KEY",provider:"openrouter"},groq:{baseURL:"https://api.groq.com/openai/v1",apiKeyEnv:"GROQ_API_KEY",provider:"groq"},ollama:{baseURL:"http://localhost:11434/v1",provider:"ollama"},deepseek:{baseURL:"https://api.deepseek.com/v1",apiKeyEnv:"DEEPSEEK_API_KEY",provider:"deepseek"},xai:{baseURL:"https://api.x.ai/v1",apiKeyEnv:"XAI_API_KEY",provider:"xai"}};function q(e={}){return e.sdk?re(e):oe(e)}function C(e,t,o,r,s){let n=t?.model??o;if(!n)throw new Error("openAICompatAdapter: model must be set via options.model or invokeOpts.model");let i=e.map(ee);t?.systemPrompt&&!e.some(d=>d.role==="system")&&i.unshift({role:"system",content:t.systemPrompt});let a={model:n,messages:i};return t?.maxTokens!=null&&(a.max_tokens=t.maxTokens),t?.temperature!=null&&(a.temperature=t.temperature),t?.tools&&t.tools.length>0&&(a.tools=t.tools.map(te)),t?.maxReasoningTokens!=null&&(a.reasoning={max_tokens:t.maxReasoningTokens}),r&&(a.stream=!0,a.stream_options={include_usage:!0}),s&&Object.assign(a,s),t?.providerExtras&&Object.assign(a,t.providerExtras),a}function ee(e){return e.role==="tool"?{role:"tool",tool_call_id:e.toolCallId,content:e.content}:e.role==="assistant"&&e.toolCalls&&e.toolCalls.length>0?{role:"assistant",content:e.content||null,tool_calls:e.toolCalls.map(t=>({id:t.id,type:"function",function:{name:t.name,arguments:JSON.stringify(t.arguments)}}))}:{role:e.role,content:e.content}}function te(e){return{type:"function",function:{name:e.name,description:e.description,parameters:e.parameters}}}function I(e){let t={input:{regular:0},output:{regular:0},raw:e};if(!e)return t;let o=e.prompt_tokens??0,r=e.prompt_tokens_details?.cached_tokens??0;e.prompt_cache_hit_tokens!=null?(r=e.prompt_cache_hit_tokens,t.input.regular=e.prompt_cache_miss_tokens??Math.max(0,o-r)):t.input.regular=Math.max(0,o-r),r>0&&(t.input.cacheRead=r),e.prompt_tokens_details?.audio_tokens&&(t.input.audio=e.prompt_tokens_details.audio_tokens);let s=e.completion_tokens??0,n=e.completion_tokens_details?.reasoning_tokens??0;return t.output.regular=Math.max(0,s-n),n>0&&(t.output.reasoning=n),e.completion_tokens_details?.audio_tokens&&(t.output.audio=e.completion_tokens_details.audio_tokens),e.completion_tokens_details?.accepted_prediction_tokens&&(t.output.predictionAccepted=e.completion_tokens_details.accepted_prediction_tokens),e.completion_tokens_details?.rejected_prediction_tokens&&(t.output.predictionRejected=e.completion_tokens_details.rejected_prediction_tokens),t}function $(e,t,o){let r=e.choices[0],s=r?.message,n=s?.content??"",i=(s?.tool_calls??[]).map(a=>({id:a.id,name:a.function.name,arguments:ne(a.function.arguments)}));return{content:n,toolCalls:i.length>0?i:void 0,usage:I(e.usage),finishReason:r?.finish_reason,latencyMs:t,model:e.model,provider:o}}function ne(e){try{let t=JSON.parse(e);return typeof t=="object"&&t!=null?t:{_raw:e}}catch{return{_raw:e}}}function N(e){let t=e.preset??"openai",o=Z[t],r=e.baseURL??o.baseURL,s=e.provider??o.provider,n=o.apiKeyEnv,i=e.apiKey??(n?globalThis.process?.env?.[n]:void 0);return{provider:s,baseURL:r,apiKey:i}}function oe(e){let{provider:t,baseURL:o,apiKey:r}=N(e),s=e.fetchImpl??fetch,n=t!=="ollama",i=()=>{let a={"content-type":"application/json",...e.headers??{}};if(n){if(!r)throw new Error(`openAICompatAdapter[${t}]: apiKey required for invoke/stream`);a.authorization=`Bearer ${r}`}return a};return{provider:t,model:e.model,async invoke(a,d){let g=C(a,d,e.model,!1,e.bodyExtras),l=y(),c=await s(`${o}/chat/completions`,{method:"POST",headers:i(),body:JSON.stringify(g),signal:d?.signal});if(!c.ok)throw await _(c,t);let p=await c.json(),m=Math.max(0,(y()-l)/1e6);return $(p,m,t)},async*stream(a,d){let g=C(a,d,e.model,!0,e.bodyExtras),l=await s(`${o}/chat/completions`,{method:"POST",headers:{...i(),accept:"text/event-stream"},body:JSON.stringify(g),signal:d?.signal});if(!l.ok)throw await _(l,t);if(!l.body)throw new Error(`openAICompatAdapter[${t}]: streaming response has no body`);let c,p;for await(let m of A(l.body,{signal:d?.signal})){if(!m.data||m.data==="[DONE]")continue;let h;try{h=JSON.parse(m.data)}catch{continue}let k=h.choices;if(k){let u=k[0];if(u?.delta?.content&&(yield{type:"token",delta:u.delta.content}),u?.delta?.reasoning_content&&(yield{type:"thinking",delta:u.delta.reasoning_content}),u?.delta?.tool_calls)for(let f of u.delta.tool_calls)yield{type:"tool-call-delta",delta:{id:f.id,name:f.function?.name,argumentsDelta:f.function?.arguments}};u?.finish_reason&&(p=u.finish_reason)}h.usage&&(c=h.usage,yield{type:"usage",usage:I(c)})}yield{type:"finish",reason:p??"stop"}}}}function re(e){let t=e.sdk;if(!t)throw new Error("sdkBackedOpenAI: sdk instance required");let{provider:o}=N(e);return{provider:o,model:e.model,async invoke(r,s){let n=C(r,s,e.model,!1,e.bodyExtras),i=y(),a=await t.chat.completions.create(n,{signal:s?.signal}),d=Math.max(0,(y()-i)/1e6);return $(a,d,o)},async*stream(r,s){let n=C(r,s,e.model,!0,e.bodyExtras),i=await t.chat.completions.create(n,{signal:s?.signal}),a,d;for await(let g of i){let l=g.choices;if(l){let p=l[0];if(p?.delta?.content&&(yield{type:"token",delta:p.delta.content}),p?.delta?.reasoning_content&&(yield{type:"thinking",delta:p.delta.reasoning_content}),p?.delta?.tool_calls)for(let m of p.delta.tool_calls)yield{type:"tool-call-delta",delta:{id:m.id,name:m.function?.name,argumentsDelta:m.function?.arguments}};p?.finish_reason&&(d=p.finish_reason)}let c=g.usage;c&&(a=c,yield{type:"usage",usage:I(c)})}yield{type:"finish",reason:d??"stop"}}}}function Re(e){switch(e.provider){case"anthropic":{let t={apiKey:e.apiKey,model:e.model,baseURL:e.baseURL,headers:e.headers,sdk:e.sdk,fetchImpl:e.fetchImpl,...e.extras};return G(t)}case"google":{let t={apiKey:e.apiKey,model:e.model,baseURL:e.baseURL,headers:e.headers,sdk:e.sdk,fetchImpl:e.fetchImpl,...e.extras};return D(t)}case"dry-run":{let t={model:e.model,...e.extras};return O(t)}case"fallback":{let t={provider:e.provider,model:e.model,...e.extras};return P(t)}case"openai":case"openrouter":case"groq":case"ollama":case"deepseek":case"xai":{let t={preset:e.provider,apiKey:e.apiKey,model:e.model,baseURL:e.baseURL,headers:e.headers,bodyExtras:e.bodyExtras,sdk:e.sdk,fetchImpl:e.fetchImpl,...e.extras};return q(t)}default:{let t=e.provider;throw new Error(`createAdapter: unknown provider: ${String(t)}`)}}}var L=class extends Error{name="AllTiersExhaustedError";skipped;failed;constructor(t){let o=[];t.failed.size>0&&o.push(`failed=[${[...t.failed.keys()].join(",")}]`),t.skipped.length>0&&o.push(`skipped=[${t.skipped.map(r=>`${r.name}(${r.reason})`).join(",")}]`),super(`All LLM adapter tiers exhausted: ${o.join(" ")}`),this.skipped=t.skipped,this.failed=t.failed}};function Me(e,t={}){if(e.length===0)throw new RangeError("cascadingLlmAdapter: tiers must be non-empty");let o=e.map(n=>({name:n.name,adapter:n.adapter,filter:n.filter,breaker:n.breaker?"canExecute"in n.breaker?n.breaker:E(n.breaker):void 0})),r=t.streamRetryBeforeFirstChunk??!0,s={provider:"cascading",model:void 0,async invoke(n,i){let a=[],d=new Map;for(let l=0;l<o.length;l++){let c=o[l];if(c.filter&&!c.filter(n,i)){a.push({name:c.name,reason:"filter"});continue}if(c.breaker&&!c.breaker.canExecute()){a.push({name:c.name,reason:"breaker"});continue}try{let p=await T(U(c.adapter.invoke(n,i)));return c.breaker?.recordSuccess(),{...p,metadata:{...p.metadata??{},tier:c.name}}}catch(p){d.set(c.name,p),c.breaker?.recordFailure(p);let m=o[l+1];m&&t.onFallback?.(c.name,m.name,p)}}let g={skipped:a,failed:d};throw t.onExhausted?.(g),new L(g)},async*stream(n,i){let a=[],d=new Map;for(let l=0;l<o.length;l++){let c=o[l];if(c.filter&&!c.filter(n,i)){a.push({name:c.name,reason:"filter"});continue}if(c.breaker&&!c.breaker.canExecute()){a.push({name:c.name,reason:"breaker"});continue}let p=!1;try{for await(let m of c.adapter.stream(n,i))p=!0,yield m;c.breaker?.recordSuccess();return}catch(m){if(d.set(c.name,m),c.breaker?.recordFailure(m),p||!r)throw m;let h=o[l+1];h&&t.onFallback?.(c.name,h.name,m)}}let g={skipped:a,failed:d};throw t.onExhausted?.(g),new L(g)}};return v(s,`cascade[${o.map(n=>n.name).join(",")}]`),s}function Ie(e,t,o){let r={name:e,adapter:t};return o?.breaker&&(r.breaker=o.breaker),o?.filter&&(r.filter=o.filter),r}export{G as a,D as b,q as c,Re as d,L as e,Me as f,Ie as g};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{E as l,J as f}from"./chunk-
|
|
1
|
+
import{E as l,J as f}from"./chunk-LYCLF26R.js";import{b as m,j as d}from"./chunk-CK2E7BTU.js";import{b as p}from"./chunk-QYADASLV.js";var F={};p(F,{atom:()=>A});function A(s,n,e){if(typeof s=="function"){let t=s;return typeof n=="function"?b(t,n,e):b(t,void 0,n)}return v(s,n)}function c(s){let n=s.cache,e;if(s.subscribe(i=>{for(let[r,o]of i)r===m&&(n=o),r===d&&(e=o)})(),e)throw e;return n}function v(s,n){let e=l(s,{...n,resubscribable:!0,resetOnTeardown:!0});return{get:()=>e.status==="sentinel"?c(e):e.cache,set:t=>e.emit(t),update:t=>{let i=e.status==="sentinel"?c(e):e.cache;e.emit(t(i))},subscribe:t=>{let i=!0;return e.subscribe(r=>{for(let[o,a]of r)if(o===m){if(i){i=!1;continue}t(a)}})},meta:e.meta,_node:e}}function b(s,n,e){let t=f(r=>s(o=>{let a=o._node;return a.status==="sentinel"&&c(a),r(a)}),{...e,resubscribable:!0,resetOnTeardown:!0}),i={get:()=>t.status==="sentinel"?c(t):t.cache,subscribe:r=>{let o=!0;return t.subscribe(a=>{for(let[u,T]of a)if(u===m){if(o){o=!1;continue}r(T)}})},meta:t.meta,_node:t};if(n){let r=u=>u.get(),o=(u,T)=>u.set(T),a=i;return a.set=u=>n(r,o,u),a.update=u=>{let T=t.status==="sentinel"?c(t):t.cache;return n(r,o,u(T))},a}return i}export{A as a,F as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as u,n as i}from"./chunk-
|
|
1
|
+
import{A as u,n as i}from"./chunk-LYCLF26R.js";import{b as t,c as o}from"./chunk-CK2E7BTU.js";function s(r,n){r!=null&&i(e=>r.down(e),[[t,n]],u.tierOf)}function p(r,n){let e=r.cache??0;return e>=n?!1:(r.down([[o],[t,e+1]]),!0)}function g(r,n,e){return{[r]:!0,[`${r}_type`]:n,...e??{}}}function l(r){return r.relatedTo?.[0]??r.summary}export{s as a,p as b,g as c,l as d};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as Ne,i as Re}from"./chunk-
|
|
1
|
+
import{b as Ne,i as Re}from"./chunk-FKRPIRE6.js";import{a as Pe}from"./chunk-SGS4OJGS.js";import{x as fe}from"./chunk-4F564IPP.js";import{a as Z,b as de,i as Oe}from"./chunk-4VVTGLXJ.js";import{f as pe}from"./chunk-T7EQPKOP.js";import{A as ee,D as be,E as U,F as B,m as _,p as D}from"./chunk-LYCLF26R.js";import{b as E,c as ye,d as ke,h as le,i as P,j as x}from"./chunk-CK2E7BTU.js";function Ce(r){return{describeKind:"producer",...r}}function oe(r,n){return B(i=>{let s=!0,u={emit(t){s&&i.emit(t)},error(t){s&&(s=!1,i.down([[x,t]]))},complete(){s&&(s=!1,i.down([[P]]))}},o;try{let t=r(u);o=typeof t=="function"?t:void 0}catch(t){return u.error(t),()=>{s=!1}}return()=>{s=!1;try{o?.()}catch{}}},Ce(n))}function Me(r,n,i){let s=!0,u,o=0,t=0,e={},a=[],l=()=>{let d=u;u=void 0;try{d?.()}catch{}};for(let d of n){let p=i?.name?`${i.name}::${d}`:d,g=i?.channelOpts?.[d],y=B(T=>(o++,()=>{t++,o>0&&t>=o&&t>=n.length&&l()}),Ce({...g,name:p}));e[d]=y,a.push(y)}let m={};for(let d of n)m[d]=p=>{s&&e[d].down([[E,p]])};m.error=d=>{s&&(s=!1,_(()=>{for(let p of a)p.down([[x,d]])}),l())},m.complete=()=>{s&&(s=!1,_(()=>{for(let d of a)d.down([[P]])}),l())};let f=r(m);return u=typeof f=="function"?f:void 0,Object.assign(e,{dispose:()=>{s&&(s=!1,_(()=>{for(let d of a)try{d.down([[P]])}catch{}}),l())}})}var he=class{ring;arr;constructor(n){n===Number.POSITIVE_INFINITY||n<=0?(this.arr=[],this.ring=null):(this.ring=new Pe(n),this.arr=null)}get length(){return this.ring!=null?this.ring.size:this.arr.length}push(n){this.ring!=null?this.ring.push(n):this.arr.push(n)}shift(){return this.ring!=null?this.ring.shift():this.arr.shift()}drain(){if(this.ring!=null){let i=this.ring.toArray();return this.ring.clear(),i}let n=this.arr;return this.arr=[],n}};function se(r){return r instanceof Error?r:new Error(String(r))}function De(r){return r===void 0?null:typeof r=="string"?Oe(r):r}function z(r,n){let{name:i,onTransportError:s,retry:u,backpressure:o,batchSize:t=Number.POSITIVE_INFINITY,flushIntervalMs:e=0,serialize:a,stopOn:l,onUpstreamMessage:m,onDispose:f,send:c,sendBatch:d,ctx:p}=n;if(!c&&!d)throw new Error("reactiveSink: `send` or `sendBatch` must be provided");let g=p,y=Math.max(1,u?.maxAttempts??1),T=De(u?.backoff??(y>1?"exponential":void 0)),h=u?.shouldRetry??(()=>!0),b=d!==void 0||t<Number.POSITIVE_INFINITY||e>0,w=k=>i?`${i}::${k}`:void 0,v=U(void 0,{equals:()=>!1,name:w("sent")}),S=U(null,{name:w("failed")}),L=U(0,{name:w("inFlight")}),F=U(null,{name:w("errors")}),K=b?U(0,{name:w("buffered")}):void 0,G=o?U(!1,{name:w("paused")}):void 0,ie=0,Q=k=>{ie+=k,L.down([[E,ie]])},O=k=>{try{s?.(k)}catch{}try{F.down([[E,k]])}catch{}},q=new Set,J=k=>{q.add(k);let N=()=>q.delete(k);k.then(N,N)},I=(k,N,C)=>{let A=T?T(N-1,C,null):0,H=A==null?0:typeof A=="number"&&A>0?A:0,$=Math.max(1,Math.ceil(H/1e6));return new Promise(M=>{setTimeout(()=>M(k()),$)})},W=k=>k!=null&&typeof k=="object"&&typeof k.then=="function",V=k=>{let N;try{N=a?a(k):k}catch(M){let R=se(M);return O({stage:"serialize",error:R,value:k}),S.down([[E,{value:k,error:R,attempts:0}]]),Promise.resolve()}let C=0,A=M=>{Q(-1);let R=se(M);if(O({stage:"send",error:R,value:k,attempt:C}),!(C<y&&h(R,C))){S.down([[E,{value:k,error:R,attempts:C}]]);return}return I($,C,R)},H=()=>{Q(-1),v.down([[E,k]])};function $(){C+=1,Q(1);let M;try{M=c(N,g)}catch(R){return A(R)??Promise.resolve()}return W(M)?M.then(H,R=>A(R)):(H(),Promise.resolve())}return $()},te=o?.maxBuffer??Number.POSITIVE_INFINITY,X=new he(te),Y,ae=!1,me=()=>{K?.down([[E,X.length]])},ue=k=>{G&&G.down([[E,k]])},we=o?.strategy??"drop-oldest",Be=(k,N)=>{let C={value:k,payload:N};if(X.length<te)return X.push(C),me(),!0;if(we==="drop-oldest"){let H=X.shift();return X.push(C),me(),ue(!0),S.down([[E,{value:H.value,error:new Error("backpressure: buffer overflow \u2014 dropped oldest"),attempts:0}]]),!0}if(we==="drop-newest")return ue(!0),S.down([[E,{value:k,error:new Error("backpressure: buffer overflow \u2014 dropped newest"),attempts:0}]]),!1;let A=new Error("backpressure: buffer overflow");return O({stage:"send",error:A,value:k}),S.down([[E,{value:k,error:A,attempts:0}]]),ue(!0),!1},Fe=k=>{let N=0,C=k.map(M=>M.payload),A=M=>{Q(-1);let R=se(M);if(O({stage:"send",error:R,value:k.map(ge=>ge.value),attempt:N}),!(N<y&&h(R,N))){for(let{value:ge}of k)S.down([[E,{value:ge,error:R,attempts:N}]]);return}return I($,N,R)},H=()=>{Q(-1);for(let{value:M}of k)v.down([[E,M]])};function $(){N+=1,Q(1);let M;try{M=d(C,g)}catch(R){return A(R)??Promise.resolve()}return W(M)?M.then(H,R=>A(R)):(H(),Promise.resolve())}return $()},He=async k=>{for(let N of k)await ze(N.value,N.payload)},ze=(k,N)=>{let C=0,A=M=>{Q(-1);let R=se(M);if(O({stage:"send",error:R,value:k,attempt:C}),!(C<y&&h(R,C))){S.down([[E,{value:k,error:R,attempts:C}]]);return}return I($,C,R)},H=()=>{Q(-1),v.down([[E,k]])};function $(){C+=1,Q(1);let M;try{M=c(N,g)}catch(R){return A(R)??Promise.resolve()}return W(M)?M.then(H,R=>A(R)):(H(),Promise.resolve())}return $()},ne=()=>{if(ae||X.length===0)return Promise.resolve();let k=X.drain();if(me(),ue(!1),d!==void 0){let C=Fe(k);return J(C),C}let N=He(k);return J(N),N},qe=()=>{Y!==void 0||ae||e<=0||(Y=setTimeout(()=>{Y=void 0,ne()},e))},Ue=r.subscribe(k=>{for(let N of k){let C=N[0];if(C!==E)try{m?.(N)}catch{}if(C===E){let A=N[1];if(b){let H;if(a)try{H=a(A)}catch(M){let R=se(M);O({stage:"serialize",error:R,value:A}),S.down([[E,{value:A,error:R,attempts:0}]]);continue}else H=A;if(!Be(A,H))continue;X.length>=t?ne():qe()}else{let H=V(A);J(H)}}else ee.messageTier(C)>=3&&b&&(Y!==void 0&&(clearTimeout(Y),Y=void 0),ne())}}),Se;if(l){let k=!1;Se=l.subscribe(N=>{if(!k){k=!0;return}N.length>0&&!Te&&Ee()})}let Te=!1,Ee=()=>{if(Te)return;Te=!0,Y!==void 0&&(clearTimeout(Y),Y=void 0),b&&ne(),ae=!0,Se?.(),Ue();let k=N=>{try{N.down([[le]])}catch{}};k(F),k(S),k(v),k(L),K&&k(K),G&&k(G);try{f?.()}catch{}},ce={dispose:Ee,sent:v,failed:S,inFlight:L,errors:F};return b&&(ce.buffered=K,ce.flush=async()=>{ae||(await ne(),await Promise.all(q))}),G&&(ce.paused=G),ce}function j(r){return{describeKind:"producer",...r}}function Ke(r,n){let{parse:i,closeOnTeardown:s=!1,...u}=n??{};return B(o=>{let t=!0,e,a=()=>{let T=e;e=void 0,T?.()},l=T=>{t&&(t=!1,o.down([T]),a())},m=(T,h=T)=>{if(t)try{let b=T!==null&&typeof T=="object"&&"data"in T?T.data:T,w=i?i(b,h):b;o.emit(w)}catch(b){l([x,b])}},f=T=>{l([x,T])},c=()=>{l([P])};if(typeof r=="function"){try{if(e=r(m,f,c),typeof e!="function")throw new Error("fromWebSocket register contract violation: register must return cleanup callable")}catch(T){l([x,T])}return()=>{t=!1,a()}}let d=r,p=T=>m(T,T),g=T=>f(T),y=()=>c();return d.addEventListener("message",p),d.addEventListener("error",g),d.addEventListener("close",y),e=()=>{d.removeEventListener("message",p),d.removeEventListener("error",g),d.removeEventListener("close",y),s&&d.close()},()=>{t=!1,a()}},j(u))}function Tr(r,n){return oe(r,n)}function We(r,n){let{method:i="GET",headers:s,body:u,transform:o=b=>b.json(),timeoutNs:t=30*1e9,signal:e,completeAfterFetch:a=!1,refetchOnSubscribe:l=!1,...m}=n??{},f=U(0,{name:`${m.name??"http"}/fetchCount`}),c=U(0,{name:`${m.name??"http"}/lastUpdated`}),d=U(!1,{name:`${m.name??"http"}/fetched`}),p=0,g=u!==void 0?typeof u=="string"?u:JSON.stringify(u):void 0,y=b=>{let w=new AbortController,v=!0;if(e?.aborted)return v=!1,b.down([[x,e.reason??new Error("Aborted")]]),()=>{};e?.addEventListener("abort",()=>w.abort(e.reason),{once:!0});let S=setTimeout(()=>w.abort(new Error("Request timeout")),Math.ceil(t/1e6));return fetch(r,{method:i,headers:s,body:g,signal:w.signal}).then(async L=>{if(clearTimeout(S),!v)return;if(!L.ok)throw new Error(`HTTP ${L.status}: ${L.statusText}`);let F=await o(L);v&&(_(()=>{p+=1,f.down([[E,p]]),c.down([[E,D()]]),d.down([[E,!0]]),b.emit(F)}),a&&b.down([[P]]))}).catch(L=>{clearTimeout(S),v&&(L&&L.name==="AbortError"||b.down([[x,L]]))}),()=>{v=!1,w.abort()}},T=B(b=>y({emit:w=>b.emit(w),down:w=>b.down(w)}),{...j(m),resubscribable:l});return{...Re(T),fetchCount:f,lastUpdated:c,fetched:d}}function gr(r,n,i){let{method:s="POST",headers:u={"Content-Type":"application/json"},serialize:o=p=>JSON.stringify(p),timeoutNs:t,batchFormat:e="json-array",batchSize:a,flushIntervalMs:l,retry:m,onTransportError:f}=i??{},c=async p=>{let g=t!==void 0?new AbortController:void 0,y;g&&t!==void 0&&(y=setTimeout(()=>g.abort(new Error("Request timeout")),Math.ceil(t/1e6)));try{let T=await fetch(n,{method:s,headers:u,body:p,signal:g?.signal}),h=async()=>{try{await T.arrayBuffer?.()}catch{}};if(!T.ok)throw await h(),new Error(`HTTP ${T.status}: ${T.statusText}`);await h()}finally{y!==void 0&&clearTimeout(y)}};return a!==void 0||l!==void 0?z(r,{onTransportError:f,retry:m,batchSize:a,flushIntervalMs:l,sendBatch:async p=>{let g;e==="ndjson"?g=p.map(y=>{let T=o(y);return typeof T=="string"?T:new TextDecoder().decode(T)}).join(`
|
|
2
2
|
`):g=JSON.stringify(p),await c(g)}}):z(r,{onTransportError:f,retry:m,serialize:o,send:async p=>{await c(p)}})}function Ae(r){return Symbol.keyFor(r)??r.description??"message"}function re(r,n){return typeof r=="string"?r:n(r)}function Le(r,n){let i=`event: ${r}
|
|
3
3
|
`;if(n!==void 0){let s=n.split(/\r?\n/);for(let u of s)i+=`data: ${u}
|
|
4
4
|
`}return`${i}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Y,b,c as M,d as S,e as R,f as N,g as L,h as k,i as C,j as _,k as P,l as he,n as se,q as ie,r as fe,s as pe,t as _e,u as re}from"./chunk-CK2E7BTU.js";var Ce={name:"json",version:1,contentType:"application/json",encode(n){let e=JSON.stringify(n);return new TextEncoder().encode(e)},decode(n,e){let t=new TextDecoder().decode(n);return JSON.parse(t)}};function $e(n){return{name:"dag-cbor",version:1,contentType:"application/dag-cbor",encode:e=>n.encode(e),decode:(e,t)=>n.decode(e)}}function je(n,e){return{name:"dag-cbor-zstd",version:1,contentType:"application/dag-cbor+zstd",encode:t=>e.compressSync(n.encode(t)),decode:(t,s)=>n.decode(e.decompressSync(t))}}var oe=1,ge=4;function ze(n,e){let t=new TextEncoder().encode(n.name);if(t.length===0||t.length>255)throw new Error(`encodeEnvelope: codec name "${n.name}" encodes to ${t.length} bytes (must be 1\u2013255)`);let s=n.version;if(!Number.isInteger(s)||s<0||s>65535)throw new Error(`encodeEnvelope: codec.version ${s} out of u16 range (expected integer 0\u201365535)`);let i=2+t.length+2+e.length;if(i>4294967295)throw new Error(`encodeEnvelope: total envelope size ${i} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let r=new Uint8Array(i),a=0;return r[a++]=oe,r[a++]=t.length,r.set(t,a),a+=t.length,r[a++]=s>>>8&255,r[a++]=s&255,r.set(e,a),r}function qe(n,e){if(n.length<ge)throw new Error(`decodeEnvelope: bytes too short (${n.length} < ${ge})`);let t=0,s=n[t++];if(s!==oe)throw new Error(`decodeEnvelope: unsupported envelope version ${s} (expected ${oe})`);let i=n[t++];if(i===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(t+i+2>n.length)throw new Error(`decodeEnvelope: envelope truncated (need ${t+i+2} bytes, have ${n.length})`);let r=new TextDecoder().decode(n.subarray(t,t+i));t+=i;let a=(n[t]<<8|n[t+1])>>>0;t+=2;let o=n.subarray(t),d=e.lookupCodec(r);if(d==null)throw new Error(`decodeEnvelope: codec "${r}" not registered (envelope codec_v=${a})`);return{codec:d,codecVersion:a,payload:o}}function ye(n){n.registerCodec(Ce)}function Ke(n){if(n.length===0)throw new Error("WAL is empty \u2014 need at least one full snapshot");let e=n[0];if(e.mode!=="full")throw new Error("WAL must start with a full record carrying a baseline snapshot");let t=JSON.parse(JSON.stringify(e.snapshot)),s=e.seq;for(let i=1;i<n.length;i++){let r=n[i];if(r.seq<=s)throw new Error(`WAL chain broken at index ${i}: seq=${r.seq} must exceed prev seq=${s}`);if(r.mode==="full"){t=JSON.parse(JSON.stringify(r.snapshot)),s=r.seq;continue}let a=r.diff;for(let d of a.nodesRemoved)delete t.nodes[d];let o=a.nodesAddedFull;if(o!=null)for(let[d,l]of Object.entries(o))t.nodes[d]=JSON.parse(JSON.stringify(l));for(let d of a.nodesChanged){let l=t.nodes[d.path];l!=null&&(l[d.field]=d.to)}s=r.seq}return t}var De={type:"system",id:""};function J(n){if(n==null)return De;let{type:e,id:t,...s}=n;return{type:e??"system",id:t??"",...s}}var D=0,U=!1,A=[],E=[],O=[],W=[];function me(){return D>0||U}function be(){return D>0}function ve(n){D>0?W.push(n):n()}function Xe(n){D+=1;let e=!1;try{n()}catch(t){throw e=!0,t}finally{if(D-=1,D===0)if(e){if(!U){let t=W.splice(0);for(let s of t)try{s()}catch{}A.length=0,E.length=0,O.length=0}}else Oe()}}function Oe(){let n=!U;n&&(U=!0);let e=[],t=0;try{for(;A.length>0||E.length>0||O.length>0||n&&W.length>0;){if(n&&W.length>0){let r=W.splice(0);for(let a of r)try{a()}catch(o){e.push(o)}continue}if(t+=1,t>1e3)throw A.length=0,E.length=0,O.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let i=(A.length>0?A:E.length>0?E:O).splice(0);for(let r of i)try{r()}catch(a){e.push(a)}}}finally{n&&(U=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function X(n,e,t){if(e.length===0)return;if(e.length===1){let l=t(e[0][0]);if(l<3||!me()){n(e);return}(l>=5?O:l===4?E:A).push(()=>n(e));return}let s=e.length,i=s,r=s,a=s,o=0;for(;o<s&&t(e[o][0])<3;)o++;for(i=o;o<s&&t(e[o][0])===3;)o++;for(r=o;o<s&&t(e[o][0])===4;)o++;a=o;let d=me();if(i>0){let l=e.slice(0,i);n(l)}if(r>i){let l=e.slice(i,r);d?A.push(()=>n(l)):n(l)}if(a>r){let l=e.slice(r,a);d?E.push(()=>n(l)):n(l)}if(s>a){let l=e.slice(a,s);d?O.push(()=>n(l)):n(l)}}function Qe(){return Math.trunc(performance.now()*1e6)}function we(){return Date.now()*1e6}var Z=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_rigorRecorder;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=t=>{let s=this._messageTypes.get(t);return s!=null?s.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}get rigorRecorder(){return this._rigorRecorder}set rigorRecorder(e){this._rigorRecorder=e}registerMessageType(e,t){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:t.tier,wireCrossing:t.wireCrossing??t.tier>=3,metaPassthrough:t.metaPassthrough??!0}),this}messageTier(e){let t=this._messageTypes.get(e);return t!=null?t.tier:1}isWireCrossing(e){let t=this._messageTypes.get(e);return t!=null?t.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let t=this._messageTypes.get(e);return t!=null?t.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}};function xe(n){n.registerMessageType(Y,{tier:0,wireCrossing:!1}),n.registerMessageType(M,{tier:1,wireCrossing:!1}),n.registerMessageType(R,{tier:1,wireCrossing:!1,metaPassthrough:!1}),n.registerMessageType(N,{tier:2,wireCrossing:!1}),n.registerMessageType(L,{tier:2,wireCrossing:!1}),n.registerMessageType(b,{tier:3,wireCrossing:!0}),n.registerMessageType(S,{tier:3,wireCrossing:!0}),n.registerMessageType(C,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(_,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(k,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var F=class extends Error{actor;action;nodeName;constructor(e,t){super(t??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}};function Te(n){return Array.isArray(n)?[...n]:[n]}function Fe(n,e){return n.has(e)||n.has("*")}function Ge(n){let e=[];return n((i,r)=>{e.push({kind:"allow",actions:new Set(Te(i)),where:r?.where??(()=>!0)})},(i,r)=>{e.push({kind:"deny",actions:new Set(Te(i)),where:r?.where??(()=>!0)})}),(i,r)=>{let a=!1,o=!1;for(let d of e)Fe(d.actions,r)&&d.where(i)&&(d.kind==="deny"?a=!0:o=!0);return a?!1:o}}function st(n){return Ge((e,t)=>{for(let s of n){let i=s.actorType==null?null:new Set(Array.isArray(s.actorType)?s.actorType:[s.actorType]),r=s.actorId==null?null:new Set(Array.isArray(s.actorId)?s.actorId:[s.actorId]),a=Object.entries(s.claims??{}),o=d=>{if(i!==null&&!i.has(String(d.type))||r!==null&&!r.has(String(d.id??"")))return!1;for(let[l,c]of a)if(d[l]!==c)return!1;return!0};s.effect==="deny"?t(s.action,{where:o}):e(s.action,{where:o})}})}var Ie=["human","llm","wallet","system"];function it(n){let e=Ie.filter(t=>n({type:t,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(t=>t==="human"||t==="llm"||t==="system")?"both":e.length===1?e[0]:e.join("+")}function ae(n){if(n===void 0)return null;if(typeof n=="number"){if(!Number.isFinite(n))throw new TypeError(`Cannot hash non-finite number: ${n}`);if(Number.isInteger(n)&&!Number.isSafeInteger(n))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${n}. Cross-language cid parity is not guaranteed for unsafe integers.`);return n}if(typeof n=="string"||typeof n=="boolean"||n===null)return n;if(Array.isArray(n))return n.map(ae);if(typeof n=="object"&&n!==null){let e={};for(let t of Object.keys(n).sort())e[t]=ae(n[t]);return e}return null}var He=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ve=new TextEncoder;function Le(n){let e=Ve.encode(n),t=e.length,s=t*8,i=t+9+63&-64,r=new Uint8Array(i);r.set(e),r[t]=128;let a=new DataView(r.buffer);a.setUint32(i-4,s>>>0,!1),a.setUint32(i-8,Math.floor(s/4294967296)>>>0,!1);let o=1779033703,d=3144134277,l=1013904242,c=2773480762,h=1359893119,p=2600822924,u=528734635,g=1541459225,T=new Uint32Array(64),m=(w,y)=>w>>>y|w<<32-y;for(let w=0;w<i;w+=64){for(let f=0;f<16;f++)T[f]=a.getUint32(w+f*4,!1);for(let f=16;f<64;f++){let H=T[f-15],V=T[f-2],K=m(H,7)^m(H,18)^H>>>3,ne=m(V,17)^m(V,19)^V>>>10;T[f]=T[f-16]+K+T[f-7]+ne>>>0}let y=o,G=d,I=l,ee=c,x=h,z=p,q=u,te=g;for(let f=0;f<64;f++){let H=m(x,6)^m(x,11)^m(x,25),V=x&z^~x&q,K=te+H+V+He[f]+T[f]>>>0,ne=m(y,2)^m(y,13)^m(y,22),Se=y&G^y&I^G&I,Re=ne+Se>>>0;te=q,q=z,z=x,x=ee+K>>>0,ee=I,I=G,G=y,y=K+Re>>>0}o=o+y>>>0,d=d+G>>>0,l=l+I>>>0,c=c+ee>>>0,h=h+x>>>0,p=p+z>>>0,u=u+q>>>0,g=g+te>>>0}let v=w=>w.toString(16).padStart(8,"0");return v(o)+v(d)+v(l)+v(c)+v(h)+v(p)+v(u)+v(g)}function de(n){let e=ae(n??null),t=JSON.stringify(e);return Le(t).slice(0,16)}function Pe(){let n=globalThis.crypto;if(n?.randomUUID)return n.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),t=e()+e()+e()+e();return`${t.slice(0,8)}-${t.slice(8,12)}-4${t.slice(13,16)}-${(parseInt(t.slice(16,17),16)&3|8).toString(16)}${t.slice(17,20)}-${t.slice(20,32)}`}function le(n,e,t){let s=t?.id??Pe();if(n===0)return{id:s,version:0};let r=(t?.hash??de)(e);return{id:s,version:0,cid:r,prev:null}}function Ne(n,e,t){n.version+=1,"cid"in n&&(n.prev=n.cid,n.cid=t(e))}function ot(n){return"cid"in n}var ke=()=>{},Ae=100;function Ee(n){return{node:n,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function ce(n){n.prevData=void 0,n.dirty=!1,n.involvedThisWave=!1,n.dataBatch.length=0,n.terminal=void 0}function Q(n){return n.length===0?n:typeof n[0]=="symbol"?[n]:n}var Ue=(n,e,t,s)=>{t.direction==="down-in"&&n._onDepMessage(t.depIndex,e)},We=(n,e,t,s)=>{let i=n;if(i._status==="completed"||i._status==="errored")return;let r=i._cached,a=r===void 0?[se]:[se,[b,r]];i._status==="dirty"&&a.push(P),X(e,a,i._config.tierOf)},B=new Z({onMessage:Ue,onSubscribe:We});xe(B);ye(B);function gt(n){if(B._isFrozen())throw new Error("configure() called after a node was created \u2014 the default GraphReFlyConfig is frozen. Call configure(...) at application startup, before any node factories run.");n(B)}var $=class n{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,t,s){this._config=s.config??B,this._config.onMessage,this._optsName=s.name,this._describeKind=s.describeKind,this._equals=s.equals??Object.is,this._resubscribable=s.resubscribable??!1,this._resetOnTeardown=s.resetOnTeardown??!1,this._autoComplete=s.completeWhenDepsComplete??!0,this._autoError=s.errorWhenDepsError??!0,this._pausable=s.pausable??!0,this._guard=s.guard,this._fn=t,this._partial=s.partial??!1,this._cached=s.initial!==void 0?s.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=s.versioningHash??this._config.defaultHashFn??de;let i=s.versioning??this._config.defaultVersioning;this._versioningLevel=i,this._versioning=i!=null?le(i,this._cached===void 0?void 0:this._cached,{id:s.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Ee);let r={};for(let[o,d]of Object.entries(s.meta??{})){let l={initial:d,name:`${s.name??"node"}:meta:${o}`,describeKind:"state",config:this._config};s.guard!=null&&(l.guard=s.guard),r[o]=new n([],void 0,l)}Object.freeze(r),this.meta=r,this._hasMeta=Object.keys(r).length>0;let a=this;this._actions={emit(o){a._emit([[b,o]])},down(o){a._emit(Q(o))},up(o){a._emitUp(Q(o))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,t){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let s=this._versioningLevel;if(s!=null&&e<=s)return;let i=t?.hash??this._hashFn;i!==this._hashFn&&(this._hashFn=i);let r=this._cached===void 0?void 0:this._cached,a=this._versioning,o=a?.id??t?.id,d=a?.version??0,l=le(e,r,{id:o,hash:i});l.version=d,this._versioning=l,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let t=J(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let s of this._extraGuards)if(!s(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,s=e?.actor!=null;if(!t&&!s)return;let i=J(e?.actor),r=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(i,r))throw new F({actor:i,action:r,nodeName:this.name});if(this._extraGuards!=null){for(let a of this._extraGuards)if(!a(i,r))throw new F({actor:i,action:r,nodeName:this.name})}this._lastMutation={actor:i,timestamp_ns:we()}}down(e,t){let s=Q(e);s.length!==0&&(this._checkGuard(t),this._emit(s))}emit(e,t){this._checkGuard(t),this._emit([[b,e]])}up(e,t){if(this._deps.length===0)return;let s=Q(e);if(s.length===0)return;this._checkGuard(t);let i=t??{internal:!0};this._validateUpTiers(s);for(let r of this._deps)r.node.up?.(s,i)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let t of this._deps)t.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let t=this._config.tierOf;for(let s of e){let i=t(s[0]);if(i===3||i===4)throw new Error(`Node "${this.name}": tier-${i} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let d=J(t);if(!this._guard(d,"observe"))throw new F({actor:d,action:"observe",nodeName:this.name})}let i=this._isTerminal&&this._resubscribable;if(i){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let d of this._deps)ce(d);if(this._partial===!1){for(let d of this._deps)if(d.prevData!==void 0||d.dataBatch.length!==0||d.terminal!==void 0||d.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let r;try{r=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:i},this._actions)}catch(d){throw this._sinkCount-=1,d}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let a=this._isTerminal;if(this._sinkCount===1&&!a)try{this._activate()}catch(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof r=="function")try{r()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let o=!1;return()=>{o||(o=!0,this._sinkCount-=1,this._removeSink(e),typeof r=="function"&&r(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[t]=this._sinks;this._sinks=t}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,t=0;try{for(let s=0;s<e;s++){let i=s,r=this._deps[s];r.unsub=ke,r.unsub=r.node.subscribe(a=>{if(r.unsub===null)return;let o=this._config.tierOf,d=!1;for(let l of a)o(l[0])>=3&&(d=!0),this._config.onMessage(this,l,{direction:"down-in",depIndex:i},this._actions);d&&this._maybeRunFnOnSettlement()}),t++}}catch(s){this._deps[t].unsub=null;for(let i=0;i<t;i++){let r=this._deps[i];if(r.unsub!=null){let a=r.unsub;r.unsub=null;try{a()}catch{}ce(r)}}throw this._dirtyDepCount=0,s}}_addDep(e){for(let i=0;i<this._deps.length;i++)if(this._deps[i].node===e)return i;let t=this._deps.length,s=Ee(e);if(this._deps.push(s),this._sinks==null)return t;s.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ie),s.unsub=ke;try{s.unsub=e.subscribe(i=>{if(s.unsub===null)return;let r=this._config.tierOf,a=!1;for(let o of i)r(o[0])>=3&&(a=!0),this._config.onMessage(this,o,{direction:"down-in",depIndex:t},this._actions);a&&this._maybeRunFnOnSettlement()})}catch(i){throw s.unsub=null,this._deps.pop(),this._dirtyDepCount--,i}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(s){this._emit([[_,this._wrapFnError("cleanup threw",s)]])}else if(t!=null&&typeof t=="object"){let s=t.deactivate;if(typeof s=="function")try{s()}catch(i){this._emit([[_,this._wrapFnError("cleanup.deactivate threw",i)]])}}for(let s of this._deps){if(s.unsub!=null){let i=s.unsub;s.unsub=null;try{i()}catch{}}ce(s)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,t){let s=this._deps[e],i=t[0];if(this._inspectorHooks!=null){let r={kind:"dep_message",depIndex:e,message:t};for(let a of this._inspectorHooks)a(r)}if(i!==Y){if(i===M){this._depDirtied(s);return}if(i===R){if(this._depInvalidated(s),this._cached===void 0)return;this._emit(pe);return}if(i===N||i===L){this._emit([t]);return}if(i===k){this._emit(re);return}if(i===b)this._depSettledAsData(s,t[1]);else if(i===S)this._depSettledAsResolved(s);else if(i===C)this._depSettledAsTerminal(s,!0);else if(i===_)this._depSettledAsTerminal(s,t[1]);else{this._emit([t]);return}if(!this._fn){(i===b||i===S)&&this._emit([t]),(i===C||i===_)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ie))}_depSettledAsData(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(t),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=t,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let t=this._deps[e];if(t.dataBatch.length===0&&t.prevData===void 0&&t.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(fe),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(t=>t.terminal!==void 0&&t.terminal!==!0);if(e!=null){this._autoError&&this._emit([[_,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(_e)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(a){this._emit([[_,this._wrapFnError("cleanup threw",a)]]);return}}else if(e!=null&&typeof e=="object"){let a=e.beforeRun;if(typeof a=="function"){e.beforeRun=void 0;try{a()}catch(o){this._emit([[_,this._wrapFnError("cleanup.beforeRun threw",o)]]);return}}}let t=this._deps.map(a=>a.involvedThisWave?a.dataBatch.length>0?[...a.dataBatch]:[]:void 0),s=this._deps.map(a=>a.prevData);for(let a=0;a<this._deps.length;a++){let o=t[a];o!=null&&o.length>0&&(this._deps[a].prevData=o[o.length-1])}let i=this._deps.map(a=>a.terminal),r={prevData:s,terminalDeps:i,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let a={kind:"run",batchData:t,prevData:s};for(let o of this._inspectorHooks)o(a)}this._isExecutingFn=!0;try{let a=this._fn(t,this._actions,r);if(typeof a=="function")this._cleanup=a;else if(a!=null&&typeof a=="object"){let o=a;(typeof o.beforeRun=="function"||typeof o.deactivate=="function"||typeof o.invalidate=="function")&&(this._cleanup=a)}}catch(a){this._emit([[_,this._wrapFnError("fn threw",a)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Ae?(this._rerunDepth=0,this._emit([[_,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Ae} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,t){let s=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${s}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[P,e[0]]:e;let s=!0,i=!1,r=!1,a=-1;for(let d of e){let l=t(d[0]);l<a&&(s=!1),l===3&&(i=!0),d[0]===M&&(r=!0),a=l}let o=e;if(!s){let d=e.map((l,c)=>({m:l,i:c,tier:t(l[0])}));d.sort((l,c)=>l.tier-c.tier||l.i-c.i),o=d.map(l=>l.m)}if(i&&!r&&this._status!=="dirty"){let d=0;for(;d<o.length&&t(o[d][0])===0;)d++;return d===0?[P,...o]:[...o.slice(0,d),P,...o.slice(d)]}return o}_emit(e){if(e.length===0)return;for(let o=0;o<e.length;o++){let d=e[o];if(d[0]===_&&d[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let t=e;if(this._isTerminal&&!this._resubscribable){let o=e.filter(d=>d[0]===k||d[0]===R);if(o.length===0)return;t=o}t=this._frameBatch(t);let i=null;for(let o=0;o<t.length;o++){let d=t[o],l=d[0];if(l!==N&&l!==L){i?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${l===N?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let h=d[1];if(l===N)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(h),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(h))c=!1;else if(this._pauseLocks.delete(h),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let p=this._pauseBuffer;this._pauseBuffer=[],this._emit(p)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?i?.push(d):i==null&&(i=t.slice(0,o))}if(i!=null){if(i.length===0)return;t=i}if(this._hasMeta&&t.some(o=>o[0]===k))for(let o of Object.keys(this.meta))try{this.meta[o]._emit(re)}catch{}let{finalMessages:r,equalsError:a}=this._updateState(t);if(r.length>0&&this._config.inspectorEnabled){let o=this._config.globalInspector;if(o!=null)try{o({kind:"emit",node:this,messages:r})}catch{}}if(r.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let o=this._config.tierOf,d=[];for(let l of r)o(l[0])===3?this._pauseBuffer.push(l):d.push(l);d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(r);a!=null&&this._emit([[_,a]])}_updateState(e){let t=this._config.tierOf,s,i,r=-1,a=0;for(let c of e)t(c[0])===3&&a++;let o=a<=1,d=-1;if(this._versioning!=null&&a>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===b){d=c;break}}for(let c=0;c<e.length;c++){let h=e[c],p=h[0];if(p===b){if(h.length>=2){let u=!1;if(o&&this._cached!==void 0)try{u=this._equals(this._cached,h[1])}catch(g){i=this._wrapFnError("equals threw",g),r=c;break}if(u){s==null&&(s=e.slice(0,c)),s.push(he),this._status="resolved";continue}this._cached=h[1],this._versioning!=null&&(d<0||c===d)&&Ne(this._versioning,h[1],this._hashFn)}this._status="settled",s?.push(h)}else if(s?.push(h),p===M)this._status="dirty";else if(p===S)this._status="resolved";else if(p===C){this._status="completed";{let u=this._config.rigorRecorder;if(u!=null)try{u.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===_){this._status="errored";{let u=this._config.rigorRecorder;if(u!=null)try{u.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===R){if(this._cached!==void 0){let g=this._config.rigorRecorder;if(g!=null)try{g.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let u=this._cleanup;if(typeof u=="function"){this._cleanup=void 0;try{u()}catch{}}else if(u!=null&&typeof u=="object"){let g=u.invalidate;if(typeof g=="function")try{g()}catch{}}}else p===k&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let l=r>=0?s??e.slice(0,r):s??e;return i!=null?{finalMessages:l,equalsError:i}:{finalMessages:l}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let s of t)s(e)};_dispatchOrAccumulate(e){if(be()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],ve(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}X(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let t=this._frameBatch(e);X(this._deliverToSinks,t,this._config.tierOf)}},Me=n=>Array.isArray(n),ue=n=>typeof n=="object"&&n!=null&&!Array.isArray(n);function j(n,e,t){let s=Me(n)?n:[],i=typeof n=="function"?n:typeof e=="function"?e:void 0,r={};return Me(n)?r=(ue(e)?e:t)??{}:ue(n)?r=n:r=(ue(e)?e:t)??{},new $(s,i,r)}function bt(n,e){return j([],{...e,initial:n})}function vt(n,e){return j((s,i,r)=>n(i,r)??void 0,{describeKind:"producer",...e})}function Be(n,e,t){return j(n,(i,r,a)=>{let o=i.map((d,l)=>d!=null&&d.length>0?d.at(-1):a.prevData[l]);r.emit(e(o,a))},{describeKind:"derived",...t})}function wt(n,e,t){return j(n,(i,r,a)=>{let o=i.map((d,l)=>d!=null&&d.length>0?d.at(-1):a.prevData[l]);return e(o,r,a)??void 0},{describeKind:"effect",...t})}function xt(n,e,t){let s=new Map;return n.forEach((i,r)=>{s.set(i,r)}),Be(n,(i,r)=>e(o=>{let d=s.get(o);if(d==null)throw new Error(`dynamicNode: untracked dep "${o.name??"<unnamed>"}"`);return i[d]},r),t)}function Tt(n,e){let t,s=new Map,i=(r,a,o)=>{let d=!1,l=c=>{let h=s.get(c);if(h!==void 0){if(h<r.length){let u=r[h];return u!=null&&u.length>0?u.at(-1):o.prevData[h]}return c.cache}d=!0;let p=t._addDep(c);return s.set(c,p),c.cache};try{let c=n(l,o);d||(a.emit(c),o.store.__autoTrackLastDiscoveryError!=null&&delete o.store.__autoTrackLastDiscoveryError)}catch(c){if(!d)throw c;o.store.__autoTrackLastDiscoveryError=c}};return t=new $([],i,{describeKind:"derived",...e}),t}function Nt(n,...e){let t=n;for(let s of e)t=s(t);return t}export{Ce as a,$e as b,je as c,oe as d,ze as e,qe as f,ye as g,Ke as h,De as i,J as j,me as k,ve as l,Xe as m,X as n,Qe as o,we as p,Z as q,xe as r,F as s,Ge as t,st as u,it as v,de as w,le as x,Ne as y,ot as z,B as A,gt as B,$ as C,j as D,bt as E,vt as F,Be as G,wt as H,xt as I,Tt as J,Nt as K};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as w}from"./chunk-
|
|
1
|
+
import{a as w}from"./chunk-533RQFF6.js";import{A as b,B as F,C as H,D as G,E as k,F as B,G as Y,H as h,I as v,J as P,K as W,i as K,j,k as g,m as S,n as C,o as I,p as M,q as _,r as u,s as q,t as z,u as J,v as Q,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 D,r as A,s as R,t as f,u as l}from"./chunk-CK2E7BTU.js";import{b as U}from"./chunk-QYADASLV.js";var X={};U(X,{COMPLETE:()=>y,COMPLETE_MSG:()=>E,COMPLETE_ONLY_BATCH:()=>f,DATA:()=>t,DEFAULT_ACTOR:()=>K,DIRTY:()=>o,DIRTY_MSG:()=>d,DIRTY_ONLY_BATCH:()=>D,ERROR:()=>a,GraphReFlyConfig:()=>_,GuardDenied:()=>q,INVALIDATE:()=>r,INVALIDATE_MSG:()=>N,INVALIDATE_ONLY_BATCH:()=>R,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:()=>l,accessHintForGuard:()=>Q,advanceVersion:()=>x,autoTrackNode:()=>P,batch:()=>S,configure:()=>F,createVersioning:()=>m,defaultConfig:()=>b,defaultHash:()=>L,derived:()=>Y,downWithBatch:()=>C,dynamicNode:()=>v,effect:()=>h,isBatching:()=>g,isV1:()=>V,monotonicNs:()=>I,node:()=>G,normalizeActor:()=>j,pipe:()=>W,policy:()=>z,policyFromRules:()=>J,producer:()=>B,registerBuiltins:()=>u,resolveDescribeFields:()=>w,state:()=>k,wallClockNs:()=>M});export{X as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{E as v,G as w,m as h}from"./chunk-
|
|
1
|
+
import{E as v,G as w,m as h}from"./chunk-LYCLF26R.js";import{b as m,c as V}from"./chunk-CK2E7BTU.js";function x(s,e){if(s===e)return 0;let r=typeof s;if(r===typeof e&&(r==="number"||r==="string"||r==="boolean"||r==="bigint")){let i=s,n=e;return i<n?-1:i>n?1:0}return String(s).localeCompare(String(e))}function k(s,e){let r=x(s[0],e[0]);return r!==0?r:x(s[1],e[1])}function g(s){return[s.secondary,s.primary]}function y(s,e){let r=g(e),o=0,i=s.length;for(;o<i;){let n=o+i>>1;k(r,g(s[n]))>0?o=n+1:i=n}return o}var b=class{_version=0;_buf=[];_byPrimary=new Map;get version(){return this._version}get size(){return this._buf.length}has(e){return this._byPrimary.has(e)}get(e){return this._byPrimary.get(e)?.value}upsert(e,r,o,i){let n=this._byPrimary.get(e),a={primary:e,secondary:r,value:o};if(n!==void 0&&i?.equals?.(n,a))return!1;if(n!==void 0){let p=y(this._buf,n);this._buf.splice(p,1)}let d=y(this._buf,a);return this._buf.splice(d,0,a),this._byPrimary.set(e,a),this._version+=1,n===void 0}upsertMany(e,r){let o=0;try{for(let i of e){let n=this._byPrimary.get(i.primary),a={primary:i.primary,secondary:i.secondary,value:i.value};if(n!==void 0&&r?.equals?.(n,a))continue;if(n!==void 0){let p=y(this._buf,n);this._buf.splice(p,1)}let d=y(this._buf,a);this._buf.splice(d,0,a),this._byPrimary.set(i.primary,a),o+=1}}finally{o>0&&(this._version+=1)}return o}delete(e){let r=this._byPrimary.get(e);if(r===void 0)return!1;let o=y(this._buf,r);return this._buf.splice(o,1),this._byPrimary.delete(e),this._version+=1,!0}deleteMany(e){let r=0;try{for(let o of e){let i=this._byPrimary.get(o);if(i===void 0)continue;let n=y(this._buf,i);this._buf.splice(n,1),this._byPrimary.delete(o),r+=1}}finally{r>0&&(this._version+=1)}return r}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._byPrimary.clear(),this._version+=1,e)}toArray(){return[...this._buf]}toPrimaryMap(){let e=new Map;for(let r of this._buf)e.set(r.primary,r.value);return e}};function R(s){return s.subscribe(()=>{})}function U(s={}){let{name:e,versioning:r,equals:o,backend:i}=s,n=i??new b;function a(t){return t?.equals!==void 0||o===void 0?t:{...t,equals:o}}let d=v([],{name:e,describeKind:"state",equals:(t,u)=>t===u,...r!=null?{versioning:r}:{}}),p=w([d],([t])=>{let u=t,l=new Map;for(let f of u)l.set(f.primary,f.value);return l},{initial:n.toPrimaryMap(),describeKind:"derived"}),_=R(p),K=!1;function I(){let t=n.toArray();h(()=>{d.down([[V]]),d.down([[m,t]])})}function c(t){let u=n.version;try{return t()}finally{n.version!==u&&I()}}return{ordered:d,byPrimary:p,has(t){return n.has(t)},get(t){return n.get(t)},get size(){return n.size},upsert(t,u,l,f){return c(()=>n.upsert(t,u,l,a(f)))},upsertMany(t,u){let l=[...t];l.length!==0&&c(()=>n.upsertMany(l,a(u)))},delete(t){c(()=>n.delete(t))},deleteMany(t){let u=[...t];u.length!==0&&c(()=>n.deleteMany(u))},clear(){c(()=>n.clear())},dispose(){K||(K=!0,_())}}}export{b as a,U as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as F,c as G}from"./chunk-
|
|
1
|
+
import{b as F,c as G}from"./chunk-L3KUKDZC.js";import{b as $}from"./chunk-TZQPPQEQ.js";import{j as _}from"./chunk-2JO6LXFT.js";import{t as B}from"./chunk-4F564IPP.js";import{B as N}from"./chunk-T7EQPKOP.js";import{D as x,E as I,G as S,H as M,m as A}from"./chunk-LYCLF26R.js";import{b as k,c as v,d as y,f as T,g as O,i as E,j as w}from"./chunk-CK2E7BTU.js";import{b as K}from"./chunk-QYADASLV.js";var U={};K(U,{budgetGate:()=>C,effectivenessTracker:()=>L,feedback:()=>V,funnel:()=>P,scorer:()=>z});function R(u,t){return G("reduction",u,t)}function P(u,t,i,b){if(t.length===0)throw new RangeError("funnel requires at least one source");if(i.length===0)throw new RangeError("funnel requires at least one stage");let d=new _(u,b),s=t.length===1?t[0]:B(...t);d.add(s,{name:"merged"});let e="merged";for(let f=0;f<i.length;f++){let o=i[f],c=new _(o.name);o.build(c);try{c.resolve("input")}catch{throw new Error(`funnel stage "${o.name}" must define an "input" node`)}try{c.resolve("output")}catch{throw new Error(`funnel stage "${o.name}" must define an "output" node`)}d.mount(o.name,c);let l=d.resolve(e),m=`${o.name}::input`,g=d.resolve(m),a=`__bridge_${e}\u2192${o.name}_input`,p=M([l],([r])=>{g.emit(r)},{name:a});d.add(p,{name:a}),d.addDisposer(N(p)),e=`${o.name}::output`}return d}function V(u,t,i,b){let d=b?.maxIterations??10,s=`__feedback_${t}`,e=I(0,{meta:R("feedback_counter",{maxIterations:d,feedbackFrom:t,feedbackTo:i})});u.add(e,{name:s});let f=u.resolve(t),o=u.resolve(i),c=`__feedback_effect_${t}`,l=x([],(m,g)=>{let a=f.subscribe(p=>{for(let r of p){let n=r[0];if(n===k){let h=r[1];if(h==null)return;A(()=>{F(e,d)&&o.emit(h)})}else if(n===E||n===w){let h=n===w&&r.length>1?[w,r[1]]:[n];e.down([h])}}});return()=>a()},{name:c,describeKind:"effect",meta:{...R("feedback_effect",{feedbackFrom:t,feedbackTo:i}),_internal:!0}});return u.add(l,{name:c}),u.addDisposer(N(l)),u}function C(u,t,i){if(t.length===0)throw new RangeError("budgetGate requires at least one constraint");let b=t.map(a=>a.node),d=[u,...b],s=[],e=!1,f=!1,o=Symbol("budget-gate"),c=new Array(t.length);function l(){return t.every((a,p)=>a.check(c[p]))}function m(a){for(;s.length>0&&l();){let p=s[0];s=s.slice(1),a.emit(p)}s.length===0&&f&&(f=!1,a.down([[y]]))}return x([],(a,p)=>{for(let n=0;n<t.length;n++)c[n]=t[n].node.cache;let r=[];for(let n=0;n<d.length;n++){let h=d[n];r.push(h.subscribe(q=>{for(let D of q)g(D,n,p)}))}return()=>{for(let n of r)n()}},{...i,describeKind:"derived",meta:R("budget_gate",i?.meta)});function g(a,p,r){let n=a[0];if(p===0){if(n===k)return l()&&s.length===0?r.emit(a[1]):(s.push(a[1]),e||(e=!0,r.up([[T,o]]))),!0;if(n===v)return r.down([[v]]),!0;if(n===y)return s.length===0?r.down([[y]]):f=!0,!0;if(n===E||n===w){for(let h of s)r.emit(h);return s=[],f=!1,e&&(e=!1,r.up([[O,o]])),r.down([a]),!0}return!1}return n===k&&(c[p-1]=a[1]),n===k||n===y?(l()&&s.length>0?(m(r),s.length===0&&e&&(e=!1,r.up([[O,o]]))):!l()&&!e&&s.length>0&&(e=!0,r.up([[T,o]])),!0):n===v?!0:n===w?(r.down([a]),!0):n===E}}function z(u,t,i){if(u.length===0)throw new RangeError("scorer requires at least one source");if(u.length!==t.length)throw new RangeError("scorer requires the same number of sources and weights");let b=[...u,...t],d=u.length,s=i?.scoreFns;return S(b,e=>{let f=e.slice(0,d),o=e.slice(d),c=[],l=0;for(let m=0;m<d;m++){let g=f[m]??0,a=o[m]??0,r=(s?.[m]?s[m](g):g)*a;c.push(r),l+=r}return{value:f,score:l,breakdown:c}},{...i?{equals:i.equals,resubscribable:i.resubscribable,resetOnTeardown:i.resetOnTeardown}:{},describeKind:"derived",meta:R("scorer",i?.meta)})}function L(u){let t=$({name:u?.name??"effectiveness-entries"}),i=S([t.entries],([e])=>new Map(e),{name:`${u?.name??"effectiveness"}-snapshot`,equals:(e,f)=>{let o=e,c=f;if(o.size!==c.size)return!1;for(let[l,m]of o){let g=c.get(l);if(!g||m.attempts!==g.attempts||m.successes!==g.successes)return!1}return!0}});function b(e,f){let o=t.get(e),c=(o?.attempts??0)+1,l=(o?.successes??0)+(f?1:0);t.set(e,{key:e,attempts:c,successes:l,successRate:l/c})}function d(e){return t.get(e)}let s=N(i);return{node:i,record:b,lookup:d,dispose:()=>s()}}export{P as a,V as b,C as c,z as d,L as e,U as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as x,c as D,d as $,e as S,f as A,g as R,h as T,i as F,j as y,k as P,l as V}from"./chunk-
|
|
1
|
+
import{b as x,c as D,d as $,e as S,f as A,g as R,h as T,i as F,j as y,k as P,l as V}from"./chunk-2JO6LXFT.js";import{a as m,b as g,c as k,d as v,e as O,f as G,g as E,h as C}from"./chunk-LYCLF26R.js";import{b as u}from"./chunk-CK2E7BTU.js";import{b as _}from"./chunk-QYADASLV.js";var j={};_(j,{ENVELOPE_VERSION:()=>v,GRAPH_META_SEGMENT:()=>R,Graph:()=>y,JsonCodec:()=>m,SIZEOF_OVERHEAD:()=>D,SIZEOF_SYMBOL:()=>$,SNAPSHOT_VERSION:()=>T,createDagCborCodec:()=>g,createDagCborZstdCodec:()=>k,decodeEnvelope:()=>G,diffForWAL:()=>P,encodeEnvelope:()=>O,explainPath:()=>x,graphProfile:()=>A,mermaidLiveUrl:()=>F,reachable:()=>V,registerBuiltinCodecs:()=>E,replayWAL:()=>C,sizeof:()=>S,validateGraphObservability:()=>L,watchTopologyTree:()=>N});function N(p,n){let o=new Map,d=(s,a)=>{if(o.has(s))return;let c={off:()=>{},prefix:a};o.set(s,c);let f=s.topology.subscribe(l=>{for(let r of l){if(r[0]!==u)continue;let e=r[1];if(n(e,s,a),e.kind==="added"&&e.nodeKind==="mount"){let t=s._mounts.get(e.name);if(t instanceof y){let i=`${a}${e.name}::`;d(t,i)}}else if(e.kind==="removed"&&e.nodeKind==="mount"){let t=`${a}${e.name}::`;for(let[i,h]of Array.from(o.entries()))i!==p&&h.prefix.startsWith(t)&&(h.off(),o.delete(i))}}});c.off=f;for(let[l,r]of s._mounts)if(r instanceof y){let e=`${a}${l}::`;d(r,e)}};return d(p,""),()=>{for(let s of o.values())s.off();o.clear()}}function L(p,n={}){let o=[],d=n.requireFound??!0;if(n.skipDescribe!==!0)try{let r=p.describe(),e=new Set(Object.keys(r.nodes)),t=[];for(let[i,h]of Object.entries(r.nodes))for(let b of h.deps)b!==""&&!e.has(b)&&t.push(`${i} \u2192 ${b}`);for(let i of r.edges)e.has(i.from)||t.push(`edge.from: ${i.from}`),e.has(i.to)||t.push(`edge.to: ${i.to}`);t.length>0?o.push({kind:"describe",ok:!1,reason:`describe() has ${t.length} dangling pointer(s); nodes \u2289 deps`,danglingDeps:t}):o.push({kind:"describe",ok:!0,nodeCount:e.size,edgeCount:r.edges.length})}catch(r){o.push({kind:"describe",ok:!1,reason:`describe() threw: ${r instanceof Error?r.message:String(r)}`})}for(let r of n.formats??[])try{let e=p.describe({format:r});typeof e!="string"||e.length===0?o.push({kind:"describe-format",ok:!1,format:r,reason:`describe({ format: "${r}" }) returned empty or non-string output`}):o.push({kind:"describe-format",ok:!0,format:r,length:e.length})}catch(e){o.push({kind:"describe-format",ok:!1,format:r,reason:e instanceof Error?e.message:String(e)})}for(let r of n.paths??[])try{p.resolve(r),o.push({kind:"observe",ok:!0,path:r})}catch(e){o.push({kind:"observe",ok:!1,path:r,reason:e instanceof Error?e.message:String(e)})}for(let[r,e]of n.pairs??[])try{let t=p.explain(r,e);d&&t.found===!1?o.push({kind:"explain",ok:!1,from:r,to:e,reason:`explain(${r} \u2192 ${e}) found no path${t.reason?`: ${t.reason}`:""}`}):o.push({kind:"explain",ok:!0,from:r,to:e,found:t.found,steps:t.steps.length})}catch(t){o.push({kind:"explain",ok:!1,from:r,to:e,reason:t instanceof Error?t.message:String(t)})}let s=o.filter(r=>!r.ok),a=s.length===0,c=n.paths?.length??0,f=n.pairs?.length??0,l=n.formats?.length??0;return{ok:a,checks:o,failures:s,summary(){let r=[n.skipDescribe===!0?null:"describe",l>0?`${l} format${l===1?"":"s"}`:null,c>0?`${c} observe path${c===1?"":"s"}`:null,f>0?`${f} explain pair${f===1?"":"s"}`:null].filter(t=>t!=null),e=r.length>0?r.join(", "):"describe-only";return a?`validateGraphObservability: OK (${e})`:`validateGraphObservability: ${s.length} failure(s) across ${e}`}}}export{N as a,L as b,j as c};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{f as he}from"./chunk-
|
|
1
|
+
import{f as he}from"./chunk-T2TB37TW.js";import{j as fe}from"./chunk-2JO6LXFT.js";import{x as ye}from"./chunk-4F564IPP.js";import{D as be,E as T,G as v,H as q,m as ee,o as z}from"./chunk-LYCLF26R.js";import{b as P,j as Z}from"./chunk-CK2E7BTU.js";import{b as Ne}from"./chunk-QYADASLV.js";var we={};Ne(we,{blindVariation:()=>De,errorCritique:()=>Re,refineLoop:()=>Se});function Ie(n){if(typeof n!="object"||n===null)return!1;let l=n;return typeof l.subscribe=="function"&&typeof l.down=="function"&&typeof l.emit=="function"}function pe(n,l){if(n.length===0)return{best:null,bestScore:Number.NEGATIVE_INFINITY};if(n.length===1){let e=ne(l);return{best:n[0],bestScore:e}}if(l.some(e=>typeof e.candidateIndex=="number")){let e=new Array(n.length);for(let i=0;i<n.length;i++)e[i]={sum:0,count:0};for(let i of l){let d=i.candidateIndex;typeof d=="number"&&d>=0&&d<n.length&&(e[d].sum+=i.score,e[d].count+=1)}let s=n[0],o=e[0].count>0?e[0].sum/e[0].count:Number.NEGATIVE_INFINITY;for(let i=1;i<n.length;i++){let d=e[i].count>0?e[i].sum/e[i].count:Number.NEGATIVE_INFINITY;d>o&&(o=d,s=n[i])}return{best:s,bestScore:o}}let t=n[0],m=l[0]?.score??Number.NEGATIVE_INFINITY;for(let e=1;e<n.length;e++){let s=l[e]?.score??Number.NEGATIVE_INFINITY;s>m&&(m=s,t=n[e])}return{best:t,bestScore:m}}function ne(n){if(n.length===0)return Number.NEGATIVE_INFINITY;let l=0;for(let x of n)l+=x.score;return l/n.length}function Se(n,l,x,t){let m=t.name??"refine-loop",e=new fe(m,t.graph),s=Ie(t.dataset)?t.dataset:T(t.dataset,{name:"dataset"});e.add(s,{name:"dataset"});let o=T(0,{name:"iteration"});e.add(o,{name:"iteration"});let i=T(x,{name:"strategy",equals:()=>!1});e.add(i,{name:"strategy"});let d=T(null,{name:"lastFeedback"});e.add(d,{name:"lastFeedback"});let k=T([],{name:"prevCandidates"});e.add(k,{name:"prevCandidates"});let y=T(!1,{name:"paused"});e.add(y,{name:"paused"});let b=T("running",{name:"status"});e.add(b,{name:"status"});let E=T([],{name:"history",equals:()=>!1});e.add(E,{name:"history"});let h=T(null,{name:"best"});e.add(h,{name:"best"});let N=T(Number.NEGATIVE_INFINITY,{name:"score"});e.add(N,{name:"score"});let C=T(0,{name:"budget-used"});e.add(C,{name:"budget-used"});let R=he("stages");e.mount("stages",R);let A=R.topic("generate"),p=R.topic("evaluate"),G=R.topic("analyze"),te=R.topic("decide"),$=x,B=null,re=[];e.addDisposer(i.subscribe(r=>{for(let a of r)a[0]===P&&($=a[1])})),e.addDisposer(d.subscribe(r=>{for(let a of r)a[0]===P&&(B=a[1])})),e.addDisposer(k.subscribe(r=>{for(let a of r)a[0]===P&&(re=a[1])}));let I=ye(o,r=>{let a=$,c=r===0||B==null;return be([],(u,f)=>{let S=!1;try{let D=c?a.seed(n):a.generate(B,re);if(D instanceof Promise)return D.then(_=>{S||f.emit(_)},_=>{S||f.down([[Z,_]])}),()=>{S=!0};f.emit(D)}catch(D){S=!0,f.down([[Z,D]])}},{describeKind:"producer"})},{name:"candidates"});e.add(I,{name:"candidates"});let ae=q([I],(r,a,c)=>{let u=c.terminalDeps[0];u!==void 0&&u!==!0&&b.emit("errored")},{name:"error-watcher",errorWhenDepsError:!1});e.add(ae,{name:"error-watcher"}),e.addDisposer(ae.subscribe(()=>{}));let Y=v([I,o],([r,a])=>({iteration:a,candidates:r,timestamp_ns:z()}),{name:"generate-event"});e.add(Y,{name:"generate-event"}),e.addDisposer(Y.subscribe(()=>{}));let oe=q([Y],([r])=>{A.publish(r)},{name:"generate-publish"});e.add(oe,{name:"generate-publish"}),e.addDisposer(oe.subscribe(()=>{}));let ie=q([I],([r])=>{k.emit(r)},{name:"generate-mirror"});e.add(ie,{name:"generate-mirror"}),e.addDisposer(ie.subscribe(()=>{}));let V=l(I,s);e.add(V,{name:"scores"});let j=v([V,I,o],([r,a,c])=>({iteration:c,candidates:a,scores:r,timestamp_ns:z()}),{name:"evaluate-event"});e.add(j,{name:"evaluate-event"}),e.addDisposer(j.subscribe(()=>{}));let se=q([j],([r])=>{p.publish(r)},{name:"evaluate-publish"});e.add(se,{name:"evaluate-publish"}),e.addDisposer(se.subscribe(()=>{}));let L=v([V,I],([r,a])=>$.analyze(r,a),{name:"feedback"});e.add(L,{name:"feedback"});let M=v([L,I,o],([r,a,c])=>({iteration:c,candidates:a,feedback:r,timestamp_ns:z()}),{name:"analyze-event"});e.add(M,{name:"analyze-event"}),e.addDisposer(M.subscribe(()=>{}));let de=q([M],([r])=>{G.publish(r)},{name:"analyze-publish"});e.add(de,{name:"analyze-publish"}),e.addDisposer(de.subscribe(()=>{}));let H=v([E],([r])=>{let a=r;if(t.patience==null||a.length<=t.patience)return!1;let c=a.slice(-(t.patience+1)),u=c[0].bestScore;return c.slice(1).every(f=>f.bestScore<=u)},{name:"patience-check"});e.add(H,{name:"patience-check"});let W=v([N],([r])=>t.minScore!=null&&r>=t.minScore,{name:"min-score-check"});e.add(W,{name:"min-score-check"});let K=v([E],([r])=>{let a=r;if(t.minDelta==null||a.length<2)return!1;let c=a[a.length-2].bestScore,u=a[a.length-1].bestScore;return Math.abs(u-c)<t.minDelta},{name:"min-delta-check"});e.add(K,{name:"min-delta-check"});let U=v([C],([r])=>t.maxEvaluations!=null&&r>=t.maxEvaluations,{name:"max-evaluations-check"});e.add(U,{name:"max-evaluations-check"});let J=v([o],([r])=>t.maxIterations!=null&&r>=t.maxIterations,{name:"max-iterations-check"});e.add(J,{name:"max-iterations-check"});let le=v([C],([r])=>t.budget!=null&&r>=t.budget,{name:"budget-exhausted-check"});e.add(le,{name:"budget-exhausted-check"}),e.addDisposer(H.subscribe(()=>{})),e.addDisposer(W.subscribe(()=>{})),e.addDisposer(K.subscribe(()=>{})),e.addDisposer(U.subscribe(()=>{})),e.addDisposer(J.subscribe(()=>{})),e.addDisposer(le.subscribe(()=>{}));let ce=v([H,W,K,U,J],([r,a,c,u,f])=>r?{converged:!0,reason:"patience"}:a?{converged:!0,reason:"min-score"}:c?{converged:!0,reason:"min-delta"}:u?{converged:!0,reason:"max-evaluations"}:f?{converged:!0,reason:"max-iterations"}:{converged:!1},{name:"converged"});e.add(ce,{name:"converged"}),e.addDisposer(ce.subscribe(()=>{}));let ue=-1,me=q([L,V,I],([r,a,c])=>{let u=o.cache,f=r,S=c,D=a;if(u<=ue)return;ue=u;let{best:_,bestScore:ge}=pe(S,D),Te=E.cache,ve={n:u,candidates:S,scores:D,feedback:f,best:_,bestScore:ge,timestamp_ns:z()},F=[...Te,ve],Q=C.cache+S.length,g="continue",w,Ee=t.budget!=null&&Q>=t.budget,ke=y.cache;if(Ee)g="budget",w="budget";else if(t.minScore!=null&&f.score>=t.minScore)g="converged",w="min-score";else if(t.maxIterations!=null&&u>=t.maxIterations)g="converged",w="max-iterations";else if(t.maxEvaluations!=null&&Q>=t.maxEvaluations)g="converged",w="max-evaluations";else if(t.minDelta!=null&&F.length>=2){let O=F[F.length-2].bestScore,X=F[F.length-1].bestScore;Math.abs(X-O)<t.minDelta&&(g="converged",w="min-delta")}else if(t.patience!=null&&F.length>t.patience){let O=F.slice(-(t.patience+1)),X=O[0].bestScore;O.slice(1).every(xe=>xe.bestScore<=X)&&(g="converged",w="patience")}g==="continue"&&ke&&(g="paused"),ee(()=>{h.emit(_),N.emit(f.score),E.emit(F),C.emit(Q),d.emit(f),te.publish({iteration:u,decision:g,reason:w,timestamp_ns:z()}),g==="continue"?o.emit(u+1):b.emit(g==="converged"?"converged":g==="budget"?"budget":"paused")})},{name:"decide-bridge"});return e.add(me,{name:"decide-bridge"}),e.addDisposer(me.subscribe(()=>{})),Object.assign(e,{best:h,score:N,status:b,history:E,strategy:i,iteration:o,generate:A,evaluate:p,analyze:G,decide:te,setStrategy(r){i.emit(r)},pause(){y.emit(!0)},resume(){b.cache==="paused"&&ee(()=>{y.emit(!1),b.emit("running"),o.emit(o.cache+1)})}})}function De(n){let l=n.width??4;return{name:n.name??"blindVariation",seed(t){return[t]},analyze(t,m){let e=ne(t),s=null;for(let o of t)(!s||o.score<s.score)&&(s=o);return{summary:`blindVariation iteration: mean=${e.toFixed(3)}, n=${t.length}`,score:e,weakTasks:s?[s.taskId]:[]}},async generate(t,m){if(m.length===0)throw new Error("blindVariation.generate: empty candidate batch \u2014 cannot derive prior for teacher");let e=m[m.length-1],s=0,i={prior:e,reportCost:d=>{s+=d}};try{if(n.parallel!==!1)return await Promise.all(Array.from({length:l},()=>n.teacher(i)));let d=[];for(let k=0;k<l;k++)d.push(await n.teacher(i));return d}finally{if(n.tokens!=null&&s>0){let d=n.tokens.cache??0;n.tokens.emit(d+s)}}}}}function Fe(n){return typeof n=="object"&&n!==null&&n.kind==="errorCritique"}function Ce(n,l){return n.length===0?`No task scored below the batch mean (${l.score.toFixed(3)}). Reinforce the current direction.`:`Failures below threshold:
|
|
2
2
|
${n.map(t=>{let m=t.error!=null?` | error: ${t.error}`:"";return`- ${t.taskId} (score=${t.score.toFixed(3)})${m}`}).join(`
|
|
3
3
|
`)}`}function Re(n){let l=n.width??4,x=n.name??"errorCritique",t=n.maxFailureSamples??5,m=n.formatCritique??Ce;return{name:x,seed(e){return[e]},analyze(e,s){let o=ne(e),i=typeof n.failureThreshold=="function"?n.failureThreshold(e):n.failureThreshold,d=i===void 0&&!Number.isFinite(o),k=i??o,y=d?[...e].sort((p,G)=>p.score-G.score):e.filter(p=>p.score<k).slice().sort((p,G)=>p.score-G.score),b=y.slice(0,t),{best:E,bestScore:h}=pe(s,e),N={summary:"",score:o,weakTasks:b.map(p=>p.taskId)},C=m(b,N),R={kind:"errorCritique",best:E,failures:b,critiqueText:C},A=y.length>b.length?` (top ${b.length} retained)`:"";return{summary:`errorCritique iteration: mean=${o.toFixed(3)}, failures=${y.length}${A}/${e.length}, bestScore=${h.toFixed(3)}`,critique:R,weakTasks:b.map(p=>p.taskId),score:o}},async generate(e,s){if(s.length===0)throw new Error("errorCritique.generate: empty candidate batch \u2014 cannot derive prior for teacher");let o=Fe(e.critique)?e.critique:void 0,i=o!==void 0?o.best:s[s.length-1],d=o?.critiqueText??e.summary,k=o?.failures??[],y=0,E={prior:i,critique:d,failures:k,reportCost:h=>{y+=h}};try{if(n.parallel!==!1)return await Promise.all(Array.from({length:l},()=>n.teacher(E)));let h=[];for(let N=0;N<l;N++)h.push(await n.teacher(E));return h}finally{if(n.tokens!=null&&y>0){let h=n.tokens.cache??0;n.tokens.emit(h+y)}}}}}export{Se as a,De as b,Re as c,we as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as k}from"./chunk-
|
|
1
|
+
import{c as k}from"./chunk-L3KUKDZC.js";import{b as I}from"./chunk-HTBOCKVD.js";import{j as h}from"./chunk-2JO6LXFT.js";import{B as p}from"./chunk-T7EQPKOP.js";import{D as w,E as f,G as d,m as x}from"./chunk-LYCLF26R.js";import{i as y}from"./chunk-CK2E7BTU.js";import{b as M}from"./chunk-QYADASLV.js";var C={};M(C,{MessagingHubGraph:()=>v,SubscriptionGraph:()=>T,TopicBridgeGraph:()=>g,TopicGraph:()=>l,messagingHub:()=>L,subscription:()=>G,topic:()=>P,topicBridge:()=>S});var N=2147483647;function m(n,t){if(!Number.isFinite(n)||!Number.isInteger(n)||n<0)throw new Error(`${t} must be a non-negative integer`);return n}function o(n,t){return k("messaging",n,t)}var l=class extends h{_log;events;latest;hasLatest;constructor(t,e={}){super(t,e.graph),this._log=I([],{name:"events",maxSize:e.retainedLimit}),this.events=this._log.entries,this.add(this.events,{name:"events"}),this.latest=d([this.events],([i])=>{let s=i;return s.length===0?null:s[s.length-1]},{name:"latest",describeKind:"derived",meta:o("topic_latest")}),this.add(this.latest,{name:"latest"}),this.addDisposer(p(this.latest)),this.hasLatest=d([this.events],([i])=>i.length>0,{name:"hasLatest",describeKind:"derived",meta:o("topic_has_latest")}),this.add(this.hasLatest,{name:"hasLatest"}),this.addDisposer(p(this.hasLatest)),this.addDisposer(()=>{this.events.down([[y]])}),this.addDisposer(()=>this._log.disposeAllViews())}publish(t){this._log.append(t)}retained(){return this.events.cache}},T=class extends h{source;cursor;available;topic;constructor(t,e,i={}){super(t,i.graph);let s=m(i.cursor??0,"subscription cursor");this.topic=e;let r=e.events;this.source=d([r],([u])=>u,{name:"source",describeKind:"derived",meta:o("subscription_source"),initial:r.cache}),this.add(this.source,{name:"source"}),this.cursor=f(s,{name:"cursor",describeKind:"state",meta:o("subscription_cursor")}),this.add(this.cursor,{name:"cursor"}),this.available=d([this.source,this.cursor],([u,b])=>{let a=u,c=Math.max(0,Math.trunc(b??0));return a.slice(c)},{name:"available",describeKind:"derived",meta:o("subscription_available"),initial:[]}),this.add(this.available,{name:"available"}),this.addDisposer(p(this.source)),this.addDisposer(p(this.available))}ack(t){let e=this.available.cache,i=t===void 0?e.length:m(t,"subscription ack count"),s=Math.min(i,e.length);if(s<=0)return this.cursor.cache;let r=this.cursor.cache+s;return this.cursor.emit(r),r}pull(t,e={}){let i=this.available.cache,s=t===void 0?i.length:m(t,"subscription pull limit"),r=i.slice(0,s);return e.ack&&r.length>0&&this.ack(r.length),r}},g=class extends h{_sourceSub;_target;bridgedCount;constructor(t,e,i,s={}){super(t,s.graph),this._sourceSub=G(`${t}-subscription`,e,{cursor:s.cursor}),this._target=i,this.mount("subscription",this._sourceSub),this.bridgedCount=f(0,{name:"bridgedCount",describeKind:"state",meta:o("topic_bridge_count")}),this.add(this.bridgedCount,{name:"bridgedCount"});let r=Math.max(1,m(s.maxPerPump??N,"topic bridge maxPerPump")),u=s.map??(a=>a),b=w([this._sourceSub.available],()=>{let a=this._sourceSub.pull(r,{ack:!0});if(a.length===0)return;let c=0;for(let _ of a){let O=u(_);O!==void 0&&(this._target.publish(O),c+=1)}if(c>0){let _=this.bridgedCount.cache;this.bridgedCount.emit(_+c)}},{name:"pump",describeKind:"effect",meta:o("topic_bridge_pump")});this.add(b,{name:"pump"}),this.addDisposer(p(b))}},v=class extends h{_topics=new Map;_version=0;_defaultTopicOptions;constructor(t,e={}){super(t,e.graph),this._defaultTopicOptions={...e.defaultTopicOptions??{}}}get version(){return this._version}get size(){return this._topics.size}has(t){return this._topics.has(t)}topicNames(){return this._topics.keys()}topic(t,e){let i=this._topics.get(t);if(i===void 0){let s={...this._defaultTopicOptions,...e??{}};i=new l(t,s),this._topics.set(t,i),this.mount(t,i),this._version+=1}return i}publish(t,e){this.topic(t).publish(e)}publishMany(t){x(()=>{for(let[e,i]of t)this.topic(e).publish(i)})}subscribe(t,e,i){let s=this.topic(e);return new T(t,s,i)}removeTopic(t){if(!this._topics.has(t))return!1;try{this.remove(t)}finally{this._topics.delete(t),this._version+=1}return!0}};function P(n,t){return new l(n,t)}function L(n,t){return new v(n,t)}function G(n,t,e){return new T(n,t,e)}function S(n,t,e,i){return new g(n,t,e,i)}export{l as a,T as b,g as c,v as d,P as e,L as f,G as g,S as h,C as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as N,E as A,F as p,p as C}from"./chunk-
|
|
1
|
+
import{D as N,E as A,F as p,p as C}from"./chunk-LYCLF26R.js";import{b as v,c as S,d as x,i as T,j as b}from"./chunk-CK2E7BTU.js";function y(e,n,t){let u=new Set;for(let o of e.split(",")){let[r,i]=o.split("/"),s=i?Number.parseInt(i,10):1;if(Number.isNaN(s)||s<1)throw new Error(`Invalid cron step: ${o}`);let a,d;if(r==="*")a=n,d=t;else if(r.includes("-")){let[f,c]=r.split("-");a=Number.parseInt(f,10),d=Number.parseInt(c,10)}else a=Number.parseInt(r,10),d=a;if(Number.isNaN(a)||Number.isNaN(d))throw new Error(`Invalid cron field: ${e}`);if(a<n||d>t)throw new Error(`Cron field out of range: ${e} (${n}-${t})`);if(a>d)throw new Error(`Invalid cron range: ${a}-${d} in ${e}`);for(let f=a;f<=d;f+=s)u.add(f)}return u}function I(e){let n=e.trim().split(/\s+/);if(n.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${n.length}`);return{minutes:y(n[0],0,59),hours:y(n[1],0,23),daysOfMonth:y(n[2],1,31),months:y(n[3],1,12),daysOfWeek:y(n[4],0,6)}}function L(e,n){return e.minutes.has(n.getMinutes())&&e.hours.has(n.getHours())&&e.daysOfMonth.has(n.getDate())&&e.months.has(n.getMonth()+1)&&e.daysOfWeek.has(n.getDay())}function m(e){return{describeKind:"producer",...e}}function $(e){return/[\\^$+?.()|[\]{}]/.test(e)?`\\${e}`:e}function J(e){let n="^";for(let t=0;t<e.length;t+=1){let u=e[t];if(u==="*"){e[t+1]==="*"?(n+=".*",t+=1):n+="[^/]*";continue}n+=$(u)}return n+="$",new RegExp(n)}function Q(e,n){for(let t of n)if(t.test(e))return!0;return!1}function _(e,n){let t=N([e],(o,r)=>{let i=o[0];if(i==null||i.length===0){r.down([[x]]);return}for(let s of i)r.emit(s)},{describeKind:"derived",initial:e.cache}),u=t.subscribe.bind(t);return t.subscribe=(o,r)=>(n(o),u(o,r)),t}function X(e,n){let{signal:t,period:u,...o}=n??{};return p(r=>{let i=!1,s=0,a,d,f=()=>{i=!0,a!==void 0&&clearTimeout(a),d!==void 0&&clearInterval(d),t?.removeEventListener("abort",l)},c=()=>{i||(u!=null?(r.emit(s++),d=setInterval(()=>{i||r.emit(s++)},u)):(i=!0,t?.removeEventListener("abort",l),r.emit(s++),r.down([[T]])))},l=()=>{i||(f(),r.down([[b,t.reason]]))};if(t?.aborted){l();return}return a=setTimeout(c,e),t?.addEventListener("abort",l,{once:!0}),f},m(o))}function Z(e){let{signal:n,...t}=e??{};return p(u=>{let o=!1,r,i,s=!1,a=!1,d=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,f=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,c=typeof document<"u"?document:void 0,l=()=>{r!==void 0&&f&&f(r),i!==void 0&&clearTimeout(i),r=void 0,i=void 0},h=()=>{o=!0,l(),s&&(n?.removeEventListener("abort",w),s=!1),a&&c&&(c.removeEventListener("visibilitychange",O),a=!1)},w=()=>{o||(h(),u.down([[b,n.reason]]))},k=F=>{o||(u.emit(F),g())},g=()=>{o||(d&&(!c||c.visibilityState!=="hidden")?r=d(k):i=setTimeout(()=>k(performance.now()),16))},O=()=>{o||(l(),g())};return n?.aborted?(w(),h):(n?.addEventListener("abort",w,{once:!0}),s=n!==void 0,c&&d&&(c.addEventListener("visibilitychange",O),a=!0),g(),h)},m(t))}function ee(e,n){let t=I(e),{tickMs:u,output:o,...r}=n??{},i=u??6e4,s=o==="date";return p(a=>{let d=-1,f=()=>{let l=new Date,h=l.getFullYear()*1e8+(l.getMonth()+1)*1e6+l.getDate()*1e4+l.getHours()*100+l.getMinutes();h!==d&&L(t,l)&&(d=h,a.emit(s?l:C()))};f();let c=setInterval(f,i);return()=>clearInterval(c)},{...m(r),name:r.name??`cron:${e}`})}function ne(e,n,t){let{capture:u,passive:o,once:r,...i}=t??{};return p(s=>{let a=f=>{s.emit(f)},d={capture:u,passive:o,once:r};return e.addEventListener(n,a,d),()=>e.removeEventListener(n,a,d)},m(i))}function M(e,n){return p(t=>{let u=!1;try{for(let o of e){if(u)return;t.emit(o)}u||t.down([[T]])}catch(o){u||t.down([[b,o]])}return()=>{u=!0}},m(n))}function K(e){return e!=null&&typeof e.then=="function"}function W(e,n){let{signal:t,...u}=n??{};return p(o=>{let r=!1,i=()=>{r||(r=!0,o.down([[b,t.reason]]))};if(t?.aborted){i();return}return t?.addEventListener("abort",i,{once:!0}),Promise.resolve(e).then(s=>{r||(r=!0,t?.removeEventListener("abort",i),o.emit(s),o.down([[T]]))},s=>{r||(r=!0,t?.removeEventListener("abort",i),o.down([[b,s]]))}),()=>{r=!0,t?.removeEventListener("abort",i)}},m(u))}function q(e,n){let{signal:t,...u}=n??{};return p(o=>{let r=new AbortController,i=()=>r.abort(t?.reason);t?.aborted?r.abort(t.reason):t?.addEventListener("abort",i,{once:!0});let s=t??r.signal,a=!1,d=e[Symbol.asyncIterator](),f=()=>{a||s.aborted||Promise.resolve(d.next()).then(c=>{if(!(a||s.aborted)){if(c.done){o.down([[T]]);return}o.emit(c.value),f()}},c=>{!a&&!s.aborted&&o.down([[b,c]])})};return f(),()=>{a=!0,t?.removeEventListener("abort",i),r.abort(),Promise.resolve(d.return?.()).catch(()=>{})}},m(u))}function H(e){return e!=null&&typeof e=="object"&&"cache"in e&&typeof e.subscribe=="function"}function te(e,n){if(H(e))return e;if(K(e))return W(e,n);if(e!=null){let t=e;if(typeof t[Symbol.asyncIterator]=="function")return q(e,n);if(typeof t[Symbol.iterator]=="function")return M(e,n)}return U(e)}function U(...e){return M(e,void 0)}function re(e){return p(n=>{n.down([[T]])},m(e))}function oe(e){return p(()=>{},m(e))}function ie(e,n){return p(t=>{t.down([[b,e]])},m(n))}function se(e,n,t){return N([e],(o,r)=>{let i=o[0];if(i!=null&&i.length>0)for(let s of i)n(s)},{describeKind:"effect",...t}).subscribe(()=>{})}function ue(e,n){return N([e],(t,u,o)=>{o.store.buf||(o.store.buf=[]);let r=o.store.buf,i=t[0];if(i!=null&&i.length>0)for(let s of i)r.push(s);if(o.terminalDeps[0]===!0){u.emit([...r]),u.down([[T]]);return}(i==null||i.length===0)&&u.down([[x]])},{describeKind:"derived",completeWhenDepsComplete:!1,...n})}function ae(e,n){return p(t=>e.subscribe(u=>{t.down(u)}),{...m(n),initial:e.cache})}function D(e,n,t){if(n<1)throw new RangeError("replay expects bufferSize >= 1");let u=[],o=p(r=>e.subscribe(i=>{for(let s of i)s[0]===v&&(u.push(s[1]),u.length>n&&u.shift());r.down(i)}),{...m(t),initial:e.cache});return _(o,r=>{for(let i of u)r([[v,i]])})}function de(e,n){return D(e,1,n)}function fe(e){return new Promise((n,t)=>{let u=!1,o=!1,r;r=e.subscribe(i=>{for(let s of i){if(u)return;if(s[0]===v){u=!0,n(s[1]),r?(r(),r=void 0):o=!0;return}if(s[0]===b){u=!0,t(s[1]),r?(r(),r=void 0):o=!0;return}if(s[0]===T){u=!0,t(new Error("completed without DATA")),r?(r(),r=void 0):o=!0;return}}}),o&&(r?.(),r=void 0)})}function P(e,n,t){return new Promise((u,o)=>{let r=!1,i=!1,s,a=t?.skipCurrent===!0;s=e.subscribe(d=>{for(let f of d){if(r)return;if(!(a&&f[0]===v)){if(f[0]===v){let c=f[1];if(n(c)){r=!0,u(c),s?(s(),s=void 0):i=!0;return}}if(f[0]===b){r=!0,o(f[1]),s?(s(),s=void 0):i=!0;return}if(f[0]===T){r=!0,o(new Error("completed without matching value")),s?(s(),s=void 0):i=!0;return}}}}),a=!1,i&&(s?.(),s=void 0)})}var E,R;async function ce(e,n){let t=n?.predicate??(r=>r!=null),u=n?.skipCurrent;if(n?.timeoutMs==null||n.timeoutMs<=0)return await P(e,t,{skipCurrent:u});if(E===void 0){let[r,i]=await Promise.all([import("./resilience-7UZHSSGC.js"),import("./backoff-HPZMEZNF.js")]);E=r.timeout,R=i.NS_PER_MS}let o=E(e,n.timeoutMs*R);return await P(o,t,{skipCurrent:u})}function le(e,n){let t=new AbortController,u=n?.reason??new Error("cancelled via nodeSignal"),o,r=!1,i=()=>{o?(o(),o=void 0):r=!0};return o=e.subscribe(s=>{if(!t.signal.aborted)for(let a of s){if(a[0]===v&&a[1]===!0){t.abort(u),i();return}if(a[0]===b){t.abort(a[1]),i();return}if(a[0]===T){i();return}}}),r&&(o?.(),o=void 0),{signal:t.signal,dispose:()=>{o&&(o(),o=void 0)}}}var pe=D;function me(e){return e.subscribe(()=>{})}function be(e){let n=A(0);return{node:n,increment(){let t=n.cache??0;return t>=e?!1:(n.down([[S],[v,t+1]]),!0)},get(){return n.cache??0},atCap(){return(n.cache??0)>=e}}}export{I as a,L as b,$ as c,J as d,Q as e,X as f,Z as g,ee as h,ne as i,M as j,W as k,q as l,te as m,U as n,re as o,oe as p,ie as q,se as r,ue as s,ae as t,D as u,de as v,fe as w,P as x,ce as y,le as z,pe as A,me as B,be as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as n}from"./chunk-
|
|
1
|
+
import{d as n}from"./chunk-YDWTVO4E.js";import{j as a}from"./chunk-2JO6LXFT.js";import{b as c}from"./chunk-QYADASLV.js";var s={};c(s,{GuardedExecutionGraph:()=>o,guardedExecution:()=>p});var o=class extends a{enforcer;violations;_target;_defaultActor;constructor(r,e){super(e.name??`${r.name}_guarded`,e.graph),this._target=r,this._defaultActor=e.actor;let t={mode:e.mode??"enforce",name:"enforcer"};e.violationsLimit!=null&&(t.violationsLimit=e.violationsLimit),this.enforcer=n(r,e.policies,t),this.violations=this.enforcer.violations,this.mount("enforcer",this.enforcer)}scopedDescribe(r){let e=r?.actor??this._defaultActor,t={...r,...e!=null?{actor:e}:{}};return this._target.describe(t)}get target(){return this._target}};function p(i,r){return new o(i,r)}export{o as a,p as b,s as c};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as ce}from"./chunk-
|
|
1
|
+
import{c as ce}from"./chunk-YUBV7EEE.js";import{a as se,b as P}from"./chunk-5QDBSZBV.js";import{j as L}from"./chunk-2JO6LXFT.js";import{f as ae,h as ie}from"./chunk-T7EQPKOP.js";import{i as ne,j as U}from"./chunk-LYCLF26R.js";import{b,h as _,i as T,j as W}from"./chunk-CK2E7BTU.js";import{b as Oe,c as re,d as te,e as oe}from"./chunk-QYADASLV.js";var ke={};Oe(ke,{ACTOR_KEY:()=>F,COMMAND_HANDLERS:()=>A,CQRS_EVENT_HANDLERS:()=>S,CRON_HANDLERS:()=>D,CommandHandler:()=>me,EVENT_HANDLERS:()=>G,EventHandler:()=>ve,GRAPHREFLY_REQUEST_GRAPH:()=>R,GRAPHREFLY_ROOT_GRAPH:()=>v,GraphCron:()=>fe,GraphInterval:()=>he,GraphReflyEventExplorer:()=>x,GraphReflyGuard:()=>Re,GraphReflyGuardImpl:()=>I,GraphReflyModule:()=>Q,INTERVAL_HANDLERS:()=>O,InjectCqrsGraph:()=>de,InjectGraph:()=>ue,InjectNode:()=>pe,ObserveGateway:()=>B,OnGraphEvent:()=>le,QUERY_HANDLERS:()=>H,QueryHandler:()=>ye,SAGA_HANDLERS:()=>N,SagaHandler:()=>ge,fromHeader:()=>Ee,fromJwtPayload:()=>V,getActor:()=>we,getGraphToken:()=>m,getNodeToken:()=>y,observeSSE:()=>Me,observeSubscription:()=>Ce,toObservable:()=>se});import{Inject as j}from"@nestjs/common";var v=Symbol.for("graphrefly:root-graph");var R=Symbol.for("graphrefly:request-graph");function m(s){return Symbol.for(`graphrefly:graph:${s}`)}function y(s){return Symbol.for(`graphrefly:node:${s}`)}var G=new Map,O=new Map,D=new Map,A=new Map,S=new Map,H=new Map,N=new Map;function ue(s){return s==="request"?j(R):j(s?m(s):v)}function de(s){return j(m(s))}function pe(s){return j(y(s))}function le(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=G.get(o)??[];n.push({nodeName:s,methodKey:t}),G.set(o,n)})}}function he(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=O.get(o)??[];n.push({ms:s,methodKey:t}),O.set(o,n)})}}function fe(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=D.get(o)??[];n.push({expr:s,methodKey:t}),D.set(o,n)})}}function me(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=A.get(n)??[];a.push({cqrsName:s,commandName:e,methodKey:o}),A.set(n,a)})}}function ve(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=S.get(n)??[];a.push({cqrsName:s,eventName:e,methodKey:o}),S.set(n,a)})}}function ye(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=H.get(n)??[];a.push({cqrsName:s,projectionName:e,methodKey:o}),H.set(n,a)})}}function ge(s,e,r){return(t,o)=>{let n=o.name;o.addInitializer(function(){let a=this.constructor,c=N.get(a)??[];c.push({cqrsName:s,eventNames:r,sagaName:e,methodKey:n}),N.set(a,c)})}}var be=0,x=class{constructor(e,r){this.graph=e;this.moduleRef=r}disposers=[];scheduleNodeNames=[];onModuleInit(){this.wireEvents(),this.wireIntervals(),this.wireCrons(),this.wireCqrsCommands(),this.wireCqrsEvents(),this.wireCqrsQueries(),this.wireCqrsSagas()}onModuleDestroy(){for(let e of this.disposers)e();this.disposers.length=0;for(let e of this.scheduleNodeNames)try{this.graph.remove(e)}catch{}this.scheduleNodeNames.length=0}wireEvents(){for(let[e,r]of G){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireEventHandler(t,o)}}wireEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),a=this.observeNode(r.nodeName).subscribe(c=>{for(let l of c)l[0]===b&&o(l[1])});this.disposers.push(a)}wireIntervals(){for(let[e,r]of O){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireIntervalHandler(t,e,o)}}wireIntervalHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ae(t.ms,{period:t.ms,name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCrons(){for(let[e,r]of D){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCronHandler(t,e,o)}}wireCronHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ie(t.expr,{name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCqrsCommands(){for(let[e,r]of A){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsCommand(t,o)}}wireCqrsCommand(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.command(r.commandName,o)}wireCqrsEvents(){for(let[e,r]of S){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsEventHandler(t,o)}}wireCqrsEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;n.event(r.eventName);let c=n.resolve(r.eventName).cache,l=c&&c.length>0?c[c.length-1].seq:0,p=this.observeNodeOn(n,r.eventName).subscribe(u=>{for(let d of u)if(d[0]===b){let g=d[1];for(let i of g)i.seq>l&&(o(i),l=i.seq)}});this.disposers.push(p)}wireCqrsQueries(){for(let[e,r]of H){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsQuery(t,o)}}wireCqrsQuery(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;let c=this.observeNodeOn(n,r.projectionName).subscribe(l=>{for(let f of l)f[0]===b&&o(f[1])});this.disposers.push(c)}wireCqrsSagas(){for(let[e,r]of N){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsSaga(t,o)}}wireCqrsSaga(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.saga(r.sagaName,r.eventNames,o)}observeNode(e){return this.graph.observe(e)}observeNodeOn(e,r){return e.observe(r)}resolveCqrsGraph(e){try{return this.moduleRef.get(m(e),{strict:!1})}catch{return console.warn(`[GraphReFly] CqrsGraph "${e}" not found in DI \u2014 did you import GraphReflyModule.forCqrs({ name: "${e}" })?`),null}}resolveInstance(e){try{return this.moduleRef.get(e,{strict:!1})}catch{return null}}};function Me(s,e,r){let{actor:t,serialize:o=De,keepAliveMs:n,signal:a}=r??{},c=new TextEncoder,l,f=r?.highWaterMark!=null,p,u,d=[],g=!1;return new ReadableStream({start(i){let h,w=()=>{},M=()=>{if(!g){g=!0,h!==void 0&&clearInterval(h),a?.removeEventListener("abort",K),w(),p?.dispose(),u?.(),u=void 0;for(let k of d)i.enqueue(k.frame);d.length=0,i.close()}};l=M;let K=()=>M(),ee=s.observe(e,{actor:t});f&&(p=P(k=>ee.up(k),{highWaterMark:r.highWaterMark,lowWaterMark:r.lowWaterMark??Math.floor(r.highWaterMark/2)})),w=ee.subscribe(k=>{for(let $ of k){if(g)return;let q=$[0];if(q===b){let C=c.encode(Y("data",o($[1])));f?(d.push({frame:C,counted:!0}),p.onEnqueue(),u?.(),u=void 0):i.enqueue(C)}else if(q===W){let C=c.encode(Y("error",o($[1])));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C),M();return}else if(q===T||q===_){if(q===T){let C=c.encode(Y("complete"));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C)}M();return}}}),n!==void 0&&n>0&&(h=setInterval(()=>{g||(f?(d.push({frame:c.encode(`: keepalive
|
|
2
2
|
|
|
3
3
|
`),counted:!1}),u?.(),u=void 0):i.enqueue(c.encode(`: keepalive
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{E as M,m as x,o as v}from"./chunk-
|
|
1
|
+
import{E as M,m as x,o as v}from"./chunk-LYCLF26R.js";import{b as _,c as K}from"./chunk-CK2E7BTU.js";var b=class{_version=0;_store=new Map;_maxSize;_defaultTtl;constructor(t={}){let{maxSize:e,defaultTtl:i}=t;if(e!==void 0&&e<1)throw new RangeError("maxSize must be >= 1");if(i!==void 0&&i<=0)throw new RangeError("defaultTtl must be positive");this._maxSize=e,this._defaultTtl=i}get version(){return this._version}get size(){return this._store.size}has(t){let e=this._store.get(t);return e===void 0?!1:this._isExpired(e)?(this._store.delete(t),this._version+=1,!1):(this._touchLru(t,e),!0)}get(t){let e=this._store.get(t);if(e!==void 0){if(this._isExpired(e)){this._store.delete(t),this._version+=1;return}return this._touchLru(t,e),e.value}}set(t,e,i){let s=this._resolveExpiresAt(i);this._store.has(t)&&this._store.delete(t),this._store.set(t,{value:e,expiresAt:s}),this._evictLruWhileOver(),this._version+=1}setMany(t,e){let i=this._resolveExpiresAt(e),s=0;try{for(let[f,a]of t)this._store.has(f)&&this._store.delete(f),this._store.set(f,{value:a,expiresAt:i}),s+=1}finally{s>0&&(this._evictLruWhileOver(),this._version+=1)}}delete(t){let e=this._store.delete(t);return e&&(this._version+=1),e}deleteMany(t){let e=0;try{for(let i of t)this._store.delete(i)&&(e+=1)}finally{e>0&&(this._version+=1)}return e}clear(){let t=this._store.size;return t===0?0:(this._store.clear(),this._version+=1,t)}pruneExpired(){let t=v(),e=0;for(let[i,s]of this._store)this._isExpired(s,t)&&(this._store.delete(i),e+=1);return e>0&&(this._version+=1),e}toMap(){let t=v(),e=new Map;for(let[i,s]of this._store)this._isExpired(s,t)||e.set(i,s.value);return e}_resolveExpiresAt(t){let e=t??this._defaultTtl;if(e!==void 0){if(!Number.isFinite(e)||e<=0)throw new RangeError(`MapBackend: ttl must be a positive finite number (got ${e})`);return v()+e*1e9}}_isExpired(t,e){return t.expiresAt===void 0?!1:(e??v())>=t.expiresAt}_touchLru(t,e){this._store.delete(t),this._store.set(t,e)}_evictLruWhileOver(){if(this._maxSize!==void 0)for(;this._store.size>this._maxSize;){let t=this._store.keys().next().value;if(t===void 0)break;this._store.delete(t)}}};function R(y={}){let{name:t,maxSize:e,defaultTtl:i,versioning:s,backend:f,retention:a}=y;if(a&&e!==void 0)throw new RangeError("reactiveMap: `maxSize` (LRU) and `retention` (score-based) are mutually exclusive. Pick one eviction policy.");if(a&&a.archiveThreshold===void 0&&a.maxSize===void 0)throw new RangeError("reactiveMap: `retention` requires at least one of `archiveThreshold` or `maxSize` to trigger archival.");let o=f??new b({maxSize:e,defaultTtl:i}),m=M(o.toMap(),{name:t,describeKind:"state",equals:(r,d)=>r===d,...s!=null?{versioning:s}:{}});function V(){let r=o.toMap();x(()=>{m.down([[K]]),m.down([[_,r]])})}function k(){if(!a)return;let r=o.toMap(),d=a.archiveThreshold,l=a.maxSize,p=[];for(let[n,h]of r)p.push({key:n,value:h,score:a.score(n,h)});p.sort((n,h)=>n.score-h.score);let c=new Set;if(d!==void 0)for(let n of p)if(n.score<d)c.add(n.key);else break;if(l!==void 0&&p.length-c.size>l)for(let n of p){if(p.length-c.size<=l)break;c.has(n.key)||c.add(n.key)}if(c.size!==0)for(let n of p)c.has(n.key)&&(a.onArchive?.(n.key,n.value,n.score),o.delete(n.key))}function u(r,d="mutation"){let l=o.version;try{return r()}finally{o.version!==l&&(d==="mutation"&&k(),V())}}return{entries:m,has(r){return u(()=>o.has(r),"read")},get(r){return u(()=>o.get(r),"read")},set(r,d,l){u(()=>o.set(r,d,l?.ttl))},setMany(r,d){u(()=>o.setMany(r,d?.ttl))},delete(r){u(()=>o.delete(r))},deleteMany(r){u(()=>o.deleteMany(r))},clear(){u(()=>o.clear())},pruneExpired(){u(()=>o.pruneExpired())},get size(){return o.size},dispose(){}}}export{b as a,R as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as z}from"./chunk-
|
|
1
|
+
import{b as z}from"./chunk-PBN426RU.js";import{g as Y,j as J}from"./chunk-2JO6LXFT.js";import{E as L,F as T,G as D,H as P}from"./chunk-LYCLF26R.js";import{b as Z}from"./chunk-QYADASLV.js";var pe={};Z(pe,{compileSpec:()=>se,decompileGraph:()=>ae,extractFnFactory:()=>V,extractSourceFactory:()=>B,generateCatalogPrompt:()=>K,isRichFnEntry:()=>M,isRichSourceEntry:()=>W,llmCompose:()=>ce,llmRefine:()=>X,specDiff:()=>ie,validateSpec:()=>A,validateSpecAgainstCatalog:()=>q});function M(i){return typeof i=="object"&&i!==null&&"factory"in i}function W(i){return typeof i=="object"&&i!==null&&"factory"in i}function V(i){return M(i)?i.factory:i}function B(i){return W(i)?i.factory:i}function K(i){let n=[];if(i.fns){let o=new Map;for(let[r,d]of Object.entries(i.fns)){let p=M(d)?d.tags?.[0]??"Other":"Other";o.has(p)||o.set(p,[]),o.get(p).push(ee(r,d))}for(let[r,d]of o)n.push(`${r}:
|
|
2
2
|
${d.join(`
|
|
3
3
|
`)}`)}if(i.sources){let o=[];for(let[r,d]of Object.entries(i.sources))o.push(te(r,d));o.length>0&&n.push(`Sources:
|
|
4
4
|
${o.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as H,b as T}from"./chunk-
|
|
1
|
+
import{a as H,b as T}from"./chunk-INXDSJRC.js";import{j as q}from"./chunk-2JO6LXFT.js";import{a as O,b as j}from"./chunk-533RQFF6.js";import{E as d,G as o,H as x,m as A}from"./chunk-LYCLF26R.js";import{b as ae}from"./chunk-QYADASLV.js";var ie={};ae(ie,{demoShell:()=>re});function w(h){return Math.max(0,Math.min(1,h))}function re(h){let B=w(h?.mainRatio??.65),E=w(h?.sideSplit??.5),J=Math.max(0,h?.viewportWidth??1280),k=h?.nodeRegistry??new Map,p=h?.adapter??null,S=h?.layoutFont??"14px monospace",u=h?.onHighlight,t=new q("demo-shell"),F=d(B,{name:"pane/main-ratio"}),D=d(E,{name:"pane/side-split"}),g=d(null,{name:"pane/fullscreen"}),G=d(J,{name:"viewport/width"});t.add(F,{name:"pane/main-ratio"}),t.add(D,{name:"pane/side-split"}),t.add(g,{name:"pane/fullscreen"}),t.add(G,{name:"viewport/width"});let L=o([F,G,g],([e,a,n])=>{let l=e,r=a,i=n;return i==="main"?r:i==="graph"||i==="code"?0:Math.round(r*l)},{name:"pane/main-width"}),R=o([L,G,g],([e,a,n])=>{let l=n,r=a;return l==="main"?0:l==="graph"||l==="code"?r:r-e},{name:"pane/side-width"}),C=o([D,g],([e,a])=>{let n=a;return n==="graph"?1:n==="code"||n==="main"?0:w(e)},{name:"pane/graph-height-ratio"}),K=o([C,g],([e,a])=>{let n=a;return n==="code"?1:n==="graph"||n==="main"?0:1-e},{name:"pane/code-height-ratio"});t.add(L,{name:"pane/main-width"}),t.add(R,{name:"pane/side-width"}),t.add(C,{name:"pane/graph-height-ratio"}),t.add(K,{name:"pane/code-height-ratio"});let b=d(null,{name:"demo/graph-ref"}),m=d(0,{name:"demo/graph-tick"});t.add(b,{name:"demo/graph-ref"}),t.add(m,{name:"demo/graph-tick"});let Q=o([b,m],([e,a])=>{let n=e;return n?n.describe({format:"mermaid"}):""},{name:"graph/mermaid"}),z=o([b,m],([e,a])=>{let n=e;if(!n)return null;let{expand:l,...r}=n.describe({detail:"standard"});return r},{name:"graph/describe"});t.add(Q,{name:"graph/mermaid"}),t.add(z,{name:"graph/describe"});let M=d(null,{name:"hover/target"});t.add(M,{name:"hover/target"});let P=o([M],([e])=>{let a=e;if(!a)return null;let n=k.get(a.id);return n?n.codeLine:null},{name:"highlight/code-scroll"}),W=o([M],([e])=>{let a=e;if(!a)return null;let n=k.get(a.id);return n?n.visualSelector:null},{name:"highlight/visual"}),N=o([M],([e])=>{let a=e;return a?a.id:null},{name:"highlight/graph"});if(t.add(P,{name:"highlight/code-scroll"}),t.add(W,{name:"highlight/visual"}),t.add(N,{name:"highlight/graph"}),u?.codeScroll){let e=u.codeScroll,a=x([P],([n])=>{e(n)});t.add(a,{name:"highlight/apply-code-scroll"})}if(u?.visual){let e=u.visual,a=x([W],([n])=>{e(n)});t.add(a,{name:"highlight/apply-visual"})}if(u?.graph){let e=u.graph,a=x([N],([n])=>{e(n)});t.add(a,{name:"highlight/apply-graph"})}let _=d(null,{name:"inspect/selected-node"});t.add(_,{name:"inspect/selected-node"});let U=O("standard"),X=o([_,b,m],([e,a,n])=>{let l=a,r=e;if(!l||!r)return null;try{let i=l.resolve(r),s=j(i,U);return{path:r,...s,value:i.cache}}catch{return null}},{name:"inspect/node-detail"}),Y=o([b,m],([e,a])=>{let n=e;return n?n.trace():[]},{name:"inspect/trace-log"});t.add(X,{name:"inspect/node-detail"}),t.add(Y,{name:"inspect/trace-log"});let I=d(!1,{name:"meta/debug"});t.add(I,{name:"meta/debug"});let Z=o([I,m],([e,a])=>e?t.describe({format:"mermaid"}):"",{name:"meta/shell-mermaid"});t.add(Z,{name:"meta/shell-mermaid"});let V=d("",{name:"layout/code-text"});if(t.add(V,{name:"layout/code-text"}),p){let e=new Map,a=o([z],([r])=>{let i=r;if(!i)return new Map;let s=new Map;for(let[c]of Object.entries(i.nodes)){let f=H(c,S,p,e),v=T(f,1/0,p,S,e),y=v.lines.reduce((te,ne)=>Math.max(te,ne.width),0),ee=v.lineCount*20;s.set(c,{width:y,height:ee})}return s},{name:"layout/graph-labels",equals:(r,i)=>{if(r===i)return!0;let s=r,c=i;if(s.size!==c.size)return!1;for(let[f,v]of s){let y=c.get(f);if(!y||y.width!==v.width||y.height!==v.height)return!1}return!0}}),n=o([V,R],([r,i])=>{let s=r;if(!s)return{lineCount:0,lines:[]};let c=H(s,S,p,e),f=i-40;return T(c,Math.max(100,f),p,S,e)},{name:"layout/code-lines"}),l=o([a],([r])=>{let i=r;if(i.size===0)return 200;let s=0;for(let{width:c}of i.values())c>s&&(s=c);return Math.max(200,Math.round(s+80))},{name:"layout/side-width-hint"});t.add(a,{name:"layout/graph-labels"}),t.add(n,{name:"layout/code-lines"}),t.add(l,{name:"layout/side-width-hint"})}let $=0;return{graph:t,setMainRatio(e){t.set("pane/main-ratio",w(e))},setSideSplit(e){t.set("pane/side-split",w(e))},setFullscreen(e){t.set("pane/fullscreen",e)},setViewportWidth(e){t.set("viewport/width",Math.max(0,e))},setHoverTarget(e){t.set("hover/target",e)},setDemoGraph(e){t.set("demo/graph-ref",e)},bumpGraphTick(){t.set("demo/graph-tick",++$)},selectNode(e){t.set("inspect/selected-node",e)},setMetaDebug(e){t.set("meta/debug",e)},setCodeText(e){t.set("layout/code-text",e)},batch(e){A(e)},destroy(){t.destroy()}}}export{re as a,ie as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as I}from"./chunk-
|
|
1
|
+
import{b as I}from"./chunk-TZQPPQEQ.js";import{t as A,x as v}from"./chunk-4F564IPP.js";import{m as p,r as y}from"./chunk-T7EQPKOP.js";import{E as R,G as w,m as h}from"./chunk-LYCLF26R.js";import{b}from"./chunk-CK2E7BTU.js";function z(t){return typeof t=="object"&&t!==null&&"cache"in t&&typeof t.subscribe=="function"}function F(t,a,e){let r=p(t),i=r.v!=null,g=R(e?.initialVerified??null,{...i?{meta:{sourceVersion:null}}:{}}),x=e?.trigger!==void 0&&e.trigger!==null,s=null;if(x&&e?.autoVerify?s=A(p(e.trigger),r):x?s=p(e.trigger):e?.autoVerify&&(s=r),s!==null){let d;if(s===r)d=v(r,c=>a(c));else{let c=r.cache;r.subscribe(f=>{for(let M of f)M[0]===b&&(c=M[1])}),d=v(s,()=>a(c))}y(d,c=>{h(()=>{if(g.down([[b,c]]),i){let f=r.v;f!=null&&g.meta.sourceVersion.down([[b,{id:f.id,version:f.version}]])}})})}return{node:r,verified:g,trigger:s}}function E(t){t.subscribe(()=>{})}function k(t){return t instanceof Map?t:new Map}function B(t,a){if(!Array.isArray(a.upsert))throw new TypeError("distill extraction requires upsert: Array<{ key, value }>");h(()=>{for(let{key:e,value:r}of a.upsert)t.set(e,r);for(let e of a.remove??[])t.delete(e)})}function G(t,a,e){let r=p(t),i=I(e.mapOptions??{}),g=e.budget??2e3,s=e.context!==void 0&&e.context!==null?p(e.context):R(null),d=k(i.entries.cache);i.entries.subscribe(o=>{for(let u of o)u[0]===b&&(d=k(u[1]))});let c=v(r,o=>a(o,d));if(y(c,o=>{B(i,o)}),e.evict){let o=new Map,u=w([i.entries],([l])=>{let m=[],N=k(l);for(let n of o.keys())N.has(n)||(o.get(n)(),o.delete(n));for(let[n,T]of N){let V=e.evict(n,T);if(z(V)){if(!o.has(n)){let S=y(V,D=>{D===!0&&i.has(n)&&i.delete(n)});o.set(n,S)}continue}if(typeof V=="boolean"){V&&m.push(n);continue}throw new TypeError("distill evict() must return boolean or Node<boolean>")}return m});y(u,l=>{for(let m of l)i.delete(m)})}let f=e.consolidateTrigger!==void 0&&e.consolidateTrigger!==null;if(e.consolidate&&f){let o=p(e.consolidateTrigger),u=v(o,()=>e.consolidate(d));y(u,l=>{B(i,l)})}let M=w([i.entries,s],([o,u])=>{let l=[...k(o).entries()].map(([n,T])=>({key:n,value:T,score:e.score(T,u),cost:e.cost(T)}));l.sort((n,T)=>T.score-n.score);let m=[],N=g;for(let n of l)n.cost<=N&&(m.push({key:n.key,value:n.value,score:n.score}),N-=n.cost);return m}),O=w([i.entries],([o])=>k(o).size);return E(M),E(O),{store:i,compact:M,size:O}}export{F as a,G as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as F,g as j,h as A}from"./chunk-
|
|
1
|
+
import{f as F,g as j,h as A}from"./chunk-U2T2XWDA.js";import{h as b,j as x}from"./chunk-2JO6LXFT.js";import{p as _}from"./chunk-LYCLF26R.js";import{b as $,d as T,i as v,j as N}from"./chunk-CK2E7BTU.js";import{b as K}from"./chunk-QYADASLV.js";var Y={};K(Y,{SNAPSHOT_WIRE_VERSION:()=>k,SurfaceError:()=>o,asSurfaceError:()=>D,createGraph:()=>R,deleteSnapshot:()=>H,diffSnapshots:()=>W,listSnapshots:()=>L,restoreSnapshot:()=>V,runReduction:()=>M,saveSnapshot:()=>U});var o=class extends Error{code;details;constructor(t,r,n){super(r),this.name="SurfaceError",this.code=t,n!==void 0&&(this.details=n)}toJSON(){let t={code:this.code,message:this.message};if(this.details!==void 0){let r=q(this.details);r!==void 0&&(t.details=r)}return t}};function q(e){try{return JSON.parse(JSON.stringify(e))}catch{return}}function D(e,t="internal-error"){if(e instanceof o)return e;let r=e instanceof Error?e.message:String(e);return new o(t,r)}function R(e,t){let r=j(e);if(!r.valid)throw new o("invalid-spec",`GraphSpec validation failed:
|
|
2
2
|
${r.errors.join(`
|
|
3
3
|
`)}`,{errors:r.errors});let n=t?.catalog??{},s=F(e,n);if(!s.valid)throw new o("catalog-error",`Catalog validation failed:
|
|
4
4
|
${s.errors.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as $}from"./chunk-
|
|
1
|
+
import{a as $}from"./chunk-T2TB37TW.js";import{c as O}from"./chunk-L3KUKDZC.js";import{a as C}from"./chunk-Q46YJCQH.js";import{b as x}from"./chunk-HTBOCKVD.js";import{j as A}from"./chunk-2JO6LXFT.js";import{B as R}from"./chunk-T7EQPKOP.js";import{C as T,E as N,G as E,o as b,p as w,u as P,w as S}from"./chunk-LYCLF26R.js";import{b as v}from"./chunk-CK2E7BTU.js";import{b as M}from"./chunk-QYADASLV.js";var J={};M(J,{AuditTrailGraph:()=>k,PolicyEnforcerGraph:()=>G,auditTrail:()=>z,complianceSnapshot:()=>F,policyEnforcer:()=>K,reactiveExplainPath:()=>q});function V(i,t){return O("audit",i,t)}var L=new Set(["data","error","complete","teardown"]),k=class extends A{entries;count;_log;_target;constructor(t,n){super(n.name??`${t.name}_audit`,n.graph),this._target=t,this._log=x([],{name:"entries",...n.maxSize!=null?{maxSize:n.maxSize}:{}}),this.entries=this._log.entries,this.add(this.entries,{name:"entries"}),this.count=E([this.entries],([c])=>c.length,{name:"count",describeKind:"derived",meta:V("count")}),this.add(this.count,{name:"count"}),this.addDisposer(R(this.count));let o=n.includeTypes!=null?new Set(n.includeTypes):L,u=n.filter,a=0,h=t.observe({timeline:!0,structured:!0}),m=h.onEvent(c=>{if(c.type==="derived")return;let e=c.type;if(!o.has(e))return;let d=c.path??"",r={seq:a++,timestamp_ns:c.timestamp_ns??b(),wall_clock_ns:w(),path:d,type:e},f=(d?D(t,d):void 0)?.lastMutation;f!=null&&(r.actor=f.actor),e==="data"&&(r.value=c.data),e==="error"&&(r.error=c.data);let l=d?U(t,d):void 0;l!=null&&(r.annotation=l),!(u!=null&&!u(r))&&this._log.append(r)});this.addDisposer(()=>{m(),h.dispose()}),this.addDisposer(()=>this._log.disposeAllViews())}all(){return this.entries.cache??[]}byNode(t){return this.all().filter(n=>n.path===t)}byActor(t){return this.all().filter(n=>n.actor?.id===t)}byActorType(t){return this.all().filter(n=>n.actor?.type===t)}byTimeRange(t,n){return this.all().filter(o=>!(o.timestamp_ns<t||n!=null&&o.timestamp_ns>=n))}get target(){return this._target}};function z(i,t={}){return new k(i,t)}var G=class extends A{policies;violations;violationCount;_target;_mode;_currentGuard;constructor(t,n,o){super(o.name??`${t.name}_policy`,o.graph),this._target=t,this._mode=o.mode??"audit";let u=I(n)?n:N(n,{name:"policies"});this.policies=u,this.add(this.policies,{name:"policies"}),this.violations=new $("violations",{retainedLimit:o.violationsLimit??1e3}),this.mount("violations",this.violations),this.violationCount=E([this.violations.events],([e])=>e.length,{name:"violationCount",describeKind:"derived",meta:V("policy_violation_count")}),this.add(this.violationCount,{name:"violationCount"}),this.addDisposer(R(this.violationCount));let h=u.cache??[];this._currentGuard=P(h);let m=u.subscribe(e=>{for(let d of e)d[0]===v&&(h=d[1]??[],this._currentGuard=P(h))});this.addDisposer(m);let c=o.paths!=null?[...o.paths]:j(t);if(this._mode==="enforce"){let e=new Map,d=r=>{if(e.has(r))return;let s=D(t,r);if(!(s instanceof T))return;let f=(l,p)=>{let y=this._currentGuard(l,p);return y||this._publishViolation(l,p,r,"blocked"),y};e.set(r,s._pushGuard(f))};for(let r of c)d(r);if(o.paths==null){let r=C(t,(s,f,l)=>{if(s.kind==="added")if(s.nodeKind==="node")d(`${l}${s.name}`);else{let p=f._mounts.get(s.name);if(!(p instanceof A))return;let y=`${l}${s.name}::`,_=j(p);for(let g of _)d(g===""?`${l}${s.name}`:`${y}${g}`)}else if(s.kind==="removed")if(s.nodeKind==="node"){let p=`${l}${s.name}`,y=e.get(p);y!=null&&(y(),e.delete(p))}else{let p=`${l}${s.name}`,y=`${p}::`;for(let[_,g]of e)(_===p||_.startsWith(y))&&(g(),e.delete(_))}});this.addDisposer(r)}else{let r=t.topology.subscribe(s=>{for(let f of s){if(f[0]!==v)continue;let l=f[1];if(l.kind!=="removed"||l.nodeKind!=="node")continue;let p=e.get(l.name);p!=null&&(p(),e.delete(l.name))}});this.addDisposer(r)}this.addDisposer(()=>{for(let r of e.values())r();e.clear()})}else{let e=t.observe({timeline:!0,structured:!0}),d=e.onEvent(r=>{if(r.type!=="data"&&r.type!=="error")return;let s=r.path??"";if(!s||o.paths!=null&&!o.paths.includes(s))return;let f=r.actor??D(t,s)?.lastMutation?.actor;if(f==null)return;let l="write";this._currentGuard(f,l)||this._publishViolation(f,l,s,"observed")});this.addDisposer(()=>{d(),e.dispose()})}}_publishViolation(t,n,o,u){this.violations.publish({timestamp_ns:b(),wall_clock_ns:w(),path:o,actor:t,action:n,mode:this._mode,result:u})}all(){return this.violations.retained()}get mode(){return this._mode}get target(){return this._target}};function K(i,t,n={}){return new G(i,t,n)}function q(i,t,n,o){return i.explain(t,n,{reactive:!0,...o})}function F(i,t={}){let n={format_version:1,timestamp_ns:b(),wall_clock_ns:w(),graph:i.snapshot()};if(t.actor!=null&&(n.actor=t.actor),t.audit!=null){let u=[...t.audit.all()];n.audit={count:u.length,entries:u}}if(t.policies!=null){let u=t.policies.policies.cache??[];n.policies={mode:t.policies.mode,rules:u,violations:[...t.policies.all()]}}let o=B(n);return{...n,fingerprint:o}}function I(i){return typeof i=="object"&&i!==null&&"subscribe"in i}function D(i,t){try{return i.node(t)}catch{return}}function U(i,t){try{return i.annotation(t)}catch{return}}function j(i){let t=i.describe({detail:"minimal"});return Object.keys(t.nodes)}function B(i){return S(JSON.stringify(H(i)))}function H(i){let t=new Set,n=o=>{if(o===void 0)return{__undefined:!0};if(o===null)return null;let u=typeof o;if(u==="bigint")return{__bigint:o.toString()};if(u!=="object")return o;let a=o;if(t.has(a))return{__circular:!0};t.add(a);try{if(Array.isArray(a))return a.map(n);if(a instanceof Date)return{__date:a.toISOString()};if(a instanceof RegExp)return{__regexp:{source:a.source,flags:a.flags}};if(a instanceof Map)return{__map:[...a.entries()].map(([c,e])=>[n(c),n(e)])};if(a instanceof Set)return{__set:[...a].map(n)};if(ArrayBuffer.isView(a)){let m=a,c=new Array(m.length);for(let e=0;e<m.length;e++)c[e]=m[e]??0;return{__typed_array:{ctor:a.constructor.name,data:c}}}let h={};for(let m of Object.keys(a).sort())h[m]=n(a[m]);return h}finally{t.delete(a)}};return n(i)}export{k as a,z as b,G as c,K as d,q as e,F as f,J as g};
|