@graphrefly/ts 0.0.1 → 0.0.3
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 +197 -117
- package/dist/actions-types-CH-XCU9O.d.cts +657 -0
- package/dist/actions-types-w2iPQTkv.d.ts +657 -0
- package/dist/adapters/index.cjs +5157 -2951
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +207 -70
- package/dist/adapters/index.d.ts +207 -70
- package/dist/adapters/index.js +3738 -1688
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/nestjs/microservices.cjs +841 -0
- package/dist/adapters/nestjs/microservices.cjs.map +1 -0
- package/dist/adapters/nestjs/microservices.d.cts +45 -0
- package/dist/adapters/nestjs/microservices.d.ts +45 -0
- package/dist/adapters/nestjs/microservices.js +206 -0
- package/dist/adapters/nestjs/microservices.js.map +1 -0
- package/dist/adapters/nestjs/native.cjs +1391 -0
- package/dist/adapters/nestjs/native.cjs.map +1 -0
- package/dist/adapters/nestjs/native.d.cts +111 -0
- package/dist/adapters/nestjs/native.d.ts +111 -0
- package/dist/adapters/nestjs/native.js +577 -0
- package/dist/adapters/nestjs/native.js.map +1 -0
- package/dist/adapters/nestjs/websockets.cjs +924 -0
- package/dist/adapters/nestjs/websockets.cjs.map +1 -0
- package/dist/adapters/nestjs/websockets.d.cts +47 -0
- package/dist/adapters/nestjs/websockets.d.ts +47 -0
- package/dist/adapters/nestjs/websockets.js +286 -0
- package/dist/adapters/nestjs/websockets.js.map +1 -0
- package/dist/adapters/nestjs.cjs +1085 -0
- package/dist/adapters/nestjs.cjs.map +1 -0
- package/dist/adapters/nestjs.d.cts +385 -0
- package/dist/adapters/nestjs.d.ts +385 -0
- package/dist/adapters/nestjs.js +112 -0
- package/dist/adapters/nestjs.js.map +1 -0
- package/dist/adapters/observe-storage.d.cts +3 -3
- package/dist/adapters/observe-storage.d.ts +3 -3
- package/dist/adapters/observe-storage.js +4 -4
- package/dist/adapters/react.cjs.map +1 -1
- package/dist/adapters/react.d.cts +2 -2
- package/dist/adapters/react.d.ts +2 -2
- package/dist/adapters/react.js +1 -1
- package/dist/adapters/solid.cjs.map +1 -1
- package/dist/adapters/solid.d.cts +2 -2
- package/dist/adapters/solid.d.ts +2 -2
- package/dist/adapters/solid.js +1 -1
- package/dist/adapters/svelte.cjs.map +1 -1
- package/dist/adapters/svelte.d.cts +2 -2
- package/dist/adapters/svelte.d.ts +2 -2
- package/dist/adapters/svelte.js +1 -1
- package/dist/adapters/vue.cjs.map +1 -1
- package/dist/adapters/vue.d.cts +2 -2
- package/dist/adapters/vue.d.ts +2 -2
- package/dist/adapters/vue.js +1 -1
- package/dist/{agent-runtime-BesGDZcB.d.ts → agent-runtime-types-core-CKwrBDyi.d.ts} +171 -320
- package/dist/{agent-runtime-DZTJ3C-p.d.cts → agent-runtime-types-core-bfl4m0vM.d.cts} +171 -320
- package/dist/agent-runtime-types-tool-BLPV3azj.d.cts +695 -0
- package/dist/agent-runtime-types-tool-hwqvVqNt.d.ts +695 -0
- package/dist/agentic-memory-retention-CLwI76JK.d.ts +14 -0
- package/dist/agentic-memory-retention-Cz8GR6ie.d.cts +14 -0
- package/dist/{agentic-memory-DfuVZ-lY.d.cts → agentic-memory-types-JDr7MPhh.d.cts} +13 -57
- package/dist/{agentic-memory-BmRCvh0d.d.ts → agentic-memory-types-khYJgzKL.d.ts} +13 -57
- package/dist/{capability-admission-B0BzqAm5.d.cts → capability-admission-B8RNFyaZ.d.cts} +3 -3
- package/dist/{capability-admission-g0mn9hpq.d.ts → capability-admission-Dkw1Xz3r.d.ts} +3 -3
- package/dist/chunk-2KUAG2GZ.js +9693 -0
- package/dist/chunk-2KUAG2GZ.js.map +1 -0
- package/dist/{chunk-CZNV3VXM.js → chunk-3J7UPZL5.js} +11 -11
- package/dist/{chunk-HKK2JD7Z.js → chunk-3LYI6ADX.js} +12 -125
- package/dist/chunk-3LYI6ADX.js.map +1 -0
- package/dist/{chunk-YXMZ2N6J.js → chunk-4M37FH2I.js} +1071 -1025
- package/dist/chunk-4M37FH2I.js.map +1 -0
- package/dist/{chunk-YDSIVHRR.js → chunk-4NWSNI4K.js} +1598 -1584
- package/dist/chunk-4NWSNI4K.js.map +1 -0
- package/dist/{chunk-Z2ANQ6JW.js → chunk-4Q77MMJY.js} +2 -2
- package/dist/{chunk-SS2A464I.js → chunk-54WPEODM.js} +3 -3
- package/dist/chunk-54WPEODM.js.map +1 -0
- package/dist/chunk-6E76H4OU.js +132 -0
- package/dist/chunk-6E76H4OU.js.map +1 -0
- package/dist/chunk-7GOTIIQ7.js +819 -0
- package/dist/chunk-7GOTIIQ7.js.map +1 -0
- package/dist/{chunk-V7CIJE4B.js → chunk-DKFWDTVY.js} +92 -9
- package/dist/chunk-DKFWDTVY.js.map +1 -0
- package/dist/{chunk-FBUU43PM.js → chunk-E4QCH32M.js} +448 -446
- package/dist/chunk-E4QCH32M.js.map +1 -0
- package/dist/{chunk-XKXWK2KP.js → chunk-GXU6WFEJ.js} +1157 -1021
- package/dist/chunk-GXU6WFEJ.js.map +1 -0
- package/dist/{chunk-K3FXTC3I.js → chunk-HJACH5PU.js} +3 -3
- package/dist/{chunk-GTPCOEOZ.js → chunk-IDMLXLLG.js} +3 -3
- package/dist/{chunk-DKP56CSW.js → chunk-JKAYLDQV.js} +2 -2
- package/dist/{chunk-4VLAQHZI.js → chunk-K7FB3JTD.js} +17 -1
- package/dist/chunk-K7FB3JTD.js.map +1 -0
- package/dist/{chunk-43BKLFZU.js → chunk-KFURM6FM.js} +10 -10
- package/dist/{chunk-H75VXTGT.js → chunk-L6LDXRWE.js} +3 -3
- package/dist/{chunk-H75VXTGT.js.map → chunk-L6LDXRWE.js.map} +1 -1
- package/dist/chunk-MCOFHMUU.js +4131 -0
- package/dist/chunk-MCOFHMUU.js.map +1 -0
- package/dist/chunk-MQEQMS7B.js +1009 -0
- package/dist/chunk-MQEQMS7B.js.map +1 -0
- package/dist/chunk-MTELVIYR.js +1421 -0
- package/dist/chunk-MTELVIYR.js.map +1 -0
- package/dist/{chunk-3JR3EDB2.js → chunk-NNDIFUKX.js} +121 -115
- package/dist/chunk-NNDIFUKX.js.map +1 -0
- package/dist/{chunk-2747WN4Y.js → chunk-PUSRRALM.js} +3 -3
- package/dist/{chunk-QFY4AFY4.js → chunk-PVC7WDKI.js} +58 -52
- package/dist/chunk-PVC7WDKI.js.map +1 -0
- package/dist/{chunk-VTHLCFN4.js → chunk-RAHNUYA5.js} +2 -2
- package/dist/chunk-TQPCAIQI.js +612 -0
- package/dist/chunk-TQPCAIQI.js.map +1 -0
- package/dist/{chunk-IXZBUWSP.js → chunk-UEMN5URK.js} +2 -2
- package/dist/chunk-WOS7RJYZ.js +1320 -0
- package/dist/chunk-WOS7RJYZ.js.map +1 -0
- package/dist/{chunk-6PHB5CJS.js → chunk-ZLFRB6FI.js} +2 -2
- package/dist/composition/index.cjs +1228 -1076
- package/dist/composition/index.cjs.map +1 -1
- package/dist/composition/index.d.cts +3 -3
- package/dist/composition/index.d.ts +3 -3
- package/dist/composition/index.js +4 -4
- package/dist/core/index.cjs +1198 -1046
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +23 -2
- package/dist/core/index.d.ts +23 -2
- package/dist/core/index.js +2 -2
- package/dist/cqrs/index.d.cts +3 -3
- package/dist/cqrs/index.d.ts +3 -3
- package/dist/cqrs/messaging.d.cts +4 -4
- package/dist/cqrs/messaging.d.ts +4 -4
- package/dist/cqrs/work-queue.d.cts +5 -5
- package/dist/cqrs/work-queue.d.ts +5 -5
- package/dist/data-structures/index.cjs +1226 -1074
- package/dist/data-structures/index.cjs.map +1 -1
- package/dist/data-structures/index.d.cts +8 -7
- package/dist/data-structures/index.d.ts +8 -7
- package/dist/data-structures/index.js +6 -5
- package/dist/{describe-DYMw_l1C.d.cts → describe-BumQ-3_0.d.cts} +1 -1
- package/dist/{describe-BpyJuWkw.d.ts → describe-cYr_Z5zm.d.ts} +1 -1
- package/dist/executors/tool-provider-adapters.cjs +3091 -0
- package/dist/executors/tool-provider-adapters.cjs.map +1 -0
- package/dist/executors/tool-provider-adapters.d.cts +174 -0
- package/dist/executors/tool-provider-adapters.d.ts +174 -0
- package/dist/executors/tool-provider-adapters.js +1336 -0
- package/dist/executors/tool-provider-adapters.js.map +1 -0
- package/dist/executors/tool-provider-runtime.cjs +5178 -0
- package/dist/executors/tool-provider-runtime.cjs.map +1 -0
- package/dist/executors/tool-provider-runtime.d.cts +17 -0
- package/dist/executors/tool-provider-runtime.d.ts +17 -0
- package/dist/executors/tool-provider-runtime.js +15 -0
- package/dist/executors/tool-provider-runtime.js.map +1 -0
- package/dist/executors/tool-provider.cjs +6392 -0
- package/dist/executors/tool-provider.cjs.map +1 -0
- package/dist/executors/tool-provider.d.cts +60 -0
- package/dist/executors/tool-provider.d.ts +60 -0
- package/dist/executors/tool-provider.js +89 -0
- package/dist/executors/tool-provider.js.map +1 -0
- package/dist/executors/work-queue.d.cts +6 -6
- package/dist/executors/work-queue.d.ts +6 -6
- package/dist/graph/index.cjs +1499 -1341
- package/dist/graph/index.cjs.map +1 -1
- package/dist/graph/index.d.cts +9 -8
- package/dist/graph/index.d.ts +9 -8
- package/dist/graph/index.js +23 -22
- package/dist/{graph-DCEWh4T2.d.cts → graph-C1C-wb0L.d.cts} +266 -137
- package/dist/{graph-D-1-SQeC.d.ts → graph-CS0b4V9B.d.ts} +266 -137
- package/dist/{index-72VZC0-E.d.cts → index-DLrNopda.d.cts} +151 -10
- package/dist/{index-Bmxeu0nK.d.ts → index-DzJni3_6.d.ts} +151 -10
- package/dist/index.cjs +3397 -3140
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -9
- package/dist/index.d.ts +12 -9
- package/dist/index.js +110 -109
- package/dist/inspection/boundary.d.cts +4 -4
- package/dist/inspection/boundary.d.ts +4 -4
- package/dist/measurements-BWAnochv.d.ts +294 -0
- package/dist/measurements-B_gJfD8h.d.cts +294 -0
- package/dist/messaging/index.cjs +57 -51
- package/dist/messaging/index.cjs.map +1 -1
- package/dist/messaging/index.d.cts +11 -276
- package/dist/messaging/index.d.ts +11 -276
- package/dist/messaging/index.js +1 -1
- package/dist/operators/index.cjs +1228 -1076
- package/dist/operators/index.cjs.map +1 -1
- package/dist/operators/index.d.cts +5 -5
- package/dist/operators/index.d.ts +5 -5
- package/dist/operators/index.js +5 -5
- package/dist/orchestration/index.cjs +8844 -6071
- package/dist/orchestration/index.cjs.map +1 -1
- package/dist/orchestration/index.d.cts +171 -224
- package/dist/orchestration/index.d.ts +171 -224
- package/dist/orchestration/index.js +42 -991
- package/dist/orchestration/index.js.map +1 -1
- package/dist/orchestration/messaging.d.cts +5 -8
- package/dist/orchestration/messaging.d.ts +5 -8
- package/dist/orchestration/work-queue.cjs +1243 -5
- package/dist/orchestration/work-queue.cjs.map +1 -1
- package/dist/orchestration/work-queue.d.cts +121 -10
- package/dist/orchestration/work-queue.d.ts +121 -10
- package/dist/orchestration/work-queue.js +1067 -4
- package/dist/orchestration/work-queue.js.map +1 -1
- package/dist/patterns/event-flow.cjs +6 -20
- package/dist/patterns/event-flow.cjs.map +1 -1
- package/dist/patterns/event-flow.d.cts +4 -4
- package/dist/patterns/event-flow.d.ts +4 -4
- package/dist/patterns/event-flow.js +2 -2
- package/dist/patterns/index.cjs +453 -465
- package/dist/patterns/index.cjs.map +1 -1
- package/dist/patterns/index.d.cts +6 -5
- package/dist/patterns/index.d.ts +6 -5
- package/dist/patterns/index.js +3 -3
- package/dist/process-types-BB7oRhX3.d.cts +200 -0
- package/dist/process-types-QNhyoYJ8.d.ts +200 -0
- package/dist/{reactive-collection-DNV0-gFi.d.cts → reactive-collection-BYlWvtnp.d.cts} +4 -34
- package/dist/{reactive-collection-BAmfrGjd.d.ts → reactive-collection-efOEdGFN.d.ts} +4 -34
- package/dist/{reactive-collection-storage-BNEldDyi.d.cts → reactive-collection-storage-BjoLsoiC.d.cts} +5 -5
- package/dist/{reactive-collection-storage-YZsAQsWK.d.ts → reactive-collection-storage-DwW6UuK_.d.ts} +5 -5
- package/dist/{reactive-map-DRD1LJ2H.d.cts → reactive-map-BHacbIqz.d.cts} +7 -2
- package/dist/{reactive-map-EsDiCmJk.d.ts → reactive-map-DN4Jyqnf.d.ts} +7 -2
- package/dist/render/index.d.cts +2 -2
- package/dist/render/index.d.ts +2 -2
- package/dist/scheduled-readiness-BmqXxnzX.d.ts +91 -0
- package/dist/scheduled-readiness-CYSw7KDE.d.cts +91 -0
- package/dist/semantic-memory-graph-B_LwbM-E.d.cts +30 -0
- package/dist/semantic-memory-graph-rsFNNhwn.d.ts +30 -0
- package/dist/{semantic-memory-graph-DKuNzuWw.d.cts → semantic-memory-graph-types-Y73bbwVI.d.cts} +2 -28
- package/dist/{semantic-memory-graph-uwbwJdhe.d.ts → semantic-memory-graph-types-safmPkuX.d.ts} +2 -28
- package/dist/solutions/index.cjs +6353 -6169
- package/dist/solutions/index.cjs.map +1 -1
- package/dist/solutions/index.d.cts +12 -10
- package/dist/solutions/index.d.ts +12 -10
- package/dist/solutions/index.js +5 -5
- package/dist/solutions/reactive-layout/browser/index.cjs +116 -108
- package/dist/solutions/reactive-layout/browser/index.cjs.map +1 -1
- package/dist/solutions/reactive-layout/browser/index.d.cts +4 -4
- package/dist/solutions/reactive-layout/browser/index.d.ts +4 -4
- package/dist/solutions/reactive-layout/browser/index.js +3 -3
- package/dist/solutions/reactive-layout/index.cjs +3578 -3350
- package/dist/solutions/reactive-layout/index.cjs.map +1 -1
- package/dist/solutions/reactive-layout/index.d.cts +32 -576
- package/dist/solutions/reactive-layout/index.d.ts +32 -576
- package/dist/solutions/reactive-layout/index.js +65 -5
- package/dist/solutions/reactive-layout/node-canvas/index.cjs +127 -117
- package/dist/solutions/reactive-layout/node-canvas/index.cjs.map +1 -1
- package/dist/solutions/reactive-layout/node-canvas/index.d.cts +4 -4
- package/dist/solutions/reactive-layout/node-canvas/index.d.ts +4 -4
- package/dist/solutions/reactive-layout/node-canvas/index.js +3 -3
- package/dist/solutions/reactive-layout/react-native/index.cjs +127 -117
- package/dist/solutions/reactive-layout/react-native/index.cjs.map +1 -1
- package/dist/solutions/reactive-layout/react-native/index.d.cts +4 -4
- package/dist/solutions/reactive-layout/react-native/index.d.ts +4 -4
- package/dist/solutions/reactive-layout/react-native/index.js +3 -3
- package/dist/solutions/reactive-layout/skia/index.cjs +127 -117
- package/dist/solutions/reactive-layout/skia/index.cjs.map +1 -1
- package/dist/solutions/reactive-layout/skia/index.d.cts +4 -4
- package/dist/solutions/reactive-layout/skia/index.d.ts +4 -4
- package/dist/solutions/reactive-layout/skia/index.js +3 -3
- package/dist/solutions/work-item/actions.cjs +1609 -1428
- package/dist/solutions/work-item/actions.cjs.map +1 -1
- package/dist/solutions/work-item/actions.d.cts +23 -184
- package/dist/solutions/work-item/actions.d.ts +23 -184
- package/dist/solutions/work-item/actions.js +1558 -934
- package/dist/solutions/work-item/actions.js.map +1 -1
- package/dist/solutions/work-item/scheduling.cjs +9181 -1838
- package/dist/solutions/work-item/scheduling.cjs.map +1 -1
- package/dist/solutions/work-item/scheduling.d.cts +1763 -328
- package/dist/solutions/work-item/scheduling.d.ts +1763 -328
- package/dist/solutions/work-item/scheduling.js +117 -3
- package/dist/solutions/work-item/work-queue.d.cts +7 -7
- package/dist/solutions/work-item/work-queue.d.ts +7 -7
- package/dist/sources/browser.cjs +1318 -1083
- package/dist/sources/browser.cjs.map +1 -1
- package/dist/sources/browser.d.cts +22 -6
- package/dist/sources/browser.d.ts +22 -6
- package/dist/sources/browser.js +4 -4
- package/dist/sources/browser.js.map +1 -1
- package/dist/sources/index.cjs +1318 -1083
- package/dist/sources/index.cjs.map +1 -1
- package/dist/sources/index.d.cts +4 -4
- package/dist/sources/index.d.ts +4 -4
- package/dist/sources/index.js +4 -4
- package/dist/sources/node.d.cts +3 -3
- package/dist/sources/node.d.ts +3 -3
- package/dist/storage/browser.cjs +16 -0
- package/dist/storage/browser.cjs.map +1 -1
- package/dist/storage/browser.js +3 -3
- package/dist/storage/index.cjs +16 -0
- package/dist/storage/index.cjs.map +1 -1
- package/dist/storage/index.d.cts +5 -4
- package/dist/storage/index.d.ts +5 -4
- package/dist/storage/index.js +6 -6
- package/dist/storage/node.cjs +16 -0
- package/dist/storage/node.cjs.map +1 -1
- package/dist/storage/node.js +3 -3
- package/dist/{store-C-joM4gh.d.ts → store-6_CHF6Ge.d.ts} +1 -1
- package/dist/{store-CNJwmT-h.d.cts → store-BljX8RkQ.d.cts} +1 -1
- package/dist/types-BAw2QVVE.d.cts +274 -0
- package/dist/types-BUbbbh4f.d.cts +34 -0
- package/dist/types-CMnzoL54.d.cts +457 -0
- package/dist/{types-CcPIn7sy.d.cts → types-CTN3XoMl.d.cts} +57 -108
- package/dist/types-CV_ohy5T.d.cts +357 -0
- package/dist/{types-BsJvElYZ.d.ts → types-DChxk1vK.d.ts} +57 -108
- package/dist/types-DRu7SnLV.d.ts +274 -0
- package/dist/types-DeID_FRl.d.ts +34 -0
- package/dist/types-IhKH0hGW.d.ts +357 -0
- package/dist/types-ePlD2uyT.d.ts +457 -0
- package/dist/{work-item-runtime-qaVgsL0T.d.cts → work-item-runtime-types-BTxLskN5.d.cts} +3 -93
- package/dist/{work-item-runtime-C3M79vE9.d.ts → work-item-runtime-types-DAsZbb2y.d.ts} +3 -93
- package/dist/work-queue/index.cjs +957 -953
- package/dist/work-queue/index.cjs.map +1 -1
- package/dist/work-queue/index.d.cts +9 -357
- package/dist/work-queue/index.d.ts +9 -357
- package/dist/work-queue/index.js +957 -953
- package/dist/work-queue/index.js.map +1 -1
- package/package.json +611 -513
- package/dist/chunk-3JR3EDB2.js.map +0 -1
- package/dist/chunk-4VLAQHZI.js.map +0 -1
- package/dist/chunk-6XAIOL3X.js +0 -2407
- package/dist/chunk-6XAIOL3X.js.map +0 -1
- package/dist/chunk-FBUU43PM.js.map +0 -1
- package/dist/chunk-HKK2JD7Z.js.map +0 -1
- package/dist/chunk-PC3BTTBE.js +0 -3217
- package/dist/chunk-PC3BTTBE.js.map +0 -1
- package/dist/chunk-QFY4AFY4.js.map +0 -1
- package/dist/chunk-SS2A464I.js.map +0 -1
- package/dist/chunk-V7CIJE4B.js.map +0 -1
- package/dist/chunk-XKXWK2KP.js.map +0 -1
- package/dist/chunk-YDSIVHRR.js.map +0 -1
- package/dist/chunk-YXMZ2N6J.js.map +0 -1
- /package/dist/{chunk-CZNV3VXM.js.map → chunk-3J7UPZL5.js.map} +0 -0
- /package/dist/{chunk-Z2ANQ6JW.js.map → chunk-4Q77MMJY.js.map} +0 -0
- /package/dist/{chunk-K3FXTC3I.js.map → chunk-HJACH5PU.js.map} +0 -0
- /package/dist/{chunk-GTPCOEOZ.js.map → chunk-IDMLXLLG.js.map} +0 -0
- /package/dist/{chunk-DKP56CSW.js.map → chunk-JKAYLDQV.js.map} +0 -0
- /package/dist/{chunk-43BKLFZU.js.map → chunk-KFURM6FM.js.map} +0 -0
- /package/dist/{chunk-2747WN4Y.js.map → chunk-PUSRRALM.js.map} +0 -0
- /package/dist/{chunk-VTHLCFN4.js.map → chunk-RAHNUYA5.js.map} +0 -0
- /package/dist/{chunk-IXZBUWSP.js.map → chunk-UEMN5URK.js.map} +0 -0
- /package/dist/{chunk-6PHB5CJS.js.map → chunk-ZLFRB6FI.js.map} +0 -0
|
@@ -2,26 +2,43 @@ import {
|
|
|
2
2
|
admitAgentRequestProposal,
|
|
3
3
|
agentRequestLedgerViews,
|
|
4
4
|
agentRequestProposalFromDecision,
|
|
5
|
+
breakerBundle,
|
|
6
|
+
constantBackoff,
|
|
5
7
|
effectRun,
|
|
6
8
|
effectRunCompletionProjector,
|
|
7
|
-
executorOutcomeViewProjector,
|
|
8
9
|
fakeExecutorBlocked,
|
|
9
10
|
fakeExecutorCanceled,
|
|
10
11
|
fakeExecutorFailure,
|
|
11
12
|
fakeExecutorResult,
|
|
12
13
|
fakeExecutorTimeout,
|
|
13
14
|
issueAgentRequest,
|
|
14
|
-
|
|
15
|
+
processBundle,
|
|
16
|
+
processEffectRunner,
|
|
17
|
+
rateLimitBundle,
|
|
15
18
|
requestSatisfactionProjector,
|
|
19
|
+
retryStatusBundle,
|
|
20
|
+
scheduledReadinessProjector,
|
|
16
21
|
structuredAgentDecisionInterpreter,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
timeoutBundle,
|
|
23
|
+
toolProviderRunAdmissionProjector,
|
|
24
|
+
toolProviderRunRetryProjector
|
|
25
|
+
} from "../chunk-MCOFHMUU.js";
|
|
26
|
+
import {
|
|
27
|
+
buildToolProviderAdapterInputs,
|
|
28
|
+
executorOutcomeViewProjector,
|
|
29
|
+
localBuiltinToolProviderCatalog,
|
|
30
|
+
resolveToolProviderExecutionPolicies,
|
|
31
|
+
toolProviderAdapterInputProjector,
|
|
32
|
+
toolProviderPolicyResolutionProjector,
|
|
33
|
+
validateToolProviderExecutionPolicy
|
|
34
|
+
} from "../chunk-MTELVIYR.js";
|
|
22
35
|
import {
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
buildToolProviderExecutorOutcome,
|
|
37
|
+
requestToolProviderAdapterRun,
|
|
38
|
+
toolProviderAdapterRunProjector
|
|
39
|
+
} from "../chunk-7GOTIIQ7.js";
|
|
40
|
+
import "../chunk-TQPCAIQI.js";
|
|
41
|
+
import "../chunk-PUSRRALM.js";
|
|
25
42
|
import {
|
|
26
43
|
backoffDelayMs,
|
|
27
44
|
nextRetryDelayMs,
|
|
@@ -29,992 +46,21 @@ import {
|
|
|
29
46
|
retryPolicy,
|
|
30
47
|
shouldRetry
|
|
31
48
|
} from "../chunk-OOEN33FB.js";
|
|
32
|
-
import "../chunk-
|
|
33
|
-
import "../chunk-
|
|
34
|
-
import "../chunk-
|
|
35
|
-
import
|
|
36
|
-
depBatch
|
|
37
|
-
} from "../chunk-WQIA3GFB.js";
|
|
49
|
+
import "../chunk-DKFWDTVY.js";
|
|
50
|
+
import "../chunk-54WPEODM.js";
|
|
51
|
+
import "../chunk-GXU6WFEJ.js";
|
|
52
|
+
import "../chunk-WQIA3GFB.js";
|
|
38
53
|
import "../chunk-S6HXABGL.js";
|
|
39
|
-
import "../chunk-
|
|
54
|
+
import "../chunk-K7FB3JTD.js";
|
|
40
55
|
import "../chunk-DGUM43GV.js";
|
|
41
|
-
|
|
42
|
-
// src/orchestration/index.ts
|
|
43
|
-
var processCommandSources = /* @__PURE__ */ new WeakMap();
|
|
44
|
-
function retryStatusBundle(graph, events, opts = {}) {
|
|
45
|
-
const policy = opts.policy ?? retryPolicy();
|
|
46
|
-
const name = opts.name ?? "retry";
|
|
47
|
-
const status = graph.node(
|
|
48
|
-
[events],
|
|
49
|
-
(ctx) => {
|
|
50
|
-
let next = ctx.state.get() ?? { state: "idle", attempt: 0, maxAttempts: policy.maxAttempts };
|
|
51
|
-
for (const raw of depBatch(ctx, 0) ?? []) {
|
|
52
|
-
const event = raw;
|
|
53
|
-
if (event.kind === "attempt") {
|
|
54
|
-
next = { state: "running", attempt: event.attempt, maxAttempts: policy.maxAttempts };
|
|
55
|
-
} else if (event.kind === "retry") {
|
|
56
|
-
next = {
|
|
57
|
-
state: "waiting",
|
|
58
|
-
attempt: event.attempt,
|
|
59
|
-
maxAttempts: policy.maxAttempts,
|
|
60
|
-
delayMs: event.delayMs
|
|
61
|
-
};
|
|
62
|
-
} else if (event.kind === "success") {
|
|
63
|
-
next = {
|
|
64
|
-
state: "succeeded",
|
|
65
|
-
attempt: event.attempt ?? next.attempt,
|
|
66
|
-
maxAttempts: policy.maxAttempts
|
|
67
|
-
};
|
|
68
|
-
} else if (event.kind === "failure") {
|
|
69
|
-
const attempt = event.attempt ?? next.attempt;
|
|
70
|
-
next = {
|
|
71
|
-
state: shouldRetry(policy, attempt) ? "failed" : "exhausted",
|
|
72
|
-
attempt,
|
|
73
|
-
maxAttempts: policy.maxAttempts,
|
|
74
|
-
delayMs: shouldRetry(policy, attempt) ? nextRetryDelayMs(policy, attempt + 1) : void 0
|
|
75
|
-
};
|
|
76
|
-
} else {
|
|
77
|
-
next = {
|
|
78
|
-
state: "exhausted",
|
|
79
|
-
attempt: event.attempt,
|
|
80
|
-
maxAttempts: policy.maxAttempts
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
ctx.state.set(next);
|
|
85
|
-
ctx.down([["DATA", next]]);
|
|
86
|
-
},
|
|
87
|
-
{ name: `${name}/status`, factory: "retryStatus" }
|
|
88
|
-
);
|
|
89
|
-
const errors = graph.node(
|
|
90
|
-
[events],
|
|
91
|
-
(ctx) => {
|
|
92
|
-
for (const raw of depBatch(ctx, 0) ?? []) {
|
|
93
|
-
const event = raw;
|
|
94
|
-
if ("error" in event) ctx.down([["DATA", event.error]]);
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
{ name: `${name}/errors`, factory: "retryErrors" }
|
|
98
|
-
);
|
|
99
|
-
return { status, errors };
|
|
100
|
-
}
|
|
101
|
-
function breakerBundle(graph, events, opts) {
|
|
102
|
-
if (!Number.isInteger(opts.failureThreshold) || opts.failureThreshold <= 0) {
|
|
103
|
-
throw new RangeError("breakerBundle: failureThreshold must be a positive integer");
|
|
104
|
-
}
|
|
105
|
-
const name = opts.name ?? "breaker";
|
|
106
|
-
const now = opts.now ?? Date.now;
|
|
107
|
-
const status = graph.node(
|
|
108
|
-
[events],
|
|
109
|
-
(ctx) => {
|
|
110
|
-
let next = ctx.state.get() ?? { state: "closed", failures: 0 };
|
|
111
|
-
if (next.state === "open" && opts.resetAfterMs !== void 0 && next.openedAtMs !== void 0 && now() - next.openedAtMs >= opts.resetAfterMs) {
|
|
112
|
-
next = { ...next, state: "half-open" };
|
|
113
|
-
}
|
|
114
|
-
for (const raw of depBatch(ctx, 0) ?? []) {
|
|
115
|
-
const event = raw;
|
|
116
|
-
if (event.kind === "success") {
|
|
117
|
-
next = { state: "closed", failures: 0 };
|
|
118
|
-
} else if (event.kind === "failure" || event.kind === "exhausted") {
|
|
119
|
-
const failures = next.failures + 1;
|
|
120
|
-
next = failures >= opts.failureThreshold ? { state: "open", failures, openedAtMs: now() } : { ...next, failures };
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
ctx.state.set(next);
|
|
124
|
-
ctx.down([["DATA", next]]);
|
|
125
|
-
},
|
|
126
|
-
{ name: `${name}/status`, factory: "breakerStatus" }
|
|
127
|
-
);
|
|
128
|
-
const allowed = graph.node(
|
|
129
|
-
[status],
|
|
130
|
-
(ctx) => {
|
|
131
|
-
const statusBatch = depBatch(ctx, 0) ?? [];
|
|
132
|
-
for (const value of statusBatch) {
|
|
133
|
-
ctx.down([["DATA", value.state !== "open"]]);
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
{ name: `${name}/allowed`, factory: "breakerAllowed" }
|
|
137
|
-
);
|
|
138
|
-
return { status, allowed };
|
|
139
|
-
}
|
|
140
|
-
function rateLimitBundle(graph, source, opts) {
|
|
141
|
-
if (!Number.isInteger(opts.max) || opts.max <= 0) {
|
|
142
|
-
throw new RangeError("rateLimitBundle: max must be a positive integer");
|
|
143
|
-
}
|
|
144
|
-
if (!Number.isFinite(opts.windowMs) || opts.windowMs <= 0) {
|
|
145
|
-
throw new RangeError("rateLimitBundle: windowMs must be positive");
|
|
146
|
-
}
|
|
147
|
-
const now = opts.now ?? Date.now;
|
|
148
|
-
const name = opts.name ?? "rateLimit";
|
|
149
|
-
const events = graph.node(
|
|
150
|
-
[source],
|
|
151
|
-
(ctx) => {
|
|
152
|
-
const current = now();
|
|
153
|
-
let state = ctx.state.get() ?? { count: 0, resetAtMs: current + opts.windowMs, allowed: 0, dropped: 0 };
|
|
154
|
-
if (current >= state.resetAtMs) {
|
|
155
|
-
state = { ...state, count: 0, resetAtMs: current + opts.windowMs };
|
|
156
|
-
}
|
|
157
|
-
for (const value of depBatch(ctx, 0) ?? []) {
|
|
158
|
-
const allowed2 = state.count < opts.max;
|
|
159
|
-
state = allowed2 ? { ...state, count: state.count + 1, allowed: state.allowed + 1 } : { ...state, dropped: state.dropped + 1 };
|
|
160
|
-
const status2 = {
|
|
161
|
-
allowed: state.allowed,
|
|
162
|
-
dropped: state.dropped,
|
|
163
|
-
remaining: Math.max(0, opts.max - state.count),
|
|
164
|
-
resetAtMs: state.resetAtMs
|
|
165
|
-
};
|
|
166
|
-
ctx.down([
|
|
167
|
-
[
|
|
168
|
-
"DATA",
|
|
169
|
-
allowed2 ? { kind: "allowed", value, status: status2 } : { kind: "dropped", value, status: status2 }
|
|
170
|
-
]
|
|
171
|
-
]);
|
|
172
|
-
}
|
|
173
|
-
ctx.state.set(state);
|
|
174
|
-
},
|
|
175
|
-
{ name: `${name}/events`, factory: "rateLimitEvents" }
|
|
176
|
-
);
|
|
177
|
-
const allowed = graph.node(
|
|
178
|
-
[events],
|
|
179
|
-
(ctx) => {
|
|
180
|
-
for (const event of depBatch(ctx, 0) ?? []) {
|
|
181
|
-
const typed = event;
|
|
182
|
-
if (typed.kind === "allowed") ctx.down([["DATA", typed.value]]);
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
{ name: `${name}/allowed`, factory: "rateLimitAllowed" }
|
|
186
|
-
);
|
|
187
|
-
const dropped = graph.node(
|
|
188
|
-
[events],
|
|
189
|
-
(ctx) => {
|
|
190
|
-
for (const event of depBatch(ctx, 0) ?? []) {
|
|
191
|
-
const typed = event;
|
|
192
|
-
if (typed.kind === "dropped") ctx.down([["DATA", typed.value]]);
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
{ name: `${name}/dropped`, factory: "rateLimitDropped" }
|
|
196
|
-
);
|
|
197
|
-
const status = graph.node(
|
|
198
|
-
[events],
|
|
199
|
-
(ctx) => {
|
|
200
|
-
for (const event of depBatch(ctx, 0) ?? []) {
|
|
201
|
-
ctx.down([["DATA", event.status]]);
|
|
202
|
-
}
|
|
203
|
-
},
|
|
204
|
-
{ name: `${name}/status`, factory: "rateLimitStatus" }
|
|
205
|
-
);
|
|
206
|
-
return { allowed, dropped, status };
|
|
207
|
-
}
|
|
208
|
-
function timeoutBundle(graph, source, ms, opts = {}) {
|
|
209
|
-
const name = opts.name ?? "timeout";
|
|
210
|
-
const node = timeout(source, ms);
|
|
211
|
-
const status = graph.node(
|
|
212
|
-
[node],
|
|
213
|
-
(ctx) => {
|
|
214
|
-
const terminal = ctx.terminal[0];
|
|
215
|
-
if (terminal === true) ctx.down([["DATA", "completed"]]);
|
|
216
|
-
else if (terminal !== false && terminal !== void 0) ctx.down([["DATA", "errored"]]);
|
|
217
|
-
else if ((depBatch(ctx, 0) ?? []).length > 0) ctx.down([["DATA", "running"]]);
|
|
218
|
-
},
|
|
219
|
-
{ name: `${name}/status`, factory: "timeoutStatus" }
|
|
220
|
-
);
|
|
221
|
-
const errors = graph.node(
|
|
222
|
-
[node],
|
|
223
|
-
(ctx) => {
|
|
224
|
-
const terminal = ctx.terminal[0];
|
|
225
|
-
if (terminal !== true && terminal !== false && terminal !== void 0) {
|
|
226
|
-
ctx.down([["DATA", terminal]]);
|
|
227
|
-
}
|
|
228
|
-
},
|
|
229
|
-
{ name: `${name}/errors`, factory: "timeoutErrors" }
|
|
230
|
-
);
|
|
231
|
-
return { node, status, errors };
|
|
232
|
-
}
|
|
233
|
-
function processBundle(graph, opts) {
|
|
234
|
-
if (typeof opts.reduce !== "function") {
|
|
235
|
-
throw new TypeError("processBundle: reduce must be a function");
|
|
236
|
-
}
|
|
237
|
-
if (opts.initialState === void 0) {
|
|
238
|
-
throw new TypeError("processBundle: initialState must not be undefined");
|
|
239
|
-
}
|
|
240
|
-
const name = opts.name ?? "process";
|
|
241
|
-
const now = opts.now ?? Date.now;
|
|
242
|
-
const topology = graph.topologyGroup({ name: `${name}.process` });
|
|
243
|
-
const command = topology.node([], null, {
|
|
244
|
-
name: `${name}/command`,
|
|
245
|
-
factory: "processCommand",
|
|
246
|
-
completeWhenDepsComplete: false,
|
|
247
|
-
errorWhenDepsError: false
|
|
248
|
-
});
|
|
249
|
-
const runtime = topology.node(
|
|
250
|
-
[command],
|
|
251
|
-
(ctx) => {
|
|
252
|
-
let state2 = ctx.state.get() ?? {
|
|
253
|
-
eventSeq: 0,
|
|
254
|
-
effectSeq: 0,
|
|
255
|
-
commandCount: 0,
|
|
256
|
-
errorCount: 0,
|
|
257
|
-
auditSeq: 0,
|
|
258
|
-
seenEventIds: [],
|
|
259
|
-
seenEffectIds: [],
|
|
260
|
-
state: opts.initialState
|
|
261
|
-
};
|
|
262
|
-
ctx.state.persist(true);
|
|
263
|
-
for (const raw of depBatch(ctx, 0) ?? []) {
|
|
264
|
-
state2 = reduceProcessCommandFact(
|
|
265
|
-
raw,
|
|
266
|
-
state2,
|
|
267
|
-
opts.reduce,
|
|
268
|
-
now,
|
|
269
|
-
(fact) => ctx.down([["DATA", fact]])
|
|
270
|
-
);
|
|
271
|
-
ctx.state.set(state2);
|
|
272
|
-
}
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
name: `${name}/runtime`,
|
|
276
|
-
factory: "processRuntime",
|
|
277
|
-
meta: { process: "facts-plus-reducer", d: "D136" },
|
|
278
|
-
completeWhenDepsComplete: false,
|
|
279
|
-
errorWhenDepsError: false
|
|
280
|
-
}
|
|
281
|
-
);
|
|
282
|
-
const events = processProjection(
|
|
283
|
-
topology,
|
|
284
|
-
runtime,
|
|
285
|
-
`${name}/events`,
|
|
286
|
-
"processEvents",
|
|
287
|
-
(fact) => fact.kind === "event" ? fact.event : void 0
|
|
288
|
-
);
|
|
289
|
-
const state = processProjection(
|
|
290
|
-
topology,
|
|
291
|
-
runtime,
|
|
292
|
-
`${name}/state`,
|
|
293
|
-
"processState",
|
|
294
|
-
(fact) => fact.kind === "state" ? fact.state : void 0
|
|
295
|
-
);
|
|
296
|
-
const audit = processProjection(
|
|
297
|
-
topology,
|
|
298
|
-
runtime,
|
|
299
|
-
`${name}/audit`,
|
|
300
|
-
"processAudit",
|
|
301
|
-
(fact) => fact.kind === "audit" ? fact.audit : void 0
|
|
302
|
-
);
|
|
303
|
-
const effectRequests = processProjection(
|
|
304
|
-
topology,
|
|
305
|
-
runtime,
|
|
306
|
-
`${name}/effectRequests`,
|
|
307
|
-
"processEffectRequests",
|
|
308
|
-
(fact) => fact.kind === "effect-request" ? fact.effect : void 0
|
|
309
|
-
);
|
|
310
|
-
const status = processProjection(
|
|
311
|
-
topology,
|
|
312
|
-
runtime,
|
|
313
|
-
`${name}/status`,
|
|
314
|
-
"processStatus",
|
|
315
|
-
(fact) => fact.kind === "status" ? fact.status : void 0
|
|
316
|
-
);
|
|
317
|
-
const errors = processProjection(
|
|
318
|
-
topology,
|
|
319
|
-
runtime,
|
|
320
|
-
`${name}/errors`,
|
|
321
|
-
"processErrors",
|
|
322
|
-
(fact) => fact.kind === "error" ? fact.error : void 0
|
|
323
|
-
);
|
|
324
|
-
const cursor = processProjection(
|
|
325
|
-
topology,
|
|
326
|
-
runtime,
|
|
327
|
-
`${name}/cursor`,
|
|
328
|
-
"processCursor",
|
|
329
|
-
(fact) => fact.kind === "cursor" ? fact.cursor : void 0
|
|
330
|
-
);
|
|
331
|
-
const retainProcessNodes = () => [
|
|
332
|
-
graph.retain(runtime, { reason: `${name}.process.runtime` }),
|
|
333
|
-
graph.retain(events, { reason: `${name}.process.events` }),
|
|
334
|
-
graph.retain(state, { reason: `${name}.process.state` }),
|
|
335
|
-
graph.retain(audit, { reason: `${name}.process.audit` }),
|
|
336
|
-
graph.retain(effectRequests, { reason: `${name}.process.effectRequests` }),
|
|
337
|
-
graph.retain(status, { reason: `${name}.process.status` }),
|
|
338
|
-
graph.retain(errors, { reason: `${name}.process.errors` }),
|
|
339
|
-
graph.retain(cursor, { reason: `${name}.process.cursor` })
|
|
340
|
-
];
|
|
341
|
-
let releaseRetains = retainProcessNodes();
|
|
342
|
-
let released = false;
|
|
343
|
-
const bundle = {
|
|
344
|
-
command,
|
|
345
|
-
events,
|
|
346
|
-
state,
|
|
347
|
-
audit,
|
|
348
|
-
effectRequests,
|
|
349
|
-
status,
|
|
350
|
-
errors,
|
|
351
|
-
cursor,
|
|
352
|
-
dispatch(next) {
|
|
353
|
-
command.down([["DATA", next]]);
|
|
354
|
-
return next;
|
|
355
|
-
},
|
|
356
|
-
release() {
|
|
357
|
-
if (released) return;
|
|
358
|
-
const activeRetains = releaseRetains;
|
|
359
|
-
releaseRetains = [];
|
|
360
|
-
for (const releaseRetain of activeRetains) releaseRetain();
|
|
361
|
-
try {
|
|
362
|
-
topology.release({ reason: `${name}.process.release` });
|
|
363
|
-
released = true;
|
|
364
|
-
processCommandSources.delete(
|
|
365
|
-
bundle
|
|
366
|
-
);
|
|
367
|
-
} catch (error) {
|
|
368
|
-
releaseRetains = retainProcessNodes();
|
|
369
|
-
throw error;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
processCommandSources.set(
|
|
374
|
-
bundle,
|
|
375
|
-
{ sources: [] }
|
|
376
|
-
);
|
|
377
|
-
return bundle;
|
|
378
|
-
}
|
|
379
|
-
function processEffectRunner(graph, process, opts) {
|
|
380
|
-
if (opts.outcomes.length === 0) {
|
|
381
|
-
throw new RangeError("processEffectRunner: outcomes must contain at least one node");
|
|
382
|
-
}
|
|
383
|
-
const name = opts.name ?? "processEffectRunner";
|
|
384
|
-
const topology = graph.topologyGroup({ name: `${name}.effectRunner` });
|
|
385
|
-
const requests = topology.node(
|
|
386
|
-
[process.effectRequests],
|
|
387
|
-
(ctx) => {
|
|
388
|
-
for (const request of depBatch(ctx, 0) ?? []) {
|
|
389
|
-
ctx.down([["DATA", request]]);
|
|
390
|
-
}
|
|
391
|
-
},
|
|
392
|
-
{
|
|
393
|
-
name: `${name}/requests`,
|
|
394
|
-
factory: "processEffectRunnerRequests",
|
|
395
|
-
partial: true,
|
|
396
|
-
completeWhenDepsComplete: false,
|
|
397
|
-
errorWhenDepsError: false
|
|
398
|
-
}
|
|
399
|
-
);
|
|
400
|
-
const runtime = topology.node(
|
|
401
|
-
[...opts.outcomes],
|
|
402
|
-
(ctx) => {
|
|
403
|
-
for (let i = 0; i < opts.outcomes.length; i += 1) {
|
|
404
|
-
for (const raw of depBatch(ctx, i) ?? []) {
|
|
405
|
-
const parsed = parseProcessEffectOutcome(raw);
|
|
406
|
-
if (typeof parsed === "string") {
|
|
407
|
-
const error = {
|
|
408
|
-
code: "malformed-outcome",
|
|
409
|
-
message: parsed,
|
|
410
|
-
outcome: raw
|
|
411
|
-
};
|
|
412
|
-
ctx.down([["DATA", { kind: "error", error }]]);
|
|
413
|
-
continue;
|
|
414
|
-
}
|
|
415
|
-
const outcome = parsed;
|
|
416
|
-
const command = processEffectOutcomeCommand(outcome);
|
|
417
|
-
ctx.down([["DATA", { kind: "outcome", outcome }]]);
|
|
418
|
-
ctx.down([["DATA", { kind: "command", command }]]);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
},
|
|
422
|
-
{
|
|
423
|
-
name: `${name}/runtime`,
|
|
424
|
-
factory: "processEffectRunner",
|
|
425
|
-
meta: { process: "effect-runner", d: "D156" },
|
|
426
|
-
partial: true,
|
|
427
|
-
completeWhenDepsComplete: false,
|
|
428
|
-
errorWhenDepsError: false
|
|
429
|
-
}
|
|
430
|
-
);
|
|
431
|
-
const outcomes = processEffectRunnerProjection(
|
|
432
|
-
topology,
|
|
433
|
-
runtime,
|
|
434
|
-
`${name}/outcomes`,
|
|
435
|
-
"processEffectRunnerOutcomes",
|
|
436
|
-
(fact) => fact.kind === "outcome" ? fact.outcome : void 0
|
|
437
|
-
);
|
|
438
|
-
const commands = processEffectRunnerProjection(
|
|
439
|
-
topology,
|
|
440
|
-
runtime,
|
|
441
|
-
`${name}/commands`,
|
|
442
|
-
"processEffectRunnerCommands",
|
|
443
|
-
(fact) => fact.kind === "command" ? fact.command : void 0
|
|
444
|
-
);
|
|
445
|
-
const errors = processEffectRunnerProjection(
|
|
446
|
-
topology,
|
|
447
|
-
runtime,
|
|
448
|
-
`${name}/errors`,
|
|
449
|
-
"processEffectRunnerErrors",
|
|
450
|
-
(fact) => fact.kind === "error" ? fact.error : void 0
|
|
451
|
-
);
|
|
452
|
-
const status = topology.node(
|
|
453
|
-
[requests, runtime],
|
|
454
|
-
(ctx) => {
|
|
455
|
-
let state = ctx.state.get() ?? { requested: 0, commanded: 0, rejected: 0 };
|
|
456
|
-
for (const request of depBatch(ctx, 0) ?? []) {
|
|
457
|
-
state = { ...state, requested: state.requested + 1 };
|
|
458
|
-
const typedRequest = request;
|
|
459
|
-
ctx.down([
|
|
460
|
-
[
|
|
461
|
-
"DATA",
|
|
462
|
-
{
|
|
463
|
-
state: "requested",
|
|
464
|
-
effectId: typedRequest.id,
|
|
465
|
-
effectType: typedRequest.type,
|
|
466
|
-
requested: state.requested,
|
|
467
|
-
commanded: state.commanded,
|
|
468
|
-
rejected: state.rejected
|
|
469
|
-
}
|
|
470
|
-
]
|
|
471
|
-
]);
|
|
472
|
-
}
|
|
473
|
-
for (const fact of depBatch(ctx, 1) ?? []) {
|
|
474
|
-
const typedFact = fact;
|
|
475
|
-
if (typedFact.kind === "command") {
|
|
476
|
-
state = { ...state, commanded: state.commanded + 1 };
|
|
477
|
-
ctx.down([
|
|
478
|
-
[
|
|
479
|
-
"DATA",
|
|
480
|
-
{
|
|
481
|
-
state: "commanded",
|
|
482
|
-
effectId: typedFact.command.payload.effectId,
|
|
483
|
-
effectType: typedFact.command.payload.effectType,
|
|
484
|
-
commandId: typedFact.command.id,
|
|
485
|
-
commandType: typedFact.command.type,
|
|
486
|
-
requested: state.requested,
|
|
487
|
-
commanded: state.commanded,
|
|
488
|
-
rejected: state.rejected
|
|
489
|
-
}
|
|
490
|
-
]
|
|
491
|
-
]);
|
|
492
|
-
}
|
|
493
|
-
if (typedFact.kind === "error") {
|
|
494
|
-
state = { ...state, rejected: state.rejected + 1 };
|
|
495
|
-
ctx.down([
|
|
496
|
-
[
|
|
497
|
-
"DATA",
|
|
498
|
-
{
|
|
499
|
-
state: "rejected",
|
|
500
|
-
effectId: typedFact.error.effectId,
|
|
501
|
-
effectType: typedFact.error.effectType,
|
|
502
|
-
requested: state.requested,
|
|
503
|
-
commanded: state.commanded,
|
|
504
|
-
rejected: state.rejected
|
|
505
|
-
}
|
|
506
|
-
]
|
|
507
|
-
]);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
ctx.state.set(state);
|
|
511
|
-
},
|
|
512
|
-
{
|
|
513
|
-
name: `${name}/status`,
|
|
514
|
-
factory: "processEffectRunnerStatus",
|
|
515
|
-
partial: true,
|
|
516
|
-
completeWhenDepsComplete: false,
|
|
517
|
-
errorWhenDepsError: false
|
|
518
|
-
}
|
|
519
|
-
);
|
|
520
|
-
const retainRunnerNodes = () => [
|
|
521
|
-
graph.retain(requests, { reason: `${name}.effectRunner.requests` }),
|
|
522
|
-
graph.retain(outcomes, { reason: `${name}.effectRunner.outcomes` }),
|
|
523
|
-
graph.retain(commands, { reason: `${name}.effectRunner.commands` }),
|
|
524
|
-
graph.retain(status, { reason: `${name}.effectRunner.status` }),
|
|
525
|
-
graph.retain(errors, { reason: `${name}.effectRunner.errors` })
|
|
526
|
-
];
|
|
527
|
-
let releaseRetains = retainRunnerNodes();
|
|
528
|
-
try {
|
|
529
|
-
attachProcessCommandSource(process, commands);
|
|
530
|
-
} catch (error) {
|
|
531
|
-
for (const releaseRetain of releaseRetains) releaseRetain();
|
|
532
|
-
releaseRetains = [];
|
|
533
|
-
topology.release({ reason: `${name}.effectRunner.failedAttach` });
|
|
534
|
-
throw error;
|
|
535
|
-
}
|
|
536
|
-
let released = false;
|
|
537
|
-
return {
|
|
538
|
-
requests,
|
|
539
|
-
outcomes,
|
|
540
|
-
commands,
|
|
541
|
-
status,
|
|
542
|
-
errors,
|
|
543
|
-
release() {
|
|
544
|
-
if (released) return;
|
|
545
|
-
const activeRetains = releaseRetains;
|
|
546
|
-
releaseRetains = [];
|
|
547
|
-
for (const releaseRetain of activeRetains) releaseRetain();
|
|
548
|
-
detachProcessCommandSource(process, commands);
|
|
549
|
-
try {
|
|
550
|
-
topology.release({ reason: `${name}.effectRunner.release` });
|
|
551
|
-
released = true;
|
|
552
|
-
} catch (error) {
|
|
553
|
-
attachProcessCommandSource(process, commands);
|
|
554
|
-
releaseRetains = retainRunnerNodes();
|
|
555
|
-
throw error;
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
};
|
|
559
|
-
}
|
|
560
|
-
function constantBackoff(delayMs) {
|
|
561
|
-
return { kind: "constant", delayMs };
|
|
562
|
-
}
|
|
563
|
-
function processEffectRunnerProjection(topology, runtime, name, factory, pick) {
|
|
564
|
-
return topology.node(
|
|
565
|
-
[runtime],
|
|
566
|
-
(ctx) => {
|
|
567
|
-
for (const fact of depBatch(ctx, 0) ?? []) {
|
|
568
|
-
const value = pick(fact);
|
|
569
|
-
if (value !== void 0) ctx.down([["DATA", value]]);
|
|
570
|
-
}
|
|
571
|
-
},
|
|
572
|
-
{
|
|
573
|
-
name,
|
|
574
|
-
factory,
|
|
575
|
-
partial: true,
|
|
576
|
-
completeWhenDepsComplete: false,
|
|
577
|
-
errorWhenDepsError: false
|
|
578
|
-
}
|
|
579
|
-
);
|
|
580
|
-
}
|
|
581
|
-
function parseProcessEffectOutcome(raw) {
|
|
582
|
-
if (!isObjectRecord(raw)) return "processEffectRunner: outcome must be an object";
|
|
583
|
-
if (typeof raw.kind !== "string") {
|
|
584
|
-
return "processEffectRunner: outcome kind must be a string";
|
|
585
|
-
}
|
|
586
|
-
if (raw.kind !== "result" && raw.kind !== "failure" && raw.kind !== "cancel" && raw.kind !== "timeout") {
|
|
587
|
-
return "processEffectRunner: outcome kind must be result, failure, cancel, or timeout";
|
|
588
|
-
}
|
|
589
|
-
if (typeof raw.effectId !== "string" || raw.effectId.length === 0) {
|
|
590
|
-
return "processEffectRunner: outcome effectId must be a non-empty string";
|
|
591
|
-
}
|
|
592
|
-
if (typeof raw.effectType !== "string" || raw.effectType.length === 0) {
|
|
593
|
-
return "processEffectRunner: outcome effectType must be a non-empty string";
|
|
594
|
-
}
|
|
595
|
-
if ("commandId" in raw && raw.commandId !== void 0) {
|
|
596
|
-
if (typeof raw.commandId !== "string" || raw.commandId.length === 0) {
|
|
597
|
-
return "processEffectRunner: outcome commandId must be a non-empty string";
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
for (const key of ["processId", "correlationId", "causationId"]) {
|
|
601
|
-
if (key in raw && raw[key] !== void 0 && typeof raw[key] !== "string") {
|
|
602
|
-
return `processEffectRunner: outcome ${key} must be a string`;
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
if ("metadata" in raw && raw.metadata !== void 0 && !isObjectRecord(raw.metadata)) {
|
|
606
|
-
return "processEffectRunner: outcome metadata must be a plain object";
|
|
607
|
-
}
|
|
608
|
-
if (raw.kind === "result" && !("value" in raw)) {
|
|
609
|
-
return "processEffectRunner: result outcome must carry value";
|
|
610
|
-
}
|
|
611
|
-
if ((raw.kind === "failure" || raw.kind === "timeout") && !("error" in raw)) {
|
|
612
|
-
return `processEffectRunner: ${raw.kind} outcome must carry error`;
|
|
613
|
-
}
|
|
614
|
-
if (raw.kind === "cancel" && "reason" in raw && raw.reason !== void 0 && typeof raw.reason !== "string") {
|
|
615
|
-
return "processEffectRunner: cancel outcome reason must be a string";
|
|
616
|
-
}
|
|
617
|
-
return raw;
|
|
618
|
-
}
|
|
619
|
-
function processEffectOutcomeCommand(outcome) {
|
|
620
|
-
const commandType = processEffectCommandType(outcome.kind);
|
|
621
|
-
return {
|
|
622
|
-
id: outcome.commandId ?? `${outcome.effectId}:${commandType}`,
|
|
623
|
-
type: commandType,
|
|
624
|
-
payload: processEffectCommandPayload(outcome),
|
|
625
|
-
processId: outcome.processId,
|
|
626
|
-
correlationId: outcome.correlationId,
|
|
627
|
-
causationId: outcome.causationId,
|
|
628
|
-
metadata: outcome.metadata
|
|
629
|
-
};
|
|
630
|
-
}
|
|
631
|
-
function processEffectCommandType(kind) {
|
|
632
|
-
switch (kind) {
|
|
633
|
-
case "result":
|
|
634
|
-
return "effect.result";
|
|
635
|
-
case "failure":
|
|
636
|
-
return "effect.failure";
|
|
637
|
-
case "cancel":
|
|
638
|
-
return "effect.cancel";
|
|
639
|
-
case "timeout":
|
|
640
|
-
return "effect.timeout";
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
function processEffectCommandPayload(outcome) {
|
|
644
|
-
const base = {
|
|
645
|
-
effectId: outcome.effectId,
|
|
646
|
-
effectType: outcome.effectType,
|
|
647
|
-
processId: outcome.processId,
|
|
648
|
-
correlationId: outcome.correlationId,
|
|
649
|
-
causationId: outcome.causationId,
|
|
650
|
-
metadata: outcome.metadata
|
|
651
|
-
};
|
|
652
|
-
switch (outcome.kind) {
|
|
653
|
-
case "result":
|
|
654
|
-
return { ...base, kind: "result", value: outcome.value };
|
|
655
|
-
case "failure":
|
|
656
|
-
return { ...base, kind: "failure", error: outcome.error };
|
|
657
|
-
case "cancel":
|
|
658
|
-
return { ...base, kind: "cancel", reason: outcome.reason };
|
|
659
|
-
case "timeout":
|
|
660
|
-
return { ...base, kind: "timeout", error: outcome.error };
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
function attachProcessCommandSource(process, source) {
|
|
664
|
-
const attached = processCommandSources.get(process);
|
|
665
|
-
if (attached === void 0) {
|
|
666
|
-
throw new Error("processEffectRunner: process command source registry missing");
|
|
667
|
-
}
|
|
668
|
-
const sources = attached.sources;
|
|
669
|
-
const previousSources = [...sources];
|
|
670
|
-
if (!sources.includes(source)) sources.push(source);
|
|
671
|
-
try {
|
|
672
|
-
process.command.replaceDeps([...sources], processCommandSourceFn(sources.length));
|
|
673
|
-
} catch (error) {
|
|
674
|
-
sources.splice(0, sources.length, ...previousSources);
|
|
675
|
-
process.command.replaceDeps(
|
|
676
|
-
[...previousSources],
|
|
677
|
-
processCommandSourceFn(previousSources.length)
|
|
678
|
-
);
|
|
679
|
-
throw error;
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
function detachProcessCommandSource(process, source) {
|
|
683
|
-
const attached = processCommandSources.get(process);
|
|
684
|
-
if (attached === void 0) {
|
|
685
|
-
throw new Error("processEffectRunner: process command source registry missing");
|
|
686
|
-
}
|
|
687
|
-
const sources = attached.sources;
|
|
688
|
-
if (!sources.includes(source)) return;
|
|
689
|
-
const previousSources = [...sources];
|
|
690
|
-
const nextSources = sources.filter((candidate) => candidate !== source);
|
|
691
|
-
sources.splice(0, sources.length, ...nextSources);
|
|
692
|
-
try {
|
|
693
|
-
process.command.replaceDeps([...nextSources], processCommandSourceFn(nextSources.length));
|
|
694
|
-
} catch (error) {
|
|
695
|
-
sources.splice(0, sources.length, ...previousSources);
|
|
696
|
-
process.command.replaceDeps(
|
|
697
|
-
[...previousSources],
|
|
698
|
-
processCommandSourceFn(previousSources.length)
|
|
699
|
-
);
|
|
700
|
-
throw error;
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
function processCommandSourceFn(sourceCount) {
|
|
704
|
-
return (ctx) => {
|
|
705
|
-
for (let i = 0; i < sourceCount; i += 1) {
|
|
706
|
-
for (const command of depBatch(ctx, i) ?? []) {
|
|
707
|
-
ctx.down([["DATA", command]]);
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
};
|
|
711
|
-
}
|
|
712
|
-
function processRuntimeDraft(state) {
|
|
713
|
-
return {
|
|
714
|
-
eventSeq: state.eventSeq,
|
|
715
|
-
effectSeq: state.effectSeq,
|
|
716
|
-
commandCount: state.commandCount,
|
|
717
|
-
errorCount: state.errorCount,
|
|
718
|
-
auditSeq: state.auditSeq,
|
|
719
|
-
seenEventIds: [...state.seenEventIds],
|
|
720
|
-
seenEffectIds: [...state.seenEffectIds],
|
|
721
|
-
state: state.state
|
|
722
|
-
};
|
|
723
|
-
}
|
|
724
|
-
function reduceProcessCommandFact(raw, state, reduce, now, emit) {
|
|
725
|
-
const draft = processRuntimeDraft(state);
|
|
726
|
-
draft.commandCount += 1;
|
|
727
|
-
const parsed = parseProcessCommand(raw);
|
|
728
|
-
if (typeof parsed === "string") {
|
|
729
|
-
emitProcessFailure(draft, emit, raw, void 0, "malformed-command", parsed);
|
|
730
|
-
return draft;
|
|
731
|
-
}
|
|
732
|
-
const command = parsed;
|
|
733
|
-
let reduction;
|
|
734
|
-
const reducerState = cloneProcessState(state.state);
|
|
735
|
-
if (!reducerState.ok) {
|
|
736
|
-
emitProcessFailure(draft, emit, command, command, "malformed-state", reducerState.message);
|
|
737
|
-
return draft;
|
|
738
|
-
}
|
|
739
|
-
try {
|
|
740
|
-
reduction = reduce(command, reducerState.value);
|
|
741
|
-
} catch (error) {
|
|
742
|
-
rethrowGraphRuntimeInvariant(error);
|
|
743
|
-
emitProcessFailure(draft, emit, command, command, "reducer-threw", errorMessage(error));
|
|
744
|
-
return draft;
|
|
745
|
-
}
|
|
746
|
-
if (!isObjectRecord(reduction) || !("state" in reduction)) {
|
|
747
|
-
emitProcessFailure(
|
|
748
|
-
draft,
|
|
749
|
-
emit,
|
|
750
|
-
command,
|
|
751
|
-
command,
|
|
752
|
-
"malformed-state",
|
|
753
|
-
"processBundle: reducer must return { state, events?, effects? }"
|
|
754
|
-
);
|
|
755
|
-
return draft;
|
|
756
|
-
}
|
|
757
|
-
if (reduction.state === void 0) {
|
|
758
|
-
emitProcessFailure(
|
|
759
|
-
draft,
|
|
760
|
-
emit,
|
|
761
|
-
command,
|
|
762
|
-
command,
|
|
763
|
-
"malformed-state",
|
|
764
|
-
"processBundle: reducer state must not be undefined"
|
|
765
|
-
);
|
|
766
|
-
return draft;
|
|
767
|
-
}
|
|
768
|
-
const privateState = cloneProcessState(reduction.state);
|
|
769
|
-
if (!privateState.ok) {
|
|
770
|
-
emitProcessFailure(draft, emit, command, command, "malformed-state", privateState.message);
|
|
771
|
-
return draft;
|
|
772
|
-
}
|
|
773
|
-
const visibleState = cloneProcessState(privateState.value);
|
|
774
|
-
if (!visibleState.ok) {
|
|
775
|
-
emitProcessFailure(draft, emit, command, command, "malformed-state", visibleState.message);
|
|
776
|
-
return draft;
|
|
777
|
-
}
|
|
778
|
-
const preparedEvents = prepareProcessEvents(command, draft, reduction.events ?? []);
|
|
779
|
-
if (typeof preparedEvents === "string") {
|
|
780
|
-
emitProcessFailure(draft, emit, command, command, "malformed-event", preparedEvents);
|
|
781
|
-
return draft;
|
|
782
|
-
}
|
|
783
|
-
const preparedEffects = prepareProcessEffects(command, draft, reduction.effects ?? []);
|
|
784
|
-
if (typeof preparedEffects === "string") {
|
|
785
|
-
emitProcessFailure(draft, emit, command, command, "malformed-effect", preparedEffects);
|
|
786
|
-
return draft;
|
|
787
|
-
}
|
|
788
|
-
const timestampMs = readTimestampMs(now);
|
|
789
|
-
if (typeof timestampMs === "string") {
|
|
790
|
-
emitProcessFailure(draft, emit, command, command, "clock-threw", timestampMs);
|
|
791
|
-
return draft;
|
|
792
|
-
}
|
|
793
|
-
draft.state = privateState.value;
|
|
794
|
-
emit({ kind: "state", state: visibleState.value, cursor: processCursorOf(draft) });
|
|
795
|
-
const events = [];
|
|
796
|
-
for (const eventDraft of preparedEvents) {
|
|
797
|
-
draft.eventSeq += 1;
|
|
798
|
-
draft.seenEventIds.push(eventDraft.id);
|
|
799
|
-
const event = {
|
|
800
|
-
id: eventDraft.id,
|
|
801
|
-
type: eventDraft.type,
|
|
802
|
-
seq: draft.eventSeq,
|
|
803
|
-
cursor: draft.eventSeq,
|
|
804
|
-
commandId: command.id,
|
|
805
|
-
commandType: command.type,
|
|
806
|
-
payload: eventDraft.payload,
|
|
807
|
-
timestampMs,
|
|
808
|
-
...eventDraft.processId === void 0 ? {} : { processId: eventDraft.processId },
|
|
809
|
-
...eventDraft.correlationId === void 0 ? {} : { correlationId: eventDraft.correlationId },
|
|
810
|
-
...eventDraft.causationId === void 0 ? {} : { causationId: eventDraft.causationId },
|
|
811
|
-
...eventDraft.metadata === void 0 ? {} : { metadata: eventDraft.metadata }
|
|
812
|
-
};
|
|
813
|
-
events.push(event);
|
|
814
|
-
emit({ kind: "event", event });
|
|
815
|
-
}
|
|
816
|
-
const effects = [];
|
|
817
|
-
for (const effectDraft of preparedEffects) {
|
|
818
|
-
draft.effectSeq += 1;
|
|
819
|
-
draft.seenEffectIds.push(effectDraft.id);
|
|
820
|
-
const effect = {
|
|
821
|
-
id: effectDraft.id,
|
|
822
|
-
type: effectDraft.type,
|
|
823
|
-
seq: draft.effectSeq,
|
|
824
|
-
cursor: draft.effectSeq,
|
|
825
|
-
commandId: command.id,
|
|
826
|
-
commandType: command.type,
|
|
827
|
-
payload: effectDraft.payload,
|
|
828
|
-
timestampMs,
|
|
829
|
-
...effectDraft.processId === void 0 ? {} : { processId: effectDraft.processId },
|
|
830
|
-
...effectDraft.correlationId === void 0 ? {} : { correlationId: effectDraft.correlationId },
|
|
831
|
-
...effectDraft.causationId === void 0 ? {} : { causationId: effectDraft.causationId },
|
|
832
|
-
...effectDraft.metadata === void 0 ? {} : { metadata: effectDraft.metadata }
|
|
833
|
-
};
|
|
834
|
-
effects.push(effect);
|
|
835
|
-
emit({ kind: "effect-request", effect });
|
|
836
|
-
}
|
|
837
|
-
emitProcessStatus(draft, emit, command, "accepted", events.length, effects.length);
|
|
838
|
-
emitProcessAudit(draft, emit, command, "success", events, effects, void 0, void 0);
|
|
839
|
-
emit({ kind: "cursor", cursor: processCursorOf(draft) });
|
|
840
|
-
return draft;
|
|
841
|
-
}
|
|
842
|
-
function processProjection(graph, runtime, name, factory, select) {
|
|
843
|
-
return graph.node(
|
|
844
|
-
[runtime],
|
|
845
|
-
(ctx) => {
|
|
846
|
-
for (const raw of depBatch(ctx, 0) ?? []) {
|
|
847
|
-
const selected = select(raw);
|
|
848
|
-
if (selected !== void 0) ctx.down([["DATA", selected]]);
|
|
849
|
-
}
|
|
850
|
-
},
|
|
851
|
-
{ name, factory, completeWhenDepsComplete: false, errorWhenDepsError: false }
|
|
852
|
-
);
|
|
853
|
-
}
|
|
854
|
-
function parseProcessCommand(value) {
|
|
855
|
-
if (!isObjectRecord(value)) return "processBundle: command fact must be an object";
|
|
856
|
-
if (typeof value.id !== "string" || value.id.length === 0) {
|
|
857
|
-
return "processBundle: command id must be a non-empty string";
|
|
858
|
-
}
|
|
859
|
-
if (typeof value.type !== "string" || value.type.length === 0) {
|
|
860
|
-
return "processBundle: command type must be a non-empty string";
|
|
861
|
-
}
|
|
862
|
-
return {
|
|
863
|
-
id: value.id,
|
|
864
|
-
type: value.type,
|
|
865
|
-
payload: value.payload,
|
|
866
|
-
...typeof value.processId === "string" ? { processId: value.processId } : {},
|
|
867
|
-
...typeof value.correlationId === "string" ? { correlationId: value.correlationId } : {},
|
|
868
|
-
...typeof value.causationId === "string" ? { causationId: value.causationId } : {},
|
|
869
|
-
...isObjectRecord(value.metadata) ? { metadata: value.metadata } : {}
|
|
870
|
-
};
|
|
871
|
-
}
|
|
872
|
-
function prepareProcessEvents(command, state, drafts) {
|
|
873
|
-
if (!Array.isArray(drafts)) return "processBundle: events must be an array";
|
|
874
|
-
const seen = /* @__PURE__ */ new Set();
|
|
875
|
-
const out = [];
|
|
876
|
-
for (let i = 0; i < drafts.length; i += 1) {
|
|
877
|
-
const draft = drafts[i];
|
|
878
|
-
if (!isObjectRecord(draft) || typeof draft.type !== "string" || draft.type.length === 0) {
|
|
879
|
-
return "processBundle: event draft must have a non-empty type";
|
|
880
|
-
}
|
|
881
|
-
const id = typeof draft.id === "string" && draft.id.length > 0 ? draft.id : `${command.id}:event:${state.eventSeq + i + 1}`;
|
|
882
|
-
if (seen.has(id)) return `processBundle: duplicate event '${id}'`;
|
|
883
|
-
if (state.seenEventIds.includes(id)) return `processBundle: duplicate event '${id}'`;
|
|
884
|
-
seen.add(id);
|
|
885
|
-
out.push({
|
|
886
|
-
id,
|
|
887
|
-
type: draft.type,
|
|
888
|
-
payload: draft.payload,
|
|
889
|
-
...typeof draft.processId === "string" ? { processId: draft.processId } : {},
|
|
890
|
-
...typeof draft.correlationId === "string" ? { correlationId: draft.correlationId } : {},
|
|
891
|
-
...typeof draft.causationId === "string" ? { causationId: draft.causationId } : {},
|
|
892
|
-
...isObjectRecord(draft.metadata) ? { metadata: draft.metadata } : {}
|
|
893
|
-
});
|
|
894
|
-
}
|
|
895
|
-
return out;
|
|
896
|
-
}
|
|
897
|
-
function prepareProcessEffects(command, state, drafts) {
|
|
898
|
-
if (!Array.isArray(drafts)) return "processBundle: effects must be an array";
|
|
899
|
-
const seen = /* @__PURE__ */ new Set();
|
|
900
|
-
const out = [];
|
|
901
|
-
for (let i = 0; i < drafts.length; i += 1) {
|
|
902
|
-
const draft = drafts[i];
|
|
903
|
-
if (!isObjectRecord(draft) || typeof draft.type !== "string" || draft.type.length === 0) {
|
|
904
|
-
return "processBundle: effect draft must have a non-empty type";
|
|
905
|
-
}
|
|
906
|
-
const id = typeof draft.id === "string" && draft.id.length > 0 ? draft.id : `${command.id}:effect:${state.effectSeq + i + 1}`;
|
|
907
|
-
if (seen.has(id)) return `processBundle: duplicate effect '${id}'`;
|
|
908
|
-
if (state.seenEffectIds.includes(id)) return `processBundle: duplicate effect '${id}'`;
|
|
909
|
-
seen.add(id);
|
|
910
|
-
out.push({
|
|
911
|
-
id,
|
|
912
|
-
type: draft.type,
|
|
913
|
-
payload: draft.payload,
|
|
914
|
-
...typeof draft.processId === "string" ? { processId: draft.processId } : {},
|
|
915
|
-
...typeof draft.correlationId === "string" ? { correlationId: draft.correlationId } : {},
|
|
916
|
-
...typeof draft.causationId === "string" ? { causationId: draft.causationId } : {},
|
|
917
|
-
...isObjectRecord(draft.metadata) ? { metadata: draft.metadata } : {}
|
|
918
|
-
});
|
|
919
|
-
}
|
|
920
|
-
return out;
|
|
921
|
-
}
|
|
922
|
-
function emitProcessFailure(state, emit, raw, command, code, message) {
|
|
923
|
-
state.errorCount += 1;
|
|
924
|
-
const cursor = processCursorOf(state);
|
|
925
|
-
const error = {
|
|
926
|
-
code,
|
|
927
|
-
message,
|
|
928
|
-
command: raw,
|
|
929
|
-
...command === void 0 ? {} : { commandId: command.id, commandType: command.type },
|
|
930
|
-
cursor
|
|
931
|
-
};
|
|
932
|
-
emit({ kind: "error", error });
|
|
933
|
-
emitProcessStatus(state, emit, command, "rejected", 0, 0, code);
|
|
934
|
-
emitProcessAudit(state, emit, command, "failure", [], [], code, message);
|
|
935
|
-
emit({ kind: "cursor", cursor: processCursorOf(state) });
|
|
936
|
-
}
|
|
937
|
-
function emitProcessStatus(state, emit, command, statusState, eventCount, effectCount, errorCode) {
|
|
938
|
-
emit({
|
|
939
|
-
kind: "status",
|
|
940
|
-
status: {
|
|
941
|
-
state: statusState,
|
|
942
|
-
...command === void 0 ? {} : { commandId: command.id, commandType: command.type },
|
|
943
|
-
eventCount,
|
|
944
|
-
effectCount,
|
|
945
|
-
...errorCode === void 0 ? {} : { errorCode },
|
|
946
|
-
cursor: processCursorOf(state)
|
|
947
|
-
}
|
|
948
|
-
});
|
|
949
|
-
}
|
|
950
|
-
function emitProcessAudit(state, emit, command, outcome, events, effects, errorCode, errorMessage2) {
|
|
951
|
-
state.auditSeq += 1;
|
|
952
|
-
emit({
|
|
953
|
-
kind: "audit",
|
|
954
|
-
audit: {
|
|
955
|
-
seq: state.auditSeq,
|
|
956
|
-
...command === void 0 ? {} : { commandId: command.id, commandType: command.type },
|
|
957
|
-
outcome,
|
|
958
|
-
eventIds: events.map((event) => event.id),
|
|
959
|
-
eventTypes: events.map((event) => event.type),
|
|
960
|
-
effectIds: effects.map((effect) => effect.id),
|
|
961
|
-
effectTypes: effects.map((effect) => effect.type),
|
|
962
|
-
...errorCode === void 0 ? {} : { errorCode },
|
|
963
|
-
...errorMessage2 === void 0 ? {} : { errorMessage: errorMessage2 },
|
|
964
|
-
cursor: processCursorOf(state)
|
|
965
|
-
}
|
|
966
|
-
});
|
|
967
|
-
}
|
|
968
|
-
function processCursorOf(state) {
|
|
969
|
-
return {
|
|
970
|
-
eventSeq: state.eventSeq,
|
|
971
|
-
effectSeq: state.effectSeq,
|
|
972
|
-
commandCount: state.commandCount,
|
|
973
|
-
errorCount: state.errorCount,
|
|
974
|
-
auditSeq: state.auditSeq
|
|
975
|
-
};
|
|
976
|
-
}
|
|
977
|
-
function cloneProcessState(state) {
|
|
978
|
-
if (typeof state !== "object" || state === null) return { ok: true, value: state };
|
|
979
|
-
try {
|
|
980
|
-
if (typeof globalThis.structuredClone === "function") {
|
|
981
|
-
return { ok: true, value: globalThis.structuredClone(state) };
|
|
982
|
-
}
|
|
983
|
-
return { ok: true, value: JSON.parse(JSON.stringify(state)) };
|
|
984
|
-
} catch (error) {
|
|
985
|
-
return {
|
|
986
|
-
ok: false,
|
|
987
|
-
message: `processBundle: state must be cloneable before reducer execution (${errorMessage(error)})`
|
|
988
|
-
};
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
function readTimestampMs(now) {
|
|
992
|
-
try {
|
|
993
|
-
const timestampMs = now();
|
|
994
|
-
if (!Number.isFinite(timestampMs)) return "processBundle: now() must return a finite number";
|
|
995
|
-
return timestampMs;
|
|
996
|
-
} catch (error) {
|
|
997
|
-
return errorMessage(error);
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
function rethrowGraphRuntimeInvariant(error) {
|
|
1001
|
-
const message = errorMessage(error);
|
|
1002
|
-
if (message.includes("R-reentrancy") || message.includes("R-rewire") || message.includes("R-graph-domain") || message.includes("D37") || message.includes("D22") || message.includes("different graph") || message.includes("cross-graph") || message.includes("wire bridge") || message.includes("mid-fn topology mutation") || message.includes("reentrant dep mutation") || message.includes("feedback cycle")) {
|
|
1003
|
-
throw error;
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
function isObjectRecord(value) {
|
|
1007
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1008
|
-
}
|
|
1009
|
-
function errorMessage(error) {
|
|
1010
|
-
return error instanceof Error ? error.message : String(error);
|
|
1011
|
-
}
|
|
1012
56
|
export {
|
|
1013
57
|
admitAgentRequestProposal,
|
|
1014
58
|
agentRequestLedgerViews,
|
|
1015
59
|
agentRequestProposalFromDecision,
|
|
1016
60
|
backoffDelayMs,
|
|
1017
61
|
breakerBundle,
|
|
62
|
+
buildToolProviderAdapterInputs,
|
|
63
|
+
buildToolProviderExecutorOutcome,
|
|
1018
64
|
constantBackoff,
|
|
1019
65
|
effectRun,
|
|
1020
66
|
effectRunCompletionProjector,
|
|
@@ -1032,14 +78,19 @@ export {
|
|
|
1032
78
|
processEffectRunner,
|
|
1033
79
|
rateLimitBundle,
|
|
1034
80
|
requestSatisfactionProjector,
|
|
81
|
+
requestToolProviderAdapterRun,
|
|
82
|
+
resolveToolProviderExecutionPolicies,
|
|
1035
83
|
retryPolicy,
|
|
1036
84
|
retryStatusBundle,
|
|
85
|
+
scheduledReadinessProjector,
|
|
1037
86
|
shouldRetry,
|
|
1038
87
|
structuredAgentDecisionInterpreter,
|
|
1039
88
|
timeoutBundle,
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
89
|
+
toolProviderAdapterInputProjector,
|
|
90
|
+
toolProviderAdapterRunProjector,
|
|
91
|
+
toolProviderPolicyResolutionProjector,
|
|
92
|
+
toolProviderRunAdmissionProjector,
|
|
93
|
+
toolProviderRunRetryProjector,
|
|
94
|
+
validateToolProviderExecutionPolicy
|
|
1044
95
|
};
|
|
1045
96
|
//# sourceMappingURL=index.js.map
|