@smthrs/platform-node 0.0.0-stage → 1.0.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +211 -0
- package/LICENSE +21 -0
- package/README.md +165 -2
- package/bin/darwin-arm64/smithers-jj-export +0 -0
- package/bin/darwin-x64/smithers-jj-export +0 -0
- package/bin/linux-arm64/smithers-jj-export +0 -0
- package/bin/linux-x64/smithers-jj-export +4 -0
- package/bin/win32-x64/smithers-jj-export.exe +0 -0
- package/dist/cjs/AtomicFileSystem.d.ts +147 -0
- package/dist/cjs/AtomicFileSystem.d.ts.map +1 -0
- package/dist/cjs/AtomicFileSystem.js +234 -0
- package/dist/cjs/AtomicFileSystem.js.map +7 -0
- package/dist/cjs/EgressHttpClient.d.ts +106 -0
- package/dist/cjs/EgressHttpClient.d.ts.map +1 -0
- package/dist/cjs/EgressHttpClient.js +202 -0
- package/dist/cjs/EgressHttpClient.js.map +7 -0
- package/dist/cjs/HostLiveness.d.ts +81 -0
- package/dist/cjs/HostLiveness.d.ts.map +1 -0
- package/dist/cjs/HostLiveness.js +49 -0
- package/dist/cjs/HostLiveness.js.map +7 -0
- package/dist/cjs/NodeHost.d.ts +145 -0
- package/dist/cjs/NodeHost.d.ts.map +1 -0
- package/dist/cjs/NodeHost.js +128 -0
- package/dist/cjs/NodeHost.js.map +7 -0
- package/dist/cjs/ProcessConfinement.d.ts +61 -0
- package/dist/cjs/ProcessConfinement.d.ts.map +1 -0
- package/dist/cjs/ProcessConfinement.js +292 -0
- package/dist/cjs/ProcessConfinement.js.map +7 -0
- package/dist/cjs/ProcessReaper.d.ts +457 -0
- package/dist/cjs/ProcessReaper.d.ts.map +1 -0
- package/dist/cjs/ProcessReaper.js +349 -0
- package/dist/cjs/ProcessReaper.js.map +7 -0
- package/dist/cjs/ProcessSandbox.d.ts +391 -0
- package/dist/cjs/ProcessSandbox.d.ts.map +1 -0
- package/dist/cjs/ProcessSandbox.js +774 -0
- package/dist/cjs/ProcessSandbox.js.map +7 -0
- package/dist/cjs/ScopedProcess.d.ts +66 -0
- package/dist/cjs/ScopedProcess.d.ts.map +1 -0
- package/dist/cjs/ScopedProcess.js +87 -0
- package/dist/cjs/ScopedProcess.js.map +7 -0
- package/dist/cjs/index.d.ts +38 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +47 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/internal/AtomicFileSystemExecutable.d.ts +61 -0
- package/dist/cjs/internal/AtomicFileSystemExecutable.d.ts.map +1 -0
- package/dist/cjs/internal/AtomicFileSystemExecutable.js +250 -0
- package/dist/cjs/internal/AtomicFileSystemExecutable.js.map +7 -0
- package/dist/cjs/internal/AtomicFileSystemProtocol.d.ts +78 -0
- package/dist/cjs/internal/AtomicFileSystemProtocol.d.ts.map +1 -0
- package/dist/cjs/internal/AtomicFileSystemProtocol.js +382 -0
- package/dist/cjs/internal/AtomicFileSystemProtocol.js.map +7 -0
- package/dist/cjs/internal/AtomicFileSystemTransport.d.ts +44 -0
- package/dist/cjs/internal/AtomicFileSystemTransport.d.ts.map +1 -0
- package/dist/cjs/internal/AtomicFileSystemTransport.js +197 -0
- package/dist/cjs/internal/AtomicFileSystemTransport.js.map +7 -0
- package/dist/cjs/internal/AtomicHelperError.d.ts +35 -0
- package/dist/cjs/internal/AtomicHelperError.d.ts.map +1 -0
- package/dist/cjs/internal/AtomicHelperError.js +45 -0
- package/dist/cjs/internal/AtomicHelperError.js.map +7 -0
- package/dist/cjs/internal/AtomicHelperFault.d.ts +59 -0
- package/dist/cjs/internal/AtomicHelperFault.d.ts.map +1 -0
- package/dist/cjs/internal/AtomicHelperFault.js +66 -0
- package/dist/cjs/internal/AtomicHelperFault.js.map +7 -0
- package/dist/cjs/internal/PipedProcess.d.ts +35 -0
- package/dist/cjs/internal/PipedProcess.d.ts.map +1 -0
- package/dist/cjs/internal/PipedProcess.js +309 -0
- package/dist/cjs/internal/PipedProcess.js.map +7 -0
- package/dist/cjs/internal/ProcSnapshot.d.ts +85 -0
- package/dist/cjs/internal/ProcSnapshot.d.ts.map +1 -0
- package/dist/cjs/internal/ProcSnapshot.js +123 -0
- package/dist/cjs/internal/ProcSnapshot.js.map +7 -0
- package/dist/cjs/internal/ProcessCleanup.d.ts +64 -0
- package/dist/cjs/internal/ProcessCleanup.d.ts.map +1 -0
- package/dist/cjs/internal/ProcessCleanup.js +62 -0
- package/dist/cjs/internal/ProcessCleanup.js.map +7 -0
- package/dist/cjs/internal/ProcessCleanupPolicyError.d.ts +30 -0
- package/dist/cjs/internal/ProcessCleanupPolicyError.d.ts.map +1 -0
- package/dist/cjs/internal/ProcessCleanupPolicyError.js +33 -0
- package/dist/cjs/internal/ProcessCleanupPolicyError.js.map +7 -0
- package/dist/cjs/internal/ProcessFault.d.ts +63 -0
- package/dist/cjs/internal/ProcessFault.d.ts.map +1 -0
- package/dist/cjs/internal/ProcessFault.js +63 -0
- package/dist/cjs/internal/ProcessFault.js.map +7 -0
- package/dist/cjs/internal/ProcessSupervisor.d.ts +143 -0
- package/dist/cjs/internal/ProcessSupervisor.d.ts.map +1 -0
- package/dist/cjs/internal/ProcessSupervisor.js +685 -0
- package/dist/cjs/internal/ProcessSupervisor.js.map +7 -0
- package/dist/cjs/internal/SupervisorProgram.d.ts +9 -0
- package/dist/cjs/internal/SupervisorProgram.d.ts.map +1 -0
- package/dist/cjs/internal/SupervisorProgram.js +326 -0
- package/dist/cjs/internal/SupervisorProgram.js.map +7 -0
- package/dist/cjs/internal/WindowsProcessJob.d.ts +39 -0
- package/dist/cjs/internal/WindowsProcessJob.d.ts.map +1 -0
- package/dist/cjs/internal/WindowsProcessJob.js +113 -0
- package/dist/cjs/internal/WindowsProcessJob.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/AtomicFileSystem.d.ts +147 -0
- package/dist/esm/AtomicFileSystem.d.ts.map +1 -0
- package/dist/esm/AtomicFileSystem.js +290 -0
- package/dist/esm/AtomicFileSystem.js.map +1 -0
- package/dist/esm/EgressHttpClient.d.ts +106 -0
- package/dist/esm/EgressHttpClient.d.ts.map +1 -0
- package/dist/esm/EgressHttpClient.js +259 -0
- package/dist/esm/EgressHttpClient.js.map +1 -0
- package/dist/esm/HostLiveness.d.ts +81 -0
- package/dist/esm/HostLiveness.d.ts.map +1 -0
- package/dist/esm/HostLiveness.js +68 -0
- package/dist/esm/HostLiveness.js.map +1 -0
- package/dist/esm/NodeHost.d.ts +145 -0
- package/dist/esm/NodeHost.d.ts.map +1 -0
- package/dist/esm/NodeHost.js +162 -0
- package/dist/esm/NodeHost.js.map +1 -0
- package/dist/esm/ProcessConfinement.d.ts +61 -0
- package/dist/esm/ProcessConfinement.d.ts.map +1 -0
- package/dist/esm/ProcessConfinement.js +311 -0
- package/dist/esm/ProcessConfinement.js.map +1 -0
- package/dist/esm/ProcessReaper.d.ts +457 -0
- package/dist/esm/ProcessReaper.d.ts.map +1 -0
- package/dist/esm/ProcessReaper.js +711 -0
- package/dist/esm/ProcessReaper.js.map +1 -0
- package/dist/esm/ProcessSandbox.d.ts +391 -0
- package/dist/esm/ProcessSandbox.d.ts.map +1 -0
- package/dist/esm/ProcessSandbox.js +1043 -0
- package/dist/esm/ProcessSandbox.js.map +1 -0
- package/dist/esm/ScopedProcess.d.ts +66 -0
- package/dist/esm/ScopedProcess.d.ts.map +1 -0
- package/dist/esm/ScopedProcess.js +67 -0
- package/dist/esm/ScopedProcess.js.map +1 -0
- package/dist/esm/index.d.ts +38 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +38 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/AtomicFileSystemExecutable.d.ts +61 -0
- package/dist/esm/internal/AtomicFileSystemExecutable.d.ts.map +1 -0
- package/dist/esm/internal/AtomicFileSystemExecutable.js +350 -0
- package/dist/esm/internal/AtomicFileSystemExecutable.js.map +1 -0
- package/dist/esm/internal/AtomicFileSystemProtocol.d.ts +78 -0
- package/dist/esm/internal/AtomicFileSystemProtocol.d.ts.map +1 -0
- package/dist/esm/internal/AtomicFileSystemProtocol.js +412 -0
- package/dist/esm/internal/AtomicFileSystemProtocol.js.map +1 -0
- package/dist/esm/internal/AtomicFileSystemTransport.d.ts +44 -0
- package/dist/esm/internal/AtomicFileSystemTransport.d.ts.map +1 -0
- package/dist/esm/internal/AtomicFileSystemTransport.js +242 -0
- package/dist/esm/internal/AtomicFileSystemTransport.js.map +1 -0
- package/dist/esm/internal/AtomicHelperError.d.ts +35 -0
- package/dist/esm/internal/AtomicHelperError.d.ts.map +1 -0
- package/dist/esm/internal/AtomicHelperError.js +39 -0
- package/dist/esm/internal/AtomicHelperError.js.map +1 -0
- package/dist/esm/internal/AtomicHelperFault.d.ts +59 -0
- package/dist/esm/internal/AtomicHelperFault.d.ts.map +1 -0
- package/dist/esm/internal/AtomicHelperFault.js +66 -0
- package/dist/esm/internal/AtomicHelperFault.js.map +1 -0
- package/dist/esm/internal/PipedProcess.d.ts +35 -0
- package/dist/esm/internal/PipedProcess.d.ts.map +1 -0
- package/dist/esm/internal/PipedProcess.js +321 -0
- package/dist/esm/internal/PipedProcess.js.map +1 -0
- package/dist/esm/internal/ProcSnapshot.d.ts +85 -0
- package/dist/esm/internal/ProcSnapshot.d.ts.map +1 -0
- package/dist/esm/internal/ProcSnapshot.js +188 -0
- package/dist/esm/internal/ProcSnapshot.js.map +1 -0
- package/dist/esm/internal/ProcessCleanup.d.ts +64 -0
- package/dist/esm/internal/ProcessCleanup.d.ts.map +1 -0
- package/dist/esm/internal/ProcessCleanup.js +45 -0
- package/dist/esm/internal/ProcessCleanup.js.map +1 -0
- package/dist/esm/internal/ProcessCleanupPolicyError.d.ts +30 -0
- package/dist/esm/internal/ProcessCleanupPolicyError.d.ts.map +1 -0
- package/dist/esm/internal/ProcessCleanupPolicyError.js +25 -0
- package/dist/esm/internal/ProcessCleanupPolicyError.js.map +1 -0
- package/dist/esm/internal/ProcessFault.d.ts +63 -0
- package/dist/esm/internal/ProcessFault.d.ts.map +1 -0
- package/dist/esm/internal/ProcessFault.js +64 -0
- package/dist/esm/internal/ProcessFault.js.map +1 -0
- package/dist/esm/internal/ProcessSupervisor.d.ts +143 -0
- package/dist/esm/internal/ProcessSupervisor.d.ts.map +1 -0
- package/dist/esm/internal/ProcessSupervisor.js +689 -0
- package/dist/esm/internal/ProcessSupervisor.js.map +1 -0
- package/dist/esm/internal/SupervisorProgram.d.ts +9 -0
- package/dist/esm/internal/SupervisorProgram.d.ts.map +1 -0
- package/dist/esm/internal/SupervisorProgram.js +310 -0
- package/dist/esm/internal/SupervisorProgram.js.map +1 -0
- package/dist/esm/internal/WindowsProcessJob.d.ts +39 -0
- package/dist/esm/internal/WindowsProcessJob.d.ts.map +1 -0
- package/dist/esm/internal/WindowsProcessJob.js +115 -0
- package/dist/esm/internal/WindowsProcessJob.js.map +1 -0
- package/dist/vendor/adapters.json +1757 -0
- package/dist/vendor/chunk-2Y7WC4KU.js +109 -0
- package/dist/vendor/chunk-3GR5VZ2M.js +118 -0
- package/dist/vendor/chunk-42QKY6T6.js +40 -0
- package/dist/vendor/chunk-54RLBMTZ.js +61 -0
- package/dist/vendor/chunk-5ZMHBXIK.js +55 -0
- package/dist/vendor/chunk-6ME2W7TF.js +28 -0
- package/dist/vendor/chunk-AMQKOQNT.js +34 -0
- package/dist/vendor/chunk-B3FZ67QU.js +59 -0
- package/dist/vendor/chunk-BKTBUBQY.js +437 -0
- package/dist/vendor/chunk-DS7GF46S.js +34 -0
- package/dist/vendor/chunk-DVOAHXPG.js +104 -0
- package/dist/vendor/chunk-DWSHTSVX.js +229 -0
- package/dist/vendor/chunk-EGBNVEEW.js +14 -0
- package/dist/vendor/chunk-EZWY45HP.js +18 -0
- package/dist/vendor/chunk-FNZOJHSV.js +71 -0
- package/dist/vendor/chunk-GXCHI7BM.js +131 -0
- package/dist/vendor/chunk-IIJ52ZU6.js +20 -0
- package/dist/vendor/chunk-J7A4CZDO.js +92 -0
- package/dist/vendor/chunk-JG5TTWPT.js +85 -0
- package/dist/vendor/chunk-JJ24ARBQ.js +394 -0
- package/dist/vendor/chunk-KOZMM5PZ.js +426 -0
- package/dist/vendor/chunk-KUUXSID7.js +18 -0
- package/dist/vendor/chunk-LEUPYT3Q.js +36 -0
- package/dist/vendor/chunk-M32LDTW7.js +18 -0
- package/dist/vendor/chunk-M7CLUILA.js +0 -0
- package/dist/vendor/chunk-MBSKBQ5D.js +21 -0
- package/dist/vendor/chunk-MLKGABMK.js +9 -0
- package/dist/vendor/chunk-NBVRTDTV.js +129 -0
- package/dist/vendor/chunk-OXNGN5H7.js +81 -0
- package/dist/vendor/chunk-QPLDT6A6.js +564 -0
- package/dist/vendor/chunk-QYBKAIA6.js +18 -0
- package/dist/vendor/chunk-RO2R4MJH.js +62 -0
- package/dist/vendor/chunk-SIR62W3Y.js +398 -0
- package/dist/vendor/chunk-TFIKFFSC.js +26 -0
- package/dist/vendor/chunk-TXKLEBBL.js +143 -0
- package/dist/vendor/chunk-UFH5UUZK.js +48 -0
- package/dist/vendor/chunk-VANKHF46.js +96 -0
- package/dist/vendor/chunk-VZBDV3TV.js +18 -0
- package/dist/vendor/chunk-XDKNKFBW.js +22 -0
- package/dist/vendor/chunk-XH4U3JSV.js +249 -0
- package/dist/vendor/chunk-Y35ZAO5U.js +53 -0
- package/dist/vendor/chunk-ZJMRMY57.js +0 -0
- package/dist/vendor/cjs/node/NodeChildProcessSpawner.d.ts +7 -0
- package/dist/vendor/cjs/node/NodeChildProcessSpawner.js +1 -0
- package/dist/vendor/cjs/node/NodeClusterHttp.d.ts +63 -0
- package/dist/vendor/cjs/node/NodeClusterHttp.js +1 -0
- package/dist/vendor/cjs/node/NodeClusterSocket.d.ts +79 -0
- package/dist/vendor/cjs/node/NodeClusterSocket.js +1 -0
- package/dist/vendor/cjs/node/NodeCrypto.d.ts +10 -0
- package/dist/vendor/cjs/node/NodeCrypto.js +1 -0
- package/dist/vendor/cjs/node/NodeFileSystem.d.ts +10 -0
- package/dist/vendor/cjs/node/NodeFileSystem.js +1 -0
- package/dist/vendor/cjs/node/NodeHttpClient.d.ts +179 -0
- package/dist/vendor/cjs/node/NodeHttpClient.js +1 -0
- package/dist/vendor/cjs/node/NodeHttpIncomingMessage.d.ts +62 -0
- package/dist/vendor/cjs/node/NodeHttpIncomingMessage.js +1 -0
- package/dist/vendor/cjs/node/NodeHttpPlatform.d.ts +36 -0
- package/dist/vendor/cjs/node/NodeHttpPlatform.js +1 -0
- package/dist/vendor/cjs/node/NodeHttpServer.d.ts +120 -0
- package/dist/vendor/cjs/node/NodeHttpServer.js +1 -0
- package/dist/vendor/cjs/node/NodeHttpServerRequest.d.ts +29 -0
- package/dist/vendor/cjs/node/NodeHttpServerRequest.js +1 -0
- package/dist/vendor/cjs/node/NodeMultipart.d.ts +46 -0
- package/dist/vendor/cjs/node/NodeMultipart.js +1 -0
- package/dist/vendor/cjs/node/NodeMultipartParser.d.ts +97 -0
- package/dist/vendor/cjs/node/NodeMultipartParser.js +1 -0
- package/dist/vendor/cjs/node/NodePath.d.ts +27 -0
- package/dist/vendor/cjs/node/NodePath.js +1 -0
- package/dist/vendor/cjs/node/NodeRedis.d.ts +74 -0
- package/dist/vendor/cjs/node/NodeRedis.js +1 -0
- package/dist/vendor/cjs/node/NodeRuntime.d.ts +85 -0
- package/dist/vendor/cjs/node/NodeRuntime.js +1 -0
- package/dist/vendor/cjs/node/NodeServices.d.ts +34 -0
- package/dist/vendor/cjs/node/NodeServices.js +1 -0
- package/dist/vendor/cjs/node/NodeSink.d.ts +8 -0
- package/dist/vendor/cjs/node/NodeSink.js +1 -0
- package/dist/vendor/cjs/node/NodeSocket.d.ts +38 -0
- package/dist/vendor/cjs/node/NodeSocket.js +1 -0
- package/dist/vendor/cjs/node/NodeSocketServer.d.ts +8 -0
- package/dist/vendor/cjs/node/NodeSocketServer.js +1 -0
- package/dist/vendor/cjs/node/NodeStdio.d.ts +11 -0
- package/dist/vendor/cjs/node/NodeStdio.js +1 -0
- package/dist/vendor/cjs/node/NodeStream.d.ts +8 -0
- package/dist/vendor/cjs/node/NodeStream.js +1 -0
- package/dist/vendor/cjs/node/NodeTerminal.d.ts +21 -0
- package/dist/vendor/cjs/node/NodeTerminal.js +1 -0
- package/dist/vendor/cjs/node/NodeWorker.d.ts +22 -0
- package/dist/vendor/cjs/node/NodeWorker.js +1 -0
- package/dist/vendor/cjs/node/NodeWorkerRunner.d.ts +12 -0
- package/dist/vendor/cjs/node/NodeWorkerRunner.js +1 -0
- package/dist/vendor/cjs/node/Undici.d.ts +28 -0
- package/dist/vendor/cjs/node/Undici.js +1 -0
- package/dist/vendor/cjs/node/index.d.ts +100 -0
- package/dist/vendor/cjs/node/index.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeChildProcessSpawner.d.ts +57 -0
- package/dist/vendor/cjs/node-shared/NodeChildProcessSpawner.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeClusterSocket.d.ts +22 -0
- package/dist/vendor/cjs/node-shared/NodeClusterSocket.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeCrypto.d.ts +27 -0
- package/dist/vendor/cjs/node-shared/NodeCrypto.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeFileSystem.d.ts +11 -0
- package/dist/vendor/cjs/node-shared/NodeFileSystem.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeHttpCompression.d.ts +36 -0
- package/dist/vendor/cjs/node-shared/NodeHttpCompression.js +1 -0
- package/dist/vendor/cjs/node-shared/NodePath.d.ts +27 -0
- package/dist/vendor/cjs/node-shared/NodePath.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeRuntime.d.ts +47 -0
- package/dist/vendor/cjs/node-shared/NodeRuntime.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeSink.d.ts +69 -0
- package/dist/vendor/cjs/node-shared/NodeSink.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeSocket.d.ts +134 -0
- package/dist/vendor/cjs/node-shared/NodeSocket.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeSocketServer.d.ts +80 -0
- package/dist/vendor/cjs/node-shared/NodeSocketServer.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeStdio.d.ts +12 -0
- package/dist/vendor/cjs/node-shared/NodeStdio.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeStream.d.ts +179 -0
- package/dist/vendor/cjs/node-shared/NodeStream.js +1 -0
- package/dist/vendor/cjs/node-shared/NodeTerminal.d.ts +22 -0
- package/dist/vendor/cjs/node-shared/NodeTerminal.js +1 -0
- package/dist/vendor/cjs/node-shared/index.d.ts +56 -0
- package/dist/vendor/cjs/node-shared/index.js +1 -0
- package/dist/vendor/cjs/node-shared/internal/nodeChildProcessSpawner.d.ts +4 -0
- package/dist/vendor/cjs/node-shared/internal/nodeChildProcessSpawner.js +1 -0
- package/dist/vendor/cjs/node-shared/internal/utils.d.ts +2 -0
- package/dist/vendor/cjs/node-shared/internal/utils.js +1 -0
- package/dist/vendor/cjs/package.json +1 -0
- package/dist/vendor/cjs/platform-node-shared.d.ts +56 -0
- package/dist/vendor/cjs/platform-node-shared.js +1 -0
- package/dist/vendor/cjs/platform-node.d.ts +100 -0
- package/dist/vendor/cjs/platform-node.js +1 -0
- package/dist/vendor/node/LICENSE +21 -0
- package/dist/vendor/node/NodeChildProcessSpawner.d.ts +7 -0
- package/dist/vendor/node/NodeChildProcessSpawner.js +14 -0
- package/dist/vendor/node/NodeClusterHttp.d.ts +63 -0
- package/dist/vendor/node/NodeClusterHttp.js +43 -0
- package/dist/vendor/node/NodeClusterSocket.d.ts +79 -0
- package/dist/vendor/node/NodeClusterSocket.js +30 -0
- package/dist/vendor/node/NodeCrypto.d.ts +10 -0
- package/dist/vendor/node/NodeCrypto.js +8 -0
- package/dist/vendor/node/NodeFileSystem.d.ts +10 -0
- package/dist/vendor/node/NodeFileSystem.js +9 -0
- package/dist/vendor/node/NodeHttpClient.d.ts +179 -0
- package/dist/vendor/node/NodeHttpClient.js +46 -0
- package/dist/vendor/node/NodeHttpIncomingMessage.d.ts +62 -0
- package/dist/vendor/node/NodeHttpIncomingMessage.js +10 -0
- package/dist/vendor/node/NodeHttpPlatform.d.ts +36 -0
- package/dist/vendor/node/NodeHttpPlatform.js +16 -0
- package/dist/vendor/node/NodeHttpServer.d.ts +120 -0
- package/dist/vendor/node/NodeHttpServer.js +46 -0
- package/dist/vendor/node/NodeHttpServerRequest.d.ts +29 -0
- package/dist/vendor/node/NodeHttpServerRequest.js +9 -0
- package/dist/vendor/node/NodeMultipart.d.ts +46 -0
- package/dist/vendor/node/NodeMultipart.js +15 -0
- package/dist/vendor/node/NodeMultipartParser.d.ts +97 -0
- package/dist/vendor/node/NodeMultipartParser.js +11 -0
- package/dist/vendor/node/NodePath.d.ts +27 -0
- package/dist/vendor/node/NodePath.js +12 -0
- package/dist/vendor/node/NodeRedis.d.ts +74 -0
- package/dist/vendor/node/NodeRedis.js +11 -0
- package/dist/vendor/node/NodeRuntime.d.ts +85 -0
- package/dist/vendor/node/NodeRuntime.js +8 -0
- package/dist/vendor/node/NodeServices.d.ts +34 -0
- package/dist/vendor/node/NodeServices.js +23 -0
- package/dist/vendor/node/NodeSink.d.ts +8 -0
- package/dist/vendor/node/NodeSink.js +12 -0
- package/dist/vendor/node/NodeSocket.d.ts +38 -0
- package/dist/vendor/node/NodeSocket.js +31 -0
- package/dist/vendor/node/NodeSocketServer.d.ts +8 -0
- package/dist/vendor/node/NodeSocketServer.js +21 -0
- package/dist/vendor/node/NodeStdio.d.ts +11 -0
- package/dist/vendor/node/NodeStdio.js +10 -0
- package/dist/vendor/node/NodeStream.d.ts +8 -0
- package/dist/vendor/node/NodeStream.js +27 -0
- package/dist/vendor/node/NodeTerminal.d.ts +21 -0
- package/dist/vendor/node/NodeTerminal.js +10 -0
- package/dist/vendor/node/NodeWorker.d.ts +22 -0
- package/dist/vendor/node/NodeWorker.js +9 -0
- package/dist/vendor/node/NodeWorkerRunner.d.ts +12 -0
- package/dist/vendor/node/NodeWorkerRunner.js +7 -0
- package/dist/vendor/node/Undici.d.ts +28 -0
- package/dist/vendor/node/Undici.js +9 -0
- package/dist/vendor/node/index.d.ts +100 -0
- package/dist/vendor/node/index.js +115 -0
- package/dist/vendor/node-shared/LICENSE +21 -0
- package/dist/vendor/node-shared/NodeChildProcessSpawner.d.ts +57 -0
- package/dist/vendor/node-shared/NodeChildProcessSpawner.js +13 -0
- package/dist/vendor/node-shared/NodeClusterSocket.d.ts +22 -0
- package/dist/vendor/node-shared/NodeClusterSocket.js +11 -0
- package/dist/vendor/node-shared/NodeCrypto.d.ts +27 -0
- package/dist/vendor/node-shared/NodeCrypto.js +9 -0
- package/dist/vendor/node-shared/NodeFileSystem.d.ts +11 -0
- package/dist/vendor/node-shared/NodeFileSystem.js +8 -0
- package/dist/vendor/node-shared/NodeHttpCompression.d.ts +36 -0
- package/dist/vendor/node-shared/NodeHttpCompression.js +13 -0
- package/dist/vendor/node-shared/NodePath.d.ts +27 -0
- package/dist/vendor/node-shared/NodePath.js +11 -0
- package/dist/vendor/node-shared/NodeRuntime.d.ts +47 -0
- package/dist/vendor/node-shared/NodeRuntime.js +7 -0
- package/dist/vendor/node-shared/NodeSink.d.ts +69 -0
- package/dist/vendor/node-shared/NodeSink.js +11 -0
- package/dist/vendor/node-shared/NodeSocket.d.ts +134 -0
- package/dist/vendor/node-shared/NodeSocket.js +23 -0
- package/dist/vendor/node-shared/NodeSocketServer.d.ts +80 -0
- package/dist/vendor/node-shared/NodeSocketServer.js +20 -0
- package/dist/vendor/node-shared/NodeStdio.d.ts +12 -0
- package/dist/vendor/node-shared/NodeStdio.js +9 -0
- package/dist/vendor/node-shared/NodeStream.d.ts +179 -0
- package/dist/vendor/node-shared/NodeStream.js +26 -0
- package/dist/vendor/node-shared/NodeTerminal.d.ts +22 -0
- package/dist/vendor/node-shared/NodeTerminal.js +9 -0
- package/dist/vendor/node-shared/index.d.ts +56 -0
- package/dist/vendor/node-shared/index.js +58 -0
- package/dist/vendor/node-shared/internal/nodeChildProcessSpawner.d.ts +4 -0
- package/dist/vendor/node-shared/internal/nodeChildProcessSpawner.js +7 -0
- package/dist/vendor/node-shared/internal/utils.d.ts +2 -0
- package/dist/vendor/node-shared/internal/utils.js +7 -0
- package/dist/vendor/platform-node-shared.d.ts +56 -0
- package/dist/vendor/platform-node-shared.js +58 -0
- package/dist/vendor/platform-node.d.ts +100 -0
- package/dist/vendor/platform-node.js +115 -0
- package/docs/README.md +129 -0
- package/docs/api.md +553 -0
- package/docs/concepts/descriptor-relative-filesystem.md +181 -0
- package/docs/concepts/host-bundle.md +125 -0
- package/docs/concepts/process-containment.md +190 -0
- package/docs/guides/answer-run-ownership.md +87 -0
- package/docs/guides/configure-the-filesystem-helper.md +152 -0
- package/docs/guides/contain-child-processes.md +139 -0
- package/docs/guides/match-files-with-glob.md +151 -0
- package/docs/installation.md +204 -0
- package/docs/quickstart.md +147 -0
- package/docs/troubleshooting.md +130 -0
- package/package.json +202 -3
- package/src/AtomicFileSystem.ts +415 -0
- package/src/EgressHttpClient.ts +327 -0
- package/src/HostLiveness.ts +103 -0
- package/src/NodeHost.ts +253 -0
- package/src/ProcessConfinement.ts +363 -0
- package/src/ProcessReaper.ts +951 -0
- package/src/ProcessSandbox.ts +1307 -0
- package/src/ScopedProcess.ts +124 -0
- package/src/index.ts +44 -0
- package/src/internal/AtomicFileSystemExecutable.ts +379 -0
- package/src/internal/AtomicFileSystemProtocol.ts +502 -0
- package/src/internal/AtomicFileSystemTransport.ts +272 -0
- package/src/internal/AtomicHelperError.ts +50 -0
- package/src/internal/AtomicHelperFault.ts +84 -0
- package/src/internal/PipedProcess.ts +357 -0
- package/src/internal/ProcSnapshot.ts +193 -0
- package/src/internal/ProcessCleanup.ts +99 -0
- package/src/internal/ProcessCleanupPolicyError.ts +30 -0
- package/src/internal/ProcessFault.ts +82 -0
- package/src/internal/ProcessSupervisor.ts +807 -0
- package/src/internal/SupervisorProgram.ts +309 -0
- package/src/internal/WindowsProcessJob.ts +114 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/EgressHttpClient.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The outbound HTTP client a Node process should use, read off its environment.\n *\n * `@effect/platform-node` ships `NodeHttpClient.layerUndici`, and its\n * dispatcher is a bare Undici `Agent`. A bare `Agent` dials every origin\n * directly: it does not read `HTTP_PROXY`, `HTTPS_PROXY` or `NO_PROXY`, and\n * nothing at the call site says so. That is invisible on a developer machine\n * with open egress and fatal inside a sandbox whose egress is default-deny\n * behind a named proxy \u2014 the request leaves for the origin, the firewall drops\n * it, and the only symptom is a transport failure far from the composition\n * that chose the client.\n *\n * This module is the one place that decision is made. {@link layer} is the\n * client every Node host composition installs; it honours the proxy the\n * environment names. Requests without a web destination use a shared pool;\n * web requests receive a fresh pinned dispatcher.\n *\n * The rule for loopback is fixed here, not by the environment: `localhost`,\n * `127.0.0.1` and `[::1]` are always reached directly, even when the\n * environment names a proxy and no exclusion, and every other origin follows\n * `NO_PROXY`. A proxy is how a process leaves its machine, and\n * `--remote http://127.0.0.1:3000` is not leaving it. The exemption is those\n * three names and nothing wider: Undici matches `NO_PROXY` entries by name,\n * never by resolved address, so `127.0.0.2` or a hostname that resolves to\n * loopback is an origin like any other and goes through the proxy.\n *\n * @since 1.0.0-rc.0\n */\n\nimport * as NodeHttpClient from \"@effect/platform-node/NodeHttpClient\"\nimport type * as Undici from \"@effect/platform-node/Undici\"\nimport { GrantStore } from \"@smthrs/kernel/GrantStore\"\nimport * as KernelHttpClient from \"@smthrs/kernel/HttpClient\"\nimport { Destination, withDestinationPinning } from \"@smthrs/kernel/HttpClient\"\nimport * as Effect from \"effect/Effect\"\nimport * as Exit from \"effect/Exit\"\nimport * as Layer from \"effect/Layer\"\nimport * as Schema from \"effect/Schema\"\nimport * as Scope from \"effect/Scope\"\nimport * as Semaphore from \"effect/Semaphore\"\nimport { HttpClient } from \"effect/unstable/http/HttpClient\"\nimport * as EffectHttpClient from \"effect/unstable/http/HttpClient\"\nimport * as HttpClientError from \"effect/unstable/http/HttpClientError\"\nimport * as HttpClientRequest from \"effect/unstable/http/HttpClientRequest\"\nimport { isIP } from \"node:net\"\n\n/**\n * A pinned connection asked for an address family none of the authorized\n * addresses has. It is the `cause` of the `TransportError` the request fails\n * with; `code` is always `no_approved_address`.\n *\n * @category errors\n * @since 1.0.0\n */\nexport class EgressAddressError extends Schema.TaggedError<EgressAddressError>()(\n \"@smthrs/platform-node/EgressAddressError\",\n { code: Schema.Literal(\"no_approved_address\"), message: Schema.String }\n) {\n override readonly name = \"EgressAddressError\"\n}\n\n/**\n * The hosts a proxy is never for. A proxy is how a process leaves its machine;\n * these names are the machine itself. Matched by name, the way Undici matches\n * every `NO_PROXY` entry, so the list is exactly these three and not\n * `127.0.0.0/8`.\n */\nconst loopback = [\"localhost\", \"127.0.0.1\", \"::1\"] as const\n\n/**\n * The exclusion list to hand Undici, given the one the environment names.\n *\n * Undici proxies *every* origin when `NO_PROXY` is empty \u2014 `#shouldProxy`\n * returns early with \"Always proxy if NO_PROXY is not set or empty\" \u2014 so a host\n * that names a proxy to reach the internet would also send `smthrs --remote\n * http://127.0.0.1:3000` and a local Ollama at `http://localhost:11434` to it.\n * Nothing in this repository has ever needed `NO_PROXY=127.0.0.1`, because the\n * client these compositions used before ignored the proxy variables outright.\n * So loopback is always excluded, the way Go's `net/http.ProxyFromEnvironment`\n * excludes it, and the environment's own entries are kept beside it.\n *\n * `*` is returned untouched: Undici recognises the wildcard only as the entire\n * value, and it already means every origin is direct.\n */\nconst exclusions = (declared: string): string =>\n declared === \"*\" ? declared : [declared, ...loopback].filter((entry) => entry !== \"\").join(\",\")\n\n// Split ESM bundles expose CommonJS Undici through default, without synthetic\n// named exports. Node and Bun also expose its constructors through default.\n// Its typings declare `default` as a namespace without them, and `bundler`\n// resolution reads that, so the value is typed as the module it carries.\nconst loadUndici = Effect.promise(\n async () => (await import(\"undici/index.js\")).default as unknown as typeof Undici\n)\n\n/**\n * An Undici dispatcher that routes through the egress proxy the supplied\n * environment names, or a direct one when it names none.\n *\n * The proxy variables are read in the order Undici itself reads them,\n * lowercase first, and passed explicitly rather than left to\n * `EnvHttpProxyAgent`'s own ambient lookup: a host serving a guest's\n * environment is not the guest, and the pool has to follow the record it was\n * handed. Loopback is always direct; see {@link exclusions}. Each dispatcher is\n * acquired in the caller's scope and destroyed with it, so a composition that\n * builds several still owns every pool it opened.\n *\n * @param environment the environment record whose proxy variables decide the route\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const dispatcher = (\n environment: Readonly<Record<string, string | undefined>>\n): Effect.Effect<Undici.Dispatcher, never, Scope.Scope> =>\n Effect.suspend(() => {\n const httpProxy = environment.http_proxy ?? environment.HTTP_PROXY ?? \"\"\n const httpsProxy = environment.https_proxy ?? environment.HTTPS_PROXY ?? \"\"\n const noProxy = exclusions(environment.no_proxy ?? environment.NO_PROXY ?? \"\")\n // Explicit empty values prevent Undici from falling back to a different\n // ambient environment. Each replacement pool uses the same proxy policy.\n //\n // Undici is loaded here rather than imported at the top, the way\n // `NodeHttpClient.makeDispatcher` loads it, because this module is imported\n // by `NodeHost` and every bundle built on it. A static import pulls the\n // whole of Undici into any process that merely composes a host, whose\n // side effects a host bundle must not carry: it reddened the Node host's\n // own `FileSystem` contract case, which never makes a request. The explicit\n // package entry also avoids Bun's incomplete built-in \"undici\" substitute.\n return Effect.acquireRelease(\n Effect.map(\n loadUndici,\n (undici) => new undici.EnvHttpProxyAgent({ httpProxy, httpsProxy, noProxy })\n ),\n (dispatcher) => Effect.promise(() => dispatcher.destroy())\n )\n })\n\n/**\n * The Undici `HttpClient` to install, given the environment the process runs in.\n *\n * Use this wherever `NodeHttpClient.layerUndici` would otherwise be provided\n * under a layer that takes `HttpClient` from context \u2014 a model transport, a\n * judge, a fetch rule, a host bundle. The two differ only in whether the pool\n * honours `HTTP_PROXY`/`HTTPS_PROXY`/`NO_PROXY`, which is the difference\n * between a request that reaches the gateway from inside a default-deny\n * sandbox and one the firewall drops.\n *\n * @param environment the environment record whose proxy variables decide the route\n * @category layers\n * @since 1.0.0-rc.0\n */\nexport const layer = (\n environment: Readonly<Record<string, string | undefined>>\n): Layer.Layer<HttpClient> =>\n Layer.effect(\n HttpClient,\n Effect.gen(function*() {\n const shared = yield* dispatcher(environment)\n const ordinary = yield* NodeHttpClient.makeUndici.pipe(Effect.provideService(NodeHttpClient.Dispatcher, shared))\n return withDestinationPinning(EffectHttpClient.transform(ordinary, (execute, request) =>\n Effect.gen(function*() {\n const destination = yield* Destination\n if (destination === undefined) return yield* execute\n const url = new URL(request.url)\n if (\n url.origin !== destination.origin || destination.addresses.length === 0 ||\n destination.addresses.some((address) => isIP(address) === 0)\n ) {\n return yield* Effect.fail(\n new HttpClientError.HttpClientError({\n reason: new HttpClientError.TransportError({\n request,\n description: \"Invalid pinned HTTP destination\"\n })\n })\n )\n }\n const proxies = [\n environment.http_proxy ?? environment.HTTP_PROXY,\n environment.https_proxy ?? environment.HTTPS_PROXY\n ]\n // The record is read per request, and a live one such as NodeHost's\n // `process.env` can name an unparsable proxy after the shared pool\n // was built from it; that is a refusal here, never a thrown URL error.\n const validProxies = proxies.every((proxy) => {\n if (!proxy) return true\n try {\n return [\"http:\", \"https:\"].includes(new URL(proxy).protocol)\n } catch {\n return false\n }\n })\n if (!validProxies) {\n return yield* Effect.fail(\n new HttpClientError.HttpClientError({\n reason: new HttpClientError.TransportError({\n request,\n description: \"Pinned HTTP requests require HTTP or HTTPS proxies\"\n })\n })\n )\n }\n const undici = yield* loadUndici\n const addresses = destination.addresses.map((address) => ({ address, family: isIP(address) }))\n // Construction and its disposal are one uninterruptible step: an\n // interruption that lands after the agent exists but before the request\n // owns it would otherwise leave the agent neither destroyed nor closed.\n return yield* Effect.uninterruptibleMask((restore) => {\n const pinned = new undici.EnvHttpProxyAgent({\n httpProxy: environment.http_proxy ?? environment.HTTP_PROXY ?? \"\",\n httpsProxy: environment.https_proxy ?? environment.HTTPS_PROXY ?? \"\",\n noProxy: exclusions(environment.no_proxy ?? environment.NO_PROXY ?? \"\"),\n // Tunnelling HTTP too prevents the proxy resolving the target hostname.\n proxyTunnel: true,\n connect: {\n lookup: (_hostname, options, callback) => {\n const candidates = options.family\n ? addresses.filter((item) => item.family === options.family)\n : addresses\n const first = candidates[0]\n if (first === undefined) {\n return callback(\n new EgressAddressError({\n code: \"no_approved_address\",\n message: \"No approved address for family\"\n }),\n \"\",\n 4\n )\n }\n if (options.all) callback(null, candidates)\n else callback(null, first.address, first.family)\n }\n },\n clientFactory: (origin, options) => {\n const proxy = new undici.Pool(origin, options)\n const connect = proxy.connect.bind(proxy)\n // EnvHttpProxyAgent selects the route using the ORIGINAL hostname.\n // Only the proxy tunnel destination changes; endpoint TLS still uses\n // the original hostname for SNI and certificate verification.\n proxy.connect = (options: Undici.Dispatcher.ConnectOptions) => {\n const address = addresses[0]!.address\n const host = isIP(address) === 6 ? `[${address}]` : address\n const authority = `${host}:${url.port || (url.protocol === \"https:\" ? \"443\" : \"80\")}`\n return connect({ ...options, path: authority, headers: { ...options.headers, host: authority } })\n }\n return proxy\n }\n })\n const pinnedRequest = request.pipe(\n HttpClientRequest.setHeader(\"host\", url.host),\n HttpClientRequest.removeHeader(\"proxy-authorization\"),\n HttpClientRequest.removeHeader(\"connection\"),\n HttpClientRequest.removeHeader(\"transfer-encoding\"),\n HttpClientRequest.removeHeader(\"content-length\")\n )\n return restore(NodeHttpClient.makeUndici.pipe(\n Effect.provideService(NodeHttpClient.Dispatcher, pinned),\n Effect.flatMap((client) => client.execute(pinnedRequest))\n )).pipe(Effect.onExit((exit) =>\n Exit.isFailure(exit)\n ? Effect.promise(() => pinned.destroy())\n // close prevents reuse immediately, but lets the active body drain.\n : Effect.sync(() => {\n void pinned.close().catch(() => pinned.destroy())\n })\n ))\n })\n })))\n })\n )\n\n/**\n * Owns one replaceable Undici pool in the caller's scope. Each replacement\n * receives the same middleware and closes the previous pool.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const rebuildableTransport = (\n acquire: Effect.Effect<Undici.Dispatcher, never, Scope.Scope>,\n decorate: (client: HttpClient) => Effect.Effect<HttpClient> = Effect.succeed\n): Effect.Effect<\n {\n readonly client: HttpClient\n readonly rebuild: Effect.Effect<HttpClient>\n },\n never,\n Scope.Scope\n> =>\n Effect.gen(function*() {\n const scope = yield* Scope.Scope\n const gate = yield* Semaphore.make(1)\n let held: Scope.Closeable | undefined = undefined\n const rebuild = gate.withPermit(Effect.uninterruptibleMask((restore) =>\n Effect.gen(function*() {\n const owned = yield* Scope.fork(scope)\n const client = yield* restore(NodeHttpClient.makeUndici.pipe(\n Effect.provideServiceEffect(NodeHttpClient.Dispatcher, acquire),\n Effect.flatMap(decorate),\n Effect.provideService(Scope.Scope, owned)\n )).pipe(Effect.onExit((exit) => Exit.isSuccess(exit) ? Effect.void : Scope.close(owned, exit)))\n const previous = held\n held = owned\n if (previous !== undefined) yield* Scope.close(previous, Exit.void)\n return client\n })\n ))\n return { client: yield* rebuild, rebuild }\n })\n\n/**\n * A model transport whose replacements retain the caller's grant store and\n * environment proxy policy. Pass it to RequestExecutor.makeWith in the host scope.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const guardedTransport = (environment: Readonly<Record<string, string | undefined>>) =>\n Effect.gen(function*() {\n const grants = yield* GrantStore\n return yield* rebuildableTransport(dispatcher(environment), (client) =>\n HttpClient.pipe(Effect.provide(KernelHttpClient.layer.pipe(\n Layer.provide(Layer.succeed(HttpClient)(client)),\n Layer.provide(Layer.succeed(GrantStore)(grants))\n ))))\n })\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BA,qBAAgC;AAEhC,wBAA2B;AAC3B,uBAAkC;AAClC,wBAAoD;AACpD,aAAwB;AACxB,WAAsB;AACtB,YAAuB;AACvB,aAAwB;AACxB,YAAuB;AACvB,gBAA2B;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AY;AACrB,QAAM,SAAS,OAAO;AACtB,SAAO,OAAO,qBAAqB,WAAW,WAAW,GAAG,CAAC,WAC3D,8BAAW,KAAK,OAAO,QAAQ,iBAAiB,MAAM;AAAA,IACpD,MAAM,QAAQ,MAAM,QAAQ,6BAAU,EAAE,MAAM,CAAC;AAAA,IAC/C,MAAM,QAAQ,MAAM,QAAQ,4BAAU,EAAE,MAAM,CAAC;AAAA,EACjD,CAAC,CAAC,CAAC;AACP,CAAC;",
|
|
6
|
+
"names": ["import_HttpClient", "dispatcher", "options"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Answers whether a recorded run owner is still alive on this host.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.1.0
|
|
5
|
+
*/
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
/**
|
|
8
|
+
* The owner identity fields liveness is decided from.
|
|
9
|
+
*
|
|
10
|
+
* Structural on purpose: `@smthrs/journal`'s `OwnerId` is exactly this shape
|
|
11
|
+
* plus a nonce, so an `OwnerId` is accepted here without this package taking a
|
|
12
|
+
* dependency on the journal to name a type.
|
|
13
|
+
*
|
|
14
|
+
* @category models
|
|
15
|
+
* @since 0.1.0
|
|
16
|
+
*/
|
|
17
|
+
export interface Owner {
|
|
18
|
+
/** The host the owner ran on. */
|
|
19
|
+
readonly hostId: string;
|
|
20
|
+
/** The operating-system process id that held the run. */
|
|
21
|
+
readonly pid: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Liveness configuration.
|
|
25
|
+
*
|
|
26
|
+
* @category models
|
|
27
|
+
* @since 0.1.0
|
|
28
|
+
*/
|
|
29
|
+
export interface Options {
|
|
30
|
+
/** The host id this process answers for. */
|
|
31
|
+
readonly hostId: string;
|
|
32
|
+
/**
|
|
33
|
+
* How the probe asks the operating system. Default `process.kill`, which
|
|
34
|
+
* delivers nothing for signal 0 and only reports whether the pid is
|
|
35
|
+
* signalable.
|
|
36
|
+
*/
|
|
37
|
+
readonly signal?: ((pid: number, signal: 0) => void) | undefined;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Builds the liveness probe `EngineStore` consults before it steals a run.
|
|
41
|
+
*
|
|
42
|
+
* The engine asks this before taking a run whose recorded owner it is not, so
|
|
43
|
+
* a wrong `true` strands a run and a wrong `false` runs it twice. The rule is
|
|
44
|
+
* therefore asymmetric on purpose:
|
|
45
|
+
*
|
|
46
|
+
* - An owner from a **different host** is alive. A pid means nothing across
|
|
47
|
+
* machines, and the process table this probe reads is only this machine's.
|
|
48
|
+
* - An owner from **this host** is dead only when the signal-0 probe reports
|
|
49
|
+
* `ESRCH`. Every other result preserves liveness.
|
|
50
|
+
*
|
|
51
|
+
* The residual risk is pid reuse. An owner whose pid was recycled by an
|
|
52
|
+
* unrelated program reads as alive and its run waits for an operator, which is
|
|
53
|
+
* the safe direction: nothing about a recycled pid can tell this process
|
|
54
|
+
* whether the run is still being driven, and the cost of guessing wrong the
|
|
55
|
+
* other way is two hosts executing one run.
|
|
56
|
+
*
|
|
57
|
+
* A multi-process deployment with a supervisor or a lease system knows better
|
|
58
|
+
* than any pid probe and should answer from that instead.
|
|
59
|
+
*
|
|
60
|
+
* `@smthrs/run-store`'s `Ownership.sameHostPidProbe` fills the same
|
|
61
|
+
* `LivenessCheck`. Both probes use the same `ESRCH`-only death rule.
|
|
62
|
+
* `EPERM`, `EINVAL`, and unknown signal errors preserve liveness.
|
|
63
|
+
*
|
|
64
|
+
* The cross-host policy differs. `sameHostPidProbe` compares the owner's
|
|
65
|
+
* `hostId` with `context.claimant.hostId` and returns `false` for a foreign
|
|
66
|
+
* host, leaving the expired lease to govern reclaiming the run. This probe
|
|
67
|
+
* compares with the configured `hostId` and returns `true` for a foreign
|
|
68
|
+
* host, so a permanently dead foreign host's runs wait for an operator.
|
|
69
|
+
*
|
|
70
|
+
* Which answer a deployment gets depends on the entry point it used:
|
|
71
|
+
* `@smthrs/flows`' `NodeRuntime` defaults to this function, while
|
|
72
|
+
* `@smthrs/cli`'s `NodeControl` passes `sameHostPidProbe`. This function
|
|
73
|
+
* returns a one-argument function, which is structurally accepted as an
|
|
74
|
+
* `Ownership.LivenessCheck` and ignores its `context` argument. Pick the
|
|
75
|
+
* probe for its cross-host policy and source of host identity.
|
|
76
|
+
*
|
|
77
|
+
* @category constructors
|
|
78
|
+
* @since 0.1.0
|
|
79
|
+
*/
|
|
80
|
+
export declare const isAlive: (options: Options) => (owner: Owner) => Effect.Effect<boolean>;
|
|
81
|
+
//# sourceMappingURL=HostLiveness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HostLiveness.d.ts","sourceRoot":"","sources":["../../src/HostLiveness.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;;;;;;;GASG;AACH,MAAM,WAAW,KAAK;IACpB,iCAAiC;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,yDAAyD;IACzD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB,4CAA4C;IAC5C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC,GAAG,SAAS,CAAA;CACjE;AAgBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,OAAO,GAAI,SAAS,OAAO,KAAG,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,CAKjF,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var HostLiveness_exports = {};
|
|
30
|
+
__export(HostLiveness_exports, {
|
|
31
|
+
isAlive: () => isAlive
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(HostLiveness_exports);
|
|
34
|
+
var Effect = __toESM(require("effect/Effect"), 1);
|
|
35
|
+
const signalable = (send, pid) => {
|
|
36
|
+
try {
|
|
37
|
+
send(pid, 0);
|
|
38
|
+
return true;
|
|
39
|
+
} catch (cause) {
|
|
40
|
+
return cause?.code !== "ESRCH";
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const isAlive = (options) => {
|
|
44
|
+
const send = options.signal ?? ((pid, signal) => {
|
|
45
|
+
process.kill(pid, signal);
|
|
46
|
+
});
|
|
47
|
+
return (owner) => Effect.sync(() => owner.hostId !== options.hostId || signalable(send, owner.pid));
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=HostLiveness.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/HostLiveness.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Answers whether a recorded run owner is still alive on this host.\n *\n * @since 0.1.0\n */\n\nimport * as Effect from \"effect/Effect\"\n\n/**\n * The owner identity fields liveness is decided from.\n *\n * Structural on purpose: `@smthrs/journal`'s `OwnerId` is exactly this shape\n * plus a nonce, so an `OwnerId` is accepted here without this package taking a\n * dependency on the journal to name a type.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface Owner {\n /** The host the owner ran on. */\n readonly hostId: string\n /** The operating-system process id that held the run. */\n readonly pid: number\n}\n\n/**\n * Liveness configuration.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface Options {\n /** The host id this process answers for. */\n readonly hostId: string\n /**\n * How the probe asks the operating system. Default `process.kill`, which\n * delivers nothing for signal 0 and only reports whether the pid is\n * signalable.\n */\n readonly signal?: ((pid: number, signal: 0) => void) | undefined\n}\n\nconst signalable = (send: (pid: number, signal: 0) => void, pid: number): boolean => {\n try {\n send(pid, 0)\n return true\n } catch (cause) {\n // ESRCH means the process is gone. EPERM means it exists and belongs to\n // another user, which is still a live owner this host must not rob. A throw\n // that is not an object at all carries no code, and reading through it\n // rather than off it is what stops that crashing the probe: a thrown string\n // or `null` is an answer nobody gave, which is a live owner.\n return (cause as { readonly code?: string } | null | undefined)?.code !== \"ESRCH\"\n }\n}\n\n/**\n * Builds the liveness probe `EngineStore` consults before it steals a run.\n *\n * The engine asks this before taking a run whose recorded owner it is not, so\n * a wrong `true` strands a run and a wrong `false` runs it twice. The rule is\n * therefore asymmetric on purpose:\n *\n * - An owner from a **different host** is alive. A pid means nothing across\n * machines, and the process table this probe reads is only this machine's.\n * - An owner from **this host** is dead only when the signal-0 probe reports\n * `ESRCH`. Every other result preserves liveness.\n *\n * The residual risk is pid reuse. An owner whose pid was recycled by an\n * unrelated program reads as alive and its run waits for an operator, which is\n * the safe direction: nothing about a recycled pid can tell this process\n * whether the run is still being driven, and the cost of guessing wrong the\n * other way is two hosts executing one run.\n *\n * A multi-process deployment with a supervisor or a lease system knows better\n * than any pid probe and should answer from that instead.\n *\n * `@smthrs/run-store`'s `Ownership.sameHostPidProbe` fills the same\n * `LivenessCheck`. Both probes use the same `ESRCH`-only death rule.\n * `EPERM`, `EINVAL`, and unknown signal errors preserve liveness.\n *\n * The cross-host policy differs. `sameHostPidProbe` compares the owner's\n * `hostId` with `context.claimant.hostId` and returns `false` for a foreign\n * host, leaving the expired lease to govern reclaiming the run. This probe\n * compares with the configured `hostId` and returns `true` for a foreign\n * host, so a permanently dead foreign host's runs wait for an operator.\n *\n * Which answer a deployment gets depends on the entry point it used:\n * `@smthrs/flows`' `NodeRuntime` defaults to this function, while\n * `@smthrs/cli`'s `NodeControl` passes `sameHostPidProbe`. This function\n * returns a one-argument function, which is structurally accepted as an\n * `Ownership.LivenessCheck` and ignores its `context` argument. Pick the\n * probe for its cross-host policy and source of host identity.\n *\n * @category constructors\n * @since 0.1.0\n */\nexport const isAlive = (options: Options): (owner: Owner) => Effect.Effect<boolean> => {\n const send = options.signal ?? ((pid, signal) => {\n process.kill(pid, signal)\n })\n return (owner) => Effect.sync(() => owner.hostId !== options.hostId || signalable(send, owner.pid))\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,aAAwB;AAoCxB,MAAM,aAAa,CAAC,MAAwC,QAAyB;AACnF,MAAI;AACF,SAAK,KAAK,CAAC;AACX,WAAO;AAAA,EACT,SAAS,OAAO;AAMd,WAAQ,OAAyD,SAAS;AAAA,EAC5E;AACF;AA2CO,MAAM,UAAU,CAAC,YAA+D;AACrF,QAAM,OAAO,QAAQ,WAAW,CAAC,KAAK,WAAW;AAC/C,YAAQ,KAAK,KAAK,MAAM;AAAA,EAC1B;AACA,SAAO,CAAC,UAAU,OAAO,KAAK,MAAM,MAAM,WAAW,QAAQ,UAAU,WAAW,MAAM,MAAM,GAAG,CAAC;AACpG;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aggregate Node.js Host bundle.
|
|
3
|
+
*
|
|
4
|
+
* This module defines the `NodeHost` service union and a single `layer` that
|
|
5
|
+
* provides the closed Host surface backed by Node: `@effect/platform-node`'s
|
|
6
|
+
* filesystem, child-process spawner, Undici `HttpClient`, native `Path`,
|
|
7
|
+
* and the Node `Jj` adapter from its own package. Use the layer when a Node
|
|
8
|
+
* program wants every host capability from one place; use the individual
|
|
9
|
+
* modules when a program should only be able to reach part of the host. The
|
|
10
|
+
* bundle also supplies native `ProcessConfinement` for the kernel spawner.
|
|
11
|
+
*
|
|
12
|
+
* There is no Node HTTP module either: outgoing requests are Effect's
|
|
13
|
+
* `HttpClient`, and `@effect/platform-node` already ships the Undici-backed
|
|
14
|
+
* implementation. Undici follows no redirect unless a redirect interceptor is
|
|
15
|
+
* installed, so every hop stays visible to `@smthrs/kernel`'s decorator.
|
|
16
|
+
*
|
|
17
|
+
* There is no Node shell module: running a command is Effect's
|
|
18
|
+
* `ChildProcessSpawner`, and `@effect/platform-node` already ships the
|
|
19
|
+
* implementation.
|
|
20
|
+
*
|
|
21
|
+
* @since 0.1.0
|
|
22
|
+
*/
|
|
23
|
+
import * as NodeChildProcessSpawner from "../vendor/cjs/node/NodeChildProcessSpawner.js";
|
|
24
|
+
import * as NodeCrypto from "../vendor/cjs/node/NodeCrypto.js";
|
|
25
|
+
import * as NodeFileSystem from "../vendor/cjs/node/NodeFileSystem.js";
|
|
26
|
+
import * as NodeHttpClient from "../vendor/cjs/node/NodeHttpClient.js";
|
|
27
|
+
import type { Jj, JjError } from "@smthrs/jj";
|
|
28
|
+
import type { HostServiceIds } from "@smthrs/kernel/HostServices";
|
|
29
|
+
import type * as KernelProcessConfinement from "@smthrs/kernel/ProcessConfinement";
|
|
30
|
+
import type * as ProcessLedger from "@smthrs/kernel/ProcessLedger";
|
|
31
|
+
import type { FileSystem } from "effect/FileSystem";
|
|
32
|
+
import * as Layer from "effect/Layer";
|
|
33
|
+
import type * as Path from "effect/Path";
|
|
34
|
+
import * as Schema from "effect/Schema";
|
|
35
|
+
import type { HttpClient } from "effect/unstable/http/HttpClient";
|
|
36
|
+
import type { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner";
|
|
37
|
+
import * as AtomicFileSystem from "./AtomicFileSystem.ts";
|
|
38
|
+
import * as EgressHttpClient from "./EgressHttpClient.ts";
|
|
39
|
+
import * as ProcessReaper from "./ProcessReaper.ts";
|
|
40
|
+
/**
|
|
41
|
+
* The Node platform modules Effect ships, re-exported so a program that wants
|
|
42
|
+
* only part of the host has one place to reach for them. `NodeJj` belongs to
|
|
43
|
+
* `@smthrs/jj`; import it from there.
|
|
44
|
+
*
|
|
45
|
+
* `NodeCrypto` is here for a different reason than the rest. `Crypto` is not a
|
|
46
|
+
* Host service — it carries no host authority the kernel could attenuate, so
|
|
47
|
+
* it is not in {@link NodeHost} and not in the closed list — but every durable
|
|
48
|
+
* composition needs one, and a program that already depends on this package
|
|
49
|
+
* for its host should not have to add a second dependency for the digest.
|
|
50
|
+
*
|
|
51
|
+
* @category re-exports
|
|
52
|
+
* @since 0.1.0
|
|
53
|
+
*/
|
|
54
|
+
export { AtomicFileSystem, EgressHttpClient, NodeChildProcessSpawner, NodeCrypto, NodeFileSystem, NodeHttpClient, ProcessReaper };
|
|
55
|
+
/**
|
|
56
|
+
* The union of host services provided by the Node host layer.
|
|
57
|
+
*
|
|
58
|
+
* @category models
|
|
59
|
+
* @since 0.1.0
|
|
60
|
+
*/
|
|
61
|
+
export type NodeHost = FileSystem | Path.Path | ChildProcessSpawner | Jj | HttpClient | KernelProcessConfinement.ProcessConfinement;
|
|
62
|
+
declare const NodeHostError_base: Schema.Class<NodeHostError, Schema.TaggedStruct<"@smthrs/platform-node/NodeHostError", {
|
|
63
|
+
readonly code: Schema.Literal<"invalid_repository_root">;
|
|
64
|
+
readonly message: Schema.String;
|
|
65
|
+
}>, import("effect/Cause").YieldableError>;
|
|
66
|
+
/**
|
|
67
|
+
* Invalid repository-root configuration, refused before layer construction.
|
|
68
|
+
* @category errors
|
|
69
|
+
* @since 1.0.0-rc.0
|
|
70
|
+
*/
|
|
71
|
+
export declare class NodeHostError extends NodeHostError_base {
|
|
72
|
+
readonly name = "NodeHostError";
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Stable implementation identities for the raw bundle's five Host slots.
|
|
76
|
+
* Contained POSIX factories replace its spawner with {@link ProcessReaper.layerSpawner}.
|
|
77
|
+
* @category models
|
|
78
|
+
* @since 1.0.0-rc.0
|
|
79
|
+
*/
|
|
80
|
+
export declare const implementationIds: Readonly<Record<(typeof HostServiceIds)[number], string>>;
|
|
81
|
+
/**
|
|
82
|
+
* What a caller may configure about a contained Node host.
|
|
83
|
+
*
|
|
84
|
+
* `platform` is deliberately absent. `ContainedSpawner.Options` declares it so a
|
|
85
|
+
* caller that supplies its own spawner can describe one, but this native host
|
|
86
|
+
* detaches by `process.platform` whatever a record claims. A caller-supplied
|
|
87
|
+
* `"win32"` on a POSIX host would therefore
|
|
88
|
+
* record `pgid: null` for a child that really does lead a group, and
|
|
89
|
+
* {@link ProcessReaper.reap} would retire that record as `no-group` and leave
|
|
90
|
+
* the orphan running forever — a durable lie rather than a compile error.
|
|
91
|
+
*
|
|
92
|
+
* @category models
|
|
93
|
+
* @since 1.0.0-rc.0
|
|
94
|
+
*/
|
|
95
|
+
export type ContainedOptions = ProcessReaper.SpawnerOptions & ProcessReaper.Options;
|
|
96
|
+
/**
|
|
97
|
+
* Provides the default Node implementations for the whole closed Host surface.
|
|
98
|
+
*
|
|
99
|
+
* @category layers
|
|
100
|
+
* @since 0.1.0
|
|
101
|
+
*/
|
|
102
|
+
export declare const layer: Layer.Layer<NodeHost, JjError>;
|
|
103
|
+
/**
|
|
104
|
+
* Provides the Node host with `Jj` bound to one absolute repository root.
|
|
105
|
+
*
|
|
106
|
+
* @category layers
|
|
107
|
+
* @since 1.0.0
|
|
108
|
+
*/
|
|
109
|
+
export declare const layerAt: (repositoryRoot: string) => Layer.Layer<NodeHost, JjError>;
|
|
110
|
+
/**
|
|
111
|
+
* Provides the Node host with process containment turned on.
|
|
112
|
+
*
|
|
113
|
+
* The difference from {@link layer} is what happens to a spawned process when
|
|
114
|
+
* its run stops. Under {@link layer} a child is signalled when its scope
|
|
115
|
+
* closes and then waited for, forever if it ignores `SIGTERM`, and a host that
|
|
116
|
+
* dies without closing its scopes abandons every child it started. This layer
|
|
117
|
+
* gives each child an escalation deadline and records it in the
|
|
118
|
+
* `ProcessLedger`, then sweeps the records a previous incarnation of the same
|
|
119
|
+
* host left behind before it hands the host over
|
|
120
|
+
* ({@link ProcessReaper.reap}).
|
|
121
|
+
*
|
|
122
|
+
* jj is contained here too: `layerContained` builds the `Jj` service over the
|
|
123
|
+
* same spawner rather than letting it start its own children, so a `jj`
|
|
124
|
+
* invocation a crashed host left running is a record the next incarnation
|
|
125
|
+
* reaps like any other.
|
|
126
|
+
*
|
|
127
|
+
* The ledger is a requirement rather than a default because the durable half
|
|
128
|
+
* of containment is only as good as the journal underneath it:
|
|
129
|
+
* `ProcessLedger.layer` inherits a crashed incarnation's processes,
|
|
130
|
+
* `ProcessLedger.layerMemory` contains this incarnation and nothing more, and
|
|
131
|
+
* the choice belongs to the program that knows which it has.
|
|
132
|
+
*
|
|
133
|
+
* @category layers
|
|
134
|
+
* @since 0.1.0
|
|
135
|
+
*/
|
|
136
|
+
export declare const layerContained: (options?: ContainedOptions) => Layer.Layer<NodeHost, JjError, ProcessLedger.ProcessLedger>;
|
|
137
|
+
/**
|
|
138
|
+
* Provides the contained Node host with `Jj` bound to one absolute repository
|
|
139
|
+
* root.
|
|
140
|
+
*
|
|
141
|
+
* @category layers
|
|
142
|
+
* @since 1.0.0
|
|
143
|
+
*/
|
|
144
|
+
export declare const layerContainedAt: (repositoryRoot: string, options?: ContainedOptions) => Layer.Layer<NodeHost, JjError, ProcessLedger.ProcessLedger>;
|
|
145
|
+
//# sourceMappingURL=NodeHost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeHost.d.ts","sourceRoot":"","sources":["../../src/NodeHost.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,uBAAuB,MAAM,+CAA+C,CAAA;AACxF,OAAO,KAAK,UAAU,MAAM,kCAAkC,CAAA;AAC9D,OAAO,KAAK,cAAc,MAAM,sCAAsC,CAAA;AACtE,OAAO,KAAK,cAAc,MAAM,sCAAsC,CAAA;AAEtE,OAAO,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,KAAK,KAAK,wBAAwB,MAAM,mCAAmC,CAAA;AAClF,OAAO,KAAK,KAAK,aAAa,MAAM,8BAA8B,CAAA;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,KAAK,IAAI,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,K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O,MAAM,gBAAgB,GAC3B,gBAAgB,MAAM,EACtB,UAAU,gBAAgB,KACzB,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,aAAa,CAAC,aAAa,CAW5D,CAAA"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var NodeHost_exports = {};
|
|
30
|
+
__export(NodeHost_exports, {
|
|
31
|
+
AtomicFileSystem: () => AtomicFileSystem,
|
|
32
|
+
EgressHttpClient: () => EgressHttpClient,
|
|
33
|
+
NodeChildProcessSpawner: () => NodeChildProcessSpawner,
|
|
34
|
+
NodeCrypto: () => NodeCrypto,
|
|
35
|
+
NodeFileSystem: () => NodeFileSystem,
|
|
36
|
+
NodeHostError: () => NodeHostError,
|
|
37
|
+
NodeHttpClient: () => NodeHttpClient,
|
|
38
|
+
ProcessReaper: () => ProcessReaper,
|
|
39
|
+
implementationIds: () => implementationIds,
|
|
40
|
+
layer: () => layer,
|
|
41
|
+
layerAt: () => layerAt,
|
|
42
|
+
layerContained: () => layerContained,
|
|
43
|
+
layerContainedAt: () => layerContainedAt
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(NodeHost_exports);
|
|
46
|
+
var NodeChildProcessSpawner = __toESM(require("../vendor/cjs/node/NodeChildProcessSpawner.js"), 1);
|
|
47
|
+
var NodeCrypto = __toESM(require("../vendor/cjs/node/NodeCrypto.js"), 1);
|
|
48
|
+
var NodeFileSystem = __toESM(require("../vendor/cjs/node/NodeFileSystem.js"), 1);
|
|
49
|
+
var NodeHttpClient = __toESM(require("../vendor/cjs/node/NodeHttpClient.js"), 1);
|
|
50
|
+
var NodePath = __toESM(require("../vendor/cjs/node/NodePath.js"), 1);
|
|
51
|
+
var NodeJj = __toESM(require("@smthrs/jj/node/NodeJj"), 1);
|
|
52
|
+
var Layer = __toESM(require("effect/Layer"), 1);
|
|
53
|
+
var Schema = __toESM(require("effect/Schema"), 1);
|
|
54
|
+
var import_node_path = require("node:path");
|
|
55
|
+
var AtomicFileSystem = __toESM(require("./AtomicFileSystem.js"), 1);
|
|
56
|
+
var EgressHttpClient = __toESM(require("./EgressHttpClient.js"), 1);
|
|
57
|
+
var ProcessConfinement = __toESM(require("./ProcessConfinement.js"), 1);
|
|
58
|
+
var ProcessReaper = __toESM(require("./ProcessReaper.js"), 1);
|
|
59
|
+
const httpClient = EgressHttpClient.layer(process.env);
|
|
60
|
+
class NodeHostError extends Schema.TaggedError()("@smthrs/platform-node/NodeHostError", {
|
|
61
|
+
code: Schema.Literal("invalid_repository_root"),
|
|
62
|
+
message: Schema.String
|
|
63
|
+
}) {
|
|
64
|
+
name = "NodeHostError";
|
|
65
|
+
}
|
|
66
|
+
const absoluteRoot = (root) => {
|
|
67
|
+
if ((0, import_node_path.isAbsolute)(root)) return root;
|
|
68
|
+
throw new NodeHostError({
|
|
69
|
+
code: "invalid_repository_root",
|
|
70
|
+
message: `NodeHost requires an absolute repository root, got ${JSON.stringify(Array.from(root).slice(0, 64).join(""))}`
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
const implementationIds = {
|
|
74
|
+
"effect/FileSystem": "@smthrs/platform-node/AtomicFileSystem",
|
|
75
|
+
"effect/Path": "@effect/platform-node/NodePath",
|
|
76
|
+
"effect/process/ChildProcessSpawner": "@effect/platform-node/NodeChildProcessSpawner",
|
|
77
|
+
"@smthrs/jj/Jj": "@smthrs/jj/node/NodeJj",
|
|
78
|
+
"effect/HttpClient": "@smthrs/platform-node/EgressHttpClient"
|
|
79
|
+
};
|
|
80
|
+
const platform = Layer.mergeAll(AtomicFileSystem.layer, NodePath.layer);
|
|
81
|
+
const reaping = (options) => ({
|
|
82
|
+
ownerPid: options?.ownerPid,
|
|
83
|
+
system: options?.system
|
|
84
|
+
});
|
|
85
|
+
const layer = Layer.mergeAll(
|
|
86
|
+
ProcessConfinement.layer(),
|
|
87
|
+
platform,
|
|
88
|
+
Layer.provide(NodeChildProcessSpawner.layer, platform),
|
|
89
|
+
httpClient,
|
|
90
|
+
NodeJj.layer
|
|
91
|
+
);
|
|
92
|
+
const layerAt = (repositoryRoot) => Layer.mergeAll(
|
|
93
|
+
ProcessConfinement.layer(),
|
|
94
|
+
platform,
|
|
95
|
+
Layer.provide(NodeChildProcessSpawner.layer, platform),
|
|
96
|
+
httpClient,
|
|
97
|
+
NodeJj.layerAt(absoluteRoot(repositoryRoot))
|
|
98
|
+
);
|
|
99
|
+
const layerContained = (options) => {
|
|
100
|
+
const spawner = Layer.provide(
|
|
101
|
+
ProcessReaper.layerSpawner({ graceMs: options?.graceMs }),
|
|
102
|
+
Layer.provide(NodeChildProcessSpawner.layer, platform)
|
|
103
|
+
);
|
|
104
|
+
return Layer.mergeAll(
|
|
105
|
+
ProcessConfinement.layer(),
|
|
106
|
+
platform,
|
|
107
|
+
httpClient,
|
|
108
|
+
// jj goes through the CONTAINED spawner here, not around it. `NodeJj.layer`
|
|
109
|
+
// spawns its own children, which is right for a host that has no spawner
|
|
110
|
+
// to offer, but under containment it would mean a `jj` that leads no
|
|
111
|
+
// recorded process group, appears in no ledger, and survives the
|
|
112
|
+
// incarnation that started it.
|
|
113
|
+
Layer.provideMerge(NodeJj.layerSpawner, spawner)
|
|
114
|
+
).pipe(Layer.provideMerge(ProcessReaper.layer(reaping(options))));
|
|
115
|
+
};
|
|
116
|
+
const layerContainedAt = (repositoryRoot, options) => {
|
|
117
|
+
const spawner = Layer.provide(
|
|
118
|
+
ProcessReaper.layerSpawner({ graceMs: options?.graceMs }),
|
|
119
|
+
Layer.provide(NodeChildProcessSpawner.layer, platform)
|
|
120
|
+
);
|
|
121
|
+
return Layer.mergeAll(
|
|
122
|
+
ProcessConfinement.layer(),
|
|
123
|
+
platform,
|
|
124
|
+
httpClient,
|
|
125
|
+
Layer.provideMerge(NodeJj.layerSpawnerAt(absoluteRoot(repositoryRoot)), spawner)
|
|
126
|
+
).pipe(Layer.provideMerge(ProcessReaper.layer(reaping(options))));
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=NodeHost.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/NodeHost.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Aggregate Node.js Host bundle.\n *\n * This module defines the `NodeHost` service union and a single `layer` that\n * provides the closed Host surface backed by Node: `@effect/platform-node`'s\n * filesystem, child-process spawner, Undici `HttpClient`, native `Path`,\n * and the Node `Jj` adapter from its own package. Use the layer when a Node\n * program wants every host capability from one place; use the individual\n * modules when a program should only be able to reach part of the host. The\n * bundle also supplies native `ProcessConfinement` for the kernel spawner.\n *\n * There is no Node HTTP module either: outgoing requests are Effect's\n * `HttpClient`, and `@effect/platform-node` already ships the Undici-backed\n * implementation. Undici follows no redirect unless a redirect interceptor is\n * installed, so every hop stays visible to `@smthrs/kernel`'s decorator.\n *\n * There is no Node shell module: running a command is Effect's\n * `ChildProcessSpawner`, and `@effect/platform-node` already ships the\n * implementation.\n *\n * @since 0.1.0\n */\n\nimport * as NodeChildProcessSpawner from \"@effect/platform-node/NodeChildProcessSpawner\"\nimport * as NodeCrypto from \"@effect/platform-node/NodeCrypto\"\nimport * as NodeFileSystem from \"@effect/platform-node/NodeFileSystem\"\nimport * as NodeHttpClient from \"@effect/platform-node/NodeHttpClient\"\nimport * as NodePath from \"@effect/platform-node/NodePath\"\nimport type { Jj, JjError } from \"@smthrs/jj\"\nimport * as NodeJj from \"@smthrs/jj/node/NodeJj\"\nimport type { HostServiceIds } from \"@smthrs/kernel/HostServices\"\nimport type * as KernelProcessConfinement from \"@smthrs/kernel/ProcessConfinement\"\nimport type * as ProcessLedger from \"@smthrs/kernel/ProcessLedger\"\nimport type { FileSystem } from \"effect/FileSystem\"\nimport * as Layer from \"effect/Layer\"\nimport type * as Path from \"effect/Path\"\nimport * as Schema from \"effect/Schema\"\nimport type { HttpClient } from \"effect/unstable/http/HttpClient\"\nimport type { ChildProcessSpawner } from \"effect/unstable/process/ChildProcessSpawner\"\nimport { isAbsolute } from \"node:path\"\nimport * as AtomicFileSystem from \"./AtomicFileSystem.ts\"\nimport * as EgressHttpClient from \"./EgressHttpClient.ts\"\nimport * as ProcessConfinement from \"./ProcessConfinement.ts\"\nimport * as ProcessReaper from \"./ProcessReaper.ts\"\n\n/**\n * The Node platform modules Effect ships, re-exported so a program that wants\n * only part of the host has one place to reach for them. `NodeJj` belongs to\n * `@smthrs/jj`; import it from there.\n *\n * `NodeCrypto` is here for a different reason than the rest. `Crypto` is not a\n * Host service \u2014 it carries no host authority the kernel could attenuate, so\n * it is not in {@link NodeHost} and not in the closed list \u2014 but every durable\n * composition needs one, and a program that already depends on this package\n * for its host should not have to add a second dependency for the digest.\n *\n * @category re-exports\n * @since 0.1.0\n */\nexport {\n AtomicFileSystem,\n EgressHttpClient,\n NodeChildProcessSpawner,\n NodeCrypto,\n NodeFileSystem,\n NodeHttpClient,\n ProcessReaper\n}\n\n/**\n * The `HttpClient` every bundle below installs: Undici through the egress\n * proxy this process's environment names, and a direct Undici pool when it\n * names none.\n *\n * `NodeHttpClient.layerUndici` is the direct pool unconditionally. It is still\n * re-exported above for a program composing its own services, but a bundle\n * that spans a whole host has to work inside a sandbox whose only way out is a\n * proxy, so the bundles read the environment. See {@link EgressHttpClient}.\n */\nconst httpClient = EgressHttpClient.layer(process.env)\n\n/**\n * The union of host services provided by the Node host layer.\n *\n * @category models\n * @since 0.1.0\n */\nexport type NodeHost =\n | FileSystem\n | Path.Path\n | ChildProcessSpawner\n | Jj\n | HttpClient\n | KernelProcessConfinement.ProcessConfinement\n\n/**\n * Invalid repository-root configuration, refused before layer construction.\n * @category errors\n * @since 1.0.0-rc.0\n */\nexport class NodeHostError extends Schema.TaggedError<NodeHostError>()(\"@smthrs/platform-node/NodeHostError\", {\n code: Schema.Literal(\"invalid_repository_root\"),\n message: Schema.String\n}) {\n override readonly name = \"NodeHostError\"\n}\n\nconst absoluteRoot = (root: string): string => {\n if (isAbsolute(root)) return root\n throw new NodeHostError({\n code: \"invalid_repository_root\",\n message: `NodeHost requires an absolute repository root, got ${\n JSON.stringify(Array.from(root).slice(0, 64).join(\"\"))\n }`\n })\n}\n\n/**\n * Stable implementation identities for the raw bundle's five Host slots.\n * Contained POSIX factories replace its spawner with {@link ProcessReaper.layerSpawner}.\n * @category models\n * @since 1.0.0-rc.0\n */\nexport const implementationIds: Readonly<Record<(typeof HostServiceIds)[number], string>> = {\n \"effect/FileSystem\": \"@smthrs/platform-node/AtomicFileSystem\",\n \"effect/Path\": \"@effect/platform-node/NodePath\",\n \"effect/process/ChildProcessSpawner\": \"@effect/platform-node/NodeChildProcessSpawner\",\n \"@smthrs/jj/Jj\": \"@smthrs/jj/node/NodeJj\",\n \"effect/HttpClient\": \"@smthrs/platform-node/EgressHttpClient\"\n}\n\n/** The two services `NodeChildProcessSpawner` resolves paths and files with. */\nconst platform = Layer.mergeAll(AtomicFileSystem.layer, NodePath.layer)\n\n/**\n * What a caller may configure about a contained Node host.\n *\n * `platform` is deliberately absent. `ContainedSpawner.Options` declares it so a\n * caller that supplies its own spawner can describe one, but this native host\n * detaches by `process.platform` whatever a record claims. A caller-supplied\n * `\"win32\"` on a POSIX host would therefore\n * record `pgid: null` for a child that really does lead a group, and\n * {@link ProcessReaper.reap} would retire that record as `no-group` and leave\n * the orphan running forever \u2014 a durable lie rather than a compile error.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type ContainedOptions = ProcessReaper.SpawnerOptions & ProcessReaper.Options\n\n/** The reaper half of {@link ContainedOptions}. */\nconst reaping = (options?: ContainedOptions): ProcessReaper.Options => ({\n ownerPid: options?.ownerPid,\n system: options?.system\n})\n\n/**\n * Provides the default Node implementations for the whole closed Host surface.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layer: Layer.Layer<NodeHost, JjError> = Layer.mergeAll(\n ProcessConfinement.layer(),\n platform,\n Layer.provide(NodeChildProcessSpawner.layer, platform),\n httpClient,\n NodeJj.layer\n)\n\n/**\n * Provides the Node host with `Jj` bound to one absolute repository root.\n *\n * @category layers\n * @since 1.0.0\n */\nexport const layerAt = (repositoryRoot: string): Layer.Layer<NodeHost, JjError> =>\n Layer.mergeAll(\n ProcessConfinement.layer(),\n platform,\n Layer.provide(NodeChildProcessSpawner.layer, platform),\n httpClient,\n NodeJj.layerAt(absoluteRoot(repositoryRoot))\n )\n\n/**\n * Provides the Node host with process containment turned on.\n *\n * The difference from {@link layer} is what happens to a spawned process when\n * its run stops. Under {@link layer} a child is signalled when its scope\n * closes and then waited for, forever if it ignores `SIGTERM`, and a host that\n * dies without closing its scopes abandons every child it started. This layer\n * gives each child an escalation deadline and records it in the\n * `ProcessLedger`, then sweeps the records a previous incarnation of the same\n * host left behind before it hands the host over\n * ({@link ProcessReaper.reap}).\n *\n * jj is contained here too: `layerContained` builds the `Jj` service over the\n * same spawner rather than letting it start its own children, so a `jj`\n * invocation a crashed host left running is a record the next incarnation\n * reaps like any other.\n *\n * The ledger is a requirement rather than a default because the durable half\n * of containment is only as good as the journal underneath it:\n * `ProcessLedger.layer` inherits a crashed incarnation's processes,\n * `ProcessLedger.layerMemory` contains this incarnation and nothing more, and\n * the choice belongs to the program that knows which it has.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layerContained = (\n options?: ContainedOptions\n): Layer.Layer<NodeHost, JjError, ProcessLedger.ProcessLedger> => {\n const spawner = Layer.provide(\n ProcessReaper.layerSpawner({ graceMs: options?.graceMs }),\n Layer.provide(NodeChildProcessSpawner.layer, platform)\n )\n return Layer.mergeAll(\n ProcessConfinement.layer(),\n platform,\n httpClient,\n // jj goes through the CONTAINED spawner here, not around it. `NodeJj.layer`\n // spawns its own children, which is right for a host that has no spawner\n // to offer, but under containment it would mean a `jj` that leads no\n // recorded process group, appears in no ledger, and survives the\n // incarnation that started it.\n Layer.provideMerge(NodeJj.layerSpawner, spawner)\n ).pipe(Layer.provideMerge(ProcessReaper.layer(reaping(options))))\n}\n\n/**\n * Provides the contained Node host with `Jj` bound to one absolute repository\n * root.\n *\n * @category layers\n * @since 1.0.0\n */\nexport const layerContainedAt = (\n repositoryRoot: string,\n options?: ContainedOptions\n): Layer.Layer<NodeHost, JjError, ProcessLedger.ProcessLedger> => {\n const spawner = Layer.provide(\n ProcessReaper.layerSpawner({ graceMs: options?.graceMs }),\n Layer.provide(NodeChildProcessSpawner.layer, platform)\n )\n return Layer.mergeAll(\n ProcessConfinement.layer(),\n platform,\n httpClient,\n Layer.provideMerge(NodeJj.layerSpawnerAt(absoluteRoot(repositoryRoot)), spawner)\n ).pipe(Layer.provideMerge(ProcessReaper.layer(reaping(options))))\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBA,8BAAyC;AACzC,iBAA4B;AAC5B,qBAAgC;AAChC,qBAAgC;AAChC,eAA0B;AAE1B,aAAwB;AAKxB,YAAuB;AAEvB,aAAwB;AAGxB,uBAA2B;AAC3B,uBAAkC;AAClC,uBAAkC;AAClC,yBAAoC;AACpC,oBAA+B;AAoC/B,MAAM,aAAa,iBAAiB,MAAM,QAAQ,GAAG;AAqB9C,MAAM,sBAAsB,OAAO,YAA2B,EAAE,uCAAuC;AAAA,EAC5G,MAAM,OAAO,QAAQ,yBAAyB;AAAA,EAC9C,SAAS,OAAO;AAClB,CAAC,EAAE;AAAA,EACiB,OAAO;AAC3B;AAEA,MAAM,eAAe,CAAC,SAAyB;AAC7C,UAAI,6BAAW,IAAI,EAAG,QAAO;AAC7B,QAAM,IAAI,cAAc;AAAA,IACtB,MAAM;AAAA,IACN,SAAS,sDACP,KAAK,UAAU,MAAM,KAAK,IAAI,EAAE,MAAM,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,CACvD;AAAA,EACF,CAAC;AACH;AAQO,MAAM,oBAA+E;AAAA,EAC1F,qBAAqB;AAAA,EACrB,eAAe;AAAA,EACf,sCAAsC;AAAA,EACtC,iBAAiB;AAAA,EACjB,qBAAqB;AACvB;AAGA,MAAM,WAAW,MAAM,SAAS,iBAAiB,OAAO,SAAS,KAAK;AAmBtE,MAAM,UAAU,CAAC,aAAuD;AAAA,EACtE,UAAU,SAAS;AAAA,EACnB,QAAQ,SAAS;AACnB;AAQ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|
|
3
|
+
* sandbox: bubblewrap on Linux, seatbelt on macOS.
|
|
4
|
+
*
|
|
5
|
+
* `@smthrs/kernel`'s `ChildProcessSpawner.layer` hands every stage that passed
|
|
6
|
+
* its `proc:spawn` check to the confinement in its context, together with the
|
|
7
|
+
* `ProcessConfinement.Profile` the grants in force admit. This module turns
|
|
8
|
+
* that profile into a {@link ProcessSandbox.Request}, plans it against the
|
|
9
|
+
* workspace, and wraps the stage's argv in the mechanism the host has, so an
|
|
10
|
+
* approved `bash` can write only where an `fs:write` grant says and reach the
|
|
11
|
+
* network only when a `net:*` grant says. A stage that asked for the platform
|
|
12
|
+
* shell is spelled out as `/bin/sh -c <line>` first: wrapping a `shell: true`
|
|
13
|
+
* command line would otherwise leave its redirections and pipes to a shell
|
|
14
|
+
* outside the sandbox.
|
|
15
|
+
*
|
|
16
|
+
* A host with no mechanism is the one decision this module leaves to its
|
|
17
|
+
* caller: {@link Options.unavailable} either refuses the spawn, so nothing
|
|
18
|
+
* runs that the profile would not have confined, or runs it unconfined with
|
|
19
|
+
* a warning, the way every host did before this seam existed. A write set
|
|
20
|
+
* the mechanism cannot enforce safely, a symbolic link below the workspace
|
|
21
|
+
* root, is always refused.
|
|
22
|
+
*
|
|
23
|
+
* @since 1.0.0-rc.1
|
|
24
|
+
*/
|
|
25
|
+
import * as KernelProcessConfinement from "@smthrs/kernel/ProcessConfinement";
|
|
26
|
+
import * as Layer from "effect/Layer";
|
|
27
|
+
import * as ProcessSandbox from "./ProcessSandbox.ts";
|
|
28
|
+
/**
|
|
29
|
+
* How the confinement is built.
|
|
30
|
+
*
|
|
31
|
+
* @category models
|
|
32
|
+
* @since 1.0.0-rc.1
|
|
33
|
+
*/
|
|
34
|
+
export interface Options {
|
|
35
|
+
/**
|
|
36
|
+
* What happens when this host has no mechanism to enforce a profile with.
|
|
37
|
+
* `"refuse"` fails the spawn, so a command never runs with more than the
|
|
38
|
+
* profile allows; `"unconfined"` runs it as given and logs a
|
|
39
|
+
* warning naming what the host lacks.
|
|
40
|
+
*/
|
|
41
|
+
readonly unavailable?: "refuse" | "unconfined" | undefined;
|
|
42
|
+
/** The host facts mechanism selection reads; defaults to the real host. */
|
|
43
|
+
readonly host?: ProcessSandbox.Host | undefined;
|
|
44
|
+
/** Where each run's private temporary directory is created; defaults to the OS temporary directory. */
|
|
45
|
+
readonly temporaryDirectory?: string | undefined;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Builds the native confinement.
|
|
49
|
+
*
|
|
50
|
+
* @category constructors
|
|
51
|
+
* @since 1.0.0-rc.1
|
|
52
|
+
*/
|
|
53
|
+
export declare const make: (options?: Options) => KernelProcessConfinement.Service;
|
|
54
|
+
/**
|
|
55
|
+
* Provides the native confinement.
|
|
56
|
+
*
|
|
57
|
+
* @category layers
|
|
58
|
+
* @since 1.0.0-rc.1
|
|
59
|
+
*/
|
|
60
|
+
export declare const layer: (options?: Options) => Layer.Layer<KernelProcessConfinement.ProcessConfinement>;
|
|
61
|
+
//# sourceMappingURL=ProcessConfinement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProcessConfinement.d.ts","sourceRoot":"","sources":["../../src/ProcessConfinement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,wBAAwB,MAAM,mCAAmC,CAAA;AAE7E,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAOrC,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AAErD;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,SAAS,CAAA;IAC1D,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,CAAC,EAAE,cAAc,CAAC,IAAI,GAAG,SAAS,CAAA;IAC/C,uGAAuG;IACvG,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACjD;AA0FD;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,UAAS,OAAY,KAAG,wBAAwB,CAAC,OA2MrE,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAAI,UAAS,OAAY,KAAG,KAAK,CAAC,KAAK,CAAC,wBAAwB,CAAC,kBAAkB,CAC1B,CAAA"}
|