@smthrs/gateway 1.0.0-rc.5 → 1.0.0-rc.7
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 +3 -3
- package/dist/cjs/GatewayRpcs.d.ts +2 -2
- package/dist/cjs/GatewayRpcs.d.ts.map +1 -1
- package/dist/cjs/GatewayRpcs.js +1 -1
- package/dist/cjs/GatewayRpcs.js.map +1 -1
- package/dist/cjs/GatewayServer.d.ts +4 -4
- package/dist/cjs/GatewayServer.d.ts.map +1 -1
- package/dist/cjs/GatewayServer.js +2 -2
- package/dist/cjs/GatewayServer.js.map +1 -1
- package/dist/cjs/HostBranchPresence.d.ts +2 -2
- package/dist/cjs/HostBranchPresence.d.ts.map +1 -1
- package/dist/cjs/HostBranchPresence.js +1 -1
- package/dist/cjs/HostBranchPresence.js.map +1 -1
- package/dist/cjs/RunTrace.d.ts +2 -2
- package/dist/cjs/RuntimeBridge.d.ts +5 -5
- package/dist/cjs/RuntimeBridge.d.ts.map +1 -1
- package/dist/cjs/RuntimeBridge.js +1 -1
- package/dist/cjs/RuntimeBridge.js.map +1 -1
- package/dist/cjs/bun/BunGateway.d.ts +1 -1
- package/dist/cjs/bun/BunGateway.d.ts.map +1 -1
- package/dist/cjs/bun/BunGateway.js.map +1 -1
- package/dist/cjs/internal/NativeGateway.d.ts +2 -2
- package/dist/cjs/internal/NativeGateway.d.ts.map +1 -1
- package/dist/cjs/internal/NativeGateway.js +2 -2
- package/dist/cjs/internal/NativeGateway.js.map +1 -1
- package/dist/cjs/node/NodeGateway.d.ts +1 -1
- package/dist/cjs/node/NodeGateway.d.ts.map +1 -1
- package/dist/esm/GatewayRpcs.d.ts +2 -2
- package/dist/esm/GatewayRpcs.d.ts.map +1 -1
- package/dist/esm/GatewayRpcs.js +1 -1
- package/dist/esm/GatewayRpcs.js.map +1 -1
- package/dist/esm/GatewayServer.d.ts +4 -4
- package/dist/esm/GatewayServer.d.ts.map +1 -1
- package/dist/esm/GatewayServer.js +3 -3
- package/dist/esm/GatewayServer.js.map +1 -1
- package/dist/esm/HostBranchPresence.d.ts +2 -2
- package/dist/esm/HostBranchPresence.d.ts.map +1 -1
- package/dist/esm/HostBranchPresence.js +1 -1
- package/dist/esm/HostBranchPresence.js.map +1 -1
- package/dist/esm/RunTrace.d.ts +2 -2
- package/dist/esm/RuntimeBridge.d.ts +5 -5
- package/dist/esm/RuntimeBridge.d.ts.map +1 -1
- package/dist/esm/RuntimeBridge.js +1 -1
- package/dist/esm/RuntimeBridge.js.map +1 -1
- package/dist/esm/bun/BunGateway.d.ts +1 -1
- package/dist/esm/bun/BunGateway.d.ts.map +1 -1
- package/dist/esm/bun/BunGateway.js.map +1 -1
- package/dist/esm/internal/NativeGateway.d.ts +2 -2
- package/dist/esm/internal/NativeGateway.d.ts.map +1 -1
- package/dist/esm/internal/NativeGateway.js +2 -2
- package/dist/esm/internal/NativeGateway.js.map +1 -1
- package/dist/esm/node/NodeGateway.d.ts +1 -1
- package/dist/esm/node/NodeGateway.d.ts.map +1 -1
- package/dist/vendor/adapters.json +952 -592
- package/dist/vendor/bun/BunAddressResolver.d.ts +15 -0
- package/dist/vendor/bun/BunAddressResolver.js +8 -0
- package/dist/vendor/bun/BunChildProcessSpawner.d.ts +1 -0
- package/dist/vendor/bun/BunChildProcessSpawner.js +6 -6
- package/dist/vendor/bun/BunClusterHttp.d.ts +13 -20
- package/dist/vendor/bun/BunClusterHttp.js +28 -28
- package/dist/vendor/bun/BunClusterSocket.d.ts +13 -8
- package/dist/vendor/bun/BunClusterSocket.js +9 -9
- package/dist/vendor/bun/BunCrypto.d.ts +1 -0
- package/dist/vendor/bun/BunCrypto.js +2 -2
- package/dist/vendor/bun/BunDatagramSocket.d.ts +227 -0
- package/dist/vendor/bun/BunDatagramSocket.js +11 -0
- package/dist/vendor/bun/BunDns.d.ts +72 -0
- package/dist/vendor/bun/BunDns.js +12 -0
- package/dist/vendor/bun/BunFileSystem.d.ts +1 -0
- package/dist/vendor/bun/BunFileSystem.js +3 -3
- package/dist/vendor/bun/BunHttpClient.d.ts +2 -1
- package/dist/vendor/bun/BunHttpClient.js +1 -1
- package/dist/vendor/bun/BunHttpPlatform.d.ts +2 -1
- package/dist/vendor/bun/BunHttpPlatform.js +5 -5
- package/dist/vendor/bun/BunHttpServer.d.ts +19 -10
- package/dist/vendor/bun/BunHttpServer.js +22 -22
- package/dist/vendor/bun/BunHttpServerRequest.d.ts +3 -1
- package/dist/vendor/bun/BunHttpServerRequest.js +1 -1
- package/dist/vendor/bun/BunMultipart.d.ts +4 -1
- package/dist/vendor/bun/BunMultipart.js +4 -4
- package/dist/vendor/bun/BunPath.d.ts +3 -0
- package/dist/vendor/bun/BunPath.js +2 -2
- package/dist/vendor/bun/BunRedis.d.ts +5 -1
- package/dist/vendor/bun/BunRedis.js +1 -1
- package/dist/vendor/bun/BunRuntime.d.ts +3 -0
- package/dist/vendor/bun/BunRuntime.js +2 -2
- package/dist/vendor/bun/BunServices.d.ts +4 -1
- package/dist/vendor/bun/BunServices.js +17 -17
- package/dist/vendor/bun/BunSink.d.ts +1 -0
- package/dist/vendor/bun/BunSink.js +2 -2
- package/dist/vendor/bun/BunSocket.d.ts +8 -3
- package/dist/vendor/bun/BunSocket.js +2 -2
- package/dist/vendor/bun/BunSocketServer.d.ts +1 -0
- package/dist/vendor/bun/BunSocketServer.js +3 -3
- package/dist/vendor/bun/BunStdio.d.ts +1 -0
- package/dist/vendor/bun/BunStdio.js +4 -4
- package/dist/vendor/bun/BunStream.d.ts +1 -0
- package/dist/vendor/bun/BunStream.js +3 -3
- package/dist/vendor/bun/BunTerminal.d.ts +6 -3
- package/dist/vendor/bun/BunTerminal.js +2 -2
- package/dist/vendor/bun/BunWorker.d.ts +3 -1
- package/dist/vendor/bun/BunWorker.js +1 -1
- package/dist/vendor/bun/BunWorkerRunner.d.ts +2 -1
- package/dist/vendor/bun/BunWorkerRunner.js +1 -1
- package/dist/vendor/bun/index.d.ts +38 -0
- package/dist/vendor/bun/index.js +63 -49
- package/dist/vendor/{chunk-GUPAV2YZ.js → chunk-27M5LSUN.js} +2 -2
- package/dist/vendor/{chunk-DZ2VOUDP.js → chunk-2BVPPQ3J.js} +27 -11
- package/dist/vendor/chunk-2IQO24DU.js +16 -0
- package/dist/vendor/{chunk-TFY7W6D4.js → chunk-2LNNNJEL.js} +1 -1
- package/dist/vendor/{chunk-ML2NAFH2.js → chunk-3VK56BXN.js} +5 -5
- package/dist/vendor/{chunk-HAEDVSSM.js → chunk-4FOGEXGP.js} +2 -2
- package/dist/vendor/{chunk-UHIDPUFF.js → chunk-4UBVC7DT.js} +7 -7
- package/dist/vendor/{chunk-QR557K66.js → chunk-6J5FUCQH.js} +2 -2
- package/dist/vendor/{chunk-2GCOZTTW.js → chunk-6PBGSFGC.js} +1 -1
- package/dist/vendor/{chunk-FUTCTCEG.js → chunk-6U5YBCZP.js} +2 -2
- package/dist/vendor/chunk-7GAMKC3O.js +374 -0
- package/dist/vendor/{chunk-XJWJXLXJ.js → chunk-A6MHC464.js} +2 -2
- package/dist/vendor/{chunk-V6LUGQ7O.js → chunk-AAGA43L5.js} +1 -1
- package/dist/vendor/chunk-AT3UQX35.js +43 -0
- package/dist/vendor/{chunk-HY7BBL3K.js → chunk-AXYO3S5F.js} +2 -2
- package/dist/vendor/chunk-BJ4Y76WR.js +20 -0
- package/dist/vendor/{chunk-WAII54GA.js → chunk-BKI6NSFH.js} +2 -2
- package/dist/vendor/{chunk-37CUR3PO.js → chunk-BMWOIEKS.js} +1 -1
- package/dist/vendor/{chunk-ZCHYLHJH.js → chunk-C3AAHJPG.js} +3 -4
- package/dist/vendor/{chunk-6C5H7S6B.js → chunk-C72RDTZK.js} +2 -2
- package/dist/vendor/{chunk-WECQDT36.js → chunk-CV6NGU7M.js} +12 -12
- package/dist/vendor/{chunk-XFEVTDVD.js → chunk-DIMYYXEQ.js} +2 -2
- package/dist/vendor/{chunk-TOHSFXMV.js → chunk-DK6W7NVZ.js} +71 -7
- package/dist/vendor/{chunk-DX4Z23DM.js → chunk-DKXPJGDE.js} +18 -18
- package/dist/vendor/{chunk-CES4OUM4.js → chunk-DLDCBZD5.js} +3 -3
- package/dist/vendor/{chunk-IFTTT6D5.js → chunk-EE65FWNU.js} +3 -3
- package/dist/vendor/{chunk-ULT6CWUI.js → chunk-ELNCZJWI.js} +2 -2
- package/dist/vendor/{chunk-BCK3NJOX.js → chunk-EUPZ62KV.js} +1 -1
- package/dist/vendor/chunk-F4CN7CQO.js +7 -0
- package/dist/vendor/{chunk-62R63L74.js → chunk-FI5AQ7TR.js} +17 -17
- package/dist/vendor/{chunk-3ARKKENZ.js → chunk-FUJO3TFS.js} +14 -8
- package/dist/vendor/{chunk-W4OASVX6.js → chunk-G6OHXUVC.js} +8 -7
- package/dist/vendor/{chunk-R4QUY7DH.js → chunk-GOLFR2OS.js} +2 -2
- package/dist/vendor/chunk-HYTFIYW5.js +16 -0
- package/dist/vendor/{chunk-Z7QPP4YH.js → chunk-IKEQPAB4.js} +2 -2
- package/dist/vendor/{chunk-H2Z2Y4QH.js → chunk-IPEZUWHG.js} +2 -2
- package/dist/vendor/{chunk-B4DHEMBB.js → chunk-JHJ5EULK.js} +1 -1
- package/dist/vendor/{chunk-TGXCX6W3.js → chunk-JOPLNUAM.js} +49 -29
- package/dist/vendor/{chunk-WVFOZ2UL.js → chunk-JTB5K4OJ.js} +1 -1
- package/dist/vendor/chunk-KE46F25E.js +274 -0
- package/dist/vendor/{chunk-Z6C7SO5Z.js → chunk-KQ6RGFAV.js} +34 -26
- package/dist/vendor/{chunk-6AQLBC2I.js → chunk-LR4CP5LM.js} +3 -3
- package/dist/vendor/chunk-LWMUYYMV.js +20 -0
- package/dist/vendor/{chunk-TGPIVY4A.js → chunk-MAY4VFMX.js} +3 -3
- package/dist/vendor/{chunk-XFZZYSJ4.js → chunk-MBWXCLXM.js} +2 -2
- package/dist/vendor/{chunk-RGECXXJS.js → chunk-MIICUBHU.js} +2 -2
- package/dist/vendor/{chunk-FPQF7CR5.js → chunk-NA54IH45.js} +11 -4
- package/dist/vendor/{chunk-XCYARUII.js → chunk-NLVEVV4N.js} +15 -15
- package/dist/vendor/{chunk-YDASSC75.js → chunk-OACTGVO3.js} +53 -33
- package/dist/vendor/{chunk-AVVVN75Z.js → chunk-OSTTDQDL.js} +55 -23
- package/dist/vendor/{chunk-XY3Q62EO.js → chunk-OTF7TIUT.js} +2 -2
- package/dist/vendor/{chunk-6UPBD47P.js → chunk-OUHKGVUY.js} +8 -8
- package/dist/vendor/{chunk-WHKMOC7Z.js → chunk-PFMOUFES.js} +2 -2
- package/dist/vendor/{chunk-OBWXQKVP.js → chunk-QSW2OXDQ.js} +6 -6
- package/dist/vendor/{chunk-UXBGYQR3.js → chunk-RGXARIVL.js} +2 -2
- package/dist/vendor/{chunk-3OSW7CT7.js → chunk-S2FQHQEN.js} +3 -2
- package/dist/vendor/{chunk-ZPIG2CUA.js → chunk-SIAD6ZM3.js} +9 -9
- package/dist/vendor/{chunk-X73E2UPI.js → chunk-SIHCCQG3.js} +2 -2
- package/dist/vendor/{chunk-LKCGQEE5.js → chunk-T2MZLWMC.js} +2 -2
- package/dist/vendor/chunk-TCB7NCNI.js +29 -0
- package/dist/vendor/{chunk-6DY5RBZD.js → chunk-TEBSASCB.js} +3 -3
- package/dist/vendor/{chunk-D64L6YND.js → chunk-THCEOHBC.js} +4 -3
- package/dist/vendor/{chunk-LIHLXXGQ.js → chunk-UFGZQOJD.js} +2 -2
- package/dist/vendor/{chunk-Z7QNPJEB.js → chunk-UFMF5EGC.js} +5 -5
- package/dist/vendor/{chunk-DS2R6WOM.js → chunk-VORW6EXI.js} +2 -2
- package/dist/vendor/{chunk-FOXN6JPJ.js → chunk-VRI5O4IJ.js} +1 -1
- package/dist/vendor/{chunk-KQDSNB7M.js → chunk-VRUFVTUD.js} +2 -2
- package/dist/vendor/{chunk-ZIQVYVMA.js → chunk-VYDIFBN4.js} +2 -2
- package/dist/vendor/chunk-WVSQBGVT.js +325 -0
- package/dist/vendor/{chunk-MSCLEMYX.js → chunk-ZMIMYPAY.js} +17 -17
- package/dist/vendor/cjs/bun/BunAddressResolver.d.ts +15 -0
- package/dist/vendor/cjs/bun/BunAddressResolver.js +1 -0
- package/dist/vendor/cjs/bun/BunChildProcessSpawner.d.ts +1 -0
- package/dist/vendor/cjs/bun/BunClusterHttp.d.ts +13 -20
- package/dist/vendor/cjs/bun/BunClusterSocket.d.ts +13 -8
- package/dist/vendor/cjs/bun/BunCrypto.d.ts +1 -0
- package/dist/vendor/cjs/bun/BunDatagramSocket.d.ts +227 -0
- package/dist/vendor/cjs/bun/BunDatagramSocket.js +1 -0
- package/dist/vendor/cjs/bun/BunDns.d.ts +72 -0
- package/dist/vendor/cjs/bun/BunDns.js +1 -0
- package/dist/vendor/cjs/bun/BunFileSystem.d.ts +1 -0
- package/dist/vendor/cjs/bun/BunHttpClient.d.ts +2 -1
- package/dist/vendor/cjs/bun/BunHttpPlatform.d.ts +2 -1
- package/dist/vendor/cjs/bun/BunHttpServer.d.ts +19 -10
- package/dist/vendor/cjs/bun/BunHttpServerRequest.d.ts +3 -1
- package/dist/vendor/cjs/bun/BunMultipart.d.ts +4 -1
- package/dist/vendor/cjs/bun/BunPath.d.ts +3 -0
- package/dist/vendor/cjs/bun/BunRedis.d.ts +5 -1
- package/dist/vendor/cjs/bun/BunRuntime.d.ts +3 -0
- package/dist/vendor/cjs/bun/BunServices.d.ts +4 -1
- package/dist/vendor/cjs/bun/BunSink.d.ts +1 -0
- package/dist/vendor/cjs/bun/BunSocket.d.ts +8 -3
- package/dist/vendor/cjs/bun/BunSocketServer.d.ts +1 -0
- package/dist/vendor/cjs/bun/BunStdio.d.ts +1 -0
- package/dist/vendor/cjs/bun/BunStream.d.ts +1 -0
- package/dist/vendor/cjs/bun/BunTerminal.d.ts +6 -3
- package/dist/vendor/cjs/bun/BunWorker.d.ts +3 -1
- package/dist/vendor/cjs/bun/BunWorkerRunner.d.ts +2 -1
- package/dist/vendor/cjs/bun/index.d.ts +38 -0
- package/dist/vendor/cjs/node/NodeAddressResolver.d.ts +16 -0
- package/dist/vendor/cjs/node/NodeAddressResolver.js +1 -0
- package/dist/vendor/cjs/node/NodeChildProcessSpawner.d.ts +1 -0
- package/dist/vendor/cjs/node/NodeClusterHttp.d.ts +13 -22
- package/dist/vendor/cjs/node/NodeClusterSocket.d.ts +14 -8
- package/dist/vendor/cjs/node/NodeCrypto.d.ts +1 -0
- package/dist/vendor/cjs/node/NodeDatagramSocket.d.ts +10 -0
- package/dist/vendor/cjs/node/NodeDatagramSocket.js +1 -0
- package/dist/vendor/cjs/node/NodeDns.d.ts +51 -0
- package/dist/vendor/cjs/node/NodeDns.js +1 -0
- package/dist/vendor/cjs/node/NodeFileSystem.d.ts +1 -0
- package/dist/vendor/cjs/node/NodeHttpClient.d.ts +21 -2
- package/dist/vendor/cjs/node/NodeHttpIncomingMessage.d.ts +5 -3
- package/dist/vendor/cjs/node/NodeHttpPlatform.d.ts +8 -6
- package/dist/vendor/cjs/node/NodeHttpServer.d.ts +21 -10
- package/dist/vendor/cjs/node/NodeHttpServerRequest.d.ts +4 -1
- package/dist/vendor/cjs/node/NodeMultipart.d.ts +5 -1
- package/dist/vendor/cjs/node/NodeMultipartParser.d.ts +9 -1
- package/dist/vendor/cjs/node/NodePath.d.ts +3 -0
- package/dist/vendor/cjs/node/NodeRedis.d.ts +5 -1
- package/dist/vendor/cjs/node/NodeRuntime.d.ts +3 -0
- package/dist/vendor/cjs/node/NodeServices.d.ts +4 -1
- package/dist/vendor/cjs/node/NodeSink.d.ts +1 -0
- package/dist/vendor/cjs/node/NodeSocket.d.ts +10 -3
- package/dist/vendor/cjs/node/NodeSocketServer.d.ts +1 -0
- package/dist/vendor/cjs/node/NodeStdio.d.ts +1 -0
- package/dist/vendor/cjs/node/NodeStream.d.ts +1 -0
- package/dist/vendor/cjs/node/NodeTerminal.d.ts +6 -3
- package/dist/vendor/cjs/node/NodeWorker.d.ts +3 -1
- package/dist/vendor/cjs/node/NodeWorkerRunner.d.ts +2 -1
- package/dist/vendor/cjs/node/Undici.d.ts +3 -0
- package/dist/vendor/cjs/node/index.d.ts +40 -0
- package/dist/vendor/cjs/node-shared/NodeAddressResolver.d.ts +13 -0
- package/dist/vendor/cjs/node-shared/NodeAddressResolver.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeChildProcessSpawner.d.ts +12 -3
- package/dist/vendor/cjs/node-shared/NodeClusterSocket.d.ts +17 -4
- package/dist/vendor/cjs/node-shared/NodeCrypto.d.ts +3 -0
- package/dist/vendor/cjs/node-shared/NodeDatagramSocket.d.ts +246 -0
- package/dist/vendor/cjs/node-shared/NodeDatagramSocket.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeDns.d.ts +221 -0
- package/dist/vendor/cjs/node-shared/NodeDns.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeFileSystem.d.ts +1 -0
- package/dist/vendor/cjs/node-shared/NodeHttpCompression.d.ts +5 -1
- package/dist/vendor/cjs/node-shared/NodePath.d.ts +3 -0
- package/dist/vendor/cjs/node-shared/NodeRuntime.d.ts +4 -0
- package/dist/vendor/cjs/node-shared/NodeSink.d.ts +4 -0
- package/dist/vendor/cjs/node-shared/NodeSocket.d.ts +11 -1
- package/dist/vendor/cjs/node-shared/NodeSocketServer.d.ts +8 -1
- package/dist/vendor/cjs/node-shared/NodeStdio.d.ts +1 -0
- package/dist/vendor/cjs/node-shared/NodeStream.d.ts +15 -0
- package/dist/vendor/cjs/node-shared/NodeTerminal.d.ts +6 -4
- package/dist/vendor/cjs/node-shared/index.d.ts +29 -0
- package/dist/vendor/cjs/node-shared/internal/nodeChildProcessSpawner.d.ts +1 -1
- package/dist/vendor/cjs/platform-bun.d.ts +38 -0
- package/dist/vendor/cjs/platform-node-shared.d.ts +29 -0
- package/dist/vendor/cjs/platform-node.d.ts +40 -0
- package/dist/vendor/node/NodeAddressResolver.d.ts +16 -0
- package/dist/vendor/node/NodeAddressResolver.js +8 -0
- package/dist/vendor/node/NodeChildProcessSpawner.d.ts +1 -0
- package/dist/vendor/node/NodeChildProcessSpawner.js +6 -6
- package/dist/vendor/node/NodeClusterHttp.d.ts +13 -22
- package/dist/vendor/node/NodeClusterHttp.js +32 -32
- package/dist/vendor/node/NodeClusterSocket.d.ts +14 -8
- package/dist/vendor/node/NodeClusterSocket.js +15 -15
- package/dist/vendor/node/NodeCrypto.d.ts +1 -0
- package/dist/vendor/node/NodeCrypto.js +2 -2
- package/dist/vendor/node/NodeDatagramSocket.d.ts +10 -0
- package/dist/vendor/node/NodeDatagramSocket.js +12 -0
- package/dist/vendor/node/NodeDns.d.ts +51 -0
- package/dist/vendor/node/NodeDns.js +12 -0
- package/dist/vendor/node/NodeFileSystem.d.ts +1 -0
- package/dist/vendor/node/NodeFileSystem.js +3 -3
- package/dist/vendor/node/NodeHttpClient.d.ts +21 -2
- package/dist/vendor/node/NodeHttpClient.js +6 -6
- package/dist/vendor/node/NodeHttpIncomingMessage.d.ts +5 -3
- package/dist/vendor/node/NodeHttpIncomingMessage.js +4 -4
- package/dist/vendor/node/NodeHttpPlatform.d.ts +8 -6
- package/dist/vendor/node/NodeHttpPlatform.js +8 -8
- package/dist/vendor/node/NodeHttpServer.d.ts +21 -10
- package/dist/vendor/node/NodeHttpServer.js +26 -26
- package/dist/vendor/node/NodeHttpServerRequest.d.ts +4 -1
- package/dist/vendor/node/NodeHttpServerRequest.js +1 -1
- package/dist/vendor/node/NodeMultipart.d.ts +5 -1
- package/dist/vendor/node/NodeMultipart.js +5 -5
- package/dist/vendor/node/NodeMultipartParser.d.ts +9 -1
- package/dist/vendor/node/NodeMultipartParser.js +1 -1
- package/dist/vendor/node/NodePath.d.ts +3 -0
- package/dist/vendor/node/NodePath.js +2 -2
- package/dist/vendor/node/NodeRedis.d.ts +5 -1
- package/dist/vendor/node/NodeRedis.js +1 -1
- package/dist/vendor/node/NodeRuntime.d.ts +3 -0
- package/dist/vendor/node/NodeRuntime.js +2 -2
- package/dist/vendor/node/NodeServices.d.ts +4 -1
- package/dist/vendor/node/NodeServices.js +17 -17
- package/dist/vendor/node/NodeSink.d.ts +1 -0
- package/dist/vendor/node/NodeSink.js +2 -2
- package/dist/vendor/node/NodeSocket.d.ts +10 -3
- package/dist/vendor/node/NodeSocket.js +2 -2
- package/dist/vendor/node/NodeSocketServer.d.ts +1 -0
- package/dist/vendor/node/NodeSocketServer.js +3 -3
- package/dist/vendor/node/NodeStdio.d.ts +1 -0
- package/dist/vendor/node/NodeStdio.js +4 -4
- package/dist/vendor/node/NodeStream.d.ts +1 -0
- package/dist/vendor/node/NodeStream.js +3 -3
- package/dist/vendor/node/NodeTerminal.d.ts +6 -3
- package/dist/vendor/node/NodeTerminal.js +2 -2
- package/dist/vendor/node/NodeWorker.d.ts +3 -1
- package/dist/vendor/node/NodeWorker.js +1 -1
- package/dist/vendor/node/NodeWorkerRunner.d.ts +2 -1
- package/dist/vendor/node/NodeWorkerRunner.js +1 -1
- package/dist/vendor/node/Undici.d.ts +3 -0
- package/dist/vendor/node/Undici.js +1 -1
- package/dist/vendor/node/index.d.ts +40 -0
- package/dist/vendor/node/index.js +63 -48
- package/dist/vendor/node-shared/NodeAddressResolver.d.ts +13 -0
- package/dist/vendor/node-shared/NodeAddressResolver.js +7 -0
- package/dist/vendor/node-shared/NodeChildProcessSpawner.d.ts +12 -3
- package/dist/vendor/node-shared/NodeChildProcessSpawner.js +5 -5
- package/dist/vendor/node-shared/NodeClusterSocket.d.ts +17 -4
- package/dist/vendor/node-shared/NodeClusterSocket.js +3 -3
- package/dist/vendor/node-shared/NodeCrypto.d.ts +3 -0
- package/dist/vendor/node-shared/NodeCrypto.js +1 -1
- package/dist/vendor/node-shared/NodeDatagramSocket.d.ts +246 -0
- package/dist/vendor/node-shared/NodeDatagramSocket.js +11 -0
- package/dist/vendor/node-shared/NodeDns.d.ts +221 -0
- package/dist/vendor/node-shared/NodeDns.js +31 -0
- package/dist/vendor/node-shared/NodeFileSystem.d.ts +1 -0
- package/dist/vendor/node-shared/NodeFileSystem.js +2 -2
- package/dist/vendor/node-shared/NodeHttpCompression.d.ts +5 -1
- package/dist/vendor/node-shared/NodeHttpCompression.js +1 -1
- package/dist/vendor/node-shared/NodePath.d.ts +3 -0
- package/dist/vendor/node-shared/NodePath.js +1 -1
- package/dist/vendor/node-shared/NodeRuntime.d.ts +4 -0
- package/dist/vendor/node-shared/NodeRuntime.js +1 -1
- package/dist/vendor/node-shared/NodeSink.d.ts +4 -0
- package/dist/vendor/node-shared/NodeSink.js +1 -1
- package/dist/vendor/node-shared/NodeSocket.d.ts +11 -1
- package/dist/vendor/node-shared/NodeSocket.js +1 -1
- package/dist/vendor/node-shared/NodeSocketServer.d.ts +8 -1
- package/dist/vendor/node-shared/NodeSocketServer.js +2 -2
- package/dist/vendor/node-shared/NodeStdio.d.ts +1 -0
- package/dist/vendor/node-shared/NodeStdio.js +3 -3
- package/dist/vendor/node-shared/NodeStream.d.ts +15 -0
- package/dist/vendor/node-shared/NodeStream.js +2 -2
- package/dist/vendor/node-shared/NodeTerminal.d.ts +6 -4
- package/dist/vendor/node-shared/NodeTerminal.js +1 -1
- package/dist/vendor/node-shared/index.d.ts +29 -0
- package/dist/vendor/node-shared/index.js +34 -22
- package/dist/vendor/node-shared/internal/nodeChildProcessSpawner.d.ts +1 -1
- package/dist/vendor/node-shared/internal/nodeChildProcessSpawner.js +1 -1
- package/dist/vendor/node-shared/internal/utils.js +1 -1
- package/dist/vendor/platform-bun.d.ts +38 -0
- package/dist/vendor/platform-bun.js +63 -49
- package/dist/vendor/platform-node-shared.d.ts +29 -0
- package/dist/vendor/platform-node-shared.js +34 -22
- package/dist/vendor/platform-node.d.ts +40 -0
- package/dist/vendor/platform-node.js +63 -48
- package/docs/api.md +1 -1
- package/docs/concepts/trust-boundary.md +1 -1
- package/docs/guides/host-the-gateway.md +1 -1
- package/docs/guides/testing.md +3 -3
- package/docs/installation.md +3 -3
- package/docs/troubleshooting.md +3 -0
- package/package.json +22 -22
- package/src/GatewayRpcs.ts +1 -1
- package/src/GatewayServer.ts +3 -3
- package/src/HostBranchPresence.ts +1 -1
- package/src/RuntimeBridge.ts +1 -1
- package/src/bun/BunGateway.ts +2 -2
- package/src/internal/NativeGateway.ts +4 -4
- package/dist/vendor/chunk-3NV2UDBI.js +0 -7
- /package/dist/vendor/{chunk-BFBIHJ6X.js → chunk-2GF47BML.js} +0 -0
- /package/dist/vendor/{chunk-MH2J3BYB.js → chunk-BYFUYMRZ.js} +0 -0
- /package/dist/vendor/{chunk-MLFIZ5O2.js → chunk-ZUPIQLXU.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/RuntimeBridge.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Versioned JSON boundary between the Go product backend and the canonical\n * TypeScript Flow/Control host.\n *\n * This module adapts HTTP-shaped commands to `Control`. It owns no graph,\n * scheduler, journal, or lifecycle state of its own.\n *\n * @since 1.0.0\n */\n\nimport { Control } from \"@smthrs/control/Control\"\nimport * as ControlError from \"@smthrs/control/ControlError\"\nimport { ControlExecutor, type Service as ControlExecutorService } from \"@smthrs/control/ControlExecutor\"\nimport type { Principal, WatchCursor } from \"@smthrs/control/ControlSchema\"\nimport {\n ApprovalPayload,\n ControlEvent,\n MessageSteer,\n Receipt,\n RunSummary,\n SignalPayload\n} from \"@smthrs/control/ControlSchema\"\nimport * as Fault from \"@smthrs/flow/Fault\"\nimport { Effect, Layer, Schema, Stream } from \"effect\"\nimport { HttpRouter, HttpServerRequest, HttpServerResponse } from \"effect/unstable/http\"\nimport { RunSummaryRow } from \"./GatewayProjection.ts\"\nimport * as Projections from \"./Projections.ts\"\nimport { monitorFromJournal } from \"./RunTrace.ts\"\n\n/**\n * The only protocol version accepted by this host.\n * @since 1.0.0\n * @category constants\n */\nexport const protocol = \"smithers.flow-runtime/v1\" as const\n\nconst Sha256 = Schema.String.check(Schema.isPattern(/^[0-9a-f]{64}$/))\nconst SourceRevision = Schema.String.check(Schema.isPattern(/^[0-9a-f]{40}$/))\nconst PositiveSafeInteger = Schema.Int.check(\n Schema.isGreaterThan(0),\n Schema.isLessThanOrEqualTo(Number.MAX_SAFE_INTEGER)\n)\nconst RequestId = Schema.NonEmptyString.check(Schema.isMaxLength(1024))\n// A decimal consumes a whole journal entry. v1 preserves an expansion offset;\n// the empty seed consumes nothing, including sequence zero.\nconst observationCursorPattern = /^(?:(0|[1-9][0-9]*)|v1:(0|[1-9][0-9]*):(0|[1-9][0-9]*))?(?![\\s\\S])/\n\n/**\n * Non-secret identity published by readiness for startup compatibility.\n * @since 1.0.0\n * @category models\n */\nexport const Identity = Schema.Struct({\n protocol: Schema.Literal(protocol),\n runtimeArtifactDigest: Sha256,\n sourceRevision: SourceRevision,\n ownerGeneration: PositiveSafeInteger\n})\n\n/**\n * Non-secret identity published by readiness for startup compatibility.\n * @since 1.0.0\n * @category models\n */\nexport type Identity = typeof Identity.Type\nconst common = {\n protocol: Schema.Literal(protocol),\n applicationRequestId: RequestId,\n ownerGeneration: PositiveSafeInteger\n}\n\n// The version a launch must run: a flow, the source commit it was chosen\n// from and that flow's execution digest. A pinned launch runs only a plan\n// with that exact identity.\nconst LaunchPin = Schema.Struct({\n flow: Schema.NonEmptyString,\n sourceCommit: SourceRevision,\n executionDigest: Sha256\n})\n\n/**\n * Launches one immutable named flow. Planning and running stay in Control.\n * @since 1.0.0\n * @category models\n */\nexport const LaunchCommand = Schema.Struct({\n ...common,\n operation: Schema.Literal(\"launch\"),\n attempt: PositiveSafeInteger,\n runId: Schema.optional(Schema.NonEmptyString),\n runtimeArtifactDigest: Sha256,\n sourceRevision: SourceRevision,\n flowId: Schema.NonEmptyString,\n payload: Schema.Json,\n pin: Schema.optional(LaunchPin)\n})\n\n/**\n * Submits an approval or denial payload produced by the same Control host.\n * @since 1.0.0\n * @category models\n */\nexport const DecisionCommand = Schema.Struct({\n ...common,\n operation: Schema.Literals([\"approve\", \"deny\"]),\n approval: ApprovalPayload\n})\n\n/**\n * Delivers one durable named signal.\n * @since 1.0.0\n * @category models\n */\nexport const SignalCommand = Schema.Struct({\n ...common,\n operation: Schema.Literal(\"signal\"),\n runId: Schema.NonEmptyString,\n signal: SignalPayload\n})\n\nconst Steer = Schema.Union([\n Schema.Struct({ kind: Schema.Literal(\"Message\"), body: Schema.String }),\n Schema.Struct({ kind: Schema.Literal(\"Seat\"), seat: Schema.NonEmptyString }),\n Schema.Struct({\n kind: Schema.Literal(\"Thinking\"),\n thinking: Schema.Literals([\"none\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\"])\n }),\n Schema.Struct({ kind: Schema.Literal(\"Tools\"), toolNames: Schema.NonEmptyArray(Schema.NonEmptyString) })\n])\n\n/**\n * Enqueues one steer for the runtime's next turn boundary.\n * @since 1.0.0\n * @category models\n */\nexport const SteerCommand = Schema.Struct({\n version: Schema.optional(Schema.Number),\n ...common,\n operation: Schema.Literal(\"steer\"),\n runId: Schema.NonEmptyString,\n messageId: Schema.NonEmptyString,\n createdAt: Schema.Number,\n attribution: MessageSteer.fields.attribution,\n steer: Steer\n})\n\n/**\n * Requests cancellation, explicit resume, or completion of a retained run.\n * @since 1.0.0\n * @category models\n */\nexport const LifecycleCommand = Schema.Struct({\n ...common,\n /** Completion is a host-only lifecycle operation. @since 1.0.0 */\n operation: Schema.Literals([\"cancel\", \"resume\", \"complete\"]),\n runId: Schema.NonEmptyString,\n reason: Schema.optional(Schema.String)\n})\n\n/**\n * Every mutating operation accepted by the bridge.\n * @since 1.0.0\n * @category models\n */\nexport const Command = Schema.Union([\n LaunchCommand,\n DecisionCommand,\n SignalCommand,\n SteerCommand,\n LifecycleCommand\n])\n\n/**\n * Every mutating operation accepted by the bridge.\n * @since 1.0.0\n * @category models\n */\nexport type Command = typeof Command.Type\n\n/**\n * A bounded, reconnectable read of one canonical runtime execution.\n * @since 1.0.0\n * @category models\n */\nexport const ObserveRequest = Schema.Struct({\n protocol: Schema.Literal(protocol),\n runId: Schema.NonEmptyString,\n afterCursor: Schema.optional(Schema.String.check(Schema.isPattern(observationCursorPattern))),\n limit: Schema.optional(PositiveSafeInteger)\n})\n\n/**\n * A bounded, reconnectable read of one canonical runtime execution.\n * @since 1.0.0\n * @category models\n */\nexport type ObserveRequest = typeof ObserveRequest.Type\n\n/**\n * A process result recorded by installed host equipment, never by a flow result.\n * @since 1.0.0\n * @category models\n */\nexport const CommandReceipt = Schema.Struct({\n runId: Schema.NonEmptyString,\n operationId: Schema.NonEmptyString,\n status: Schema.Literals([\"running\", \"completed\"]),\n argv: Schema.NonEmptyArray(Schema.String),\n exitCode: Schema.optionalKey(Schema.Int),\n stderr: Schema.optionalKey(Schema.String),\n fault: Schema.optionalKey(Schema.Literals([\"factory\", \"infra\"]))\n})\n/**\n * A process result recorded by installed host equipment.\n * @since 1.0.0\n * @category models\n */\nexport type CommandReceipt = typeof CommandReceipt.Type\n\n/**\n * Host identity fixed for the lifetime of one owning process.\n * @since 1.0.0\n * @category models\n */\nexport interface Config {\n readonly runtimeArtifactDigest: string\n readonly sourceRevision: string\n /** Captured and verified by native catalog registration, never decoded from a request or environment. */\n readonly verifiedCatalogSourceRevision?: string | undefined\n readonly ownerGeneration: number\n /**\n * Private installed-host receipt reader; never accepted on the command wire.\n * @since 1.0.0\n */\n readonly commandReceipt?: ((runId: string) => Effect.Effect<CommandReceipt | undefined, unknown>) | undefined\n /**\n * Native host completion port, captured from the executor rather than from a request.\n * @since 1.0.0\n */\n readonly requestComplete?: ControlExecutorService[\"requestComplete\"]\n readonly authenticate: (\n headers: Readonly<Record<string, string>>\n ) => Effect.Effect<Principal, ControlError.Unauthorized>\n}\n\n/**\n * Stable bridge-only failures. Control failures retain their own code.\n * @since 1.0.0\n * @category errors\n */\nexport class BridgeError extends Schema.TaggedError<BridgeError>()(\"@smthrs/gateway/RuntimeBridgeError\", {\n code: Schema.Literals([\n \"invalid_request\",\n \"artifact_mismatch\",\n \"source_mismatch\",\n \"stale_owner\",\n \"run_not_found\",\n \"resource_limit\",\n \"unavailable\",\n \"internal\"\n ]),\n message: Schema.String,\n retryable: Schema.Boolean\n}) {}\n\nconst decodeCommand = Schema.decodeUnknownEffect(Command)\nconst decodeObserve = Schema.decodeUnknownEffect(ObserveRequest)\nconst terminal = new Set([\"completed\", \"failed\", \"cancelled\"])\nconst retryableCodes = new Set([\"transport_error\", \"unavailable\", \"persistence_failed\", \"launch_failed\"])\nconst notFoundCodes = new Set([\"run_not_found\", \"flow_not_found\", \"plan_not_found\"])\nconst conflictCodes = new Set([\"stale_owner\", \"artifact_mismatch\", \"source_mismatch\", \"conflict\"])\nconst defaultEventLimit = 250\nconst maximumEventLimit = 1_000\n\n// Host generation fences who may execute a delivery, but it is not part of\n// the durable product request identity. A replacement owner must reconcile a\n// lost acknowledgement against the same Control command keys.\nconst idempotencyKey = (input: Pick<Command, \"applicationRequestId\">, suffix: string) =>\n `bridge:v1:${input.applicationRequestId}:${suffix}`\n\nconst validateOwner = (config: Config, input: Pick<Command, \"ownerGeneration\">) =>\n input.ownerGeneration === config.ownerGeneration\n ? Effect.void\n : Effect.fail(\n new BridgeError({ code: \"stale_owner\", message: \"Runtime owner generation is stale\", retryable: true })\n )\n\n/**\n * Executes one decoded command exclusively through the canonical Control API.\n * @since 1.0.0\n * @category constructors\n */\nexport const execute = (\n config: Config,\n control: Control[\"Service\"],\n principal: Principal,\n input: Command\n) =>\n Effect.gen(function*() {\n yield* validateOwner(config, input)\n switch (input.operation) {\n case \"launch\": {\n if (input.runtimeArtifactDigest !== config.runtimeArtifactDigest) {\n return yield* Effect.fail(\n new BridgeError({\n code: \"artifact_mismatch\",\n message: \"Runtime artifact digest does not match the owning host\",\n retryable: false\n })\n )\n }\n if (input.sourceRevision !== config.sourceRevision) {\n return yield* Effect.fail(\n new BridgeError({\n code: \"source_mismatch\",\n message: \"Flow source revision does not match the owning host\",\n retryable: false\n })\n )\n }\n // Every launch of a pinned attempt (its composition and the engine's\n // launches) runs from the pinned source commit: a host serving any\n // other source refuses before planning imports anything.\n if (input.pin !== undefined && input.pin.sourceCommit !== config.sourceRevision) {\n return yield* Effect.fail(\n new BridgeError({\n code: \"source_mismatch\",\n message: \"Flow source revision does not match the pinned launch\",\n retryable: false\n })\n )\n }\n const plan = yield* control.plan({\n flowId: input.flowId,\n input: input.payload,\n idempotencyKey: idempotencyKey(input, \"plan\")\n })\n // Graphs are optional for valid Flow declarations. Only a verified\n // native catalog snapshot can supply the missing provenance; the\n // configured/wire identity by itself cannot stand in for that proof.\n const plannedSource = plan.graph?.sourceRevision ?? config.verifiedCatalogSourceRevision\n if (plannedSource !== input.sourceRevision) {\n return yield* Effect.fail(\n new BridgeError({\n code: \"source_mismatch\",\n message: \"Flow source revision does not match the immutable request\",\n retryable: false\n })\n )\n }\n // A pinned launch runs nothing but its pin: a plan with no execution\n // identity, or the pinned flow planned as other code, never starts.\n if (\n input.pin !== undefined &&\n (plan.executionDigest === undefined ||\n (input.pin.flow === input.flowId && plan.executionDigest !== input.pin.executionDigest))\n ) {\n return yield* Effect.fail(\n new BridgeError({\n code: \"source_mismatch\",\n message: \"Flow execution digest does not match the pinned launch\",\n retryable: false\n })\n )\n }\n const receipt = yield* control.run({\n _tag: \"Plan\",\n planId: plan.planId,\n digest: plan.digest,\n envelope: plan.envelope,\n idempotencyKey: idempotencyKey(input, `run:${input.runId ?? input.attempt}`),\n principal,\n ...(input.runId === undefined ? {} : { reservedRunId: input.runId })\n })\n return {\n operation: input.operation,\n applicationRequestId: input.applicationRequestId,\n ownerGeneration: input.ownerGeneration,\n runtimeArtifactDigest: config.runtimeArtifactDigest,\n sourceRevision: input.sourceRevision,\n planId: plan.planId,\n planDigest: plan.digest,\n ...(plan.executionDigest === undefined ? {} : { executionDigest: plan.executionDigest }),\n envelope: plan.envelope,\n approval: plan.approval,\n receipt\n } as const\n }\n case \"approve\":\n case \"deny\": {\n const request = {\n ...input.approval,\n idempotencyKey: idempotencyKey(input, input.operation),\n principal\n }\n const receipt = yield* input.operation === \"approve\" ? control.approve(request) : control.deny(request)\n return { operation: input.operation, applicationRequestId: input.applicationRequestId, receipt } as const\n }\n case \"signal\": {\n const receipt = yield* control.signal({\n runId: input.runId,\n signal: input.signal,\n idempotencyKey: idempotencyKey(input, \"signal\"),\n principal\n })\n return { operation: input.operation, applicationRequestId: input.applicationRequestId, receipt } as const\n }\n case \"steer\": {\n const receipt = yield* control.steer({\n runId: input.runId,\n idempotencyKey: idempotencyKey(input, \"steer\"),\n ...(input.version === undefined ? {} : { version: input.version }),\n message: {\n ...input.steer,\n runId: input.runId,\n messageId: input.messageId,\n createdAt: input.createdAt,\n ...(input.attribution === undefined ? {} : { attribution: input.attribution }),\n principal\n }\n })\n return { operation: input.operation, applicationRequestId: input.applicationRequestId, receipt } as const\n }\n // This authenticated host bridge is not a catalog or public Control\n // verb. The executor validates the completed native child and resumes\n // its retained parent to settle from that child's committed result.\n case \"complete\": {\n const executor = yield* Effect.serviceOption(ControlExecutor)\n const complete = config.requestComplete ??\n (executor._tag === \"Some\" ? executor.value.requestComplete : undefined)\n if (complete === undefined) {\n return yield* Effect.fail(\n new BridgeError({\n code: \"unavailable\",\n message: \"Completed-module settlement is unavailable\",\n retryable: true\n })\n )\n }\n const receipt = yield* complete({ runId: input.runId, receiptId: idempotencyKey(input, \"complete\") })\n return { operation: input.operation, applicationRequestId: input.applicationRequestId, receipt } as const\n }\n case \"cancel\":\n case \"resume\": {\n const request = {\n runId: input.runId,\n idempotencyKey: idempotencyKey(input, input.operation),\n ...(input.reason === undefined ? {} : { reason: input.reason }),\n principal\n }\n const receipt = yield* input.operation === \"cancel\" ? control.cancel(request) : control.resume(request)\n return { operation: input.operation, applicationRequestId: input.applicationRequestId, receipt } as const\n }\n }\n })\n\nconst cursorPosition = (cursor: string | undefined): Effect.Effect<WatchCursor | undefined, BridgeError> => {\n if (cursor === undefined || cursor === \"\") return Effect.succeed(undefined)\n const match = observationCursorPattern.exec(cursor)\n const sequence = Number(match?.[1] ?? match?.[2])\n const offset = match?.[3] === undefined ? undefined : Number(match[3])\n const valid = (value: number) => Number.isSafeInteger(value) && value >= 0 && value < Number.MAX_SAFE_INTEGER\n return match !== null && valid(sequence) && (offset === undefined || valid(offset))\n ? Effect.succeed({ sequence, ...(offset === undefined ? {} : { offset }) })\n : Effect.fail(\n new BridgeError({\n code: \"invalid_request\",\n message: \"Observation cursor is invalid or out of range\",\n retryable: false\n })\n )\n}\n\nconst encodedCursor = (cursor: WatchCursor): string =>\n cursor.offset === undefined ? String(cursor.sequence) : `v1:${cursor.sequence}:${cursor.offset}`\n\n/**\n * Reads a bounded event replay and current canonical run projection.\n * @since 1.0.0\n * @category constructors\n */\nexport const observe = (control: Control[\"Service\"], input: ObserveRequest, receipts?: Config[\"commandReceipt\"]) =>\n Effect.gen(function*() {\n const after = yield* cursorPosition(input.afterCursor)\n const limit = Math.min(input.limit ?? defaultEventLimit, maximumEventLimit)\n const listed = yield* control.list({ _tag: \"runs\", filters: { runId: input.runId }, limit: 1 })\n const summary = listed._tag === \"runs\" ? listed.items[0] : undefined\n if (summary === undefined) {\n return yield* Effect.fail(\n new BridgeError({ code: \"run_not_found\", message: \"Runtime execution was not found\", retryable: true })\n )\n }\n const events = Array.from(\n yield* Stream.runCollect(Stream.take(\n control.watch({\n runId: input.runId,\n ...(after === undefined\n ? {}\n : after.offset === undefined\n ? { afterSequence: after.sequence }\n : { afterCursor: after }),\n follow: false\n }),\n limit + 1\n ))\n )\n const page = events.slice(0, limit)\n const last = page.at(-1)\n // Typed Flow results use the same committed root projection as the app.\n // A terminal status alone never supplies a result, and a bounded event\n // page cannot reconstruct a root result that precedes its cursor.\n let finalOutput: string | undefined\n let failure: {\n readonly failureFault?: Fault.Class\n readonly failureTag?: string\n readonly failureMessage?: string\n } = {}\n if (terminal.has(summary.status)) {\n const projections = yield* Projections.make(control)\n const snapshot = yield* projections.snapshot({ _tag: \"run-summary\", runId: input.runId })\n const row = snapshot.rows.find(Schema.is(RunSummaryRow))\n if (\n row === undefined || row.runId !== summary.runId || row.flowId !== summary.flowId ||\n row.status !== summary.status || row.planId !== summary.planId || row.planDigest !== summary.planDigest\n ) {\n return yield* Effect.fail(\n new BridgeError({ code: \"internal\", message: \"Terminal result observation changed\", retryable: true })\n )\n }\n finalOutput = row.finalOutput\n failure = {\n ...(row.failureFault === undefined ? {} : { failureFault: row.failureFault }),\n ...(row.failureTag === undefined ? {} : { failureTag: row.failureTag }),\n ...(row.failureMessage === undefined ? {} : { failureMessage: row.failureMessage })\n }\n }\n // Keep the private receipt out of every repository-controlled projection.\n const hostSummary = yield* Schema.decodeUnknownEffect(RunSummary)(summary)\n const commandReceipt = receipts === undefined ? undefined : yield* receipts(input.runId)\n if (commandReceipt !== undefined && commandReceipt.runId !== input.runId) {\n return yield* Effect.fail(\n new BridgeError({ code: \"internal\", message: \"Host command receipt names another run\", retryable: false })\n )\n }\n return {\n run: {\n ...hostSummary,\n ...(commandReceipt === undefined ? {} : { commandReceipt }),\n ...(finalOutput === undefined ? {} : { finalOutput }),\n ...failure\n },\n events: page,\n nextCursor: last === undefined\n ? input.afterCursor ?? \"\"\n : encodedCursor(last.cursor ?? { sequence: last.sequence }),\n hasMore: events.length > limit,\n terminal: terminal.has(summary.status)\n }\n })\n\n// Disposable raw journal prefixes for Inspect. This stores no run state: the\n// existing monitor fold still derives every answer from journal records. Bound\n// retention across all runs of one control service, and rebuild after eviction.\nconst monitorJournals = new WeakMap<\n Control[\"Service\"],\n Map<string, {\n readonly records: ReadonlyArray<ControlEvent>\n readonly bytes: number\n }>\n>()\nconst monitorJournalBytes = 64 * 1024 * 1024\n\n/** Read an existing run and its committed journal without invoking any execution door.\n * @since 1.0.0\n * @category constructors\n */\nexport const monitor = (control: Control[\"Service\"], runId: string, at?: number) =>\n Effect.gen(function*() {\n const listed = yield* control.list({ _tag: \"runs\", filters: { runId }, limit: 1 })\n const run = listed._tag === \"runs\" ? listed.items[0] : undefined\n if (run === undefined || run.runId !== runId) {\n return yield* new BridgeError({\n code: \"run_not_found\",\n message: \"Runtime execution was not found\",\n retryable: false\n })\n }\n const cache = monitorJournals.get(control) ??\n new Map<string, { readonly records: ReadonlyArray<ControlEvent>; readonly bytes: number }>()\n monitorJournals.set(control, cache)\n const cached = cache.get(runId)\n const last = cached?.records.at(-1)?.sequence\n // Replay the final entry because one entry may expand into several events.\n const consumed = last === undefined ? 0 : cached!.records.filter((row) => row.sequence === last).length\n let skipped = 0\n const suffix = Array.from(\n yield* Stream.runCollect(\n control.watch({\n runId,\n follow: false,\n ...(last === undefined || last === 0 ? {} : { afterSequence: last - 1 })\n }).pipe(\n Stream.filter((row) =>\n last === undefined || row.sequence > last || row.sequence === last && skipped++ >= consumed\n ),\n Stream.take(Projections.maxEventsScanned + 1)\n )\n )\n )\n const records = [...(cached?.records ?? []), ...suffix]\n if (records.length > Projections.maxEventsScanned) {\n return yield* new BridgeError({\n code: \"resource_limit\",\n message: \"Run journal exceeds the inspection limit\",\n retryable: false\n })\n }\n const bytes = (cached?.bytes ?? 0) +\n suffix.reduce((sum, row) => sum + new TextEncoder().encode(JSON.stringify(row)).byteLength, 0)\n const current = cache.get(runId)\n // A slower reader cannot overwrite a longer committed prefix.\n if (bytes <= monitorJournalBytes && (current === undefined || current.records.length <= records.length)) {\n cache.delete(runId)\n cache.set(runId, { records, bytes })\n let total = [...cache.values()].reduce((sum, entry) => sum + entry.bytes, 0)\n while (cache.size > 32 || total > monitorJournalBytes) {\n const oldest = cache.keys().next().value!\n total -= cache.get(oldest)!.bytes\n cache.delete(oldest)\n }\n }\n const folded = monitorFromJournal({ runId, flowId: run.flowId, status: run.status }, records, at)\n // The journal is read page by page when its tab opens (run-events). Only a\n // replay frame carries its own journal prefix. The extent bounds the run.\n let start = Infinity\n let end = 0\n for (const row of records) {\n if (row.occurredAt > 0) {\n start = Math.min(start, row.occurredAt)\n end = Math.max(end, row.occurredAt)\n }\n }\n const value: Partial<typeof folded> & Omit<typeof folded, \"journal\"> & { extent?: { start: string; end: string } } =\n {\n ...folded,\n ...(end === 0 ? {} : { extent: { start: new Date(start).toISOString(), end: new Date(end).toISOString() } })\n }\n if (at === undefined) delete value.journal\n if (new TextEncoder().encode(JSON.stringify(value)).byteLength > Projections.maxProjectionBytes) {\n return yield* new BridgeError({\n code: \"resource_limit\",\n message: \"Run monitor exceeds the inspection limit\",\n retryable: false\n })\n }\n return value\n })\n\n/**\n * Successful command response on the JSON wire.\n * @since 1.0.0\n * @category models\n */\nexport const CommandResponse = Schema.Struct({\n protocol: Schema.Literal(protocol),\n ok: Schema.Literal(true),\n value: Schema.Struct({\n operation: Schema.String,\n applicationRequestId: Schema.String,\n ownerGeneration: Schema.optional(PositiveSafeInteger),\n runtimeArtifactDigest: Schema.optional(Sha256),\n sourceRevision: Schema.optional(SourceRevision),\n planId: Schema.optional(Schema.String),\n planDigest: Schema.optional(Sha256),\n executionDigest: Schema.optional(Sha256),\n envelope: Schema.optional(Schema.Json),\n approval: Schema.optional(ApprovalPayload),\n receipt: Receipt\n })\n})\n\n/**\n * Successful observation response on the JSON wire.\n * @since 1.0.0\n * @category models\n */\nexport const ObserveResponse = Schema.Struct({\n protocol: Schema.Literal(protocol),\n ok: Schema.Literal(true),\n value: Schema.Struct({\n run: Schema.Struct({\n ...RunSummary.fields,\n finalOutput: Schema.optional(Schema.String),\n failureFault: Schema.optional(Fault.Class),\n failureTag: Schema.optional(Schema.String),\n failureMessage: Schema.optional(Schema.String),\n commandReceipt: Schema.optionalKey(CommandReceipt)\n }),\n events: Schema.Array(ControlEvent),\n nextCursor: Schema.String,\n hasMore: Schema.Boolean,\n terminal: Schema.Boolean\n })\n})\n\n/**\n * Stable sanitized failure response on the JSON wire.\n * @since 1.0.0\n * @category models\n */\nexport const ErrorResponse = Schema.Struct({\n protocol: Schema.Literal(protocol),\n ok: Schema.Literal(false),\n error: Schema.Struct({ code: Schema.String, message: Schema.String, retryable: Schema.Boolean })\n})\n\nconst errorResponse = (cause: unknown) => {\n const known = Schema.is(ControlError.ControlErrorSchema)(cause)\n const code = cause instanceof BridgeError || known ? cause.code : \"internal\"\n const retryable = cause instanceof BridgeError\n ? cause.retryable\n : cause instanceof ControlError.TransportError\n ? cause.retryable\n : retryableCodes.has(code)\n // Control errors can contain storage paths, SQL diagnostics, or executor\n // output. The bridge publishes their stable code, never that backend text.\n const message = cause instanceof BridgeError ? cause.message : \"Runtime bridge failed\"\n const status = code === \"unauthorized\" ?\n 401\n : notFoundCodes.has(code) ?\n 404\n : conflictCodes.has(code) ?\n 409\n : retryable ?\n 503\n : code === \"internal\" ?\n 500\n : 400\n return HttpServerResponse.jsonUnsafe({ protocol, ok: false, error: { code, message, retryable } }, { status })\n}\n\n/**\n * Answers a failed bridge request with its sanitized response, logging it first.\n *\n * The wire carries only the stable code. The operator log carries the full\n * cause of every failure the caller did not cause, so a launch that failed in\n * storage or in the executor can be diagnosed from the host.\n */\nconst respondToFailure = (operation: \"runtime-bridge.command\" | \"runtime-bridge.observe\") => (cause: unknown) => {\n const response = errorResponse(cause)\n if (cause instanceof BridgeError) return Effect.succeed(response)\n const code = Schema.is(ControlError.ControlErrorSchema)(cause) ? cause.code : \"internal\"\n return Effect.logError({ message: \"Runtime bridge request failed\", operation, code, cause }).pipe(\n Effect.as(response)\n )\n}\n\nconst readJson = Effect.gen(function*() {\n const request = yield* HttpServerRequest.HttpServerRequest\n const text = yield* request.text\n return yield* Effect.try({\n try: () => JSON.parse(text) as unknown,\n catch: () => new BridgeError({ code: \"invalid_request\", message: \"Request body must be JSON\", retryable: false })\n })\n})\n\nconst authenticated = <A, E, R>(\n config: Config,\n effect: (principal: Principal) => Effect.Effect<A, E, R>\n) =>\n Effect.gen(function*() {\n const request = yield* HttpServerRequest.HttpServerRequest\n const principal = yield* config.authenticate(request.headers)\n return yield* effect(principal)\n })\n\n/**\n * Mounts the authenticated JSON bridge beside the existing gateway RPCs.\n * @since 1.0.0\n * @category layers\n */\nexport const layer = (config: Config) => {\n const command = authenticated(config, (principal) =>\n Effect.gen(function*() {\n const body = yield* readJson\n const input = yield* decodeCommand(body).pipe(Effect.mapError(() =>\n new BridgeError({\n code: \"invalid_request\",\n message: \"Request does not match the runtime bridge contract\",\n retryable: false\n })\n ))\n const control = yield* Control\n const value = yield* execute(config, control, principal, input)\n return HttpServerResponse.jsonUnsafe({ protocol, ok: true, value })\n })).pipe(\n Effect.catch(respondToFailure(\"runtime-bridge.command\")),\n Effect.withSpan(\"runtime-bridge.command\")\n )\n\n const observation = authenticated(config, () =>\n Effect.gen(function*() {\n const body = yield* readJson\n const input = yield* decodeObserve(body).pipe(Effect.mapError(() =>\n new BridgeError({\n code: \"invalid_request\",\n message: \"Request does not match the observation contract\",\n retryable: false\n })\n ))\n const control = yield* Control\n const value = yield* observe(control, input, config.commandReceipt)\n return HttpServerResponse.jsonUnsafe({ protocol, ok: true, value })\n })).pipe(\n Effect.catch(respondToFailure(\"runtime-bridge.observe\")),\n Effect.withSpan(\"runtime-bridge.observe\")\n )\n\n const inspection = authenticated(config, () =>\n Effect.gen(function*() {\n const body = yield* readJson\n const input = yield* Schema.decodeUnknownEffect(Schema.Struct({\n protocol: Schema.Literal(protocol),\n runId: Schema.NonEmptyString,\n at: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)))\n }))(body).pipe(Effect.mapError(() =>\n new BridgeError({ code: \"invalid_request\", message: \"Invalid monitor request\", retryable: false })\n ))\n const control = yield* Control\n return HttpServerResponse.jsonUnsafe({\n protocol,\n ok: true,\n value: yield* monitor(control, input.runId, input.at)\n })\n })).pipe(Effect.catch(respondToFailure(\"runtime-bridge.observe\")))\n\n return HttpRouter.add(\"POST\", \"/runtime/v1/command\", command).pipe(\n Layer.merge(HttpRouter.add(\"POST\", \"/runtime/v1/monitor\", inspection)),\n Layer.merge(HttpRouter.add(\"POST\", \"/runtime/v1/observe\", observation))\n )\n}\n"],
|
|
4
|
+
"sourcesContent": ["/**\n * Versioned JSON boundary between the Go product backend and the canonical\n * TypeScript Flow/Control host.\n *\n * This module adapts HTTP-shaped commands to `Control`. It owns no graph,\n * scheduler, journal, or lifecycle state of its own.\n *\n * @since 1.0.0\n */\n\nimport { Control } from \"@smthrs/control/Control\"\nimport * as ControlError from \"@smthrs/control/ControlError\"\nimport { ControlExecutor, type Service as ControlExecutorService } from \"@smthrs/control/ControlExecutor\"\nimport type { Principal, WatchCursor } from \"@smthrs/control/ControlSchema\"\nimport {\n ApprovalPayload,\n ControlEvent,\n MessageSteer,\n Receipt,\n RunSummary,\n SignalPayload\n} from \"@smthrs/control/ControlSchema\"\nimport * as Fault from \"@smthrs/flow/Fault\"\nimport { Effect, Layer, Schema, Stream } from \"effect\"\nimport { HttpRouter, HttpServerRequest, HttpServerResponse } from \"effect/http\"\nimport { RunSummaryRow } from \"./GatewayProjection.ts\"\nimport * as Projections from \"./Projections.ts\"\nimport { monitorFromJournal } from \"./RunTrace.ts\"\n\n/**\n * The only protocol version accepted by this host.\n * @since 1.0.0\n * @category constants\n */\nexport const protocol = \"smithers.flow-runtime/v1\" as const\n\nconst Sha256 = Schema.String.check(Schema.isPattern(/^[0-9a-f]{64}$/))\nconst SourceRevision = Schema.String.check(Schema.isPattern(/^[0-9a-f]{40}$/))\nconst PositiveSafeInteger = Schema.Int.check(\n Schema.isGreaterThan(0),\n Schema.isLessThanOrEqualTo(Number.MAX_SAFE_INTEGER)\n)\nconst RequestId = Schema.NonEmptyString.check(Schema.isMaxLength(1024))\n// A decimal consumes a whole journal entry. v1 preserves an expansion offset;\n// the empty seed consumes nothing, including sequence zero.\nconst observationCursorPattern = /^(?:(0|[1-9][0-9]*)|v1:(0|[1-9][0-9]*):(0|[1-9][0-9]*))?(?![\\s\\S])/\n\n/**\n * Non-secret identity published by readiness for startup compatibility.\n * @since 1.0.0\n * @category models\n */\nexport const Identity = Schema.Struct({\n protocol: Schema.Literal(protocol),\n runtimeArtifactDigest: Sha256,\n sourceRevision: SourceRevision,\n ownerGeneration: PositiveSafeInteger\n})\n\n/**\n * Non-secret identity published by readiness for startup compatibility.\n * @since 1.0.0\n * @category models\n */\nexport type Identity = typeof Identity.Type\nconst common = {\n protocol: Schema.Literal(protocol),\n applicationRequestId: RequestId,\n ownerGeneration: PositiveSafeInteger\n}\n\n// The version a launch must run: a flow, the source commit it was chosen\n// from and that flow's execution digest. A pinned launch runs only a plan\n// with that exact identity.\nconst LaunchPin = Schema.Struct({\n flow: Schema.NonEmptyString,\n sourceCommit: SourceRevision,\n executionDigest: Sha256\n})\n\n/**\n * Launches one immutable named flow. Planning and running stay in Control.\n * @since 1.0.0\n * @category models\n */\nexport const LaunchCommand = Schema.Struct({\n ...common,\n operation: Schema.Literal(\"launch\"),\n attempt: PositiveSafeInteger,\n runId: Schema.optional(Schema.NonEmptyString),\n runtimeArtifactDigest: Sha256,\n sourceRevision: SourceRevision,\n flowId: Schema.NonEmptyString,\n payload: Schema.Json,\n pin: Schema.optional(LaunchPin)\n})\n\n/**\n * Submits an approval or denial payload produced by the same Control host.\n * @since 1.0.0\n * @category models\n */\nexport const DecisionCommand = Schema.Struct({\n ...common,\n operation: Schema.Literals([\"approve\", \"deny\"]),\n approval: ApprovalPayload\n})\n\n/**\n * Delivers one durable named signal.\n * @since 1.0.0\n * @category models\n */\nexport const SignalCommand = Schema.Struct({\n ...common,\n operation: Schema.Literal(\"signal\"),\n runId: Schema.NonEmptyString,\n signal: SignalPayload\n})\n\nconst Steer = Schema.Union([\n Schema.Struct({ kind: Schema.Literal(\"Message\"), body: Schema.String }),\n Schema.Struct({ kind: Schema.Literal(\"Seat\"), seat: Schema.NonEmptyString }),\n Schema.Struct({\n kind: Schema.Literal(\"Thinking\"),\n thinking: Schema.Literals([\"none\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\"])\n }),\n Schema.Struct({ kind: Schema.Literal(\"Tools\"), toolNames: Schema.NonEmptyArray(Schema.NonEmptyString) })\n])\n\n/**\n * Enqueues one steer for the runtime's next turn boundary.\n * @since 1.0.0\n * @category models\n */\nexport const SteerCommand = Schema.Struct({\n version: Schema.optional(Schema.Number),\n ...common,\n operation: Schema.Literal(\"steer\"),\n runId: Schema.NonEmptyString,\n messageId: Schema.NonEmptyString,\n createdAt: Schema.Number,\n attribution: MessageSteer.fields.attribution,\n steer: Steer\n})\n\n/**\n * Requests cancellation, explicit resume, or completion of a retained run.\n * @since 1.0.0\n * @category models\n */\nexport const LifecycleCommand = Schema.Struct({\n ...common,\n /** Completion is a host-only lifecycle operation. @since 1.0.0 */\n operation: Schema.Literals([\"cancel\", \"resume\", \"complete\"]),\n runId: Schema.NonEmptyString,\n reason: Schema.optional(Schema.String)\n})\n\n/**\n * Every mutating operation accepted by the bridge.\n * @since 1.0.0\n * @category models\n */\nexport const Command = Schema.Union([\n LaunchCommand,\n DecisionCommand,\n SignalCommand,\n SteerCommand,\n LifecycleCommand\n])\n\n/**\n * Every mutating operation accepted by the bridge.\n * @since 1.0.0\n * @category models\n */\nexport type Command = typeof Command.Type\n\n/**\n * A bounded, reconnectable read of one canonical runtime execution.\n * @since 1.0.0\n * @category models\n */\nexport const ObserveRequest = Schema.Struct({\n protocol: Schema.Literal(protocol),\n runId: Schema.NonEmptyString,\n afterCursor: Schema.optional(Schema.String.check(Schema.isPattern(observationCursorPattern))),\n limit: Schema.optional(PositiveSafeInteger)\n})\n\n/**\n * A bounded, reconnectable read of one canonical runtime execution.\n * @since 1.0.0\n * @category models\n */\nexport type ObserveRequest = typeof ObserveRequest.Type\n\n/**\n * A process result recorded by installed host equipment, never by a flow result.\n * @since 1.0.0\n * @category models\n */\nexport const CommandReceipt = Schema.Struct({\n runId: Schema.NonEmptyString,\n operationId: Schema.NonEmptyString,\n status: Schema.Literals([\"running\", \"completed\"]),\n argv: Schema.NonEmptyArray(Schema.String),\n exitCode: Schema.optionalKey(Schema.Int),\n stderr: Schema.optionalKey(Schema.String),\n fault: Schema.optionalKey(Schema.Literals([\"factory\", \"infra\"]))\n})\n/**\n * A process result recorded by installed host equipment.\n * @since 1.0.0\n * @category models\n */\nexport type CommandReceipt = typeof CommandReceipt.Type\n\n/**\n * Host identity fixed for the lifetime of one owning process.\n * @since 1.0.0\n * @category models\n */\nexport interface Config {\n readonly runtimeArtifactDigest: string\n readonly sourceRevision: string\n /** Captured and verified by native catalog registration, never decoded from a request or environment. */\n readonly verifiedCatalogSourceRevision?: string | undefined\n readonly ownerGeneration: number\n /**\n * Private installed-host receipt reader; never accepted on the command wire.\n * @since 1.0.0\n */\n readonly commandReceipt?: ((runId: string) => Effect.Effect<CommandReceipt | undefined, unknown>) | undefined\n /**\n * Native host completion port, captured from the executor rather than from a request.\n * @since 1.0.0\n */\n readonly requestComplete?: ControlExecutorService[\"requestComplete\"]\n readonly authenticate: (\n headers: Readonly<Record<string, string>>\n ) => Effect.Effect<Principal, ControlError.Unauthorized>\n}\n\n/**\n * Stable bridge-only failures. Control failures retain their own code.\n * @since 1.0.0\n * @category errors\n */\nexport class BridgeError extends Schema.TaggedError<BridgeError>()(\"@smthrs/gateway/RuntimeBridgeError\", {\n code: Schema.Literals([\n \"invalid_request\",\n \"artifact_mismatch\",\n \"source_mismatch\",\n \"stale_owner\",\n \"run_not_found\",\n \"resource_limit\",\n \"unavailable\",\n \"internal\"\n ]),\n message: Schema.String,\n retryable: Schema.Boolean\n}) {}\n\nconst decodeCommand = Schema.decodeUnknownEffect(Command)\nconst decodeObserve = Schema.decodeUnknownEffect(ObserveRequest)\nconst terminal = new Set([\"completed\", \"failed\", \"cancelled\"])\nconst retryableCodes = new Set([\"transport_error\", \"unavailable\", \"persistence_failed\", \"launch_failed\"])\nconst notFoundCodes = new Set([\"run_not_found\", \"flow_not_found\", \"plan_not_found\"])\nconst conflictCodes = new Set([\"stale_owner\", \"artifact_mismatch\", \"source_mismatch\", \"conflict\"])\nconst defaultEventLimit = 250\nconst maximumEventLimit = 1_000\n\n// Host generation fences who may execute a delivery, but it is not part of\n// the durable product request identity. A replacement owner must reconcile a\n// lost acknowledgement against the same Control command keys.\nconst idempotencyKey = (input: Pick<Command, \"applicationRequestId\">, suffix: string) =>\n `bridge:v1:${input.applicationRequestId}:${suffix}`\n\nconst validateOwner = (config: Config, input: Pick<Command, \"ownerGeneration\">) =>\n input.ownerGeneration === config.ownerGeneration\n ? Effect.void\n : Effect.fail(\n new BridgeError({ code: \"stale_owner\", message: \"Runtime owner generation is stale\", retryable: true })\n )\n\n/**\n * Executes one decoded command exclusively through the canonical Control API.\n * @since 1.0.0\n * @category constructors\n */\nexport const execute = (\n config: Config,\n control: Control[\"Service\"],\n principal: Principal,\n input: Command\n) =>\n Effect.gen(function*() {\n yield* validateOwner(config, input)\n switch (input.operation) {\n case \"launch\": {\n if (input.runtimeArtifactDigest !== config.runtimeArtifactDigest) {\n return yield* Effect.fail(\n new BridgeError({\n code: \"artifact_mismatch\",\n message: \"Runtime artifact digest does not match the owning host\",\n retryable: false\n })\n )\n }\n if (input.sourceRevision !== config.sourceRevision) {\n return yield* Effect.fail(\n new BridgeError({\n code: \"source_mismatch\",\n message: \"Flow source revision does not match the owning host\",\n retryable: false\n })\n )\n }\n // Every launch of a pinned attempt (its composition and the engine's\n // launches) runs from the pinned source commit: a host serving any\n // other source refuses before planning imports anything.\n if (input.pin !== undefined && input.pin.sourceCommit !== config.sourceRevision) {\n return yield* Effect.fail(\n new BridgeError({\n code: \"source_mismatch\",\n message: \"Flow source revision does not match the pinned launch\",\n retryable: false\n })\n )\n }\n const plan = yield* control.plan({\n flowId: input.flowId,\n input: input.payload,\n idempotencyKey: idempotencyKey(input, \"plan\")\n })\n // Graphs are optional for valid Flow declarations. Only a verified\n // native catalog snapshot can supply the missing provenance; the\n // configured/wire identity by itself cannot stand in for that proof.\n const plannedSource = plan.graph?.sourceRevision ?? config.verifiedCatalogSourceRevision\n if (plannedSource !== input.sourceRevision) {\n return yield* Effect.fail(\n new BridgeError({\n code: \"source_mismatch\",\n message: \"Flow source revision does not match the immutable request\",\n retryable: false\n })\n )\n }\n // A pinned launch runs nothing but its pin: a plan with no execution\n // identity, or the pinned flow planned as other code, never starts.\n if (\n input.pin !== undefined &&\n (plan.executionDigest === undefined ||\n (input.pin.flow === input.flowId && plan.executionDigest !== input.pin.executionDigest))\n ) {\n return yield* Effect.fail(\n new BridgeError({\n code: \"source_mismatch\",\n message: \"Flow execution digest does not match the pinned launch\",\n retryable: false\n })\n )\n }\n const receipt = yield* control.run({\n _tag: \"Plan\",\n planId: plan.planId,\n digest: plan.digest,\n envelope: plan.envelope,\n idempotencyKey: idempotencyKey(input, `run:${input.runId ?? input.attempt}`),\n principal,\n ...(input.runId === undefined ? {} : { reservedRunId: input.runId })\n })\n return {\n operation: input.operation,\n applicationRequestId: input.applicationRequestId,\n ownerGeneration: input.ownerGeneration,\n runtimeArtifactDigest: config.runtimeArtifactDigest,\n sourceRevision: input.sourceRevision,\n planId: plan.planId,\n planDigest: plan.digest,\n ...(plan.executionDigest === undefined ? {} : { executionDigest: plan.executionDigest }),\n envelope: plan.envelope,\n approval: plan.approval,\n receipt\n } as const\n }\n case \"approve\":\n case \"deny\": {\n const request = {\n ...input.approval,\n idempotencyKey: idempotencyKey(input, input.operation),\n principal\n }\n const receipt = yield* input.operation === \"approve\" ? control.approve(request) : control.deny(request)\n return { operation: input.operation, applicationRequestId: input.applicationRequestId, receipt } as const\n }\n case \"signal\": {\n const receipt = yield* control.signal({\n runId: input.runId,\n signal: input.signal,\n idempotencyKey: idempotencyKey(input, \"signal\"),\n principal\n })\n return { operation: input.operation, applicationRequestId: input.applicationRequestId, receipt } as const\n }\n case \"steer\": {\n const receipt = yield* control.steer({\n runId: input.runId,\n idempotencyKey: idempotencyKey(input, \"steer\"),\n ...(input.version === undefined ? {} : { version: input.version }),\n message: {\n ...input.steer,\n runId: input.runId,\n messageId: input.messageId,\n createdAt: input.createdAt,\n ...(input.attribution === undefined ? {} : { attribution: input.attribution }),\n principal\n }\n })\n return { operation: input.operation, applicationRequestId: input.applicationRequestId, receipt } as const\n }\n // This authenticated host bridge is not a catalog or public Control\n // verb. The executor validates the completed native child and resumes\n // its retained parent to settle from that child's committed result.\n case \"complete\": {\n const executor = yield* Effect.serviceOption(ControlExecutor)\n const complete = config.requestComplete ??\n (executor._tag === \"Some\" ? executor.value.requestComplete : undefined)\n if (complete === undefined) {\n return yield* Effect.fail(\n new BridgeError({\n code: \"unavailable\",\n message: \"Completed-module settlement is unavailable\",\n retryable: true\n })\n )\n }\n const receipt = yield* complete({ runId: input.runId, receiptId: idempotencyKey(input, \"complete\") })\n return { operation: input.operation, applicationRequestId: input.applicationRequestId, receipt } as const\n }\n case \"cancel\":\n case \"resume\": {\n const request = {\n runId: input.runId,\n idempotencyKey: idempotencyKey(input, input.operation),\n ...(input.reason === undefined ? {} : { reason: input.reason }),\n principal\n }\n const receipt = yield* input.operation === \"cancel\" ? control.cancel(request) : control.resume(request)\n return { operation: input.operation, applicationRequestId: input.applicationRequestId, receipt } as const\n }\n }\n })\n\nconst cursorPosition = (cursor: string | undefined): Effect.Effect<WatchCursor | undefined, BridgeError> => {\n if (cursor === undefined || cursor === \"\") return Effect.succeed(undefined)\n const match = observationCursorPattern.exec(cursor)\n const sequence = Number(match?.[1] ?? match?.[2])\n const offset = match?.[3] === undefined ? undefined : Number(match[3])\n const valid = (value: number) => Number.isSafeInteger(value) && value >= 0 && value < Number.MAX_SAFE_INTEGER\n return match !== null && valid(sequence) && (offset === undefined || valid(offset))\n ? Effect.succeed({ sequence, ...(offset === undefined ? {} : { offset }) })\n : Effect.fail(\n new BridgeError({\n code: \"invalid_request\",\n message: \"Observation cursor is invalid or out of range\",\n retryable: false\n })\n )\n}\n\nconst encodedCursor = (cursor: WatchCursor): string =>\n cursor.offset === undefined ? String(cursor.sequence) : `v1:${cursor.sequence}:${cursor.offset}`\n\n/**\n * Reads a bounded event replay and current canonical run projection.\n * @since 1.0.0\n * @category constructors\n */\nexport const observe = (control: Control[\"Service\"], input: ObserveRequest, receipts?: Config[\"commandReceipt\"]) =>\n Effect.gen(function*() {\n const after = yield* cursorPosition(input.afterCursor)\n const limit = Math.min(input.limit ?? defaultEventLimit, maximumEventLimit)\n const listed = yield* control.list({ _tag: \"runs\", filters: { runId: input.runId }, limit: 1 })\n const summary = listed._tag === \"runs\" ? listed.items[0] : undefined\n if (summary === undefined) {\n return yield* Effect.fail(\n new BridgeError({ code: \"run_not_found\", message: \"Runtime execution was not found\", retryable: true })\n )\n }\n const events = Array.from(\n yield* Stream.runCollect(Stream.take(\n control.watch({\n runId: input.runId,\n ...(after === undefined\n ? {}\n : after.offset === undefined\n ? { afterSequence: after.sequence }\n : { afterCursor: after }),\n follow: false\n }),\n limit + 1\n ))\n )\n const page = events.slice(0, limit)\n const last = page.at(-1)\n // Typed Flow results use the same committed root projection as the app.\n // A terminal status alone never supplies a result, and a bounded event\n // page cannot reconstruct a root result that precedes its cursor.\n let finalOutput: string | undefined\n let failure: {\n readonly failureFault?: Fault.Class\n readonly failureTag?: string\n readonly failureMessage?: string\n } = {}\n if (terminal.has(summary.status)) {\n const projections = yield* Projections.make(control)\n const snapshot = yield* projections.snapshot({ _tag: \"run-summary\", runId: input.runId })\n const row = snapshot.rows.find(Schema.is(RunSummaryRow))\n if (\n row === undefined || row.runId !== summary.runId || row.flowId !== summary.flowId ||\n row.status !== summary.status || row.planId !== summary.planId || row.planDigest !== summary.planDigest\n ) {\n return yield* Effect.fail(\n new BridgeError({ code: \"internal\", message: \"Terminal result observation changed\", retryable: true })\n )\n }\n finalOutput = row.finalOutput\n failure = {\n ...(row.failureFault === undefined ? {} : { failureFault: row.failureFault }),\n ...(row.failureTag === undefined ? {} : { failureTag: row.failureTag }),\n ...(row.failureMessage === undefined ? {} : { failureMessage: row.failureMessage })\n }\n }\n // Keep the private receipt out of every repository-controlled projection.\n const hostSummary = yield* Schema.decodeUnknownEffect(RunSummary)(summary)\n const commandReceipt = receipts === undefined ? undefined : yield* receipts(input.runId)\n if (commandReceipt !== undefined && commandReceipt.runId !== input.runId) {\n return yield* Effect.fail(\n new BridgeError({ code: \"internal\", message: \"Host command receipt names another run\", retryable: false })\n )\n }\n return {\n run: {\n ...hostSummary,\n ...(commandReceipt === undefined ? {} : { commandReceipt }),\n ...(finalOutput === undefined ? {} : { finalOutput }),\n ...failure\n },\n events: page,\n nextCursor: last === undefined\n ? input.afterCursor ?? \"\"\n : encodedCursor(last.cursor ?? { sequence: last.sequence }),\n hasMore: events.length > limit,\n terminal: terminal.has(summary.status)\n }\n })\n\n// Disposable raw journal prefixes for Inspect. This stores no run state: the\n// existing monitor fold still derives every answer from journal records. Bound\n// retention across all runs of one control service, and rebuild after eviction.\nconst monitorJournals = new WeakMap<\n Control[\"Service\"],\n Map<string, {\n readonly records: ReadonlyArray<ControlEvent>\n readonly bytes: number\n }>\n>()\nconst monitorJournalBytes = 64 * 1024 * 1024\n\n/** Read an existing run and its committed journal without invoking any execution door.\n * @since 1.0.0\n * @category constructors\n */\nexport const monitor = (control: Control[\"Service\"], runId: string, at?: number) =>\n Effect.gen(function*() {\n const listed = yield* control.list({ _tag: \"runs\", filters: { runId }, limit: 1 })\n const run = listed._tag === \"runs\" ? listed.items[0] : undefined\n if (run === undefined || run.runId !== runId) {\n return yield* new BridgeError({\n code: \"run_not_found\",\n message: \"Runtime execution was not found\",\n retryable: false\n })\n }\n const cache = monitorJournals.get(control) ??\n new Map<string, { readonly records: ReadonlyArray<ControlEvent>; readonly bytes: number }>()\n monitorJournals.set(control, cache)\n const cached = cache.get(runId)\n const last = cached?.records.at(-1)?.sequence\n // Replay the final entry because one entry may expand into several events.\n const consumed = last === undefined ? 0 : cached!.records.filter((row) => row.sequence === last).length\n let skipped = 0\n const suffix = Array.from(\n yield* Stream.runCollect(\n control.watch({\n runId,\n follow: false,\n ...(last === undefined || last === 0 ? {} : { afterSequence: last - 1 })\n }).pipe(\n Stream.filter((row) =>\n last === undefined || row.sequence > last || row.sequence === last && skipped++ >= consumed\n ),\n Stream.take(Projections.maxEventsScanned + 1)\n )\n )\n )\n const records = [...(cached?.records ?? []), ...suffix]\n if (records.length > Projections.maxEventsScanned) {\n return yield* new BridgeError({\n code: \"resource_limit\",\n message: \"Run journal exceeds the inspection limit\",\n retryable: false\n })\n }\n const bytes = (cached?.bytes ?? 0) +\n suffix.reduce((sum, row) => sum + new TextEncoder().encode(JSON.stringify(row)).byteLength, 0)\n const current = cache.get(runId)\n // A slower reader cannot overwrite a longer committed prefix.\n if (bytes <= monitorJournalBytes && (current === undefined || current.records.length <= records.length)) {\n cache.delete(runId)\n cache.set(runId, { records, bytes })\n let total = [...cache.values()].reduce((sum, entry) => sum + entry.bytes, 0)\n while (cache.size > 32 || total > monitorJournalBytes) {\n const oldest = cache.keys().next().value!\n total -= cache.get(oldest)!.bytes\n cache.delete(oldest)\n }\n }\n const folded = monitorFromJournal({ runId, flowId: run.flowId, status: run.status }, records, at)\n // The journal is read page by page when its tab opens (run-events). Only a\n // replay frame carries its own journal prefix. The extent bounds the run.\n let start = Infinity\n let end = 0\n for (const row of records) {\n if (row.occurredAt > 0) {\n start = Math.min(start, row.occurredAt)\n end = Math.max(end, row.occurredAt)\n }\n }\n const value: Partial<typeof folded> & Omit<typeof folded, \"journal\"> & { extent?: { start: string; end: string } } =\n {\n ...folded,\n ...(end === 0 ? {} : { extent: { start: new Date(start).toISOString(), end: new Date(end).toISOString() } })\n }\n if (at === undefined) delete value.journal\n if (new TextEncoder().encode(JSON.stringify(value)).byteLength > Projections.maxProjectionBytes) {\n return yield* new BridgeError({\n code: \"resource_limit\",\n message: \"Run monitor exceeds the inspection limit\",\n retryable: false\n })\n }\n return value\n })\n\n/**\n * Successful command response on the JSON wire.\n * @since 1.0.0\n * @category models\n */\nexport const CommandResponse = Schema.Struct({\n protocol: Schema.Literal(protocol),\n ok: Schema.Literal(true),\n value: Schema.Struct({\n operation: Schema.String,\n applicationRequestId: Schema.String,\n ownerGeneration: Schema.optional(PositiveSafeInteger),\n runtimeArtifactDigest: Schema.optional(Sha256),\n sourceRevision: Schema.optional(SourceRevision),\n planId: Schema.optional(Schema.String),\n planDigest: Schema.optional(Sha256),\n executionDigest: Schema.optional(Sha256),\n envelope: Schema.optional(Schema.Json),\n approval: Schema.optional(ApprovalPayload),\n receipt: Receipt\n })\n})\n\n/**\n * Successful observation response on the JSON wire.\n * @since 1.0.0\n * @category models\n */\nexport const ObserveResponse = Schema.Struct({\n protocol: Schema.Literal(protocol),\n ok: Schema.Literal(true),\n value: Schema.Struct({\n run: Schema.Struct({\n ...RunSummary.fields,\n finalOutput: Schema.optional(Schema.String),\n failureFault: Schema.optional(Fault.Class),\n failureTag: Schema.optional(Schema.String),\n failureMessage: Schema.optional(Schema.String),\n commandReceipt: Schema.optionalKey(CommandReceipt)\n }),\n events: Schema.Array(ControlEvent),\n nextCursor: Schema.String,\n hasMore: Schema.Boolean,\n terminal: Schema.Boolean\n })\n})\n\n/**\n * Stable sanitized failure response on the JSON wire.\n * @since 1.0.0\n * @category models\n */\nexport const ErrorResponse = Schema.Struct({\n protocol: Schema.Literal(protocol),\n ok: Schema.Literal(false),\n error: Schema.Struct({ code: Schema.String, message: Schema.String, retryable: Schema.Boolean })\n})\n\nconst errorResponse = (cause: unknown) => {\n const known = Schema.is(ControlError.ControlErrorSchema)(cause)\n const code = cause instanceof BridgeError || known ? cause.code : \"internal\"\n const retryable = cause instanceof BridgeError\n ? cause.retryable\n : cause instanceof ControlError.TransportError\n ? cause.retryable\n : retryableCodes.has(code)\n // Control errors can contain storage paths, SQL diagnostics, or executor\n // output. The bridge publishes their stable code, never that backend text.\n const message = cause instanceof BridgeError ? cause.message : \"Runtime bridge failed\"\n const status = code === \"unauthorized\" ?\n 401\n : notFoundCodes.has(code) ?\n 404\n : conflictCodes.has(code) ?\n 409\n : retryable ?\n 503\n : code === \"internal\" ?\n 500\n : 400\n return HttpServerResponse.jsonUnsafe({ protocol, ok: false, error: { code, message, retryable } }, { status })\n}\n\n/**\n * Answers a failed bridge request with its sanitized response, logging it first.\n *\n * The wire carries only the stable code. The operator log carries the full\n * cause of every failure the caller did not cause, so a launch that failed in\n * storage or in the executor can be diagnosed from the host.\n */\nconst respondToFailure = (operation: \"runtime-bridge.command\" | \"runtime-bridge.observe\") => (cause: unknown) => {\n const response = errorResponse(cause)\n if (cause instanceof BridgeError) return Effect.succeed(response)\n const code = Schema.is(ControlError.ControlErrorSchema)(cause) ? cause.code : \"internal\"\n return Effect.logError({ message: \"Runtime bridge request failed\", operation, code, cause }).pipe(\n Effect.as(response)\n )\n}\n\nconst readJson = Effect.gen(function*() {\n const request = yield* HttpServerRequest.HttpServerRequest\n const text = yield* request.text\n return yield* Effect.try({\n try: () => JSON.parse(text) as unknown,\n catch: () => new BridgeError({ code: \"invalid_request\", message: \"Request body must be JSON\", retryable: false })\n })\n})\n\nconst authenticated = <A, E, R>(\n config: Config,\n effect: (principal: Principal) => Effect.Effect<A, E, R>\n) =>\n Effect.gen(function*() {\n const request = yield* HttpServerRequest.HttpServerRequest\n const principal = yield* config.authenticate(request.headers)\n return yield* effect(principal)\n })\n\n/**\n * Mounts the authenticated JSON bridge beside the existing gateway RPCs.\n * @since 1.0.0\n * @category layers\n */\nexport const layer = (config: Config) => {\n const command = authenticated(config, (principal) =>\n Effect.gen(function*() {\n const body = yield* readJson\n const input = yield* decodeCommand(body).pipe(Effect.mapError(() =>\n new BridgeError({\n code: \"invalid_request\",\n message: \"Request does not match the runtime bridge contract\",\n retryable: false\n })\n ))\n const control = yield* Control\n const value = yield* execute(config, control, principal, input)\n return HttpServerResponse.jsonUnsafe({ protocol, ok: true, value })\n })).pipe(\n Effect.catch(respondToFailure(\"runtime-bridge.command\")),\n Effect.withSpan(\"runtime-bridge.command\")\n )\n\n const observation = authenticated(config, () =>\n Effect.gen(function*() {\n const body = yield* readJson\n const input = yield* decodeObserve(body).pipe(Effect.mapError(() =>\n new BridgeError({\n code: \"invalid_request\",\n message: \"Request does not match the observation contract\",\n retryable: false\n })\n ))\n const control = yield* Control\n const value = yield* observe(control, input, config.commandReceipt)\n return HttpServerResponse.jsonUnsafe({ protocol, ok: true, value })\n })).pipe(\n Effect.catch(respondToFailure(\"runtime-bridge.observe\")),\n Effect.withSpan(\"runtime-bridge.observe\")\n )\n\n const inspection = authenticated(config, () =>\n Effect.gen(function*() {\n const body = yield* readJson\n const input = yield* Schema.decodeUnknownEffect(Schema.Struct({\n protocol: Schema.Literal(protocol),\n runId: Schema.NonEmptyString,\n at: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)))\n }))(body).pipe(Effect.mapError(() =>\n new BridgeError({ code: \"invalid_request\", message: \"Invalid monitor request\", retryable: false })\n ))\n const control = yield* Control\n return HttpServerResponse.jsonUnsafe({\n protocol,\n ok: true,\n value: yield* monitor(control, input.runId, input.at)\n })\n })).pipe(Effect.catch(respondToFailure(\"runtime-bridge.observe\")))\n\n return HttpRouter.add(\"POST\", \"/runtime/v1/command\", command).pipe(\n Layer.merge(HttpRouter.add(\"POST\", \"/runtime/v1/monitor\", inspection)),\n Layer.merge(HttpRouter.add(\"POST\", \"/runtime/v1/observe\", observation))\n )\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,qBAAwB;AACxB,mBAA8B;AAC9B,6BAAwE;AAExE,2BAOO;AACP,YAAuB;AACvB,oBAA8C;AAC9C,kBAAkE;AAClE,+BAA8B;AAC9B,kBAA6B;AAC7B,sBAAmC;AAO5B,MAAM,WAAW;AAExB,MAAM,SAAS,qBAAO,OAAO,MAAM,qBAAO,UAAU,gBAAgB,CAAC;AACrE,MAAM,iBAAiB,qBAAO,OAAO,MAAM,qBAAO,UAAU,gBAAgB,CAAC;AAC7E,MAAM,sBAAsB,qBAAO,IAAI;AAAA,EACrC,qBAAO,cAAc,CAAC;AAAA,EACtB,qBAAO,oBAAoB,OAAO,gBAAgB;AACpD;AACA,MAAM,YAAY,qBAAO,eAAe,MAAM,qBAAO,YAAY,IAAI,CAAC;AAGtE,MAAM,2BAA2B;AAO1B,MAAM,WAAW,qBA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AAS,qBAAO,IAAI,MAAM,qBAAO,uBAAuB,CAAC,CAAC,CAAC;AAAA,IACxE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,qBAAO;AAAA,MAAS,MAC7B,IAAI,YAAY,EAAE,MAAM,mBAAmB,SAAS,2BAA2B,WAAW,MAAM,CAAC;AAAA,IACnG,CAAC;AACD,UAAM,UAAU,OAAO;AACvB,WAAO,+BAAmB,WAAW;AAAA,MACnC;AAAA,MACA,IAAI;AAAA,MACJ,OAAO,OAAO,QAAQ,SAAS,MAAM,OAAO,MAAM,EAAE;AAAA,IACtD,CAAC;AAAA,EACH,CAAC,CAAC,EAAE,KAAK,qBAAO,MAAM,iBAAiB,wBAAwB,CAAC,CAAC;AAEnE,SAAO,uBAAW,IAAI,QAAQ,uBAAuB,OAAO,EAAE;AAAA,IAC5D,oBAAM,MAAM,uBAAW,IAAI,QAAQ,uBAAuB,UAAU,CAAC;AAAA,IACrE,oBAAM,MAAM,uBAAW,IAAI,QAAQ,uBAAuB,WAAW,CAAC;AAAA,EACxE;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
4
|
import { Layer } from "effect";
|
|
5
|
-
import type { HttpServer } from "effect/
|
|
5
|
+
import type { HttpServer } from "effect/http/HttpServer";
|
|
6
6
|
import { GatewayError } from "../GatewayError.ts";
|
|
7
7
|
import type * as GatewayServer from "../GatewayServer.ts";
|
|
8
8
|
import * as NativeGateway from "../internal/NativeGateway.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BunGateway.d.ts","sourceRoot":"","sources":["../../../src/bun/BunGateway.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAiB,KAAK,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"BunGateway.d.ts","sourceRoot":"","sources":["../../../src/bun/BunGateway.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAiB,KAAK,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,KAAK,aAAa,MAAM,qBAAqB,CAAA;AACzD,OAAO,KAAK,aAAa,MAAM,8BAA8B,CAAA;AAE7D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAE/E;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAC9B,aAAa,CAAC,aAAa,EAC3B,MAAM,GAAG,MAAM,GAAG,cAAc,GAAG,QAAQ,GAAG,YAAY,GAAG,iBAAiB,GAAG,qBAAqB,CACvG,CAAA;AAyBD;;;GAGG;AACH,eAAO,MAAM,KAAK,GAAI,QAAQ,aAAa,CAAC,MAAM,EAAE,UAAS,aAAkD,sQACtF,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/bun/BunGateway.ts"],
|
|
4
|
-
"sourcesContent": ["/** Bun HTTP adapter for the same authenticated workspace gateway protocol.\n * @since 1.0.0\n */\n\nimport * as BunHttpServer from \"@effect/platform-bun/BunHttpServer\"\nimport { Cause, Effect, Layer } from \"effect\"\nimport type { HttpServer } from \"effect/
|
|
4
|
+
"sourcesContent": ["/** Bun HTTP adapter for the same authenticated workspace gateway protocol.\n * @since 1.0.0\n */\n\nimport * as BunHttpServer from \"@effect/platform-bun/BunHttpServer\"\nimport { Cause, Effect, Layer } from \"effect\"\nimport type { HttpServer } from \"effect/http/HttpServer\"\nimport type { ServeError } from \"effect/http/HttpServerError\"\nimport { GatewayError } from \"../GatewayError.ts\"\nimport type * as GatewayServer from \"../GatewayServer.ts\"\nimport * as NativeGateway from \"../internal/NativeGateway.ts\"\n\nexport { bearerPrincipal, scopedPrincipal } from \"../internal/NativeGateway.ts\"\n\n/** TCP bind and existing gateway policy options supported by the Bun host.\n * @since 1.0.0\n * @category models\n */\nexport type ServerOptions = Pick<\n NativeGateway.ServerOptions,\n \"host\" | \"port\" | \"allowedHosts\" | \"listen\" | \"credential\" | \"heartbeatMillis\" | \"maxRequestBodyBytes\"\n>\n\nconst native = NativeGateway.makeLayer((options) =>\n BunHttpServer.layerServer({\n // Shared listenOptions has already supplied and admitted the bind host.\n hostname: options.host!,\n port: options.port ?? 7331\n }).pipe(Layer.catchCause((cause): Layer.Layer<HttpServer, ServeError | GatewayError> => {\n const failure = Cause.squash(cause)\n const code = typeof failure === \"object\" && failure !== null && \"code\" in failure ? failure.code : undefined\n if (Cause.hasInterruptsOnly(cause) || ![\"EADDRINUSE\", \"EACCES\", \"EADDRNOTAVAIL\"].includes(String(code))) {\n return Layer.effectContext<HttpServer, ServeError | GatewayError, never>(Effect.failCause(cause))\n }\n // The errno is safe to keep: NativeGateway logs it for the operator and\n // strips it from the refusal every bearer holder sees.\n return Layer.effectContext<HttpServer, ServeError | GatewayError, never>(Effect.fail(\n new GatewayError({\n code: \"bind_failed\",\n message: \"The gateway socket could not be bound\",\n cause: { _tag: \"BunServeError\", code: String(code) }\n })\n ))\n }))\n)\n\n/** Serves the existing HTTP/WebSocket gateway using Bun.serve in the caller's scope.\n * @since 1.0.0\n * @category layers\n */\nexport const layer = (health: GatewayServer.Health, options: ServerOptions = NativeGateway.defaultServerOptions) =>\n native(health, options)\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAA+B;AAC/B,oBAAqC;AAGrC,0BAA6B;AAE7B,oBAA+B;AAE/B,2BAAiD;AAWjD,MAAM,SAAS,cAAc;AAAA,EAAU,CAAC,YACtC,cAAc,YAAY;AAAA;AAAA,IAExB,UAAU,QAAQ;AAAA,IAClB,MAAM,QAAQ,QAAQ;AAAA,EACxB,CAAC,EAAE,KAAK,oBAAM,WAAW,CAAC,UAA8D;AACtF,UAAM,UAAU,oBAAM,OAAO,KAAK;AAClC,UAAM,OAAO,OAAO,YAAY,YAAY,YAAY,QAAQ,UAAU,UAAU,QAAQ,OAAO;AACnG,QAAI,oBAAM,kBAAkB,KAAK,KAAK,CAAC,CAAC,cAAc,UAAU,eAAe,EAAE,SAAS,OAAO,IAAI,CAAC,GAAG;AACvG,aAAO,oBAAM,cAA4D,qBAAO,UAAU,KAAK,CAAC;AAAA,IAClG;AAGA,WAAO,oBAAM,cAA4D,qBAAO;AAAA,MAC9E,IAAI,iCAAa;AAAA,QACf,MAAM;AAAA,QACN,SAAS;AAAA,QACT,OAAO,EAAE,MAAM,iBAAiB,MAAM,OAAO,IAAI,EAAE;AAAA,MACrD,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC,CAAC;AACJ;AAMO,MAAM,QAAQ,CAAC,QAA8B,UAAyB,cAAc,yBACzF,OAAO,QAAQ,OAAO;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { ControlRpcs } from "@smthrs/control";
|
|
21
21
|
import { Effect, Layer } from "effect";
|
|
22
|
-
import type { HttpServer } from "effect/
|
|
23
|
-
import type { ServeError } from "effect/
|
|
22
|
+
import type { HttpServer } from "effect/http/HttpServer";
|
|
23
|
+
import type { ServeError } from "effect/http/HttpServerError";
|
|
24
24
|
import type { ListenOptions } from "node:net";
|
|
25
25
|
import { GatewayError } from "../GatewayError.ts";
|
|
26
26
|
import * as GatewayServer from "../GatewayServer.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeGateway.d.ts","sourceRoot":"","sources":["../../../src/internal/NativeGateway.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,WAAW,E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
43
|
var import_control = require("@smthrs/control");
|
|
44
44
|
var import_effect = require("effect");
|
|
45
|
-
var import_http = require("effect/
|
|
46
|
-
var import_rpc = require("effect/
|
|
45
|
+
var import_http = require("effect/http");
|
|
46
|
+
var import_rpc = require("effect/rpc");
|
|
47
47
|
var import_GatewayError = require("../GatewayError.js");
|
|
48
48
|
var GatewayServer = __toESM(require("../GatewayServer.js"), 1);
|
|
49
49
|
const defaultServerOptions = { host: "127.0.0.1", port: 7331 };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/internal/NativeGateway.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Shared native gateway bind policy, credential policy,\n * and the one composition a `smithers serve` verb hosts.\n *\n * Two rules decide whether a bind is allowed, and both fail closed:\n *\n * 1. A non-loopback host requires an explicit `listen` opt-in. Binding\n * `0.0.0.0` because a port was free is how a workspace gateway ends up on\n * a shared network by accident.\n * 2. A non-loopback bind requires a bearer credential. The control plane can\n * launch runs, cancel them, and approve capability grants; reachable from\n * another machine, an unauthenticated one is a remote execution service.\n *\n * A loopback bind with no network credential allows anonymous reads; approval\n * decisions require the session operator token. Ingress still checks Host and\n * Origin so a web page cannot exercise the loopback endpoint.\n *\n * @since 1.0.0\n */\n\nimport { ControlRpcs, ScopedToken } from \"@smthrs/control\"\nimport { Effect, Layer } from \"effect\"\nimport { HttpRouter } from \"effect/unstable/http\"\nimport type { HttpServer } from \"effect/unstable/http/HttpServer\"\nimport type { ServeError } from \"effect/unstable/http/HttpServerError\"\nimport { RpcSerialization } from \"effect/unstable/rpc\"\nimport type { ListenOptions } from \"node:net\"\nimport { GatewayError, settingRefusal } from \"../GatewayError.ts\"\nimport * as GatewayServer from \"../GatewayServer.ts\"\nimport type * as RuntimeBridge from \"../RuntimeBridge.ts\"\n\n/**\n * Where the gateway binds, and whether a non-loopback bind was asked for.\n *\n * @since 1.0.0\n * @category models\n */\nexport interface ServerOptions extends ListenOptions {\n /** Additional accepted Host header names (without ports), for network or proxy access. */\n readonly allowedHosts?: ReadonlyArray<string> | undefined\n /** The `--listen` opt-in required for a non-loopback host. */\n readonly listen?: boolean | undefined\n /** The shared bearer credential, required for a non-loopback bind. */\n readonly credential?: string | undefined\n /** Per-session approval token on credential-free loopback. Read calls remain anonymous. */\n readonly operatorToken?: string | undefined\n /**\n * How often an idle followed `Watch` on `/rpc/ws` and an idle followed\n * `Projection.Subscribe` on `/projections/ws` emit a keepalive frame. Unset,\n * both run at `Projections.heartbeatIntervalMillis` unless the supplied\n * `Projections` service was built with its own cadence. A relay with an idle\n * cut shorter than that one needs a shorter cadence here.\n */\n readonly heartbeatMillis?: number | undefined\n /** Maximum bytes accepted on one HTTP RPC request. Default one MiB. */\n readonly maxRequestBodyBytes?: number | undefined\n /** Immutable identity of an opt-in packaged Flow runtime bridge. */\n readonly runtimeBridge?: Omit<RuntimeBridge.Config, \"authenticate\"> | undefined\n}\n\n/**\n * The default bind: loopback, port 7331, no credential.\n *\n * @since 1.0.0\n * @category models\n */\nexport const defaultServerOptions: ServerOptions = { host: \"127.0.0.1\", port: 7331 }\n\n/**\n * Whether a host names this machine only.\n *\n * @param host the host to classify\n * @since 1.0.0\n * @category predicates\n */\nexport const isLoopbackHost = (host: string): boolean => GatewayServer.loopbackHostNames.includes(host)\n\n/**\n * The typed refusal a requested bind earns, or `undefined` when it is allowed.\n *\n * Every start-time rule this module enforces answers here as a `bind_failed`\n * `GatewayError`, so a host that wants to report a refusal rather than crash on\n * one asks this before it composes a layer. {@link listenOptions} and\n * {@link layer} fail with exactly what this returns.\n *\n * @param options the requested bind\n * @since 1.0.0\n * @category constructors\n */\nexport const bindRefusal = (options: ServerOptions): GatewayError | undefined => {\n const setting = settingRefusal(\"The gateway keepalive cadence\", options.heartbeatMillis) ??\n settingRefusal(\"The gateway request body limit\", options.maxRequestBodyBytes)\n if (setting !== undefined) return setting\n // The bridge authenticates only with the bearer credential, even on\n // loopback, so a bridge without one would answer 401 to every request.\n if (options.runtimeBridge !== undefined && (options.credential === undefined || options.credential === \"\")) {\n return new GatewayError({\n code: \"bind_failed\",\n message: \"Refusing to enable the runtime bridge without a bearer credential\"\n })\n }\n const host = options.host ?? \"127.0.0.1\"\n if (isLoopbackHost(host)) return undefined\n if (options.listen !== true) {\n return new GatewayError({\n code: \"bind_failed\",\n message: `Refusing non-loopback gateway bind ${host} without an explicit --listen opt-in`\n })\n }\n if (options.credential === undefined || options.credential === \"\") {\n return new GatewayError({\n code: \"bind_failed\",\n message: `Refusing non-loopback gateway bind ${host} without a bearer credential`\n })\n }\n return undefined\n}\n\n/**\n * Applies the bind policy, returning the admitted Node options or a typed\n * `bind_failed` refusal.\n *\n * @param options the requested bind\n * @since 1.0.0\n * @category constructors\n */\nexport const listenOptions = (options: ServerOptions): Effect.Effect<ListenOptions, GatewayError> =>\n Effect.suspend(() => {\n const refusal = bindRefusal(options)\n if (refusal !== undefined) return Effect.fail(refusal)\n // `credential`, `listen`, and the keepalive cadence are this module's, not\n // `node:net`'s: they are named here so the rest is exactly a bind.\n const {\n allowedHosts: _allowedHosts,\n credential: _credential,\n heartbeatMillis: _cadence,\n listen: _listen,\n maxRequestBodyBytes: _maxBody,\n runtimeBridge: _runtimeBridge,\n ...node\n } = options\n return Effect.succeed({ ...node, host: node.host ?? \"127.0.0.1\" })\n })\n\n/**\n * The authentication both RPC mounts run under.\n *\n * A configured credential authenticates every request that presents it and\n * stamps the same server-owned principal. A scoped token minted under that\n * credential (`@smthrs/control` `ScopedToken`) authenticates only the\n * procedures, run, or flow it names, until it expires, and stamps\n * {@link scopedPrincipal}. With no credential the composition is\n * loopback-only (see {@link listenOptions}) and every request runs as the\n * anonymous read principal. A session operator token alone stamps the local\n * operator for approval decisions; without it approvals are unauthorized.\n *\n * @param options the requested bind\n * @since 1.0.0\n * @category layers\n */\nexport const layerAuth = (options: ServerOptions): Layer.Layer<ControlRpcs.ControlAuth> =>\n options.credential === undefined || options.credential === \"\"\n ? ControlRpcs.layerAuth({\n authenticate: (headers) => {\n const token = options.operatorToken\n if (token === undefined || token === \"\") {\n return Effect.succeed({ id: \"loopback\", kind: \"anonymous\", stampedAt: 0 })\n }\n return ControlRpcs.bearerAuthenticator({\n token,\n principal: { id: \"local\", kind: \"operator\" }\n }).authenticate(headers).pipe(\n Effect.catchTag(\n \"/control/Unauthorized\",\n () => Effect.succeed({ id: \"loopback\", kind: \"anonymous\", stampedAt: 0 })\n )\n )\n }\n }, gatewayRunVisibility)\n : ControlRpcs.layerAuth(credentialAuthenticator(options.credential), gatewayRunVisibility)\n\n/**\n * Every identity this gateway stamps reads every run. They all stand for the\n * one operator who holds the gateway's credential, or the machine's loopback\n * user when there is none; a scoped token is that operator's grant, confined\n * by the procedures, run, or flow it names rather than by who launched a run.\n */\nconst gatewayRunVisibility: ControlRpcs.AuthOptions = { seesAllRuns: () => true }\n\n/**\n * The bearer credential itself, or a scoped token minted under it.\n *\n * The runtime bridge deliberately does not use this: it accepts the bearer\n * alone, because a scoped token names control procedures and the bridge's\n * versioned commands are not those.\n */\nconst credentialAuthenticator = (credential: string): ControlRpcs.Authenticator =>\n ControlRpcs.anyAuthenticator([\n ControlRpcs.bearerAuthenticator({ token: credential, principal: bearerPrincipal }),\n ScopedToken.authenticator({ key: credential, principal: scopedPrincipal })\n ])\n\n/**\n * The identity stamped only after this gateway verifies its configured token.\n * Hosts may explicitly delegate operator decisions to this exact identity.\n * @category constants\n * @since 1.0.0\n */\nexport const bearerPrincipal = Object.freeze({ id: \"gateway\", kind: \"bearer\" })\n\n/**\n * The protected mounts a scoped token may reach: those guarded in band by\n * `ControlAuth`, which checks each frame's procedure against the token, and\n * the ticket exchange that opens their sockets.\n * @category constants\n * @since 1.0.0\n */\nexport const scopedTokenPaths: ReadonlyArray<string> = [\n \"/rpc\",\n \"/rpc/ws\",\n \"/projections\",\n \"/projections/ws\",\n \"/auth/ticket\"\n]\n\n/**\n * The identity stamped after this gateway verifies a scoped token minted\n * under its configured credential. It is its own kind so that delegating\n * approval to {@link bearerPrincipal} does not delegate it to every token\n * minted from the bearer; a host that wants a scoped `approve:runs` token to\n * decide delegates to this identity explicitly.\n * @category constants\n * @since 1.0.0\n */\nexport const scopedPrincipal = Object.freeze({ id: \"gateway\", kind: \"scoped\" })\n\n/**\n * The ingress policy a requested bind runs behind.\n *\n * The accepted Host names are the loopback names, the operator's\n * `allowedHosts`, and the concrete bind host itself, so `--host 192.168.1.10`\n * is reachable at that address without naming it twice. A wildcard bind\n * (`0.0.0.0` or `::`) adds nothing: every interface is not a Host name, and\n * the operator names the reachable ones. Protected paths are authenticated\n * before any request body is read.\n *\n * @param options the requested bind\n * @since 1.0.0\n * @category constructors\n */\nexport const ingressOptions = (options: ServerOptions): GatewayServer.IngressOptions => {\n const maxRequestBodyBytes = options.maxRequestBodyBytes\n const host = options.host ?? \"127.0.0.1\"\n const allowedHosts = [...GatewayServer.loopbackHostHeaderNames, ...options.allowedHosts ?? []]\n const bindAuthority = URL.parse(`http://${host.includes(\":\") ? `[${host}]` : host}`)\n if (host !== \"0.0.0.0\" && host !== \"::\" && bindAuthority !== null && !allowedHosts.includes(bindAuthority.hostname)) {\n allowedHosts.push(bindAuthority.hostname)\n }\n if (options.credential === undefined || options.credential === \"\") {\n return {\n loopbackOnly: true,\n ...(maxRequestBodyBytes === undefined ? {} : { maxRequestBodyBytes }),\n allowedHosts\n }\n }\n // The edge knows no call, so a scoped token passes here on its signature\n // and expiry, and only toward the mounts whose every frame `ControlAuth`\n // judges in band; journal sync and the runtime bridge take the bearer alone.\n const bearer = ControlRpcs.bearerAuthenticator({ token: options.credential, principal: bearerPrincipal })\n const scoped = credentialAuthenticator(options.credential)\n return {\n allowedHosts,\n ...(maxRequestBodyBytes === undefined ? {} : { maxRequestBodyBytes }),\n authorize: (headers, path) =>\n (scopedTokenPaths.includes(path) ? scoped : bearer).authenticate(headers).pipe(\n Effect.match({ onFailure: () => false, onSuccess: () => true })\n )\n }\n}\n\nconst bindFailure = (failure: ServeError | GatewayError): GatewayError =>\n new GatewayError({\n code: \"bind_failed\",\n message: \"The gateway socket could not be bound\",\n cause: { _tag: failure._tag }\n })\n\n/**\n * Fails the layer with the sanitized refusal every bearer holder may see, after\n * logging the operator's copy: the requested authority and the operating-system\n * cause (`EADDRINUSE`, `EACCES`, `EADDRNOTAVAIL`), which the wire error omits.\n */\nconst mapServeError = <A, R>(\n bind: ListenOptions,\n server: Layer.Layer<A, ServeError | GatewayError, R>\n): Layer.Layer<A, GatewayError, R> =>\n server.pipe(\n Layer.catch((failure) =>\n Layer.effectContext<A, GatewayError, never>(\n Effect.logError({\n message: \"The gateway socket could not be bound\",\n host: bind.host,\n port: bind.port,\n cause: failure\n }).pipe(Effect.andThen(Effect.fail(bindFailure(failure))))\n )\n )\n )\n\n/**\n * Hosts the assembled gateway on an injected native HTTP server.\n *\n * Supplies the bind policy, the shared-credential authentication both RPC\n * mounts run under, and newline-delimited JSON as the wire serialization. The\n * caller supplies what the mounts read through: `Control`, `Projections`,\n * `SyncServer`, and the `SyncAuth` middleware.\n *\n * The returned layer retains the concrete `HttpServer` service, so a caller\n * that bound port 0 can read the ephemeral address it got.\n *\n * Policy refusals and operating-system listen failures both fail the layer as\n * sanitized `bind_failed` `GatewayError` values.\n *\n * @param health the identity `GET /health` answers with\n * @param options the requested bind\n * @since 1.0.0\n * @category layers\n */\nexport const makeLayer = (\n server: (options: ListenOptions) => Layer.Layer<HttpServer, ServeError | GatewayError>\n) =>\n(\n health: GatewayServer.Health,\n options: ServerOptions = defaultServerOptions\n) =>\n Layer.unwrap(\n Effect.map(listenOptions(options), (nodeOptions) =>\n HttpRouter.serve(\n GatewayServer.layer(health, {\n ...(options.heartbeatMillis === undefined ? {} : { heartbeatMillis: options.heartbeatMillis }),\n ingress: ingressOptions(options),\n ...(options.runtimeBridge === undefined ? {} : {\n runtimeBridge: {\n ...options.runtimeBridge,\n authenticate: ControlRpcs.bearerAuthenticator({\n // listenOptions rejects a runtime bridge without a credential.\n token: options.credential!,\n principal: bearerPrincipal\n }).authenticate\n }\n })\n }).pipe(\n Layer.provide(layerAuth(options)),\n Layer.provide(RpcSerialization.layerNdjson)\n ),\n { disableListenLog: true, disableLogger: true }\n ).pipe(\n Layer.provideMerge(mapServeError(nodeOptions, server(nodeOptions)))\n ))\n )\n"],
|
|
4
|
+
"sourcesContent": ["/**\n * Shared native gateway bind policy, credential policy,\n * and the one composition a `smithers serve` verb hosts.\n *\n * Two rules decide whether a bind is allowed, and both fail closed:\n *\n * 1. A non-loopback host requires an explicit `listen` opt-in. Binding\n * `0.0.0.0` because a port was free is how a workspace gateway ends up on\n * a shared network by accident.\n * 2. A non-loopback bind requires a bearer credential. The control plane can\n * launch runs, cancel them, and approve capability grants; reachable from\n * another machine, an unauthenticated one is a remote execution service.\n *\n * A loopback bind with no network credential allows anonymous reads; approval\n * decisions require the session operator token. Ingress still checks Host and\n * Origin so a web page cannot exercise the loopback endpoint.\n *\n * @since 1.0.0\n */\n\nimport { ControlRpcs, ScopedToken } from \"@smthrs/control\"\nimport { Effect, Layer } from \"effect\"\nimport { HttpRouter } from \"effect/http\"\nimport type { HttpServer } from \"effect/http/HttpServer\"\nimport type { ServeError } from \"effect/http/HttpServerError\"\nimport { RpcSerialization } from \"effect/rpc\"\nimport type { ListenOptions } from \"node:net\"\nimport { GatewayError, settingRefusal } from \"../GatewayError.ts\"\nimport * as GatewayServer from \"../GatewayServer.ts\"\nimport type * as RuntimeBridge from \"../RuntimeBridge.ts\"\n\n/**\n * Where the gateway binds, and whether a non-loopback bind was asked for.\n *\n * @since 1.0.0\n * @category models\n */\nexport interface ServerOptions extends ListenOptions {\n /** Additional accepted Host header names (without ports), for network or proxy access. */\n readonly allowedHosts?: ReadonlyArray<string> | undefined\n /** The `--listen` opt-in required for a non-loopback host. */\n readonly listen?: boolean | undefined\n /** The shared bearer credential, required for a non-loopback bind. */\n readonly credential?: string | undefined\n /** Per-session approval token on credential-free loopback. Read calls remain anonymous. */\n readonly operatorToken?: string | undefined\n /**\n * How often an idle followed `Watch` on `/rpc/ws` and an idle followed\n * `Projection.Subscribe` on `/projections/ws` emit a keepalive frame. Unset,\n * both run at `Projections.heartbeatIntervalMillis` unless the supplied\n * `Projections` service was built with its own cadence. A relay with an idle\n * cut shorter than that one needs a shorter cadence here.\n */\n readonly heartbeatMillis?: number | undefined\n /** Maximum bytes accepted on one HTTP RPC request. Default one MiB. */\n readonly maxRequestBodyBytes?: number | undefined\n /** Immutable identity of an opt-in packaged Flow runtime bridge. */\n readonly runtimeBridge?: Omit<RuntimeBridge.Config, \"authenticate\"> | undefined\n}\n\n/**\n * The default bind: loopback, port 7331, no credential.\n *\n * @since 1.0.0\n * @category models\n */\nexport const defaultServerOptions: ServerOptions = { host: \"127.0.0.1\", port: 7331 }\n\n/**\n * Whether a host names this machine only.\n *\n * @param host the host to classify\n * @since 1.0.0\n * @category predicates\n */\nexport const isLoopbackHost = (host: string): boolean => GatewayServer.loopbackHostNames.includes(host)\n\n/**\n * The typed refusal a requested bind earns, or `undefined` when it is allowed.\n *\n * Every start-time rule this module enforces answers here as a `bind_failed`\n * `GatewayError`, so a host that wants to report a refusal rather than crash on\n * one asks this before it composes a layer. {@link listenOptions} and\n * {@link layer} fail with exactly what this returns.\n *\n * @param options the requested bind\n * @since 1.0.0\n * @category constructors\n */\nexport const bindRefusal = (options: ServerOptions): GatewayError | undefined => {\n const setting = settingRefusal(\"The gateway keepalive cadence\", options.heartbeatMillis) ??\n settingRefusal(\"The gateway request body limit\", options.maxRequestBodyBytes)\n if (setting !== undefined) return setting\n // The bridge authenticates only with the bearer credential, even on\n // loopback, so a bridge without one would answer 401 to every request.\n if (options.runtimeBridge !== undefined && (options.credential === undefined || options.credential === \"\")) {\n return new GatewayError({\n code: \"bind_failed\",\n message: \"Refusing to enable the runtime bridge without a bearer credential\"\n })\n }\n const host = options.host ?? \"127.0.0.1\"\n if (isLoopbackHost(host)) return undefined\n if (options.listen !== true) {\n return new GatewayError({\n code: \"bind_failed\",\n message: `Refusing non-loopback gateway bind ${host} without an explicit --listen opt-in`\n })\n }\n if (options.credential === undefined || options.credential === \"\") {\n return new GatewayError({\n code: \"bind_failed\",\n message: `Refusing non-loopback gateway bind ${host} without a bearer credential`\n })\n }\n return undefined\n}\n\n/**\n * Applies the bind policy, returning the admitted Node options or a typed\n * `bind_failed` refusal.\n *\n * @param options the requested bind\n * @since 1.0.0\n * @category constructors\n */\nexport const listenOptions = (options: ServerOptions): Effect.Effect<ListenOptions, GatewayError> =>\n Effect.suspend(() => {\n const refusal = bindRefusal(options)\n if (refusal !== undefined) return Effect.fail(refusal)\n // `credential`, `listen`, and the keepalive cadence are this module's, not\n // `node:net`'s: they are named here so the rest is exactly a bind.\n const {\n allowedHosts: _allowedHosts,\n credential: _credential,\n heartbeatMillis: _cadence,\n listen: _listen,\n maxRequestBodyBytes: _maxBody,\n runtimeBridge: _runtimeBridge,\n ...node\n } = options\n return Effect.succeed({ ...node, host: node.host ?? \"127.0.0.1\" })\n })\n\n/**\n * The authentication both RPC mounts run under.\n *\n * A configured credential authenticates every request that presents it and\n * stamps the same server-owned principal. A scoped token minted under that\n * credential (`@smthrs/control` `ScopedToken`) authenticates only the\n * procedures, run, or flow it names, until it expires, and stamps\n * {@link scopedPrincipal}. With no credential the composition is\n * loopback-only (see {@link listenOptions}) and every request runs as the\n * anonymous read principal. A session operator token alone stamps the local\n * operator for approval decisions; without it approvals are unauthorized.\n *\n * @param options the requested bind\n * @since 1.0.0\n * @category layers\n */\nexport const layerAuth = (options: ServerOptions): Layer.Layer<ControlRpcs.ControlAuth> =>\n options.credential === undefined || options.credential === \"\"\n ? ControlRpcs.layerAuth({\n authenticate: (headers) => {\n const token = options.operatorToken\n if (token === undefined || token === \"\") {\n return Effect.succeed({ id: \"loopback\", kind: \"anonymous\", stampedAt: 0 })\n }\n return ControlRpcs.bearerAuthenticator({\n token,\n principal: { id: \"local\", kind: \"operator\" }\n }).authenticate(headers).pipe(\n Effect.catchTag(\n \"/control/Unauthorized\",\n () => Effect.succeed({ id: \"loopback\", kind: \"anonymous\", stampedAt: 0 })\n )\n )\n }\n }, gatewayRunVisibility)\n : ControlRpcs.layerAuth(credentialAuthenticator(options.credential), gatewayRunVisibility)\n\n/**\n * Every identity this gateway stamps reads every run. They all stand for the\n * one operator who holds the gateway's credential, or the machine's loopback\n * user when there is none; a scoped token is that operator's grant, confined\n * by the procedures, run, or flow it names rather than by who launched a run.\n */\nconst gatewayRunVisibility: ControlRpcs.AuthOptions = { seesAllRuns: () => true }\n\n/**\n * The bearer credential itself, or a scoped token minted under it.\n *\n * The runtime bridge deliberately does not use this: it accepts the bearer\n * alone, because a scoped token names control procedures and the bridge's\n * versioned commands are not those.\n */\nconst credentialAuthenticator = (credential: string): ControlRpcs.Authenticator =>\n ControlRpcs.anyAuthenticator([\n ControlRpcs.bearerAuthenticator({ token: credential, principal: bearerPrincipal }),\n ScopedToken.authenticator({ key: credential, principal: scopedPrincipal })\n ])\n\n/**\n * The identity stamped only after this gateway verifies its configured token.\n * Hosts may explicitly delegate operator decisions to this exact identity.\n * @category constants\n * @since 1.0.0\n */\nexport const bearerPrincipal = Object.freeze({ id: \"gateway\", kind: \"bearer\" })\n\n/**\n * The protected mounts a scoped token may reach: those guarded in band by\n * `ControlAuth`, which checks each frame's procedure against the token, and\n * the ticket exchange that opens their sockets.\n * @category constants\n * @since 1.0.0\n */\nexport const scopedTokenPaths: ReadonlyArray<string> = [\n \"/rpc\",\n \"/rpc/ws\",\n \"/projections\",\n \"/projections/ws\",\n \"/auth/ticket\"\n]\n\n/**\n * The identity stamped after this gateway verifies a scoped token minted\n * under its configured credential. It is its own kind so that delegating\n * approval to {@link bearerPrincipal} does not delegate it to every token\n * minted from the bearer; a host that wants a scoped `approve:runs` token to\n * decide delegates to this identity explicitly.\n * @category constants\n * @since 1.0.0\n */\nexport const scopedPrincipal = Object.freeze({ id: \"gateway\", kind: \"scoped\" })\n\n/**\n * The ingress policy a requested bind runs behind.\n *\n * The accepted Host names are the loopback names, the operator's\n * `allowedHosts`, and the concrete bind host itself, so `--host 192.168.1.10`\n * is reachable at that address without naming it twice. A wildcard bind\n * (`0.0.0.0` or `::`) adds nothing: every interface is not a Host name, and\n * the operator names the reachable ones. Protected paths are authenticated\n * before any request body is read.\n *\n * @param options the requested bind\n * @since 1.0.0\n * @category constructors\n */\nexport const ingressOptions = (options: ServerOptions): GatewayServer.IngressOptions => {\n const maxRequestBodyBytes = options.maxRequestBodyBytes\n const host = options.host ?? \"127.0.0.1\"\n const allowedHosts = [...GatewayServer.loopbackHostHeaderNames, ...options.allowedHosts ?? []]\n const bindAuthority = URL.parse(`http://${host.includes(\":\") ? `[${host}]` : host}`)\n if (host !== \"0.0.0.0\" && host !== \"::\" && bindAuthority !== null && !allowedHosts.includes(bindAuthority.hostname)) {\n allowedHosts.push(bindAuthority.hostname)\n }\n if (options.credential === undefined || options.credential === \"\") {\n return {\n loopbackOnly: true,\n ...(maxRequestBodyBytes === undefined ? {} : { maxRequestBodyBytes }),\n allowedHosts\n }\n }\n // The edge knows no call, so a scoped token passes here on its signature\n // and expiry, and only toward the mounts whose every frame `ControlAuth`\n // judges in band; journal sync and the runtime bridge take the bearer alone.\n const bearer = ControlRpcs.bearerAuthenticator({ token: options.credential, principal: bearerPrincipal })\n const scoped = credentialAuthenticator(options.credential)\n return {\n allowedHosts,\n ...(maxRequestBodyBytes === undefined ? {} : { maxRequestBodyBytes }),\n authorize: (headers, path) =>\n (scopedTokenPaths.includes(path) ? scoped : bearer).authenticate(headers).pipe(\n Effect.match({ onFailure: () => false, onSuccess: () => true })\n )\n }\n}\n\nconst bindFailure = (failure: ServeError | GatewayError): GatewayError =>\n new GatewayError({\n code: \"bind_failed\",\n message: \"The gateway socket could not be bound\",\n cause: { _tag: failure._tag }\n })\n\n/**\n * Fails the layer with the sanitized refusal every bearer holder may see, after\n * logging the operator's copy: the requested authority and the operating-system\n * cause (`EADDRINUSE`, `EACCES`, `EADDRNOTAVAIL`), which the wire error omits.\n */\nconst mapServeError = <A, R>(\n bind: ListenOptions,\n server: Layer.Layer<A, ServeError | GatewayError, R>\n): Layer.Layer<A, GatewayError, R> =>\n server.pipe(\n Layer.catch((failure) =>\n Layer.effectContext<A, GatewayError, never>(\n Effect.logError({\n message: \"The gateway socket could not be bound\",\n host: bind.host,\n port: bind.port,\n cause: failure\n }).pipe(Effect.andThen(Effect.fail(bindFailure(failure))))\n )\n )\n )\n\n/**\n * Hosts the assembled gateway on an injected native HTTP server.\n *\n * Supplies the bind policy, the shared-credential authentication both RPC\n * mounts run under, and newline-delimited JSON as the wire serialization. The\n * caller supplies what the mounts read through: `Control`, `Projections`,\n * `SyncServer`, and the `SyncAuth` middleware.\n *\n * The returned layer retains the concrete `HttpServer` service, so a caller\n * that bound port 0 can read the ephemeral address it got.\n *\n * Policy refusals and operating-system listen failures both fail the layer as\n * sanitized `bind_failed` `GatewayError` values.\n *\n * @param health the identity `GET /health` answers with\n * @param options the requested bind\n * @since 1.0.0\n * @category layers\n */\nexport const makeLayer = (\n server: (options: ListenOptions) => Layer.Layer<HttpServer, ServeError | GatewayError>\n) =>\n(\n health: GatewayServer.Health,\n options: ServerOptions = defaultServerOptions\n) =>\n Layer.unwrap(\n Effect.map(listenOptions(options), (nodeOptions) =>\n HttpRouter.serve(\n GatewayServer.layer(health, {\n ...(options.heartbeatMillis === undefined ? {} : { heartbeatMillis: options.heartbeatMillis }),\n ingress: ingressOptions(options),\n ...(options.runtimeBridge === undefined ? {} : {\n runtimeBridge: {\n ...options.runtimeBridge,\n authenticate: ControlRpcs.bearerAuthenticator({\n // listenOptions rejects a runtime bridge without a credential.\n token: options.credential!,\n principal: bearerPrincipal\n }).authenticate\n }\n })\n }).pipe(\n Layer.provide(layerAuth(options)),\n Layer.provide(RpcSerialization.layerNdjson)\n ),\n { disableListenLog: true, disableLogger: true }\n ).pipe(\n Layer.provideMerge(mapServeError(nodeOptions, server(nodeOptions)))\n ))\n )\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;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AAAA,QACX,MAAM,KAAK;AAAA,QACX,OAAO;AAAA,MACT,CAAC,EAAE,KAAK,qBAAO,QAAQ,qBAAO,KAAK,YAAY,OAAO,CAAC,CAAC,CAAC;AAAA,IAC3D;AAAA,EACF;AACF;AAqBK,MAAM,YAAY,CACvB,WAEF,CACE,QACA,UAAyB,yBAEzB,oBAAM;AAAA,EACJ,qBAAO,IAAI,cAAc,OAAO,GAAG,CAAC,gBAClC,uBAAW;AAAA,IACT,cAAc,MAAM,QAAQ;AAAA,MAC1B,GAAI,QAAQ,oBAAoB,SAAY,CAAC,IAAI,EAAE,iBAAiB,QAAQ,gBAAgB;AAAA,MAC5F,SAAS,eAAe,OAAO;AAAA,MAC/B,GAAI,QAAQ,kBAAkB,SAAY,CAAC,IAAI;AAAA,QAC7C,eAAe;AAAA,UACb,GAAG,QAAQ;AAAA,UACX,cAAc,2BAAY,oBAAoB;AAAA;AAAA,YAE5C,OAAO,QAAQ;AAAA,YACf,WAAW;AAAA,UACb,CAAC,EAAE;AAAA,QACL;AAAA,MACF;AAAA,IACF,CAAC,EAAE;AAAA,MACD,oBAAM,QAAQ,UAAU,OAAO,CAAC;AAAA,MAChC,oBAAM,QAAQ,4BAAiB,WAAW;AAAA,IAC5C;AAAA,IACA,EAAE,kBAAkB,MAAM,eAAe,KAAK;AAAA,EAChD,EAAE;AAAA,IACA,oBAAM,aAAa,cAAc,aAAa,OAAO,WAAW,CAAC,CAAC;AAAA,EACpE,CAAC;AACL;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -12,5 +12,5 @@ export type ServerOptions = NativeGateway.ServerOptions;
|
|
|
12
12
|
* @since 1.0.0
|
|
13
13
|
* @category layers
|
|
14
14
|
*/
|
|
15
|
-
export declare const layer: (health: import("../GatewayServer.ts").Health, options?: NativeGateway.ServerOptions) => import("effect/Layer").Layer<import("effect/
|
|
15
|
+
export declare const layer: (health: import("../GatewayServer.ts").Health, options?: NativeGateway.ServerOptions) => import("effect/Layer").Layer<import("effect/http/HttpServer").HttpServer, import("../GatewayError.ts").GatewayError | import("@smthrs/sync/SyncError").SyncError, import("@smthrs/control/Control").Control | import("@smthrs/sync/SyncRpcs").SyncAuth | import("@smthrs/sync/SyncServer").SyncServer | import("../Projections.ts").Projections>;
|
|
16
16
|
//# sourceMappingURL=NodeGateway.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeGateway.d.ts","sourceRoot":"","sources":["../../../src/node/NodeGateway.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,aAAa,MAAM,8BAA8B,CAAA;AAE7D,OAAO,EACL,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,SAAS,EACT,aAAa,EACb,eAAe,EACf,gBAAgB,EACjB,MAAM,8BAA8B,CAAA;AACrC;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,aAAa,CAAC,aAAa,CAAA;AAEvD;;;GAGG;AACH,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"NodeGateway.d.ts","sourceRoot":"","sources":["../../../src/node/NodeGateway.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,aAAa,MAAM,8BAA8B,CAAA;AAE7D,OAAO,EACL,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,SAAS,EACT,aAAa,EACb,eAAe,EACf,gBAAgB,EACjB,MAAM,8BAA8B,CAAA;AACrC;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,aAAa,CAAC,aAAa,CAAA;AAEvD;;;GAGG;AACH,eAAO,MAAM,KAAK,2aAAoF,CAAA"}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { ControlError, ControlRpcs } from "@smthrs/control";
|
|
17
17
|
import { Schema } from "effect";
|
|
18
|
-
import { Rpc, RpcGroup } from "effect/
|
|
18
|
+
import { Rpc, RpcGroup } from "effect/rpc";
|
|
19
19
|
import { GatewayError } from "./GatewayError.ts";
|
|
20
20
|
import * as RunHistory from "./RunHistory.ts";
|
|
21
21
|
/**
|
|
@@ -720,7 +720,7 @@ export declare const GatewayRpcs: RpcGroup.RpcGroup<Rpc.Rpc<"Projection.Snapshot
|
|
|
720
720
|
readonly value: Schema.Int;
|
|
721
721
|
readonly offset: Schema.Int;
|
|
722
722
|
}>>;
|
|
723
|
-
}>, import("effect/
|
|
723
|
+
}>, import("effect/rpc/RpcSchema").Stream<Schema.Union<readonly [Schema.TaggedStruct<"snapshot-start", {
|
|
724
724
|
readonly selector: Schema.Union<readonly [Schema.TaggedStruct<"workspace-runs", {
|
|
725
725
|
readonly flowId: Schema.optionalKey<Schema.NonEmptyString>;
|
|
726
726
|
}>, Schema.TaggedStruct<"run-summary", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GatewayRpcs.d.ts","sourceRoot":"","sources":["../../src/GatewayRpcs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAiB,MAAM,iBAAiB,CAAA;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"GatewayRpcs.d.ts","sourceRoot":"","sources":["../../src/GatewayRpcs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAiB,MAAM,iBAAiB,CAAA;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;;;;GAKG;AACH,eAAO,MAAM,QA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;;;;;;;;;;;;IA1FtB;;;;;;;;;;;;OAYG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yKAsHgC,CAAA"}
|
package/dist/esm/GatewayRpcs.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { ControlError, ControlRpcs, ControlSchema } from "@smthrs/control";
|
|
17
17
|
import { Schema } from "effect";
|
|
18
|
-
import { Rpc, RpcGroup } from "effect/
|
|
18
|
+
import { Rpc, RpcGroup } from "effect/rpc";
|
|
19
19
|
import { GatewayError } from "./GatewayError.js";
|
|
20
20
|
import * as GatewaySchema from "./GatewaySchema.js";
|
|
21
21
|
import * as RunHistory from "./RunHistory.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GatewayRpcs.js","sourceRoot":"","sources":["../../src/GatewayRpcs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"GatewayRpcs.js","sourceRoot":"","sources":["../../src/GatewayRpcs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;A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C,CAAA","sourcesContent":["/**\n * The gateway's own remote procedures: the served read path, and the one\n * composite mutation a product client cannot assemble safely on its own.\n *\n * Control mutations are not re-declared here. `@smthrs/control` `ControlRpcs`\n * is the mutation contract and the gateway mounts it unchanged at `/rpc`, so\n * there is exactly one wire definition of `Plan`, `Run`, `Approve`, `Deny`,\n * `Cancel`, `Signal`, `Steer`, `Resume`, `List`, and `Watch`.\n *\n * The group shares `ControlRpcs.ControlAuth`, so one bearer credential\n * authenticates both mounts and one server-stamped principal is recorded for\n * whatever it authorizes.\n *\n * @since 1.0.0\n */\n\nimport { ControlError, ControlRpcs, ControlSchema } from \"@smthrs/control\"\nimport { Schema } from \"effect\"\nimport { Rpc, RpcGroup } from \"effect/rpc\"\nimport { GatewayError } from \"./GatewayError.ts\"\nimport * as GatewaySchema from \"./GatewaySchema.ts\"\nimport * as RunHistory from \"./RunHistory.ts\"\n\n/**\n * The decision a client submits for one approval.\n *\n * @since 1.0.0\n * @category models\n */\nexport const Decision = Schema.Literals([\"approve\", \"deny\"])\n\n/**\n * The decision a client submits for one approval.\n *\n * @since 1.0.0\n * @category models\n */\nexport type Decision = typeof Decision.Type\n\n/**\n * One approval decision, submitted with the exact payload the run published.\n *\n * @since 1.0.0\n * @category models\n */\nexport const SubmitApprovalInput = Schema.Struct({\n ...ControlSchema.ApprovalPayload.fields,\n decision: Decision,\n /**\n * The answer to a question, for a gate that asks one.\n *\n * Most gates are a grant: approve or deny, and the decision IS the payload.\n * A `HumanTask` gate asks for a value — prose, a choice, a JSON object — and\n * the decision alone answers nothing. Present exactly when the row being\n * submitted is one of those, in which case `target.requestId` names the wait\n * point and this is what is delivered to it. A denial carries no answer: the\n * question is refused, not answered.\n *\n * Additive on purpose: a client that never asks a person anything submits\n * exactly what it submitted before.\n */\n answer: Schema.optional(Schema.Json)\n})\n\n/**\n * One approval decision, submitted with the exact payload the run published.\n *\n * @since 1.0.0\n * @category models\n */\nexport type SubmitApprovalInput = typeof SubmitApprovalInput.Type\n\n/**\n * What submitting an approval did.\n *\n * `decision` is the receipt for the grant or refusal. Control owns the\n * decision and its durable resume delegation as one domain command.\n *\n * @since 1.0.0\n * @category models\n */\nexport const SubmitApprovalOutput = Schema.Struct({\n decision: ControlSchema.Receipt\n})\n\n/**\n * What submitting an approval did.\n *\n * @since 1.0.0\n * @category models\n */\nexport type SubmitApprovalOutput = typeof SubmitApprovalOutput.Type\n\n/**\n * The failures `Approval.Submit` can answer with: exactly the union\n * `@smthrs/control` `Control.approve`, `Control.deny`, and — for a gate that\n * asks a question — `Control.signal` declare, because the handler is a\n * transport adapter over those commands and adds no failure of its own. A\n * member none of them raises would be a recovery branch no client's code could\n * ever reach.\n *\n * `NoMatchingWait` is the one an answer adds: the question was answered after\n * the run moved on, or somebody else answered it first. `CodeDrift` is a node\n * decision on a run whose flow changed since it started (#1807).\n */\nconst submitErrors = Schema.Union([\n ControlError.NoMatchingWait,\n ControlError.CodeDrift,\n ControlError.PlanDigestMismatch,\n ControlError.EnvelopeMismatch,\n ControlError.AlreadyResolved,\n ControlError.PlanNotFound,\n ControlError.RunNotFound,\n ControlError.InvalidInput,\n ControlError.Unauthorized,\n ControlError.PersistenceError,\n ControlError.Unavailable,\n ControlError.TransportError\n])\n\n/**\n * The failures `Run.Fork` and `Run.Verify` answer with: the history host's own\n * refusal, `Unauthorized` for an anonymous loopback caller, or `Unavailable`\n * from a gateway composed without a history host.\n */\nconst historyErrors = Schema.Union([RunHistory.HistoryRefused, ControlError.Unauthorized, ControlError.Unavailable])\n\n/**\n * The gateway read path, the composite approval mutation, and the run\n * history procedures.\n *\n * `Approval.Submit` is the transport form of Control's single decision\n * command. Control records the decision and durable resume delegation; the\n * gateway never composes a second mutation.\n *\n * @since 1.0.0\n * @category groups\n */\nexport const GatewayRpcs = RpcGroup.make(\n Rpc.make(\"Projection.Snapshot\", {\n defect: ControlRpcs.ControlDefect,\n payload: Schema.Struct({\n selector: GatewaySchema.ProjectionSelector,\n after: Schema.optional(GatewaySchema.ProjectionCursor)\n }),\n success: GatewaySchema.ProjectionSnapshot,\n error: GatewayError\n }),\n Rpc.make(\"Projection.Subscribe\", {\n defect: ControlRpcs.ControlDefect,\n payload: Schema.Struct({\n selector: GatewaySchema.ProjectionSelector,\n after: Schema.optional(GatewaySchema.ProjectionCursor)\n }),\n success: GatewaySchema.GatewayFrame,\n error: GatewayError,\n stream: true\n }),\n Rpc.make(\"Approval.Submit\", {\n defect: ControlRpcs.ControlDefect,\n payload: SubmitApprovalInput,\n success: SubmitApprovalOutput,\n error: submitErrors\n }),\n /* Branches a run at a recorded frame into a parked child, as `smthrs runs fork`. */\n Rpc.make(\"Run.Fork\", {\n defect: ControlRpcs.ControlDefect,\n payload: RunHistory.ForkInput,\n success: RunHistory.ForkOutput,\n error: historyErrors\n }),\n /* Reports what a resume under the current flow code would replay, as `smthrs runs verify`. */\n Rpc.make(\"Run.Verify\", {\n defect: ControlRpcs.ControlDefect,\n payload: RunHistory.VerifyInput,\n success: RunHistory.VerifyReport,\n error: historyErrors\n })\n).middleware(ControlRpcs.ControlAuth)\n"]}
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
import { Control } from "@smthrs/control/Control";
|
|
28
28
|
import * as SyncServer from "@smthrs/sync/SyncServer";
|
|
29
29
|
import { Effect, Layer, Schema } from "effect";
|
|
30
|
-
import { HttpRouter } from "effect/
|
|
31
|
-
import { RpcSerialization, RpcServer } from "effect/
|
|
30
|
+
import { HttpRouter } from "effect/http";
|
|
31
|
+
import { RpcSerialization, RpcServer } from "effect/rpc";
|
|
32
32
|
import { GatewayError } from "./GatewayError.ts";
|
|
33
33
|
import { Projections } from "./Projections.ts";
|
|
34
34
|
import * as RuntimeBridge from "./RuntimeBridge.ts";
|
|
@@ -73,7 +73,7 @@ export declare const layerHealth: (health: Health) => Layer.Layer<never, never,
|
|
|
73
73
|
* @since 1.0.0
|
|
74
74
|
* @category layers
|
|
75
75
|
*/
|
|
76
|
-
export declare const layerHandlers: Layer.Layer<import("effect/
|
|
76
|
+
export declare const layerHandlers: Layer.Layer<import("effect/rpc/Rpc").Handler<"Projection.Snapshot"> | import("effect/rpc/Rpc").Handler<"Projection.Subscribe"> | import("effect/rpc/Rpc").Handler<"Approval.Submit"> | import("effect/rpc/Rpc").Handler<"Run.Fork"> | import("effect/rpc/Rpc").Handler<"Run.Verify">, never, Control | Projections>;
|
|
77
77
|
/**
|
|
78
78
|
* The kind a `Watch` keepalive carries.
|
|
79
79
|
*
|
|
@@ -371,7 +371,7 @@ export declare const carriesRpcRequest: (serialization: RpcSerialization.RpcSeri
|
|
|
371
371
|
* Enforces local Host/Origin policy and edge authentication before reading a
|
|
372
372
|
* body or upgrading a socket, then validates RPC body size and framing.
|
|
373
373
|
*
|
|
374
|
-
* `effect/
|
|
374
|
+
* `effect/rpc` hands every decoded message to the server loop, and a
|
|
375
375
|
* body that decodes to something else — `{}`, `[]`, prose, nothing at all —
|
|
376
376
|
* reached it as a message with no tag and died there, so the gateway answered
|
|
377
377
|
* `500 Internal Server Error` with an empty body (release validation). That is the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GatewayServer.d.ts","sourceRoot":"","sources":["../../src/GatewayServer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAOjD,OAAO,KAAK,UAAU,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAU,MAAM,EAAsB,MAAM,QAAQ,CAAA;AAE1E,OAAO,EAAW,UAAU,EAAyC,MAAM,
|
|
1
|
+
{"version":3,"file":"GatewayServer.d.ts","sourceRoot":"","sources":["../../src/GatewayServer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAOjD,OAAO,KAAK,UAAU,MAAM,yBAAyB,CAAA;AACrD,OAA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";
|
|
|
33
33
|
import * as SyncServer from "@smthrs/sync/SyncServer";
|
|
34
34
|
import { Effect, Layer, Option, Schema, Stream } from "effect";
|
|
35
35
|
import * as ByteSize from "effect/ByteSize";
|
|
36
|
-
import { Headers, HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/
|
|
37
|
-
import { RpcSerialization, RpcServer } from "effect/
|
|
36
|
+
import { Headers, HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
37
|
+
import { RpcSerialization, RpcServer } from "effect/rpc";
|
|
38
38
|
import { GatewayError, settingRefusal } from "./GatewayError.js";
|
|
39
39
|
import { GatewayRpcs } from "./GatewayRpcs.js";
|
|
40
40
|
import * as GatewaySchema from "./GatewaySchema.js";
|
|
@@ -579,7 +579,7 @@ export const carriesRpcRequest = (serialization, body) => {
|
|
|
579
579
|
* Enforces local Host/Origin policy and edge authentication before reading a
|
|
580
580
|
* body or upgrading a socket, then validates RPC body size and framing.
|
|
581
581
|
*
|
|
582
|
-
* `effect/
|
|
582
|
+
* `effect/rpc` hands every decoded message to the server loop, and a
|
|
583
583
|
* body that decodes to something else — `{}`, `[]`, prose, nothing at all —
|
|
584
584
|
* reached it as a message with no tag and died there, so the gateway answered
|
|
585
585
|
* `500 Internal Server Error` with an empty body (release validation). That is the
|