@graphrefly/graphrefly 0.45.0 → 0.47.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/README.md +1 -2
- package/dist/_internal-B23BagFd.d.cts +33 -0
- package/dist/_internal-B23BagFd.d.ts +33 -0
- package/dist/adaptive-rate-limiter-Dch_xYIi.d.cts +111 -0
- package/dist/adaptive-rate-limiter-Dch_xYIi.d.ts +111 -0
- package/dist/agents-C0Ji9ldU.d.cts +629 -0
- package/dist/agents-C9zexT7I.d.ts +629 -0
- package/dist/audit-BAXb3VOg.d.ts +246 -0
- package/dist/audit-C_bPfkqS.d.cts +246 -0
- package/dist/backoff-7KIK3WQW.js +24 -0
- package/dist/backoff-7KIK3WQW.js.map +1 -0
- package/dist/backoff-Bnb9OoPh.d.cts +6 -0
- package/dist/backoff-Bnb9OoPh.d.ts +6 -0
- package/dist/base/composition/index.cjs +865 -0
- package/dist/base/composition/index.cjs.map +1 -0
- package/dist/base/composition/index.d.cts +468 -0
- package/dist/base/composition/index.d.ts +468 -0
- package/dist/base/composition/index.js +40 -0
- package/dist/base/composition/index.js.map +1 -0
- package/dist/base/index.cjs +6390 -0
- package/dist/base/index.cjs.map +1 -0
- package/dist/base/index.d.cts +21 -0
- package/dist/base/index.d.ts +21 -0
- package/dist/base/index.js +259 -0
- package/dist/base/index.js.map +1 -0
- package/dist/base/io/index.cjs +3270 -0
- package/dist/base/io/index.cjs.map +1 -0
- package/dist/base/io/index.d.cts +2245 -0
- package/dist/base/io/index.d.ts +2245 -0
- package/dist/base/io/index.js +117 -0
- package/dist/base/io/index.js.map +1 -0
- package/dist/base/meta/index.cjs +43 -0
- package/dist/base/meta/index.cjs.map +1 -0
- package/dist/base/meta/index.d.cts +45 -0
- package/dist/base/meta/index.d.ts +45 -0
- package/dist/base/meta/index.js +13 -0
- package/dist/base/meta/index.js.map +1 -0
- package/dist/base/mutation/index.cjs +200 -0
- package/dist/base/mutation/index.cjs.map +1 -0
- package/dist/base/mutation/index.d.cts +177 -0
- package/dist/base/mutation/index.d.ts +177 -0
- package/dist/base/mutation/index.js +22 -0
- package/dist/base/mutation/index.js.map +1 -0
- package/dist/base/render/index.cjs +1120 -0
- package/dist/base/render/index.cjs.map +1 -0
- package/dist/base/render/index.d.cts +227 -0
- package/dist/base/render/index.d.ts +227 -0
- package/dist/base/render/index.js +24 -0
- package/dist/base/render/index.js.map +1 -0
- package/dist/base/sources/browser/index.cjs +172 -0
- package/dist/base/sources/browser/index.cjs.map +1 -0
- package/dist/base/sources/browser/index.d.cts +84 -0
- package/dist/base/sources/browser/index.d.ts +84 -0
- package/dist/base/sources/browser/index.js +151 -0
- package/dist/base/sources/browser/index.js.map +1 -0
- package/dist/base/sources/event/index.cjs +98 -0
- package/dist/base/sources/event/index.cjs.map +1 -0
- package/dist/base/sources/event/index.d.cts +91 -0
- package/dist/base/sources/event/index.d.ts +91 -0
- package/dist/base/sources/event/index.js +13 -0
- package/dist/base/sources/event/index.js.map +1 -0
- package/dist/base/sources/index.cjs +755 -0
- package/dist/base/sources/index.cjs.map +1 -0
- package/dist/base/sources/index.d.cts +357 -0
- package/dist/base/sources/index.d.ts +357 -0
- package/dist/base/sources/index.js +42 -0
- package/dist/base/sources/index.js.map +1 -0
- package/dist/base/sources/node/index.cjs +320 -0
- package/dist/base/sources/node/index.cjs.map +1 -0
- package/dist/base/sources/node/index.d.cts +185 -0
- package/dist/base/sources/node/index.d.ts +185 -0
- package/dist/base/sources/node/index.js +306 -0
- package/dist/base/sources/node/index.js.map +1 -0
- package/dist/base/utils/index.cjs +37 -0
- package/dist/base/utils/index.cjs.map +1 -0
- package/dist/base/utils/index.d.cts +37 -0
- package/dist/base/utils/index.d.ts +37 -0
- package/dist/base/utils/index.js +11 -0
- package/dist/base/utils/index.js.map +1 -0
- package/dist/base/worker/index.cjs +548 -0
- package/dist/base/worker/index.cjs.map +1 -0
- package/dist/base/worker/index.d.cts +207 -0
- package/dist/base/worker/index.d.ts +207 -0
- package/dist/base/worker/index.js +20 -0
- package/dist/base/worker/index.js.map +1 -0
- package/dist/breaker-C9skL3d8.d.ts +175 -0
- package/dist/breaker-ugSdq54q.d.cts +175 -0
- package/dist/cascading-CSSbKGrJ.d.ts +199 -0
- package/dist/cascading-baGkiihI.d.cts +199 -0
- package/dist/chunk-22SG74BD.js +207 -0
- package/dist/chunk-22SG74BD.js.map +1 -0
- package/dist/chunk-255UCBG4.js +58 -0
- package/dist/chunk-255UCBG4.js.map +1 -0
- package/dist/chunk-2LO3EL4W.js +1 -0
- package/dist/chunk-2LO3EL4W.js.map +1 -0
- package/dist/chunk-2OB3CEJS.js +1065 -0
- package/dist/chunk-2OB3CEJS.js.map +1 -0
- package/dist/chunk-36NMM65U.js +144 -0
- package/dist/chunk-36NMM65U.js.map +1 -0
- package/dist/chunk-3CEXCBN6.js +1 -0
- package/dist/chunk-3CEXCBN6.js.map +1 -0
- package/dist/chunk-3MUSLI6E.js +105 -0
- package/dist/chunk-3MUSLI6E.js.map +1 -0
- package/dist/chunk-3PSLNJDU.js +884 -0
- package/dist/chunk-3PSLNJDU.js.map +1 -0
- package/dist/chunk-42FQ27MQ.js +594 -0
- package/dist/chunk-42FQ27MQ.js.map +1 -0
- package/dist/chunk-4GYMCUDZ.js +1085 -0
- package/dist/chunk-4GYMCUDZ.js.map +1 -0
- package/dist/chunk-4S53H2KR.js +382 -0
- package/dist/chunk-4S53H2KR.js.map +1 -0
- package/dist/chunk-4XCHZRUJ.js +128 -0
- package/dist/chunk-4XCHZRUJ.js.map +1 -0
- package/dist/chunk-5IMMNARC.js +1153 -0
- package/dist/chunk-5IMMNARC.js.map +1 -0
- package/dist/chunk-6XZYT4SW.js +256 -0
- package/dist/chunk-6XZYT4SW.js.map +1 -0
- package/dist/chunk-7EGRP2VX.js +76 -0
- package/dist/chunk-7EGRP2VX.js.map +1 -0
- package/dist/chunk-A7KV5UK4.js +150 -0
- package/dist/chunk-A7KV5UK4.js.map +1 -0
- package/dist/chunk-APY2SS5X.js +156 -0
- package/dist/chunk-APY2SS5X.js.map +1 -0
- package/dist/chunk-AZDQPQ3V.js +66 -0
- package/dist/chunk-AZDQPQ3V.js.map +1 -0
- package/dist/chunk-BU3SEFA5.js +90 -0
- package/dist/chunk-BU3SEFA5.js.map +1 -0
- package/dist/chunk-BXGZFGZ4.js +189 -0
- package/dist/chunk-BXGZFGZ4.js.map +1 -0
- package/dist/chunk-CGHORL6G.js +579 -0
- package/dist/chunk-CGHORL6G.js.map +1 -0
- package/dist/chunk-CXANAIZU.js +530 -0
- package/dist/chunk-CXANAIZU.js.map +1 -0
- package/dist/chunk-CZQHCKKG.js +1 -0
- package/dist/chunk-CZQHCKKG.js.map +1 -0
- package/dist/chunk-DKNHAICT.js +133 -0
- package/dist/chunk-DKNHAICT.js.map +1 -0
- package/dist/chunk-DM4OMPWK.js +584 -0
- package/dist/chunk-DM4OMPWK.js.map +1 -0
- package/dist/chunk-DMSNO6ZB.js +452 -0
- package/dist/chunk-DMSNO6ZB.js.map +1 -0
- package/dist/chunk-E5OZPDIW.js +229 -0
- package/dist/chunk-E5OZPDIW.js.map +1 -0
- package/dist/chunk-EHRRQ4IC.js +211 -0
- package/dist/chunk-EHRRQ4IC.js.map +1 -0
- package/dist/chunk-EVYY4X5A.js +509 -0
- package/dist/chunk-EVYY4X5A.js.map +1 -0
- package/dist/chunk-FDFD67UO.js +1 -0
- package/dist/chunk-FDFD67UO.js.map +1 -0
- package/dist/chunk-FMPF42Q4.js +13 -0
- package/dist/chunk-FMPF42Q4.js.map +1 -0
- package/dist/chunk-FW23JYNQ.js +454 -0
- package/dist/chunk-FW23JYNQ.js.map +1 -0
- package/dist/chunk-GWRNLJNW.js +2508 -0
- package/dist/chunk-GWRNLJNW.js.map +1 -0
- package/dist/chunk-HL7HUJIX.js +1 -0
- package/dist/chunk-HL7HUJIX.js.map +1 -0
- package/dist/chunk-IHTWQEDR.js +169 -0
- package/dist/chunk-IHTWQEDR.js.map +1 -0
- package/dist/chunk-IJRR6YAI.js +128 -0
- package/dist/chunk-IJRR6YAI.js.map +1 -0
- package/dist/chunk-JGFRAFDL.js +221 -0
- package/dist/chunk-JGFRAFDL.js.map +1 -0
- package/dist/chunk-JKTC747G.js +725 -0
- package/dist/chunk-JKTC747G.js.map +1 -0
- package/dist/chunk-KN3H5CNT.js +11 -0
- package/dist/chunk-KN3H5CNT.js.map +1 -0
- package/dist/chunk-KPG3DGLA.js +1 -0
- package/dist/chunk-KPG3DGLA.js.map +1 -0
- package/dist/chunk-KRNQ6RGQ.js +1 -0
- package/dist/chunk-KRNQ6RGQ.js.map +1 -0
- package/dist/chunk-MLTPJMH6.js +417 -0
- package/dist/chunk-MLTPJMH6.js.map +1 -0
- package/dist/chunk-N3SZ7BMH.js +95 -0
- package/dist/chunk-N3SZ7BMH.js.map +1 -0
- package/dist/chunk-NDUD3IMO.js +540 -0
- package/dist/chunk-NDUD3IMO.js.map +1 -0
- package/dist/chunk-NY2PYHNC.js +873 -0
- package/dist/chunk-NY2PYHNC.js.map +1 -0
- package/dist/chunk-O3MT7DYI.js +225 -0
- package/dist/chunk-O3MT7DYI.js.map +1 -0
- package/dist/chunk-OCUDSN63.js +2386 -0
- package/dist/chunk-OCUDSN63.js.map +1 -0
- package/dist/chunk-OIWU3NYV.js +199 -0
- package/dist/chunk-OIWU3NYV.js.map +1 -0
- package/dist/chunk-OQUIJT7A.js +1 -0
- package/dist/chunk-OQUIJT7A.js.map +1 -0
- package/dist/chunk-P5LBT622.js +105 -0
- package/dist/chunk-P5LBT622.js.map +1 -0
- package/dist/chunk-PKGQG5QQ.js +519 -0
- package/dist/chunk-PKGQG5QQ.js.map +1 -0
- package/dist/chunk-PKPO3JTZ.js +561 -0
- package/dist/chunk-PKPO3JTZ.js.map +1 -0
- package/dist/chunk-PL5UDIQ5.js +118 -0
- package/dist/chunk-PL5UDIQ5.js.map +1 -0
- package/dist/chunk-PZWISPIQ.js +432 -0
- package/dist/chunk-PZWISPIQ.js.map +1 -0
- package/dist/chunk-Q3EYOCZB.js +510 -0
- package/dist/chunk-Q3EYOCZB.js.map +1 -0
- package/dist/chunk-QMBYUVRL.js +15 -0
- package/dist/chunk-QMBYUVRL.js.map +1 -0
- package/dist/chunk-RAGGHLCV.js +200 -0
- package/dist/chunk-RAGGHLCV.js.map +1 -0
- package/dist/chunk-RJOG4IJU.js +1039 -0
- package/dist/chunk-RJOG4IJU.js.map +1 -0
- package/dist/chunk-SOOKUYVM.js +403 -0
- package/dist/chunk-SOOKUYVM.js.map +1 -0
- package/dist/chunk-T5BN5KG7.js +1 -0
- package/dist/chunk-T5BN5KG7.js.map +1 -0
- package/dist/chunk-TNX5ZGDJ.js +574 -0
- package/dist/chunk-TNX5ZGDJ.js.map +1 -0
- package/dist/chunk-TP7244Y6.js +207 -0
- package/dist/chunk-TP7244Y6.js.map +1 -0
- package/dist/chunk-TSBFTJKM.js +57 -0
- package/dist/chunk-TSBFTJKM.js.map +1 -0
- package/dist/chunk-URQ2CBBF.js +143 -0
- package/dist/chunk-URQ2CBBF.js.map +1 -0
- package/dist/chunk-VLAGJZSL.js +1079 -0
- package/dist/chunk-VLAGJZSL.js.map +1 -0
- package/dist/chunk-W2BOPXTI.js +1 -0
- package/dist/chunk-W2BOPXTI.js.map +1 -0
- package/dist/chunk-Y52CS6YA.js +88 -0
- package/dist/chunk-Y52CS6YA.js.map +1 -0
- package/dist/chunk-YCBUWK77.js +92 -0
- package/dist/chunk-YCBUWK77.js.map +1 -0
- package/dist/chunk-YJ4U2D2C.js +314 -0
- package/dist/chunk-YJ4U2D2C.js.map +1 -0
- package/dist/chunk-Z4YXAUDN.js +239 -0
- package/dist/chunk-Z4YXAUDN.js.map +1 -0
- package/dist/chunk-Z65DVDEQ.js +146 -0
- package/dist/chunk-Z65DVDEQ.js.map +1 -0
- package/dist/chunk-Z6EGP5D7.js +92 -0
- package/dist/chunk-Z6EGP5D7.js.map +1 -0
- package/dist/chunk-ZT4WMQW4.js +1575 -0
- package/dist/chunk-ZT4WMQW4.js.map +1 -0
- package/dist/chunk-ZVXXDWIB.js +1282 -0
- package/dist/chunk-ZVXXDWIB.js.map +1 -0
- package/dist/compat/index.cjs +3150 -6
- package/dist/compat/index.cjs.map +1 -1
- package/dist/compat/index.d.cts +116 -1
- package/dist/compat/index.d.ts +116 -1
- package/dist/compat/index.js +175 -2
- package/dist/compat/index.js.map +1 -1
- package/dist/compat/jotai/index.cjs +130 -2
- package/dist/compat/jotai/index.cjs.map +1 -1
- package/dist/compat/jotai/index.d.cts +2 -1
- package/dist/compat/jotai/index.d.ts +2 -1
- package/dist/compat/jotai/index.js +7 -2
- package/dist/compat/jotai/index.js.map +1 -1
- package/dist/compat/nanostores/index.cjs +186 -2
- package/dist/compat/nanostores/index.cjs.map +1 -1
- package/dist/compat/nanostores/index.d.cts +2 -1
- package/dist/compat/nanostores/index.d.ts +2 -1
- package/dist/compat/nanostores/index.js +21 -2
- package/dist/compat/nanostores/index.js.map +1 -1
- package/dist/compat/nestjs/index.cjs +2291 -6
- package/dist/compat/nestjs/index.cjs.map +1 -1
- package/dist/compat/nestjs/index.d.cts +10 -1
- package/dist/compat/nestjs/index.d.ts +10 -1
- package/dist/compat/nestjs/index.js +76 -2
- package/dist/compat/nestjs/index.js.map +1 -1
- package/dist/compat/react/index.cjs +95 -2
- package/dist/compat/react/index.cjs.map +1 -1
- package/dist/compat/react/index.d.cts +2 -1
- package/dist/compat/react/index.d.ts +2 -1
- package/dist/compat/react/index.js +11 -2
- package/dist/compat/react/index.js.map +1 -1
- package/dist/compat/solid/index.cjs +82 -2
- package/dist/compat/solid/index.cjs.map +1 -1
- package/dist/compat/solid/index.d.cts +2 -1
- package/dist/compat/solid/index.d.ts +2 -1
- package/dist/compat/solid/index.js +11 -2
- package/dist/compat/solid/index.js.map +1 -1
- package/dist/compat/svelte/index.cjs +85 -2
- package/dist/compat/svelte/index.cjs.map +1 -1
- package/dist/compat/svelte/index.d.cts +2 -1
- package/dist/compat/svelte/index.d.ts +2 -1
- package/dist/compat/svelte/index.js +11 -2
- package/dist/compat/svelte/index.js.map +1 -1
- package/dist/compat/vue/index.cjs +100 -2
- package/dist/compat/vue/index.cjs.map +1 -1
- package/dist/compat/vue/index.d.cts +3 -1
- package/dist/compat/vue/index.d.ts +3 -1
- package/dist/compat/vue/index.js +11 -2
- package/dist/compat/vue/index.js.map +1 -1
- package/dist/compat/zustand/index.cjs +50 -2
- package/dist/compat/zustand/index.cjs.map +1 -1
- package/dist/compat/zustand/index.d.cts +2 -1
- package/dist/compat/zustand/index.d.ts +2 -1
- package/dist/compat/zustand/index.js +7 -2
- package/dist/compat/zustand/index.js.map +1 -1
- package/dist/distill-De6Rnn15.d.cts +48 -0
- package/dist/distill-De6Rnn15.d.ts +48 -0
- package/dist/external-register-CWyroXb_.d.cts +138 -0
- package/dist/external-register-CWyroXb_.d.ts +138 -0
- package/dist/fallback-Bx46zqky.d.cts +243 -0
- package/dist/fallback-pIWW8A2d.d.ts +243 -0
- package/dist/guarded-execution-BcdtxeBk.d.ts +207 -0
- package/dist/guarded-execution-C-3hnP6A.d.cts +207 -0
- package/dist/index-B6pxYJzO.d.cts +36 -0
- package/dist/index-B6pxYJzO.d.ts +36 -0
- package/dist/index-BFsng6v1.d.cts +44 -0
- package/dist/index-BFsng6v1.d.ts +44 -0
- package/dist/index-B_p8tnvf.d.cts +770 -0
- package/dist/index-Bg-LwEt-.d.cts +45 -0
- package/dist/index-Bg-LwEt-.d.ts +45 -0
- package/dist/index-Brp888t0.d.cts +127 -0
- package/dist/index-Brp888t0.d.ts +127 -0
- package/dist/index-CDfk6jHN.d.cts +37 -0
- package/dist/index-CDfk6jHN.d.ts +37 -0
- package/dist/index-DLAxYaN5.d.cts +169 -0
- package/dist/index-DLAxYaN5.d.ts +169 -0
- package/dist/index-DeWbQzMe.d.cts +34 -0
- package/dist/index-DeWbQzMe.d.ts +34 -0
- package/dist/index-_HDSmPyp.d.ts +770 -0
- package/dist/index-dX9IzPqj.d.cts +86 -0
- package/dist/index-dX9IzPqj.d.ts +86 -0
- package/dist/index.cjs +26009 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -42
- package/dist/index.d.ts +55 -42
- package/dist/index.js +849 -0
- package/dist/index.js.map +1 -1
- package/dist/layout-types-B5aiHYgk.d.cts +72 -0
- package/dist/layout-types-B5aiHYgk.d.ts +72 -0
- package/dist/memory-composers-BryDrRBX.d.cts +529 -0
- package/dist/memory-composers-CVQqPYEV.d.ts +529 -0
- package/dist/observable-B25XqCbZ.d.cts +59 -0
- package/dist/observable-B25XqCbZ.d.ts +59 -0
- package/dist/pipeline-graph-Ce47CB6Y.d.cts +145 -0
- package/dist/pipeline-graph-DXCwY9vG.d.ts +145 -0
- package/dist/presets/ai/index.cjs +4377 -0
- package/dist/presets/ai/index.cjs.map +1 -0
- package/dist/presets/ai/index.d.cts +98 -0
- package/dist/presets/ai/index.d.ts +98 -0
- package/dist/presets/ai/index.js +54 -0
- package/dist/presets/ai/index.js.map +1 -0
- package/dist/presets/harness/index.cjs +5929 -0
- package/dist/presets/harness/index.cjs.map +1 -0
- package/dist/presets/harness/index.d.cts +566 -0
- package/dist/presets/harness/index.d.ts +566 -0
- package/dist/presets/harness/index.js +71 -0
- package/dist/presets/harness/index.js.map +1 -0
- package/dist/presets/index.cjs +9782 -0
- package/dist/presets/index.cjs.map +1 -0
- package/dist/presets/index.d.cts +28 -0
- package/dist/presets/index.d.ts +28 -0
- package/dist/presets/index.js +129 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/presets/inspect/index.cjs +1087 -0
- package/dist/presets/inspect/index.cjs.map +1 -0
- package/dist/presets/inspect/index.d.cts +172 -0
- package/dist/presets/inspect/index.d.ts +172 -0
- package/dist/presets/inspect/index.js +21 -0
- package/dist/presets/inspect/index.js.map +1 -0
- package/dist/presets/resilience/index.cjs +1593 -0
- package/dist/presets/resilience/index.cjs.map +1 -0
- package/dist/presets/resilience/index.d.cts +205 -0
- package/dist/presets/resilience/index.d.ts +205 -0
- package/dist/presets/resilience/index.js +18 -0
- package/dist/presets/resilience/index.js.map +1 -0
- package/dist/rate-limiter-CEALq4N1.d.ts +559 -0
- package/dist/rate-limiter-DpVbSYdH.d.cts +559 -0
- package/dist/reactive-layout-fswlBUvX.d.cts +195 -0
- package/dist/reactive-layout-fswlBUvX.d.ts +195 -0
- package/dist/retry-BDbRZ_gx.d.ts +125 -0
- package/dist/retry-DWuhjvsA.d.cts +125 -0
- package/dist/solutions/index.cjs +8200 -0
- package/dist/solutions/index.cjs.map +1 -0
- package/dist/solutions/index.d.cts +23 -0
- package/dist/solutions/index.d.ts +23 -0
- package/dist/solutions/index.js +55 -0
- package/dist/solutions/index.js.map +1 -0
- package/dist/spawnable-5mDY501F.d.cts +746 -0
- package/dist/spawnable-D3lR0oQu.d.ts +746 -0
- package/dist/status-U-rUI79b.d.cts +84 -0
- package/dist/status-U-rUI79b.d.ts +84 -0
- package/dist/timeout-U5O4ESK3.js +12 -0
- package/dist/timeout-U5O4ESK3.js.map +1 -0
- package/dist/types-BB5Lw-pB.d.cts +442 -0
- package/dist/types-BB5Lw-pB.d.ts +442 -0
- package/dist/types-CJWIMJiZ.d.ts +548 -0
- package/dist/types-vCq7ShIm.d.cts +548 -0
- package/dist/utils/ai/browser.cjs +2169 -0
- package/dist/utils/ai/browser.cjs.map +1 -0
- package/dist/utils/ai/browser.d.cts +129 -0
- package/dist/utils/ai/browser.d.ts +129 -0
- package/dist/utils/ai/browser.js +255 -0
- package/dist/utils/ai/browser.js.map +1 -0
- package/dist/utils/ai/index.cjs +8468 -0
- package/dist/utils/ai/index.cjs.map +1 -0
- package/dist/utils/ai/index.d.cts +1777 -0
- package/dist/utils/ai/index.d.ts +1777 -0
- package/dist/utils/ai/index.js +173 -0
- package/dist/utils/ai/index.js.map +1 -0
- package/dist/utils/ai/node.cjs +648 -0
- package/dist/utils/ai/node.cjs.map +1 -0
- package/dist/utils/ai/node.d.cts +57 -0
- package/dist/utils/ai/node.d.ts +57 -0
- package/dist/utils/ai/node.js +84 -0
- package/dist/utils/ai/node.js.map +1 -0
- package/dist/utils/cqrs/index.cjs +1036 -0
- package/dist/utils/cqrs/index.cjs.map +1 -0
- package/dist/utils/cqrs/index.d.cts +438 -0
- package/dist/utils/cqrs/index.d.ts +438 -0
- package/dist/utils/cqrs/index.js +18 -0
- package/dist/utils/cqrs/index.js.map +1 -0
- package/dist/utils/demo-shell/index.cjs +865 -0
- package/dist/utils/demo-shell/index.cjs.map +1 -0
- package/dist/utils/demo-shell/index.d.cts +90 -0
- package/dist/utils/demo-shell/index.d.ts +90 -0
- package/dist/utils/demo-shell/index.js +13 -0
- package/dist/utils/demo-shell/index.js.map +1 -0
- package/dist/utils/domain-templates/index.cjs +732 -0
- package/dist/utils/domain-templates/index.cjs.map +1 -0
- package/dist/utils/domain-templates/index.d.cts +214 -0
- package/dist/utils/domain-templates/index.d.ts +214 -0
- package/dist/utils/domain-templates/index.js +17 -0
- package/dist/utils/domain-templates/index.js.map +1 -0
- package/dist/utils/graphspec/index.cjs +1174 -0
- package/dist/utils/graphspec/index.cjs.map +1 -0
- package/dist/utils/graphspec/index.d.cts +449 -0
- package/dist/utils/graphspec/index.d.ts +449 -0
- package/dist/utils/graphspec/index.js +35 -0
- package/dist/utils/graphspec/index.js.map +1 -0
- package/dist/utils/harness/index.cjs +656 -0
- package/dist/utils/harness/index.cjs.map +1 -0
- package/dist/utils/harness/index.d.cts +542 -0
- package/dist/utils/harness/index.d.ts +542 -0
- package/dist/utils/harness/index.js +56 -0
- package/dist/utils/harness/index.js.map +1 -0
- package/dist/utils/index.cjs +17614 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +96 -0
- package/dist/utils/index.d.ts +96 -0
- package/dist/utils/index.js +514 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/inspect/index.cjs +807 -0
- package/dist/utils/inspect/index.cjs.map +1 -0
- package/dist/utils/inspect/index.d.cts +123 -0
- package/dist/utils/inspect/index.d.ts +123 -0
- package/dist/utils/inspect/index.js +30 -0
- package/dist/utils/inspect/index.js.map +1 -0
- package/dist/utils/job-queue/index.cjs +717 -0
- package/dist/utils/job-queue/index.cjs.map +1 -0
- package/dist/utils/job-queue/index.d.cts +200 -0
- package/dist/utils/job-queue/index.d.ts +200 -0
- package/dist/utils/job-queue/index.js +18 -0
- package/dist/utils/job-queue/index.js.map +1 -0
- package/dist/utils/memory/index.cjs +1456 -0
- package/dist/utils/memory/index.cjs.map +1 -0
- package/dist/utils/memory/index.d.cts +660 -0
- package/dist/utils/memory/index.d.ts +660 -0
- package/dist/utils/memory/index.js +19 -0
- package/dist/utils/memory/index.js.map +1 -0
- package/dist/utils/messaging/index.cjs +666 -0
- package/dist/utils/messaging/index.cjs.map +1 -0
- package/dist/utils/messaging/index.d.cts +562 -0
- package/dist/utils/messaging/index.d.ts +562 -0
- package/dist/utils/messaging/index.js +50 -0
- package/dist/utils/messaging/index.js.map +1 -0
- package/dist/utils/orchestration/index.cjs +876 -0
- package/dist/utils/orchestration/index.cjs.map +1 -0
- package/dist/utils/orchestration/index.d.cts +233 -0
- package/dist/utils/orchestration/index.d.ts +233 -0
- package/dist/utils/orchestration/index.js +19 -0
- package/dist/utils/orchestration/index.js.map +1 -0
- package/dist/utils/process/index.cjs +743 -0
- package/dist/utils/process/index.cjs.map +1 -0
- package/dist/utils/process/index.d.cts +411 -0
- package/dist/utils/process/index.d.ts +411 -0
- package/dist/utils/process/index.js +14 -0
- package/dist/utils/process/index.js.map +1 -0
- package/dist/utils/reactive-layout/index.cjs +1607 -0
- package/dist/utils/reactive-layout/index.cjs.map +1 -0
- package/dist/utils/reactive-layout/index.d.cts +492 -0
- package/dist/utils/reactive-layout/index.d.ts +492 -0
- package/dist/utils/reactive-layout/index.js +52 -0
- package/dist/utils/reactive-layout/index.js.map +1 -0
- package/dist/utils/reduction/index.cjs +203 -0
- package/dist/utils/reduction/index.cjs.map +1 -0
- package/dist/utils/reduction/index.d.cts +102 -0
- package/dist/utils/reduction/index.d.ts +102 -0
- package/dist/utils/reduction/index.js +14 -0
- package/dist/utils/reduction/index.js.map +1 -0
- package/dist/utils/resilience/index.cjs +1617 -0
- package/dist/utils/resilience/index.cjs.map +1 -0
- package/dist/utils/resilience/index.d.cts +9 -0
- package/dist/utils/resilience/index.d.ts +9 -0
- package/dist/utils/resilience/index.js +44 -0
- package/dist/utils/resilience/index.js.map +1 -0
- package/dist/utils/surface/index.cjs +1070 -0
- package/dist/utils/surface/index.cjs.map +1 -0
- package/dist/utils/surface/index.d.cts +240 -0
- package/dist/utils/surface/index.d.ts +240 -0
- package/dist/utils/surface/index.js +30 -0
- package/dist/utils/surface/index.js.map +1 -0
- package/dist/utils/topology-view/index.cjs +620 -0
- package/dist/utils/topology-view/index.cjs.map +1 -0
- package/dist/utils/topology-view/index.d.cts +68 -0
- package/dist/utils/topology-view/index.d.ts +68 -0
- package/dist/utils/topology-view/index.js +11 -0
- package/dist/utils/topology-view/index.js.map +1 -0
- package/package.json +293 -241
- package/dist/core/index.cjs +0 -21
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.d.cts +0 -1
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.js +0 -3
- package/dist/core/index.js.map +0 -1
- package/dist/extra/browser.cjs +0 -21
- package/dist/extra/browser.cjs.map +0 -1
- package/dist/extra/browser.d.cts +0 -1
- package/dist/extra/browser.d.ts +0 -1
- package/dist/extra/browser.js +0 -3
- package/dist/extra/browser.js.map +0 -1
- package/dist/extra/index.cjs +0 -21
- package/dist/extra/index.cjs.map +0 -1
- package/dist/extra/index.d.cts +0 -1
- package/dist/extra/index.d.ts +0 -1
- package/dist/extra/index.js +0 -3
- package/dist/extra/index.js.map +0 -1
- package/dist/extra/node.cjs +0 -21
- package/dist/extra/node.cjs.map +0 -1
- package/dist/extra/node.d.cts +0 -1
- package/dist/extra/node.d.ts +0 -1
- package/dist/extra/node.js +0 -3
- package/dist/extra/node.js.map +0 -1
- package/dist/extra/operators.cjs +0 -21
- package/dist/extra/operators.cjs.map +0 -1
- package/dist/extra/operators.d.cts +0 -1
- package/dist/extra/operators.d.ts +0 -1
- package/dist/extra/operators.js +0 -3
- package/dist/extra/operators.js.map +0 -1
- package/dist/extra/reactive.cjs +0 -21
- package/dist/extra/reactive.cjs.map +0 -1
- package/dist/extra/reactive.d.cts +0 -1
- package/dist/extra/reactive.d.ts +0 -1
- package/dist/extra/reactive.js +0 -3
- package/dist/extra/reactive.js.map +0 -1
- package/dist/extra/render/index.cjs +0 -21
- package/dist/extra/render/index.cjs.map +0 -1
- package/dist/extra/render/index.d.cts +0 -1
- package/dist/extra/render/index.d.ts +0 -1
- package/dist/extra/render/index.js +0 -3
- package/dist/extra/render/index.js.map +0 -1
- package/dist/extra/sources.cjs +0 -21
- package/dist/extra/sources.cjs.map +0 -1
- package/dist/extra/sources.d.cts +0 -1
- package/dist/extra/sources.d.ts +0 -1
- package/dist/extra/sources.js +0 -3
- package/dist/extra/sources.js.map +0 -1
- package/dist/extra/storage-browser.cjs +0 -21
- package/dist/extra/storage-browser.cjs.map +0 -1
- package/dist/extra/storage-browser.d.cts +0 -1
- package/dist/extra/storage-browser.d.ts +0 -1
- package/dist/extra/storage-browser.js +0 -3
- package/dist/extra/storage-browser.js.map +0 -1
- package/dist/extra/storage-core.cjs +0 -21
- package/dist/extra/storage-core.cjs.map +0 -1
- package/dist/extra/storage-core.d.cts +0 -1
- package/dist/extra/storage-core.d.ts +0 -1
- package/dist/extra/storage-core.js +0 -3
- package/dist/extra/storage-core.js.map +0 -1
- package/dist/extra/storage-node.cjs +0 -21
- package/dist/extra/storage-node.cjs.map +0 -1
- package/dist/extra/storage-node.d.cts +0 -1
- package/dist/extra/storage-node.d.ts +0 -1
- package/dist/extra/storage-node.js +0 -3
- package/dist/extra/storage-node.js.map +0 -1
- package/dist/extra/storage-tiers-browser.cjs +0 -21
- package/dist/extra/storage-tiers-browser.cjs.map +0 -1
- package/dist/extra/storage-tiers-browser.d.cts +0 -1
- package/dist/extra/storage-tiers-browser.d.ts +0 -1
- package/dist/extra/storage-tiers-browser.js +0 -3
- package/dist/extra/storage-tiers-browser.js.map +0 -1
- package/dist/extra/storage-tiers-node.cjs +0 -21
- package/dist/extra/storage-tiers-node.cjs.map +0 -1
- package/dist/extra/storage-tiers-node.d.cts +0 -1
- package/dist/extra/storage-tiers-node.d.ts +0 -1
- package/dist/extra/storage-tiers-node.js +0 -3
- package/dist/extra/storage-tiers-node.js.map +0 -1
- package/dist/extra/storage-tiers.cjs +0 -21
- package/dist/extra/storage-tiers.cjs.map +0 -1
- package/dist/extra/storage-tiers.d.cts +0 -1
- package/dist/extra/storage-tiers.d.ts +0 -1
- package/dist/extra/storage-tiers.js +0 -3
- package/dist/extra/storage-tiers.js.map +0 -1
- package/dist/extra/storage-wal.cjs +0 -21
- package/dist/extra/storage-wal.cjs.map +0 -1
- package/dist/extra/storage-wal.d.cts +0 -1
- package/dist/extra/storage-wal.d.ts +0 -1
- package/dist/extra/storage-wal.js +0 -3
- package/dist/extra/storage-wal.js.map +0 -1
- package/dist/graph/index.cjs +0 -21
- package/dist/graph/index.cjs.map +0 -1
- package/dist/graph/index.d.cts +0 -1
- package/dist/graph/index.d.ts +0 -1
- package/dist/graph/index.js +0 -3
- package/dist/graph/index.js.map +0 -1
- package/dist/patterns/ai/browser.cjs +0 -21
- package/dist/patterns/ai/browser.cjs.map +0 -1
- package/dist/patterns/ai/browser.d.cts +0 -1
- package/dist/patterns/ai/browser.d.ts +0 -1
- package/dist/patterns/ai/browser.js +0 -3
- package/dist/patterns/ai/browser.js.map +0 -1
- package/dist/patterns/ai/index.cjs +0 -21
- package/dist/patterns/ai/index.cjs.map +0 -1
- package/dist/patterns/ai/index.d.cts +0 -1
- package/dist/patterns/ai/index.d.ts +0 -1
- package/dist/patterns/ai/index.js +0 -3
- package/dist/patterns/ai/index.js.map +0 -1
- package/dist/patterns/ai/node.cjs +0 -21
- package/dist/patterns/ai/node.cjs.map +0 -1
- package/dist/patterns/ai/node.d.cts +0 -1
- package/dist/patterns/ai/node.d.ts +0 -1
- package/dist/patterns/ai/node.js +0 -3
- package/dist/patterns/ai/node.js.map +0 -1
- package/dist/patterns/cqrs/index.cjs +0 -21
- package/dist/patterns/cqrs/index.cjs.map +0 -1
- package/dist/patterns/cqrs/index.d.cts +0 -1
- package/dist/patterns/cqrs/index.d.ts +0 -1
- package/dist/patterns/cqrs/index.js +0 -3
- package/dist/patterns/cqrs/index.js.map +0 -1
- package/dist/patterns/demo-shell/index.cjs +0 -21
- package/dist/patterns/demo-shell/index.cjs.map +0 -1
- package/dist/patterns/demo-shell/index.d.cts +0 -1
- package/dist/patterns/demo-shell/index.d.ts +0 -1
- package/dist/patterns/demo-shell/index.js +0 -3
- package/dist/patterns/demo-shell/index.js.map +0 -1
- package/dist/patterns/domain-templates/index.cjs +0 -21
- package/dist/patterns/domain-templates/index.cjs.map +0 -1
- package/dist/patterns/domain-templates/index.d.cts +0 -1
- package/dist/patterns/domain-templates/index.d.ts +0 -1
- package/dist/patterns/domain-templates/index.js +0 -3
- package/dist/patterns/domain-templates/index.js.map +0 -1
- package/dist/patterns/graphspec/index.cjs +0 -21
- package/dist/patterns/graphspec/index.cjs.map +0 -1
- package/dist/patterns/graphspec/index.d.cts +0 -1
- package/dist/patterns/graphspec/index.d.ts +0 -1
- package/dist/patterns/graphspec/index.js +0 -3
- package/dist/patterns/graphspec/index.js.map +0 -1
- package/dist/patterns/harness/index.cjs +0 -21
- package/dist/patterns/harness/index.cjs.map +0 -1
- package/dist/patterns/harness/index.d.cts +0 -1
- package/dist/patterns/harness/index.d.ts +0 -1
- package/dist/patterns/harness/index.js +0 -3
- package/dist/patterns/harness/index.js.map +0 -1
- package/dist/patterns/inspect/index.cjs +0 -21
- package/dist/patterns/inspect/index.cjs.map +0 -1
- package/dist/patterns/inspect/index.d.cts +0 -1
- package/dist/patterns/inspect/index.d.ts +0 -1
- package/dist/patterns/inspect/index.js +0 -3
- package/dist/patterns/inspect/index.js.map +0 -1
- package/dist/patterns/job-queue/index.cjs +0 -21
- package/dist/patterns/job-queue/index.cjs.map +0 -1
- package/dist/patterns/job-queue/index.d.cts +0 -1
- package/dist/patterns/job-queue/index.d.ts +0 -1
- package/dist/patterns/job-queue/index.js +0 -3
- package/dist/patterns/job-queue/index.js.map +0 -1
- package/dist/patterns/memory/index.cjs +0 -21
- package/dist/patterns/memory/index.cjs.map +0 -1
- package/dist/patterns/memory/index.d.cts +0 -1
- package/dist/patterns/memory/index.d.ts +0 -1
- package/dist/patterns/memory/index.js +0 -3
- package/dist/patterns/memory/index.js.map +0 -1
- package/dist/patterns/messaging/index.cjs +0 -21
- package/dist/patterns/messaging/index.cjs.map +0 -1
- package/dist/patterns/messaging/index.d.cts +0 -1
- package/dist/patterns/messaging/index.d.ts +0 -1
- package/dist/patterns/messaging/index.js +0 -3
- package/dist/patterns/messaging/index.js.map +0 -1
- package/dist/patterns/orchestration/index.cjs +0 -21
- package/dist/patterns/orchestration/index.cjs.map +0 -1
- package/dist/patterns/orchestration/index.d.cts +0 -1
- package/dist/patterns/orchestration/index.d.ts +0 -1
- package/dist/patterns/orchestration/index.js +0 -3
- package/dist/patterns/orchestration/index.js.map +0 -1
- package/dist/patterns/process/index.cjs +0 -21
- package/dist/patterns/process/index.cjs.map +0 -1
- package/dist/patterns/process/index.d.cts +0 -1
- package/dist/patterns/process/index.d.ts +0 -1
- package/dist/patterns/process/index.js +0 -3
- package/dist/patterns/process/index.js.map +0 -1
- package/dist/patterns/reactive-layout/index.cjs +0 -21
- package/dist/patterns/reactive-layout/index.cjs.map +0 -1
- package/dist/patterns/reactive-layout/index.d.cts +0 -1
- package/dist/patterns/reactive-layout/index.d.ts +0 -1
- package/dist/patterns/reactive-layout/index.js +0 -3
- package/dist/patterns/reactive-layout/index.js.map +0 -1
- package/dist/patterns/reduction/index.cjs +0 -21
- package/dist/patterns/reduction/index.cjs.map +0 -1
- package/dist/patterns/reduction/index.d.cts +0 -1
- package/dist/patterns/reduction/index.d.ts +0 -1
- package/dist/patterns/reduction/index.js +0 -3
- package/dist/patterns/reduction/index.js.map +0 -1
- package/dist/patterns/surface/index.cjs +0 -21
- package/dist/patterns/surface/index.cjs.map +0 -1
- package/dist/patterns/surface/index.d.cts +0 -1
- package/dist/patterns/surface/index.d.ts +0 -1
- package/dist/patterns/surface/index.js +0 -3
- package/dist/patterns/surface/index.js.map +0 -1
- package/dist/patterns/topology-view/index.cjs +0 -21
- package/dist/patterns/topology-view/index.cjs.map +0 -1
- package/dist/patterns/topology-view/index.d.cts +0 -1
- package/dist/patterns/topology-view/index.d.ts +0 -1
- package/dist/patterns/topology-view/index.js +0 -3
- package/dist/patterns/topology-view/index.js.map +0 -1
- package/dist/testing/index.cjs +0 -21
- package/dist/testing/index.cjs.map +0 -1
- package/dist/testing/index.d.cts +0 -1
- package/dist/testing/index.d.ts +0 -1
- package/dist/testing/index.js +0 -3
- package/dist/testing/index.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/surface/errors.ts","../src/utils/surface/create.ts","../src/utils/surface/reduce.ts","../src/utils/surface/snapshot.ts"],"sourcesContent":["/**\n * Typed errors for the surface layer (§9.3-core).\n *\n * The surface layer is consumed by `@graphrefly/mcp-server` and\n * `@graphrefly/cli`. Both have native error channels (MCP's `isError` flag,\n * CLI's exit codes), so surface functions throw a {@link SurfaceError}\n * carrying a structured code + details payload that wrappers can map to\n * their native shape. No `Result` envelope — keep the callsite idiom\n * `try/catch` and let each wrapper surface the error its own way.\n *\n * @module\n */\n\n/** Structured error codes emitted by the surface layer. JSON-safe. */\nexport type SurfaceErrorCode =\n\t| \"invalid-spec\"\n\t| \"graph-not-found\"\n\t| \"graph-exists\"\n\t| \"snapshot-not-found\"\n\t| \"node-not-found\"\n\t| \"reduce-timeout\"\n\t| \"catalog-error\"\n\t| \"restore-failed\"\n\t| \"snapshot-failed\"\n\t| \"tier-no-list\"\n\t| \"compose-not-configured\"\n\t| \"compose-failed\"\n\t| \"internal-error\";\n\n/** JSON-safe shape surfaces should echo back through the wrapper. */\nexport interface SurfaceErrorPayload {\n\tcode: SurfaceErrorCode;\n\tmessage: string;\n\t/** Optional structured detail; must be JSON-safe. */\n\tdetails?: Readonly<Record<string, unknown>>;\n}\n\n/**\n * Thrown by surface layer functions on failure. `code` is the stable\n * machine-readable identifier; `details` carries structured context\n * (e.g. `validateSpec` errors, missing path name). Both fields round-trip\n * through `toJSON()` for wrappers that serialize errors over the wire.\n */\nexport class SurfaceError extends Error {\n\treadonly code: SurfaceErrorCode;\n\treadonly details?: Readonly<Record<string, unknown>>;\n\n\tconstructor(\n\t\tcode: SurfaceErrorCode,\n\t\tmessage: string,\n\t\tdetails?: Readonly<Record<string, unknown>>,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"SurfaceError\";\n\t\tthis.code = code;\n\t\tif (details !== undefined) this.details = details;\n\t}\n\n\t/**\n\t * JSON-safe payload for wire serialization. Defensively validates\n\t * `details` — if it can't be round-tripped through `JSON.stringify`\n\t * (cyclic refs, `BigInt`, `Error` instance not pre-toJSON'd), the\n\t * payload falls back to `{code, message}` only rather than crashing\n\t * the MCP/CLI wrapper when it serializes this error onto the wire.\n\t */\n\ttoJSON(): SurfaceErrorPayload {\n\t\tconst out: SurfaceErrorPayload = { code: this.code, message: this.message };\n\t\tif (this.details !== undefined) {\n\t\t\tconst safe = safeDetails(this.details);\n\t\t\tif (safe !== undefined) out.details = safe;\n\t\t}\n\t\treturn out;\n\t}\n}\n\nfunction safeDetails(\n\tdetails: Readonly<Record<string, unknown>>,\n): Readonly<Record<string, unknown>> | undefined {\n\ttry {\n\t\t// Round-trip through JSON to strip non-serializable values (functions,\n\t\t// undefined) and reject cyclic structures with a thrown TypeError. The\n\t\t// round-trip result is the canonical wire shape.\n\t\treturn JSON.parse(JSON.stringify(details)) as Readonly<Record<string, unknown>>;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** Wrap any thrown value as a SurfaceError. Idempotent on existing SurfaceError. */\nexport function asSurfaceError(\n\terr: unknown,\n\tfallbackCode: SurfaceErrorCode = \"internal-error\",\n): SurfaceError {\n\tif (err instanceof SurfaceError) return err;\n\tconst message = err instanceof Error ? err.message : String(err);\n\treturn new SurfaceError(fallbackCode, message);\n}\n","/**\n * Surface: create a graph from a {@link GraphSpec} (§9.3-core).\n *\n * Thin wrapper over {@link compileSpec} that converts the two failure modes\n * ({@link validateSpec} structural errors, and catalog-aware validation\n * errors) into typed {@link SurfaceError} throws. Consumers are MCP/CLI\n * wrappers, not end-user graph code — those should import `compileSpec`\n * directly.\n *\n * @module\n */\n\nimport type { Graph } from \"@graphrefly/pure-ts/graph\";\nimport type { CompileSpecOptions, GraphSpec } from \"../graphspec/index.js\";\nimport { compileSpec, validateSpec, validateSpecAgainstCatalog } from \"../graphspec/index.js\";\nimport { SurfaceError } from \"./errors.js\";\n\n/** Options for {@link createGraph}. Same shape as {@link CompileSpecOptions}. */\nexport type CreateGraphOptions = CompileSpecOptions;\n\n/**\n * Build a {@link Graph} from a parsed {@link GraphSpec} with surface-layer\n * error typing.\n *\n * @throws {SurfaceError} `invalid-spec` for structural errors;\n * `catalog-error` when fn/source names or config don't match the catalog.\n */\nexport function createGraph(spec: GraphSpec, opts?: CreateGraphOptions): Graph {\n\tconst structural = validateSpec(spec);\n\tif (!structural.valid) {\n\t\tthrow new SurfaceError(\n\t\t\t\"invalid-spec\",\n\t\t\t`GraphSpec validation failed:\\n${structural.errors.join(\"\\n\")}`,\n\t\t\t{ errors: structural.errors },\n\t\t);\n\t}\n\tconst catalog = opts?.catalog ?? {};\n\tconst catalogValidation = validateSpecAgainstCatalog(spec, catalog);\n\tif (!catalogValidation.valid) {\n\t\tthrow new SurfaceError(\n\t\t\t\"catalog-error\",\n\t\t\t`Catalog validation failed:\\n${catalogValidation.errors.join(\"\\n\")}`,\n\t\t\t{ errors: catalogValidation.errors },\n\t\t);\n\t}\n\ttry {\n\t\treturn compileSpec(spec, opts);\n\t} catch (err) {\n\t\t// compileSpec re-throws validation errors plus may throw on missing\n\t\t// catalog entries for template-inner deferred nodes. Surface as\n\t\t// catalog-error; callers can inspect the wrapped message.\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\tthrow new SurfaceError(\"catalog-error\", message);\n\t}\n}\n","/**\n * Surface: one-shot `input → pipeline → output` (§9.3-core).\n *\n * `runReduction` compiles a {@link GraphSpec}, pushes an input value to a\n * named state node, awaits the first post-push DATA emission on a named\n * output, then disposes the graph. Stateless per call — no graphId, no\n * registry.\n *\n * Named `runReduction` (not `reduce`) to avoid collision with the\n * reactive {@link reduce} operator in `extra/operators.ts`. The MCP tool\n * name (`graphrefly_reduce`) and CLI subcommand (`graphrefly reduce`) use\n * the short form; the library export carries the verb.\n *\n * The subscribe-before-push ordering is deliberate. `graph.set` propagates\n * synchronously for sync derived/operator chains; for async sources\n * (`fromPromise`, `fromAsyncIter`, LLM adapters) the first post-push DATA\n * arrives on a later tick. Subscribing before the push catches both, and\n * skipping the priming push-on-subscribe emission avoids resolving with the\n * stale pre-push cache (spec §2.2).\n *\n * @module\n */\n\nimport type { Node } from \"@graphrefly/pure-ts/core\";\nimport { COMPLETE, DATA, ERROR, RESOLVED } from \"@graphrefly/pure-ts/core\";\nimport type { GraphSpec, GraphSpecCatalog } from \"../graphspec/index.js\";\nimport { createGraph } from \"./create.js\";\nimport { SurfaceError } from \"./errors.js\";\n\n/** Options for {@link reduce}. */\nexport interface ReduceOptions {\n\t/** Fn/source catalog for {@link createGraph}. */\n\tcatalog?: GraphSpecCatalog;\n\t/** Path of the state node that receives the input. Default `\"input\"`. */\n\tinputPath?: string;\n\t/** Path of the node whose first post-push DATA is the result. Default `\"output\"`. */\n\toutputPath?: string;\n\t/** Hard deadline in milliseconds. Default `30_000`. */\n\ttimeoutMs?: number;\n}\n\nconst DEFAULT_TIMEOUT_MS = 30_000;\n\n/**\n * Run a spec as a one-shot reduction: `input → graph → output`.\n *\n * Resolves on the first `[DATA, v]` **or** `[RESOLVED]` emitted by\n * `outputPath` after the input push. The RESOLVED path handles spec\n * §1.3.3 equals-substitution (output recomputed to a value equal to its\n * cache, so the graph skips the DATA push) by returning `outputNode.cache`\n * — the caller always gets the settled value, never hangs on idempotent\n * inputs.\n *\n * @throws {SurfaceError} `invalid-spec` / `catalog-error` (propagated from\n * {@link createGraph}), `node-not-found` when `inputPath`/`outputPath`\n * can't be resolved, `reduce-timeout` when `timeoutMs` elapses without\n * a post-push emission, or the ERROR payload from the graph re-thrown\n * as `internal-error`.\n */\nexport async function runReduction(\n\tspec: GraphSpec,\n\tinput: unknown,\n\topts?: ReduceOptions,\n): Promise<unknown> {\n\tconst inputPath = opts?.inputPath ?? \"input\";\n\tconst outputPath = opts?.outputPath ?? \"output\";\n\tconst timeoutMs = opts?.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n\n\tconst graph = createGraph(spec, { catalog: opts?.catalog });\n\tlet outputNode: Node<unknown>;\n\ttry {\n\t\toutputNode = graph.resolve(outputPath);\n\t} catch {\n\t\tgraph.destroy();\n\t\tthrow new SurfaceError(\n\t\t\t\"node-not-found\",\n\t\t\t`reduce: output path \"${outputPath}\" is not registered`,\n\t\t\t{ path: outputPath },\n\t\t);\n\t}\n\t// Verify input path exists before we subscribe and push.\n\ttry {\n\t\tgraph.resolve(inputPath);\n\t} catch {\n\t\tgraph.destroy();\n\t\tthrow new SurfaceError(\n\t\t\t\"node-not-found\",\n\t\t\t`reduce: input path \"${inputPath}\" is not registered`,\n\t\t\t{ path: inputPath },\n\t\t);\n\t}\n\n\ttry {\n\t\treturn await new Promise<unknown>((resolve, reject) => {\n\t\t\tlet primed = false;\n\t\t\tlet settled = false;\n\t\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\t\tlet unsub: (() => void) | undefined;\n\t\t\t// Sync-settle deferred-unsubscribe invariant (C24-4):\n\t\t\t// `outputNode.subscribe(cb)` may invoke `cb` synchronously during\n\t\t\t// the call (push-on-subscribe per spec §2.2). If `cb` reaches\n\t\t\t// `finish()` BEFORE `subscribe()` returns, `unsub` is still\n\t\t\t// `undefined` and we'd leak the subscription if we tried `unsub?.()`\n\t\t\t// immediately. The contract: `finish()` toggles `shouldUnsub = true`;\n\t\t\t// the post-subscribe block (after `unsub` is assigned) checks that\n\t\t\t// flag and tears down. Two-phase ensures exactly one unsubscribe\n\t\t\t// regardless of whether settlement happened during or after the\n\t\t\t// subscribe call.\n\t\t\tlet shouldUnsub = false;\n\n\t\t\tconst finish = (action: () => void): void => {\n\t\t\t\tif (settled) return;\n\t\t\t\tsettled = true;\n\t\t\t\tif (timer !== undefined) clearTimeout(timer);\n\t\t\t\tif (unsub !== undefined) {\n\t\t\t\t\tunsub();\n\t\t\t\t\tunsub = undefined;\n\t\t\t\t} else {\n\t\t\t\t\tshouldUnsub = true;\n\t\t\t\t}\n\t\t\t\taction();\n\t\t\t};\n\n\t\t\tunsub = outputNode.subscribe((msgs) => {\n\t\t\t\tfor (const m of msgs) {\n\t\t\t\t\tif (settled) return;\n\t\t\t\t\t// Skip push-on-subscribe emissions that land before we\n\t\t\t\t\t// trigger the input push — those carry pre-push state.\n\t\t\t\t\tif (!primed) continue;\n\t\t\t\t\tif (m[0] === DATA) {\n\t\t\t\t\t\tfinish(() => resolve(m[1]));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (m[0] === RESOLVED) {\n\t\t\t\t\t\t// Spec §1.3.3 equals-substitution: the output recomputed to\n\t\t\t\t\t\t// a value equal to its cached value, so the graph emits\n\t\t\t\t\t\t// RESOLVED instead of DATA. For a one-shot reduce the\n\t\t\t\t\t\t// caller wants the output value — read the cache **before**\n\t\t\t\t\t\t// finish() runs unsub (which can trigger lazy deactivation\n\t\t\t\t\t\t// and clear the cache per the RAM-cache rule).\n\t\t\t\t\t\tconst cached = outputNode.cache;\n\t\t\t\t\t\tfinish(() => resolve(cached));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (m[0] === ERROR) {\n\t\t\t\t\t\tconst payload = m[1];\n\t\t\t\t\t\tconst message = payload instanceof Error ? payload.message : String(payload);\n\t\t\t\t\t\tconst cause = payload instanceof Error ? payload : undefined;\n\t\t\t\t\t\tfinish(() =>\n\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\tnew SurfaceError(\n\t\t\t\t\t\t\t\t\t\"internal-error\",\n\t\t\t\t\t\t\t\t\t`reduce: output emitted ERROR: ${message}`,\n\t\t\t\t\t\t\t\t\tcause != null ? { cause } : undefined,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (m[0] === COMPLETE) {\n\t\t\t\t\t\tfinish(() =>\n\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\tnew SurfaceError(\n\t\t\t\t\t\t\t\t\t\"internal-error\",\n\t\t\t\t\t\t\t\t\t`reduce: output COMPLETEd without a post-push DATA`,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\tif (shouldUnsub) {\n\t\t\t\tunsub?.();\n\t\t\t\tunsub = undefined;\n\t\t\t}\n\n\t\t\tprimed = true;\n\t\t\ttry {\n\t\t\t\tgraph.set(inputPath, input);\n\t\t\t} catch (err) {\n\t\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\t\tconst cause = err instanceof Error ? err : undefined;\n\t\t\t\tfinish(() =>\n\t\t\t\t\treject(\n\t\t\t\t\t\tnew SurfaceError(\n\t\t\t\t\t\t\t\"internal-error\",\n\t\t\t\t\t\t\t`reduce: failed to set input on \"${inputPath}\": ${message}`,\n\t\t\t\t\t\t\tcause != null ? { path: inputPath, cause } : { path: inputPath },\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Synchronous wave may have already settled the promise via the\n\t\t\t// subscribe callback above; skip the timer in that case so we\n\t\t\t// don't leak an orphan setTimeout into the event loop (A1, E4).\n\t\t\tif (!settled && Number.isFinite(timeoutMs) && timeoutMs > 0) {\n\t\t\t\ttimer = setTimeout(() => {\n\t\t\t\t\tfinish(() =>\n\t\t\t\t\t\treject(\n\t\t\t\t\t\t\tnew SurfaceError(\n\t\t\t\t\t\t\t\t\"reduce-timeout\",\n\t\t\t\t\t\t\t\t`reduce: no output emitted within ${timeoutMs}ms`,\n\t\t\t\t\t\t\t\t{ timeoutMs, outputPath },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}, timeoutMs);\n\t\t\t\t// Belt-and-suspenders: if the caller drops the returned promise\n\t\t\t\t// we shouldn't keep the process alive.\n\t\t\t\ttimer.unref?.();\n\t\t\t}\n\t\t});\n\t} finally {\n\t\tgraph.destroy();\n\t}\n}\n","/**\n * Surface: snapshot save/restore/diff/list over {@link KvStorageTier} (§9.3-core).\n *\n * One-shot snapshot management for stateless callers (MCP tools, CLI\n * commands) layered on the existing multi-tier auto-checkpoint substrate.\n * A saved snapshot is a `mode: \"full\"` {@link GraphCheckpointRecord} with\n * `seq: 0` — byte-identical to the baseline anchor\n * {@link Graph.attachSnapshotStorage} writes on its first flush. An\n * auto-checkpointed graph can therefore be restored through this surface,\n * and a surface-saved snapshot can be picked up by `attachSnapshotStorage({\n * autoRestore: true })`.\n *\n * The wire envelope stays at {@link SNAPSHOT_WIRE_VERSION}; no new format.\n *\n * @module\n */\n\nimport { wallClockNs } from \"@graphrefly/pure-ts/core\";\nimport type { KvStorageTier } from \"@graphrefly/pure-ts/extra\";\nimport type {\n\tGraphCheckpointRecord,\n\tGraphDiffResult,\n\tGraphNodeFactory,\n\tGraphPersistSnapshot,\n} from \"@graphrefly/pure-ts/graph\";\nimport { Graph, SNAPSHOT_VERSION } from \"@graphrefly/pure-ts/graph\";\nimport { SurfaceError } from \"./errors.js\";\n\n/**\n * Current envelope version. Re-exported from `graph.ts` so the one-shot\n * surface path and `Graph.attachSnapshotStorage` write byte-identical\n * `format_version` fields — no silent wire drift.\n */\nexport const SNAPSHOT_WIRE_VERSION = SNAPSHOT_VERSION;\n\n/** Shape returned by {@link saveSnapshot}. */\nexport interface SaveSnapshotResult {\n\tsnapshotId: string;\n\ttimestamp_ns: number;\n}\n\n/** Options for {@link restoreSnapshot}. */\nexport interface RestoreSnapshotOptions {\n\t/** Passthrough to `Graph.fromSnapshot`. First matching pattern wins. */\n\tfactories?: Record<string, GraphNodeFactory>;\n}\n\n/**\n * Key prefix applied to every surface-written snapshot record. Isolates\n * surface-saved snapshots from other keys on the same tier (notably\n * `attachSnapshotStorage` baseline/WAL keys written under `graph.name`).\n */\nexport const SNAPSHOT_KEY_PREFIX = \"snapshot:\";\n\n/**\n * Reject caller-supplied ids that start with {@link SNAPSHOT_KEY_PREFIX}.\n *\n * Surface ids are keyed in the caller's external namespace; the `\"snapshot:\"`\n * prefix is an implementation detail of tier layout. Allowing `\"snapshot:foo\"`\n * through would produce surprising round-trips — `deleteSnapshot(\"foo\")` and\n * `deleteSnapshot(\"snapshot:foo\")` would both target the same tier key, while\n * `listSnapshots()` decodes to `\"foo\"` — so we enforce disjointness at the API\n * boundary (pre-1.0, no back-compat).\n */\nfunction assertExternalId(snapshotId: string): void {\n\tif (snapshotId.startsWith(SNAPSHOT_KEY_PREFIX)) {\n\t\tthrow new SurfaceError(\n\t\t\t\"snapshot-failed\",\n\t\t\t`snapshot id must not start with \"${SNAPSHOT_KEY_PREFIX}\" (reserved); got \"${snapshotId}\"`,\n\t\t\t{ snapshotId },\n\t\t);\n\t}\n}\n\nfunction encodeKey(snapshotId: string): string {\n\treturn `${SNAPSHOT_KEY_PREFIX}${snapshotId}`;\n}\n\nfunction decodeKey(key: string): string | undefined {\n\treturn key.startsWith(SNAPSHOT_KEY_PREFIX) ? key.slice(SNAPSHOT_KEY_PREFIX.length) : undefined;\n}\n\nfunction unwrapCheckpoint(raw: unknown, snapshotId: string): GraphPersistSnapshot {\n\tif (raw == null || typeof raw !== \"object\") {\n\t\tthrow new SurfaceError(\"snapshot-not-found\", `snapshot \"${snapshotId}\" not found in tier`, {\n\t\t\tsnapshotId,\n\t\t});\n\t}\n\t// Accept both wrapped (GraphCheckpointRecord) and bare\n\t// (GraphPersistSnapshot) payloads — attachSnapshotStorage writes wrapped, a user\n\t// may also hand us a bare one via dictKv for tests.\n\tconst record = raw as Record<string, unknown>;\n\tif (\"mode\" in record) {\n\t\tif (record.mode === \"full\" && \"snapshot\" in record) {\n\t\t\treturn record.snapshot as GraphPersistSnapshot;\n\t\t}\n\t\tif (record.mode === \"diff\") {\n\t\t\tthrow new SurfaceError(\n\t\t\t\t\"restore-failed\",\n\t\t\t\t`snapshot \"${snapshotId}\" is a diff record (legacy/non-paired tier write); under the Phase 14.6 paired-tier shape snapshot tiers hold only baselines. For WAL replay use Graph.restoreSnapshot({ mode: \"diff\", source: { tier, walTier } }).`,\n\t\t\t\t{ snapshotId, mode: \"diff\" },\n\t\t\t);\n\t\t}\n\t\tthrow new SurfaceError(\n\t\t\t\"restore-failed\",\n\t\t\t`snapshot \"${snapshotId}\" has unknown mode \"${String(record.mode)}\"`,\n\t\t\t{ snapshotId, mode: String(record.mode) },\n\t\t);\n\t}\n\tif (\"nodes\" in record && \"edges\" in record && \"subgraphs\" in record && \"name\" in record) {\n\t\treturn record as unknown as GraphPersistSnapshot;\n\t}\n\tthrow new SurfaceError(\n\t\t\"restore-failed\",\n\t\t`snapshot \"${snapshotId}\" payload is not a GraphCheckpointRecord or GraphPersistSnapshot`,\n\t\t{ snapshotId },\n\t);\n}\n\n/**\n * Write a graph's current state as a one-shot `mode: \"full\"` record.\n *\n * Uses the same {@link GraphCheckpointRecord} envelope as\n * {@link Graph.attachSnapshotStorage} so the two persistence paths interoperate.\n *\n * @throws {SurfaceError} `snapshot-failed` when the tier's `save` throws.\n */\nexport async function saveSnapshot(\n\tgraph: Graph,\n\tsnapshotId: string,\n\ttier: KvStorageTier,\n): Promise<SaveSnapshotResult> {\n\tassertExternalId(snapshotId);\n\tlet snapshot: GraphPersistSnapshot;\n\ttry {\n\t\tsnapshot = graph.snapshot();\n\t} catch (err) {\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\tthrow new SurfaceError(\n\t\t\t\"snapshot-failed\",\n\t\t\t`snapshot \"${snapshotId}\" serialization failed: ${message}`,\n\t\t\t{ snapshotId },\n\t\t);\n\t}\n\tconst record: GraphCheckpointRecord = {\n\t\tname: graph.name,\n\t\tmode: \"full\",\n\t\tseq: 0,\n\t\ttimestamp_ns: wallClockNs(),\n\t\tformat_version: SNAPSHOT_WIRE_VERSION,\n\t\tsnapshot,\n\t};\n\ttry {\n\t\tawait tier.save(encodeKey(snapshotId), record);\n\t} catch (err) {\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\tthrow new SurfaceError(\"snapshot-failed\", `snapshot \"${snapshotId}\" save failed: ${message}`, {\n\t\t\tsnapshotId,\n\t\t});\n\t}\n\treturn { snapshotId, timestamp_ns: record.timestamp_ns };\n}\n\n/**\n * Load a snapshot from a tier and materialize it as a new {@link Graph}.\n *\n * Uses {@link Graph.fromSnapshot} to reconstruct topology; pass\n * `factories` when the graph includes non-state nodes that the default\n * hydrator can't rebuild on its own.\n *\n * **Requires a `mode: \"full\"` record.** Surface-written snapshots from\n * {@link saveSnapshot} always qualify. Records written by\n * {@link Graph.attachSnapshotStorage} with `compactEvery > 1` may be\n * `mode: \"diff\"` between compacts — those throw `restore-failed` until\n * the tier's next compact flush (or until Phase 8.7 WAL replay lands).\n * If you need interop during development, either call\n * {@link saveSnapshot} explicitly (always full) or configure\n * `attachSnapshotStorage({compactEvery: 1})`.\n *\n * @throws {SurfaceError} `snapshot-not-found` on miss; `restore-failed`\n * when the payload shape doesn't match, when the record is\n * `mode: \"diff\"`, or when `Graph.fromSnapshot` rejects.\n */\nexport async function restoreSnapshot(\n\tsnapshotId: string,\n\ttier: KvStorageTier,\n\topts?: RestoreSnapshotOptions,\n): Promise<Graph> {\n\tassertExternalId(snapshotId);\n\t// Try namespaced key first (surface-written records), fall back to raw key\n\t// so callers restoring snapshots that predate the namespacing change (or\n\t// bare `GraphPersistSnapshot` payloads written by user test fixtures)\n\t// still resolve. Once all writers are on encodeKey, the fallback can go.\n\tconst key = encodeKey(snapshotId);\n\tlet raw = await tier.load(key);\n\tif (raw === undefined) {\n\t\traw = await tier.load(snapshotId);\n\t}\n\tconst snapshot = unwrapCheckpoint(raw, snapshotId);\n\ttry {\n\t\treturn Graph.fromSnapshot(\n\t\t\tsnapshot,\n\t\t\topts?.factories ? { factories: opts.factories } : undefined,\n\t\t);\n\t} catch (err) {\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\tthrow new SurfaceError(\n\t\t\t\"restore-failed\",\n\t\t\t`snapshot \"${snapshotId}\" restore failed: ${message}`,\n\t\t\t{\n\t\t\t\tsnapshotId,\n\t\t\t},\n\t\t);\n\t}\n}\n\n/**\n * Load two snapshots and compute a {@link GraphDiffResult} via static\n * {@link Graph.diff}. Returns the audit shape (structural + value diff,\n * no payload); use {@link diffForWAL} directly for WAL-oriented diffs.\n *\n * @throws {SurfaceError} `snapshot-not-found` on either miss.\n */\nexport async function diffSnapshots(\n\tsnapshotIdA: string,\n\tsnapshotIdB: string,\n\ttier: KvStorageTier,\n): Promise<GraphDiffResult> {\n\tassertExternalId(snapshotIdA);\n\tassertExternalId(snapshotIdB);\n\tconst loadWithFallback = async (id: string): Promise<unknown> => {\n\t\tconst key = encodeKey(id);\n\t\tlet raw = await tier.load(key);\n\t\tif (raw === undefined) raw = await tier.load(id);\n\t\treturn raw;\n\t};\n\tconst [rawA, rawB] = await Promise.all([\n\t\tloadWithFallback(snapshotIdA),\n\t\tloadWithFallback(snapshotIdB),\n\t]);\n\tconst snapshotA = unwrapCheckpoint(rawA, snapshotIdA);\n\tconst snapshotB = unwrapCheckpoint(rawB, snapshotIdB);\n\treturn Graph.diff(snapshotA, snapshotB);\n}\n\n/**\n * Enumerate snapshot ids on a tier.\n *\n * Only keys written by {@link saveSnapshot} are returned. Surface-written\n * records are stored under the `\"snapshot:\"` key prefix and decoded back to\n * the caller-visible id before being returned — other keys on the same tier\n * (notably `attachSnapshotStorage` baseline/WAL keys written under `graph.name`) are\n * filtered out automatically. This lets a single tier back both the surface\n * and `attachSnapshotStorage` without leaking graph names through `listSnapshots`.\n *\n * @param tier — the storage tier to enumerate.\n * @param opts.includeUnprefixed — when `true`, also return keys that are\n * NOT under the namespacing prefix. Off by default; set this when reading\n * pre-namespacing snapshot sets.\n *\n * **Caveat:** when a tier is shared with {@link Graph.attachSnapshotStorage}, its\n * auto-checkpoint baseline + WAL keys (written under `graph.name`) are\n * unprefixed. Calling with `includeUnprefixed: true` returns those keys\n * alongside surface snapshots — and subsequent `restoreSnapshot` /\n * `deleteSnapshot` will operate on them via the fallback-lookup path,\n * potentially overwriting or deleting live auto-checkpoint state. Use\n * `includeUnprefixed` only against tiers you know are NOT shared with\n * `attachSnapshotStorage`, or follow up with a predicate filter to separate\n * ids you own from ones owned by other subsystems.\n *\n * @throws {SurfaceError} `tier-no-list` when the tier does not implement\n * the optional `list()` method. Check `typeof tier.list === \"function\"`\n * before calling if you want to branch on capability.\n */\nexport async function listSnapshots(\n\ttier: KvStorageTier,\n\topts?: { includeUnprefixed?: boolean },\n): Promise<readonly string[]> {\n\tif (typeof tier.list !== \"function\") {\n\t\tthrow new SurfaceError(\n\t\t\t\"tier-no-list\",\n\t\t\t\"KvStorageTier does not implement list(); wrap the tier with an enumerator or use a different backend\",\n\t\t);\n\t}\n\tconst keys = await tier.list();\n\tconst result: string[] = [];\n\tconst includeUnprefixed = opts?.includeUnprefixed === true;\n\tfor (const k of keys) {\n\t\tconst decoded = decodeKey(k);\n\t\tif (decoded !== undefined) result.push(decoded);\n\t\telse if (includeUnprefixed) result.push(k);\n\t}\n\treturn result;\n}\n\n/**\n * Delete a snapshot from a tier.\n *\n * Silent on miss (clear semantics). `tier.clear` is optional — throws\n * `snapshot-failed` when the tier is append-only.\n *\n * @throws {SurfaceError} `snapshot-failed` when `clear` is unsupported\n * or throws.\n */\nexport async function deleteSnapshot(snapshotId: string, tier: KvStorageTier): Promise<void> {\n\tassertExternalId(snapshotId);\n\tif (typeof tier.delete !== \"function\") {\n\t\tthrow new SurfaceError(\n\t\t\t\"snapshot-failed\",\n\t\t\t`KvStorageTier is append-only (no delete()); cannot delete \"${snapshotId}\"`,\n\t\t\t{ snapshotId },\n\t\t);\n\t}\n\ttry {\n\t\tawait tier.delete(encodeKey(snapshotId));\n\t} catch (err) {\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\tthrow new SurfaceError(\n\t\t\t\"snapshot-failed\",\n\t\t\t`snapshot \"${snapshotId}\" delete failed: ${message}`,\n\t\t\t{\n\t\t\t\tsnapshotId,\n\t\t\t},\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;;AA2CO,IAAM,eAAN,cAA2B,MAAM;AAAA,EAC9B;AAAA,EACA;AAAA,EAET,YACC,MACA,SACA,SACC;AACD,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,QAAI,YAAY,OAAW,MAAK,UAAU;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,SAA8B;AAC7B,UAAM,MAA2B,EAAE,MAAM,KAAK,MAAM,SAAS,KAAK,QAAQ;AAC1E,QAAI,KAAK,YAAY,QAAW;AAC/B,YAAM,OAAO,YAAY,KAAK,OAAO;AACrC,UAAI,SAAS,OAAW,KAAI,UAAU;AAAA,IACvC;AACA,WAAO;AAAA,EACR;AACD;AAEA,SAAS,YACR,SACgD;AAChD,MAAI;AAIH,WAAO,KAAK,MAAM,KAAK,UAAU,OAAO,CAAC;AAAA,EAC1C,QAAQ;AACP,WAAO;AAAA,EACR;AACD;AAGO,SAAS,eACf,KACA,eAAiC,kBAClB;AACf,MAAI,eAAe,aAAc,QAAO;AACxC,QAAM,UAA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/lens.ts
|
|
6
|
+
import { node } from "@graphrefly/pure-ts/core";
|
|
7
|
+
import { keepalive } from "@graphrefly/pure-ts/extra";
|
|
8
|
+
import {
|
|
9
|
+
reachable
|
|
10
|
+
} from "@graphrefly/pure-ts/graph";
|
|
11
|
+
import { watchTopologyTree } from "@graphrefly/pure-ts/graph";
|
|
12
|
+
function computeHealthReport(described) {
|
|
13
|
+
const problems = [];
|
|
14
|
+
for (const [path, desc] of Object.entries(described.nodes)) {
|
|
15
|
+
if (desc.status !== "errored") continue;
|
|
16
|
+
const entry = { path, status: "errored" };
|
|
17
|
+
const upstream = reachable(described, path, "upstream", {});
|
|
18
|
+
for (const p of upstream) {
|
|
19
|
+
if (p === path) continue;
|
|
20
|
+
if (described.nodes[p]?.status === "errored") {
|
|
21
|
+
entry.upstreamCause = p;
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
problems.push(entry);
|
|
26
|
+
}
|
|
27
|
+
problems.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
28
|
+
return { ok: problems.length === 0, problems };
|
|
29
|
+
}
|
|
30
|
+
function healthReportEqual(a, b) {
|
|
31
|
+
if (a.ok !== b.ok) return false;
|
|
32
|
+
if (a.problems.length !== b.problems.length) return false;
|
|
33
|
+
for (let i = 0; i < a.problems.length; i++) {
|
|
34
|
+
const x = a.problems[i];
|
|
35
|
+
const y = b.problems[i];
|
|
36
|
+
if (x.path !== y.path) return false;
|
|
37
|
+
if (x.status !== y.status) return false;
|
|
38
|
+
if (x.upstreamCause !== y.upstreamCause) return false;
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
function graphLens(target) {
|
|
43
|
+
const topologyHandle = target.describe({
|
|
44
|
+
reactive: true,
|
|
45
|
+
detail: "standard",
|
|
46
|
+
reactiveName: "graphLens.topology"
|
|
47
|
+
});
|
|
48
|
+
const topology = topologyHandle.node;
|
|
49
|
+
const health = node(
|
|
50
|
+
[topology],
|
|
51
|
+
(batchData, actions, ctx) => {
|
|
52
|
+
const data = batchData.map(
|
|
53
|
+
(batch, i) => batch != null && batch.length > 0 ? batch.at(-1) : ctx.prevData[i]
|
|
54
|
+
);
|
|
55
|
+
actions.emit(computeHealthReport(data[0]));
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "graphLens.health",
|
|
59
|
+
describeKind: "derived",
|
|
60
|
+
equals: healthReportEqual,
|
|
61
|
+
meta: domainMeta("lens", "health")
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
const stopHealthKeep = keepalive(health);
|
|
65
|
+
const flowMap = /* @__PURE__ */ new Map();
|
|
66
|
+
let lastAppliedFlush_ns = -1;
|
|
67
|
+
const dataFlow = target.observe({ reactive: true, tiers: ["data"] });
|
|
68
|
+
const flow = node(
|
|
69
|
+
[dataFlow, topology],
|
|
70
|
+
(batchData, actions, ctx) => {
|
|
71
|
+
const data = batchData.map(
|
|
72
|
+
(batch, i) => batch != null && batch.length > 0 ? batch.at(-1) : ctx.prevData[i]
|
|
73
|
+
);
|
|
74
|
+
const changeset = data[0];
|
|
75
|
+
const described = data[1];
|
|
76
|
+
const c = changeset;
|
|
77
|
+
const desc = described;
|
|
78
|
+
if (c != null && c.flushedAt_ns > lastAppliedFlush_ns) {
|
|
79
|
+
lastAppliedFlush_ns = c.flushedAt_ns;
|
|
80
|
+
for (const event of c.events) {
|
|
81
|
+
if (event.type !== "data") continue;
|
|
82
|
+
const path = event.path;
|
|
83
|
+
if (path == null || path === "") continue;
|
|
84
|
+
const prior = flowMap.get(path);
|
|
85
|
+
flowMap.set(path, {
|
|
86
|
+
path,
|
|
87
|
+
count: (prior?.count ?? 0) + 1,
|
|
88
|
+
lastUpdate_ns: c.flushedAt_ns
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (desc != null && flowMap.size > 0) {
|
|
93
|
+
const valid = new Set(Object.keys(desc.nodes));
|
|
94
|
+
for (const k of [...flowMap.keys()]) {
|
|
95
|
+
if (!valid.has(k)) flowMap.delete(k);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
actions.emit(new Map(flowMap));
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: "graphLens.flow",
|
|
102
|
+
describeKind: "derived",
|
|
103
|
+
meta: domainMeta("lens", "flow")
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
const stopFlowKeep = keepalive(flow);
|
|
107
|
+
let disposed = false;
|
|
108
|
+
return {
|
|
109
|
+
topology,
|
|
110
|
+
health,
|
|
111
|
+
flow,
|
|
112
|
+
dispose() {
|
|
113
|
+
if (disposed) return;
|
|
114
|
+
disposed = true;
|
|
115
|
+
stopFlowKeep();
|
|
116
|
+
stopHealthKeep();
|
|
117
|
+
topologyHandle.dispose();
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export {
|
|
123
|
+
computeHealthReport,
|
|
124
|
+
healthReportEqual,
|
|
125
|
+
graphLens,
|
|
126
|
+
watchTopologyTree
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=chunk-4XCHZRUJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/inspect/lens.ts"],"sourcesContent":["/**\n * Reactive graph observability preset (Tier 5.3 reshape — Session A.4 lock).\n *\n * `graphLens(target)` is a thin compositor (~30 LOC of glue) over two\n * already-shipped reactive primitives:\n *\n * - `target.describe({ reactive: true })` — live topology snapshot.\n * - `target.observe({ reactive: true, tiers: [\"data\"] })` — coalesced data\n * changesets per outermost batch flush.\n *\n * It returns three Nodes plus a dispose function:\n *\n * - `topology: Node<GraphDescribeOutput>` — the live describe snapshot,\n * re-emitting on every settle of the target tree (structural change,\n * error/complete/teardown transition).\n * - `health: Node<HealthReport>` — `{ok, problems[]}` aggregated from the\n * live describe; `ok=false` when any node enters `\"errored\"` status,\n * with `upstreamCause` walked backward through deps.\n * - `flow: Node<ReadonlyMap<string, FlowEntry>>` — per-path DATA counters\n * accumulating as `target.observe({reactive: true, tiers: [\"data\"]})`\n * delivers changesets. The map is reconciled against `topology` on each\n * topology change so removed nodes drop their entries.\n *\n * Pre-Tier-5.3 shipped a `LensGraph` class with `stats` / `health` / `flow`\n * (as a `ReactiveMapBundle`) / `why(from, to)` / `flowEntryNode(...)`. The\n * surface collapsed because every concern was already a one-liner over\n * `describe({reactive:true})` + `observe({reactive:true, tiers})` once those\n * landed in Tier 1.5.1 / 1.5.2 — the class added no protocol-level concept,\n * just glue. Callers who need topology stats compose a derived over\n * `topology` directly; callers who need a causal chain call\n * `target.describe({ explain: { from, to }, reactive: true })`.\n *\n * The transitive topology-subscription helper {@link watchTopologyTree} is\n * re-exported here for downstream factories that need full-tree dynamic\n * coverage without taking a dep on `graph/`.\n *\n * @module\n */\nimport { type Node, node } from \"@graphrefly/pure-ts/core\";\nimport { keepalive } from \"@graphrefly/pure-ts/extra\";\nimport {\n\ttype Graph,\n\ttype GraphDescribeOutput,\n\ttype ObserveChangeset,\n\ttype ObserveEvent,\n\treachable,\n} from \"@graphrefly/pure-ts/graph\";\nimport { domainMeta } from \"../../base/meta/domain-meta.js\";\n\nexport { watchTopologyTree } from \"@graphrefly/pure-ts/graph\";\n\n// ---------------------------------------------------------------------------\n// Payload types\n// ---------------------------------------------------------------------------\n\n/** A single health problem entry. */\nexport interface HealthProblem {\n\tpath: string;\n\t/** V1 only reports `\"errored\"`. Future versions may add `\"completed\"`, `\"disconnected\"`. */\n\tstatus: \"errored\";\n\t/** First errored upstream ancestor along the dep chain, when one exists and is distinct from `path`. */\n\tupstreamCause?: string;\n}\n\n/** Aggregate health snapshot. `ok=true` iff `problems.length === 0`. */\nexport interface HealthReport {\n\tok: boolean;\n\tproblems: readonly HealthProblem[];\n}\n\n/** Per-path flow entry stored in the {@link GraphLensView.flow} map. */\nexport interface FlowEntry {\n\tpath: string;\n\t/** Cumulative DATA emissions observed since the lens activated. */\n\tcount: number;\n\t/** Monotonic ns at the most recent DATA emission for this path, or `null` if none yet. */\n\tlastUpdate_ns: number | null;\n}\n\n/** Output of {@link graphLens}. */\nexport interface GraphLensView {\n\t/** Live describe snapshot. Re-emits on structural change AND status transitions. */\n\ttopology: Node<GraphDescribeOutput>;\n\t/** Live `{ok, problems[]}`. Aggregated from `topology`; equality-deduped. */\n\thealth: Node<HealthReport>;\n\t/** Per-path DATA counter map. Re-emits per outermost batch flush. */\n\tflow: Node<ReadonlyMap<string, FlowEntry>>;\n\t/**\n\t * Tear down the underlying `describe({reactive:true})` subscription.\n\t * The `flow` node activates lazily; subscribing-then-unsubscribing reclaims\n\t * its observe stream automatically. Call `dispose()` once when finished.\n\t */\n\tdispose(): void;\n}\n\n// ---------------------------------------------------------------------------\n// Pure helpers (exported for testing / composition)\n// ---------------------------------------------------------------------------\n\n/** Build a `HealthReport` from a fresh `GraphDescribeOutput`. */\nexport function computeHealthReport(described: GraphDescribeOutput): HealthReport {\n\tconst problems: HealthProblem[] = [];\n\tfor (const [path, desc] of Object.entries(described.nodes)) {\n\t\tif (desc.status !== \"errored\") continue;\n\t\tconst entry: HealthProblem = { path, status: \"errored\" };\n\t\t// Walk upstream to find the first errored ancestor (if any) distinct from `path`.\n\t\t// Explicit empty options disambiguates the overload (otherwise both match\n\t\t// and TS picks the `withDetail:true` signature first).\n\t\tconst upstream = reachable(described, path, \"upstream\", {});\n\t\tfor (const p of upstream) {\n\t\t\tif (p === path) continue;\n\t\t\tif (described.nodes[p]?.status === \"errored\") {\n\t\t\t\tentry.upstreamCause = p;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tproblems.push(entry);\n\t}\n\tproblems.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));\n\treturn { ok: problems.length === 0, problems };\n}\n\n/** Structural equality for {@link HealthReport} — used as the `health` derived's `equals`. */\nexport function healthReportEqual(a: HealthReport, b: HealthReport): boolean {\n\tif (a.ok !== b.ok) return false;\n\tif (a.problems.length !== b.problems.length) return false;\n\tfor (let i = 0; i < a.problems.length; i++) {\n\t\tconst x = a.problems[i]!;\n\t\tconst y = b.problems[i]!;\n\t\tif (x.path !== y.path) return false;\n\t\tif (x.status !== y.status) return false;\n\t\tif (x.upstreamCause !== y.upstreamCause) return false;\n\t}\n\treturn true;\n}\n\n// ---------------------------------------------------------------------------\n// graphLens preset\n// ---------------------------------------------------------------------------\n\n/**\n * Reactive observability preset over a target {@link Graph}.\n *\n * @param target - The graph to observe.\n *\n * @example\n * ```ts\n * const g = new Graph(\"app\");\n * g.add(state(0, { name: \"counter\" }), { name: \"counter\" });\n *\n * const lens = graphLens(g);\n * lens.topology.subscribe((msgs) => console.log(\"topology:\", msgs));\n * lens.health.subscribe((msgs) => console.log(\"health:\", msgs));\n * lens.flow.subscribe((msgs) => {\n * for (const [type, payload] of msgs) {\n * if (type === DATA) console.log(\"flow map size:\", (payload as ReadonlyMap<string, FlowEntry>).size);\n * }\n * });\n *\n * // Causal chains: use the underlying primitive directly — `graphLens` no\n * // longer wraps it, since `graph.describe({ explain: {...}, reactive: true })`\n * // already provides everything the old `lens.why()` did.\n * const why = g.describe({\n * explain: { from: \"counter\", to: \"consumer\" },\n * reactive: true,\n * });\n *\n * // Tear down when done.\n * lens.dispose();\n * ```\n *\n * @category observability\n */\nexport function graphLens(target: Graph): GraphLensView {\n\tconst topologyHandle = target.describe({\n\t\treactive: true,\n\t\tdetail: \"standard\",\n\t\treactiveName: \"graphLens.topology\",\n\t});\n\tconst topology = topologyHandle.node;\n\n\tconst health = node<HealthReport>(\n\t\t[topology],\n\t\t(batchData, actions, ctx) => {\n\t\t\tconst data = batchData.map((batch, i) =>\n\t\t\t\tbatch != null && batch.length > 0 ? batch.at(-1) : ctx.prevData[i],\n\t\t\t);\n\t\t\tactions.emit(computeHealthReport(data[0] as GraphDescribeOutput));\n\t\t},\n\t\t{\n\t\t\tname: \"graphLens.health\",\n\t\t\tdescribeKind: \"derived\",\n\t\t\tequals: healthReportEqual,\n\t\t\tmeta: domainMeta(\"lens\", \"health\"),\n\t\t},\n\t);\n\t// `topology` is already kept alive by `_describeReactive`'s internal\n\t// keepalive; `health` needs its own so the derived stays warm even if\n\t// the consumer subscribes lazily.\n\tconst stopHealthKeep = keepalive(health);\n\n\t// `flow` accumulates per-path counters across emissions. Closure-mirror\n\t// (COMPOSITION-GUIDE §28) holds the canonical map; the derived returns a\n\t// fresh ReadonlyMap projection per emit so consumers never observe an\n\t// in-place mutation. Topology drives reconciliation: paths that disappear\n\t// from the describe drop their counter entry.\n\t//\n\t// `lastAppliedFlush_ns` guards against double-applying the same changeset\n\t// when topology re-emits without a new dataFlow event (e.g. a node remove\n\t// re-fires `topology` while `dataFlow.cache` still holds the previous\n\t// changeset by reference). Using the monotonic `flushedAt_ns` cursor (qa\n\t// G2A — EC4 fix) is more robust than ref-comparison: an empty changeset\n\t// re-emitted with a fresh object identity but the same `flushedAt_ns`\n\t// won't trigger a stale-events replay, and a genuinely-new changeset\n\t// always advances the cursor.\n\tconst flowMap = new Map<string, FlowEntry>();\n\tlet lastAppliedFlush_ns = -1;\n\tconst dataFlow = target.observe({ reactive: true, tiers: [\"data\"] });\n\tconst flow = node<ReadonlyMap<string, FlowEntry>>(\n\t\t[dataFlow, topology],\n\t\t(batchData, actions, ctx) => {\n\t\t\tconst data = batchData.map((batch, i) =>\n\t\t\t\tbatch != null && batch.length > 0 ? batch.at(-1) : ctx.prevData[i],\n\t\t\t);\n\t\t\tconst changeset = data[0];\n\t\t\tconst described = data[1];\n\t\t\tconst c = changeset as ObserveChangeset | undefined;\n\t\t\tconst desc = described as GraphDescribeOutput | undefined;\n\n\t\t\t// Apply NEW changeset events first so a freshly-emitted node-remove\n\t\t\t// observed below cleanly drops the entry. (If we reconciled first\n\t\t\t// then applied, an event referencing a path the topology had already\n\t\t\t// dropped would re-create the entry only to be wiped on the next\n\t\t\t// topology re-emit — order events-then-topology to avoid that.)\n\t\t\t//\n\t\t\t// Skip when `events.length === 0`: an empty changeset has no work\n\t\t\t// to do. The cursor advances anyway so a future identical-content\n\t\t\t// changeset (different ref, same flushedAt_ns) is also skipped.\n\t\t\tif (c != null && c.flushedAt_ns > lastAppliedFlush_ns) {\n\t\t\t\tlastAppliedFlush_ns = c.flushedAt_ns;\n\t\t\t\tfor (const event of c.events as readonly ObserveEvent[]) {\n\t\t\t\t\tif (event.type !== \"data\") continue;\n\t\t\t\t\tconst path = event.path;\n\t\t\t\t\tif (path == null || path === \"\") continue;\n\t\t\t\t\tconst prior = flowMap.get(path);\n\t\t\t\t\tflowMap.set(path, {\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tcount: (prior?.count ?? 0) + 1,\n\t\t\t\t\t\tlastUpdate_ns: c.flushedAt_ns,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Reconcile against current topology — drop entries whose paths\n\t\t\t// no longer exist in the describe.\n\t\t\tif (desc != null && flowMap.size > 0) {\n\t\t\t\tconst valid = new Set(Object.keys(desc.nodes));\n\t\t\t\tfor (const k of [...flowMap.keys()]) {\n\t\t\t\t\tif (!valid.has(k)) flowMap.delete(k);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Snapshot — consumers receive a frozen view.\n\t\t\tactions.emit(new Map(flowMap) as ReadonlyMap<string, FlowEntry>);\n\t\t},\n\t\t{\n\t\t\tname: \"graphLens.flow\",\n\t\t\tdescribeKind: \"derived\",\n\t\t\tmeta: domainMeta(\"lens\", \"flow\"),\n\t\t},\n\t);\n\tconst stopFlowKeep = keepalive(flow);\n\n\tlet disposed = false;\n\treturn {\n\t\ttopology,\n\t\thealth,\n\t\tflow,\n\t\tdispose() {\n\t\t\tif (disposed) return;\n\t\t\tdisposed = true;\n\t\t\tstopFlowKeep();\n\t\t\tstopHealthKeep();\n\t\t\ttopologyHandle.dispose();\n\t\t},\n\t};\n}\n"],"mappings":";;;;;AAsCA,SAAoB,YAAY;AAChC,SAAS,iBAAiB;AAC1B;AAAA,EAK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