@smthrs/gateway 0.35.0 → 1.0.0-rc.4
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/CHANGELOG.md +198 -0
- package/LICENSE +1 -1
- package/README.md +92 -0
- package/dist/cjs/Diagnosis.d.ts +275 -0
- package/dist/cjs/Diagnosis.d.ts.map +1 -0
- package/dist/cjs/Diagnosis.js +476 -0
- package/dist/cjs/Diagnosis.js.map +7 -0
- package/dist/cjs/EngineTrace.d.ts +76 -0
- package/dist/cjs/EngineTrace.d.ts.map +1 -0
- package/dist/cjs/EngineTrace.js +509 -0
- package/dist/cjs/EngineTrace.js.map +7 -0
- package/dist/cjs/GatewayError.d.ts +54 -0
- package/dist/cjs/GatewayError.d.ts.map +1 -0
- package/dist/cjs/GatewayError.js +51 -0
- package/dist/cjs/GatewayError.js.map +7 -0
- package/dist/cjs/GatewayProjection.d.ts +480 -0
- package/dist/cjs/GatewayProjection.d.ts.map +1 -0
- package/dist/cjs/GatewayProjection.js +471 -0
- package/dist/cjs/GatewayProjection.js.map +7 -0
- package/dist/cjs/GatewayRpcs.d.ts +1886 -0
- package/dist/cjs/GatewayRpcs.d.ts.map +1 -0
- package/dist/cjs/GatewayRpcs.js +121 -0
- package/dist/cjs/GatewayRpcs.js.map +7 -0
- package/dist/cjs/GatewaySchema.d.ts +3274 -0
- package/dist/cjs/GatewaySchema.d.ts.map +1 -0
- package/dist/cjs/GatewaySchema.js +141 -0
- package/dist/cjs/GatewaySchema.js.map +7 -0
- package/dist/cjs/GatewayServer.d.ts +427 -0
- package/dist/cjs/GatewayServer.d.ts.map +1 -0
- package/dist/cjs/GatewayServer.js +428 -0
- package/dist/cjs/GatewayServer.js.map +7 -0
- package/dist/cjs/HostBranchPresence.d.ts +19 -0
- package/dist/cjs/HostBranchPresence.d.ts.map +1 -0
- package/dist/cjs/HostBranchPresence.js +82 -0
- package/dist/cjs/HostBranchPresence.js.map +7 -0
- package/dist/cjs/Projections.d.ts +209 -0
- package/dist/cjs/Projections.d.ts.map +1 -0
- package/dist/cjs/Projections.js +906 -0
- package/dist/cjs/Projections.js.map +7 -0
- package/dist/cjs/RunDevTools.d.ts +181 -0
- package/dist/cjs/RunDevTools.d.ts.map +1 -0
- package/dist/cjs/RunDevTools.js +195 -0
- package/dist/cjs/RunDevTools.js.map +7 -0
- package/dist/cjs/RunHistory.d.ts +185 -0
- package/dist/cjs/RunHistory.d.ts.map +1 -0
- package/dist/cjs/RunHistory.js +68 -0
- package/dist/cjs/RunHistory.js.map +7 -0
- package/dist/cjs/RunTrace.d.ts +753 -0
- package/dist/cjs/RunTrace.d.ts.map +1 -0
- package/dist/cjs/RunTrace.js +1595 -0
- package/dist/cjs/RunTrace.js.map +7 -0
- package/dist/cjs/RuntimeBridge.d.ts +1386 -0
- package/dist/cjs/RuntimeBridge.d.ts.map +1 -0
- package/dist/cjs/RuntimeBridge.js +598 -0
- package/dist/cjs/RuntimeBridge.js.map +7 -0
- package/dist/cjs/bun/BunGateway.d.ts +20 -0
- package/dist/cjs/bun/BunGateway.d.ts.map +1 -0
- package/dist/cjs/bun/BunGateway.js +62 -0
- package/dist/cjs/bun/BunGateway.js.map +7 -0
- package/dist/cjs/index.d.ts +65 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +59 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/internal/NativeGateway.d.ts +176 -0
- package/dist/cjs/internal/NativeGateway.d.ts.map +1 -0
- package/dist/cjs/internal/NativeGateway.js +187 -0
- package/dist/cjs/internal/NativeGateway.js.map +7 -0
- package/dist/cjs/internal/actionRenderings.d.ts +12 -0
- package/dist/cjs/internal/actionRenderings.d.ts.map +1 -0
- package/dist/cjs/internal/actionRenderings.js +224 -0
- package/dist/cjs/internal/actionRenderings.js.map +7 -0
- package/dist/cjs/internal/callEvents.d.ts +97 -0
- package/dist/cjs/internal/callEvents.d.ts.map +1 -0
- package/dist/cjs/internal/callEvents.js +169 -0
- package/dist/cjs/internal/callEvents.js.map +7 -0
- package/dist/cjs/internal/digestIndex.d.ts +31 -0
- package/dist/cjs/internal/digestIndex.d.ts.map +1 -0
- package/dist/cjs/internal/digestIndex.js +105 -0
- package/dist/cjs/internal/digestIndex.js.map +7 -0
- package/dist/cjs/internal/digestMemory.d.ts +19 -0
- package/dist/cjs/internal/digestMemory.d.ts.map +1 -0
- package/dist/cjs/internal/digestMemory.js +33 -0
- package/dist/cjs/internal/digestMemory.js.map +7 -0
- package/dist/cjs/internal/inspectLabels.d.ts +13 -0
- package/dist/cjs/internal/inspectLabels.d.ts.map +1 -0
- package/dist/cjs/internal/inspectLabels.js +29 -0
- package/dist/cjs/internal/inspectLabels.js.map +7 -0
- package/dist/cjs/internal/nativeResolution.d.ts +41 -0
- package/dist/cjs/internal/nativeResolution.d.ts.map +1 -0
- package/dist/cjs/internal/nativeResolution.js +62 -0
- package/dist/cjs/internal/nativeResolution.js.map +7 -0
- package/dist/cjs/internal/nodeEvents.d.ts +47 -0
- package/dist/cjs/internal/nodeEvents.d.ts.map +1 -0
- package/dist/cjs/internal/nodeEvents.js +60 -0
- package/dist/cjs/internal/nodeEvents.js.map +7 -0
- package/dist/cjs/node/NodeGateway.d.ts +16 -0
- package/dist/cjs/node/NodeGateway.d.ts.map +1 -0
- package/dist/cjs/node/NodeGateway.js +48 -0
- package/dist/cjs/node/NodeGateway.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/Diagnosis.d.ts +275 -0
- package/dist/esm/Diagnosis.d.ts.map +1 -0
- package/dist/esm/Diagnosis.js +697 -0
- package/dist/esm/Diagnosis.js.map +1 -0
- package/dist/esm/EngineTrace.d.ts +76 -0
- package/dist/esm/EngineTrace.d.ts.map +1 -0
- package/dist/esm/EngineTrace.js +557 -0
- package/dist/esm/EngineTrace.js.map +1 -0
- package/dist/esm/GatewayError.d.ts +54 -0
- package/dist/esm/GatewayError.d.ts.map +1 -0
- package/dist/esm/GatewayError.js +60 -0
- package/dist/esm/GatewayError.js.map +1 -0
- package/dist/esm/GatewayProjection.d.ts +480 -0
- package/dist/esm/GatewayProjection.d.ts.map +1 -0
- package/dist/esm/GatewayProjection.js +799 -0
- package/dist/esm/GatewayProjection.js.map +1 -0
- package/dist/esm/GatewayRpcs.d.ts +1886 -0
- package/dist/esm/GatewayRpcs.d.ts.map +1 -0
- package/dist/esm/GatewayRpcs.js +145 -0
- package/dist/esm/GatewayRpcs.js.map +1 -0
- package/dist/esm/GatewaySchema.d.ts +3274 -0
- package/dist/esm/GatewaySchema.d.ts.map +1 -0
- package/dist/esm/GatewaySchema.js +244 -0
- package/dist/esm/GatewaySchema.js.map +1 -0
- package/dist/esm/GatewayServer.d.ts +427 -0
- package/dist/esm/GatewayServer.d.ts.map +1 -0
- package/dist/esm/GatewayServer.js +725 -0
- package/dist/esm/GatewayServer.js.map +1 -0
- package/dist/esm/HostBranchPresence.d.ts +19 -0
- package/dist/esm/HostBranchPresence.d.ts.map +1 -0
- package/dist/esm/HostBranchPresence.js +57 -0
- package/dist/esm/HostBranchPresence.js.map +1 -0
- package/dist/esm/Projections.d.ts +209 -0
- package/dist/esm/Projections.d.ts.map +1 -0
- package/dist/esm/Projections.js +1254 -0
- package/dist/esm/Projections.js.map +1 -0
- package/dist/esm/RunDevTools.d.ts +181 -0
- package/dist/esm/RunDevTools.d.ts.map +1 -0
- package/dist/esm/RunDevTools.js +281 -0
- package/dist/esm/RunDevTools.js.map +1 -0
- package/dist/esm/RunHistory.d.ts +185 -0
- package/dist/esm/RunHistory.d.ts.map +1 -0
- package/dist/esm/RunHistory.js +109 -0
- package/dist/esm/RunHistory.js.map +1 -0
- package/dist/esm/RunTrace.d.ts +753 -0
- package/dist/esm/RunTrace.d.ts.map +1 -0
- package/dist/esm/RunTrace.js +2106 -0
- package/dist/esm/RunTrace.js.map +1 -0
- package/dist/esm/RuntimeBridge.d.ts +1386 -0
- package/dist/esm/RuntimeBridge.d.ts.map +1 -0
- package/dist/esm/RuntimeBridge.js +659 -0
- package/dist/esm/RuntimeBridge.js.map +1 -0
- package/dist/esm/bun/BunGateway.d.ts +20 -0
- package/dist/esm/bun/BunGateway.d.ts.map +1 -0
- package/dist/esm/bun/BunGateway.js +32 -0
- package/dist/esm/bun/BunGateway.js.map +1 -0
- package/dist/esm/index.d.ts +65 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +65 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/NativeGateway.d.ts +176 -0
- package/dist/esm/internal/NativeGateway.d.ts.map +1 -0
- package/dist/esm/internal/NativeGateway.js +268 -0
- package/dist/esm/internal/NativeGateway.js.map +1 -0
- package/dist/esm/internal/actionRenderings.d.ts +12 -0
- package/dist/esm/internal/actionRenderings.d.ts.map +1 -0
- package/dist/esm/internal/actionRenderings.js +212 -0
- package/dist/esm/internal/actionRenderings.js.map +1 -0
- package/dist/esm/internal/callEvents.d.ts +97 -0
- package/dist/esm/internal/callEvents.d.ts.map +1 -0
- package/dist/esm/internal/callEvents.js +206 -0
- package/dist/esm/internal/callEvents.js.map +1 -0
- package/dist/esm/internal/digestIndex.d.ts +31 -0
- package/dist/esm/internal/digestIndex.d.ts.map +1 -0
- package/dist/esm/internal/digestIndex.js +87 -0
- package/dist/esm/internal/digestIndex.js.map +1 -0
- package/dist/esm/internal/digestMemory.d.ts +19 -0
- package/dist/esm/internal/digestMemory.d.ts.map +1 -0
- package/dist/esm/internal/digestMemory.js +23 -0
- package/dist/esm/internal/digestMemory.js.map +1 -0
- package/dist/esm/internal/inspectLabels.d.ts +13 -0
- package/dist/esm/internal/inspectLabels.d.ts.map +1 -0
- package/dist/esm/internal/inspectLabels.js +17 -0
- package/dist/esm/internal/inspectLabels.js.map +1 -0
- package/dist/esm/internal/nativeResolution.d.ts +41 -0
- package/dist/esm/internal/nativeResolution.d.ts.map +1 -0
- package/dist/esm/internal/nativeResolution.js +78 -0
- package/dist/esm/internal/nativeResolution.js.map +1 -0
- package/dist/esm/internal/nodeEvents.d.ts +47 -0
- package/dist/esm/internal/nodeEvents.d.ts.map +1 -0
- package/dist/esm/internal/nodeEvents.js +60 -0
- package/dist/esm/internal/nodeEvents.js.map +1 -0
- package/dist/esm/node/NodeGateway.d.ts +16 -0
- package/dist/esm/node/NodeGateway.d.ts.map +1 -0
- package/dist/esm/node/NodeGateway.js +13 -0
- package/dist/esm/node/NodeGateway.js.map +1 -0
- package/dist/vendor/adapters.json +2707 -0
- package/dist/vendor/bun/BunChildProcessSpawner.d.ts +7 -0
- package/dist/vendor/bun/BunChildProcessSpawner.js +14 -0
- package/dist/vendor/bun/BunClusterHttp.d.ts +83 -0
- package/dist/vendor/bun/BunClusterHttp.js +39 -0
- package/dist/vendor/bun/BunClusterSocket.d.ts +65 -0
- package/dist/vendor/bun/BunClusterSocket.js +22 -0
- package/dist/vendor/bun/BunCrypto.d.ts +10 -0
- package/dist/vendor/bun/BunCrypto.js +8 -0
- package/dist/vendor/bun/BunFileSystem.d.ts +10 -0
- package/dist/vendor/bun/BunFileSystem.js +9 -0
- package/dist/vendor/bun/BunHttpClient.d.ts +9 -0
- package/dist/vendor/bun/BunHttpClient.js +1 -0
- package/dist/vendor/bun/BunHttpPlatform.d.ts +10 -0
- package/dist/vendor/bun/BunHttpPlatform.js +11 -0
- package/dist/vendor/bun/BunHttpServer.d.ts +142 -0
- package/dist/vendor/bun/BunHttpServer.js +38 -0
- package/dist/vendor/bun/BunHttpServerRequest.d.ts +18 -0
- package/dist/vendor/bun/BunHttpServerRequest.js +7 -0
- package/dist/vendor/bun/BunMultipart.d.ts +31 -0
- package/dist/vendor/bun/BunMultipart.js +12 -0
- package/dist/vendor/bun/BunPath.d.ts +24 -0
- package/dist/vendor/bun/BunPath.js +12 -0
- package/dist/vendor/bun/BunRedis.d.ts +49 -0
- package/dist/vendor/bun/BunRedis.js +11 -0
- package/dist/vendor/bun/BunRuntime.d.ts +85 -0
- package/dist/vendor/bun/BunRuntime.js +8 -0
- package/dist/vendor/bun/BunServices.d.ts +34 -0
- package/dist/vendor/bun/BunServices.js +23 -0
- package/dist/vendor/bun/BunSink.d.ts +8 -0
- package/dist/vendor/bun/BunSink.js +12 -0
- package/dist/vendor/bun/BunSocket.d.ts +40 -0
- package/dist/vendor/bun/BunSocket.js +29 -0
- package/dist/vendor/bun/BunSocketServer.d.ts +8 -0
- package/dist/vendor/bun/BunSocketServer.js +21 -0
- package/dist/vendor/bun/BunStdio.d.ts +11 -0
- package/dist/vendor/bun/BunStdio.js +10 -0
- package/dist/vendor/bun/BunStream.d.ts +19 -0
- package/dist/vendor/bun/BunStream.js +30 -0
- package/dist/vendor/bun/BunTerminal.d.ts +21 -0
- package/dist/vendor/bun/BunTerminal.js +10 -0
- package/dist/vendor/bun/BunWorker.d.ts +20 -0
- package/dist/vendor/bun/BunWorker.js +9 -0
- package/dist/vendor/bun/BunWorkerRunner.d.ts +12 -0
- package/dist/vendor/bun/BunWorkerRunner.js +7 -0
- package/dist/vendor/bun/LICENSE +21 -0
- package/dist/vendor/bun/index.d.ts +92 -0
- package/dist/vendor/bun/index.js +107 -0
- package/dist/vendor/chunk-2GCOZTTW.js +48 -0
- package/dist/vendor/chunk-37CUR3PO.js +81 -0
- package/dist/vendor/chunk-3ARKKENZ.js +45 -0
- package/dist/vendor/chunk-3NV2UDBI.js +7 -0
- package/dist/vendor/chunk-3OSW7CT7.js +143 -0
- package/dist/vendor/chunk-62R63L74.js +62 -0
- package/dist/vendor/chunk-6AQLBC2I.js +118 -0
- package/dist/vendor/chunk-6C5H7S6B.js +18 -0
- package/dist/vendor/chunk-6DY5RBZD.js +85 -0
- package/dist/vendor/chunk-6UPBD47P.js +53 -0
- package/dist/vendor/chunk-AVVVN75Z.js +96 -0
- package/dist/vendor/chunk-B4DHEMBB.js +14 -0
- package/dist/vendor/chunk-BCK3NJOX.js +15 -0
- package/dist/vendor/chunk-BFBIHJ6X.js +0 -0
- package/dist/vendor/chunk-CES4OUM4.js +63 -0
- package/dist/vendor/chunk-D64L6YND.js +59 -0
- package/dist/vendor/chunk-DS2R6WOM.js +18 -0
- package/dist/vendor/chunk-DX4Z23DM.js +65 -0
- package/dist/vendor/chunk-DZ2VOUDP.js +564 -0
- package/dist/vendor/chunk-FOXN6JPJ.js +61 -0
- package/dist/vendor/chunk-FPQF7CR5.js +55 -0
- package/dist/vendor/chunk-FUTCTCEG.js +20 -0
- package/dist/vendor/chunk-GUPAV2YZ.js +18 -0
- package/dist/vendor/chunk-H2Z2Y4QH.js +70 -0
- package/dist/vendor/chunk-HAEDVSSM.js +129 -0
- package/dist/vendor/chunk-HY7BBL3K.js +93 -0
- package/dist/vendor/chunk-IFTTT6D5.js +31 -0
- package/dist/vendor/chunk-KQDSNB7M.js +26 -0
- package/dist/vendor/chunk-LIHLXXGQ.js +26 -0
- package/dist/vendor/chunk-LKCGQEE5.js +28 -0
- package/dist/vendor/chunk-MH2J3BYB.js +0 -0
- package/dist/vendor/chunk-ML2NAFH2.js +131 -0
- package/dist/vendor/chunk-MLFIZ5O2.js +0 -0
- package/dist/vendor/chunk-MLKGABMK.js +9 -0
- package/dist/vendor/chunk-MSCLEMYX.js +71 -0
- package/dist/vendor/chunk-OBWXQKVP.js +57 -0
- package/dist/vendor/chunk-QR557K66.js +20 -0
- package/dist/vendor/chunk-R4QUY7DH.js +18 -0
- package/dist/vendor/chunk-RGECXXJS.js +18 -0
- package/dist/vendor/chunk-TFY7W6D4.js +36 -0
- package/dist/vendor/chunk-TGPIVY4A.js +104 -0
- package/dist/vendor/chunk-TGXCX6W3.js +398 -0
- package/dist/vendor/chunk-TOHSFXMV.js +437 -0
- package/dist/vendor/chunk-UHIDPUFF.js +34 -0
- package/dist/vendor/chunk-ULT6CWUI.js +109 -0
- package/dist/vendor/chunk-UXBGYQR3.js +18 -0
- package/dist/vendor/chunk-V6LUGQ7O.js +21 -0
- package/dist/vendor/chunk-W4OASVX6.js +92 -0
- package/dist/vendor/chunk-WAII54GA.js +18 -0
- package/dist/vendor/chunk-WECQDT36.js +426 -0
- package/dist/vendor/chunk-WHKMOC7Z.js +28 -0
- package/dist/vendor/chunk-WVFOZ2UL.js +40 -0
- package/dist/vendor/chunk-X73E2UPI.js +18 -0
- package/dist/vendor/chunk-XCYARUII.js +63 -0
- package/dist/vendor/chunk-XFEVTDVD.js +34 -0
- package/dist/vendor/chunk-XFZZYSJ4.js +22 -0
- package/dist/vendor/chunk-XJWJXLXJ.js +18 -0
- package/dist/vendor/chunk-XY3Q62EO.js +18 -0
- package/dist/vendor/chunk-YDASSC75.js +394 -0
- package/dist/vendor/chunk-Z6C7SO5Z.js +507 -0
- package/dist/vendor/chunk-Z7QNPJEB.js +229 -0
- package/dist/vendor/chunk-Z7QPP4YH.js +249 -0
- package/dist/vendor/chunk-ZCHYLHJH.js +86 -0
- package/dist/vendor/chunk-ZIQVYVMA.js +22 -0
- package/dist/vendor/chunk-ZPIG2CUA.js +34 -0
- package/dist/vendor/cjs/bun/BunChildProcessSpawner.d.ts +7 -0
- package/dist/vendor/cjs/bun/BunChildProcessSpawner.js +1 -0
- package/dist/vendor/cjs/bun/BunClusterHttp.d.ts +83 -0
- package/dist/vendor/cjs/bun/BunClusterHttp.js +1 -0
- package/dist/vendor/cjs/bun/BunClusterSocket.d.ts +65 -0
- package/dist/vendor/cjs/bun/BunClusterSocket.js +1 -0
- package/dist/vendor/cjs/bun/BunCrypto.d.ts +10 -0
- package/dist/vendor/cjs/bun/BunCrypto.js +1 -0
- package/dist/vendor/cjs/bun/BunFileSystem.d.ts +10 -0
- package/dist/vendor/cjs/bun/BunFileSystem.js +1 -0
- package/dist/vendor/cjs/bun/BunHttpClient.d.ts +9 -0
- package/dist/vendor/cjs/bun/BunHttpClient.js +1 -0
- package/dist/vendor/cjs/bun/BunHttpPlatform.d.ts +10 -0
- package/dist/vendor/cjs/bun/BunHttpPlatform.js +1 -0
- package/dist/vendor/cjs/bun/BunHttpServer.d.ts +142 -0
- package/dist/vendor/cjs/bun/BunHttpServer.js +1 -0
- package/dist/vendor/cjs/bun/BunHttpServerRequest.d.ts +18 -0
- package/dist/vendor/cjs/bun/BunHttpServerRequest.js +1 -0
- package/dist/vendor/cjs/bun/BunMultipart.d.ts +31 -0
- package/dist/vendor/cjs/bun/BunMultipart.js +1 -0
- package/dist/vendor/cjs/bun/BunPath.d.ts +24 -0
- package/dist/vendor/cjs/bun/BunPath.js +1 -0
- package/dist/vendor/cjs/bun/BunRedis.d.ts +49 -0
- package/dist/vendor/cjs/bun/BunRedis.js +1 -0
- package/dist/vendor/cjs/bun/BunRuntime.d.ts +85 -0
- package/dist/vendor/cjs/bun/BunRuntime.js +1 -0
- package/dist/vendor/cjs/bun/BunServices.d.ts +34 -0
- package/dist/vendor/cjs/bun/BunServices.js +1 -0
- package/dist/vendor/cjs/bun/BunSink.d.ts +8 -0
- package/dist/vendor/cjs/bun/BunSink.js +1 -0
- package/dist/vendor/cjs/bun/BunSocket.d.ts +40 -0
- package/dist/vendor/cjs/bun/BunSocket.js +1 -0
- package/dist/vendor/cjs/bun/BunSocketServer.d.ts +8 -0
- package/dist/vendor/cjs/bun/BunSocketServer.js +1 -0
- package/dist/vendor/cjs/bun/BunStdio.d.ts +11 -0
- package/dist/vendor/cjs/bun/BunStdio.js +1 -0
- package/dist/vendor/cjs/bun/BunStream.d.ts +19 -0
- package/dist/vendor/cjs/bun/BunStream.js +1 -0
- package/dist/vendor/cjs/bun/BunTerminal.d.ts +21 -0
- package/dist/vendor/cjs/bun/BunTerminal.js +1 -0
- package/dist/vendor/cjs/bun/BunWorker.d.ts +20 -0
- package/dist/vendor/cjs/bun/BunWorker.js +1 -0
- package/dist/vendor/cjs/bun/BunWorkerRunner.d.ts +12 -0
- package/dist/vendor/cjs/bun/BunWorkerRunner.js +1 -0
- package/dist/vendor/cjs/bun/index.d.ts +92 -0
- package/dist/vendor/cjs/bun/index.js +1 -0
- package/dist/vendor/cjs/node/NodeChildProcessSpawner.d.ts +7 -0
- package/dist/vendor/cjs/node/NodeChildProcessSpawner.js +1 -0
- package/dist/vendor/cjs/node/NodeClusterHttp.d.ts +63 -0
- package/dist/vendor/cjs/node/NodeClusterHttp.js +1 -0
- package/dist/vendor/cjs/node/NodeClusterSocket.d.ts +79 -0
- package/dist/vendor/cjs/node/NodeClusterSocket.js +1 -0
- package/dist/vendor/cjs/node/NodeCrypto.d.ts +10 -0
- package/dist/vendor/cjs/node/NodeCrypto.js +1 -0
- package/dist/vendor/cjs/node/NodeFileSystem.d.ts +10 -0
- package/dist/vendor/cjs/node/NodeFileSystem.js +1 -0
- package/dist/vendor/cjs/node/NodeHttpClient.d.ts +179 -0
- package/dist/vendor/cjs/node/NodeHttpClient.js +1 -0
- package/dist/vendor/cjs/node/NodeHttpIncomingMessage.d.ts +62 -0
- package/dist/vendor/cjs/node/NodeHttpIncomingMessage.js +1 -0
- package/dist/vendor/cjs/node/NodeHttpPlatform.d.ts +36 -0
- package/dist/vendor/cjs/node/NodeHttpPlatform.js +1 -0
- package/dist/vendor/cjs/node/NodeHttpServer.d.ts +120 -0
- package/dist/vendor/cjs/node/NodeHttpServer.js +1 -0
- package/dist/vendor/cjs/node/NodeHttpServerRequest.d.ts +29 -0
- package/dist/vendor/cjs/node/NodeHttpServerRequest.js +1 -0
- package/dist/vendor/cjs/node/NodeMultipart.d.ts +46 -0
- package/dist/vendor/cjs/node/NodeMultipart.js +1 -0
- package/dist/vendor/cjs/node/NodeMultipartParser.d.ts +97 -0
- package/dist/vendor/cjs/node/NodeMultipartParser.js +1 -0
- package/dist/vendor/cjs/node/NodePath.d.ts +27 -0
- package/dist/vendor/cjs/node/NodePath.js +1 -0
- package/dist/vendor/cjs/node/NodeRedis.d.ts +74 -0
- package/dist/vendor/cjs/node/NodeRedis.js +1 -0
- package/dist/vendor/cjs/node/NodeRuntime.d.ts +85 -0
- package/dist/vendor/cjs/node/NodeRuntime.js +1 -0
- package/dist/vendor/cjs/node/NodeServices.d.ts +34 -0
- package/dist/vendor/cjs/node/NodeServices.js +1 -0
- package/dist/vendor/cjs/node/NodeSink.d.ts +8 -0
- package/dist/vendor/cjs/node/NodeSink.js +1 -0
- package/dist/vendor/cjs/node/NodeSocket.d.ts +38 -0
- package/dist/vendor/cjs/node/NodeSocket.js +1 -0
- package/dist/vendor/cjs/node/NodeSocketServer.d.ts +8 -0
- package/dist/vendor/cjs/node/NodeSocketServer.js +1 -0
- package/dist/vendor/cjs/node/NodeStdio.d.ts +11 -0
- package/dist/vendor/cjs/node/NodeStdio.js +1 -0
- package/dist/vendor/cjs/node/NodeStream.d.ts +8 -0
- package/dist/vendor/cjs/node/NodeStream.js +1 -0
- package/dist/vendor/cjs/node/NodeTerminal.d.ts +21 -0
- package/dist/vendor/cjs/node/NodeTerminal.js +1 -0
- package/dist/vendor/cjs/node/NodeWorker.d.ts +22 -0
- package/dist/vendor/cjs/node/NodeWorker.js +1 -0
- package/dist/vendor/cjs/node/NodeWorkerRunner.d.ts +12 -0
- package/dist/vendor/cjs/node/NodeWorkerRunner.js +1 -0
- package/dist/vendor/cjs/node/Undici.d.ts +28 -0
- package/dist/vendor/cjs/node/Undici.js +1 -0
- package/dist/vendor/cjs/node/index.d.ts +100 -0
- package/dist/vendor/cjs/node/index.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeChildProcessSpawner.d.ts +57 -0
- package/dist/vendor/cjs/node-shared/NodeChildProcessSpawner.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeClusterSocket.d.ts +22 -0
- package/dist/vendor/cjs/node-shared/NodeClusterSocket.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeCrypto.d.ts +27 -0
- package/dist/vendor/cjs/node-shared/NodeCrypto.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeFileSystem.d.ts +11 -0
- package/dist/vendor/cjs/node-shared/NodeFileSystem.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeHttpCompression.d.ts +36 -0
- package/dist/vendor/cjs/node-shared/NodeHttpCompression.js +1 -0
- package/dist/vendor/cjs/node-shared/NodePath.d.ts +27 -0
- package/dist/vendor/cjs/node-shared/NodePath.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeRuntime.d.ts +47 -0
- package/dist/vendor/cjs/node-shared/NodeRuntime.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeSink.d.ts +69 -0
- package/dist/vendor/cjs/node-shared/NodeSink.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeSocket.d.ts +134 -0
- package/dist/vendor/cjs/node-shared/NodeSocket.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeSocketServer.d.ts +80 -0
- package/dist/vendor/cjs/node-shared/NodeSocketServer.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeStdio.d.ts +12 -0
- package/dist/vendor/cjs/node-shared/NodeStdio.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeStream.d.ts +179 -0
- package/dist/vendor/cjs/node-shared/NodeStream.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeTerminal.d.ts +22 -0
- package/dist/vendor/cjs/node-shared/NodeTerminal.js +1 -0
- package/dist/vendor/cjs/node-shared/index.d.ts +56 -0
- package/dist/vendor/cjs/node-shared/index.js +1 -0
- package/dist/vendor/cjs/node-shared/internal/nodeChildProcessSpawner.d.ts +4 -0
- package/dist/vendor/cjs/node-shared/internal/nodeChildProcessSpawner.js +1 -0
- package/dist/vendor/cjs/node-shared/internal/utils.d.ts +2 -0
- package/dist/vendor/cjs/node-shared/internal/utils.js +1 -0
- package/dist/vendor/cjs/package.json +1 -0
- package/dist/vendor/cjs/platform-bun.d.ts +92 -0
- package/dist/vendor/cjs/platform-bun.js +1 -0
- package/dist/vendor/cjs/platform-node-shared.d.ts +56 -0
- package/dist/vendor/cjs/platform-node-shared.js +1 -0
- package/dist/vendor/cjs/platform-node.d.ts +100 -0
- package/dist/vendor/cjs/platform-node.js +1 -0
- package/dist/vendor/node/LICENSE +21 -0
- package/dist/vendor/node/NodeChildProcessSpawner.d.ts +7 -0
- package/dist/vendor/node/NodeChildProcessSpawner.js +14 -0
- package/dist/vendor/node/NodeClusterHttp.d.ts +63 -0
- package/dist/vendor/node/NodeClusterHttp.js +43 -0
- package/dist/vendor/node/NodeClusterSocket.d.ts +79 -0
- package/dist/vendor/node/NodeClusterSocket.js +30 -0
- package/dist/vendor/node/NodeCrypto.d.ts +10 -0
- package/dist/vendor/node/NodeCrypto.js +8 -0
- package/dist/vendor/node/NodeFileSystem.d.ts +10 -0
- package/dist/vendor/node/NodeFileSystem.js +9 -0
- package/dist/vendor/node/NodeHttpClient.d.ts +179 -0
- package/dist/vendor/node/NodeHttpClient.js +46 -0
- package/dist/vendor/node/NodeHttpIncomingMessage.d.ts +62 -0
- package/dist/vendor/node/NodeHttpIncomingMessage.js +10 -0
- package/dist/vendor/node/NodeHttpPlatform.d.ts +36 -0
- package/dist/vendor/node/NodeHttpPlatform.js +16 -0
- package/dist/vendor/node/NodeHttpServer.d.ts +120 -0
- package/dist/vendor/node/NodeHttpServer.js +46 -0
- package/dist/vendor/node/NodeHttpServerRequest.d.ts +29 -0
- package/dist/vendor/node/NodeHttpServerRequest.js +9 -0
- package/dist/vendor/node/NodeMultipart.d.ts +46 -0
- package/dist/vendor/node/NodeMultipart.js +15 -0
- package/dist/vendor/node/NodeMultipartParser.d.ts +97 -0
- package/dist/vendor/node/NodeMultipartParser.js +11 -0
- package/dist/vendor/node/NodePath.d.ts +27 -0
- package/dist/vendor/node/NodePath.js +12 -0
- package/dist/vendor/node/NodeRedis.d.ts +74 -0
- package/dist/vendor/node/NodeRedis.js +11 -0
- package/dist/vendor/node/NodeRuntime.d.ts +85 -0
- package/dist/vendor/node/NodeRuntime.js +8 -0
- package/dist/vendor/node/NodeServices.d.ts +34 -0
- package/dist/vendor/node/NodeServices.js +23 -0
- package/dist/vendor/node/NodeSink.d.ts +8 -0
- package/dist/vendor/node/NodeSink.js +12 -0
- package/dist/vendor/node/NodeSocket.d.ts +38 -0
- package/dist/vendor/node/NodeSocket.js +31 -0
- package/dist/vendor/node/NodeSocketServer.d.ts +8 -0
- package/dist/vendor/node/NodeSocketServer.js +21 -0
- package/dist/vendor/node/NodeStdio.d.ts +11 -0
- package/dist/vendor/node/NodeStdio.js +10 -0
- package/dist/vendor/node/NodeStream.d.ts +8 -0
- package/dist/vendor/node/NodeStream.js +27 -0
- package/dist/vendor/node/NodeTerminal.d.ts +21 -0
- package/dist/vendor/node/NodeTerminal.js +10 -0
- package/dist/vendor/node/NodeWorker.d.ts +22 -0
- package/dist/vendor/node/NodeWorker.js +9 -0
- package/dist/vendor/node/NodeWorkerRunner.d.ts +12 -0
- package/dist/vendor/node/NodeWorkerRunner.js +7 -0
- package/dist/vendor/node/Undici.d.ts +28 -0
- package/dist/vendor/node/Undici.js +9 -0
- package/dist/vendor/node/index.d.ts +100 -0
- package/dist/vendor/node/index.js +115 -0
- package/dist/vendor/node-shared/LICENSE +21 -0
- package/dist/vendor/node-shared/NodeChildProcessSpawner.d.ts +57 -0
- package/dist/vendor/node-shared/NodeChildProcessSpawner.js +13 -0
- package/dist/vendor/node-shared/NodeClusterSocket.d.ts +22 -0
- package/dist/vendor/node-shared/NodeClusterSocket.js +11 -0
- package/dist/vendor/node-shared/NodeCrypto.d.ts +27 -0
- package/dist/vendor/node-shared/NodeCrypto.js +9 -0
- package/dist/vendor/node-shared/NodeFileSystem.d.ts +11 -0
- package/dist/vendor/node-shared/NodeFileSystem.js +8 -0
- package/dist/vendor/node-shared/NodeHttpCompression.d.ts +36 -0
- package/dist/vendor/node-shared/NodeHttpCompression.js +13 -0
- package/dist/vendor/node-shared/NodePath.d.ts +27 -0
- package/dist/vendor/node-shared/NodePath.js +11 -0
- package/dist/vendor/node-shared/NodeRuntime.d.ts +47 -0
- package/dist/vendor/node-shared/NodeRuntime.js +7 -0
- package/dist/vendor/node-shared/NodeSink.d.ts +69 -0
- package/dist/vendor/node-shared/NodeSink.js +11 -0
- package/dist/vendor/node-shared/NodeSocket.d.ts +134 -0
- package/dist/vendor/node-shared/NodeSocket.js +23 -0
- package/dist/vendor/node-shared/NodeSocketServer.d.ts +80 -0
- package/dist/vendor/node-shared/NodeSocketServer.js +20 -0
- package/dist/vendor/node-shared/NodeStdio.d.ts +12 -0
- package/dist/vendor/node-shared/NodeStdio.js +9 -0
- package/dist/vendor/node-shared/NodeStream.d.ts +179 -0
- package/dist/vendor/node-shared/NodeStream.js +26 -0
- package/dist/vendor/node-shared/NodeTerminal.d.ts +22 -0
- package/dist/vendor/node-shared/NodeTerminal.js +9 -0
- package/dist/vendor/node-shared/index.d.ts +56 -0
- package/dist/vendor/node-shared/index.js +58 -0
- package/dist/vendor/node-shared/internal/nodeChildProcessSpawner.d.ts +4 -0
- package/dist/vendor/node-shared/internal/nodeChildProcessSpawner.js +7 -0
- package/dist/vendor/node-shared/internal/utils.d.ts +2 -0
- package/dist/vendor/node-shared/internal/utils.js +7 -0
- package/dist/vendor/platform-bun.d.ts +92 -0
- package/dist/vendor/platform-bun.js +107 -0
- package/dist/vendor/platform-node-shared.d.ts +56 -0
- package/dist/vendor/platform-node-shared.js +58 -0
- package/dist/vendor/platform-node.d.ts +100 -0
- package/dist/vendor/platform-node.js +115 -0
- package/docs/README.md +158 -0
- package/docs/api.md +601 -0
- package/docs/concepts/projections.md +250 -0
- package/docs/concepts/subscriptions.md +204 -0
- package/docs/concepts/trust-boundary.md +256 -0
- package/docs/guides/diagnose-a-run.md +115 -0
- package/docs/guides/follow-a-run.md +150 -0
- package/docs/guides/host-the-gateway.md +153 -0
- package/docs/guides/read-a-projection.md +138 -0
- package/docs/guides/serve-beyond-loopback.md +166 -0
- package/docs/guides/submit-an-approval.md +187 -0
- package/docs/guides/testing.md +148 -0
- package/docs/installation.md +89 -0
- package/docs/quickstart.md +200 -0
- package/docs/troubleshooting.md +355 -0
- package/package.json +264 -32
- package/src/Diagnosis.ts +892 -0
- package/src/EngineTrace.ts +627 -0
- package/src/GatewayError.ts +71 -0
- package/src/GatewayProjection.ts +959 -0
- package/src/GatewayRpcs.ts +179 -0
- package/src/GatewaySchema.ts +516 -0
- package/src/GatewayServer.ts +932 -0
- package/src/HostBranchPresence.ts +76 -0
- package/src/Projections.ts +1735 -0
- package/src/RunDevTools.ts +394 -0
- package/src/RunHistory.ts +174 -0
- package/src/RunTrace.ts +2796 -0
- package/src/RuntimeBridge.ts +835 -0
- package/src/bun/BunGateway.ts +52 -0
- package/src/index.ts +77 -0
- package/src/internal/NativeGateway.ts +360 -0
- package/src/internal/actionRenderings.ts +212 -0
- package/src/internal/callEvents.ts +257 -0
- package/src/internal/digestIndex.ts +134 -0
- package/src/internal/digestMemory.ts +27 -0
- package/src/internal/inspectLabels.ts +18 -0
- package/src/internal/nativeResolution.ts +103 -0
- package/src/internal/nodeEvents.ts +100 -0
- package/src/node/NodeGateway.ts +30 -0
- package/openapi.yaml +0 -29945
- package/src/README.md +0 -39
- package/src/api/README.md +0 -23
- package/src/api/apiCollectionNames.js +0 -10
- package/src/api/index.d.ts +0 -126
- package/src/api/index.js +0 -14
- package/src/api/normalizeApiRow.js +0 -36
- package/src/api/serializeAccountRow.js +0 -10
- package/src/api/serializeApprovalRow.js +0 -53
- package/src/api/serializeComparisonScoreRow.js +0 -18
- package/src/api/serializeCronRow.js +0 -30
- package/src/api/serializeDocRow.js +0 -20
- package/src/api/serializeMemoryFactRow.js +0 -21
- package/src/api/serializePromptRow.js +0 -10
- package/src/api/serializeRunEventRow.js +0 -28
- package/src/api/serializeRunRow.js +0 -93
- package/src/api/serializeScoreDetailRow.js +0 -25
- package/src/api/serializeScoreRow.js +0 -26
- package/src/api/serializeTicketRow.js +0 -20
- package/src/api/serializeWorkflowRow.js +0 -10
- package/src/auth/scopes.d.ts +0 -19
- package/src/auth/scopes.js +0 -164
- package/src/index.d.ts +0 -316
- package/src/index.js +0 -108
- package/src/rpc/gatewayRpcTypes.ts +0 -186
- package/src/rpc/index.d.ts +0 -223
- package/src/rpc/index.js +0 -2527
|
@@ -0,0 +1,906 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var Projections_exports = {};
|
|
30
|
+
__export(Projections_exports, {
|
|
31
|
+
Projections: () => Projections,
|
|
32
|
+
heartbeatIntervalMillis: () => heartbeatIntervalMillis,
|
|
33
|
+
layer: () => layer,
|
|
34
|
+
layerWith: () => layerWith,
|
|
35
|
+
make: () => make,
|
|
36
|
+
maxDurationRuns: () => maxDurationRuns,
|
|
37
|
+
maxEventBytes: () => maxEventBytes,
|
|
38
|
+
maxEventsPerPage: () => maxEventsPerPage,
|
|
39
|
+
maxEventsPerRun: () => maxEventsPerRun,
|
|
40
|
+
maxEventsScanned: () => maxEventsScanned,
|
|
41
|
+
maxProjectionBytes: () => maxProjectionBytes,
|
|
42
|
+
maxWorkspaceRuns: () => maxWorkspaceRuns
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(Projections_exports);
|
|
45
|
+
var import_Control = require("@smthrs/control/Control");
|
|
46
|
+
var ControlSchema = __toESM(require("@smthrs/control/ControlSchema"), 1);
|
|
47
|
+
var Health = __toESM(require("@smthrs/control/Health"), 1);
|
|
48
|
+
var import_effect = require("effect");
|
|
49
|
+
var Diagnosis = __toESM(require("./Diagnosis.js"), 1);
|
|
50
|
+
var import_GatewayError = require("./GatewayError.js");
|
|
51
|
+
var GatewayProjection = __toESM(require("./GatewayProjection.js"), 1);
|
|
52
|
+
var GatewaySchema = __toESM(require("./GatewaySchema.js"), 1);
|
|
53
|
+
var import_callEvents = require("./internal/callEvents.js");
|
|
54
|
+
var import_digestMemory = require("./internal/digestMemory.js");
|
|
55
|
+
var NativeResolution = __toESM(require("./internal/nativeResolution.js"), 1);
|
|
56
|
+
const heartbeatIntervalMillis = 3e4;
|
|
57
|
+
const maxWorkspaceRuns = 500;
|
|
58
|
+
const createdAfter = (run, other) => run.createdAt !== other.createdAt ? run.createdAt > other.createdAt : run.runId > other.runId;
|
|
59
|
+
const maxEventsPerRun = 1e4;
|
|
60
|
+
const maxEventsScanned = 1e5;
|
|
61
|
+
const maxEventsPerPage = 1e3;
|
|
62
|
+
const maxDurationRuns = 20;
|
|
63
|
+
const maxProjectionBytes = 4 * 1024 * 1024;
|
|
64
|
+
const maxEventBytes = 16 * 1024;
|
|
65
|
+
const clippedTextPoints = 2048;
|
|
66
|
+
const workspaceDeltaCoalesceMillis = 50;
|
|
67
|
+
const workspaceDeltaBatchSize = 1024;
|
|
68
|
+
class Projections extends import_effect.Context.Service()("@smthrs/gateway/Projections") {
|
|
69
|
+
}
|
|
70
|
+
const summarize = (cause) => {
|
|
71
|
+
const record = typeof cause === "object" && cause !== null ? cause : void 0;
|
|
72
|
+
if (record === void 0 || typeof record._tag !== "string") return void 0;
|
|
73
|
+
return typeof record.code === "string" ? { _tag: record._tag, code: record.code } : { _tag: record._tag };
|
|
74
|
+
};
|
|
75
|
+
const logReadFailure = (operation, cause) => {
|
|
76
|
+
const summary = summarize(cause);
|
|
77
|
+
const known = summary?._tag === "/control/PersistenceError" && summary.code === "persistence_failed" || summary?._tag === "/control/Unavailable" && summary.code === "unavailable";
|
|
78
|
+
return import_effect.Effect.logWarning({ operation, ...known ? summary : {} });
|
|
79
|
+
};
|
|
80
|
+
const unavailable = (message, cause) => {
|
|
81
|
+
const summary = summarize(cause);
|
|
82
|
+
return new import_GatewayError.GatewayError({
|
|
83
|
+
code: "run_unavailable",
|
|
84
|
+
message,
|
|
85
|
+
...summary === void 0 ? {} : { cause: summary }
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
const malformed = (message) => new import_GatewayError.GatewayError({ code: "malformed_request", message });
|
|
89
|
+
const resourceLimit = (message) => new import_GatewayError.GatewayError({ code: "resource_limit", message });
|
|
90
|
+
const scopeOf = (selector) => "runId" in selector ? selector.runId : void 0;
|
|
91
|
+
const emptyEventBuffer = (compactHealth = false) => ({
|
|
92
|
+
compactHealth,
|
|
93
|
+
seen: false,
|
|
94
|
+
events: [],
|
|
95
|
+
encodedBytes: 2,
|
|
96
|
+
lastPosition: { value: 0, offset: 0 },
|
|
97
|
+
carry: void 0,
|
|
98
|
+
dropped: 0
|
|
99
|
+
});
|
|
100
|
+
const textEncoder = new TextEncoder();
|
|
101
|
+
const encodedSize = (value) => textEncoder.encode(JSON.stringify(value)).byteLength;
|
|
102
|
+
const clipDeep = (value) => {
|
|
103
|
+
if (typeof value === "string") return Diagnosis.clip(value, clippedTextPoints);
|
|
104
|
+
if (Array.isArray(value)) return value.map(clipDeep);
|
|
105
|
+
if (typeof value === "object" && value !== null) {
|
|
106
|
+
return Object.fromEntries(Object.entries(value).map(([key, member]) => [key, clipDeep(member)]));
|
|
107
|
+
}
|
|
108
|
+
return value;
|
|
109
|
+
};
|
|
110
|
+
const isJsonObject = (json) => typeof json === "object" && json !== null && !Array.isArray(json);
|
|
111
|
+
const retainedEvent = (event) => {
|
|
112
|
+
if (encodedSize(event) <= maxEventBytes) return event;
|
|
113
|
+
const clipped = { ...event, payload: clipDeep(event.payload) };
|
|
114
|
+
if (encodedSize(clipped) <= maxEventBytes) return clipped;
|
|
115
|
+
const marker = { truncated: true, encodedBytes: encodedSize(event.payload) };
|
|
116
|
+
const payload = event.payload;
|
|
117
|
+
if (event.kind === "control.agent.relevance-settled" && isJsonObject(payload)) {
|
|
118
|
+
const memory = (verdicts) => Array.isArray(verdicts) ? verdicts.filter(
|
|
119
|
+
(verdict) => typeof verdict === "object" && verdict !== null && verdict.kind === "memory"
|
|
120
|
+
) : [];
|
|
121
|
+
const compact = {
|
|
122
|
+
...event,
|
|
123
|
+
payload: {
|
|
124
|
+
...marker,
|
|
125
|
+
kept: clipDeep(memory(payload.kept)),
|
|
126
|
+
withheld: clipDeep(memory(payload.withheld))
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
if (encodedSize(compact) <= maxEventBytes) return compact;
|
|
130
|
+
}
|
|
131
|
+
return { ...event, payload: marker };
|
|
132
|
+
};
|
|
133
|
+
const decodeEvent = import_effect.Schema.decodeUnknownSync(ControlSchema.ControlEvent);
|
|
134
|
+
const decodeFrame = import_effect.Schema.decodeUnknownSync(GatewaySchema.GatewayFrame);
|
|
135
|
+
const decodeSnapshot = import_effect.Schema.decodeUnknownSync(GatewaySchema.ProjectionSnapshot);
|
|
136
|
+
const decodedEvent = (candidate, message) => import_effect.Effect.suspend(() => {
|
|
137
|
+
try {
|
|
138
|
+
const event = decodeEvent(candidate);
|
|
139
|
+
const payload = event.payload;
|
|
140
|
+
if (event.kind === "control.engine.event" && typeof payload === "object" && payload !== null && "eventType" in payload && (payload.eventType === "flows.engine.plan-recorded" || payload.eventType === "flows.engine.subgraph-appended") && encodedSize(event) > maxEventBytes) {
|
|
141
|
+
return import_effect.Effect.fail(resourceLimit(`One graph event exceeds ${maxEventBytes} encoded bytes`));
|
|
142
|
+
}
|
|
143
|
+
return Number.isSafeInteger(event.sequence) && event.sequence >= 0 ? import_effect.Effect.succeed(event) : import_effect.Effect.fail(unavailable(message, void 0));
|
|
144
|
+
} catch (cause) {
|
|
145
|
+
return import_effect.Effect.fail(unavailable(message, cause));
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
const appendEvent = (state, candidate, message, run) => import_effect.Effect.flatMap(decodedEvent(candidate, message), (decoded) => {
|
|
149
|
+
const resolution = encodedSize(decoded) > maxEventBytes ? NativeResolution.fromEvent(decoded) : void 0;
|
|
150
|
+
let carry = state.carry;
|
|
151
|
+
if (resolution?.result !== void 0) {
|
|
152
|
+
carry = Diagnosis.combine(carry ?? Diagnosis.emptyDigest(), {
|
|
153
|
+
...Diagnosis.emptyDigest(),
|
|
154
|
+
nativeResolution: resolution
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
const event = resolution?.result === void 0 ? retainedEvent(decoded) : {
|
|
158
|
+
...decoded,
|
|
159
|
+
payload: { truncated: true, encodedBytes: encodedSize(decoded.payload) }
|
|
160
|
+
};
|
|
161
|
+
const bytes = encodedSize(event);
|
|
162
|
+
let removedBytes = 0;
|
|
163
|
+
let keep = true;
|
|
164
|
+
if (state.compactHealth && event.kind === Health.statusObservedEventType) {
|
|
165
|
+
const decoded2 = import_effect.Schema.decodeUnknownOption(Health.HealthObservation)(event.payload);
|
|
166
|
+
if (decoded2._tag === "None" || decoded2.value.outcome === "discarded" || decoded2.value.subjectId !== `run:${run.runId}`) keep = false;
|
|
167
|
+
else {
|
|
168
|
+
const same = state.events.findIndex(
|
|
169
|
+
(old) => old.kind === Health.statusObservedEventType && typeof old.payload === "object" && old.payload !== null && !Array.isArray(old.payload) && "incarnation" in old.payload && old.payload.incarnation === decoded2.value.incarnation
|
|
170
|
+
);
|
|
171
|
+
if (same >= 0) {
|
|
172
|
+
const previous = state.events[same];
|
|
173
|
+
const prior = previous.payload;
|
|
174
|
+
if (prior.evidenceSeq > decoded2.value.evidenceSeq) keep = false;
|
|
175
|
+
else removedBytes += textEncoder.encode(JSON.stringify(state.events.splice(same, 1)[0])).byteLength + 1;
|
|
176
|
+
}
|
|
177
|
+
const healthEntries = state.events.filter((old) => old.kind === Health.statusObservedEventType);
|
|
178
|
+
if (keep && healthEntries.length >= 16) {
|
|
179
|
+
const incarnation = Health.runIncarnation(run);
|
|
180
|
+
const oldest = state.events.indexOf(
|
|
181
|
+
healthEntries.find((old) => old.payload.incarnation !== incarnation)
|
|
182
|
+
);
|
|
183
|
+
removedBytes += textEncoder.encode(JSON.stringify(state.events.splice(oldest, 1)[0])).byteLength + 1;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
} else if (state.compactHealth && event.kind === "control.monitor.beat") keep = false;
|
|
187
|
+
let encodedBytes = Math.max(2, state.encodedBytes - removedBytes) + (0, import_digestMemory.retainedDigestBytes)(carry) - (0, import_digestMemory.retainedDigestBytes)(state.carry) + (keep ? bytes + (state.events.length === 0 ? 0 : 1) : 0);
|
|
188
|
+
if (!Number.isSafeInteger(encodedBytes)) {
|
|
189
|
+
return import_effect.Effect.fail(unavailable(message, void 0));
|
|
190
|
+
}
|
|
191
|
+
const offset = state.seen && event.sequence === state.lastPosition.value ? state.lastPosition.offset + 1 : 0;
|
|
192
|
+
if (keep) state.events.push(event);
|
|
193
|
+
let dropped = state.dropped;
|
|
194
|
+
while (state.events.length > maxEventsPerRun || encodedBytes > maxProjectionBytes) {
|
|
195
|
+
const evicted = state.events.shift();
|
|
196
|
+
if (evicted === void 0) {
|
|
197
|
+
return import_effect.Effect.fail(resourceLimit(`Projection identity state exceeds ${maxProjectionBytes} encoded bytes`));
|
|
198
|
+
}
|
|
199
|
+
encodedBytes = Math.max(2, encodedBytes - encodedSize(evicted) - (state.events.length === 0 ? 0 : 1));
|
|
200
|
+
const previousCarryBytes = (0, import_digestMemory.retainedDigestBytes)(carry);
|
|
201
|
+
carry = Diagnosis.combine(carry ?? Diagnosis.emptyDigest(), Diagnosis.digest([evicted], run.runId));
|
|
202
|
+
encodedBytes += (0, import_digestMemory.retainedDigestBytes)(carry) - previousCarryBytes;
|
|
203
|
+
dropped += 1;
|
|
204
|
+
}
|
|
205
|
+
return import_effect.Effect.succeed({
|
|
206
|
+
compactHealth: state.compactHealth,
|
|
207
|
+
seen: true,
|
|
208
|
+
events: state.events,
|
|
209
|
+
encodedBytes,
|
|
210
|
+
lastPosition: { value: event.sequence, offset },
|
|
211
|
+
carry,
|
|
212
|
+
dropped
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
const bufferOf = (events, message, compactHealth, run) => events.reduce(
|
|
216
|
+
(state, event) => import_effect.Effect.flatMap(state, (buffer) => appendEvent(buffer, event, message, run)),
|
|
217
|
+
import_effect.Effect.succeed(emptyEventBuffer(compactHealth))
|
|
218
|
+
);
|
|
219
|
+
const cursorOf = (selector, position) => ({
|
|
220
|
+
selector,
|
|
221
|
+
projection: selector._tag,
|
|
222
|
+
runId: scopeOf(selector) ?? null,
|
|
223
|
+
value: position.value,
|
|
224
|
+
offset: position.offset
|
|
225
|
+
});
|
|
226
|
+
const comparePosition = (left, right) => left.value === right.value ? left.offset - right.offset : left.value - right.value;
|
|
227
|
+
const positionedEvents = (events) => {
|
|
228
|
+
let sequence = -1;
|
|
229
|
+
let offset = 0;
|
|
230
|
+
return events.map((event) => {
|
|
231
|
+
offset = event.sequence === sequence ? offset + 1 : 0;
|
|
232
|
+
sequence = event.sequence;
|
|
233
|
+
return { event, position: { value: sequence, offset } };
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
const sameSelector = (left, right) => {
|
|
237
|
+
if (left._tag !== right._tag) return false;
|
|
238
|
+
switch (left._tag) {
|
|
239
|
+
case "workspace-runs":
|
|
240
|
+
return left.flowId === right.flowId;
|
|
241
|
+
case "approvals":
|
|
242
|
+
return left.runId === right.runId;
|
|
243
|
+
case "node-output": {
|
|
244
|
+
const candidate = right;
|
|
245
|
+
return left.runId === candidate.runId && left.nodeId === candidate.nodeId;
|
|
246
|
+
}
|
|
247
|
+
case "flow-durations":
|
|
248
|
+
return left.flowId === right.flowId;
|
|
249
|
+
default:
|
|
250
|
+
return left.runId === right.runId;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
const rowsOfRun = (selector, source, now) => {
|
|
254
|
+
switch (selector._tag) {
|
|
255
|
+
case "workspace-runs":
|
|
256
|
+
case "run-summary":
|
|
257
|
+
return [GatewayProjection.runSummary(source.run, source.events, now, source.carry)];
|
|
258
|
+
case "run-tree":
|
|
259
|
+
return GatewayProjection.runTree(source.run, source.events);
|
|
260
|
+
case "run-events":
|
|
261
|
+
return source.events;
|
|
262
|
+
case "transcript":
|
|
263
|
+
return GatewayProjection.transcript(source.events);
|
|
264
|
+
case "approvals":
|
|
265
|
+
return GatewayProjection.approvals(source.events, source.run);
|
|
266
|
+
case "node-output":
|
|
267
|
+
return GatewayProjection.nodeOutput(source.events).filter((row) => row.nodeId === selector.nodeId);
|
|
268
|
+
case "flow-durations":
|
|
269
|
+
return GatewayProjection.nodeDurations(source.events, source.carry);
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
const turnsOpened = (events) => GatewayProjection.transcript(events).at(-1)?.turn ?? 0;
|
|
273
|
+
const transcriptAppend = (event, turnsBefore) => GatewayProjection.transcript([event]).map((row) => ({ ...row, turn: row.turn + turnsBefore }));
|
|
274
|
+
const eligibleForWorkspace = (selector, source) => selector._tag !== "approvals" || source.run.status === "waiting-approval" && GatewayProjection.approvals(source.events, source.run).some((row) => row.status === "pending");
|
|
275
|
+
const waitIdentity = (row) => row.waitRunId === void 0 ? void 0 : `${row.waitRunId}:${row.requestId}`;
|
|
276
|
+
const ownerRank = (runs) => {
|
|
277
|
+
const listed = new Map(runs.map((run) => [run.runId, run]));
|
|
278
|
+
const depths = /* @__PURE__ */ new Map();
|
|
279
|
+
const depthOf = (run) => {
|
|
280
|
+
const known = depths.get(run.runId);
|
|
281
|
+
if (known !== void 0) return known;
|
|
282
|
+
depths.set(run.runId, 0);
|
|
283
|
+
const parent = run.parentRunId === void 0 ? void 0 : listed.get(run.parentRunId);
|
|
284
|
+
const depth = parent === void 0 ? 0 : depthOf(parent) + 1;
|
|
285
|
+
depths.set(run.runId, depth);
|
|
286
|
+
return depth;
|
|
287
|
+
};
|
|
288
|
+
return (left, right) => depthOf(left) - depthOf(right) || (createdAfter(left, right) ? 1 : -1);
|
|
289
|
+
};
|
|
290
|
+
const approvalInbox = (perRun) => {
|
|
291
|
+
const owners = /* @__PURE__ */ new Map();
|
|
292
|
+
const rank = ownerRank(perRun.map(({ run }) => run));
|
|
293
|
+
for (const { run, rows } of [...perRun].sort((left, right) => rank(left.run, right.run))) {
|
|
294
|
+
for (const row of rows) {
|
|
295
|
+
const identity = waitIdentity(row);
|
|
296
|
+
if (identity !== void 0 && !owners.has(identity)) owners.set(identity, run.runId);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
const inbox = [];
|
|
300
|
+
for (const { run, rows } of perRun) {
|
|
301
|
+
for (const row of rows) {
|
|
302
|
+
const identity = waitIdentity(row);
|
|
303
|
+
if (identity !== void 0) {
|
|
304
|
+
if (owners.get(identity) !== run.runId) continue;
|
|
305
|
+
owners.delete(identity);
|
|
306
|
+
}
|
|
307
|
+
inbox.push(row);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return inbox;
|
|
311
|
+
};
|
|
312
|
+
const pendingApprovals = (source) => GatewayProjection.approvals(source.events, source.run).filter((row) => row.status === "pending");
|
|
313
|
+
const rowsOfWorkspace = (selector, runs, now) => {
|
|
314
|
+
if (selector._tag === "flow-durations") {
|
|
315
|
+
return GatewayProjection.flowDurations(
|
|
316
|
+
selector.flowId,
|
|
317
|
+
runs.flatMap((source) => rowsOfRun(selector, source, now))
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
if (selector._tag !== "approvals") return runs.flatMap((source) => rowsOfRun(selector, source, now));
|
|
321
|
+
return approvalInbox(runs.map((source) => ({ run: source.run, rows: pendingApprovals(source) })));
|
|
322
|
+
};
|
|
323
|
+
const rowsOf = (selector, source, now) => source._tag === "run" ? rowsOfRun(selector, source.run, now) : rowsOfWorkspace(selector, source.runs, now);
|
|
324
|
+
const boundedRows = (selector, candidate) => import_effect.Effect.suspend(() => {
|
|
325
|
+
try {
|
|
326
|
+
const schema = import_effect.Schema.Array(GatewaySchema.rowSchemaFor(selector));
|
|
327
|
+
const rows = import_effect.Schema.decodeUnknownSync(schema)(candidate);
|
|
328
|
+
const encoded = import_effect.Schema.encodeUnknownSync(schema)(rows);
|
|
329
|
+
const bytes = textEncoder.encode(JSON.stringify(encoded)).byteLength;
|
|
330
|
+
return bytes <= maxProjectionBytes ? import_effect.Effect.succeed(rows) : import_effect.Effect.fail(resourceLimit(`Projection rows exceed ${maxProjectionBytes} encoded bytes`));
|
|
331
|
+
} catch (cause) {
|
|
332
|
+
return import_effect.Effect.fail(unavailable("Projection produced invalid rows", cause));
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
const frameOf = (candidate) => import_effect.Effect.suspend(() => {
|
|
336
|
+
try {
|
|
337
|
+
return import_effect.Effect.succeed(decodeFrame(candidate));
|
|
338
|
+
} catch (cause) {
|
|
339
|
+
return import_effect.Effect.fail(unavailable("Projection produced an invalid frame", cause));
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
const snapshotOf = (candidate) => import_effect.Effect.suspend(() => {
|
|
343
|
+
try {
|
|
344
|
+
return import_effect.Effect.succeed(decodeSnapshot(candidate));
|
|
345
|
+
} catch (cause) {
|
|
346
|
+
return import_effect.Effect.fail(unavailable("Projection produced an invalid snapshot", cause));
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
const cursorPositionOf = (source) => source._tag === "run" ? source.run.lastPosition : { value: 0, offset: 0 };
|
|
350
|
+
const makeService = (control, heartbeatMillis, now) => {
|
|
351
|
+
const journalBuffers = /* @__PURE__ */ new Map();
|
|
352
|
+
const eventsOf = (run, compactHealth) => import_effect.Effect.suspend(() => {
|
|
353
|
+
const runId = run.runId;
|
|
354
|
+
const key = `${runId}:${compactHealth}`;
|
|
355
|
+
const cached = journalBuffers.get(key);
|
|
356
|
+
const seed = cached === void 0 ? emptyEventBuffer(compactHealth) : { ...cached, events: [...cached.events] };
|
|
357
|
+
const message = `Reading the events of ${runId} failed`;
|
|
358
|
+
let position;
|
|
359
|
+
return import_effect.Stream.runFoldEffect(
|
|
360
|
+
control.watch({
|
|
361
|
+
runId,
|
|
362
|
+
follow: false,
|
|
363
|
+
...cached === void 0 || !cached.seen || cached.lastPosition.value === 0 ? {} : { afterSequence: cached.lastPosition.value - 1 }
|
|
364
|
+
}).pipe(
|
|
365
|
+
import_effect.Stream.tapError((cause) => logReadFailure("read-events", cause)),
|
|
366
|
+
import_effect.Stream.mapError((cause) => unavailable(message, cause)),
|
|
367
|
+
import_effect.Stream.take(maxEventsScanned)
|
|
368
|
+
),
|
|
369
|
+
() => seed,
|
|
370
|
+
(buffer, candidate) => import_effect.Effect.flatMap(decodedEvent(candidate, message), (event) => {
|
|
371
|
+
if (position !== void 0 && event.sequence < position.value) {
|
|
372
|
+
return import_effect.Effect.fail(unavailable(message, void 0));
|
|
373
|
+
}
|
|
374
|
+
position = { value: event.sequence, offset: position?.value === event.sequence ? position.offset + 1 : 0 };
|
|
375
|
+
if (cached !== void 0 && cached.seen && comparePosition(position, cached.lastPosition) <= 0) {
|
|
376
|
+
return import_effect.Effect.succeed(buffer);
|
|
377
|
+
}
|
|
378
|
+
return appendEvent(buffer, event, message, run);
|
|
379
|
+
})
|
|
380
|
+
).pipe(import_effect.Effect.tap(
|
|
381
|
+
(buffer) => import_effect.Effect.sync(() => {
|
|
382
|
+
const current = journalBuffers.get(key);
|
|
383
|
+
if (current === void 0 || comparePosition(buffer.lastPosition, current.lastPosition) >= 0) {
|
|
384
|
+
journalBuffers.delete(key);
|
|
385
|
+
journalBuffers.set(key, { ...buffer, events: [...buffer.events] });
|
|
386
|
+
if (journalBuffers.size > 32) journalBuffers.delete(journalBuffers.keys().next().value);
|
|
387
|
+
}
|
|
388
|
+
})
|
|
389
|
+
));
|
|
390
|
+
});
|
|
391
|
+
const runEventsPage = (run, after) => {
|
|
392
|
+
const runId = run.runId;
|
|
393
|
+
const message = `Reading the events of ${runId} failed`;
|
|
394
|
+
const empty = { events: [], bytes: 2, seen: void 0, last: void 0, full: false };
|
|
395
|
+
let stopped = false;
|
|
396
|
+
return import_effect.Stream.runFoldEffect(
|
|
397
|
+
control.watch({
|
|
398
|
+
runId,
|
|
399
|
+
...after === void 0 || after.value === 0 ? {} : { afterSequence: after.value - 1 },
|
|
400
|
+
follow: false
|
|
401
|
+
}).pipe(
|
|
402
|
+
import_effect.Stream.tapError((cause) => logReadFailure("read-events", cause)),
|
|
403
|
+
import_effect.Stream.mapError((cause) => unavailable(message, cause)),
|
|
404
|
+
import_effect.Stream.take(maxEventsScanned),
|
|
405
|
+
import_effect.Stream.takeWhile(() => !stopped)
|
|
406
|
+
),
|
|
407
|
+
() => empty,
|
|
408
|
+
(page, candidate) => page.full ? import_effect.Effect.succeed(page) : import_effect.Effect.flatMap(
|
|
409
|
+
decodedEvent(candidate, `${message}: the control plane returned an invalid event`),
|
|
410
|
+
(decoded) => {
|
|
411
|
+
if (page.seen !== void 0 && decoded.sequence < page.seen.value) {
|
|
412
|
+
return import_effect.Effect.fail(unavailable(message, void 0));
|
|
413
|
+
}
|
|
414
|
+
const position = {
|
|
415
|
+
value: decoded.sequence,
|
|
416
|
+
offset: page.seen?.value === decoded.sequence ? page.seen.offset + 1 : 0
|
|
417
|
+
};
|
|
418
|
+
const seen = position;
|
|
419
|
+
if (after !== void 0 && comparePosition(position, after) <= 0) {
|
|
420
|
+
return import_effect.Effect.succeed({ ...page, seen });
|
|
421
|
+
}
|
|
422
|
+
const event = decoded.kind === "control.engine.event" ? decoded : retainedEvent(decoded);
|
|
423
|
+
if (encodedSize(event) + 2 > maxProjectionBytes) {
|
|
424
|
+
return import_effect.Effect.fail(resourceLimit(`One journal event exceeds ${maxProjectionBytes} encoded bytes`));
|
|
425
|
+
}
|
|
426
|
+
const bytes = page.bytes + encodedSize(event) + (page.events.length === 0 ? 0 : 1);
|
|
427
|
+
if (page.events.length > 0 && bytes > maxProjectionBytes) {
|
|
428
|
+
stopped = true;
|
|
429
|
+
return import_effect.Effect.succeed({ ...page, seen, full: true });
|
|
430
|
+
}
|
|
431
|
+
page.events.push(event);
|
|
432
|
+
stopped = page.events.length >= maxEventsPerPage;
|
|
433
|
+
return import_effect.Effect.succeed({ events: page.events, bytes, seen, last: position, full: stopped });
|
|
434
|
+
}
|
|
435
|
+
)
|
|
436
|
+
).pipe(
|
|
437
|
+
import_effect.Effect.map((page) => ({
|
|
438
|
+
events: page.events,
|
|
439
|
+
lastPosition: page.last ?? after ?? { value: 0, offset: 0 }
|
|
440
|
+
}))
|
|
441
|
+
);
|
|
442
|
+
};
|
|
443
|
+
const runsMatching = (filters, newest) => {
|
|
444
|
+
const singleRun = filters.runId !== void 0;
|
|
445
|
+
const ceiling = newest ?? 1;
|
|
446
|
+
const page = (accumulated, seen, cursor) => {
|
|
447
|
+
const remaining = ceiling - accumulated.length;
|
|
448
|
+
return control.list({
|
|
449
|
+
_tag: "runs",
|
|
450
|
+
filters,
|
|
451
|
+
limit: remaining,
|
|
452
|
+
...newest === void 0 ? {} : { order: "newest" },
|
|
453
|
+
...cursor === void 0 ? {} : { cursor }
|
|
454
|
+
}).pipe(
|
|
455
|
+
import_effect.Effect.tapError((cause) => logReadFailure("list-runs", cause)),
|
|
456
|
+
import_effect.Effect.mapError((cause) => unavailable("Listing runs failed", cause)),
|
|
457
|
+
import_effect.Effect.flatMap((response) => {
|
|
458
|
+
if (response._tag !== "runs") return import_effect.Effect.succeed(accumulated);
|
|
459
|
+
const ids = new Set(accumulated.map((run) => run.runId));
|
|
460
|
+
const added = response.items.filter((run) => {
|
|
461
|
+
if (ids.has(run.runId)) return false;
|
|
462
|
+
ids.add(run.runId);
|
|
463
|
+
return true;
|
|
464
|
+
}).slice(0, remaining);
|
|
465
|
+
const runs = [...accumulated, ...added];
|
|
466
|
+
if (singleRun || added.length === 0 || response.nextCursor === void 0 || runs.length >= ceiling || seen.has(response.nextCursor)) return import_effect.Effect.succeed(runs);
|
|
467
|
+
seen.add(response.nextCursor);
|
|
468
|
+
return page(runs, seen, response.nextCursor);
|
|
469
|
+
})
|
|
470
|
+
);
|
|
471
|
+
};
|
|
472
|
+
return import_effect.Effect.suspend(() => page([], /* @__PURE__ */ new Set()));
|
|
473
|
+
};
|
|
474
|
+
const runOf = (runId) => runsMatching({ runId }).pipe(
|
|
475
|
+
import_effect.Effect.flatMap((runs) => {
|
|
476
|
+
const run = runs.find((candidate) => candidate.runId === runId);
|
|
477
|
+
return run === void 0 ? import_effect.Effect.fail(new import_GatewayError.GatewayError({ code: "run_not_found", message: `No run ${runId}` })) : import_effect.Effect.succeed(run);
|
|
478
|
+
})
|
|
479
|
+
);
|
|
480
|
+
const consistentRunSource = (before, attempts = 8, compactHealth = true) => import_effect.Effect.gen(function* () {
|
|
481
|
+
const buffer = yield* eventsOf(before, compactHealth);
|
|
482
|
+
const run = yield* runOf(before.runId);
|
|
483
|
+
if (JSON.stringify(before) === JSON.stringify(run)) return { run, ...buffer };
|
|
484
|
+
if (attempts === 1) return yield* import_effect.Effect.fail(unavailable("Run changed throughout the snapshot read", void 0));
|
|
485
|
+
return yield* consistentRunSource(run, attempts - 1, compactHealth);
|
|
486
|
+
});
|
|
487
|
+
const runSourceOf = (runId, compactHealth = true) => import_effect.Effect.flatMap(runOf(runId), (run) => consistentRunSource(run, 8, compactHealth));
|
|
488
|
+
const durationRunsOf = (flowId) => runsMatching({ flowId, terminal: true }, maxDurationRuns);
|
|
489
|
+
const workspaceSourceOf = (selector) => import_effect.Effect.flatMap(
|
|
490
|
+
// The inbox asks the control plane which runs are parked rather than
|
|
491
|
+
// reading every run's journal to find out, and a duration fold asks it
|
|
492
|
+
// for one flow's runs rather than for the workspace's.
|
|
493
|
+
selector._tag === "flow-durations" ? durationRunsOf(selector.flowId) : runsMatching(
|
|
494
|
+
selector._tag === "approvals" ? { status: "waiting-approval" } : selector._tag === "workspace-runs" && selector.flowId !== void 0 ? { flowId: selector.flowId } : {},
|
|
495
|
+
maxWorkspaceRuns
|
|
496
|
+
),
|
|
497
|
+
(runs) => import_effect.Effect.map(
|
|
498
|
+
import_effect.Effect.forEach(runs, (run) => consistentRunSource(run), { concurrency: 8 }),
|
|
499
|
+
(sources) => sources.filter((source) => eligibleForWorkspace(selector, source))
|
|
500
|
+
)
|
|
501
|
+
);
|
|
502
|
+
const sourceOf = (selector) => {
|
|
503
|
+
const runId = scopeOf(selector);
|
|
504
|
+
return runId === void 0 ? import_effect.Effect.map(workspaceSourceOf(selector), (runs) => ({ _tag: "workspace", runs })) : import_effect.Effect.map(runSourceOf(runId, selector._tag !== "run-events"), (run) => ({ _tag: "run", run }));
|
|
505
|
+
};
|
|
506
|
+
const snapshot = (selector, after) => import_effect.Effect.gen(function* () {
|
|
507
|
+
if (after !== void 0) {
|
|
508
|
+
if (selector._tag !== "run-events") {
|
|
509
|
+
return yield* malformed("Only run-events snapshots accept an after cursor");
|
|
510
|
+
}
|
|
511
|
+
const scope = resumeScope(selector, after);
|
|
512
|
+
if (typeof scope !== "string") return yield* scope;
|
|
513
|
+
}
|
|
514
|
+
if (selector._tag === "run-events") {
|
|
515
|
+
const run = yield* runOf(selector.runId);
|
|
516
|
+
const page = yield* runEventsPage(run, after);
|
|
517
|
+
const rows2 = yield* boundedRows(selector, page.events);
|
|
518
|
+
return yield* snapshotOf({ selector, cursor: cursorOf(selector, page.lastPosition), rows: rows2 });
|
|
519
|
+
}
|
|
520
|
+
const source = yield* sourceOf(selector);
|
|
521
|
+
const rows = yield* boundedRows(selector, rowsOf(selector, source, now()));
|
|
522
|
+
return yield* snapshotOf({ selector, cursor: cursorOf(selector, cursorPositionOf(source)), rows });
|
|
523
|
+
});
|
|
524
|
+
const snapshotFrames = (selector, source, rows) => {
|
|
525
|
+
const cursor = cursorOf(selector, cursorPositionOf(source));
|
|
526
|
+
return import_effect.Effect.forEach([
|
|
527
|
+
{ _tag: "snapshot-start", selector, cursor },
|
|
528
|
+
...rows.map((row) => ({ _tag: "row", selector, cursor, row })),
|
|
529
|
+
{ _tag: "snapshot-end", selector, cursor }
|
|
530
|
+
], frameOf);
|
|
531
|
+
};
|
|
532
|
+
const deltaRows = (selector, run, event, events, turnsBefore, duplicateCall, carry) => {
|
|
533
|
+
if (selector._tag === "run-events") return import_effect.Effect.succeed([event]);
|
|
534
|
+
if (selector._tag === "transcript") {
|
|
535
|
+
return import_effect.Effect.succeed(duplicateCall ? [] : transcriptAppend(event, turnsBefore));
|
|
536
|
+
}
|
|
537
|
+
return import_effect.Effect.succeed(rowsOfRun(selector, { run, events, carry }, now()));
|
|
538
|
+
};
|
|
539
|
+
const runDeltaFrames = (selector, source, from) => {
|
|
540
|
+
const runId = source.run.runId;
|
|
541
|
+
const message = `Following ${runId} failed`;
|
|
542
|
+
const replayHealth = selector._tag === "run-summary" && comparePosition(from, source.lastPosition) < 0;
|
|
543
|
+
const seedEvents = positionedEvents(source.events).filter(({ position }) => comparePosition(position, from) <= 0).map(({ event }) => event);
|
|
544
|
+
const seed = replayHealth ? import_effect.Effect.succeed(emptyEventBuffer(true)) : comparePosition(from, source.lastPosition) === 0 ? import_effect.Effect.succeed({
|
|
545
|
+
compactHealth: source.compactHealth,
|
|
546
|
+
seen: source.seen,
|
|
547
|
+
events: source.events,
|
|
548
|
+
encodedBytes: source.encodedBytes,
|
|
549
|
+
lastPosition: source.lastPosition,
|
|
550
|
+
carry: source.carry,
|
|
551
|
+
dropped: source.dropped
|
|
552
|
+
}) : bufferOf(seedEvents, `${message}: the cursor seed is invalid`, source.compactHealth, source.run);
|
|
553
|
+
return import_effect.Stream.unwrap(import_effect.Effect.map(seed, (initial) => control.watch({
|
|
554
|
+
runId,
|
|
555
|
+
// Sequence zero also needs replay for empty seeds and derived offsets.
|
|
556
|
+
...from.value === 0 || replayHealth ? {} : { afterSequence: from.value - 1 },
|
|
557
|
+
follow: true
|
|
558
|
+
}).pipe(
|
|
559
|
+
import_effect.Stream.tapError((cause) => logReadFailure("follow-run", cause)),
|
|
560
|
+
import_effect.Stream.mapError((cause) => unavailable(message, cause)),
|
|
561
|
+
import_effect.Stream.mapAccumEffect(
|
|
562
|
+
() => ({
|
|
563
|
+
buffer: initial,
|
|
564
|
+
observed: void 0,
|
|
565
|
+
turns: selector._tag === "transcript" ? turnsOpened(initial.events) : 0,
|
|
566
|
+
reportedCalls: (() => {
|
|
567
|
+
const seen = /* @__PURE__ */ new Map();
|
|
568
|
+
if (selector._tag === "transcript") {
|
|
569
|
+
for (const event of initial.events) {
|
|
570
|
+
const key = (0, import_callEvents.callEventKey)(event);
|
|
571
|
+
if (key !== void 0) {
|
|
572
|
+
seen.set(
|
|
573
|
+
key,
|
|
574
|
+
seen.get(key) === true || ((0, import_callEvents.nativeCallEvent)(event) ?? (0, import_callEvents.nativeStepEvent)(event)) !== void 0
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
return seen;
|
|
580
|
+
})()
|
|
581
|
+
}),
|
|
582
|
+
(state, candidate) => import_effect.Effect.flatMap(
|
|
583
|
+
decodedEvent(candidate, `${message}: the control plane returned an invalid event`),
|
|
584
|
+
(event) => {
|
|
585
|
+
if (state.observed !== void 0 && event.sequence < state.observed.value) {
|
|
586
|
+
return import_effect.Effect.fail(unavailable(`${message}: event sequences moved backward`, void 0));
|
|
587
|
+
}
|
|
588
|
+
const position = {
|
|
589
|
+
value: event.sequence,
|
|
590
|
+
offset: state.observed?.value === event.sequence ? state.observed.offset + 1 : 0
|
|
591
|
+
};
|
|
592
|
+
const nextState = { ...state, observed: position };
|
|
593
|
+
if ((replayHealth || seedEvents.length > 0 || from.value > 0 || from.offset > 0) && comparePosition(position, from) <= 0) {
|
|
594
|
+
return replayHealth ? import_effect.Effect.map(
|
|
595
|
+
appendEvent(state.buffer, event, `${message}: cursor history is invalid`, source.run),
|
|
596
|
+
(buffer) => [{ ...nextState, buffer }, []]
|
|
597
|
+
) : import_effect.Effect.succeed([nextState, []]);
|
|
598
|
+
}
|
|
599
|
+
const turnsBefore = state.turns;
|
|
600
|
+
const callKey = selector._tag === "transcript" ? (0, import_callEvents.callEventKey)(event) : void 0;
|
|
601
|
+
const duplicateCall = callKey !== void 0 && state.reportedCalls.has(callKey);
|
|
602
|
+
const authoritative = ((0, import_callEvents.nativeCallEvent)(event) ?? (0, import_callEvents.nativeStepEvent)(event)) !== void 0;
|
|
603
|
+
const replaceTranscript = duplicateCall && authoritative && state.reportedCalls.get(callKey) === false;
|
|
604
|
+
if (callKey !== void 0) {
|
|
605
|
+
state.reportedCalls.set(callKey, authoritative || state.reportedCalls.get(callKey) === true);
|
|
606
|
+
}
|
|
607
|
+
const turns = selector._tag === "transcript" ? transcriptAppend(event, turnsBefore).at(-1)?.turn ?? turnsBefore : 0;
|
|
608
|
+
return import_effect.Effect.flatMap(
|
|
609
|
+
selector._tag === "run-summary" || selector._tag === "run-tree" || selector._tag === "approvals" ? runOf(runId) : import_effect.Effect.succeed(source.run),
|
|
610
|
+
(run) => import_effect.Effect.map(
|
|
611
|
+
appendEvent(state.buffer, event, `${message}: event history is invalid`, run),
|
|
612
|
+
(buffer) => [
|
|
613
|
+
{
|
|
614
|
+
buffer,
|
|
615
|
+
observed: position,
|
|
616
|
+
turns,
|
|
617
|
+
reportedCalls: state.reportedCalls
|
|
618
|
+
},
|
|
619
|
+
[
|
|
620
|
+
{
|
|
621
|
+
run,
|
|
622
|
+
event,
|
|
623
|
+
events: buffer.events,
|
|
624
|
+
carry: buffer.carry,
|
|
625
|
+
position,
|
|
626
|
+
turnsBefore,
|
|
627
|
+
duplicateCall,
|
|
628
|
+
replaceTranscript
|
|
629
|
+
}
|
|
630
|
+
]
|
|
631
|
+
]
|
|
632
|
+
)
|
|
633
|
+
);
|
|
634
|
+
}
|
|
635
|
+
)
|
|
636
|
+
),
|
|
637
|
+
import_effect.Stream.mapEffect(
|
|
638
|
+
({ carry, duplicateCall, event, events, position, replaceTranscript, run, turnsBefore }) => replaceTranscript ? import_effect.Effect.flatMap(boundedRows(selector, GatewayProjection.transcript(events)), (rows) => import_effect.Effect.forEach([
|
|
639
|
+
{ _tag: "snapshot-start", selector, cursor: cursorOf(selector, position) },
|
|
640
|
+
...rows.map((row) => ({ _tag: "row", selector, cursor: cursorOf(selector, position), row })),
|
|
641
|
+
{ _tag: "snapshot-end", selector, cursor: cursorOf(selector, position) }
|
|
642
|
+
], frameOf)) : import_effect.Effect.flatMap(deltaRows(selector, run, event, events, turnsBefore, duplicateCall, carry), (rows) => import_effect.Effect.flatMap(boundedRows(selector, rows), (delta) => import_effect.Effect.map(
|
|
643
|
+
frameOf({
|
|
644
|
+
_tag: "delta",
|
|
645
|
+
selector,
|
|
646
|
+
cursor: cursorOf(selector, position),
|
|
647
|
+
delta
|
|
648
|
+
}),
|
|
649
|
+
(frame) => [frame]
|
|
650
|
+
)))
|
|
651
|
+
),
|
|
652
|
+
import_effect.Stream.flattenIterable
|
|
653
|
+
)));
|
|
654
|
+
};
|
|
655
|
+
const workspaceDeltaFrames = (selector, runs) => import_effect.Stream.unwrap(import_effect.Effect.sync(() => {
|
|
656
|
+
const rowsOfSource = (source) => selector._tag === "approvals" ? pendingApprovals(source) : rowsOfRun(selector, source, now());
|
|
657
|
+
const sources = new Map(runs.map((source) => [
|
|
658
|
+
source.run.runId,
|
|
659
|
+
{ source, observed: void 0, rows: rowsOfSource(source) }
|
|
660
|
+
]));
|
|
661
|
+
const judged = /* @__PURE__ */ new Map();
|
|
662
|
+
const makeRoom = () => {
|
|
663
|
+
if (sources.size + judged.size >= maxWorkspaceRuns) {
|
|
664
|
+
judged.delete(judged.keys().next().value);
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
const remember = (runId, lastPosition, observed) => {
|
|
668
|
+
judged.delete(runId);
|
|
669
|
+
makeRoom();
|
|
670
|
+
judged.set(runId, { lastPosition, observed });
|
|
671
|
+
};
|
|
672
|
+
const oldestFollowed = () => {
|
|
673
|
+
let oldest;
|
|
674
|
+
for (const followed of sources.values()) {
|
|
675
|
+
if (oldest === void 0 || createdAfter(oldest.source.run, followed.source.run)) oldest = followed;
|
|
676
|
+
}
|
|
677
|
+
return oldest;
|
|
678
|
+
};
|
|
679
|
+
const noFrames = [];
|
|
680
|
+
const delta = () => import_effect.Effect.flatMap(
|
|
681
|
+
boundedRows(
|
|
682
|
+
selector,
|
|
683
|
+
selector._tag === "approvals" ? approvalInbox([...sources.values()].map(({ rows, source }) => ({ run: source.run, rows }))) : [...sources.values()].flatMap(({ rows }) => rows)
|
|
684
|
+
),
|
|
685
|
+
(rows) => import_effect.Effect.map(
|
|
686
|
+
frameOf({
|
|
687
|
+
_tag: "delta",
|
|
688
|
+
selector,
|
|
689
|
+
cursor: cursorOf(selector, { value: 0, offset: 0 }),
|
|
690
|
+
delta: rows
|
|
691
|
+
}),
|
|
692
|
+
(frame) => [frame]
|
|
693
|
+
)
|
|
694
|
+
);
|
|
695
|
+
const message = "Following the workspace failed";
|
|
696
|
+
const admit = (event, refreshed) => import_effect.Effect.gen(function* () {
|
|
697
|
+
const runId = event.runId;
|
|
698
|
+
if (runId === void 0) return "unchanged";
|
|
699
|
+
const current = sources.get(runId);
|
|
700
|
+
const verdict = judged.get(runId);
|
|
701
|
+
const previous = current?.observed ?? verdict?.observed;
|
|
702
|
+
if (previous !== void 0 && event.sequence < previous.value) {
|
|
703
|
+
return yield* import_effect.Effect.fail(unavailable(`${message}: event sequences moved backward`, void 0));
|
|
704
|
+
}
|
|
705
|
+
const position = {
|
|
706
|
+
value: event.sequence,
|
|
707
|
+
offset: previous?.value === event.sequence ? previous.offset + 1 : 0
|
|
708
|
+
};
|
|
709
|
+
if (current !== void 0) {
|
|
710
|
+
current.observed = position;
|
|
711
|
+
if (current.source.events.length > 0 && comparePosition(position, current.source.lastPosition) <= 0) return "unchanged";
|
|
712
|
+
if (!refreshed.has(runId)) {
|
|
713
|
+
current.source = { ...current.source, run: yield* runOf(runId) };
|
|
714
|
+
refreshed.add(runId);
|
|
715
|
+
}
|
|
716
|
+
const buffer = yield* appendEvent(
|
|
717
|
+
current.source,
|
|
718
|
+
event,
|
|
719
|
+
`${message}: event history is invalid`,
|
|
720
|
+
current.source.run
|
|
721
|
+
);
|
|
722
|
+
current.source = { run: current.source.run, ...buffer };
|
|
723
|
+
return "stale";
|
|
724
|
+
}
|
|
725
|
+
if (verdict !== void 0) {
|
|
726
|
+
verdict.observed = position;
|
|
727
|
+
if (verdict.lastPosition === void 0 || comparePosition(position, verdict.lastPosition) <= 0) {
|
|
728
|
+
return "unchanged";
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
const displaced = sources.size >= maxWorkspaceRuns ? oldestFollowed() : void 0;
|
|
732
|
+
if (displaced !== void 0) {
|
|
733
|
+
const newer = yield* runOf(runId).pipe(
|
|
734
|
+
import_effect.Effect.map((run) => createdAfter(run, displaced.source.run)),
|
|
735
|
+
import_effect.Effect.catchIf((failure) => failure.code === "run_not_found", () => import_effect.Effect.succeed(false))
|
|
736
|
+
);
|
|
737
|
+
if (!newer) return "unchanged";
|
|
738
|
+
}
|
|
739
|
+
return yield* runSourceOf(runId).pipe(
|
|
740
|
+
import_effect.Effect.flatMap((source) => {
|
|
741
|
+
const admitted = source.events.length > 0 && comparePosition(position, source.lastPosition) <= 0 ? import_effect.Effect.succeed(source) : import_effect.Effect.map(
|
|
742
|
+
appendEvent(source, event, `${message}: event history is invalid`, source.run),
|
|
743
|
+
(buffer) => ({ run: source.run, ...buffer })
|
|
744
|
+
);
|
|
745
|
+
return import_effect.Effect.map(admitted, (complete) => {
|
|
746
|
+
if (!eligibleForWorkspace(selector, complete)) {
|
|
747
|
+
remember(runId, complete.lastPosition, position);
|
|
748
|
+
return "unchanged";
|
|
749
|
+
}
|
|
750
|
+
judged.delete(runId);
|
|
751
|
+
if (displaced !== void 0 && sources.size >= maxWorkspaceRuns) {
|
|
752
|
+
sources.delete(displaced.source.run.runId);
|
|
753
|
+
}
|
|
754
|
+
makeRoom();
|
|
755
|
+
sources.set(runId, { source: complete, observed: position, rows: rowsOfSource(complete) });
|
|
756
|
+
return "fresh";
|
|
757
|
+
});
|
|
758
|
+
}),
|
|
759
|
+
import_effect.Effect.catchIf(
|
|
760
|
+
(failure) => failure.code === "run_not_found",
|
|
761
|
+
() => {
|
|
762
|
+
remember(runId, void 0, position);
|
|
763
|
+
return import_effect.Effect.succeed("unchanged");
|
|
764
|
+
}
|
|
765
|
+
)
|
|
766
|
+
);
|
|
767
|
+
});
|
|
768
|
+
const refresh = (runId) => import_effect.Effect.gen(function* () {
|
|
769
|
+
const current = sources.get(runId);
|
|
770
|
+
if (current === void 0 || current.observed === void 0) return;
|
|
771
|
+
const source = current.source;
|
|
772
|
+
if (eligibleForWorkspace(selector, source)) {
|
|
773
|
+
current.rows = rowsOfSource(source);
|
|
774
|
+
} else {
|
|
775
|
+
sources.delete(runId);
|
|
776
|
+
remember(runId, source.lastPosition, current.observed);
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
return control.watch({ follow: true }).pipe(
|
|
780
|
+
import_effect.Stream.tapError((cause) => logReadFailure("follow-workspace", cause)),
|
|
781
|
+
import_effect.Stream.mapError((cause) => unavailable(message, cause)),
|
|
782
|
+
import_effect.Stream.groupedWithin(workspaceDeltaBatchSize, workspaceDeltaCoalesceMillis),
|
|
783
|
+
import_effect.Stream.mapEffect(
|
|
784
|
+
(batch) => import_effect.Effect.gen(function* () {
|
|
785
|
+
const stale = /* @__PURE__ */ new Set();
|
|
786
|
+
const refreshed = /* @__PURE__ */ new Set();
|
|
787
|
+
let changed = false;
|
|
788
|
+
for (const candidate of batch) {
|
|
789
|
+
const event = yield* decodedEvent(candidate, `${message}: the control plane returned an invalid event`);
|
|
790
|
+
const admission = yield* admit(event, refreshed);
|
|
791
|
+
if (admission === "unchanged") continue;
|
|
792
|
+
changed = true;
|
|
793
|
+
if (admission === "stale" && event.runId !== void 0) stale.add(event.runId);
|
|
794
|
+
}
|
|
795
|
+
yield* import_effect.Effect.forEach(stale, refresh, { discard: true });
|
|
796
|
+
return changed ? yield* delta() : noFrames;
|
|
797
|
+
})
|
|
798
|
+
),
|
|
799
|
+
import_effect.Stream.flattenIterable
|
|
800
|
+
);
|
|
801
|
+
}));
|
|
802
|
+
const deltaFrames = (selector, source, from) => {
|
|
803
|
+
if (selector._tag === "flow-durations") return import_effect.Stream.empty;
|
|
804
|
+
return source._tag === "workspace" ? workspaceDeltaFrames(selector, source.runs) : runDeltaFrames(selector, source.run, from);
|
|
805
|
+
};
|
|
806
|
+
const heartbeats = import_effect.Stream.tick(heartbeatMillis).pipe(
|
|
807
|
+
import_effect.Stream.drop(1),
|
|
808
|
+
import_effect.Stream.mapEffect(
|
|
809
|
+
() => import_effect.Effect.map(import_effect.Effect.clockWith((clock) => clock.currentTimeMillis), (atMs) => ({
|
|
810
|
+
_tag: "heartbeat",
|
|
811
|
+
atMs
|
|
812
|
+
}))
|
|
813
|
+
)
|
|
814
|
+
);
|
|
815
|
+
const resumeScope = (selector, after) => {
|
|
816
|
+
const candidate = after;
|
|
817
|
+
if (!Number.isSafeInteger(candidate.value) || candidate.value < 0) {
|
|
818
|
+
return malformed(
|
|
819
|
+
`Cursor value ${String(candidate.value)} must be a non-negative safe integer`
|
|
820
|
+
);
|
|
821
|
+
}
|
|
822
|
+
if (!Number.isSafeInteger(candidate.offset) || candidate.offset < 0) {
|
|
823
|
+
return malformed(
|
|
824
|
+
`Cursor offset ${String(candidate.offset)} must be a non-negative safe integer`
|
|
825
|
+
);
|
|
826
|
+
}
|
|
827
|
+
if (!import_effect.Schema.is(GatewaySchema.ProjectionCursor)(after)) {
|
|
828
|
+
return malformed("The projection cursor is not a valid gateway cursor");
|
|
829
|
+
}
|
|
830
|
+
const runId = scopeOf(selector);
|
|
831
|
+
if (after.projection !== selector._tag) {
|
|
832
|
+
return malformed(
|
|
833
|
+
`A cursor for the ${after.projection} projection cannot resume a ${selector._tag} subscription`
|
|
834
|
+
);
|
|
835
|
+
}
|
|
836
|
+
if (!sameSelector(after.selector, selector)) {
|
|
837
|
+
return malformed("A cursor can resume only the exact selector that issued it");
|
|
838
|
+
}
|
|
839
|
+
if (runId === void 0) {
|
|
840
|
+
return malformed(
|
|
841
|
+
`A ${selector._tag} subscription has no resumable cursor, because control journal sequences belong to per-run partitions`
|
|
842
|
+
);
|
|
843
|
+
}
|
|
844
|
+
if (after.runId !== runId) {
|
|
845
|
+
return malformed(`A cursor for run ${after.runId ?? "none"} cannot resume a subscription to run ${runId}`);
|
|
846
|
+
}
|
|
847
|
+
return runId;
|
|
848
|
+
};
|
|
849
|
+
const fromSnapshot = (selector) => import_effect.Effect.flatMap(
|
|
850
|
+
sourceOf(selector),
|
|
851
|
+
(source) => import_effect.Effect.flatMap(boundedRows(selector, rowsOf(selector, source, now())), (rows) => import_effect.Effect.map(snapshotFrames(selector, source, rows), (frames) => import_effect.Stream.concat(
|
|
852
|
+
import_effect.Stream.fromIterable(frames),
|
|
853
|
+
deltaFrames(selector, source, cursorPositionOf(source))
|
|
854
|
+
)))
|
|
855
|
+
);
|
|
856
|
+
const fromCursor = (selector, after) => {
|
|
857
|
+
const scope = resumeScope(selector, after);
|
|
858
|
+
return typeof scope === "string" ? import_effect.Effect.flatMap(runSourceOf(scope, selector._tag !== "run-events"), (source) => {
|
|
859
|
+
const position = { value: after.value, offset: after.offset };
|
|
860
|
+
const last = source.lastPosition;
|
|
861
|
+
if (comparePosition(position, last) > 0) {
|
|
862
|
+
return import_effect.Effect.fail(malformed(
|
|
863
|
+
`Cursor ${after.value}:${after.offset} cannot resume run ${scope} past its last position ${last.value}:${last.offset}`
|
|
864
|
+
));
|
|
865
|
+
}
|
|
866
|
+
const retained = position.value === 0 && position.offset === 0 || positionedEvents(source.events).some((candidate) => comparePosition(candidate.position, position) === 0);
|
|
867
|
+
const issued = retained ? import_effect.Effect.succeed(true) : source.compactHealth ? control.watch({
|
|
868
|
+
runId: scope,
|
|
869
|
+
follow: false,
|
|
870
|
+
...position.value === 0 ? {} : { afterSequence: position.value - 1 }
|
|
871
|
+
}).pipe(
|
|
872
|
+
import_effect.Stream.takeWhile((event) => event.sequence <= position.value),
|
|
873
|
+
import_effect.Stream.take(maxEventsPerRun + 1),
|
|
874
|
+
import_effect.Stream.runCollect,
|
|
875
|
+
import_effect.Effect.map(
|
|
876
|
+
(events) => events.length <= maxEventsPerRun && events[position.offset]?.sequence === position.value
|
|
877
|
+
),
|
|
878
|
+
import_effect.Effect.mapError((cause) => unavailable("Checking the projection cursor failed", cause))
|
|
879
|
+
) : import_effect.Effect.succeed(false);
|
|
880
|
+
return import_effect.Effect.flatMap(issued, (valid) => valid ? import_effect.Effect.succeed(runDeltaFrames(selector, source, position)) : import_effect.Effect.fail(malformed(`Cursor ${after.value}:${after.offset} was not issued by run ${scope}`)));
|
|
881
|
+
}) : import_effect.Effect.fail(scope);
|
|
882
|
+
};
|
|
883
|
+
const subscribe = (selector, after) => import_effect.Stream.merge(
|
|
884
|
+
import_effect.Stream.unwrap(after === void 0 ? fromSnapshot(selector) : fromCursor(selector, after)),
|
|
885
|
+
heartbeats,
|
|
886
|
+
{ haltStrategy: "left" }
|
|
887
|
+
);
|
|
888
|
+
return { snapshot, subscribe };
|
|
889
|
+
};
|
|
890
|
+
const make = (control, options = {}) => import_effect.Effect.suspend(() => {
|
|
891
|
+
const refusal = (0, import_GatewayError.settingRefusal)("The gateway keepalive cadence", options.heartbeatMillis);
|
|
892
|
+
return refusal === void 0 ? import_effect.Effect.clockWith(
|
|
893
|
+
(clock) => import_effect.Effect.succeed(
|
|
894
|
+
makeService(
|
|
895
|
+
control,
|
|
896
|
+
options.heartbeatMillis ?? heartbeatIntervalMillis,
|
|
897
|
+
() => clock.currentTimeMillisUnsafe()
|
|
898
|
+
)
|
|
899
|
+
)
|
|
900
|
+
) : import_effect.Effect.fail(refusal);
|
|
901
|
+
});
|
|
902
|
+
const layer = import_effect.Layer.effect(Projections)(
|
|
903
|
+
import_effect.Effect.flatMap(import_Control.Control, (control) => make(control))
|
|
904
|
+
);
|
|
905
|
+
const layerWith = (options) => import_effect.Layer.effect(Projections)(import_effect.Effect.flatMap(import_Control.Control, (control) => make(control, options)));
|
|
906
|
+
//# sourceMappingURL=Projections.js.map
|