@graphrefly/graphrefly 0.31.0 → 0.33.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-2JO6LXFT.js +7 -0
- package/dist/{chunk-FTA5TB2A.js → chunk-2LZ6DL45.js} +1 -1
- package/dist/{chunk-WQ7I7JVU.js → chunk-4F564IPP.js} +1 -1
- package/dist/{chunk-YQJPYEAL.js → chunk-4NYSEUKV.js} +1 -1
- package/dist/{chunk-N2KKISCE.js → chunk-533RQFF6.js} +1 -1
- package/dist/{chunk-ZM7C2FUM.js → chunk-55T3K37W.js} +1 -1
- package/dist/chunk-6HQ6HVTF.js +1 -0
- package/dist/{chunk-4VXL3UZK.js → chunk-7Q2WPFQ7.js} +1 -1
- package/dist/{chunk-3Q2WXM6X.js → chunk-BY4WKPKM.js} +1 -1
- package/dist/{chunk-4ZPO2EL5.js → chunk-C5DINHNP.js} +1 -1
- package/dist/{chunk-I4U3TPK2.js → chunk-CJMFZXIZ.js} +1 -1
- package/dist/{chunk-W6FQIFVE.js → chunk-CLD3F4R5.js} +1 -1
- package/dist/chunk-DUK7LTJO.js +43 -0
- package/dist/{chunk-RWGJQQLT.js → chunk-FKRPIRE6.js} +1 -1
- package/dist/{chunk-PZP4MEXK.js → chunk-GAOX6OPT.js} +1 -1
- package/dist/{chunk-OKQUPJRY.js → chunk-GCUYSIM4.js} +1 -1
- package/dist/chunk-HIJ2RKVP.js +1 -0
- package/dist/{chunk-XRSHMHEG.js → chunk-HTBOCKVD.js} +1 -1
- package/dist/{chunk-JXRZXP3N.js → chunk-IB64M7VP.js} +1 -1
- package/dist/{chunk-Q2SY7M7K.js → chunk-IJFSR4NU.js} +1 -1
- package/dist/{chunk-YZKGGMPT.js → chunk-INXDSJRC.js} +1 -1
- package/dist/{chunk-WLPVGXQ6.js → chunk-IPNJDNE7.js} +1 -1
- package/dist/{chunk-4UUDNFYG.js → chunk-KGKJCHEK.js} +1 -1
- 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-PNTBXOQ6.js → chunk-O2WY22L7.js} +1 -1
- package/dist/{chunk-JMGGCSIC.js → chunk-PBN426RU.js} +1 -1
- package/dist/{chunk-7EQPXQ7H.js → chunk-Q46YJCQH.js} +1 -1
- package/dist/{chunk-4KAUNEKV.js → chunk-SFIM774L.js} +1 -1
- package/dist/{chunk-EBQ6FXKW.js → chunk-T2TB37TW.js} +1 -1
- package/dist/{chunk-UMH3HSP7.js → chunk-T7EQPKOP.js} +1 -1
- package/dist/{chunk-3JRKP4BH.js → chunk-TONEKQM3.js} +1 -1
- package/dist/{chunk-GF5T7PGC.js → chunk-TZLEMGAK.js} +1 -1
- package/dist/{chunk-LWGLBCMU.js → chunk-TZQPPQEQ.js} +1 -1
- package/dist/chunk-U2T2XWDA.js +80 -0
- package/dist/{chunk-7EJTWGKW.js → chunk-UF746BQ4.js} +1 -1
- package/dist/{chunk-7QMVU3IX.js → chunk-WBWBY6LI.js} +1 -1
- package/dist/{chunk-WYJTXYWX.js → chunk-Y63GWRHO.js} +1 -1
- package/dist/{chunk-YZ6VYLFD.js → chunk-YDWTVO4E.js} +1 -1
- package/dist/{chunk-Z3UWIJ3A.js → chunk-YUBV7EEE.js} +1 -1
- package/dist/chunk-Z4GXBOWO.js +61 -0
- 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-CWeI0aHd.d.ts → graph-BROUZPG9.d.ts} +12 -2
- package/dist/{graph-C4Uxwv0T.d.cts → graph-DaoydJ_u.d.cts} +12 -2
- package/dist/{index-BXzl1NDD.d.ts → index--BTb6HUO.d.ts} +332 -108
- package/dist/{index-Dm3_D5Ta.d.cts → index-B-KCkW4M.d.cts} +4 -4
- package/dist/{index-CDK5RsV5.d.cts → index-B1hFhK1K.d.cts} +1 -1
- package/dist/{index-CJymKyzT.d.ts → index-B5eS17Bz.d.ts} +7 -7
- package/dist/{index-UZO988ox.d.cts → index-BDEhWLF4.d.cts} +3 -3
- package/dist/{index-DGb1awva.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-CfFYyLR8.d.ts → index-BUtCR0k6.d.ts} +13 -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-DxMS0cHM.d.ts → index-Bd2AjMQY.d.ts} +2 -2
- package/dist/{index-CvS9IuTG.d.ts → index-Bi4ZP6Hc.d.ts} +2 -2
- package/dist/{index-D-kHVedZ.d.cts → index-BkfL5MXh.d.cts} +24 -3
- package/dist/{index-9iguV3bF.d.cts → index-BpjQanLs.d.cts} +2 -2
- package/dist/{index-D9HrBx2J.d.ts → index-BsxqmV6u.d.ts} +2 -2
- package/dist/{index-DVNLe3pS.d.cts → index-C2Dey3L-.d.cts} +12 -3
- package/dist/{index-CwhcFzTA.d.ts → index-C5uMGVJw.d.ts} +4 -4
- package/dist/{index-D9Y_u6BG.d.cts → index-C8_bnDBZ.d.cts} +3 -3
- package/dist/{index-C5Ghnp5B.d.ts → index-CD7qmvSf.d.ts} +3 -3
- package/dist/{index-wIx1Jisk.d.ts → index-CI5fULSz.d.ts} +1 -1
- package/dist/{index-BBINVimG.d.ts → index-CNxdDb2e.d.ts} +3 -3
- package/dist/{index-FBqTfL_S.d.cts → index-CQ1gt4rn.d.cts} +1 -1
- package/dist/{index-DD7RhHNJ.d.cts → index-C_cXlbu0.d.cts} +332 -108
- package/dist/{index-B-z8WaSd.d.cts → index-Ccv_61jG.d.cts} +2 -2
- package/dist/{index-RQg6lTrN.d.ts → index-Ced0dphF.d.ts} +9 -9
- package/dist/{index-DylQCKEL.d.cts → index-ChZvMC4M.d.cts} +13 -4
- package/dist/{index-CcS0t-l2.d.ts → index-Chi9IiHJ.d.ts} +24 -3
- package/dist/{index-CcpEvuPl.d.cts → index-ClJUZAOr.d.cts} +18 -3
- package/dist/{index-D7XxY1Ff.d.cts → index-ClKm7CFB.d.cts} +1 -1
- package/dist/{index-C98oJsEs.d.cts → index-Cn3taOmp.d.cts} +2 -2
- package/dist/{index-yIdWFo2b.d.cts → index-CoR-tOZA.d.cts} +4 -4
- package/dist/{index-BpFWP7Bq.d.cts → index-Cp91Sxbo.d.cts} +5 -4
- package/dist/{index-IZ3l_vQ9.d.ts → index-Cq7Uqgu4.d.ts} +2 -2
- package/dist/{index-DBQUKh59.d.cts → index-D23g00HE.d.cts} +4 -4
- package/dist/{index-Docdiu9a.d.ts → index-D80nGRb9.d.ts} +3 -3
- package/dist/{index-Bd6oFZqO.d.ts → index-DDf8PoPO.d.ts} +439 -67
- package/dist/{index-CRAkoq-y.d.cts → index-DR3XqZlV.d.cts} +1 -1
- package/dist/{index-BANwzwBV.d.ts → index-Db21wuaD.d.ts} +5 -4
- package/dist/{index-CZChc85Q.d.cts → index-Dgcd59CJ.d.cts} +439 -67
- package/dist/{index-CIXaiYDE.d.cts → index-DhWrMTI6.d.cts} +1 -1
- package/dist/{index-CotRMjtJ.d.ts → index-DheNs40A.d.ts} +2 -2
- package/dist/{index-C6NBfXj-.d.ts → index-Dia4yc2y.d.ts} +3 -3
- package/dist/{index-Bs3-LC83.d.cts → index-Ds3Rz9m9.d.cts} +3 -3
- package/dist/{index-FrYrV-Vf.d.ts → index-Dtpr2FIB.d.ts} +18 -3
- package/dist/{index-ByPnK85n.d.ts → index-DupIl9wI.d.ts} +1 -1
- package/dist/{index-B5iVOD7w.d.ts → index-DuvQAU02.d.ts} +2 -2
- package/dist/{index-D0C_USMR.d.ts → index-DxEcY7Om.d.ts} +1 -1
- package/dist/{index-CFW32Dy1.d.ts → index-HvJ90_tX.d.ts} +12 -3
- package/dist/{index-DR3gf_DG.d.cts → index-Jgl7ev9I.d.cts} +9 -9
- package/dist/{index-BMe3pCom.d.cts → index-RJX4snyi.d.cts} +2 -2
- package/dist/{index-gJQqJTKx.d.cts → index-ZIQaKIdY.d.cts} +7 -7
- package/dist/{index-BEpRsvhg.d.ts → index-b4a6Sg0R.d.ts} +4 -4
- package/dist/{index-lKuLYmHO.d.cts → index-iKsmdnq6.d.cts} +2 -2
- package/dist/{index-Bvi5uJxX.d.ts → index-nP13Qe6T.d.ts} +1 -1
- package/dist/{index-iBp74eGU.d.cts → index-p0bkNfby.d.cts} +3 -3
- package/dist/{index-SSGqF8mI.d.cts → index-wcfc7W-f.d.cts} +2 -2
- package/dist/{index-Cy7eFeIX.d.cts → index-yJY9thRY.d.cts} +2 -2
- package/dist/{index-DnrZghBB.d.ts → index-ygRFoyrN.d.ts} +2 -2
- package/dist/{index-Ip3q9T9x.d.ts → index-zA1uVtk0.d.ts} +1 -1
- package/dist/index.cjs +53 -50
- 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 +4 -4
- 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 +21 -18
- 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 +5 -5
- 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 +27 -25
- 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 -11
- package/dist/patterns/harness/index.d.cts +10 -9
- package/dist/patterns/harness/index.d.ts +10 -9
- 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 +2 -2
- 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 +2 -2
- 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 +15 -13
- 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-BAr6-_o5.d.ts → reactive-layout-DBJ3Vz-m.d.ts} +2 -2
- package/dist/{reactive-layout-5oEn8lHM.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-CVREibAc.d.cts → topology-tree-BB6oJxMz.d.cts} +1 -1
- package/dist/{topology-tree-CkjojcB6.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-5LJAQTSS.js +0 -1
- package/dist/chunk-7AJKUA36.js +0 -1
- package/dist/chunk-ASDKRNOJ.js +0 -60
- package/dist/chunk-KN4Q5MQO.js +0 -1
- package/dist/chunk-PSQNYY72.js +0 -7
- package/dist/chunk-X2VHDT26.js +0 -43
- package/dist/chunk-XEFAMCEA.js +0 -78
|
@@ -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};
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
${d.join(`
|
|
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
|
+
${o.join(`
|
|
5
|
+
`)}`)}return n.join(`
|
|
6
|
+
|
|
7
|
+
`)}function ee(i,n){if(!M(n))return`- ${i}`;let o=`- ${i}: ${n.description}`;if(n.configSchema){let r=Object.entries(n.configSchema).map(([d,p])=>{let l=`${d}: ${p.type}`;return p.enum&&(l+=` (${p.enum.join("|")})`),p.required===!1&&(l+="?"),l});o+=`. Config: { ${r.join(", ")} }`}return o}function te(i,n){if(!W(n))return`- ${i}`;let o=`- ${i}: ${n.description}`;if(n.configSchema){let r=Object.entries(n.configSchema).map(([d,p])=>{let l=`${d}: ${p.type}`;return p.required===!1&&(l+="?"),l});o+=`. Config: { ${r.join(", ")} }`}return o}function q(i,n){let o=[],r=new Set(Object.keys(n.fns??{})),d=new Set(Object.keys(n.sources??{}));for(let[p,l]of Object.entries(i.nodes)){if(l.type==="template")continue;let s=l;if(s.fn&&r.size>0&&!r.has(s.fn))if(d.has(s.fn))o.push(`Node "${p}": fn "${s.fn}" is a source, not a function. Use it as a producer source instead, or use a function from: ${[...r].join(", ")}`);else{let c=I(s.fn,r);o.push(`Node "${p}": fn "${s.fn}" not found in catalog`+(c?`. Did you mean "${c}"?`:""))}if(s.source&&d.size>0&&!d.has(s.source))if(r.has(s.source))o.push(`Node "${p}": source "${s.source}" is a function, not a source. Use it as fn instead, or use a source from: ${[...d].join(", ")}`);else{let c=I(s.source,d);o.push(`Node "${p}": source "${s.source}" not found in catalog`+(c?`. Did you mean "${c}"?`:""))}if(s.fn&&s.config&&n.fns?.[s.fn]){let c=n.fns[s.fn];if(M(c)&&c.configSchema){for(let[t,$]of Object.entries(c.configSchema))if($.required!==!1&&!(t in s.config)&&o.push(`Node "${p}": config missing required field "${t}"`),t in s.config&&$.enum){let O=s.config[t];$.enum.includes(O)||o.push(`Node "${p}": config.${t} = ${JSON.stringify(O)}, expected one of: ${$.enum.join(", ")}`)}}}}if(i.templates){for(let[p,l]of Object.entries(i.templates))for(let[s,c]of Object.entries(l.nodes))if(c.fn&&r.size>0&&!r.has(c.fn)){let t=I(c.fn,r);o.push(`Template "${p}" node "${s}": fn "${c.fn}" not found in catalog`+(t?`. Did you mean "${t}"?`:""))}}return{valid:o.length===0,errors:o,warnings:[]}}function I(i,n){let o=null,r=1/0,d=i.toLowerCase();for(let p of n){let l=ne(d,p.toLowerCase());l<r&&l<=Math.max(3,Math.floor(i.length/2))&&(r=l,o=p)}return o}function ne(i,n){let o=i.length,r=n.length,d=Array.from({length:o+1},(p,l)=>Array.from({length:r+1},(s,c)=>l===0?c:c===0?l:0));for(let p=1;p<=o;p++)for(let l=1;l<=r;l++)d[p][l]=i[p-1]===n[l-1]?d[p-1][l-1]:1+Math.min(d[p-1][l],d[p][l-1],d[p-1][l-1]);return d[o][r]}var U=new Set(["state","producer","derived","effect","operator","template"]),oe=new Set(["state","producer","derived","effect","operator"]);function A(i){let n=[],o=[];if(i==null||typeof i!="object")return{valid:!1,errors:["GraphSpec must be a non-null object"],warnings:o};let r=i;if((typeof r.name!="string"||r.name.length===0)&&n.push("Missing or empty 'name' field"),r.nodes==null||typeof r.nodes!="object"||Array.isArray(r.nodes))return n.push("Missing or invalid 'nodes' field (must be an object)"),{valid:!1,errors:n,warnings:o};let d=new Set(Object.keys(r.nodes)),p=new Map,l=new Map;if(r.templates!=null&&typeof r.templates=="object"&&!Array.isArray(r.templates)){for(let[s,c]of Object.entries(r.templates))if(c!=null&&typeof c=="object"){let t=c;l.set(s,{params:Array.isArray(t.params)?t.params:[]})}}if(r.templates!=null)if(typeof r.templates!="object"||Array.isArray(r.templates))n.push("'templates' must be an object");else for(let[s,c]of Object.entries(r.templates)){if(c==null||typeof c!="object"){n.push(`Template "${s}": must be an object`);continue}let t=c;if(Array.isArray(t.params)||n.push(`Template "${s}": missing 'params' array`),t.nodes==null||typeof t.nodes!="object"||Array.isArray(t.nodes))n.push(`Template "${s}": missing or invalid 'nodes' object`);else{let $=new Set(Array.isArray(t.params)?t.params:[]),O=new Set(Object.keys(t.nodes));for(let[w,m]of Object.entries(t.nodes)){if(m==null||typeof m!="object"){n.push(`Template "${s}" node "${w}": must be an object`);continue}let g=m;if((typeof g.type!="string"||!oe.has(g.type))&&n.push(`Template "${s}" node "${w}": invalid type`),Array.isArray(g.deps))for(let y of g.deps)!O.has(y)&&!$.has(y)&&n.push(`Template "${s}" node "${w}": dep "${y}" is not an inner node or param`)}typeof t.output!="string"?n.push(`Template "${s}": missing 'output' string`):t.nodes[t.output]||n.push(`Template "${s}": output "${t.output}" is not a declared node`)}}for(let[s,c]of Object.entries(r.nodes)){if(c==null||typeof c!="object"){n.push(`Node "${s}": must be an object`);continue}let t=c;if(typeof t.type!="string"||!U.has(t.type)){n.push(`Node "${s}": invalid type "${String(t.type)}" (expected: ${[...U].join(", ")})`);continue}if(p.set(s,t.type),t.type==="template")if(typeof t.template!="string"||!l.has(t.template))n.push(`Node "${s}": template "${String(t.template)}" not found in templates`);else if(t.bind==null||typeof t.bind!="object"||Array.isArray(t.bind))n.push(`Node "${s}": template ref requires 'bind' object`);else{let $=l.get(t.template),O=t.bind;for(let w of $.params)w in O||n.push(`Node "${s}": template param "${w}" is not bound (template "${t.template}")`);for(let[,w]of Object.entries(O))typeof w=="string"&&!d.has(w)&&n.push(`Node "${s}": bind target "${w}" does not reference an existing node`)}else{if(Array.isArray(t.deps))for(let $ of t.deps)$===s?n.push(`Node "${s}": self-referencing dep`):d.has($)||n.push(`Node "${s}": dep "${$}" does not reference an existing node`);(t.type==="derived"||t.type==="effect"||t.type==="operator")&&!Array.isArray(t.deps)&&n.push(`Node "${s}": ${t.type} node should have a 'deps' array`)}}if(r.feedback!=null)if(!Array.isArray(r.feedback))n.push("'feedback' must be an array");else for(let s=0;s<r.feedback.length;s++){let c=r.feedback[s];if(c==null||typeof c!="object"){n.push(`Feedback [${s}]: must be an object`);continue}let t=c;typeof t.from!="string"||!d.has(t.from)?n.push(`Feedback [${s}]: 'from' "${String(t.from)}" does not reference an existing node`):p.get(t.from)==="effect"&&o.push(`Feedback [${s}]: 'from' "${t.from}" is an effect node \u2014 effects emit no DATA, so the feedback edge will never fire. Did you mean a derived/state node upstream?`),typeof t.from=="string"&&t.from===t.to&&n.push(`Feedback [${s}]: 'from' and 'to' must be different nodes`),typeof t.to!="string"||!d.has(t.to)?n.push(`Feedback [${s}]: 'to' "${String(t.to)}" does not reference an existing node`):typeof t.to=="string"&&p.get(t.to)!=="state"&&n.push(`Feedback [${s}]: 'to' node "${t.to}" must be a state node (got "${p.get(t.to)??"unknown"}")`)}return{valid:n.length===0,errors:n,warnings:o}}function se(i,n){let o=A(i);if(!o.valid)throw new Error(`compileSpec: invalid GraphSpec:
|
|
8
|
+
${o.errors.join(`
|
|
9
|
+
`)}`);let r=n?.catalog??{},d=n?.onMissing??"placeholder",p=new J(i.name),l=i.templates??{},s=q(i,r);if(!s.valid)throw new Error(`compileSpec: catalog validation errors:
|
|
10
|
+
${s.errors.join(`
|
|
11
|
+
`)}`);let c=[],t=(a,f,e)=>{if(e){c.push({path:a,kind:"source",name:e});return}f&&c.push({path:a,kind:"fn",name:f})},$=a=>{let f=r.fns?.[a];return f?V(f):void 0},O=a=>{let f=r.sources?.[a];return f?B(f):void 0},w=new Map,m=[];for(let[a,f]of Object.entries(i.nodes)){if(f.type==="template")continue;let e=f;if(e.type==="state"){let h=L(e.initial,{name:a,meta:e.meta?{...e.meta}:void 0});p.add(h,{name:a}),w.set(a,h)}else if(e.type==="producer"){let h=e.source?O(e.source):void 0,b=e.fn?$(e.fn):void 0;if(h){let u=h(e.config??{});p.add(u,{name:a}),w.set(a,u)}else if(b){let u=b([],e.config??{});p.add(u,{name:a}),w.set(a,u)}else{t(a,e.fn,e.source);let u=T(()=>{},{name:a,meta:{...e.meta,_specFn:e.fn,_specSource:e.source}});p.add(u,{name:a}),w.set(a,u)}}else m.push([a,e])}let g=!0,y=new Map(m);for(;y.size>0&&g;){g=!1;for(let[a,f]of[...y.entries()]){let e=f.deps??[];if(!e.every(x=>w.has(x)))continue;let h=e.map(x=>w.get(x)),b=f.fn?$(f.fn):void 0,u;b?u=b(h,f.config??{}):f.type==="effect"?(f.fn&&t(a,f.fn,void 0),u=P(h,()=>{})):(f.fn&&t(a,f.fn,void 0),u=D(h,x=>x[0])),p.add(u,{name:a}),w.set(a,u),y.delete(a),g=!0}}if(y.size>0){let a=[...y.keys()].sort().join(", ");throw new Error(`compileSpec: unresolvable deps for nodes: ${a}`)}for(let[a,f]of Object.entries(i.nodes)){if(f.type!=="template")continue;let e=f,h=l[e.template],b=new J(a),u=new Map,x=[];for(let[k,S]of Object.entries(h.nodes)){let v=(S.deps??[]).map(j=>j.startsWith("$")&&e.bind[j]?e.bind[j]:j),G={...S,deps:v};if(S.type==="state"){let j=L(S.initial,{name:k,meta:S.meta?{...S.meta}:void 0});b.add(j,{name:k}),u.set(k,j)}else if(S.type==="producer"){let j=S.source?O(S.source):void 0,E=S.fn?$(S.fn):void 0;if(j){let F=j(S.config??{});b.add(F,{name:k}),u.set(k,F)}else if(E){let F=E([],S.config??{});b.add(F,{name:k}),u.set(k,F)}else{t(`${a}.${k}`,S.fn,S.source);let F=T(()=>{},{name:k,meta:{...S.meta,_specFn:S.fn,_specSource:S.source}});b.add(F,{name:k}),u.set(k,F)}}else x.push([k,G])}let R=!0,N=new Map(x);for(;N.size>0&&R;){R=!1;for(let[k,S]of[...N.entries()]){let v=S.deps??[];if(!v.every(C=>u.has(C)||w.has(C)))continue;let j=v.map(C=>u.get(C)??w.get(C)),E=S.fn?$(S.fn):void 0,F;E?F=E(j,S.config??{}):S.type==="effect"?(S.fn&&t(`${a}.${k}`,S.fn,void 0),F=P(j,()=>{})):(S.fn&&t(`${a}.${k}`,S.fn,void 0),F=D(j,C=>C[0])),b.add(F,{name:k}),u.set(k,F),N.delete(k),R=!0}}if(N.size>0){let k=[...N.keys()].sort().join(", ");throw new Error(`compileSpec: template "${e.template}" has unresolvable deps: ${k}`)}p.mount(a,b);let _=`${a}::${h.output}`;w.set(a,p.resolve(_));try{let k=p.resolve(_);k.meta._templateName?.emit(e.template),k.meta._templateBind?.emit(e.bind)}catch{}}for(let a of i.feedback??[])z(p,a.from,a.to,{maxIterations:a.maxIterations});if(c.length>0){if(d==="error"){let a=c.map(f=>` - ${f.path}: missing ${f.kind} "${f.name}"`);throw new Error(`compileSpec: ${c.length} catalog entr${c.length===1?"y":"ies"} missing \u2014 pass them via opts.catalog or set opts.onMissing to "warn"/"placeholder":
|
|
12
|
+
${a.join(`
|
|
13
|
+
`)}`)}if(d==="warn"){let a=n?.onWarn??(f=>console.warn(f));for(let f of c)a(`compileSpec: ${f.path} references missing ${f.kind} "${f.name}" \u2014 substituted placeholder`)}}return p}var re=new Set(["reduction","reduction_type","_specFn","_specSource","_templateName","_templateBind","feedbackFrom","feedbackTo","_internal"]);function ae(i){let n=i.describe({detail:"standard"}),o={},r=[],d=`::${Y}::`,p=/^__feedback_(?!effect_)(.+)$/,l=new Set;for(let m of Object.keys(n.nodes)){if(m.includes(d))continue;let g=p.exec(m);if(g){l.add(g[1]);let y=n.nodes[m]?.meta;y?.feedbackFrom&&y?.feedbackTo&&r.push({from:y.feedbackFrom,to:y.feedbackTo,...y.maxIterations?{maxIterations:y.maxIterations}:{}})}}for(let[m,g]of Object.entries(n.nodes)){if(m.includes(d)||p.test(m)||g.meta?._internal||m.startsWith("__feedback_effect_")||m.startsWith("__bridge_")||m.includes("::"))continue;let y={type:g.type};if(g.deps.length>0&&(y.deps=g.deps.filter(a=>!a.includes("::"))),g.type==="state"&&g.value!==void 0&&(y.initial=g.value),g.meta&&Object.keys(g.meta).length>0){let a={};for(let[f,e]of Object.entries(g.meta))re.has(f)||(a[f]=e);Object.keys(a).length>0&&(y.meta=a)}o[m]=y}let s={},c={},t=new Set;for(let m of n.subgraphs){let g=`${m}::`;for(let[y,a]of Object.entries(n.nodes)){if(!y.startsWith(g)||y.includes(d))continue;let f=a.meta;if(f?._templateName&&f?._templateBind){let e=f._templateName,h=f._templateBind;if(!s[e]){let b={},u=new Set,x=`${m}::`;for(let[v,G]of Object.entries(n.nodes)){if(!v.startsWith(x)||v.includes(d))continue;let j=v.slice(x.length);j.includes("::")||(u.add(j),b[j]={type:G.type,...G.deps.length>0?{deps:G.deps.map(E=>E.startsWith(x)?E.slice(x.length):E)}:{}})}let R=[],N=new Map;for(let v of Object.values(b))for(let G of v.deps??[])if(!u.has(G)&&!N.has(G)){let j=`$${G}`;R.push(j),N.set(G,j)}for(let v of Object.values(b))v.deps&&(v.deps=v.deps.map(G=>N.get(G)??G));let _=new Set;for(let v of Object.values(b))for(let G of v.deps??[])u.has(G)&&_.add(G);let S=[...u].filter(v=>!_.has(v))[0]??[...u].pop();s[e]={params:R,nodes:b,output:S}}delete o[m],c[m]={type:"template",template:e,bind:h},t.add(m);break}}}let $=new Map;for(let m of n.subgraphs){if(t.has(m))continue;let g={},y=`${m}::`;for(let[f,e]of Object.entries(n.nodes)){if(f.includes(d)||!f.startsWith(y))continue;let h=f.slice(y.length);h.includes("::")||(g[h]={type:e.type,...e.deps.length>0?{deps:e.deps.map(b=>b.startsWith(y)?b.slice(y.length):b)}:{}})}let a=JSON.stringify(Object.fromEntries(Object.entries(g).sort(([f],[e])=>f.localeCompare(e)).map(([f,e])=>[f,{type:e.type,deps:e.deps??[]}])));$.has(a)||$.set(a,[]),$.get(a).push({name:m,nodes:g})}for(let[,m]of $){if(m.length<2)continue;let g=`${m[0].name}_template`,y=m[0].nodes,a=new Set(Object.keys(y)),f=[],e=new Map;for(let R of Object.values(y))for(let N of R.deps??[])if(!a.has(N)&&!e.has(N)){let _=`$${N}`;f.push(_),e.set(N,_)}let h=new Set;for(let R of Object.values(y))for(let N of R.deps??[])a.has(N)&&h.add(N);let u=[...a].filter(R=>!h.has(R))[0]??[...a].pop(),x={};for(let[R,N]of Object.entries(y))x[R]={...N,deps:N.deps?.map(_=>e.get(_)??_)};s[g]={params:f,nodes:x,output:u};for(let R of m){delete o[R.name];let N={},_=new Set(Object.keys(R.nodes));for(let k of Object.values(R.nodes))for(let S of k.deps??[])if(!_.has(S)){let v=e.get(S)??`$${S}`;N[v]=S}c[R.name]={type:"template",template:g,bind:N}}}let O={...o,...c},w={name:n.name,nodes:O};return Object.keys(s).length>0&&(w.templates=s),r.length>0&&(w.feedback=r),w}function ie(i,n){let o=[];i.name!==n.name&&o.push({type:"changed",path:"name",detail:`"${i.name}" \u2192 "${n.name}"`});let r=new Set(Object.keys(i.nodes)),d=new Set(Object.keys(n.nodes));for(let e of d)if(!r.has(e)){let h=n.nodes[e];o.push({type:"added",path:`nodes.${e}`,detail:`type: ${h.type}`})}for(let e of r)d.has(e)||o.push({type:"removed",path:`nodes.${e}`});for(let e of r){if(!d.has(e))continue;let h=i.nodes[e],b=n.nodes[e];if(JSON.stringify(h)!==JSON.stringify(b)){let u=[];h.type!==b.type&&u.push(`type: ${h.type} \u2192 ${b.type}`),JSON.stringify(h.deps)!==JSON.stringify(b.deps)&&u.push("deps changed"),h.fn!==b.fn&&u.push(`fn: ${h.fn} \u2192 ${b.fn}`),JSON.stringify(h.config)!==JSON.stringify(b.config)&&u.push("config changed"),o.push({type:"changed",path:`nodes.${e}`,detail:u.join("; ")||"modified"})}}let p=i.templates??{},l=n.templates??{},s=new Set(Object.keys(p)),c=new Set(Object.keys(l));for(let e of c)s.has(e)||o.push({type:"added",path:`templates.${e}`});for(let e of s)c.has(e)||o.push({type:"removed",path:`templates.${e}`});for(let e of s)c.has(e)&&JSON.stringify(p[e])!==JSON.stringify(l[e])&&o.push({type:"changed",path:`templates.${e}`,detail:"template definition changed"});let t=i.feedback??[],$=n.feedback??[],O=new Set(t.map(e=>`${e.from}->${e.to}`)),w=new Set($.map(e=>`${e.from}->${e.to}`));for(let e of $){let h=`${e.from}->${e.to}`;O.has(h)||o.push({type:"added",path:`feedback.${h}`,detail:`maxIterations: ${e.maxIterations??10}`})}for(let e of t){let h=`${e.from}->${e.to}`;w.has(h)||o.push({type:"removed",path:`feedback.${h}`})}for(let e of t){let h=`${e.from}->${e.to}`,b=$.find(u=>u.from===e.from&&u.to===e.to);b&&JSON.stringify(e)!==JSON.stringify(b)&&o.push({type:"changed",path:`feedback.${h}`,detail:`maxIterations: ${e.maxIterations??10} \u2192 ${b.maxIterations??10}`})}let m=o.filter(e=>e.type==="added").length,g=o.filter(e=>e.type==="removed").length,y=o.filter(e=>e.type==="changed").length,a=[];m&&a.push(`${m} added`),g&&a.push(`${g} removed`),y&&a.push(`${y} changed`);let f=a.length>0?a.join(", "):"no changes";return{entries:o,summary:f}}var H=`You are a graph architect for GraphReFly, a reactive graph protocol.
|
|
14
|
+
|
|
15
|
+
Given a natural-language description, produce a JSON GraphSpec with this structure:
|
|
16
|
+
|
|
17
|
+
{
|
|
18
|
+
"name": "<graph_name>",
|
|
19
|
+
"nodes": {
|
|
20
|
+
"<node_name>": {
|
|
21
|
+
"type": "state" | "derived" | "producer" | "effect" | "operator",
|
|
22
|
+
"deps": ["<dep_node_name>", ...],
|
|
23
|
+
"fn": "<catalog_function_name>",
|
|
24
|
+
"source": "<catalog_source_name>",
|
|
25
|
+
"config": { ... },
|
|
26
|
+
"initial": <value>,
|
|
27
|
+
"meta": { "description": "<purpose>" }
|
|
28
|
+
},
|
|
29
|
+
"<template_instance>": {
|
|
30
|
+
"type": "template",
|
|
31
|
+
"template": "<template_name>",
|
|
32
|
+
"bind": { "$param": "node_name" }
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"templates": {
|
|
36
|
+
"<template_name>": {
|
|
37
|
+
"params": ["$param1", "$param2"],
|
|
38
|
+
"nodes": { ... },
|
|
39
|
+
"output": "<output_node>"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"feedback": [
|
|
43
|
+
{ "from": "<condition_node>", "to": "<state_node>", "maxIterations": 10 }
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
Rules:
|
|
48
|
+
- "state" nodes hold user/LLM-writable values (knobs). Use "initial" for default values.
|
|
49
|
+
- "derived" nodes compute from deps using a named "fn".
|
|
50
|
+
- "effect" nodes produce side effects from deps.
|
|
51
|
+
- "producer" nodes generate values from a named "source".
|
|
52
|
+
- Use "templates" when the same subgraph pattern repeats (e.g., per-source resilience).
|
|
53
|
+
- Use "feedback" for bounded cycles where a derived value writes back to a state node.
|
|
54
|
+
- meta.description is required for every node.
|
|
55
|
+
- Return ONLY valid JSON, no markdown fences or commentary.`;function Q(i){let n=i.match(/^```(?:json)?\s*([\s\S]*?)\s*```[\s\S]*$/);return n?n[1]:i}async function ce(i,n,o){let r=H,d=o?.catalogDescription??(o?.catalog?K(o.catalog):void 0);d&&(r+=`
|
|
56
|
+
|
|
57
|
+
Available catalog (use ONLY these names):
|
|
58
|
+
${d}`),o?.systemPromptExtra&&(r+=`
|
|
59
|
+
|
|
60
|
+
${o.systemPromptExtra}`);let p=[{role:"system",content:r},{role:"user",content:i}],c=(await n.invoke(p,{model:o?.model,temperature:o?.temperature??0,maxTokens:o?.maxTokens})).content.trim();c.startsWith("```")&&(c=Q(c));let t;try{t=JSON.parse(c)}catch{throw new Error(`llmCompose: LLM response is not valid JSON: ${c.slice(0,200)}`)}let $=A(t);if(!$.valid)throw new Error(`llmCompose: invalid GraphSpec:
|
|
61
|
+
${$.errors.join(`
|
|
62
|
+
`)}`);let O=t;if(o?.catalog){let w=o.maxAutoRefine??0;for(let m=0;m<=w;m++){let g=q(O,o.catalog);if(g.valid)break;if(m===w)throw new Error(`llmCompose: catalog validation failed after ${w} refine attempts:
|
|
63
|
+
${g.errors.join(`
|
|
64
|
+
`)}`);O=await X(O,`Fix these catalog errors:
|
|
65
|
+
${g.errors.join(`
|
|
66
|
+
`)}
|
|
67
|
+
|
|
68
|
+
Use ONLY functions and sources from the catalog.`,n,{...o,catalogDescription:d})}}return O}async function X(i,n,o,r){let d=H;r?.catalogDescription&&(d+=`
|
|
69
|
+
|
|
70
|
+
Available catalog:
|
|
71
|
+
${r.catalogDescription}`),r?.systemPromptExtra&&(d+=`
|
|
72
|
+
|
|
73
|
+
${r.systemPromptExtra}`);let p=[{role:"system",content:d},{role:"user",content:`Current GraphSpec:
|
|
74
|
+
${JSON.stringify(i,null,2)}
|
|
75
|
+
|
|
76
|
+
Modification request: ${n}
|
|
77
|
+
|
|
78
|
+
Return the complete modified GraphSpec as JSON.`}],c=(await o.invoke(p,{model:r?.model,temperature:r?.temperature??0,maxTokens:r?.maxTokens})).content.trim();c.startsWith("```")&&(c=Q(c));let t;try{t=JSON.parse(c)}catch{throw new Error(`llmRefine: LLM response is not valid JSON: ${c.slice(0,200)}`)}let $=A(t);if(!$.valid)throw new Error(`llmRefine: invalid GraphSpec:
|
|
79
|
+
${$.errors.join(`
|
|
80
|
+
`)}`);return t}export{M as a,W as b,V as c,B as d,K as e,q as f,A as g,se as h,ae as i,ie as j,ce as k,X as l,pe as m};
|
|
@@ -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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as R}from"./chunk-
|
|
1
|
+
import{c as R}from"./chunk-L3KUKDZC.js";import{b as N}from"./chunk-HTBOCKVD.js";import{j as k}from"./chunk-2JO6LXFT.js";import{B as g}from"./chunk-T7EQPKOP.js";import{D as T,E as S,G as y,m as q,p as w,t as u}from"./chunk-LYCLF26R.js";import{b as A}from"./chunk-QYADASLV.js";var P={};A(P,{CqrsGraph:()=>h,MemoryEventStore:()=>_,cqrs:()=>O});var j=u((i,e)=>{i("write"),i("signal"),e("observe")}),D=u((i,e)=>{i("observe"),i("signal"),e("write")}),H=u((i,e)=>{i("observe"),i("signal"),e("write")});function m(i,e){return R("cqrs",i,e)}var _=class{_store=new Map;persist(e){let t=this._store.get(e.type);t||(t=[],this._store.set(e.type,t)),t.push(e)}loadEvents(e,t){let n=this._store.get(e)??[],r=t?.timestampNs,s=t?.seq,o=r==null?[...n]:n.filter(d=>d.timestampNs>r||d.timestampNs===r&&d.seq>(s??-1)),a=o.length>0?o[o.length-1]:void 0;return{events:o,cursor:a?{timestampNs:a.timestampNs,seq:a.seq}:t}}clear(){this._store.clear()}},h=class extends k{_eventLogs=new Map;_commandHandlers=new Map;_projections=new Set;_sagas=new Set;_keepaliveDisposers=[];_eventStore;_seq=0;constructor(e,t={}){super(e,t.graph)}destroy(){for(let e of this._keepaliveDisposers)e();this._keepaliveDisposers.length=0,super.destroy()}event(e){let t=this._eventLogs.get(e);if(t)return t.node;let n=N([],{name:e,versioning:0}),r=n.entries,s=y([r],([o])=>o,{name:e,describeKind:"state",meta:m("event",{event_name:e}),guard:H,initial:r.cache});return this.add(s,{name:e}),this._keepaliveDisposers.push(g(s)),this._eventLogs.set(e,{log:n,node:s}),s}_appendEvent(e,t){let n=this._eventLogs.get(e);if(n||(this.event(e),n=this._eventLogs.get(e)),n.node.status==="completed"||n.node.status==="errored")throw new Error(`Cannot dispatch to terminated event stream "${e}" (status: ${n.node.status}).`);let r=n.log.entries.v,s={type:e,payload:t,timestampNs:w(),seq:++this._seq,...r!=null?{v0:{id:r.id,version:r.version}}:{}};n.log.append(s),this._eventStore&&this._eventStore.persist(s)}command(e,t){let n=S(void 0,{name:e,describeKind:"state",meta:{...m("command",{command_name:e}),error:null},guard:j});return this.add(n,{name:e}),this._commandHandlers.set(e,t),n}dispatch(e,t){let n=this._commandHandlers.get(e);if(!n)throw new Error(`Unknown command: "${e}". Register with .command() first.`);let r=this.resolve(e);q(()=>{r.emit(t,{internal:!0});try{n(t,{emit:(s,o)=>this._appendEvent(s,o)}),r.meta.error.emit(null,{internal:!0})}catch(s){throw r.meta.error.emit(s,{internal:!0}),s}})}projection(e,t,n,r){let s=t.map(a=>(this._eventLogs.has(a)||this.event(a),this._eventLogs.get(a).node)),o=y(s,a=>{let d=[];for(let v of a){let p=v;d.push(...p)}return d.sort((v,p)=>v.timestampNs-p.timestampNs||v.seq-p.seq),n(r,d)},{name:e,describeKind:"derived",meta:m("projection",{projection_name:e,source_events:t}),guard:D,initial:r});return this.add(o,{name:e}),this._keepaliveDisposers.push(g(o)),this._projections.add(e),o}saga(e,t,n){let r=t.map(d=>(this._eventLogs.has(d)||this.event(d),this._eventLogs.get(d).node)),s=new Map,o={},a=T(r,(d,v)=>{let p=o.n.meta.error;for(let c=0;c<d.length;c++){let E=d[c];if(E==null||E.length===0)continue;let l=E.at(-1);if(!l)continue;let f=t[c],C=s.get(f)??0;if(l.length>C){let b=l.slice(C);for(let L of b)try{n(L),p.emit(null,{internal:!0})}catch(x){p.emit(x,{internal:!0})}s.set(f,l.length)}}},{name:e,describeKind:"effect",meta:{...m("saga",{saga_name:e,source_events:t}),error:null}});return o.n=a,this.add(a,{name:e}),this._keepaliveDisposers.push(g(a)),this._sagas.add(e),a}useEventStore(e){this._eventStore=e}async rebuildProjection(e,t,n){if(!this._eventStore)throw new Error("No event store wired. Call useEventStore() first.");let r=[];for(let s of e){let o=await this._eventStore.loadEvents(s);r.push(...o.events)}return r.sort((s,o)=>s.timestampNs-o.timestampNs||s.seq-o.seq),t(n,r)}};function O(i,e){return new h(i,e)}export{_ as a,h as b,O as c,P as d};
|