@graphrefly/graphrefly 0.44.0 → 0.45.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 +21 -17
- package/dist/compat/index.cjs +20 -10
- package/dist/compat/index.cjs.map +1 -0
- package/dist/compat/index.d.cts +1 -22
- package/dist/compat/index.d.ts +1 -22
- package/dist/compat/index.js +3 -1
- package/dist/compat/index.js.map +1 -0
- package/dist/compat/jotai/index.cjs +21 -1
- package/dist/compat/jotai/index.cjs.map +1 -0
- package/dist/compat/jotai/index.d.cts +1 -2
- package/dist/compat/jotai/index.d.ts +1 -2
- package/dist/compat/jotai/index.js +3 -1
- package/dist/compat/jotai/index.js.map +1 -0
- package/dist/compat/nanostores/index.cjs +21 -1
- package/dist/compat/nanostores/index.cjs.map +1 -0
- package/dist/compat/nanostores/index.d.cts +1 -2
- package/dist/compat/nanostores/index.d.ts +1 -2
- package/dist/compat/nanostores/index.js +3 -1
- package/dist/compat/nanostores/index.js.map +1 -0
- package/dist/compat/nestjs/index.cjs +20 -10
- package/dist/compat/nestjs/index.cjs.map +1 -0
- package/dist/compat/nestjs/index.d.cts +1 -13
- package/dist/compat/nestjs/index.d.ts +1 -13
- package/dist/compat/nestjs/index.js +3 -1
- package/dist/compat/nestjs/index.js.map +1 -0
- package/dist/compat/react/index.cjs +21 -1
- package/dist/compat/react/index.cjs.map +1 -0
- package/dist/compat/react/index.d.cts +1 -2
- package/dist/compat/react/index.d.ts +1 -2
- package/dist/compat/react/index.js +3 -1
- package/dist/compat/react/index.js.map +1 -0
- package/dist/compat/solid/index.cjs +21 -1
- package/dist/compat/solid/index.cjs.map +1 -0
- package/dist/compat/solid/index.d.cts +1 -2
- package/dist/compat/solid/index.d.ts +1 -2
- package/dist/compat/solid/index.js +3 -1
- package/dist/compat/solid/index.js.map +1 -0
- package/dist/compat/svelte/index.cjs +21 -1
- package/dist/compat/svelte/index.cjs.map +1 -0
- package/dist/compat/svelte/index.d.cts +1 -2
- package/dist/compat/svelte/index.d.ts +1 -2
- package/dist/compat/svelte/index.js +3 -1
- package/dist/compat/svelte/index.js.map +1 -0
- package/dist/compat/vue/index.cjs +21 -1
- package/dist/compat/vue/index.cjs.map +1 -0
- package/dist/compat/vue/index.d.cts +1 -3
- package/dist/compat/vue/index.d.ts +1 -3
- package/dist/compat/vue/index.js +3 -1
- package/dist/compat/vue/index.js.map +1 -0
- package/dist/compat/zustand/index.cjs +21 -3
- package/dist/compat/zustand/index.cjs.map +1 -0
- package/dist/compat/zustand/index.d.cts +1 -6
- package/dist/compat/zustand/index.d.ts +1 -6
- package/dist/compat/zustand/index.js +3 -1
- package/dist/compat/zustand/index.js.map +1 -0
- package/dist/core/index.cjs +21 -1
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +1 -3
- package/dist/core/index.d.ts +1 -3
- package/dist/core/index.js +3 -1
- package/dist/core/index.js.map +1 -0
- package/dist/extra/browser.cjs +21 -1
- package/dist/extra/browser.cjs.map +1 -0
- package/dist/extra/browser.d.cts +1 -4
- package/dist/extra/browser.d.ts +1 -4
- package/dist/extra/browser.js +3 -1
- package/dist/extra/browser.js.map +1 -0
- package/dist/extra/index.cjs +20 -19
- package/dist/extra/index.cjs.map +1 -0
- package/dist/extra/index.d.cts +1 -17
- package/dist/extra/index.d.ts +1 -17
- package/dist/extra/index.js +3 -1
- package/dist/extra/index.js.map +1 -0
- package/dist/extra/node.cjs +21 -2
- package/dist/extra/node.cjs.map +1 -0
- package/dist/extra/node.d.cts +1 -187
- package/dist/extra/node.d.ts +1 -187
- package/dist/extra/node.js +3 -2
- package/dist/extra/node.js.map +1 -0
- package/dist/extra/operators.cjs +21 -1
- package/dist/extra/operators.cjs.map +1 -0
- package/dist/extra/operators.d.cts +1 -958
- package/dist/extra/operators.d.ts +1 -958
- package/dist/extra/operators.js +3 -1
- package/dist/extra/operators.js.map +1 -0
- package/dist/extra/reactive.cjs +21 -1
- package/dist/extra/reactive.cjs.map +1 -0
- package/dist/extra/reactive.d.cts +1 -353
- package/dist/extra/reactive.d.ts +1 -353
- package/dist/extra/reactive.js +3 -1
- package/dist/extra/reactive.js.map +1 -0
- package/dist/extra/render/index.cjs +21 -5
- package/dist/extra/render/index.cjs.map +1 -0
- package/dist/extra/render/index.d.cts +1 -183
- package/dist/extra/render/index.d.ts +1 -183
- package/dist/extra/render/index.js +3 -1
- package/dist/extra/render/index.js.map +1 -0
- package/dist/extra/sources.cjs +21 -3
- package/dist/extra/sources.cjs.map +1 -0
- package/dist/extra/sources.d.cts +1 -584
- package/dist/extra/sources.d.ts +1 -584
- package/dist/extra/sources.js +3 -1
- package/dist/extra/sources.js.map +1 -0
- package/dist/extra/storage-browser.cjs +21 -1
- package/dist/extra/storage-browser.cjs.map +1 -0
- package/dist/extra/storage-browser.d.cts +1 -37
- package/dist/extra/storage-browser.d.ts +1 -37
- package/dist/extra/storage-browser.js +3 -1
- package/dist/extra/storage-browser.js.map +1 -0
- package/dist/extra/storage-core.cjs +21 -1
- package/dist/extra/storage-core.cjs.map +1 -0
- package/dist/extra/storage-core.d.cts +1 -28
- package/dist/extra/storage-core.d.ts +1 -28
- package/dist/extra/storage-core.js +3 -1
- package/dist/extra/storage-core.js.map +1 -0
- package/dist/extra/storage-node.cjs +20 -0
- package/dist/extra/storage-node.cjs.map +1 -0
- package/dist/extra/storage-node.d.cts +1 -2
- package/dist/extra/storage-node.d.ts +1 -2
- package/dist/extra/storage-node.js +3 -0
- package/dist/extra/storage-node.js.map +1 -0
- package/dist/extra/storage-tiers-browser.cjs +21 -1
- package/dist/extra/storage-tiers-browser.cjs.map +1 -0
- package/dist/extra/storage-tiers-browser.d.cts +1 -120
- package/dist/extra/storage-tiers-browser.d.ts +1 -120
- package/dist/extra/storage-tiers-browser.js +3 -1
- package/dist/extra/storage-tiers-browser.js.map +1 -0
- package/dist/extra/storage-tiers-node.cjs +21 -1
- package/dist/extra/storage-tiers-node.cjs.map +1 -0
- package/dist/extra/storage-tiers-node.d.cts +1 -210
- package/dist/extra/storage-tiers-node.d.ts +1 -210
- package/dist/extra/storage-tiers-node.js +3 -1
- package/dist/extra/storage-tiers-node.js.map +1 -0
- package/dist/extra/storage-tiers.cjs +21 -1
- package/dist/extra/storage-tiers.cjs.map +1 -0
- package/dist/extra/storage-tiers.d.cts +1 -412
- package/dist/extra/storage-tiers.d.ts +1 -412
- package/dist/extra/storage-tiers.js +3 -1
- package/dist/extra/storage-tiers.js.map +1 -0
- package/dist/extra/storage-wal.cjs +21 -0
- package/dist/extra/storage-wal.cjs.map +1 -0
- package/dist/extra/storage-wal.d.cts +1 -0
- package/dist/extra/storage-wal.d.ts +1 -0
- package/dist/extra/storage-wal.js +3 -0
- package/dist/extra/storage-wal.js.map +1 -0
- package/dist/graph/index.cjs +21 -7
- package/dist/graph/index.cjs.map +1 -0
- package/dist/graph/index.d.cts +1 -7
- package/dist/graph/index.d.ts +1 -7
- package/dist/graph/index.js +3 -1
- package/dist/graph/index.js.map +1 -0
- package/dist/index.cjs +20 -227
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +45 -95
- package/dist/index.d.ts +45 -95
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -0
- package/dist/patterns/ai/browser.cjs +20 -7
- package/dist/patterns/ai/browser.cjs.map +1 -0
- package/dist/patterns/ai/browser.d.cts +1 -127
- package/dist/patterns/ai/browser.d.ts +1 -127
- package/dist/patterns/ai/browser.js +3 -3
- package/dist/patterns/ai/browser.js.map +1 -0
- package/dist/patterns/ai/index.cjs +20 -73
- package/dist/patterns/ai/index.cjs.map +1 -0
- package/dist/patterns/ai/index.d.cts +1 -20
- package/dist/patterns/ai/index.d.ts +1 -20
- package/dist/patterns/ai/index.js +3 -1
- package/dist/patterns/ai/index.js.map +1 -0
- package/dist/patterns/ai/node.cjs +21 -1
- package/dist/patterns/ai/node.cjs.map +1 -0
- package/dist/patterns/ai/node.d.cts +1 -59
- package/dist/patterns/ai/node.d.ts +1 -59
- package/dist/patterns/ai/node.js +3 -1
- package/dist/patterns/ai/node.js.map +1 -0
- package/dist/patterns/cqrs/index.cjs +21 -3
- package/dist/patterns/cqrs/index.cjs.map +1 -0
- package/dist/patterns/cqrs/index.d.cts +1 -8
- package/dist/patterns/cqrs/index.d.ts +1 -8
- package/dist/patterns/cqrs/index.js +3 -1
- package/dist/patterns/cqrs/index.js.map +1 -0
- package/dist/patterns/demo-shell/index.cjs +21 -5
- package/dist/patterns/demo-shell/index.cjs.map +1 -0
- package/dist/patterns/demo-shell/index.d.cts +1 -7
- package/dist/patterns/demo-shell/index.d.ts +1 -7
- package/dist/patterns/demo-shell/index.js +3 -1
- package/dist/patterns/demo-shell/index.js.map +1 -0
- package/dist/patterns/domain-templates/index.cjs +21 -3
- package/dist/patterns/domain-templates/index.cjs.map +1 -0
- package/dist/patterns/domain-templates/index.d.cts +1 -6
- package/dist/patterns/domain-templates/index.d.ts +1 -6
- package/dist/patterns/domain-templates/index.js +3 -1
- package/dist/patterns/domain-templates/index.js.map +1 -0
- package/dist/patterns/graphspec/index.cjs +21 -86
- package/dist/patterns/graphspec/index.cjs.map +1 -0
- package/dist/patterns/graphspec/index.d.cts +1 -8
- package/dist/patterns/graphspec/index.d.ts +1 -8
- package/dist/patterns/graphspec/index.js +3 -1
- package/dist/patterns/graphspec/index.js.map +1 -0
- package/dist/patterns/harness/index.cjs +21 -48
- package/dist/patterns/harness/index.cjs.map +1 -0
- package/dist/patterns/harness/index.d.cts +1 -13
- package/dist/patterns/harness/index.d.ts +1 -13
- package/dist/patterns/harness/index.js +3 -1
- package/dist/patterns/harness/index.js.map +1 -0
- package/dist/patterns/inspect/index.cjs +21 -3
- package/dist/patterns/inspect/index.cjs.map +1 -0
- package/dist/patterns/inspect/index.d.cts +1 -9
- package/dist/patterns/inspect/index.d.ts +1 -9
- package/dist/patterns/inspect/index.js +3 -1
- package/dist/patterns/inspect/index.js.map +1 -0
- package/dist/patterns/job-queue/index.cjs +21 -3
- package/dist/patterns/job-queue/index.cjs.map +1 -0
- package/dist/patterns/job-queue/index.d.cts +1 -9
- package/dist/patterns/job-queue/index.d.ts +1 -9
- package/dist/patterns/job-queue/index.js +3 -1
- package/dist/patterns/job-queue/index.js.map +1 -0
- package/dist/patterns/memory/index.cjs +21 -3
- package/dist/patterns/memory/index.cjs.map +1 -0
- package/dist/patterns/memory/index.d.cts +1 -8
- package/dist/patterns/memory/index.d.ts +1 -8
- package/dist/patterns/memory/index.js +3 -1
- package/dist/patterns/memory/index.js.map +1 -0
- package/dist/patterns/messaging/index.cjs +21 -3
- package/dist/patterns/messaging/index.cjs.map +1 -0
- package/dist/patterns/messaging/index.d.cts +1 -7
- package/dist/patterns/messaging/index.d.ts +1 -7
- package/dist/patterns/messaging/index.js +3 -1
- package/dist/patterns/messaging/index.js.map +1 -0
- package/dist/patterns/orchestration/index.cjs +21 -3
- package/dist/patterns/orchestration/index.cjs.map +1 -0
- package/dist/patterns/orchestration/index.d.cts +1 -8
- package/dist/patterns/orchestration/index.d.ts +1 -8
- package/dist/patterns/orchestration/index.js +3 -1
- package/dist/patterns/orchestration/index.js.map +1 -0
- package/dist/patterns/process/index.cjs +21 -3
- package/dist/patterns/process/index.cjs.map +1 -0
- package/dist/patterns/process/index.d.cts +1 -10
- package/dist/patterns/process/index.d.ts +1 -10
- package/dist/patterns/process/index.js +3 -1
- package/dist/patterns/process/index.js.map +1 -0
- package/dist/patterns/reactive-layout/index.cjs +21 -4
- package/dist/patterns/reactive-layout/index.cjs.map +1 -0
- package/dist/patterns/reactive-layout/index.d.cts +1 -7
- package/dist/patterns/reactive-layout/index.d.ts +1 -7
- package/dist/patterns/reactive-layout/index.js +3 -1
- package/dist/patterns/reactive-layout/index.js.map +1 -0
- package/dist/patterns/reduction/index.cjs +21 -3
- package/dist/patterns/reduction/index.cjs.map +1 -0
- package/dist/patterns/reduction/index.d.cts +1 -6
- package/dist/patterns/reduction/index.d.ts +1 -6
- package/dist/patterns/reduction/index.js +3 -1
- package/dist/patterns/reduction/index.js.map +1 -0
- package/dist/patterns/surface/index.cjs +21 -13
- package/dist/patterns/surface/index.cjs.map +1 -0
- package/dist/patterns/surface/index.d.cts +1 -9
- package/dist/patterns/surface/index.d.ts +1 -9
- package/dist/patterns/surface/index.js +3 -1
- package/dist/patterns/surface/index.js.map +1 -0
- package/dist/patterns/topology-view/index.cjs +21 -0
- package/dist/patterns/topology-view/index.cjs.map +1 -0
- package/dist/patterns/topology-view/index.d.cts +1 -0
- package/dist/patterns/topology-view/index.d.ts +1 -0
- package/dist/patterns/topology-view/index.js +3 -0
- package/dist/patterns/topology-view/index.js.map +1 -0
- package/dist/testing/index.cjs +21 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +1 -0
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.js +3 -0
- package/dist/testing/index.js.map +1 -0
- package/package.json +608 -584
- package/dist/backoff-HPZMEZNF.js +0 -1
- package/dist/cascading-BglDkMdX.d.cts +0 -199
- package/dist/cascading-MFgxu7Yo.d.ts +0 -199
- package/dist/chunk-2T7U5EU6.js +0 -1
- package/dist/chunk-3G5U5QNE.js +0 -5
- package/dist/chunk-4VVTGLXJ.js +0 -1
- package/dist/chunk-5M4CCMMD.js +0 -45
- package/dist/chunk-5QDBSZBV.js +0 -1
- package/dist/chunk-5XJ6B66J.js +0 -1
- package/dist/chunk-6QZNQS5B.js +0 -1
- package/dist/chunk-6X7AFUJV.js +0 -9
- package/dist/chunk-7K6PWTDQ.js +0 -1
- package/dist/chunk-7LIAPXJB.js +0 -1
- package/dist/chunk-7WPU3UHQ.js +0 -1
- package/dist/chunk-A5WCQ5NO.js +0 -1
- package/dist/chunk-APPIWSGD.js +0 -84
- package/dist/chunk-BEZWM2SY.js +0 -1
- package/dist/chunk-C72GO4IZ.js +0 -1
- package/dist/chunk-CB676TKJ.js +0 -1
- package/dist/chunk-CE6TI2TL.js +0 -1
- package/dist/chunk-CE72X3WO.js +0 -1
- package/dist/chunk-CK2E7BTU.js +0 -1
- package/dist/chunk-CLVB32RD.js +0 -1
- package/dist/chunk-CRVT7D2P.js +0 -1
- package/dist/chunk-D5RFJOZ2.js +0 -1
- package/dist/chunk-D7GPHKFH.js +0 -1
- package/dist/chunk-DHRX7JX4.js +0 -2
- package/dist/chunk-ESMPEKEV.js +0 -1
- package/dist/chunk-F672GV32.js +0 -1
- package/dist/chunk-FZMYDOWV.js +0 -1
- package/dist/chunk-GHBWHMRZ.js +0 -1
- package/dist/chunk-GLERH466.js +0 -1
- package/dist/chunk-GPW2V3RE.js +0 -1
- package/dist/chunk-HIDYF36O.js +0 -1
- package/dist/chunk-HITNVN6B.js +0 -3
- package/dist/chunk-HY4DJBA7.js +0 -5
- package/dist/chunk-KZIEYVXN.js +0 -1
- package/dist/chunk-L6NSJVJZ.js +0 -1
- package/dist/chunk-N4MQX6JU.js +0 -18
- package/dist/chunk-N7FHEL4D.js +0 -1
- package/dist/chunk-NTEURFZH.js +0 -1
- package/dist/chunk-OIVP6KFV.js +0 -1
- package/dist/chunk-OPHBU3LG.js +0 -1
- package/dist/chunk-OYQOZP2F.js +0 -5
- package/dist/chunk-PTZK576G.js +0 -1
- package/dist/chunk-QYADASLV.js +0 -1
- package/dist/chunk-ST7UXLWR.js +0 -1
- package/dist/chunk-SVY7VUYU.js +0 -1
- package/dist/chunk-TK3NWWD4.js +0 -1
- package/dist/chunk-TSOYJ743.js +0 -1
- package/dist/chunk-UNGSTR4X.js +0 -61
- package/dist/chunk-VIMF6LGM.js +0 -1
- package/dist/chunk-VJLMUKOI.js +0 -1
- package/dist/chunk-VN6RDSK2.js +0 -1
- package/dist/chunk-VV4N5P64.js +0 -1
- package/dist/chunk-W3I423PS.js +0 -1
- package/dist/chunk-WJR24TAG.js +0 -1
- package/dist/chunk-XTGKMHSW.js +0 -1
- package/dist/chunk-YBB7ZGTY.js +0 -1
- package/dist/chunk-Z4NPUARF.js +0 -1
- package/dist/chunk-ZGNQRPDT.js +0 -1
- package/dist/chunk-ZKPSFFKU.js +0 -1
- package/dist/chunk-ZLV5SQSX.js +0 -1
- package/dist/content-addressed-storage-4-ST1tYk.d.cts +0 -124
- package/dist/content-addressed-storage-DuYMjV7o.d.ts +0 -124
- package/dist/decay-BvOWTZ00.d.ts +0 -112
- package/dist/decay-CFlLvXUT.d.cts +0 -112
- package/dist/fallback-74oxi34l.d.cts +0 -250
- package/dist/fallback-DUyyBTBK.d.ts +0 -250
- package/dist/graph-CWvEUQAq.d.cts +0 -1861
- package/dist/graph-D9LFnda9.d.ts +0 -1861
- package/dist/index-5k1T6jl0.d.cts +0 -121
- package/dist/index-9770hRuQ.d.cts +0 -779
- package/dist/index-B-_tFaqV.d.cts +0 -468
- package/dist/index-B17QddL1.d.cts +0 -374
- package/dist/index-B1F8Enjf.d.ts +0 -704
- package/dist/index-B5S8ULbU.d.ts +0 -515
- package/dist/index-B8YnZpIR.d.ts +0 -102
- package/dist/index-BHskSB8v.d.ts +0 -3413
- package/dist/index-BIYAkbAi.d.cts +0 -26
- package/dist/index-BQSKmbuG.d.cts +0 -127
- package/dist/index-BaQaY_IQ.d.cts +0 -231
- package/dist/index-BmZXHqkE.d.ts +0 -36
- package/dist/index-BoJ5JHxI.d.ts +0 -557
- package/dist/index-BocU7pqs.d.ts +0 -779
- package/dist/index-BrPrLl4e.d.cts +0 -86
- package/dist/index-BxNs2HB9.d.cts +0 -1858
- package/dist/index-Byu-OpX_.d.ts +0 -113
- package/dist/index-C1T3d7V-.d.cts +0 -704
- package/dist/index-C5ri2Axc.d.cts +0 -301
- package/dist/index-C5stwKcw.d.cts +0 -44
- package/dist/index-C9l6OEBL.d.ts +0 -26
- package/dist/index-CBBLl_rc.d.ts +0 -127
- package/dist/index-CBGUK09R.d.ts +0 -754
- package/dist/index-CC-AvFTy.d.cts +0 -557
- package/dist/index-CJF1URuX.d.ts +0 -121
- package/dist/index-CK29LV56.d.cts +0 -34
- package/dist/index-CMh5Rz1y.d.ts +0 -385
- package/dist/index-CPQlGA29.d.ts +0 -34
- package/dist/index-CR8QpwX8.d.ts +0 -2680
- package/dist/index-CS0LTlB8.d.cts +0 -385
- package/dist/index-CSOmP7xT.d.cts +0 -291
- package/dist/index-CYq8vAyV.d.ts +0 -291
- package/dist/index-CZ3r5Rxp.d.ts +0 -374
- package/dist/index-CasX6Pfq.d.cts +0 -358
- package/dist/index-CdAlHFEt.d.ts +0 -44
- package/dist/index-CdTelp1M.d.ts +0 -202
- package/dist/index-CeFiHtAg.d.ts +0 -468
- package/dist/index-Cj3WohTd.d.cts +0 -202
- package/dist/index-Climxqsu.d.cts +0 -754
- package/dist/index-Co7uli2l.d.cts +0 -3413
- package/dist/index-CviRnE4K.d.ts +0 -45
- package/dist/index-Cwv0KWcU.d.cts +0 -102
- package/dist/index-CzLVrjxn.d.ts +0 -231
- package/dist/index-D0aciIex.d.cts +0 -209
- package/dist/index-DHen9Klo.d.ts +0 -1858
- package/dist/index-DV_1YuVk.d.cts +0 -221
- package/dist/index-Dc4AYqrJ.d.cts +0 -515
- package/dist/index-Dgl1HpPn.d.ts +0 -86
- package/dist/index-DisjX8a-.d.ts +0 -221
- package/dist/index-UPSiS-X7.d.cts +0 -2680
- package/dist/index-Yq60JP3s.d.ts +0 -209
- package/dist/index-ZVQhLa2i.d.cts +0 -37
- package/dist/index-_6ODbuOu.d.cts +0 -45
- package/dist/index-hcDJ8PSI.d.cts +0 -36
- package/dist/index-nozs3fFC.d.ts +0 -301
- package/dist/index-p09KSrTN.d.ts +0 -358
- package/dist/index-sqkqlb1p.d.ts +0 -37
- package/dist/index-tRCxuAXF.d.cts +0 -113
- package/dist/node-kK3CvTrR.d.cts +0 -1347
- package/dist/node-kK3CvTrR.d.ts +0 -1347
- package/dist/observable-DWjNfLvC.d.ts +0 -36
- package/dist/observable-e3eiPPFy.d.cts +0 -36
- package/dist/pipeline-graph-CIKhynsF.d.cts +0 -142
- package/dist/pipeline-graph-Sgj0gCwn.d.ts +0 -142
- package/dist/reactive-layout-DOTs9P3X.d.ts +0 -183
- package/dist/reactive-layout-DgctbqZo.d.cts +0 -183
- package/dist/reactive-log-BKALbfal.d.ts +0 -223
- package/dist/reactive-log-DIGdYqQ6.d.cts +0 -223
- package/dist/reactive-map-CEFGp8TK.d.cts +0 -296
- package/dist/reactive-map-DS_SIAxv.d.ts +0 -296
- package/dist/resilience-6LYQJAC5.js +0 -1
- package/dist/sugar-DQjFmVqb.d.cts +0 -399
- package/dist/sugar-fhLIE7TT.d.ts +0 -399
- package/dist/topology-tree-Bcz27hpF.d.cts +0 -25
- package/dist/topology-tree-xvaD0fOX.d.ts +0 -25
- package/dist/types-C0_yquda.d.cts +0 -442
- package/dist/types-CWFysE9E.d.ts +0 -442
|
@@ -1,48 +1,21 @@
|
|
|
1
|
-
"use strict";var an=Object.defineProperty;var oo=Object.getOwnPropertyDescriptor;var so=Object.getOwnPropertyNames;var io=Object.prototype.hasOwnProperty;var J=(r,e)=>()=>(r&&(e=r(r=0)),e);var ao=(r,e)=>{for(var t in e)an(r,t,{get:e[t],enumerable:!0})},uo=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of so(e))!io.call(r,s)&&s!==t&&an(r,s,{get:()=>e[s],enumerable:!(n=oo(e,s))||n.enumerable});return r};var lo=r=>uo(an({},"__esModule",{value:!0}),r);var Ve,M,Z,Y,Re,De,je,pe,j,I,qe,Ot,Xn,At,Zn,er,St,un,dn,ln,Dt,Te=J(()=>{"use strict";Ve=Symbol.for("graphrefly/START"),M=Symbol.for("graphrefly/DATA"),Z=Symbol.for("graphrefly/DIRTY"),Y=Symbol.for("graphrefly/RESOLVED"),Re=Symbol.for("graphrefly/INVALIDATE"),De=Symbol.for("graphrefly/PAUSE"),je=Symbol.for("graphrefly/RESUME"),pe=Symbol.for("graphrefly/TEARDOWN"),j=Symbol.for("graphrefly/COMPLETE"),I=Symbol.for("graphrefly/ERROR"),qe=Object.freeze([Z]),Ot=Object.freeze([Y]),Xn=Object.freeze([Re]),At=Object.freeze([Ve]),Zn=Object.freeze([j]),er=Object.freeze([pe]),St=Object.freeze([qe]),un=Object.freeze([Ot]),dn=Object.freeze([Xn]),ln=Object.freeze([Zn]),Dt=Object.freeze([er])});function nr(r,e){let t=new TextEncoder().encode(r.name);if(t.length===0||t.length>255)throw new Error(`encodeEnvelope: codec name "${r.name}" encodes to ${t.length} bytes (must be 1\u2013255)`);let n=r.version;if(!Number.isInteger(n)||n<0||n>65535)throw new Error(`encodeEnvelope: codec.version ${n} out of u16 range (expected integer 0\u201365535)`);let s=2+t.length+2+e.length;if(s>4294967295)throw new Error(`encodeEnvelope: total envelope size ${s} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let o=new Uint8Array(s),i=0;return o[i++]=cn,o[i++]=t.length,o.set(t,i),i+=t.length,o[i++]=n>>>8&255,o[i++]=n&255,o.set(e,i),o}function rr(r,e){if(r.length<tr)throw new Error(`decodeEnvelope: bytes too short (${r.length} < ${tr})`);let t=0,n=r[t++];if(n!==cn)throw new Error(`decodeEnvelope: unsupported envelope version ${n} (expected ${cn})`);let s=r[t++];if(s===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(t+s+2>r.length)throw new Error(`decodeEnvelope: envelope truncated (need ${t+s+2} bytes, have ${r.length})`);let o=new TextDecoder().decode(r.subarray(t,t+s));t+=s;let i=(r[t]<<8|r[t+1])>>>0;t+=2;let a=r.subarray(t),u=e.lookupCodec(o);if(u==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:u,codecVersion:i,payload:a}}function or(r){r.registerCodec(co)}var co,cn,tr,fn=J(()=>{"use strict";co={name:"json",version:1,contentType:"application/json",encode(r){let e=JSON.stringify(r);return new TextEncoder().encode(e)},decode(r,e){let t=new TextDecoder().decode(r);return JSON.parse(t)}},cn=1,tr=4});function Ct(r){if(r==null)return Ze;let{type:e,id:t,...n}=r;return{type:e??"system",id:t??"",...n}}var Ze,Mt=J(()=>{"use strict";Ze={type:"system",id:""}});function gt(){return et>0||ht}function sr(){return et>0}function nt(r){et>0?mt.push(r):r()}function K(r){et+=1;let e=!1;try{r()}catch(t){throw e=!0,t}finally{if(et-=1,et===0)if(e){if(!ht){let t=mt.splice(0);for(let n of t)try{n()}catch{}Ke.length=0,Ue.length=0,tt.length=0}}else fo()}}function fo(){let r=!ht;r&&(ht=!0);let e=[],t=0;try{for(;Ke.length>0||Ue.length>0||tt.length>0||r&&mt.length>0;){if(r&&mt.length>0){let o=mt.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(t+=1,t>1e3)throw Ke.length=0,Ue.length=0,tt.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(Ke.length>0?Ke:Ue.length>0?Ue:tt).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{r&&(ht=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function bt(r,e,t){if(e.length===0)return;if(e.length===1){let d=t(e[0][0]);if(d<3||!gt()){r(e);return}(d>=5?tt:d===4?Ue:Ke).push(()=>r(e));return}let n=e.length,s=n,o=n,i=n,a=0;for(;a<n&&t(e[a][0])<3;)a++;for(s=a;a<n&&t(e[a][0])===3;)a++;for(o=a;a<n&&t(e[a][0])===4;)a++;i=a;let u=gt();if(s>0){let d=e.slice(0,s);r(d)}if(o>s){let d=e.slice(s,o);u?Ke.push(()=>r(d)):r(d)}if(i>o){let d=e.slice(o,i);u?Ue.push(()=>r(d)):r(d)}if(n>i){let d=e.slice(i,n);u?tt.push(()=>r(d)):r(d)}}var et,ht,Ke,Ue,tt,mt,Ce=J(()=>{"use strict";et=0,ht=!1,Ke=[],Ue=[],tt=[],mt=[]});function U(){return Math.trunc(performance.now()*1e6)}function Me(){return Date.now()*1e6}var Oe=J(()=>{"use strict"});function ir(r){r.registerMessageType(Ve,{tier:0,wireCrossing:!1}),r.registerMessageType(Z,{tier:1,wireCrossing:!1}),r.registerMessageType(Re,{tier:1,wireCrossing:!1,metaPassthrough:!1}),r.registerMessageType(De,{tier:2,wireCrossing:!1}),r.registerMessageType(je,{tier:2,wireCrossing:!1}),r.registerMessageType(M,{tier:3,wireCrossing:!0}),r.registerMessageType(Y,{tier:3,wireCrossing:!0}),r.registerMessageType(j,{tier:4,wireCrossing:!0,metaPassthrough:!1}),r.registerMessageType(I,{tier:4,wireCrossing:!0,metaPassthrough:!1}),r.registerMessageType(pe,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var It,ar=J(()=>{"use strict";Te();It=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_rigorRecorder;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=t=>{let n=this._messageTypes.get(t);return n!=null?n.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}get rigorRecorder(){return this._rigorRecorder}set rigorRecorder(e){this._rigorRecorder=e}registerMessageType(e,t){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:t.tier,wireCrossing:t.wireCrossing??t.tier>=3,metaPassthrough:t.metaPassthrough??!0}),this}messageTier(e){let t=this._messageTypes.get(e);return t!=null?t.tier:1}isWireCrossing(e){let t=this._messageTypes.get(e);return t!=null?t.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let t=this._messageTypes.get(e);return t!=null?t.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});function ur(r){return Array.isArray(r)?[...r]:[r]}function po(r,e){return r.has(e)||r.has("*")}function dr(r){let e=[];return r((s,o)=>{e.push({kind:"allow",actions:new Set(ur(s)),where:o?.where??(()=>!0)})},(s,o)=>{e.push({kind:"deny",actions:new Set(ur(s)),where:o?.where??(()=>!0)})}),(s,o)=>{let i=!1,a=!1;for(let u of e)po(u.actions,o)&&u.where(s)&&(u.kind==="deny"?i=!0:a=!0);return i?!1:a}}function pn(r){let e=ho.filter(t=>r({type:t,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(t=>t==="human"||t==="llm"||t==="system")?"both":e.length===1?e[0]:e.join("+")}var Ae,ho,rt=J(()=>{"use strict";Ae=class extends Error{actor;action;nodeName;constructor(e,t){super(t??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}};ho=["human","llm","wallet","system"]});function hn(r){if(r===void 0)return null;if(typeof r=="number"){if(!Number.isFinite(r))throw new TypeError(`Cannot hash non-finite number: ${r}`);if(Number.isInteger(r)&&!Number.isSafeInteger(r))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${r}. Cross-language cid parity is not guaranteed for unsafe integers.`);return r}if(typeof r=="string"||typeof r=="boolean"||r===null)return r;if(Array.isArray(r))return r.map(hn);if(typeof r=="object"&&r!==null){let e={};for(let t of Object.keys(r).sort())e[t]=hn(r[t]);return e}return null}function bo(r){let e=go.encode(r),t=e.length,n=t*8,s=t+9+63&-64,o=new Uint8Array(s);o.set(e),o[t]=128;let i=new DataView(o.buffer);i.setUint32(s-4,n>>>0,!1),i.setUint32(s-8,Math.floor(n/4294967296)>>>0,!1);let a=1779033703,u=3144134277,d=1013904242,l=2773480762,f=1359893119,c=2600822924,h=528734635,p=1541459225,g=new Uint32Array(64),m=(T,y)=>T>>>y|T<<32-y;for(let T=0;T<s;T+=64){for(let k=0;k<16;k++)g[k]=i.getUint32(T+k*4,!1);for(let k=16;k<64;k++){let C=g[k-15],H=g[k-2],z=m(C,7)^m(C,18)^C>>>3,fe=m(H,17)^m(H,19)^H>>>10;g[k]=g[k-16]+z+g[k-7]+fe>>>0}let y=a,_=u,w=d,N=l,b=f,x=c,E=h,A=p;for(let k=0;k<64;k++){let C=m(b,6)^m(b,11)^m(b,25),H=b&x^~b&E,z=A+C+H+mo[k]+g[k]>>>0,fe=m(y,2)^m(y,13)^m(y,22),ne=y&_^y&w^_&w,we=fe+ne>>>0;A=E,E=x,x=b,b=N+z>>>0,N=w,w=_,_=y,y=z+we>>>0}a=a+y>>>0,u=u+_>>>0,d=d+w>>>0,l=l+N>>>0,f=f+b>>>0,c=c+x>>>0,h=h+E>>>0,p=p+A>>>0}let v=T=>T.toString(16).padStart(8,"0");return v(a)+v(u)+v(d)+v(l)+v(f)+v(c)+v(h)+v(p)}function mn(r){let e=hn(r??null),t=JSON.stringify(e);return bo(t).slice(0,16)}function yo(){let r=globalThis.crypto;if(r?.randomUUID)return r.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),t=e()+e()+e()+e();return`${t.slice(0,8)}-${t.slice(8,12)}-4${t.slice(13,16)}-${(parseInt(t.slice(16,17),16)&3|8).toString(16)}${t.slice(17,20)}-${t.slice(20,32)}`}function gn(r,e,t){let n=t?.id??yo();if(r===0)return{id:n,version:0};let o=(t?.hash??mn)(e);return{id:n,version:0,cid:o,prev:null}}function lr(r,e,t){r.version+=1,"cid"in r&&(r.prev=r.cid,r.cid=t(e))}var mo,go,cr=J(()=>{"use strict";mo=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),go=new TextEncoder});function hr(r){return{node:r,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function bn(r){r.prevData=void 0,r.dirty=!1,r.involvedThisWave=!1,r.dataBatch.length=0,r.terminal=void 0}function Gt(r){return r.length===0?r:typeof r[0]=="symbol"?[r]:r}function te(r,e,t){let n=mr(r)?r:[],s=typeof r=="function"?r:typeof e=="function"?e:void 0,o={};return mr(r)?o=(yn(e)?e:t)??{}:yn(r)?o=r:o=(yn(e)?e:t)??{},new de(n,s,o)}var fr,pr,vo,To,ot,de,mr,yn,Ie=J(()=>{"use strict";fn();Mt();Ce();Oe();ar();rt();Te();cr();fr=()=>{},pr=100;vo=(r,e,t,n)=>{t.direction==="down-in"&&r._onDepMessage(t.depIndex,e)},To=(r,e,t,n)=>{let s=r;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[At]:[At,[M,o]];s._status==="dirty"&&i.push(qe),bt(e,i,s._config.tierOf)},ot=new It({onMessage:vo,onSubscribe:To});ir(ot);or(ot);de=class r{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,t,n){this._config=n.config??ot,this._config.onMessage,this._optsName=n.name,this._describeKind=n.describeKind,this._equals=n.equals??Object.is,this._resubscribable=n.resubscribable??!1,this._resetOnTeardown=n.resetOnTeardown??!1,this._autoComplete=n.completeWhenDepsComplete??!0,this._autoError=n.errorWhenDepsError??!0,this._pausable=n.pausable??!0,this._guard=n.guard,this._fn=t,this._partial=n.partial??!1,this._cached=n.initial!==void 0?n.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=n.versioningHash??this._config.defaultHashFn??mn;let s=n.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?gn(s,this._cached===void 0?void 0:this._cached,{id:n.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(hr);let o={};for(let[a,u]of Object.entries(n.meta??{})){let d={initial:u,name:`${n.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};n.guard!=null&&(d.guard=n.guard),n.resubscribable===!0&&(d.resubscribable=!0),o[a]=new r([],void 0,d)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let i=this;this._actions={emit(a){i._emit([[M,a]])},down(a){i._emit(Gt(a))},up(a){i._emitUp(Gt(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,t){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let n=this._versioningLevel;if(n!=null&&e<=n)return;let s=t?.hash??this._hashFn;s!==this._hashFn&&(this._hashFn=s);let o=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??t?.id,u=i?.version??0,d=gn(e,o,{id:a,hash:s});d.version=u,this._versioning=d,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let t=Ct(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let n of this._extraGuards)if(!n(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,n=e?.actor!=null;if(!t&&!n)return;let s=Ct(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new Ae({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new Ae({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:Me()}}down(e,t){let n=Gt(e);n.length!==0&&(this._checkGuard(t),this._emit(n))}emit(e,t){this._checkGuard(t),this._emit([[M,e]])}up(e,t){if(this._deps.length===0)return;let n=Gt(e);if(n.length===0)return;this._checkGuard(t);let s=t??{internal:!0};this._validateUpTiers(n);for(let o of this._deps)o.node.up?.(n,s)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let t of this._deps)t.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let t=this._config.tierOf;for(let n of e){let s=t(n[0]);if(s===3||s===4)throw new Error(`Node "${this.name}": tier-${s} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let u=Ct(t);if(!this._guard(u,"observe"))throw new Ae({actor:u,action:"observe",nodeName:this.name})}let s=this._isTerminal&&this._resubscribable;if(s){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let u of this._deps)bn(u);if(this._partial===!1){for(let u of this._deps)if(u.prevData!==void 0||u.dataBatch.length!==0||u.terminal!==void 0||u.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let o;try{o=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:s},this._actions)}catch(u){throw this._sinkCount-=1,u}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(u){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof o=="function")try{o()}catch{}throw u}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof o=="function"&&o(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[t]=this._sinks;this._sinks=t}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,t=0;try{for(let n=0;n<e;n++){let s=n,o=this._deps[n];o.unsub=fr,o.unsub=o.node.subscribe(i=>{if(o.unsub===null)return;let a=this._config.tierOf,u=!1;for(let d of i)a(d[0])>=3&&(u=!0),this._config.onMessage(this,d,{direction:"down-in",depIndex:s},this._actions);u&&this._maybeRunFnOnSettlement()}),t++}}catch(n){this._deps[t].unsub=null;for(let s=0;s<t;s++){let o=this._deps[s];if(o.unsub!=null){let i=o.unsub;o.unsub=null;try{i()}catch{}bn(o)}}throw this._dirtyDepCount=0,n}}_addDep(e){for(let s=0;s<this._deps.length;s++)if(this._deps[s].node===e)return s;let t=this._deps.length,n=hr(e);if(this._deps.push(n),this._sinks==null)return t;n.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(St),n.unsub=fr;try{n.unsub=e.subscribe(s=>{if(n.unsub===null)return;let o=this._config.tierOf,i=!1;for(let a of s)o(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:t},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(s){throw n.unsub=null,this._deps.pop(),this._dirtyDepCount--,s}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(n){this._emit([[I,this._wrapFnError("cleanup threw",n)]])}else if(t!=null&&typeof t=="object"){let n=t.deactivate;if(typeof n=="function")try{n()}catch(s){this._emit([[I,this._wrapFnError("cleanup.deactivate threw",s)]])}}for(let n of this._deps){if(n.unsub!=null){let s=n.unsub;n.unsub=null;try{s()}catch{}}bn(n)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,t){let n=this._deps[e],s=t[0];if(this._inspectorHooks!=null){let o={kind:"dep_message",depIndex:e,message:t};for(let i of this._inspectorHooks)i(o)}if(s!==Ve){if(s===Z){this._depDirtied(n);return}if(s===Re){if(this._depInvalidated(n),this._cached===void 0)return;this._emit(dn);return}if(s===De||s===je){this._emit([t]);return}if(s===pe){this._emit(Dt);return}if(s===M)this._depSettledAsData(n,t[1]);else if(s===Y)this._depSettledAsResolved(n);else if(s===j)this._depSettledAsTerminal(n,!0);else if(s===I)this._depSettledAsTerminal(n,t[1]);else{this._emit([t]);return}if(!this._fn){(s===M||s===Y)&&this._emit([t]),(s===j||s===I)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(St))}_depSettledAsData(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(t),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=t,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let t=this._deps[e];if(t.dataBatch.length===0&&t.prevData===void 0&&t.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(un),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(t=>t.terminal!==void 0&&t.terminal!==!0);if(e!=null){this._autoError&&this._emit([[I,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(ln)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[I,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(a){this._emit([[I,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let t=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),n=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=t[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let s=this._deps.map(i=>i.terminal),o={prevData:n,terminalDeps:s,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:t,prevData:n};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(t,this._actions,o);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[I,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>pr?(this._rerunDepth=0,this._emit([[I,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${pr} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,t){let n=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${n}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[qe,e[0]]:e;let n=!0,s=!1,o=!1,i=-1;for(let u of e){let d=t(u[0]);d<i&&(n=!1),d===3&&(s=!0),u[0]===Z&&(o=!0),i=d}let a=e;if(!n){let u=e.map((d,l)=>({m:d,i:l,tier:t(d[0])}));u.sort((d,l)=>d.tier-l.tier||d.i-l.i),a=u.map(d=>d.m)}if(s&&!o&&this._status!=="dirty"){let u=0;for(;u<a.length&&t(a[u][0])===0;)u++;return u===0?[qe,...a]:[...a.slice(0,u),qe,...a.slice(u)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let u=e[a];if(u[0]===I&&u[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let t=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(u=>u[0]===pe||u[0]===Re);if(a.length===0)return;t=a}t=this._frameBatch(t);let s=null;for(let a=0;a<t.length;a++){let u=t[a],d=u[0];if(d!==De&&d!==je){s?.push(u);continue}if(u.length<2)throw new Error(`Node "${this.name}": [[${d===De?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let l=!0;if(this._pausable!==!1){let f=u[1];if(d===De)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(f),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(f))l=!1;else if(this._pauseLocks.delete(f),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let c=this._pauseBuffer;this._pauseBuffer=[],this._emit(c)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}l?s?.push(u):s==null&&(s=t.slice(0,a))}if(s!=null){if(s.length===0)return;t=s}if(this._hasMeta&&t.some(a=>a[0]===pe))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(Dt)}catch{}let{finalMessages:o,equalsError:i}=this._updateState(t);if(o.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:o})}catch{}}if(o.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,u=[];for(let d of o)a(d[0])===3?this._pauseBuffer.push(d):u.push(d);u.length>0&&this._dispatchOrAccumulate(u)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[I,i]])}_updateState(e){let t=this._config.tierOf,n,s,o=-1,i=0;for(let l of e)t(l[0])===3&&i++;let a=i<=1,u=-1;if(this._versioning!=null&&i>1){for(let l=e.length-1;l>=0;l--)if(e[l][0]===M){u=l;break}}for(let l=0;l<e.length;l++){let f=e[l],c=f[0];if(c===M){if(f.length>=2){let h=!1;if(a&&this._cached!==void 0)try{h=this._equals(this._cached,f[1])}catch(p){s=this._wrapFnError("equals threw",p),o=l;break}if(h){n==null&&(n=e.slice(0,l)),n.push(Ot),this._status="resolved";continue}this._cached=f[1],this._versioning!=null&&(u<0||l===u)&&lr(this._versioning,f[1],this._hashFn)}this._status="settled",n?.push(f)}else if(n?.push(f),c===Z)this._status="dirty";else if(c===Y)this._status="resolved";else if(c===j){this._status="completed";{let h=this._config.rigorRecorder;if(h!=null)try{h.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(c===I){this._status="errored";{let h=this._config.rigorRecorder;if(h!=null)try{h.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(c===Re){if(this._cached!==void 0){let p=this._config.rigorRecorder;if(p!=null)try{p.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let h=this._cleanup;if(typeof h=="function"){this._cleanup=void 0;try{h()}catch{}}else if(h!=null&&typeof h=="object"){let p=h.invalidate;if(typeof p=="function")try{p()}catch{}}}else c===pe&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let d=o>=0?n??e.slice(0,o):n??e;return s!=null?{finalMessages:d,equalsError:s}:{finalMessages:d}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let n of t)n(e)};_dispatchOrAccumulate(e){if(sr()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],nt(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}bt(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let t=this._frameBatch(e);bt(this._deliverToSinks,t,this._config.tierOf)}},mr=r=>Array.isArray(r),yn=r=>typeof r=="object"&&r!=null&&!Array.isArray(r)});function V(r,e){return te([],{...e,initial:r})}function he(r,e){return te((n,s,o)=>r(s,o)??void 0,{describeKind:"producer",...e})}function G(r,e,t){return te(r,(s,o,i)=>{let a=s.map((u,d)=>u!=null&&u.length>0?u.at(-1):i.prevData[d]);o.emit(e(a,i))},{describeKind:"derived",...t})}function le(r,e,t){return te(r,(s,o,i)=>{let a=s.map((u,d)=>u!=null&&u.length>0?u.at(-1):i.prevData[d]);return e(a,o,i)??void 0},{describeKind:"effect",...t})}var oe=J(()=>{"use strict";Ie()});function vn(r){return{describeKind:"producer",...r}}function gr(r,e){return he(t=>{let n=!1;try{for(let s of r){if(n)return;t.emit(s)}n||t.down([[j]])}catch(s){n||t.down([[I,s]])}return()=>{n=!0}},vn(e))}function _o(r){return r!=null&&typeof r.then=="function"}function wo(r,e){let{signal:t,...n}=e??{};return he(s=>{let o=!1,i=()=>{o||(o=!0,s.down([[I,t.reason]]))};if(t?.aborted){i();return}return t?.addEventListener("abort",i,{once:!0}),Promise.resolve(r).then(a=>{o||(o=!0,t?.removeEventListener("abort",i),s.emit(a),s.down([[j]]))},a=>{o||(o=!0,t?.removeEventListener("abort",i),s.down([[I,a]]))}),()=>{o=!0,t?.removeEventListener("abort",i)}},vn(n))}function xo(r,e){let{signal:t,...n}=e??{};return he(s=>{let o=new AbortController,i=()=>o.abort(t?.reason);t?.aborted?o.abort(t.reason):t?.addEventListener("abort",i,{once:!0});let a=t??o.signal,u=!1,d=r[Symbol.asyncIterator](),l=()=>{u||a.aborted||Promise.resolve(d.next()).then(f=>{if(!(u||a.aborted)){if(f.done){s.down([[j]]);return}s.emit(f.value),l()}},f=>{!u&&!a.aborted&&s.down([[I,f]])})};return l(),()=>{u=!0,t?.removeEventListener("abort",i),o.abort(),Promise.resolve(d.return?.()).catch(()=>{})}},vn(n))}function No(r){return r!=null&&typeof r=="object"&&"cache"in r&&typeof r.subscribe=="function"}function Ee(r,e){if(No(r))return r;if(_o(r))return wo(r,e);if(r!=null){let t=r;if(typeof t[Symbol.asyncIterator]=="function")return xo(r,e);if(typeof t[Symbol.iterator]=="function")return gr(r,e)}return Eo(r)}function Eo(...r){return gr(r,void 0)}function br(r,e){let t=new AbortController,n=e?.reason??new Error("cancelled via nodeSignal"),s,o=!1,i=()=>{s?(s(),s=void 0):o=!0};return s=r.subscribe(a=>{if(!t.signal.aborted)for(let u of a){if(u[0]===M&&u[1]===!0){t.abort(n),i();return}if(u[0]===I){t.abort(u[1]),i();return}if(u[0]===j){i();return}}}),o&&(s?.(),s=void 0),{signal:t.signal,dispose:()=>{s&&(s(),s=void 0)}}}function me(r){return r.subscribe(()=>{})}var yr=J(()=>{"use strict";Te();oe()});var Pe=J(()=>{"use strict";yr()});function Pt(r,e){if(e!=null&&e.length>0)return new Set(e);switch(r){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;case"spec":return new Set(["type","deps","meta","value"]);default:return new Set(["type","deps"])}}function Co(r){return r._describeKind!=null?r._describeKind:r._deps.length>0?"derived":r._fn!=null?"producer":"state"}function We(r){let e=new WeakSet,t={};for(let[n,s]of Tr(r))t[n]=Tn(s,e);return t}function Tn(r,e){if(r==null)return r;let t=typeof r;if(t==="boolean"||t==="number"||t==="string")return r;if(t==="function")return"<function>";if(Array.isArray(r))return e.has(r)?"<cycle>":(e.add(r),r.map(n=>Tn(n,e)));if(t==="object"){let n=r;if(e.has(n))return"<cycle>";e.add(n);try{if(typeof n.subscribe=="function"&&"cache"in n)return"<Node>"}catch{return"<unserializable>"}let s={};for(let[o,i]of Tr(n))s[o]=Tn(i,e);return s}return"<unserializable>"}function Tr(r){let e=[],t;try{t=Object.keys(r)}catch{return e}for(let n of t)try{e.push([n,r[n]])}catch{e.push([n,"<unserializable>"])}return e}function Je(r,e){let t={factory:r};return e!==void 0&&(t.factoryArgs=e),t}function Mo(r){let e={};for(let[t,n]of Object.entries(r.meta))try{e[t]=n.cache}catch{}return e}function _n(r,e,t){let n=e==null,s=!n&&e!=null?[...e].filter(l=>l.startsWith("meta.")).map(l=>l.slice(5)):null,o=n||e.has("meta")||s!=null&&s.length>0,i="state",a=[];r instanceof de&&(i=Co(r),a=r._deps.map(l=>l.node.name??""));let u={type:i,deps:a};(n||e.has("status"))&&(u.status=r.status);let d=r instanceof de?r._guard:void 0;if(o){let l={...Mo(r)};if(d!=null&&l.access===void 0&&(l.access=pn(d)),s!=null&&s.length>0&&!e.has("meta")){let f={};for(let c of s)c in l&&(f[c]=l[c]);u.meta=f}else u.meta=l}if(r.name!=null&&(u.name=r.name),(n||e.has("value"))&&(!t||i==="state")){r.status==="sentinel"&&(u.sentinel=!0);try{u.value=r.cache}catch{}}if((n||e.has("v"))&&r.v!=null){let l={id:r.v.id,version:r.v.version};"cid"in r.v&&(l.cid=r.v.cid,l.prev=r.v.prev),u.v=l}return(n||e.has("guard"))&&d!=null&&(u.guard=pn(d)),(n||e.has("lastMutation"))&&r.lastMutation!=null&&(u.lastMutation=r.lastMutation),u}var st=J(()=>{"use strict";rt();Ie()});function Lt(r){return{describeKind:"derived",...r}}function Io(r){return{describeKind:"derived",partial:!0,...r}}function Ft(r,e,t){return te([r],(n,s)=>{let o=n[0];if(o==null||o.length===0){s.down([[Y]]);return}let i=!1;for(let a of o)e(a)&&(s.emit(a),i=!0);i||s.down([[Y]])},{...Lt(t),meta:{...Je("filter"),...t?.meta??{}}})}function wn(r,e,t){return te([r,e],(n,s,o)=>{let i=n[0],a=n[1],u=a!=null&&a.length>0?a.at(-1):o.prevData[1];if(i!=null&&i.length>0){if(!(a!=null&&a.length>0)&&o.prevData[1]===void 0){s.down([[Y]]);return}for(let d of i)s.emit([d,u])}else s.down([[Y]])},{...Io(t),meta:{...Je("withLatestFrom"),...t?.meta??{}}})}function _r(...r){return r.length===0?he(e=>{e.down([[j]])},{...Lt(),meta:{...Je("merge")}}):he(e=>{let t=r.length,n=0,s=[];for(let o of r){let i=o.subscribe(a=>{for(let u of a)u[0]===M?e.emit(u[1]):u[0]===j?(n+=1,n>=t&&e.down([[j]])):u[0]===I&&e.down([u])});s.push(i)}return()=>{for(let o of s)o()}},{...Lt(),meta:{...Je("merge")}})}function Go(r,e,t){let n,s=!1,o=()=>{s||(s=!0,t())};return n=r.subscribe(i=>{let a=!1,u=!1;for(let d of i)d[0]!==Ve&&(d[0]===M?e.emit(d[1]):d[0]===j?a=!0:d[0]===I?(u=!0,e.down([d])):(d[0]===Z||d[0]===Y)&&e.down([d]));u?(n?.(),n=void 0,o()):a&&o()}),()=>{n?.(),n=void 0}}function it(r,e,t){let n,s=!1;function o(){n?.(),n=void 0}return te([r],(i,a,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){o();return}if(u.terminalDeps[0]===!0){s=!0,n||a.down([[j]]);return}let d=i[0];if(!(d==null||d.length===0))return o(),n=Go(Ee(e(d[d.length-1])),a,()=>{o(),s&&a.down([[j]])}),{deactivate:()=>{o(),s=!1}}},{...Lt(t),completeWhenDepsComplete:!1,meta:{...Je("switchMap"),...t?.meta??{}}})}var wr=J(()=>{"use strict";Te();st();Ie();oe();Pe()});var Ye=J(()=>{"use strict";wr()});function Rn(r,e){if(Object.is(r,e))return!0;if(r==null||e==null||typeof r!="object"||typeof e!="object")return!1;if(Array.isArray(r)){if(!Array.isArray(e)||r.length!==e.length)return!1;for(let o=0;o<r.length;o++)if(!Rn(r[o],e[o]))return!1;return!0}if(Array.isArray(e))return!1;let t=Object.keys(r),n=Object.keys(e);if(t.length!==n.length)return!1;let s=new Set(n);for(let o of t)if(!s.has(o)||!Rn(r[o],e[o]))return!1;return!0}function xr(r,e){return`${r}\0${e}`}function On(r,e){let t=[],n=new Set(r.subgraphs),s=new Set(e.subgraphs),o=[];for(let m of s)n.has(m)||o.push(m);o.sort();for(let m of o)t.push({type:"subgraph-mounted",path:m});let i=new Set(Object.keys(r.nodes)),a=new Set(Object.keys(e.nodes)),u=[];for(let m of a)i.has(m)||u.push(m);u.sort();for(let m of u)t.push({type:"node-added",path:m,node:{...e.nodes[m]}});let d=[];for(let m of a){if(!i.has(m))continue;let v=r.nodes[m]?.meta,T=e.nodes[m]?.meta;v==null&&T==null||Rn(v??{},T??{})||d.push(m)}d.sort();for(let m of d)t.push({type:"node-meta-changed",path:m,prevMeta:r.nodes[m]?.meta??{},nextMeta:e.nodes[m]?.meta??{}});let l=new Map;for(let m of r.edges)l.set(xr(m.from,m.to),m);let f=new Map;for(let m of e.edges)f.set(xr(m.from,m.to),m);let c=[];for(let[m,v]of f)l.has(m)||c.push(v);c.sort((m,v)=>m.from<v.from?-1:m.from>v.from?1:m.to<v.to?-1:m.to>v.to?1:0);for(let m of c)t.push({type:"edge-added",from:m.from,to:m.to});let h=[];for(let[m,v]of l)f.has(m)||h.push(v);h.sort((m,v)=>m.from<v.from?-1:m.from>v.from?1:m.to<v.to?-1:m.to>v.to?1:0);for(let m of h)t.push({type:"edge-removed",from:m.from,to:m.to});let p=[];for(let m of i)a.has(m)||p.push(m);p.sort();for(let m of p)t.push({type:"node-removed",path:m});let g=[];for(let m of n)s.has(m)||g.push(m);g.sort();for(let m of g)t.push({type:"subgraph-unmounted",path:m});return{events:t,flushedAt_ns:U()}}var Nr=J(()=>{"use strict";Oe()});var jt,Er=J(()=>{"use strict";jt=class{_timer;_gen=0;start(e,t){this.cancel(),this._gen+=1;let n=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,n===this._gen&&t()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var vt,kr=J(()=>{"use strict";vt=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let t=(this.head+this._size)%this.capacity;this.buf[t]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let t=e<0?this._size+e:e;if(!(t<0||t>=this._size))return this.buf[(this.head+t)%this.capacity]}toArray(){let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this.buf[(this.head+t)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}}});function Rr(r,e,t,n={}){let s=e in r.nodes,o=t in r.nodes;if(!s)return zt(e,t,"no-such-from");if(!o)return zt(e,t,"no-such-to");let i=n.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===t){if(n.findCycle===!0){let d=qo(r,e,n);if(d!=null)return d}let u=Ht(e,r.nodes[e],0,n);return Bt(e,t,[u])}if(i===0)return zt(e,t,"no-path");let a=Or(r,e,t,i);return a.found?Bt(e,t,Ar(r,a.pathOrder,n)):zt(e,t,a.truncated?"max-depth-exceeded":"no-path")}function Or(r,e,t,n){let s=new Map,o=[{path:t,depth:0}],i=new Set([t]),a=0,u=!1;for(;a<o.length;){let f=o[a++];if(f.path===e)break;if(n!=null&&f.depth>=n){let g=r.nodes[f.path];g?.deps&&g.deps.length>0&&(u=!0);continue}let c=r.nodes[f.path];if(c==null)continue;let h=c.deps??[],p=new Map;for(let g=0;g<h.length;g++){let m=h[g];if(!m)continue;let v=p.get(m);v==null&&(v=[],p.set(m,v)),v.push(g)}for(let[g,m]of p)i.has(g)||(i.add(g),s.set(g,{from:f.path,depIndices:m}),o.push({path:g,depth:f.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:u};let d=[{path:e}],l=e;for(;l!==t;){let f=s.get(l);if(f==null)return{found:!1,pathOrder:[],truncated:!1};d[d.length-1].depIndices=f.depIndices,d.push({path:f.from}),l=f.from}return{found:!0,pathOrder:d,truncated:!1}}function qo(r,e,t){let n=r.nodes[e];if(n==null)return null;let s=n.deps??[],o=[];for(let a=0;a<s.length;a++)s[a]===e&&o.push(a);if(o.length>0){let a=Ht(e,n,0,t);a.dep_index=o[0];let u=Ht(e,n,1,t);return Bt(e,e,[a,u])}let i=null;for(let a=0;a<s.length;a++){let u=s[a];if(!u||u===e)continue;let d=Or(r,u,e,t.maxDepth);d.found&&(i==null||d.pathOrder.length<i.pathOrder.length)&&(i=d,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...d.pathOrder],truncated:!1})}return i==null?null:Bt(e,e,Ar(r,i.pathOrder,t))}function Ar(r,e,t){return e.map((n,s)=>{let o=r.nodes[n.path],i=Ht(n.path,o,s,t);return n.depIndices!=null&&n.depIndices.length>0&&(i.dep_index=n.depIndices[0],n.depIndices.length>1&&(i.dep_indices=[...n.depIndices])),i})}function Ht(r,e,t,n){let s={path:r,type:e.type,hop:t};e.status!==void 0&&(s.status=e.status),"value"in e&&(s.value=e.value),e.v!=null&&(s.v=e.v);let o=n.annotations?.get(r)??e.annotation;o!=null&&(s.annotation=o);let i=n.lastMutations?.get(r)??e.lastMutation;return i!=null&&(s.lastMutation=i),s}function Bt(r,e,t){return Sr(r,e,!0,"ok",t)}function zt(r,e,t){return Sr(r,e,!1,t,[])}function Sr(r,e,t,n,s){let o=Ko(r,e,t,n,s);return{from:r,to:e,found:t,reason:n,steps:s,text:o,toJSON(){return{from:r,to:e,found:t,reason:n,steps:s}}}}function Ko(r,e,t,n,s){if(!t)switch(n){case"no-such-from":return`explainPath: no node named "${r}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${r}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${r}" to "${e}"`}let o=[`Causal path: ${r} \u2192 ${e} (${s.length} step(s))`];for(let i of s){let u=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(o.push(u),"value"in i&&o.push(` value: ${Uo(i.value)}`),i.annotation!=null&&o.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let d=i.lastMutation.actor;o.push(` actor: ${d.type}${d.id?`:${d.id}`:""}`)}}return o.join(`
|
|
2
|
-
|
|
3
|
-
`)}function Pr(r){if(r.version!==Qe)throw new Error(`unsupported snapshot version ${String(r.version)} (expected ${Qe})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in r))throw new Error(`snapshot missing required key "${e}"`);if(typeof r.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof r.nodes!="object"||r.nodes===null||Array.isArray(r.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(r.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(r.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function Zo(r,e){let t=new WeakMap,n=(s,o)=>{if(Object.is(s,o))return!0;if(s==null||o==null||typeof s!="object"||typeof o!="object")return!1;let i=t.get(s);if(i==null&&(i=new WeakSet,t.set(s,i)),i.has(o))return!0;i.add(o);let a=s.constructor,u=o.constructor;if(a!==u)return!1;if(s instanceof Date)return s.getTime()===o.getTime();if(s instanceof RegExp)return s.source===o.source&&s.flags===o.flags;if(Array.isArray(s)){let c=o;if(s.length!==c.length)return!1;for(let h=0;h<s.length;h++)if(!n(s[h],c[h]))return!1;return!0}if(s instanceof Map){let c=o;if(s.size!==c.size)return!1;for(let[h,p]of s)if(!c.has(h)||!n(p,c.get(h)))return!1;return!0}if(s instanceof Set){let c=o;if(s.size!==c.size)return!1;for(let h of s){let p=!1;for(let g of c)if(n(h,g)){p=!0;break}if(!p)return!1}return!0}if(ArrayBuffer.isView(s)){let c=s,h=o;if(c.length!==h.length)return!1;for(let p=0;p<c.length;p++)if(c[p]!==h[p])return!1;return!0}let d=Object.keys(s),l=Object.keys(o);if(d.length!==l.length)return!1;let f=new Set(l);for(let c of d)if(!f.has(c)||!n(s[c],o[c]))return!1;return!0};return n(r,e)}function es(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ut(r){let e="^";for(let t=0;t<r.length;t+=1){let n=r[t];if(n==="*"){e+=".*";continue}if(n==="?"){e+=".";continue}if(n==="["){let s=r.indexOf("]",t+1);if(s<=t+1){e+="\\[";continue}let o=r.slice(t+1,s);o.startsWith("!")&&(o=`^${o.slice(1)}`),o=o.replace(/\\/g,"\\\\"),e+=`[${o}]`,t=s;continue}e+=es(n)}return e+="$",new RegExp(e)}function Sn(r){if(typeof r=="string")return JSON.stringify(r);if(typeof r=="number"||typeof r=="boolean"||r==null)return String(r);try{return JSON.stringify(r)}catch{return"[unserializable]"}}function rs(r){return r==="none"?ns:r==="ansi"||r==null?ts:{data:r.data??"",dirty:r.dirty??"",resolved:r.resolved??"",invalidate:r.invalidate??"",pause:r.pause??"",resume:r.resume??"",complete:r.complete??"",error:r.error??"",teardown:r.teardown??"",derived:r.derived??"",path:r.path??"",reset:r.reset??""}}function Lr(r){if(r==null)return{};let e=r.detail;return e==="full"?{...r,structured:r.structured??!0,timeline:r.timeline??!0,causal:r.causal??!0,derived:r.derived??!0}:e==="minimal"?{...r,structured:r.structured??!0}:r.format==="stage-log"?{...r,structured:r.structured??!0,timeline:r.timeline??!0}:r}function os(r,e,t){for(let n=0;n<r.length;n++){let s=r.charCodeAt(n);if(s<32||s===127)throw new Error(`Graph "${e}": ${t} "${r}" must not contain control character (U+${s.toString(16).padStart(4,"0").toUpperCase()} at index ${n})`)}}function Dn(r,e,t){if(r==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(r.includes(Q))throw new Error(`Graph "${e}": ${t} "${r}" must not contain '${Q}' (path separator)`);if(r===Se)throw new Error(`Graph "${e}": ${t} name "${Se}" is reserved for meta companion paths`);os(r,e,t)}function ss(r,e){if(r==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=r.split(Q);for(let n of t)if(n==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function is(r,e){let t=!1;for(let s of r)if(!e.isMetaPassthrough(s[0])){t=!0;break}return t?r.filter(s=>e.isMetaPassthrough(s[0])):r}function $r(r){for(let e of r._mounts.values())$r(e);for(let e of r._nodes.values())try{e.down([[pe]],{internal:!0})}catch{}}function Vr(r,e){let t=ge.diff(r,e),n={};for(let s of t.nodesAdded){let o=e.nodes[s];o!=null&&(n[s]=o)}return{...t,nodesAddedFull:n}}function Cn(r,e,t,n={}){let s={paths:[],depths:new Map,truncated:!1};if(!e)return n.withDetail?s:[];if(!n.both&&t!=="upstream"&&t!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let o=n.maxDepth;if(o!=null&&(!Number.isInteger(o)||o<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(o===0)return n.withDetail?s:[];let i=new Map,a=new Map,u=new Map,d=new Map,l=new Set;for(let[y,_]of Object.entries(r.nodes)){if(!y)continue;l.add(y);let w=_.deps??[];i.set(y,w);for(let N of w)N&&(l.add(N),a.has(N)||a.set(N,new Set),a.get(N).add(y))}for(let y of r.edges){if(y==null||typeof y!="object")continue;let _=typeof y.from=="string"?y.from:"",w=typeof y.to=="string"?y.to:"";!_||!w||(l.add(_),l.add(w),d.has(_)||d.set(_,new Set),d.get(_).add(w),u.has(w)||u.set(w,new Set),u.get(w).add(_))}if(!l.has(e))return n.withDetail?s:[];let f=n.both===!0,c=y=>{if(f){let b=i.get(y)??[],x=u.get(y),E=a.get(y),A=d.get(y),k=[...b];return x&&k.push(...x),E&&k.push(...E),A&&k.push(...A),k}if(t==="upstream"){let b=i.get(y)??[],x=u.get(y);return x?[...b,...x]:b}let _=a.get(y),w=d.get(y),N=_?[..._]:[];return w&&N.push(...w),N},h=new Set([e]),p=new Map,g=[{path:e,depth:0}],m=0,v=!1;for(;m<g.length;){let y=g[m++];if(o!=null&&y.depth>=o){c(y.path).length>0&&(v=!0);continue}for(let _ of c(y.path))!_||h.has(_)||(h.add(_),p.set(_,y.depth+1),g.push({path:_,depth:y.depth+1}))}let T=[...p.keys()].sort((y,_)=>y<_?-1:y>_?1:0);return n.withDetail?{paths:T,depths:p,truncated:v}:T}function as(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++){let n=r[t],s=e[t];if(n.path!==s.path||n.type!==s.type||n.status!==s.status||n.hop!==s.hop||n.dep_index!==s.dep_index||n.annotation!==s.annotation||n.value!==s.value||n.lastMutation!==s.lastMutation)return!1;let o=n.v,i=s.v;if(o!==i&&(o==null||i==null||o.id!==i.id||o.version!==i.version))return!1}return!0}var Q,Se,Qe,ts,ns,ge,Tt=J(()=>{"use strict";Mt();Ce();Oe();rt();Te();st();Ie();oe();Nr();Pe();Er();kr();fn();Dr();An();Q="::",Se="__meta__",Qe=1;ts={data:"\x1B[32m",dirty:"\x1B[33m",resolved:"\x1B[36m",invalidate:"\x1B[93m",pause:"\x1B[90m",resume:"\x1B[96m",complete:"\x1B[34m",error:"\x1B[31m",teardown:"\x1B[91m",derived:"\x1B[35m",path:"\x1B[90m",reset:"\x1B[0m"},ns={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};ge=class r{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;_factory;_factoryArgs;constructor(e,t){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(Q))throw new Error(`Graph name must not contain '${Q}' (got "${e}")`);if(e===Se)throw new Error(`Graph name "${Se}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??ot,this._traceRing=new vt(t?.traceCapacity??1e3),t?.versioning!=null&&this.setVersioning(t.versioning),typeof t?.factory=="string"&&(this._factory=t.factory,t.factoryArgs!==void 0&&(this._factoryArgs=t.factoryArgs))}tagFactory(e,t){return this._factory=e,this._factoryArgs=t,this}ancestors(e=!0){let t=[],n=e?this:this._parent;for(;n!=null;)t.push(n),n=n._parent;return t}get topology(){return this._topology==null&&(this._topology=he(e=>{let t=n=>{e.emit(n)};return this._topologyEmitters.add(t),()=>{this._topologyEmitters.delete(t)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let t of this._topologyEmitters)t(e)}nameOf(e){return this._nodeToName.get(e)}add(e,t){let n=e.name,s=t?.name??n;if(s==null||s==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let o=s,i=t?.annotation;if(Dn(o,this.name,"add"),this._mounts.has(o))throw new Error(`Graph "${this.name}": name "${o}" is already a mount point`);if(this._nodes.has(o))throw new Error(`Graph "${this.name}": node "${o}" already exists`);let a=this._nodeToName.get(e);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(o,e),this._nodeToName.set(e,o),this._emitTopology({kind:"added",name:o,nodeKind:"node"}),i!=null&&(this._annotations.set(o,i),this.config.inspectorEnabled&&this._traceRing.push({path:o,annotation:i,timestamp_ns:U()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof de&&t._applyVersioning(e)}remove(e){Dn(e,this.name,"remove");let t=this._mounts.get(e);if(t){let o={kind:"mount",nodes:[],mounts:[]},i=[];t._collectObserveTargets("",i);for(let[a,u]of i)a.includes(`${Q}${Se}${Q}`)||o.nodes.push(a);return o.nodes.sort(),o.mounts.push(e),o.mounts.push(...t._collectSubgraphs(`${e}${Q}`)),this._mounts.delete(e),t._parent=void 0,$r(t),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:o}),o}let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(n),n.down([[pe]],{internal:!0});let s={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:s}),s}removeAll(e){let t=typeof e=="function"?e:(()=>{let o=Ut(e);return i=>o.test(i)})(),n={kind:"mount",nodes:[],mounts:[]},s=[...this._nodes.keys(),...this._mounts.keys()].filter(o=>t(o));for(let o of s){let i=this.remove(o);n.nodes.push(...i.nodes),n.mounts.push(...i.mounts)}return n.nodes.sort(),n.mounts.sort(),n}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),t=this._nodes,n=0;return{[Symbol.iterator](){return this},next(){if(n>=e.length)return{value:void 0,done:!0};let s=e[n++];return{value:[s,t.get(s)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(Q))return this.resolve(e);let t=this._nodes.get(e);if(!t)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return t}get(e){return this.node(e).cache}set(e,t,n){let s=n?.internal===!0;this.node(e).down([[M,t]],{actor:n?.actor,internal:s,delivery:"write"})}setAll(e,t){let n=Symbol.iterator in e?e:Object.entries(e);K(()=>{for(let[s,o]of n)this.set(s,o,t)})}invalidate(e,t){let n=t?.internal===!0;this.node(e).down([[Re]],{actor:t?.actor,internal:n,delivery:"write"})}error(e,t,n){let s=n?.internal===!0;this.node(e).down([[I,t]],{actor:n?.actor,internal:s,delivery:"write"})}complete(e,t){let n=t?.internal===!0;this.node(e).down([[j]],{actor:t?.actor,internal:n,delivery:"write"})}_registerSelfPruningKeepalive(e){let t,n,s=()=>{t?.(),t=void 0,n?.(),n=void 0};t=e.subscribe(o=>{for(let i of o){let a=i[0];if(a===pe||a===j||a===I){s();return}}}),n=this.addDisposer(s)}_wireSignalToRemove(e,t){if(t==null)return;let n=()=>{try{this.remove(e)}catch{}};if(t.aborted){n();return}t.addEventListener("abort",n,{once:!0}),this.addDisposer(()=>t.removeEventListener("abort",n))}derived(e,t,n,s){let o=t.map(h=>this.resolve(h)),{keepAlive:i,annotation:a,equals:u,initial:d,meta:l,signal:f}=s??{},c=G(o,n,{name:e,...u!=null?{equals:u}:{},...d!==void 0?{initial:d}:{},...l!=null?{meta:l}:{}});return this.add(c,{name:e,...a!=null?{annotation:a}:{}}),i===!0&&this._registerSelfPruningKeepalive(c),this._wireSignalToRemove(e,f),c}effect(e,t,n,s){let o=t.map(l=>this.resolve(l)),{annotation:i,meta:a,signal:u}=s??{},d=le(o,n,{name:e,...a!=null?{meta:a}:{}});return this.add(d,{name:e,...i!=null?{annotation:i}:{}}),this._wireSignalToRemove(e,u),d}produce(e,t,n){if(t===void 0)throw new Error(`Graph "${this.name}".produce("${e}", \u2026): source must not be \`undefined\` \u2014 undefined is the global SENTINEL (spec \xA71.1). Pass \`null\` for nullary DATA, or a Promise/AsyncIterable/Iterable for async sources.`);if(t!==null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function")throw new Error(`Graph "${this.name}".produce("${e}", \u2026): Node sources are rejected. For Node\u2192Node, use graph.derived(name, [path], ([v]) => v, { keepAlive: true }) \u2014 fromAny passes Nodes through verbatim and silently drops opts.`);let{annotation:s,meta:o,equals:i,signal:a}=n??{},u=Ee(t,{name:e,...o!=null?{meta:o}:{},...i!=null?{equals:i}:{},...a!=null?{signal:a}:{}});return this.add(u,{name:e,...s!=null?{annotation:s}:{}}),this._wireSignalToRemove(e,a),u}batch(e){K(e)}edges(e){let t=e?.recursive===!0,n=new Map;if(!t){for(let[u,d]of this._nodes)n.set(d,u);let a=[];for(let[u,d]of this._nodes)if(d instanceof de)for(let l of d._deps){let f=n.get(l.node);f!=null&&a.push([f,u])}return a.sort((u,d)=>u[0]<d[0]?-1:u[0]>d[0]?1:u[1]<d[1]?-1:u[1]>d[1]?1:0),a}let s=[];this._collectObserveTargets("",s);let o=new Map;for(let[a,u]of s)o.set(u,a);let i=[];for(let[a,u]of s)if(u instanceof de)for(let d of u._deps){let l=o.get(d.node);l!=null&&i.push([l,a])}return i.sort((a,u)=>a[0]<u[0]?-1:a[0]>u[0]?1:a[1]<u[1]?-1:a[1]>u[1]?1:0),i}mount(e,t){if(t===void 0){let s=new r(e);return this.mount(e,s)}if(typeof t=="function"){let s=new r(e);return t(s),this.mount(e,s)}let n=t;if(Dn(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let s=this;s!=null;s=s._parent)if(s===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let t=ss(e,this.name);return this._resolveFromSegments(t)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let t=e;if(t[0]===this.name&&(t=t.slice(1),t.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let n=t[0],s=t.slice(1);if(s.length===0){let a=this._nodes.get(n);if(a)return a;throw this._mounts.has(n)?new Error(`Graph "${this.name}": path ends at subgraph "${n}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${n}"`)}let o=this._nodes.get(n);if(o&&s.length>0&&s[0]===Se)return this._resolveMetaChainFromNode(o,s,t.join(Q));let i=this._mounts.get(n);if(!i)throw this._nodes.has(n)?new Error(`Graph "${this.name}": "${n}" is a node; trailing path "${s.join(Q)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${n}"`);return i.resolve(s.join(Q))}_resolveMetaChainFromNode(e,t,n){let s=e,o=0,i=[...t];for(;o<i.length;){if(i[o]!==Se)throw new Error(`Graph "${this.name}": expected ${Se} segment in meta path "${n}"`);if(o+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${Se} in "${n}"`);let a=i[o+1],u=s.meta[a];if(!u)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${n}"`);s=u,o+=2}return s}signal(e,t){if(t?.internal!==!0){for(let s of e)if(this.config.messageTier(s[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let n=[];if(this._signalDeliver(e,t??{},new Set,n),n.length>0)throw n[0]}_signalDeliver(e,t,n,s){for(let u of this._mounts.values())u._signalDeliver(e,t,n,s);let i=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},a=is(e,this.config);for(let u of[...this._nodes.keys()].sort()){let d=this._nodes.get(u);if(!n.has(d)){n.add(d);try{d.down(e,i)}catch(l){if(l instanceof Ae)throw l;s.push(l)}a.length!==0&&this._signalMetaSubtree(d,a,n,i,s)}}}_signalMetaSubtree(e,t,n,s,o){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!n.has(a)){n.add(a);try{a.down(t,s)}catch(u){if(u instanceof Ae)throw u;o.push(u)}this._signalMetaSubtree(a,t,n,s,o)}}}describe(e){if(e?.reactive==="diff")return this._describeReactiveDiff(e);if(e?.reactive===!0)return this._describeReactive(e);let t=Qo(e?.actor),n=e?.filter;if(e?.detail!=null&&e?.fields!=null)throw new TypeError("Graph.describe(): pass either `detail` or `fields`, not both. `detail: 'spec'` is the canonical spec projection; use `fields` only when you need a custom subset.");let s=Pt(e?.detail,e?.fields),o=e?.detail==="spec",i=s,a=[];this._collectObserveTargets("",a);let u=new Map;for(let[_,w]of a)u.set(w,_);let d=[];{let _=a.map(([,b])=>b),w=new Set(u.values()),N=0;for(;_.length>0;){let b=_.shift();if(b instanceof de)for(let x of b._deps){let E=x.node;if(u.has(E))continue;let A=E.name??"",k=A;if(!k||w.has(k))if(A){let C=2;for(;w.has(`${A}#${C}`);)C++;k=`${A}#${C}`}else for(k=`__internal__/${N++}`;w.has(k);)k=`__internal__/${N++}`;u.set(E,k),w.add(k),d.push([k,E]),_.push(E)}}}let l=[...a,...d],f={};for(let[_,w]of l){if(t!=null&&!w.allowsObserve(t))continue;let N=_n(w,i,o),b=w instanceof de?w._deps.map(k=>u.get(k.node)??k.node.name??""):[],{name:x,...E}=N,A={...E,deps:b};if(!o){let k=this._annotations.get(_);k!=null&&(A.annotation=k)}if(n!=null)if(typeof n=="function"){let k=n;if(!(k.length>=2?k(_,A):k(A)))continue}else{let k=!0;for(let[C,H]of Object.entries(n)){let z=C==="deps_includes"?"depsIncludes":C==="meta_has"?"metaHas":C;if(z==="depsIncludes"){if(!A.deps.includes(String(H))){k=!1;break}continue}if(z==="metaHas"){if(!Object.hasOwn(A.meta??{},String(H))){k=!1;break}continue}if(A[z]!==H){k=!1;break}}if(!k)continue}f[_]=A}let c=new Set(Object.keys(f)),h=[];for(let[_,w]of l)if(w instanceof de)for(let N of w._deps){let b=u.get(N.node);b!=null&&h.push([b,_])}h.sort((_,w)=>_[0]<w[0]?-1:_[0]>w[0]?1:_[1]<w[1]?-1:_[1]>w[1]?1:0);let p=h.map(([_,w])=>({from:_,to:w}));(t!=null||n!=null)&&(p=p.filter(_=>c.has(_.from)&&c.has(_.to)));let g=this._collectSubgraphs(""),m=t!=null||n!=null?g.filter(_=>{let w=`${_}${Q}`;return[...c].some(N=>N===_||N.startsWith(w))}):g,v=this,T=e;return{name:this.name,nodes:f,edges:p,subgraphs:m,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(_){let w={...T};return Array.isArray(_)?(w.fields=_,w.detail=void 0):(w.detail=_,w.fields=void 0),v.describe(w)}}}_collectSubgraphs(e){let t=[];for(let n of[...this._mounts.keys()].sort()){let s=e===""?n:`${e}${n}`;t.push(s),t.push(...this._mounts.get(n)._collectSubgraphs(`${s}${Q}`))}return t}resourceProfile(e){return qt(this,e)}reachable(e,t,n={}){return n.withDetail===!0?Cn(this.describe(),e,t,{...n,withDetail:!0}):Cn(this.describe(),e,t,n)}explain(e,t,n){return n?.reactive===!0?this._explainReactive(e,t,n):this._explainStatic(ze(e),ze(t),{...n?.maxDepth!==void 0?{maxDepth:Ir(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:Gr(n.findCycle)}:{}})}_explainStatic(e,t,n){let s=this.describe({detail:"full"}),o=new Map(this._annotations),i=new Map;for(let[a,u]of Object.entries(s.nodes))u.lastMutation!=null&&i.set(a,u.lastMutation);return Rr(s,e,t,{...n?.maxDepth!=null?{maxDepth:n.maxDepth}:{},...n?.findCycle===!0?{findCycle:!0}:{},annotations:o,lastMutations:i})}_describeReactive(e){let t={...e,reactive:!1},n=e.reactiveName??"describe",s=0,o=V(s,{name:`${n}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,d=()=>{a||u||(a=!0,nt(()=>{a=!1,!u&&(s+=1,o.emit(s))}))},l=i.onEvent(T=>{let y=T.type;y!=="data"&&y!=="error"&&y!=="complete"&&y!=="teardown"||d()}),f=[],c=new WeakSet,h=T=>{if(c.has(T)||u)return;c.add(T);let y=T.topology.subscribe(_=>{for(let w of _){if(w[0]!==M)continue;let N=w[1];if(d(),N.kind==="added"&&N.nodeKind==="mount"){let b=T._mounts.get(N.name);b!=null&&h(b)}}});f.push(y);for(let _ of T._mounts.keys()){let w=T._mounts.get(_);w!=null&&h(w)}};h(this);let p,g=e.actor;Fr(g)&&(p=g.subscribe(T=>{let y=!1,_=!1;for(let w of T){let N=w[0];N===M?y=!0:(N===j||N===I||N===pe)&&(_=!0)}y&&d(),_&&(p?.(),p=void 0,d())}));let m;try{m=G([o],()=>this.describe(t),{name:n,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(T,y)=>T===y})}catch(T){l(),p?.();for(let y of f)y();throw i.dispose(),T}let v=me(m);return{node:m,dispose(){u=!0,l(),p?.();for(let T of f)T();f.length=0,i.dispose(),v()}}}_describeReactiveDiff(e){let t={...e,reactive:!1},n=e.reactiveName??"describe-diff",s={name:this.name,nodes:{},edges:[],subgraphs:[]},o=this.describe(t),i=On(s,o),a=V(i,{name:n,meta:{domain:"audit",kind:"describe-diff"},equals:(c,h)=>c===h}),u=this._describeReactive({...e,reactiveName:void 0}),d=!1,l=u.node.subscribe(c=>{if(!d)for(let h of c){if(h[0]!==M)continue;let p=h[1],g=On(o,p);o=p,g.events.length!==0&&a.emit(g)}}),f=me(a);return{node:a,dispose(){d=!0,l(),u.dispose(),a.down([[pe,"describe-diff disposed"]]),f()}}}_explainReactive(e,t,n){let s=0,o=V(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,d=()=>{a||u||(a=!0,nt(()=>{a=!1,!u&&(s+=1,o.emit(s))}))},l=i.onEvent(T=>{let y=T.type;y!=="data"&&y!=="error"&&y!=="complete"&&y!=="teardown"||d()}),f=[];e!=null&&Xe(e)&&f.push(e),t!=null&&Xe(t)&&f.push(t),n?.maxDepth!=null&&Xe(n.maxDepth)&&f.push(n.maxDepth),n?.findCycle!=null&&Xe(n.findCycle)&&f.push(n.findCycle);let c=()=>{for(let T of f)if(T.cache===void 0)return!1;return!0},h=()=>{let T=ze(e),y=ze(t);return{from:T,to:y,found:!1,reason:"pending",steps:[],text:"(awaiting reactive args)",toJSON:()=>({from:T,to:y,found:!1,reason:"pending",steps:[]})}},p;try{p=G([o],()=>{if(!c())return h();let T=ze(e),y=ze(t),_={...n?.maxDepth!==void 0?{maxDepth:Ir(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:Gr(n.findCycle)}:{}};return this._explainStatic(T,y,_)},{name:n?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:ze(e),to:ze(t)},equals:(T,y)=>T.found===y.found&&T.reason===y.reason&&T.steps.length===y.steps.length&&as(T.steps,y.steps)})}catch(T){throw l(),i.dispose(),T}let g=me(p),m=[],v=T=>{let y;return y=T.subscribe(_=>{let w=!1,N=!1;for(let b of _){let x=b[0];x===M?w=!0:(x===j||x===I||x===pe)&&(N=!0)}(w||N)&&d(),N&&y&&(y(),y=void 0)}),()=>{y&&(y(),y=void 0)}};for(let T of f)m.push(v(T));return{node:p,dispose(){u=!0,l();for(let T of m)T?.();m.length=0,i.dispose(),g()}}}_pathsMatching(e){let t=Ut(e),n=[];return this._collectObserveTargets("",n),n.map(([s])=>s).filter(s=>t.test(s))}_collectObserveTargets(e,t){for(let n of[...this._mounts.keys()].sort()){let s=e===""?n:`${e}${Q}${n}`;this._mounts.get(n)._collectObserveTargets(s,t)}for(let n of[...this._nodes.keys()].sort()){let s=this._nodes.get(n),o=e===""?n:`${e}${Q}${n}`;t.push([o,s]),this._appendMetaObserveTargets(o,s,t)}}_appendMetaObserveTargets(e,t,n){for(let s of Object.keys(t.meta).sort()){let o=t.meta[s],i=`${e}${Q}${Se}${Q}${s}`;n.push([i,o]),this._appendMetaObserveTargets(i,o,n)}}observe(e,t){let n=typeof e=="string",o=Lr(n?t:e);if(o.reactive===!0)return this._observeReactive(n?e:void 0,o);let i=o.structured===!0||o.timeline===!0||o.causal===!0||o.derived===!0||o.detail==="minimal"||o.detail==="full"||o.format!=null,a=o.actor;if(n){let l=e,f=this.resolve(l);if(a!=null&&!f.allowsObserve(a))throw new Ae({actor:a,action:"observe",nodeName:l});return i?this._buildStructuredObserver([[l,f]],o,"one"):{subscribe(c){return f.subscribe(c)},up(c){try{f.up?.(c)}catch(h){if(h instanceof Ae)return;throw h}}}}let u=[];this._collectObserveTargets("",u),u.sort((l,f)=>l[0]<f[0]?-1:l[0]>f[0]?1:0);let d=a==null?u:u.filter(([,l])=>l.allowsObserve(a));return i?this._buildStructuredObserver(d,o,"all"):{subscribe:l=>{let f=d.map(([c,h])=>h.subscribe(p=>{l(c,p)}));return()=>{for(let c of f)c()}},up:(l,f)=>{try{this.resolve(l).up?.(f)}catch(c){if(c instanceof Ae)return;throw c}}}}_observeReactive(e,t){let n=t.tiers,s=n!=null?new Set(n):null,o=t.reactiveName??"observe";return he(i=>{let a=[],u=!1,d=!1,l=()=>{if(a.length===0||d)return;let g={events:a.slice(),flushedAt_ns:U()};a.length=0,i.emit(g)},f={...t,reactive:!1,structured:!0,timeline:!0},c=e!=null?this.observe(e,f):this.observe(f),h=g=>{d||(a.push(g),!u&&(u=!0,nt(()=>{u=!1,l()})))};for(let g of c.events)h(g);let p=c.onEvent(h);return()=>{d=!0,p(),c.dispose()}},{name:o,meta:{domain:"audit",kind:"observe-reactive"}})}_buildStructuredObserver(e,t,n){let s=n==="one"?e[0]?.[0]:void 0,o=i=>{if(n==="one"&&s!=null){let l=this.resolve(s);return this._buildStructuredObserver([[s,l]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((l,f)=>l[0]<f[0]?-1:l[0]>f[0]?1:0);let u=i.actor,d=u==null?a:a.filter(([,l])=>l.allowsObserve(u));return this._buildStructuredObserver(d,i,"all")};return this._createObserveResult(e,t,o)}_createObserveResult(e,t,n){let s=t.timeline===!0,o=t.causal===!0,i=t.derived===!0,a=t.detail==="minimal",u=this.config.inspectorEnabled,d=(o||i)&&u,l=t.maxEvents,f=l!=null&&l>0?new vt(l):null,c=[],h=new Set,p=t.tiers!=null?new Set(t.tiers):null,g={},m=new Set,v=0,T=0,y=0,_=0,w=0,N=0,b=!1,x=!1,E=0,A=new Map,k=new Map,C=new Map,H=S=>{if(!(p!=null&&!p.has(S.type))){f?f.push(S):c.push(S);for(let B of h)B(S)}},z=S=>p==null||p.has(S),fe=()=>s?{timestamp_ns:U(),in_batch:gt(),batch_id:E}:{},ne=(S,B)=>{if(!(!d||!(S instanceof de)))return S._setInspectorHook(ve=>{if(ve.kind==="dep_message")A.set(S,ve.depIndex);else if(ve.kind==="run"){let Ge=ve.batchData.map((R,P)=>R!=null&&R.length>0?R.at(-1):ve.prevData[P]);k.set(S,Ge);let Ne=ve.batchData.map(R=>R!=null?[...R]:void 0);C.set(S,Ne),i&&H({type:"derived",path:B,dep_values:Ge,dep_batches:Ne,...fe()})}})},we=S=>{let B=A.get(S),ve=k.get(S);if(!o||ve==null)return{};let Ne=(B!=null&&B>=0&&S instanceof de?S._deps[B]:void 0)?.node,R=Ne?.v,P=C.get(S);return{trigger_dep_index:B,trigger_dep_name:Ne?.name,...R!=null?{trigger_version:{id:R.id,version:R.version}}:{},dep_values:[...ve],...P!=null?{dep_batches:P}:{}}},xe=[],$=[];for(let[S,B]of e){let ve=ne(B,S);ve&&xe.push(ve),$.push(B.subscribe(Ge=>{E++;for(let Ne of Ge){let R=Ne[0],P=fe();if(R===M){g[S]=Ne[1];let ee=B instanceof de?B.lastMutation?.actor??Ze:Ze;H({type:"data",path:S,data:Ne[1],actor:ee,...P,...we(B)})}else if(a)R===Z?z("dirty")&&v++:R===Y?z("resolved")&&T++:R===Re?z("invalidate")&&y++:R===De?z("pause")&&_++:R===je?z("resume")&&w++:R===pe?z("teardown")&&N++:R===j&&!m.has(S)?z("complete")&&(b=!0):R===I&&z("error")&&(x=!0,m.add(S));else if(R===Z)z("dirty")&&v++,H({type:"dirty",path:S,...P});else if(R===Y)z("resolved")&&T++,H({type:"resolved",path:S,...P,...we(B)});else if(R===Re)z("invalidate")&&y++,H({type:"invalidate",path:S,...P});else if(R===De)z("pause")&&_++,H({type:"pause",path:S,lockId:Ne[1],...P});else if(R===je)z("resume")&&w++,H({type:"resume",path:S,lockId:Ne[1],...P});else if(R===j)z("complete")&&!m.has(S)&&(b=!0),H({type:"complete",path:S,...P});else if(R===I){z("error")&&(x=!0,m.add(S));let ee=B instanceof de?B.lastMutation?.actor??Ze:Ze;H({type:"error",path:S,data:Ne[1],actor:ee,...P})}else R===pe&&(z("teardown")&&N++,H({type:"teardown",path:S,...P}))}}))}let L=!1,F=()=>{if(!L){L=!0;for(let S of $)S();for(let S of xe)S();for(let S of W)S({value:void 0,done:!0});W.length=0}},re=[],W=[];h.add(S=>{let B=W.shift();B?B({value:S,done:!1}):re.push(S)});let se={get values(){return g},get dirtyCount(){return v},get resolvedCount(){return T},get invalidateCount(){return y},get pauseCount(){return _},get resumeCount(){return w},get teardownCount(){return N},get events(){return f?f.toArray():[...c]},get anyCompletedCleanly(){return b},get anyErrored(){return x},get completedWithoutErrors(){return b&&!x},onEvent(S){return h.add(S),()=>h.delete(S)},dispose:F,expand(S){F();let B={...t};return typeof S=="string"?B.detail=S:Object.assign(B,S),n(Lr(B))},[Symbol.asyncIterator](){return{next(){return re.length>0?Promise.resolve({value:re.shift(),done:!1}):L?Promise.resolve({value:void 0,done:!0}):new Promise(S=>W.push(S))},return(){return F(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(se,t),se}_attachFormatLogger(e,t){let n=t.format;if(n==null)return;let s=t.logger??(p=>console.log(p)),o=t.includeTypes?new Set(t.includeTypes):null,i=t.excludeTypes?new Set(t.excludeTypes):null,a=o==null&&i==null?()=>!0:p=>(o==null||o.has(p))&&(i==null||!i.has(p)),u=rs(t.theme),d=n==="stage-log"?U():0,l=p=>p==null?"":t.stageLabels?.[p]??p,f=(p,g)=>p.length>g?`${p.slice(0,g-1)}\u2026`:p,c=p=>p.type==="data"||p.type==="error"?f(Sn(p.data),120):"",h=p=>{if(n==="stage-log"){let b=(U()-d)/1e9,x=l(p.path).padEnd(9);if(p.type==="data"){let E=c(p);return`[${b.toFixed(3)}s] ${x} \u2190${E?` ${E}`:""}`}if(p.type==="error"){let E=c(p);return`[${b.toFixed(3)}s] ${x} \u2717${E?` ${E}`:""}`}return p.type==="complete"?`[${b.toFixed(3)}s] ${x} \u25A0 complete`:`[${b.toFixed(3)}s] ${x} ${p.type}`}if(n==="json")try{return JSON.stringify(p)}catch{return JSON.stringify({type:p.type,path:p.path,data:"[unserializable]"})}let g=u[p.type]??"",m=p.path?`${u.path}${p.path}${u.reset} `:"",v=p.type==="data"||p.type==="error",T=p.type==="pause"||p.type==="resume",y=v?` ${Sn(p.data)}`:T?` ${Sn(p.lockId)}`:"",_=p.type==="data"||p.type==="resolved"||p.type==="derived"?p:void 0,w=_?.trigger_dep_name!=null?` <- ${_.trigger_dep_name}`:_?.trigger_dep_index!=null?` <- #${_.trigger_dep_index}`:"",N=p.in_batch?" [batch]":"";return`${m}${g}${p.type.toUpperCase()}${u.reset}${y}${w}${N}`};e.onEvent(p=>{a(p.type)&&s(h(p),p)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){Kt(this._disposers,this.name),this.signal([[pe]],{internal:!0}),Kt(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){Kt(this._disposers,this.name),Kt(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand:t,...n}=this.describe({detail:"full"}),s={};for(let a of Object.keys(n.nodes).sort()){let{lastMutation:u,guard:d,...l}=n.nodes[a];s[a]=l}let o=[...n.subgraphs].sort(),i={...n,version:1,nodes:s,subgraphs:o};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(e.codec);if(a==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return nr(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let n=t?.config??ot,{codec:s,codecVersion:o,payload:i}=rr(e,n);return s.decode(i,o)}restore(e,t){if(Pr(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let n=t?.only==null?null:(Array.isArray(t.only)?t.only:[t.only]).map(o=>Ut(o)),s=t?.includeProducers===!0;for(let o of Object.keys(e.nodes).sort()){if(n!==null&&!n.some(a=>a.test(o)))continue;let i=e.nodes[o];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&t?.onError?.(o,new Error(`restore: slice.value is undefined for "${o}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!s)){if(i.v!=null){let u=this.tryResolve(o)?.v;if(u!=null&&u.id===i.v.id&&u.version===i.v.version)continue}try{this.set(o,i.value)}catch(a){t?.onError?.(o,a)}}}}}static fromSnapshot(e,t){Pr(e);let n=typeof t=="function"?t:t?.build,s=typeof t=="function"?void 0:t?.factories,o=new r(e.name);if(n)return n(o),o.restore(e),o;for(let h of[...e.subgraphs].sort((p,g)=>{let m=p.split(Q).length,v=g.split(Q).length;return m!==v?m-v:p<g?-1:p>g?1:0})){let p=h.split(Q),g=o;for(let m of p)g._mounts.has(m)||g.mount(m,new r(m)),g=g._mounts.get(m)}let i=s?Object.entries(s).map(([h,p])=>({re:Ut(h),factory:p})):[],a=h=>{for(let p of i)if(p.re.test(h))return p.factory},u=h=>{let p=h.split(Q),g=p.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${h}"`);let m=o;for(let v of p){let T=m._mounts.get(v);if(!T)throw new Error(`unknown mount "${v}" in path "${h}"`);m=T}return[m,g]},d=Object.entries(e.nodes).filter(([h])=>!h.includes(`${Q}${Se}${Q}`)).sort((h,p)=>h[0]<p[0]?-1:h[0]>p[0]?1:0),l=new Map(d),f=new Map,c=!0;for(;l.size>0&&c;){c=!1;for(let[h,p]of[...l.entries()]){let g=p?.deps??[];if(!g.every(w=>f.has(w)))continue;let[m,v]=u(h),T={...p?.meta??{}},y=a(h),_;if(p?.type==="state")_=V(p.value,{meta:T});else{if(y==null)continue;_=y(v,{path:h,type:p.type,value:p.value,meta:T,deps:g,resolvedDeps:g.map(w=>f.get(w))})}m.add(_,{name:v}),f.set(h,_),l.delete(h),c=!0}}if(l.size>0){let h=[...l.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${h}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return o.restore(e),o}toJSON(){return this.snapshot()}attachSnapshotStorage(e,t={}){let n=e.map(d=>({tier:d,debounceMs:Math.max(0,d.debounceMs??0),compactEvery:Math.max(1,d.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));t.autoRestore===!0&&this._cascadeRestore(e,t.onError);let s=(d,l)=>{if(d.disposed)return;let f=Xo(l.nodes);if(d.lastSnapshot!=null&&f!==""&&f===d.lastFingerprint)return;let c=d.seq+1,h=Me(),m=d.lastSnapshot==null||c%d.compactEvery===0?{name:this.name,mode:"full",snapshot:l,seq:c,timestamp_ns:h,format_version:Qe}:{name:this.name,mode:"diff",diff:Vr(d.lastSnapshot,l),seq:c,timestamp_ns:h,format_version:Qe};if(d.tier.filter&&!d.tier.filter(m))return;let v;try{v=d.tier.save(m)}catch(T){t.onError?.(T,d.tier);return}if(v&&typeof v.then=="function"){let _=(d.savePending??Promise.resolve()).then(()=>v,()=>v).then(()=>{d.disposed||(d.seq=c,d.lastSnapshot=l,d.lastFingerprint=f)},w=>{t.onError?.(w,d.tier)});d.savePending=_.finally(()=>{d.savePending===_&&(d.savePending=void 0)})}else d.seq=c,d.lastSnapshot=l,d.lastFingerprint=f},o=(d,l)=>{try{s(d,l)}catch(f){t.onError?.(f,d.tier)}},i=(d,l)=>{if(!l.some(p=>{let g=this.config.messageTier(p[0]);return g>=3&&g<5}))return;if(t.filter){let p=this.tryResolve(d);if(p==null)return;let g=_n(p,Pt("standard"));if(!t.filter(d,g))return}let c,h=()=>(c==null&&(c=this.snapshot()),c);for(let p of n)p.disposed||(p.debounceMs===0?o(p,h()):(p.timer==null&&(p.timer=new jt),p.timer.start(p.debounceMs,()=>{p.disposed||o(p,this.snapshot())})))},a;if(t.paths!=null){let l=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(f=>{let c=this.tryResolve(f);return c==null?()=>{}:c.subscribe(h=>i(f,h))});a=()=>{for(let f of l)f()}}else a=this.observe().subscribe((d,l)=>i(d,l));let u=()=>{a();for(let d of n)d.disposed=!0,d.timer?.cancel();this._storageDisposers.delete(u)};return this._storageDisposers.add(u),{dispose:u}}async _cascadeRestore(e,t){for(let n of e){let s;try{s=await n.load?.()}catch(i){t?.(i,n);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let o=s;try{if(o.mode==="full"&&o.snapshot!=null)return this.restore(o.snapshot),!0;if(o.version===Qe&&o.nodes!=null)return this.restore(o),!0}catch(i){t?.(i,n)}}return!1}static async fromStorage(e,t,n){for(let s of t){let o;try{o=await s.load?.()}catch(u){n?.onError?.(u,s);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let i=o,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===Qe&&i.nodes!=null?i:void 0;if(a!=null)try{return r.fromSnapshot(a,n)}catch(u){n?.onError?.(u,s)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${t.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,t,n){if(e!=null&&t!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,t),this.config.inspectorEnabled){let s={path:e,annotation:t,timestamp_ns:U(),...n?.actor!=null?{actor:n.actor}:{}};this._traceRing.push(s)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let t=this._traceRing.toArray().filter(s=>!e(s)),n=this._traceRing.size-t.length;this._traceRing.clear();for(let s of t)this._traceRing.push(s);return n}static diff(e,t){let n=new Set(Object.keys(e.nodes)),s=new Set(Object.keys(t.nodes)),o=[...s].filter(T=>!n.has(T)).sort(),i=[...n].filter(T=>!s.has(T)).sort(),a=[],u=[];for(let T of n){if(!s.has(T))continue;let y=e.nodes[T],_=t.nodes[T],w=y.v,N=_.v;w!=null&&N!=null&&w.id===N.id&&w.version!==N.version&&u.push({path:T,id:w.id,from:w.version,to:N.version});let b=w!=null&&N!=null&&w.id===N.id&&w.version===N.version;for(let x of["type","status","sentinel"]){let E=y[x],A=_[x];E!==A&&a.push({path:T,field:x,from:E,to:A})}if(!b)for(let x of["value","meta"]){let E=y[x],A=_[x];Zo(E,A)||a.push({path:T,field:x,from:E,to:A})}}let d=T=>`${T.from} ${T.to}`,l=new Set(e.edges.map(d)),f=new Set(t.edges.map(d)),c=t.edges.filter(T=>!l.has(d(T))),h=e.edges.filter(T=>!f.has(d(T))),p=new Set(e.subgraphs),g=new Set(t.subgraphs),m=[...g].filter(T=>!p.has(T)).sort(),v=[...p].filter(T=>!g.has(T)).sort();return{nodesAdded:o,nodesRemoved:i,nodesChanged:a,versionChanges:u,edgesAdded:c,edgesRemoved:h,subgraphsAdded:m,subgraphsRemoved:v}}}});function He(r,e,t){return{[r]:!0,[`${r}_type`]:e,...t??{}}}var _t=J(()=>{"use strict"});var Pn=J(()=>{"use strict";Tt()});var Gs={};ao(Gs,{DEFAULT_DECAY_RATE:()=>ut,DEFAULT_EXECUTE_PROMPT:()=>Nn,DEFAULT_QUEUE_CONFIGS:()=>$t,DEFAULT_SEVERITY_WEIGHTS:()=>at,DEFAULT_TRIAGE_PROMPT:()=>xn,DEFAULT_VERIFY_PROMPT:()=>En,HarnessGraph:()=>nn,QUEUE_NAMES:()=>ke,actuatorExecutor:()=>vr,affectedTaskFilter:()=>Vo,autoSolidify:()=>Do,beforeAfterCompare:()=>$o,blindVariation:()=>ms,codeChangeBridge:()=>jo,createIntakeBridge:()=>Po,defaultErrorClassifier:()=>Vt,defaultLlmExecutor:()=>eo,defaultLlmVerifier:()=>to,dispatchActuator:()=>So,effectivenessTracker:()=>Bo,errorCritique:()=>ys,evalIntakeBridge:()=>Lo,evalSource:()=>Fo,evalVerifier:()=>Br,harnessEvalPair:()=>xs,harnessLoop:()=>As,harnessProfile:()=>Ds,harnessTrace:()=>Ms,notifyEffect:()=>zo,priorityScore:()=>Rs,refineExecutor:()=>Bn,refineLoop:()=>Hn,resolvePromptFn:()=>yt,strategyKey:()=>dt,strategyModel:()=>Qn});module.exports=lo(Gs);Te();oe();Pe();function ko(r,e){return{outcome:"success",detail:`actuator applied ${e.intervention} for ${Ao(e.summary)}`,artifact:r}}function Ro(r,e){let t=r instanceof Error?r.message:String(r);return{outcome:"failure",detail:`actuator threw on ${e.intervention}: ${t}`}}function Oo(r){return`actuator skipped ${r.intervention} (shouldApply returned false)`}function Ao(r,e=80){return r.length<=e?r:`${r.slice(0,e-1)}\u2026`}function vr(r){let e=r.name??"actuator-executor",t=r.toOutput??ko,n=r.onError??Ro,s=r.skipDetail??Oo;return(o,i)=>{let a=o.payload.item;return r.shouldApply&&!r.shouldApply(a)?{...o.payload,execution:{item:a,outcome:"failure",detail:s(a)}}:he(u=>{let d=new AbortController,l=i?.signal,f=()=>{};if(l)if(l.aborted)d.abort();else{let m=()=>d.abort();l.addEventListener("abort",m,{once:!0}),f=()=>l.removeEventListener("abort",m)}let c=!1,h=null,p=m=>{c||(c=!0,u.down([[M,{...o.payload,execution:{item:a,...m}}],[j]]),h?.(),h=null)},g;try{let m=r.apply(a,{signal:d.signal});g=Ee(m,{signal:d.signal})}catch(m){return p(n(m,a)),()=>{f(),d.abort()}}return h=g.subscribe(m=>{for(let v of m){if(c)return;if(v[0]===M){p(t(v[1],a));return}if(v[0]===I){p(n(v[1],a));return}if(v[0]===j){p(n(new Error("actuator inner completed without emitting DATA"),a));return}}}),c&&h&&(h(),h=null),()=>{f(),d.abort(),h?.(),h=null}},{name:`${e}/inner`})}}function So(r){let e=r.name??"dispatch-actuator",t=r.default??null,n=t!=null;return vr({apply:(s,o)=>{let i=Object.hasOwn(r.routes,s.intervention)?r.routes[s.intervention]:t;if(!i)throw new Error(`dispatchActuator: no route for intervention '${s.intervention}'`);return i(s,o)},shouldApply:s=>Object.hasOwn(r.routes,s.intervention)||n,skipDetail:s=>`no route for intervention '${s.intervention}'`,name:e})}Te();oe();function Do(r){let e=r.name??"auto-solidify",t=r.extract??(s=>s.execution.artifact??null),n=r.predicate??(()=>!0);return he(s=>{let o=null,i=!1,a=()=>{i||(i=!0,o?.(),o=null)},u=d=>{i||(s.down([[I,d]]),a())};return o=r.verifyResults.subscribe(d=>{if(!i)for(let l of d){if(i)return;if(l[0]!==M){if(l[0]===j){s.down([[j]]),a();return}continue}let f=l[1];if(f==null||!f.verified)continue;let c;try{c=n(f)}catch(p){u(p);return}if(!c)continue;let h;try{h=t(f)}catch(p){u(p);return}if(h!=null){try{r.write(h,f)}catch(p){u(p);return}s.down([[M,h]])}}}),i&&o&&(o(),o=null),()=>{a()}},{name:e})}oe();Ye();Pe();function Po(r,e,t,n){return le([r],([s])=>{if(s==null)return;let o=t(s);for(let i of o)e.publish(i)},{name:n?.name??"intake-bridge"})}function Lo(r,e,t){let n=t?.defaultSeverity??"medium";return le([r],([s])=>{if(s==null)return;let o=Array.isArray(s)?s:[s];for(let i of o)for(let a of i.tasks)if(!(a.valid&&a.judge_scores?.every(u=>u.pass))){if(!a.valid&&(!a.judge_scores||a.judge_scores.length===0)){e.publish({source:"eval",summary:`Task ${a.task_id} invalid (model: ${i.model})`,evidence:`Run ${i.run_id}: task produced invalid output`,affectsAreas:["graphspec"],affectsEvalTasks:[a.task_id],severity:n});continue}if(a.judge_scores)for(let u of a.judge_scores)u.pass||e.publish({source:"eval",summary:`${a.task_id}: ${u.claim} (model: ${i.model})`,evidence:u.reasoning,affectsAreas:["graphspec"],affectsEvalTasks:[a.task_id],severity:n})}},{name:t?.name??"eval-intake-bridge"})}function Fo(r,e){return it(r,()=>Ee(e()))}function $o(r,e){return G([r,e],([t,n])=>{let s=t,o=n,i=new Map(s.tasks.map(c=>[c.task_id,c])),a=new Map(o.tasks.map(c=>[c.task_id,c])),u=new Set([...i.keys(),...a.keys()]),d=[],l=[],f=[];for(let c of u){let h=i.get(c),p=a.get(c),g=h?.valid??!1,m=p?.valid??!1,v=h?.judge_scores?h.judge_scores.filter(_=>_.pass).length:void 0,T=p?.judge_scores?p.judge_scores.filter(_=>_.pass).length:void 0,y=v!==void 0&&T!==void 0?T-v:void 0;d.push({taskId:c,before:g,after:m,scoreDiff:y}),g&&!m&&l.push(c),!g&&m&&f.push(c)}return{newFailures:l,resolved:f,taskDeltas:d,overallImproved:f.length>l.length}},{name:"eval-delta"})}function Vo(r,e){let t=e==null?null:Array.isArray(e)?V(e):e,n=[r];return t&&n.push(t),G(n,s=>{let o=s[0],i=t?new Set(s[1]):null,a=new Set;for(let u of o)for(let d of u.affectsEvalTasks??[])(i==null||i.has(d))&&a.add(d);return[...a].sort()},{name:"affected-task-filter"})}function jo(r,e,t,n){let s=n?.defaultSeverity??"high";function o(a){let u=[];for(let d of a.lintErrors??[])u.push({source:"code-change",summary:`Lint: ${d.rule} in ${d.file}:${d.line}`,evidence:d.message,affectsAreas:[d.file],severity:s});for(let d of a.testFailures??[])u.push({source:"test",summary:`Test failure: ${d.testId}`,evidence:d.message,affectsAreas:[d.file],affectsEvalTasks:[d.testId],severity:s});return u}let i=t??o;return le([r],([a])=>{if(a!=null)for(let u of i(a))e.publish(u)},{name:n?.name??"code-change-bridge"})}function zo(r,e,t){return le([r.latest],([n])=>{n!=null&&e(n)},{name:t?.name??"notify-effect"})}var ke=["auto-fix","needs-decision","investigation","backlog"],$t={"auto-fix":{gated:!1},"needs-decision":{gated:!0},investigation:{gated:!0},backlog:{gated:!1}},at={critical:100,high:70,medium:40,low:10},ut=Math.LN2/(168*3600);function dt(r,e){return`${r}\u2192${e}`}var Ho=/\b(parse|json|config|validation|syntax)\b/i,Vt=r=>Ho.test(r.detail)?"self-correctable":"structural",xn=`You are a triage classifier for a reactive collaboration harness.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Issue:
|
|
23
|
-
{{item}}
|
|
24
|
-
|
|
25
|
-
Output JSON:
|
|
26
|
-
{
|
|
27
|
-
"outcome": "success" | "failure" | "partial",
|
|
28
|
-
"detail": "<description of what was done or what failed>"
|
|
29
|
-
}`,En=`You are a QA reviewer.
|
|
30
|
-
|
|
31
|
-
Given an execution result, verify whether the fix is correct.
|
|
32
|
-
|
|
33
|
-
Execution:
|
|
34
|
-
{{execution}}
|
|
35
|
-
|
|
36
|
-
Original issue:
|
|
37
|
-
{{item}}
|
|
38
|
-
|
|
39
|
-
Output JSON:
|
|
40
|
-
{
|
|
41
|
-
"verified": true/false,
|
|
42
|
-
"findings": ["<finding1>", ...],
|
|
43
|
-
"errorClass": "self-correctable" | "structural" // only if verified=false
|
|
44
|
-
}`;function yt(r,e,t){if(typeof r=="function")return r;let n=r??e;return s=>t(n,s)}oe();Ce();Oe();Te();oe();var kn=class{_version=0;_store=new Map;_maxSize;_defaultTtl;constructor(e={}){let{maxSize:t,defaultTtl:n}=e;if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(n!==void 0&&n<=0)throw new RangeError("defaultTtl must be positive");this._maxSize=t,this._defaultTtl=n}get version(){return this._version}get size(){return this._store.size}has(e){let t=this._store.get(e);return t===void 0?!1:this._isExpired(t)?(this._store.delete(e),this._version+=1,!1):(this._touchLru(e,t),!0)}get(e){let t=this._store.get(e);if(t!==void 0){if(this._isExpired(t)){this._store.delete(e),this._version+=1;return}return this._touchLru(e,t),t.value}}set(e,t,n){let s=this._resolveExpiresAt(n);this._store.has(e)&&this._store.delete(e),this._store.set(e,{value:t,expiresAt:s}),this._evictLruWhileOver(),this._version+=1}setMany(e,t){let n=this._resolveExpiresAt(t),s=0;try{for(let[o,i]of e)this._store.has(o)&&this._store.delete(o),this._store.set(o,{value:i,expiresAt:n}),s+=1}finally{s>0&&(this._evictLruWhileOver(),this._version+=1)}}delete(e){let t=this._store.delete(e);return t&&(this._version+=1),t}deleteMany(e){let t=0;try{for(let n of e)this._store.delete(n)&&(t+=1)}finally{t>0&&(this._version+=1)}return t}clear(){let e=this._store.size;return e===0?0:(this._store.clear(),this._version+=1,e)}pruneExpired(){let e=U(),t=0;for(let[n,s]of this._store)this._isExpired(s,e)&&(this._store.delete(n),t+=1);return t>0&&(this._version+=1),t}toMap(){let e=U(),t=new Map;for(let[n,s]of this._store)this._isExpired(s,e)||t.set(n,s.value);return t}_resolveExpiresAt(e){let t=e??this._defaultTtl;if(t!==void 0){if(!Number.isFinite(t)||t<=0)throw new RangeError(`MapBackend: ttl must be a positive finite number (got ${t})`);return U()+t*1e9}}_isExpired(e,t){return e.expiresAt===void 0?!1:(t??U())>=e.expiresAt}_touchLru(e,t){this._store.delete(e),this._store.set(e,t)}_evictLruWhileOver(){if(this._maxSize!==void 0)for(;this._store.size>this._maxSize;){let e=this._store.keys().next().value;if(e===void 0)break;this._store.delete(e)}}};function lt(r={}){let{name:e,maxSize:t,defaultTtl:n,versioning:s,backend:o,retention:i}=r;if(i&&t!==void 0)throw new RangeError("reactiveMap: `maxSize` (LRU) and `retention` (score-based) are mutually exclusive. Pick one eviction policy.");if(i&&i.archiveThreshold===void 0&&i.maxSize===void 0)throw new RangeError("reactiveMap: `retention` requires at least one of `archiveThreshold` or `maxSize` to trigger archival.");let a=o??new kn({maxSize:t,defaultTtl:n}),u=V(a.toMap(),{name:e,describeKind:"state",equals:(c,h)=>c===h,...s!=null?{versioning:s}:{}});function d(){let c=a.toMap();K(()=>{u.down([[Z]]),u.down([[M,c]])})}function l(){if(!i)return;let c=a.toMap(),h=i.archiveThreshold,p=i.maxSize,g=[];for(let[v,T]of c)g.push({key:v,value:T,score:i.score(v,T)});g.sort((v,T)=>v.score-T.score);let m=new Set;if(h!==void 0)for(let v of g)if(v.score<h)m.add(v.key);else break;if(p!==void 0&&g.length-m.size>p)for(let v of g){if(g.length-m.size<=p)break;m.has(v.key)||m.add(v.key)}if(m.size!==0)for(let v of g)m.has(v.key)&&(i.onArchive?.(v.key,v.value,v.score),a.delete(v.key))}function f(c,h="mutation"){let p=a.version;try{return c()}finally{a.version!==p&&(h==="mutation"&&l(),d())}}return{entries:u,has(c){return f(()=>a.has(c),"read")},get(c){return f(()=>a.get(c),"read")},set(c,h,p){f(()=>a.set(c,h,p?.ttl))},setMany(c,h){f(()=>a.setMany(c,h?.ttl))},delete(c){f(()=>a.delete(c))},deleteMany(c){f(()=>a.deleteMany(c))},clear(){f(()=>a.clear())},pruneExpired(){f(()=>a.pruneExpired())},get size(){return a.size},dispose(){}}}Pe();function Bo(r){let e=lt({name:r?.name??"effectiveness-entries"}),t=G([e.entries],([i])=>new Map(i),{name:`${r?.name??"effectiveness"}-snapshot`,equals:(i,a)=>{let u=i,d=a;if(u.size!==d.size)return!1;for(let[l,f]of u){let c=d.get(l);if(!c||f.attempts!==c.attempts||f.successes!==c.successes)return!1}return!0}});function n(i,a){let u=e.get(i),d=(u?.attempts??0)+1,l=(u?.successes??0)+(a?1:0);e.set(i,{key:i,attempts:d,successes:l,successRate:l/d})}function s(i){return e.get(i)}let o=me(t);return{node:t,record:n,lookup:s,dispose:()=>{o(),e.dispose()}}}Ce();oe();Ye();oe();Ye();Ce();Oe();Te();Ie();oe();Ye();Tt();Mt();Ce();rt();Te();st();oe();Ie();_t();Ce();Oe();rt();Te();oe();Ce();Te();Ie();oe();var Mn=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,t){if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=t,t!==void 0){if(this._buf=new Array(t),e&&e.length>0){let n=Math.min(e.length,t),s=e.length-n;for(let o=0;o<n;o++)this._buf[o]=e[s+o];this._size=n}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let t=e>=0?e:this._size+e;if(!(t<0||t>=this._size))return this._maxSize!==void 0?this._buf[(this._head+t)%this._maxSize]:this._buf[t]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let t=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let n=t;n<e.length;n++)this._rawAppend(e[n]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let t=0;t<e;t++)this._buf[(this._head+t)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let t=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,t);else{for(let n=0;n<t;n++)this._buf[(this._head+n)%this._maxSize]=void 0;this._head=(this._head+t)%this._maxSize}return this._size-=t,this._version+=1,t}slice(e,t){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${t})`);let n=t===void 0?this._size:Math.min(Math.max(t,0),this._size),s=Math.min(e,this._size);if(s>=n)return[];let o=n-s;if(this._maxSize===void 0)return this._buf.slice(s,n);let i=new Array(o);for(let a=0;a<o;a++)i[a]=this._buf[(this._head+s+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let t=Math.min(e,this._size);return this.slice(this._size-t,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this._buf[(this._head+t)%this._maxSize];return e}snapshot(){return this.toArray()}restore(e){if(this._maxSize===void 0){this._buf.length=0;for(let t=0;t<e.length;t++)this._buf.push(e[t]);this._size=this._buf.length}else{let t=this._maxSize;for(let o=0;o<t;o++)this._buf[o]=void 0;this._head=0;let n=Math.min(e.length,t),s=e.length-n;for(let o=0;o<n;o++)this._buf[o]=e[s+o];this._size=n}this._version+=1}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function wt(r){return r.subscribe(()=>{})}var us=64;function ct(r,e={}){let{name:t,maxSize:n,versioning:s,guard:o,backend:i}=e,a=i??new Mn(r,n),u=V(a.toArray(),{name:t,describeKind:"state",equals:(b,x)=>b===x,...s!=null?{versioning:s}:{},...o!=null?{guard:o}:{}});function d(){let b=a.toArray();K(()=>{u.down([[Z]],{internal:!0}),u.down([[M,b]],{internal:!0})})}let l=new Map,f=new Map,c=new Map;function h(b,x){return`${b}:${x===void 0?"END":x}`}function p(b){if(b.size<us)return;let x=b.keys().next();if(x.done)return;let E=b.get(x.value);E!==void 0&&E.dispose(),b.delete(x.value)}function g(b){let x=a.version;try{return b()}finally{a.version!==x&&d()}}function m(b){if(!Number.isInteger(b)||b<0)throw new RangeError(`tail: n must be a non-negative integer (got ${b})`);let x=l.get(b);if(x!==void 0)return l.delete(b),l.set(b,x),x.node;p(l);let E=G([u],([k])=>{let C=k;return b===0||C.length===0?[]:C.slice(Math.max(0,C.length-b))},{initial:a.tail(b),describeKind:"derived"}),A=wt(E);return l.set(b,{node:E,dispose:A}),E}function v(b,x){if(!Number.isInteger(b)||b<0)throw new RangeError(`slice: start must be a non-negative integer (got ${b})`);if(x!==void 0&&(!Number.isInteger(x)||x<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${x})`);let E=h(b,x),A=f.get(E);if(A!==void 0)return f.delete(E),f.set(E,A),A.node;p(f);let k=G([u],([H])=>{let z=H;return x===void 0?z.slice(b):z.slice(b,x)},{initial:a.slice(b,x),describeKind:"derived"}),C=wt(k);return f.set(E,{node:k,dispose:C}),k}function T(b){let x=c.get(b);if(x!==void 0)return x.node;let E=G([u,b],([k,C])=>{let H=k,z=Math.max(0,Math.trunc(C??0));return H.slice(z)},{initial:[],describeKind:"derived"}),A=wt(E);return c.set(b,{node:E,dispose:A}),E}let y,_;function w(){y===void 0&&(y=te([u],(b,x,E)=>{let A=b[0],C=A!=null&&A.length>0?A.at(-1):E.prevData[0];if(C==null||C.length===0){x.down([[Y]]);return}x.emit(C[C.length-1])},{name:t!=null?`${t}::lastValue`:"lastValue",describeKind:"derived",initial:a.size===0?void 0:a.at(a.size-1)}),_=G([u],([b])=>b.length>0,{name:t!=null?`${t}::hasLatest`:"hasLatest",describeKind:"derived",initial:a.size>0}),wt(y),wt(_))}let N={entries:u,get size(){return a.size},at(b){return a.at(b)},append(b){g(()=>a.append(b))},appendMany(b){b.length!==0&&g(()=>a.appendMany(b))},clear(){g(()=>a.clear())},trimHead(b){g(()=>a.trimHead(b))},withLatest(){return w(),u},get lastValue(){return w(),y},get hasLatest(){return w(),_},view(b){switch(b.kind){case"tail":return m(b.n);case"slice":return v(b.start,b.stop);case"fromCursor":return T(b.cursor)}},attach(b){let x=b.subscribe(E=>{for(let A of E)A[0]===M&&N.append(A[1])});return()=>x()},attachStorage(b){if(b.length===0)return()=>{};let x=new Map;for(let A of b)x.set(A,a.size);(async()=>{for(let A of b)if(typeof A.loadEntries=="function")try{let k=await Promise.resolve(A.loadEntries());k.entries.length>0&&a.size===0&&(a.restore(k.entries),x.set(A,k.entries.length),d());break}catch{}})();let E=u.subscribe(A=>{for(let k of A){if(k[0]!==M)continue;let C=k[1];for(let H of b){let z=x.get(H)??0;if(C.length<z){try{let ne=H.appendEntries(C);ne instanceof Promise&&ne.catch(()=>{})}catch{}x.set(H,C.length);continue}if(C.length===z)continue;let fe=C.slice(z);x.set(H,C.length);try{let ne=H.appendEntries(fe);ne instanceof Promise&&ne.catch(()=>{})}catch{}}}});return()=>E()},disposeAllViews(){for(let b of l.values())b.dispose();l.clear();for(let b of f.values())b.dispose();f.clear();for(let b of c.values())b.dispose();c.clear()},dispose(){for(let b of l.values())b.dispose();l.clear();for(let b of f.values())b.dispose();f.clear();for(let b of c.values())b.dispose();c.clear()}};return N}function In(r,e){let t=r.cache??0;return t>=e?!1:(r.down([[Z],[M,t+1]]),!0)}var ds=dr((r,e)=>{r("observe"),r("signal"),e("write")});function Jt(r){let e=ct([],{name:r.name,maxSize:r.retainedLimit??1024,guard:r.guard??ds,...r.versioning!=null?{versioning:r.versioning}:{}});return e.withLatest(),r.graph&&r.graph.add(e.entries,{name:r.name}),e}function Gn(r){if(r===null||typeof r!="object"||Object.isFrozen(r))return r;for(let e of Object.keys(r))Gn(r[e]);return Object.freeze(r)}var jr=new WeakSet;function Yt(r){let e=r.cache,t=typeof e=="number"&&Number.isFinite(e);!t&&e!==void 0&&!jr.has(r)&&(jr.add(r),console.warn(`bumpCursor: cursor cache held a non-numeric value (${String(e)}); resetting to 0. Causes include: a snapshot codec round-tripping the cursor as a string / null / NaN, OR a malformed initial seed (e.g. state<number>(NaN)). Audit consumers may see colliding seq values after this point.`));let s=(t?e:0)+1;return r.down([[Z],[M,s]]),s}function Wt(r,e,t,n,s,o){let i=e(t,n,s);if(i===void 0)return;let a=o!=null?{...i,handlerVersion:o}:i;r.append(a)}function Le(r,e){let t=e.freeze??!0;return function(...s){let o=t?s.map(Gn):s,i=Me(),a=e.seq?Yt(e.seq):void 0;try{let u=r(...o);return e.audit&&e.onSuccess&&Wt(e.audit,e.onSuccess,o,u,{t_ns:i,seq:a},e.handlerVersion),u}catch(u){if(e.audit&&e.onFailure){let d=u instanceof Error?u.name:typeof u;Wt(e.audit,e.onFailure,o,u,{t_ns:i,seq:a,errorType:d},e.handlerVersion)}throw u}}}function ft(r,e){let t=e.freeze??!0;return function(...s){let o=t?s.map(Gn):s,i=Me(),a,u,d=!1,l;try{K(()=>{e.seq&&(l=Yt(e.seq));try{a=r(...o),e.audit&&e.onSuccess&&Wt(e.audit,e.onSuccess,o,a,{t_ns:i,seq:l},e.handlerVersion)}catch(f){throw u=f,d=!0,f}})}catch(f){if(d&&e.audit&&e.onFailure){let c=u instanceof Error?u.name:typeof u;Wt(e.audit,e.onFailure,o,u,{t_ns:i,seq:l,errorType:c},e.handlerVersion)}throw d?u:f}return a}}function zr(r,e,t=0){let n=V(t,{name:e,describeKind:"state"});return r.add(n,{name:e}),n}Pe();Pn();var ls=256;function pt(r,e){if(!Number.isFinite(r)||!Number.isInteger(r)||r<0)throw new Error(`${e} must be a non-negative integer`);return r}function Be(r,e){return He("messaging",r,e)}var cs=1024,Ln=class extends ge{_log;_publishImpl;events;latest;hasLatest;constructor(e,t={}){super(e,t.graph),this._log=ct([],{name:"events",maxSize:t.retainedLimit??cs}),this._log.withLatest(),this.events=this._log.entries,this.add(this.events,{name:"events"}),this.latest=G([this.events],([n])=>{let s=n;return s.length===0?null:s[s.length-1]},{name:"latest",describeKind:"derived",meta:Be("topic_latest")}),this.add(this.latest,{name:"latest"}),this.addDisposer(me(this.latest)),this.hasLatest=G([this.events],([n])=>n.length>0,{name:"hasLatest",describeKind:"derived",meta:Be("topic_has_latest")}),this.add(this.hasLatest,{name:"hasLatest"}),this.addDisposer(me(this.hasLatest)),this.addDisposer(()=>{this.events.down([[j]])}),this.addDisposer(()=>this._log.disposeAllViews()),this._publishImpl=Le(n=>{this._log.append(n)},{freeze:!1})}publish(e){if(e===void 0)throw new TypeError(`TopicGraph "${this.name}": publish(undefined) is not allowed (spec \xA75.12 SENTINEL).`);this._publishImpl(e)}attachEventStorage(e){return this._log.attachStorage(e)}retained(){return this.events.cache}get _logBundle(){return this._log}},Qt=class extends ge{cursor;available;topic;_disposed=!1;_ackImpl;_pullAndAckImpl;constructor(e,t,n={}){super(e,n.graph),this.topic=t;let s;if(n.from!==void 0?n.from==="retained"?s=0:n.from==="now"?s=t.events.cache.length:s=pt(n.from,"subscription from"):s=pt(n.cursor??0,"subscription cursor"),this.cursor=V(s,{name:"cursor",describeKind:"state",meta:Be("subscription_cursor")}),this.add(this.cursor,{name:"cursor"}),this.available=t._logBundle.view({kind:"fromCursor",cursor:this.cursor}),this.add(this.available,{name:"available"}),this.addDisposer(me(this.available)),n.advanceOn!==void 0){let o=n.advanceOn,i=!1,a=te([o],()=>{if(!i){i=!0;return}if(this._disposed)return;let u=this.available.cache;if(u.length===0)return;let d=this.cursor.cache+u.length;this.cursor.emit(d)},{name:"advancePump",describeKind:"effect",meta:Be("subscription_advance_pump")});this.add(a,{name:"advancePump"}),this.addDisposer(me(a))}this._ackImpl=Le(o=>{let i=this.available.cache,a=o===void 0?i.length:pt(o,"subscription ack count"),u=Math.min(a,i.length);if(u<=0)return this.cursor.cache;let d=this.cursor.cache+u;return this.cursor.emit(d),d},{freeze:!1}),this._pullAndAckImpl=Le(o=>{let i=this.available.cache,a=o===void 0?i.length:pt(o,"subscription pullAndAck limit"),u=i.slice(0,a);if(u.length===0)return{items:u,cursor:this.cursor.cache};let d=this.cursor.cache+u.length;return this.cursor.emit(d),{items:u,cursor:d}},{freeze:!1})}ack(e){return this._disposed?this.cursor.cache:this._ackImpl(e)}pull(e){if(this._disposed)return[];let t=this.available.cache,n=e===void 0?t.length:pt(e,"subscription pull limit");return t.slice(0,n)}pullAndAck(e){return this._disposed?{items:[],cursor:this.cursor.cache}:this._pullAndAckImpl(e)}dispose(){this._disposed||(this._disposed=!0,this.cursor.down([[j]]),this.destroy())}},Fn=class extends ge{_sourceSub;bridgedCount;output;constructor(e,t,n,s={}){super(e,s.graph),this._sourceSub=ps(`${e}-subscription`,t,{cursor:s.cursor}),this.mount("subscription",this._sourceSub);let o=Math.max(1,pt(s.maxPerPump??ls,"topic bridge maxPerPump")),i=s.map??(c=>c);this.output=G([this._sourceSub.available],([c])=>{let h=c,p=[],g=Math.min(h.length,o);for(let m=0;m<g;m++){let v=i(h[m]);v!==void 0&&p.push(v)}return p},{name:"output",describeKind:"derived",meta:Be("topic_bridge_output",{targetRef:n.name}),initial:[]}),this.add(this.output,{name:"output"}),this.addDisposer(me(this.output)),this.bridgedCount=V(0,{name:"bridgedCount",describeKind:"state",meta:Be("topic_bridge_count")}),this.add(this.bridgedCount,{name:"bridgedCount"}),this.addDisposer(me(this.bridgedCount));let a=this.output,u=this._sourceSub,d=this.bridgedCount,l=te([a],()=>{let c=a.cache;if(c.length===0)return;let h=u.available.cache.length,p=Math.min(h,o);if(p>0){u.ack(p);let g=d.cache??0;d.emit(g+c.length)}},{name:"ackPump",describeKind:"effect",meta:Be("topic_bridge_ack_pump")});this.add(l,{name:"ackPump"}),this.addDisposer(me(l));let f=fs(this.output,n);this.addDisposer(f)}};function fs(r,e){return r.subscribe(t=>{for(let n of t){if(n[0]!==M)continue;let s=n[1];s.length!==0&&K(()=>{for(let o of s)e.publish(o)})}})}var $n=class{_map=new Map;version;constructor(e){this.version=e}get size(){return this._map.size}has(e){return this._map.has(e)}get(e){return this._map.get(e)}set(e,t){this._map.set(e,t)}delete(e){return this._map.delete(e)}keys(){return this._map.keys()}},Vn=class extends ge{_registry;version;_defaultTopicOptions;_removeTopicImpl;constructor(e,t={}){super(e,t.graph);let n=V(0,{name:"version",describeKind:"state",meta:Be("hub_version")});this.add(n,{name:"version"}),this.version=n,this._registry=new $n(n),this._defaultTopicOptions={...t.defaultTopicOptions??{}},this._removeTopicImpl=Le(s=>{try{this.remove(s)}finally{this._registry.delete(s);let o=this.version.cache??0;this.version.emit(o+1)}},{freeze:!1})}get size(){return this._registry.size}has(e){return this._registry.has(e)}topicNames(){return this._registry.keys()}topic(e,t){let n=this._registry.get(e);if(n===void 0){let s={...this._defaultTopicOptions,...t??{}};n=new Ln(e,s),this._registry.set(e,n),this.mount(e,n);let o=this.version.cache??0;this.version.emit(o+1)}return n}publish(e,t){this.topic(e).publish(t)}publishMany(e){K(()=>{for(let[t,n]of e)this.topic(t).publish(n)})}subscribe(e,t,n){let s=this.topic(t);return new Qt(e,s,n)}removeTopic(e){return this._registry.has(e)?(this._removeTopicImpl(e),!0):!1}};function Xt(r,e){return new Vn(r,e)}function ps(r,e,t){return new Qt(r,e,t)}function jn(r,e,t,n){return new Fn(r,e,t,n)}function hs(r){if(typeof r!="object"||r===null)return!1;let e=r;return typeof e.subscribe=="function"&&typeof e.down=="function"&&typeof e.emit=="function"}function Hr(r,e){if(r.length===0)return{best:null,bestScore:Number.NEGATIVE_INFINITY};if(r.length===1){let o=zn(e);return{best:r[0],bestScore:o}}if(e.some(o=>typeof o.candidateIndex=="number")){let o=new Array(r.length);for(let u=0;u<r.length;u++)o[u]={sum:0,count:0};for(let u of e){let d=u.candidateIndex;typeof d=="number"&&d>=0&&d<r.length&&(o[d].sum+=u.score,o[d].count+=1)}let i=r[0],a=o[0].count>0?o[0].sum/o[0].count:Number.NEGATIVE_INFINITY;for(let u=1;u<r.length;u++){let d=o[u].count>0?o[u].sum/o[u].count:Number.NEGATIVE_INFINITY;d>a&&(a=d,i=r[u])}return{best:i,bestScore:a}}let n=r[0],s=e[0]?.score??Number.NEGATIVE_INFINITY;for(let o=1;o<r.length;o++){let i=e[o]?.score??Number.NEGATIVE_INFINITY;i>s&&(s=i,n=r[o])}return{best:n,bestScore:s}}function zn(r){if(r.length===0)return Number.NEGATIVE_INFINITY;let e=0;for(let t of r)e+=t.score;return e/r.length}function Hn(r,e,t,n){let s=n.name??"refine-loop",o=new ge(s,n.graph),i=hs(n.dataset)?n.dataset:V(n.dataset,{name:"dataset"});o.add(i,{name:"dataset"});let a=V(0,{name:"iteration"});o.add(a,{name:"iteration"});let u=V(t,{name:"strategy",equals:()=>!1});o.add(u,{name:"strategy"});let d=V(null,{name:"lastFeedback"});o.add(d,{name:"lastFeedback"});let l=V([],{name:"prevCandidates"});o.add(l,{name:"prevCandidates"});let f=V(!1,{name:"paused"});o.add(f,{name:"paused"});let c=V("running",{name:"status"});o.add(c,{name:"status"});let h=V([],{name:"history",equals:()=>!1});o.add(h,{name:"history"});let p=V(null,{name:"best"});o.add(p,{name:"best"});let g=V(Number.NEGATIVE_INFINITY,{name:"score"});o.add(g,{name:"score"});let m=V(0,{name:"budget-used"});o.add(m,{name:"budget-used"});let v=Xt("stages");o.mount("stages",v);let T=v.topic("generate"),y=v.topic("evaluate"),_=v.topic("analyze"),w=v.topic("decide"),N=t,b=null,x=[];o.addDisposer(u.subscribe(R=>{for(let P of R)P[0]===M&&(N=P[1])})),o.addDisposer(d.subscribe(R=>{for(let P of R)P[0]===M&&(b=P[1])})),o.addDisposer(l.subscribe(R=>{for(let P of R)P[0]===M&&(x=P[1])}));let E=it(a,R=>{let P=N,ee=R===0||b==null;return te([],(ie,be)=>{let q=!1;try{let O=ee?P.seed(r):P.generate(b,x);if(O instanceof Promise)return O.then(D=>{q||be.emit(D)},D=>{q||be.down([[I,D]])}),()=>{q=!0};be.emit(O)}catch(O){q=!0,be.down([[I,O]])}},{describeKind:"producer"})},{name:"candidates"});o.add(E,{name:"candidates"});let A=le([E],(R,P,ee)=>{let ie=ee.terminalDeps[0];ie!==void 0&&ie!==!0&&c.emit("errored")},{name:"error-watcher",errorWhenDepsError:!1});o.add(A,{name:"error-watcher"}),o.addDisposer(A.subscribe(()=>{}));let k=G([E,a],([R,P])=>({iteration:P,candidates:R,timestamp_ns:U()}),{name:"generate-event"});o.add(k,{name:"generate-event"}),o.addDisposer(k.subscribe(()=>{}));let C=le([k],([R])=>{T.publish(R)},{name:"generate-publish"});o.add(C,{name:"generate-publish"}),o.addDisposer(C.subscribe(()=>{}));let H=le([E],([R])=>{l.emit(R)},{name:"generate-mirror"});o.add(H,{name:"generate-mirror"}),o.addDisposer(H.subscribe(()=>{}));let z=e(E,i);o.add(z,{name:"scores"});let fe=G([z,E,a],([R,P,ee])=>({iteration:ee,candidates:P,scores:R,timestamp_ns:U()}),{name:"evaluate-event"});o.add(fe,{name:"evaluate-event"}),o.addDisposer(fe.subscribe(()=>{}));let ne=le([fe],([R])=>{y.publish(R)},{name:"evaluate-publish"});o.add(ne,{name:"evaluate-publish"}),o.addDisposer(ne.subscribe(()=>{}));let we=G([z,E],([R,P])=>N.analyze(R,P),{name:"feedback"});o.add(we,{name:"feedback"});let xe=G([we,E,a],([R,P,ee])=>({iteration:ee,candidates:P,feedback:R,timestamp_ns:U()}),{name:"analyze-event"});o.add(xe,{name:"analyze-event"}),o.addDisposer(xe.subscribe(()=>{}));let $=le([xe],([R])=>{_.publish(R)},{name:"analyze-publish"});o.add($,{name:"analyze-publish"}),o.addDisposer($.subscribe(()=>{}));let L=G([h],([R])=>{let P=R;if(n.patience==null||P.length<=n.patience)return!1;let ee=P.slice(-(n.patience+1)),ie=ee[0].bestScore;return ee.slice(1).every(be=>be.bestScore<=ie)},{name:"patience-check"});o.add(L,{name:"patience-check"});let F=G([g],([R])=>n.minScore!=null&&R>=n.minScore,{name:"min-score-check"});o.add(F,{name:"min-score-check"});let re=G([h],([R])=>{let P=R;if(n.minDelta==null||P.length<2)return!1;let ee=P[P.length-2].bestScore,ie=P[P.length-1].bestScore;return Math.abs(ie-ee)<n.minDelta},{name:"min-delta-check"});o.add(re,{name:"min-delta-check"});let W=G([m],([R])=>n.maxEvaluations!=null&&R>=n.maxEvaluations,{name:"max-evaluations-check"});o.add(W,{name:"max-evaluations-check"});let se=G([a],([R])=>n.maxIterations!=null&&R>=n.maxIterations,{name:"max-iterations-check"});o.add(se,{name:"max-iterations-check"});let S=G([m],([R])=>n.budget!=null&&R>=n.budget,{name:"budget-exhausted-check"});o.add(S,{name:"budget-exhausted-check"}),o.addDisposer(L.subscribe(()=>{})),o.addDisposer(F.subscribe(()=>{})),o.addDisposer(re.subscribe(()=>{})),o.addDisposer(W.subscribe(()=>{})),o.addDisposer(se.subscribe(()=>{})),o.addDisposer(S.subscribe(()=>{}));let B=G([L,F,re,W,se],([R,P,ee,ie,be])=>R?{converged:!0,reason:"patience"}:P?{converged:!0,reason:"min-score"}:ee?{converged:!0,reason:"min-delta"}:ie?{converged:!0,reason:"max-evaluations"}:be?{converged:!0,reason:"max-iterations"}:{converged:!1},{name:"converged"});o.add(B,{name:"converged"}),o.addDisposer(B.subscribe(()=>{}));let ve=-1,Ge=le([we,z,E],([R,P,ee])=>{let ie=a.cache,be=R,q=ee,O=P;if(ie<=ve)return;ve=ie;let{best:D,bestScore:X}=Hr(q,O),ae=h.cache,Fe={n:ie,candidates:q,scores:O,feedback:be,best:D,bestScore:X,timestamp_ns:U()},ye=[...ae,Fe],$e=m.cache+q.length,ue="continue",_e,rn=n.budget!=null&&$e>=n.budget,on=f.cache;if(rn)ue="budget",_e="budget";else if(n.minScore!=null&&be.score>=n.minScore)ue="converged",_e="min-score";else if(n.maxIterations!=null&&ie>=n.maxIterations)ue="converged",_e="max-iterations";else if(n.maxEvaluations!=null&&$e>=n.maxEvaluations)ue="converged",_e="max-evaluations";else if(n.minDelta!=null&&ye.length>=2){let Rt=ye[ye.length-2].bestScore,sn=ye[ye.length-1].bestScore;Math.abs(sn-Rt)<n.minDelta&&(ue="converged",_e="min-delta")}else if(n.patience!=null&&ye.length>n.patience){let Rt=ye.slice(-(n.patience+1)),sn=Rt[0].bestScore;Rt.slice(1).every(ro=>ro.bestScore<=sn)&&(ue="converged",_e="patience")}ue==="continue"&&on&&(ue="paused"),K(()=>{p.emit(D),g.emit(be.score),h.emit(ye),m.emit($e),d.emit(be),w.publish({iteration:ie,decision:ue,reason:_e,timestamp_ns:U()}),ue==="continue"?a.emit(ie+1):c.emit(ue==="converged"?"converged":ue==="budget"?"budget":"paused")})},{name:"decide-bridge"});return o.add(Ge,{name:"decide-bridge"}),o.addDisposer(Ge.subscribe(()=>{})),Object.assign(o,{best:p,score:g,status:c,history:h,strategy:u,iteration:a,generate:T,evaluate:y,analyze:_,decide:w,setStrategy(R){u.emit(R)},pause(){f.emit(!0)},resume(){c.cache==="paused"&&K(()=>{f.emit(!1),c.emit("running"),a.emit(a.cache+1)})}})}function ms(r){let e=r.width??4;return{name:r.name??"blindVariation",seed(n){return[n]},analyze(n,s){let o=zn(n),i=null;for(let a of n)(!i||a.score<i.score)&&(i=a);return{summary:`blindVariation iteration: mean=${o.toFixed(3)}, n=${n.length}`,score:o,weakTasks:i?[i.taskId]:[]}},async generate(n,s){if(s.length===0)throw new Error("blindVariation.generate: empty candidate batch \u2014 cannot derive prior for teacher");let o=s[s.length-1],i=0,u={prior:o,reportCost:d=>{i+=d}};try{if(r.parallel!==!1)return await Promise.all(Array.from({length:e},()=>r.teacher(u)));let d=[];for(let l=0;l<e;l++)d.push(await r.teacher(u));return d}finally{if(r.tokens!=null&&i>0){let d=r.tokens.cache??0;r.tokens.emit(d+i)}}}}}function gs(r){return typeof r=="object"&&r!==null&&r.kind==="errorCritique"}function bs(r,e){return r.length===0?`No task scored below the batch mean (${e.score.toFixed(3)}). Reinforce the current direction.`:`Failures below threshold:
|
|
45
|
-
${r.map(n=>{let s=n.error!=null?` | error: ${n.error}`:"";return`- ${n.taskId} (score=${n.score.toFixed(3)})${s}`}).join(`
|
|
46
|
-
`)}`}function ys(r){let e=r.width??4,t=r.name??"errorCritique",n=r.maxFailureSamples??5,s=r.formatCritique??bs;return{name:t,seed(o){return[o]},analyze(o,i){let a=zn(o),u=typeof r.failureThreshold=="function"?r.failureThreshold(o):r.failureThreshold,d=u===void 0&&!Number.isFinite(a),l=u??a,f=d?[...o].sort((y,_)=>y.score-_.score):o.filter(y=>y.score<l).slice().sort((y,_)=>y.score-_.score),c=f.slice(0,n),{best:h,bestScore:p}=Hr(i,o),g={summary:"",score:a,weakTasks:c.map(y=>y.taskId)},m=s(c,g),v={kind:"errorCritique",best:h,failures:c,critiqueText:m},T=f.length>c.length?` (top ${c.length} retained)`:"";return{summary:`errorCritique iteration: mean=${a.toFixed(3)}, failures=${f.length}${T}/${o.length}, bestScore=${p.toFixed(3)}`,critique:v,weakTasks:c.map(y=>y.taskId),score:a}},async generate(o,i){if(i.length===0)throw new Error("errorCritique.generate: empty candidate batch \u2014 cannot derive prior for teacher");let a=gs(o.critique)?o.critique:void 0,u=a!==void 0?a.best:i[i.length-1],d=a?.critiqueText??o.summary,l=a?.failures??[],f=0,h={prior:u,critique:d,failures:l,reportCost:p=>{f+=p}};try{if(r.parallel!==!1)return await Promise.all(Array.from({length:e},()=>r.teacher(h)));let p=[];for(let g=0;g<e;g++)p.push(await r.teacher(h));return p}finally{if(r.tokens!=null&&f>0){let p=r.tokens.cache??0;r.tokens.emit(p+f)}}}}}function vs(r){let{best:e,score:t,status:n}=r,s=Number.isFinite(t)?t.toFixed(3):String(t),o=e??void 0;return n==="converged"?{outcome:"success",detail:`refineLoop converged at score ${s}`,artifact:o}:n==="budget"?{outcome:"partial",detail:`refineLoop hit budget at score ${s}`,artifact:o}:{outcome:"failure",detail:`refineLoop errored (status=${n})`,artifact:o}}function Bn(r){let e=r.name??"refine-executor",t=r.toOutput??vs;return n=>{let s=n.payload.item,o=Hn(r.seedFrom(s),r.evaluator,r.strategy,{...r.refine,dataset:r.datasetFor(s),name:`${e}/inner`}),i=G([o.status,o.best,o.score],([a,u,d])=>{let l=a;if(l!=="converged"&&l!=="budget"&&l!=="errored")return null;let f=t({best:u,score:d,status:l});return{...n.payload,execution:{item:s,...f}}},{name:`${e}/output`});return Ft(i,a=>a!=null,{name:`${e}/gate-out`})}}function Ts(r){if(r.length===0)return Number.NEGATIVE_INFINITY;let e=0;for(let t of r)e+=t.score;return e/r.length}function _s(r){let{passCount:e,total:t,meanScore:n,threshold:s,missingArtifact:o}=r,i=Number.isFinite(n)?n.toFixed(3):String(n),a=!o&&t>0&&n>=s,u=o?["EXECUTE stage did not emit an artifact; cannot verify reactively"]:a?[`${e}/${t} eval tasks passed; mean score ${i} \u2265 ${s}`]:t===0?["No eval tasks were selected for this item \u2014 cannot verify"]:[`${e}/${t} eval tasks passed; mean score ${i} < threshold ${s}`];return a?{verified:!0,findings:u}:{verified:!1,findings:u,errorClass:"structural"}}function ws(r){return r.artifact??null}function Br(r){let e=r.name??"eval-verifier",t=r.threshold??.5,n=r.toOutput??_s,s=r.extractArtifact??ws;return o=>{let{item:i,execution:a}=o.payload;if(a==null)return{...o.payload,verify:{verified:!1,findings:["evalVerifier: prior execute stage produced no execution"],errorClass:"structural"}};let u=s(a,i);if(u==null)return{...o.payload,verify:n({scores:[],meanScore:Number.NEGATIVE_INFINITY,passCount:0,total:0,threshold:t,missingArtifact:!0})};let d=V([u],{name:`${e}/candidates`}),l=V(r.datasetFor(i),{name:`${e}/dataset`}),f;K(()=>{f=r.evaluator(d,l)});let c=G([f],([h])=>{let p=h;if(p==null)return null;let g=Ts(p),m=p.filter(v=>v.score>=t).length;return{...o.payload,verify:n({scores:p,meanScore:g,passCount:m,total:p.length,threshold:t})}},{name:`${e}/output`});return Ft(c,h=>h!=null,{name:`${e}/gate-out`})}}function xs(r){let e=r.name??"harness-pair",t=Bn({name:`${e}-exec`,seedFrom:r.seedFrom,evaluator:r.evaluator,strategy:r.strategy,datasetFor:r.datasetFor,refine:r.refine}),n=Br({name:`${e}-verify`,evaluator:r.evaluator,datasetFor:r.datasetFor,threshold:r.threshold});return{executor:t,verifier:n}}Oe();st();oe();Ye();Tt();function xt(r){return r.relatedTo?.[0]??r.summary}Te();oe();_t();Pe();function Nt(r,e){return He("ai",r,e)}function Et(r){let e=r.match(/^```(?:json)?\s*([\s\S]*?)\s*```[\s\S]*$/);return e?e[1]:r}function qn(r,e,t){return he(n=>{let s=new AbortController,o=t.parentSignal,i=()=>{};if(o)if(o.aborted)s.abort();else{let c=()=>s.abort();o.addEventListener("abort",c,{once:!0}),i=()=>o.removeEventListener("abort",c)}let a=!1,u=null,d=c=>{a||(a=!0,n.down([[M,c],[j]]),u?.(),u=null)},l;try{l=r.invoke(e,{...t.invokeOpts,signal:s.signal})}catch(c){return d(t.onFailure("throw",c)),()=>{i(),s.abort()}}return u=Ee(l,{signal:s.signal}).subscribe(c=>{for(let h of c){if(a)return;if(h[0]===M){try{d(t.onSuccess(h[1]))}catch(p){d(t.onFailure("onSuccess-threw",p))}return}if(h[0]===I){d(t.onFailure("error",h[1]));return}if(h[0]===j){d(t.onFailure("complete",void 0));return}}}),a&&u&&(u(),u=null),()=>{i(),s.abort(),u?.(),u=null}})}Te();oe();Ye();Pe();function qr(r){return r!=null&&typeof r=="object"&&"content"in r?String(r.content):typeof r=="string"?r:String(r)}function Ns(r,e=200){return r.length<=e?r:`${r.slice(0,e)}\u2026`}function Kr(r,e,t,n){let s=n?.format??"text",o=n?.name??"prompt_node";n?.tools!==void 0&&s!=="raw"&&console.warn("promptNode: `tools` is set but `format !== 'raw'`. Tool calls in the response will be silently dropped \u2014 set `format: 'raw'` to receive the full LLMResponse with `toolCalls`.");let i=e.length,a=n?.tools!==void 0?[...e,n.tools]:e,u=G(a,l=>{let f=l.slice(0,i),c=n?.tools!==void 0?l[i]:void 0;if(f.some(p=>p==null))return{messages:[],tools:c};let h=typeof t=="string"?t:t(...f);return h?{messages:[{role:"user",content:h}],tools:c}:{messages:[],tools:c}},{name:`${o}::messages`,meta:Nt("prompt_node")});return it(u,l=>{let{messages:f,tools:c}=l;return!f||f.length===0?V(null):he(h=>{let p=!1,g=!1,m,v={model:n?.model,temperature:n?.temperature,maxTokens:n?.maxTokens,systemPrompt:n?.systemPrompt,...c!==void 0?{tools:c}:{}};if(n?.abort){let w=br(n.abort);v.signal=w.signal,m=w.dispose}let T;try{T=r.invoke(f,v)}catch(w){return p=!0,h.down([[I,w]]),()=>{m?.()}}let _=Ee(T).subscribe(w=>{if(!(g||p))for(let N of w){if(p)return;if(N[0]===M){let b=N[1];if(s==="raw")h.emit(b);else try{let x=qr(b),E=s==="json"?JSON.parse(Et(x)):x;h.emit(E)}catch(x){let E=qr(b),A=new Error(`promptNode: failed to parse LLM response as JSON: ${x.message}
|
|
47
|
-
Raw content (first 200 chars): ${Ns(E)}`);p=!0,h.down([[I,A]]);return}}else if(N[0]===I){p=!0,h.down([[I,N[1]]]);return}else if(N[0]===j){p=!0,h.down([[j]]);return}else h.down([N])}});return()=>{g=!0,_(),m?.()}},{name:`${o}::call`,meta:Nt("prompt_node::call")})},{name:`${o}::output`,meta:n?.meta?{...Nt("prompt_node::output"),...n.meta}:Nt("prompt_node::output")})}Ce();Oe();Te();st();Ie();oe();_t();Tt();function kt(r,e){return He("orchestration",r,e)}var Zt=class extends ge{constructor(e,t){super(e,t)}task(e,t,n={}){let s=(n.deps??[]).map(i=>this._resolveStep(i)),o=G(s,t,{name:e,describeKind:"derived",meta:kt("task",n.meta)});return this.add(o,{name:e}),o}classify(e,t,n,s={}){let o=this._resolveStep(t),i=G([o],([a])=>{try{return{tag:n(a),value:a}}catch(u){return{tag:"error",value:a,error:u}}},{name:e,describeKind:"derived",meta:kt("classify",s.meta)});return this.add(i,{name:e}),i}combine(e,t,n={}){let s=Object.keys(t),o=s.map(a=>this._resolveStep(t[a])),i=G(o,a=>{let u={};for(let d=0;d<s.length;d++)u[s[d]]=a[d];return u},{name:e,describeKind:"derived",meta:kt("combine",n.meta)});return this.add(i,{name:e}),i}approvalGate(e,t,n={}){let s=n.maxPending??1e3;if(s<1&&s!==Number.POSITIVE_INFINITY)throw new RangeError("approvalGate: maxPending must be >= 1");let o=n.startOpen??!1;typeof t!="string"&&this.nameOf(t)===void 0&&this.add(t,{name:`${e}/source`});let i=this._resolveStep(t),a=new ge(`${e}_state`),u=V([],{name:"pending",equals:()=>!1}),d=V(o,{name:"isOpen"}),l=G([u],([$])=>$.length,{name:"count"}),f=V(0,{name:"droppedCount"}),c=Jt({name:"decisions",retainedLimit:1024,graph:a});a.add(u,{name:"pending"}),a.add(d,{name:"isOpen"}),a.add(l,{name:"count"}),a.add(f,{name:"droppedCount"}),this.mount(`${e}_state`,a);let h=[],p=!1,g=!1,m=o,v=d.subscribe($=>{for(let L of $)L[0]===M&&(m=L[1])});this.addDisposer(v);function T(){u.emit([...h])}function y($,L,F){c.append({action:$,t_ns:Me(),...L!==void 0?{items:L,count:L.length}:{},...F!==void 0?{unflushed:F}:{},...n.handlerVersion!=null?{handlerVersion:n.handlerVersion}:{}})}function _($){if(h.push($),h.length>s){let L=h.shift();f.emit(f.cache+1),y("drop",[L])}T()}function w($){let L=h.splice(0,$);return T(),L}let N=te([i],($,L,F)=>{let re=F.terminalDeps[0];if(re!==void 0){p=!0;let se=h.length;h=[],T(),y("teardown",void 0,se),L.down(re===!0?[[j]]:[[I,re]]);return}let W=$[0];if(W==null||W.length===0){L.down([[Y]]);return}for(let se of W)m?L.emit(se):(_(se),L.down([[Y]]))},{name:e,describeKind:"derived",meta:kt("approval_gate",n.meta)});if(this.add(N,{name:e}),n.approver!=null){n.approver.cache&&(d.emit(!0),m=!0,n.onceOnly&&(g=!0));let L=n.approver.subscribe(F=>{for(let re of F){if(re[0]!==M)continue;let W=!!re[1];if(W&&!m){if(n.onceOnly){if(g)continue;g=!0}K(()=>{d.emit(!0);let se=w(h.length);y("open",se);for(let S of se){if(p)break;N.emit(S)}})}else if(!W&&m){if(n.onceOnly&&g)continue;K(()=>{d.emit(!1),y("close")})}}});this.addDisposer(L)}let b=$=>{if(p)throw new Error(`approvalGate: ${$}() called after the gate was torn down`)},x=($=1)=>{b("approve");let L=w($);for(let F of L){if(p)break;N.emit(F)}},E=($=1)=>{b("reject"),w($)},A=($,L=1)=>{b("modify");let F=[...h],re=w(L);for(let W=0;W<re.length&&!p;W++)N.emit($(re[W],W,F))},k=()=>{b("open"),d.emit(!0);let $=w(h.length);for(let L of $){if(p)break;N.emit(L)}},C=()=>{b("close"),!(n.onceOnly&&g)&&d.emit(!1)},H=ft(x,{audit:c,freeze:!1,onSuccess:($,L,F)=>({action:"approve",count:$[0]??1,t_ns:F.t_ns,...n.handlerVersion!=null?{handlerVersion:n.handlerVersion}:{}}),onFailure:($,L,F)=>({action:"drop",t_ns:F.t_ns,errorType:F.errorType,...n.handlerVersion!=null?{handlerVersion:n.handlerVersion}:{}})}),z=ft(E,{audit:c,freeze:!1,onSuccess:($,L,F)=>({action:"reject",count:$[0]??1,t_ns:F.t_ns,...n.handlerVersion!=null?{handlerVersion:n.handlerVersion}:{}}),onFailure:($,L,F)=>({action:"drop",t_ns:F.t_ns,errorType:F.errorType,...n.handlerVersion!=null?{handlerVersion:n.handlerVersion}:{}})}),fe=ft(A,{audit:c,freeze:!1,onSuccess:($,L,F)=>({action:"modify",count:$[1]??1,t_ns:F.t_ns,...n.handlerVersion!=null?{handlerVersion:n.handlerVersion}:{}}),onFailure:($,L,F)=>({action:"drop",t_ns:F.t_ns,errorType:F.errorType,...n.handlerVersion!=null?{handlerVersion:n.handlerVersion}:{}})}),ne=ft(k,{audit:c,freeze:!1,onSuccess:($,L,F)=>({action:"open",t_ns:F.t_ns,...n.handlerVersion!=null?{handlerVersion:n.handlerVersion}:{}}),onFailure:($,L,F)=>({action:"drop",t_ns:F.t_ns,errorType:F.errorType,...n.handlerVersion!=null?{handlerVersion:n.handlerVersion}:{}})}),we=ft(C,{audit:c,freeze:!1,onSuccess:($,L,F)=>({action:"close",t_ns:F.t_ns,...n.handlerVersion!=null?{handlerVersion:n.handlerVersion}:{}}),onFailure:($,L,F)=>({action:"drop",t_ns:F.t_ns,errorType:F.errorType,...n.handlerVersion!=null?{handlerVersion:n.handlerVersion}:{}})});return this.addDisposer(l.subscribe(()=>{})),{output:N,pending:u,count:l,isOpen:d,droppedCount:f,decisions:c,audit:c,approve:H,reject:z,modify:fe,open:ne,close:we}}approval(e,t,n,s={}){return this.approvalGate(e,t,{...s,approver:n,maxPending:1})}catch(e,t,n,s={}){let o=this._resolveStep(t),i=s.on??"errored",a=te([o],(u,d,l)=>{let f=l.terminalDeps[0];if(f!==void 0){let h=f===!0?{kind:"completed"}:{kind:"errored",error:f};if(i==="terminal"||i===h.kind){d.emit(n(h,d));return}d.down(h.kind==="completed"?[[j]]:[[I,h.error]]);return}let c=u[0];if(c==null||c.length===0){d.down([[Y]]);return}for(let h of c)d.emit(h)},{name:e,describeKind:"derived",completeWhenDepsComplete:s.completeWhenDepsComplete??!(i==="completed"||i==="terminal"),errorWhenDepsError:!(i==="errored"||i==="terminal"),meta:kt("catch",s.meta)});return this.add(a,{name:e}),a}_resolveStep(e){if(typeof e=="string")return this.resolve(e);if(this.nameOf(e)===void 0)throw new Error(`PipelineGraph "${this.name}": Node dep is not registered. Pass a string path or call graph.add(node) first.`);return e}};function Kn(r,e){let t=new Zt(r,e),{factory:n,factoryArgs:s,...o}=e??{};return t.tagFactory("pipelineGraph",We(o)),t}var Gu=Math.LN2/604800;function Ur(r,e,t,n=0){if(!Number.isFinite(r))return n;if(!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0)return Math.max(n,r);let s=r*Math.exp(-t*e);return Math.max(n,s)}Oe();Ie();_t();Ce();Te();oe();var Un=class{_version=0;_buf;constructor(e){this._buf=e?[...e]:[]}get version(){return this._version}get size(){return this._buf.length}at(e){if(!Number.isInteger(e))return;let t=e>=0?e:this._buf.length+e;if(!(t<0||t>=this._buf.length))return this._buf[t]}append(e){this._buf.push(e),this._version+=1}appendMany(e){if(e.length===0)return;let t=this._buf.length;this._buf.length=t+e.length;for(let n=0;n<e.length;n++)this._buf[t+n]=e[n];this._version+=1}insert(e,t){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insert: index ${e} out of range [0, ${this._buf.length}]`);this._buf.splice(e,0,t),this._version+=1}insertMany(e,t){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insertMany: index ${e} out of range [0, ${this._buf.length}]`);t.length!==0&&(this._buf.splice(e,0,...t),this._version+=1)}pop(e){if(this._buf.length===0)throw new RangeError("pop from empty list");if(!Number.isInteger(e))throw new RangeError(`pop: index ${e} must be an integer`);let t=e>=0?e:this._buf.length+e;if(t<0||t>=this._buf.length)throw new RangeError(`pop: index ${e} out of range`);let[n]=this._buf.splice(t,1);return this._version+=1,n}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._version+=1,e)}toArray(){return[...this._buf]}};function Wr(r,e={}){let{name:t,versioning:n,backend:s}=e,o=s??new Un(r),i=V(o.toArray(),{name:t,describeKind:"state",equals:(d,l)=>d===l,...n!=null?{versioning:n}:{}});function a(){let d=o.toArray();K(()=>{i.down([[Z]]),i.down([[M,d]])})}function u(d){let l=o.version;try{return d()}finally{o.version!==l&&a()}}return{items:i,get size(){return o.size},at(d){return o.at(d)},append(d){u(()=>o.append(d))},appendMany(d){u(()=>o.appendMany(d))},insert(d,l){u(()=>o.insert(d,l))},insertMany(d,l){u(()=>o.insertMany(d,l))},pop(d=-1){return u(()=>o.pop(d))},clear(){u(()=>o.clear())},dispose(){}}}Pe();Pn();var Es=256,ks=1024;function en(r,e){if(!Number.isFinite(r)||!Number.isInteger(r)||r<0)throw new Error(`${e} must be a non-negative integer`);return r}function tn(r,e){return He("job_queue",r,e)}var Wn=class extends ge{_pending;_jobs;_seqCursor;pending;jobs;depth;events;audit;_enqueueImpl;_ackImpl;_nackImpl;_removeByIdImpl;constructor(e,t={}){super(e,t.graph),this._pending=Wr([],{name:"pending"}),this._jobs=lt({name:"jobs"}),this.pending=this._pending.items,this.jobs=this._jobs.entries,this.add(this.pending,{name:"pending"}),this.add(this.jobs,{name:"jobs"}),this.depth=G([this.pending],([n])=>n.length,{name:"depth",describeKind:"derived",meta:tn("queue_depth"),initial:0}),this.add(this.depth,{name:"depth"}),this.addDisposer(me(this.depth)),this.events=Jt({name:"events",retainedLimit:1024,graph:this}),this.audit=this.events,this._seqCursor=zr(this,"seq",0),this._enqueueImpl=Le((n,s)=>{let o=this._seqCursor.cache,i=s.id??`${this.name}-${o}`;if(this._jobs.get(i)!==void 0)throw new Error(`jobQueue("${this.name}"): duplicate job id "${i}"`);let a={id:i,payload:n,attempts:0,metadata:Object.freeze({...s.metadata??{}}),state:"queued"};return this._jobs.set(i,a),this._pending.append(i),i},{audit:this.events,seq:this._seqCursor,freeze:!1,onSuccess:([n],s,{t_ns:o,seq:i})=>({action:"enqueue",id:s,payload:n,t_ns:o,seq:i??0})}),this._ackImpl=Le((n,s)=>{this._jobs.delete(n)},{audit:this.events,seq:this._seqCursor,freeze:!1,onSuccess:([n,s],o,{t_ns:i,seq:a})=>({action:"ack",id:n,attempts:s.attempts,t_ns:i,seq:a??0})}),this._nackImpl=Le((n,s,o)=>{o?(this._jobs.set(n,{...s,state:"queued"}),this._pending.append(n)):this._jobs.delete(n)},{audit:this.events,seq:this._seqCursor,freeze:!1,onSuccess:([n,s],o,{t_ns:i,seq:a})=>({action:"nack",id:n,attempts:s.attempts,t_ns:i,seq:a??0})}),this._removeByIdImpl=Le((n,s)=>{if(s.state==="queued"){let i=this.pending.cache.indexOf(n);i>=0&&this._pending.pop(i)}this._jobs.delete(n)},{audit:this.events,seq:this._seqCursor,freeze:!1,onSuccess:([n,s],o,{t_ns:i,seq:a})=>({action:"remove",id:n,attempts:s.attempts,t_ns:i,seq:a??0})})}attachEventStorage(e){return this.events.attachStorage(e)}enqueue(e,t={}){return this._enqueueImpl(e,t)}claim(e=1){let t=en(e,"job queue claim limit");if(t===0)return[];let n=[];for(;n.length<t&&this.pending.cache.length!==0;){let o=this._pending.pop(0),i=this._jobs.get(o);if(!i||i.state!=="queued")continue;let a={...i,state:"inflight",attempts:i.attempts+1};this._jobs.set(o,a),n.push(a),this.events.append({action:"claim",id:o,attempts:a.attempts,t_ns:Me(),seq:Yt(this._seqCursor)})}return n}ack(e){let t=this._jobs.get(e);return!t||t.state!=="inflight"?!1:(this._ackImpl(e,t),!0)}nack(e,t={}){let n=this._jobs.get(e);return!n||n.state!=="inflight"?!1:(this._nackImpl(e,n,t.requeue??!0),!0)}removeById(e){let t=this._jobs.get(e);return t?(this._removeByIdImpl(e,t),!0):!1}consumeFrom(e,t){return e.subscribe(n=>{for(let s of n){if(s[0]!==M)continue;let o=s[1];this.enqueue(o,t?{metadata:t.metadata}:void 0)}})}},Jn=class extends ge{_stageNames;_stageWorkFns;_queues=new Map;_completed;completed;completedCount;constructor(e,t={}){super(e,t.graph);let n=t.stages??["incoming","processing","done"],s=[],o=new Map,i=new Map,a=new Map;for(let l of n){let f=typeof l=="string"?l.trim():l.name.trim();typeof l!="string"&&l.work&&o.set(f,l.work),typeof l!="string"&&l.maxPerPump!=null&&i.set(f,Math.max(1,en(l.maxPerPump,`job flow stage "${f}" maxPerPump`))),typeof l!="string"&&l.maxInflight!=null&&a.set(f,Math.max(1,en(l.maxInflight,`job flow stage "${f}" maxInflight`))),s.push(f)}if(s.length<2)throw new Error(`jobFlow("${e}"): requires at least 2 stages`);if(new Set(s).size!==s.length)throw new Error(`jobFlow("${e}"): stage names must be unique`);this._stageNames=Object.freeze([...s]),this._stageWorkFns=o;for(let l of this._stageNames){let f=Yn(`${e}-${l}`);this._queues.set(l,f),this.mount(l,f)}this._completed=ct([],{name:"completed",maxSize:ks}),this.completed=this._completed.entries,this.add(this.completed,{name:"completed"}),this.completedCount=G([this.completed],([l])=>l.length,{name:"completedCount",describeKind:"derived",meta:tn("job_flow_completed_count"),initial:0}),this.add(this.completedCount,{name:"completedCount"}),this.addDisposer(me(this.completedCount));let d=Math.max(1,en(t.maxPerPump??Es,"job flow maxPerPump"));for(let l=0;l<this._stageNames.length;l+=1){let f=this._stageNames[l],c=this.queue(f),h=l+1<this._stageNames.length?this.queue(this._stageNames[l+1]):null,p=this._stageWorkFns.get(f),g=i.get(f)??d,m=a.get(f),v=m!==void 0?V(0,{name:`__inflight__/${f}`}):null;v&&this.add(v,{name:`__inflight__/${f}`});let T=h===null;if(p){let y=v!=null?[c.pending,v]:[c.pending],_=te(y,(w,N,b)=>{"inflight"in b.store||(b.store.inflight={entries:new Set,terminated:!1});let x=b.store.inflight,E=x.entries,A=0;for(;A<g&&!(m!==void 0&&E.size>=m);){let k=c.claim(1);if(k.length===0)break;let C=k[0];if(!C)break;let z=[...C.metadata.job_flow_path??[],f],fe=new AbortController,ne={unsub:()=>{},ac:fe};E.add(ne),v?.emit(E.size);let we;try{we=p(C,{signal:fe.signal})}catch{E.delete(ne),v?.emit(E.size),c.nack(C.id,{requeue:!1}),A+=1;continue}let xe=Ee(we),$=!1,L,F=()=>{L?L():Promise.resolve().then(()=>L?.()),E.delete(ne),x.terminated||v?.emit(E.size)};L=xe.subscribe(re=>{if(!$){for(let W of re)if(W[0]===M){$=!0,F();let se=W[1],S={...C.metadata,job_flow_path:z};if(T){let B={...C,payload:se,metadata:Object.freeze(S)};K(()=>{c.ack(C.id),this._completed.append(B)})}else K(()=>{c.ack(C.id),h.enqueue(se,{metadata:S})});return}else if(W[0]===I){$=!0,F(),c.nack(C.id,{requeue:!1});return}}}),ne.unsub=()=>L?.(),A+=1}return{deactivate:()=>{x.terminated=!0;for(let k of E){try{k.ac.abort()}catch{}try{k.unsub()}catch{}}E.clear()}}},{name:`pump_${f}`,describeKind:"effect",meta:tn("job_flow_pump",{stage:f,has_work:!0})});this.add(_,{name:`pump_${f}`}),this.addDisposer(me(_))}else{let y=te([c.pending],()=>{let _=0;for(;_<g;){let w=c.claim(1);if(w.length===0)break;let N=w[0];if(!N)break;let x=[...N.metadata.job_flow_path??[],f],E={...N.metadata,job_flow_path:x};if(T){let A={...N,metadata:Object.freeze(E)};K(()=>{c.ack(N.id),this._completed.append(A)})}else K(()=>{c.ack(N.id),h.enqueue(N.payload,{metadata:E})});_+=1}},{name:`pump_${f}`,describeKind:"effect",meta:tn("job_flow_pump",{stage:f,has_work:!1})});this.add(y,{name:`pump_${f}`}),this.addDisposer(me(y))}}}stages(){return this._stageNames}queue(e){let t=this._queues.get(e);if(!t)throw new Error(`jobFlow("${this.name}"): unknown stage "${e}"`);return t}enqueue(e,t={}){return this.queue(this._stageNames[0]).enqueue(e,t)}retainedCompleted(){return this.completed.cache}};function Yn(r,e){return new Wn(r,e)}function Jr(r,e){let t=new Jn(r,e),{factory:n,factoryArgs:s,...o}=e??{};return t.tagFactory("jobFlow",We(o)),t}Oe();oe();function Qn(){let r=lt({name:"strategy-entries"}),e=G([r.entries],([i])=>{let a=i;return new Map(a)},{name:"strategy-model",equals:(i,a)=>{let u=i,d=a;if(u.size!==d.size)return!1;for(let[l,f]of u){let c=d.get(l);if(!c||f.attempts!==c.attempts||f.successes!==c.successes)return!1}return!0}});function t(i,a,u){let d=dt(i,a),l=r.get(d),f=(l?.attempts??0)+1,c=(l?.successes??0)+(u?1:0);r.set(d,{rootCause:i,intervention:a,attempts:f,successes:c,successRate:c/f})}function n(i,a){return r.get(dt(i,a))}let s=e.subscribe(()=>{});function o(){s()}return{node:e,record:t,lookup:n,dispose:o}}function Rs(r,e,t,n,s){let o={...at,...s?.severityWeights},i=s?.decayRate??ut,a=s?.effectivenessThreshold??.7,u=s?.effectivenessBoost??15,d=[r,e,t];return n&&d.push(n),G(d,l=>{let f=l[0],c=l[1],h=l[2],p=n?l[3]:0,g=o[f.severity??"medium"],m=(U()-h)/1e9,v=Ur(g,m,i,0),T=dt(f.rootCause,f.intervention),y=c.get(T);return y&&y.successRate>=a&&(v+=u),v+=p*20,v},{name:"priority-score"})}var Yr="intake",Os="triage-output",Qr="retry",Xr="verify-results",Zr="__unrouted";function eo(r,e){let t=yt(e,Nn,(n,s)=>n.replace("{{item}}",JSON.stringify(s)));return(n,s)=>{let o=n.payload.item,i=[{role:"user",content:t(o)}],a=d=>({...n.payload,execution:{item:o,outcome:"failure",detail:d}}),u=d=>d instanceof Error?d.message:String(d);return qn(r,i,{parentSignal:s?.signal,onSuccess:d=>{let l;try{l=JSON.parse(Et(String(d.content)))}catch(c){return a(`execute parse error: ${u(c)}`)}if(l==null||typeof l!="object"||Array.isArray(l))return a(`execute parse error: non-object response: ${JSON.stringify(l)}`);let f=l;return{...n.payload,execution:{item:o,outcome:f.outcome??"failure",detail:f.detail??"unknown",artifact:f.artifact}}},onFailure:(d,l)=>a(d==="complete"?"adapter completed without emitting DATA":`executor failed: ${u(l)}`)})}}function to(r,e){let t=yt(e,En,(n,s)=>{let[o,i]=s;return n.replace("{{execution}}",JSON.stringify(o)).replace("{{item}}",JSON.stringify(i))});return(n,s)=>{let{item:o,execution:i}=n.payload;if(i==null)return{...n.payload,verify:{verified:!1,findings:["verifier: prior execute stage produced no execution"],errorClass:"structural"}};let a=[{role:"user",content:t([i,o])}],u=l=>({...n.payload,verify:{verified:!1,findings:[l],errorClass:"self-correctable"}}),d=l=>l instanceof Error?l.message:String(l);return qn(r,a,{parentSignal:s?.signal,onSuccess:l=>{let f;try{f=JSON.parse(Et(String(l.content)))}catch(h){return u(`verify parse error: ${d(h)}`)}if(f==null||typeof f!="object"||Array.isArray(f))return u(`verify parse error: non-object response: ${JSON.stringify(f)}`);let c=f;return{...n.payload,verify:{verified:c.verified===!0,findings:c.findings??[],errorClass:c.errorClass}}},onFailure:(l,f)=>u(l==="complete"?"verifier completed without emitting DATA":`verifier failed: ${d(f)}`)})}}var nn=class extends ge{queues;executeFlow;jobs;gates;queueTopics;strategy;totalRetries;totalReingestions;priorityScores;reflect;constructor(e,t,n,s,o,i,a,u,d,l,f){super(e),this.queues=t,this.executeFlow=n,this.queueTopics=s,this.jobs=o,this.gates=i,this.strategy=a,this.totalRetries=u,this.totalReingestions=d,this.reflect=l,this.priorityScores=f}get intake(){return this.queues.topic(Yr)}get verifyResults(){return this.queues.topic(Xr)}get retry(){return this.queues.topic(Qr)}get unrouted(){return this.queues.topic(Zr)}stageNodes(){let e=this.queues,t=i=>e.has(i)?`queues::${i}::latest`:null,n=i=>i==null?[]:[i],s=ke.flatMap(i=>n(t(i))),o=[];for(let[i]of this.gates)o.push(`gates::${i}/gate`);return[{label:"INTAKE",paths:n(t("intake"))},{label:"TRIAGE",paths:["triage"]},{label:"QUEUE",paths:s},{label:"GATE",paths:o},{label:"EXECUTE",paths:["executeFlow::execute::events"]},{label:"VERIFY",paths:["executeFlow::verify::events"]},{label:"REFLECT",paths:["reflect"]},{label:"STRATEGY",paths:["strategy"]}]}};function As(r,e){let t=e.adapter,n=e.maxRetries??2,s=e.retainedLimit??1e3,o=e.errorClassifier??Vt,i=new Map;for(let O of ke)i.set(O,{...$t[O],...e.queues?.[O]});let a=Xt(`${r}/queues`,{defaultTopicOptions:{retainedLimit:s}}),u=a.topic(Yr),d=a.topic(Os),l=a.topic(Qr),f=a.topic(Xr),c=new Map;for(let O of ke)c.set(O,a.topic(O));let h=a.topic(Zr),p=Qn(),g=wn(u.latest,p.node),m=yt(e.triagePrompt,xn,(O,D)=>{let[X,ae]=D;return O.replace("{{strategy}}",JSON.stringify(Array.from(ae.entries()))).replace("{{item}}",JSON.stringify(X))}),v=Kr(t,[g],O=>{let D=O;return!D||!D[0]?"":m(D)},{name:"triage",format:"json"}),T=wn(v,g),_=le([T],([O])=>{if(O==null)return;let[D,X]=O;if(!D?.route)return;let ae=X?.[0],Fe={...D,...ae};d.publish(Fe)}).subscribe(()=>{}),w=new Set(ke);for(let O of ke)jn(`bridge/${O}`,d,c.get(O),{map:D=>D.route===O?D:void 0});jn("bridge/__unrouted",d,h,{map:O=>w.has(O.route)?void 0:O});let N=new Map,b=new Map;for(let O of ke)N.set(O,Yn(`jobs/${O}`));let x=[];for(let O of ke){let D=c.get(O),X=N.get(O),ae=new WeakSet,Fe=le([D.events],([ye])=>{let $e=ye??[];for(let ue of $e){if(ae.has(ue))continue;ae.add(ue);let _e=X.enqueue(ue);b.set(xt(ue),{route:O,id:_e})}},{name:`jobs/${O}-mirror`});x.push(Fe.subscribe(()=>{}))}function E(O){let D=xt(O),X=b.get(D);X&&(N.get(X.route)?.removeById(X.id),b.delete(D))}let A=Kn("gates"),k=new Map;for(let O of ke){let D=i.get(O);if(!D.gated)continue;let X=c.get(O),ae=A.approvalGate(`${O}/gate`,X.latest,{maxPending:D.maxPending,startOpen:D.startOpen});k.set(O,ae)}let C=[];for(let O of ke)i.get(O).gated&&k.has(O)?C.push(k.get(O).output):C.push(c.get(O).latest);C.push(l.latest);let H=_r(...C),z=e.executor??eo(t,e.executePrompt),fe=e.verifier??to(t,e.verifyPrompt),ne=e.executeMaxPerPump??Number.MAX_SAFE_INTEGER,we=e.verifyMaxPerPump??Number.MAX_SAFE_INTEGER,xe=Jr(`${r}/executeFlow`,{stages:[{name:"execute",work:O=>z(O),maxPerPump:ne},{name:"verify",work:O=>fe(O),maxPerPump:we}]}),$=le([H],([O])=>{O!=null&&xe.enqueue({item:O})},{name:"execute-enqueue"}),L=$.subscribe(()=>{}),F=e.maxReingestions??1,re=Math.min(e.maxTotalRetries??n*10,100),W=Math.min(e.maxTotalReingestions??F*10,100),se=V(0),S=V(0);function B(O,D,X){return{item:X,execution:O,verified:D.verified,findings:D.findings??[],errorClass:D.errorClass}}function ve(O,D){p.record(D.rootCause,D.intervention,!0),f.publish(O),E(D)}function Ge(O,D){let X=xt(D),ae=D.$retries??0,Fe={...D,$retries:ae+1,summary:`[RETRY ${ae+1}/${n}] ${X} \u2014 Previous attempt failed: ${O.findings.join("; ")}`,relatedTo:[X]};l.publish(Fe)}function Ne(O,D){p.record(D.rootCause,D.intervention,!1),f.publish(O),E(D);let X=xt(D),ae=D.$reingestions??0;ae<F&&In(S,W)&&u.publish({source:D.source,summary:`Verification failed for: ${X}`,evidence:O.findings.join(`
|
|
48
|
-
`),affectsAreas:D.affectsAreas,affectsEvalTasks:D.affectsEvalTasks,severity:D.severity??"high",relatedTo:[X],$reingestions:ae+1})}let R=0,P=le([xe.completed],([O])=>{let D=O??[];R>D.length&&(R=D.length);let X=R;R=D.length;for(let ae=X;ae<D.length;ae++){let Fe=D[ae],{item:ye,execution:$e,verify:ue}=Fe.payload;if($e==null||ue==null){E(ye);continue}let _e=B($e,ue,ye);if(_e.verified){ve(_e,ye);continue}let rn=_e.errorClass??o({item:ye,outcome:$e.outcome,detail:_e.findings.join("; ")}),on=ye.$retries??0;rn==="self-correctable"&&on<n&&In(se,re)?Ge(_e,ye):Ne(_e,ye)}},{name:"verify-dispatch"}),ee=P.subscribe(()=>{}),ie=G([xe.completed],()=>null,{name:"reflect",equals:()=>!1}),be;e.priority&&(be=Ss(c,p,e));let q=new nn(r,a,xe,c,N,k,p,se,S,ie,be);q.addDisposer(_),q.addDisposer(L),q.addDisposer(ee),q.addDisposer(p.dispose);for(let O of x)q.addDisposer(O);if(q.add(g,{name:"triage-input"}),q.add(v,{name:"triage"}),q.add(T,{name:"router-input"}),q.add(H,{name:"execute-input"}),q.add($,{name:"execute-enqueue"}),q.add(P,{name:"verify-dispatch"}),q.add(ie,{name:"reflect"}),q.add(p.node,{name:"strategy"}),q.addDisposer(ie.subscribe(()=>{})),be)for(let[O,D]of be)q.add(D,{name:`priority/${O}`}),q.addDisposer(D.subscribe(()=>{}));q.mount("queues",a),q.mount("gates",A),q.mount("executeFlow",xe);for(let[O,D]of N)q.mount(`jobs/${O}`,D);return q.tagFactory("harnessLoop",We(e)),q}function Ss(r,e,t){if(!t.lastInteractionNs)throw new Error("harnessLoop: `opts.priority` requires `opts.lastInteractionNs` \u2014 pass a Node<number> (e.g. `fromTimer(60_000)` or a `state(monotonicNs())` you bump on human interaction). Priority scores only decay when this node settles; an internal default would freeze age at construction time.");let n=t.lastInteractionNs,s=t.priority??{},o={...at,...s.severityWeights},i=s.decayRate??ut,a=s.effectivenessThreshold??.7,u=s.effectivenessBoost??15,d=new Map;for(let[l,f]of r){let c=G([f.latest,e.node,n],h=>{let p=h[0];if(p==null)return 0;let g=o[p.severity??"medium"]??40,m=(U()-h[2])/1e9,v=g*Math.exp(-i*Math.max(0,m)),T=`${p.rootCause}\u2192${p.intervention}`,_=h[1]?.get(T);return _&&_.successRate>=a&&(v+=u),v},{name:`priority/${l}`});d.set(l,c)}return d}An();function Ds(r,e){let t=qt(r,e),n={};for(let s of ke){let o=r.queues.has(s)?r.queues.topic(s):null;n[s]=o?.retained().length??0}return{...t,queueDepths:n,strategyEntries:r.strategy.node.cache?.size??0,totalRetries:r.totalRetries.cache??0,totalReingestions:r.totalReingestions.cache??0}}Oe();function Cs(r){let e={};for(let{label:t,paths:n}of r.stageNodes())for(let s of n)e[s]=t;return e}function Ms(r,e){let t=e?.logger===null?null:e?.logger??console.log,n=e?.detail??"summary",s=U(),o=[],i=[],a=Cs(r);function u(){return(U()-s)/1e9}function d(l,f,c){let h={elapsed:u(),stage:l,type:f};n!=="summary"&&(h.summary=Is(c)),n==="full"&&(h.data=c),i.push(h)}for(let[l,f]of Object.entries(a))try{let c=r.observe(l,{format:"stage-log",stageLabels:a,logger:t?h=>t(h):()=>{},includeTypes:["data","error","complete"]});c.onEvent(h=>{h.type==="data"?d(f,"data",h.data):h.type==="error"?d(f,"error",h.data):h.type==="complete"&&d(f,"complete",void 0)}),o.push(c)}catch(c){let h=c instanceof Error?c.message:String(c);d(f,"error",`observe-unavailable: ${l} \u2014 ${h}`),t&&t(`[${u().toFixed(3)}s] ${f.padEnd(9)} \u2717 observe-unavailable: ${h}`)}return{get events(){return i},dispose(){for(let l of o)l.dispose();o.length=0}}}function Is(r){if(r==null)return"null";if(typeof r=="string")return no(r,80);if(typeof r=="number"||typeof r=="boolean"||typeof r=="bigint")return String(r);try{let e=JSON.stringify(r);return no(e,120)}catch{return String(r)}}function no(r,e){return r.length>e?`${r.slice(0,e-1)}\u2026`:r}0&&(module.exports={DEFAULT_DECAY_RATE,DEFAULT_EXECUTE_PROMPT,DEFAULT_QUEUE_CONFIGS,DEFAULT_SEVERITY_WEIGHTS,DEFAULT_TRIAGE_PROMPT,DEFAULT_VERIFY_PROMPT,HarnessGraph,QUEUE_NAMES,actuatorExecutor,affectedTaskFilter,autoSolidify,beforeAfterCompare,blindVariation,codeChangeBridge,createIntakeBridge,defaultErrorClassifier,defaultLlmExecutor,defaultLlmVerifier,dispatchActuator,effectivenessTracker,errorCritique,evalIntakeBridge,evalSource,evalVerifier,harnessEvalPair,harnessLoop,harnessProfile,harnessTrace,notifyEffect,priorityScore,refineExecutor,refineLoop,resolvePromptFn,strategyKey,strategyModel});
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/patterns/harness/index.ts
|
|
18
|
+
var harness_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(harness_exports);
|
|
20
|
+
__reExport(harness_exports, require("@graphrefly/pure-ts/patterns/harness"), module.exports);
|
|
21
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/patterns/harness/index.ts"],"sourcesContent":["// Phase 13.9.A shim — re-export from pure-TS sibling until\n// @graphrefly/native (napi binding) and per-milestone swap-overs land.\nexport * from \"@graphrefly/pure-ts/patterns/harness\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAEA,4BAAc,iDAFd;","names":[]}
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
import '../../extra/sources.cjs';
|
|
3
|
-
import '../../node-kK3CvTrR.cjs';
|
|
4
|
-
import '../../types-C0_yquda.cjs';
|
|
5
|
-
import '../../index-DV_1YuVk.cjs';
|
|
6
|
-
import '../../index-D0aciIex.cjs';
|
|
7
|
-
import '../../graph-CWvEUQAq.cjs';
|
|
8
|
-
import '../../sugar-DQjFmVqb.cjs';
|
|
9
|
-
import '../../extra/storage-core.cjs';
|
|
10
|
-
import '../../extra/storage-tiers.cjs';
|
|
11
|
-
import '../../reactive-log-DIGdYqQ6.cjs';
|
|
12
|
-
import '../../index-C5ri2Axc.cjs';
|
|
13
|
-
import '../../pipeline-graph-CIKhynsF.cjs';
|
|
1
|
+
export * from '@graphrefly/pure-ts/patterns/harness';
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
import '../../extra/sources.js';
|
|
3
|
-
import '../../node-kK3CvTrR.js';
|
|
4
|
-
import '../../types-CWFysE9E.js';
|
|
5
|
-
import '../../index-DisjX8a-.js';
|
|
6
|
-
import '../../index-Yq60JP3s.js';
|
|
7
|
-
import '../../graph-D9LFnda9.js';
|
|
8
|
-
import '../../sugar-fhLIE7TT.js';
|
|
9
|
-
import '../../extra/storage-core.js';
|
|
10
|
-
import '../../extra/storage-tiers.js';
|
|
11
|
-
import '../../reactive-log-BKALbfal.js';
|
|
12
|
-
import '../../index-nozs3fFC.js';
|
|
13
|
-
import '../../pipeline-graph-Sgj0gCwn.js';
|
|
1
|
+
export * from '@graphrefly/pure-ts/patterns/harness';
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
// src/patterns/harness/index.ts
|
|
2
|
+
export * from "@graphrefly/pure-ts/patterns/harness";
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/patterns/harness/index.ts"],"sourcesContent":["// Phase 13.9.A shim — re-export from pure-TS sibling until\n// @graphrefly/native (napi binding) and per-milestone swap-overs land.\nexport * from \"@graphrefly/pure-ts/patterns/harness\";\n"],"mappings":";AAEA,cAAc;","names":[]}
|