@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,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var AtomicFileSystemExecutable_exports = {};
|
|
20
|
+
__export(AtomicFileSystemExecutable_exports, {
|
|
21
|
+
installedPackageRoot: () => installedPackageRoot,
|
|
22
|
+
outsideWorkspace: () => outsideWorkspace,
|
|
23
|
+
packageRoot: () => packageRoot,
|
|
24
|
+
registerEmbeddedHelper: () => registerEmbeddedHelper,
|
|
25
|
+
resolveConfiguredExecutable: () => resolveConfiguredExecutable,
|
|
26
|
+
resolveDefaultExecutable: () => resolveDefaultExecutable,
|
|
27
|
+
resolvePackageRoot: () => resolvePackageRoot,
|
|
28
|
+
stagePackaged: () => stagePackaged
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(AtomicFileSystemExecutable_exports);
|
|
31
|
+
var import_node_crypto = require("node:crypto");
|
|
32
|
+
var import_node_fs = require("node:fs");
|
|
33
|
+
var import_node_module = require("node:module");
|
|
34
|
+
var import_node_os = require("node:os");
|
|
35
|
+
var import_node_path = require("node:path");
|
|
36
|
+
var import_node_url = require("node:url");
|
|
37
|
+
var import_AtomicFileSystemTransport = require("./AtomicFileSystemTransport.js");
|
|
38
|
+
var import_AtomicHelperError = require("./AtomicHelperError.js");
|
|
39
|
+
const import_meta = {};
|
|
40
|
+
const moduleDirectory = typeof __dirname === "string" ? __dirname : (0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
|
|
41
|
+
const resolvePackageRoot = (directory) => {
|
|
42
|
+
const sourcePackageRoot = (0, import_node_path.resolve)(directory, "../..");
|
|
43
|
+
return (0, import_node_fs.existsSync)((0, import_node_path.join)(sourcePackageRoot, "package.json")) ? sourcePackageRoot : (0, import_node_path.resolve)(directory, "../../..");
|
|
44
|
+
};
|
|
45
|
+
const installedPackageRoot = (modulePath, fallback) => {
|
|
46
|
+
try {
|
|
47
|
+
return (0, import_node_path.dirname)((0, import_node_module.createRequire)(modulePath).resolve("@smthrs/platform-node/package.json"));
|
|
48
|
+
} catch {
|
|
49
|
+
return fallback;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const packageRoot = installedPackageRoot(
|
|
53
|
+
(0, import_node_path.join)(moduleDirectory, "resolver.cjs"),
|
|
54
|
+
resolvePackageRoot(moduleDirectory)
|
|
55
|
+
);
|
|
56
|
+
const staged = /* @__PURE__ */ new Map();
|
|
57
|
+
const stagedRoots = /* @__PURE__ */ new Set();
|
|
58
|
+
const trusted = /* @__PURE__ */ new Set();
|
|
59
|
+
const installHint = "install @smthrs/platform-node with its native helper, run cargo build --locked --release -p smithers-ffi --bin smithers-jj-export in a source checkout, or set SMITHERS_WORKSPACE_JJ_EXPORT_BINARY to its absolute path";
|
|
60
|
+
const helperName = process.platform === "win32" ? "smithers-jj-export.exe" : "smithers-jj-export";
|
|
61
|
+
const sha256 = (bytes) => (0, import_node_crypto.createHash)("sha256").update(bytes).digest("hex");
|
|
62
|
+
const ownedByThisUser = (info) => {
|
|
63
|
+
const uid = process.getuid?.();
|
|
64
|
+
return uid === void 0 || info.uid === uid;
|
|
65
|
+
};
|
|
66
|
+
const privateDirectory = (directory) => {
|
|
67
|
+
try {
|
|
68
|
+
(0, import_node_fs.mkdirSync)(directory, { mode: 448 });
|
|
69
|
+
} catch (cause) {
|
|
70
|
+
if (cause.code !== "EEXIST") throw cause;
|
|
71
|
+
}
|
|
72
|
+
const info = (0, import_node_fs.lstatSync)(directory);
|
|
73
|
+
if (!info.isDirectory() || !ownedByThisUser(info)) {
|
|
74
|
+
throw new import_AtomicHelperError.AtomicHelperError({
|
|
75
|
+
code: "staging_directory_not_private",
|
|
76
|
+
message: `atomic helper staging directory is not a private directory: ${directory}`
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
(0, import_node_fs.chmodSync)(directory, 448);
|
|
80
|
+
};
|
|
81
|
+
const matches = (destination, digest) => {
|
|
82
|
+
try {
|
|
83
|
+
const info = (0, import_node_fs.lstatSync)(destination);
|
|
84
|
+
if (!info.isFile() || info.nlink !== 1 || !ownedByThisUser(info)) return false;
|
|
85
|
+
return sha256((0, import_node_fs.readFileSync)(destination)) === digest;
|
|
86
|
+
} catch {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const staleMs = 7 * 24 * 60 * 60 * 1e3;
|
|
91
|
+
const refreshMs = 60 * 60 * 1e3;
|
|
92
|
+
const refresh = (copy) => {
|
|
93
|
+
const now = Date.now();
|
|
94
|
+
if (now - copy.touchedAt < refreshMs) return;
|
|
95
|
+
copy.touchedAt = now;
|
|
96
|
+
(0, import_node_fs.utimes)((0, import_node_path.dirname)(copy.path), now / 1e3, now / 1e3, () => {
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
const prune = (base, keep) => {
|
|
100
|
+
const now = Date.now();
|
|
101
|
+
let names;
|
|
102
|
+
try {
|
|
103
|
+
names = (0, import_node_fs.readdirSync)(base);
|
|
104
|
+
} catch {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const temporaryPrefix = `.${helperName}.`;
|
|
108
|
+
for (const name of names) {
|
|
109
|
+
if (!name.startsWith(".smthrs-atomic-helper-")) continue;
|
|
110
|
+
const directory = (0, import_node_path.join)(base, name);
|
|
111
|
+
try {
|
|
112
|
+
const info = (0, import_node_fs.lstatSync)(directory);
|
|
113
|
+
if (!info.isDirectory() || !ownedByThisUser(info)) continue;
|
|
114
|
+
if (name !== keep && now - info.mtimeMs > staleMs) {
|
|
115
|
+
(0, import_node_fs.rmSync)(directory, { recursive: true, force: true });
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
for (const entry of (0, import_node_fs.readdirSync)(directory)) {
|
|
119
|
+
if (!entry.startsWith(temporaryPrefix) || !/^\d+\.[0-9a-f]{12}$/.test(entry.slice(temporaryPrefix.length))) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const temporary = (0, import_node_path.join)(directory, entry);
|
|
123
|
+
try {
|
|
124
|
+
const file = (0, import_node_fs.lstatSync)(temporary);
|
|
125
|
+
if (file.isFile() && ownedByThisUser(file) && now - file.mtimeMs > staleMs) {
|
|
126
|
+
(0, import_node_fs.rmSync)(temporary, { force: true });
|
|
127
|
+
}
|
|
128
|
+
} catch {
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
} catch {
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
let embeddedHelper;
|
|
136
|
+
const registerEmbeddedHelper = (source) => {
|
|
137
|
+
embeddedHelper = source;
|
|
138
|
+
};
|
|
139
|
+
const outsideWorkspace = (source, boundaryRoot, bases = [(0, import_node_os.tmpdir)(), (0, import_node_os.homedir)()]) => {
|
|
140
|
+
const cached = staged.get(source);
|
|
141
|
+
if (cached !== void 0) {
|
|
142
|
+
if ((0, import_node_fs.existsSync)(cached.path)) {
|
|
143
|
+
refresh(cached);
|
|
144
|
+
return (0, import_AtomicFileSystemTransport.usableExecutable)(cached.path, boundaryRoot);
|
|
145
|
+
}
|
|
146
|
+
staged.delete(source);
|
|
147
|
+
}
|
|
148
|
+
const bytes = (0, import_node_fs.readFileSync)(source);
|
|
149
|
+
const digest = sha256(bytes);
|
|
150
|
+
for (const [index, base] of bases.entries()) {
|
|
151
|
+
const directory = (0, import_node_path.join)(base, `.smthrs-atomic-helper-${digest}`);
|
|
152
|
+
const destination = (0, import_node_path.join)(directory, helperName);
|
|
153
|
+
let temporary;
|
|
154
|
+
try {
|
|
155
|
+
privateDirectory(directory);
|
|
156
|
+
const now = /* @__PURE__ */ new Date();
|
|
157
|
+
(0, import_node_fs.utimesSync)(directory, now, now);
|
|
158
|
+
if (!matches(destination, digest)) {
|
|
159
|
+
temporary = (0, import_node_path.join)(directory, `.${helperName}.${process.pid}.${(0, import_node_crypto.randomBytes)(6).toString("hex")}`);
|
|
160
|
+
(0, import_node_fs.writeFileSync)(temporary, bytes, { flag: "wx", mode: 320 });
|
|
161
|
+
(0, import_node_fs.chmodSync)(temporary, 320);
|
|
162
|
+
(0, import_node_fs.renameSync)(temporary, destination);
|
|
163
|
+
temporary = void 0;
|
|
164
|
+
}
|
|
165
|
+
const executable = (0, import_AtomicFileSystemTransport.usableExecutable)(destination, boundaryRoot);
|
|
166
|
+
prune(base, `.smthrs-atomic-helper-${digest}`);
|
|
167
|
+
staged.set(source, { path: executable, touchedAt: now.getTime() });
|
|
168
|
+
return executable;
|
|
169
|
+
} catch (cause) {
|
|
170
|
+
if (temporary !== void 0) (0, import_node_fs.rmSync)(temporary, { force: true });
|
|
171
|
+
if (index === bases.length - 1) throw cause;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
throw new import_AtomicHelperError.AtomicHelperError({
|
|
175
|
+
code: "staging_unavailable",
|
|
176
|
+
message: "no staging location for smithers-jj-export"
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
const packagedHelper = (root) => (0, import_node_path.join)(root, "bin", `${process.platform}-${process.arch}`, helperName);
|
|
180
|
+
const checkoutHelpers = (root) => {
|
|
181
|
+
const checkout = (0, import_node_path.resolve)(root, "../../../..");
|
|
182
|
+
return (0, import_node_fs.existsSync)((0, import_node_path.join)(checkout, "pnpm-workspace.yaml")) ? [(0, import_node_path.join)(checkout, "target/release", helperName), (0, import_node_path.join)(checkout, "target/debug", helperName)] : [];
|
|
183
|
+
};
|
|
184
|
+
const stagePackaged = (root) => {
|
|
185
|
+
if (stagedRoots.has(root)) return;
|
|
186
|
+
stagedRoots.add(root);
|
|
187
|
+
const candidate = embeddedHelper ?? packagedHelper(root);
|
|
188
|
+
try {
|
|
189
|
+
if ((0, import_node_fs.existsSync)(candidate) && (0, import_node_fs.statSync)(candidate).isFile()) {
|
|
190
|
+
outsideWorkspace(candidate, void 0);
|
|
191
|
+
trusted.add(candidate);
|
|
192
|
+
}
|
|
193
|
+
} catch {
|
|
194
|
+
}
|
|
195
|
+
if (embeddedHelper !== void 0) return;
|
|
196
|
+
for (const build of checkoutHelpers(root)) {
|
|
197
|
+
try {
|
|
198
|
+
if ((0, import_node_fs.existsSync)(build)) {
|
|
199
|
+
const executable = (0, import_AtomicFileSystemTransport.usableExecutable)(build, void 0);
|
|
200
|
+
outsideWorkspace(executable, void 0);
|
|
201
|
+
trusted.add(executable);
|
|
202
|
+
}
|
|
203
|
+
} catch {
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
const workspaceSupplied = (candidate, source, boundaryRoot) => (0, import_AtomicFileSystemTransport.inside)(boundaryRoot, (0, import_node_path.resolve)(candidate)) || (0, import_AtomicFileSystemTransport.inside)(boundaryRoot, (0, import_node_path.join)(import_node_fs.realpathSync.native((0, import_node_path.dirname)(candidate)), (0, import_node_path.basename)(candidate))) || (0, import_AtomicFileSystemTransport.inside)(boundaryRoot, import_node_fs.realpathSync.native(source));
|
|
208
|
+
const pinned = (candidate, source, boundaryRoot) => {
|
|
209
|
+
if (boundaryRoot !== void 0 && !trusted.has(source) && workspaceSupplied(candidate, source, boundaryRoot)) {
|
|
210
|
+
throw new import_AtomicHelperError.AtomicHelperError({
|
|
211
|
+
code: "helper_inside_workspace",
|
|
212
|
+
message: `atomic helper executable must live outside the confined workspace: ${candidate} was not present when the host was built`
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
return outsideWorkspace(source, boundaryRoot);
|
|
216
|
+
};
|
|
217
|
+
const resolveDefaultExecutable = (root, boundaryRoot, fallback = "/usr/local/bin/smithers-jj-export") => {
|
|
218
|
+
if (embeddedHelper !== void 0) return outsideWorkspace(embeddedHelper, boundaryRoot);
|
|
219
|
+
const candidates = [packagedHelper(root), ...checkoutHelpers(root), fallback];
|
|
220
|
+
for (const [index, candidate] of candidates.entries()) {
|
|
221
|
+
if (!(0, import_node_fs.existsSync)(candidate)) continue;
|
|
222
|
+
if (index === 0) {
|
|
223
|
+
if (!(0, import_node_fs.statSync)(candidate).isFile()) {
|
|
224
|
+
throw new import_AtomicHelperError.AtomicHelperError({
|
|
225
|
+
code: "helper_not_regular_file",
|
|
226
|
+
message: `packaged atomic helper is not a regular file: ${candidate}`
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
return pinned(candidate, candidate, boundaryRoot);
|
|
230
|
+
}
|
|
231
|
+
const executable = (0, import_AtomicFileSystemTransport.usableExecutable)(candidate, void 0);
|
|
232
|
+
return boundaryRoot !== void 0 && workspaceSupplied(candidate, executable, boundaryRoot) ? pinned(candidate, executable, boundaryRoot) : executable;
|
|
233
|
+
}
|
|
234
|
+
throw new import_AtomicHelperError.AtomicHelperError({
|
|
235
|
+
code: "helper_missing",
|
|
236
|
+
message: `smithers-jj-export is missing; ${installHint} (searched ${candidates.join(", ")})`
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
const resolveConfiguredExecutable = (configured, boundaryRoot) => {
|
|
240
|
+
try {
|
|
241
|
+
return (0, import_AtomicFileSystemTransport.usableExecutable)(configured, boundaryRoot);
|
|
242
|
+
} catch (cause) {
|
|
243
|
+
const reason = cause.message;
|
|
244
|
+
throw new import_AtomicHelperError.AtomicHelperError({
|
|
245
|
+
code: "helper_unusable",
|
|
246
|
+
message: `smithers-jj-export is unusable at SMITHERS_WORKSPACE_JJ_EXPORT_BINARY=${configured}: ${reason}; ${installHint}`
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
//# sourceMappingURL=AtomicFileSystemExecutable.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/internal/AtomicFileSystemExecutable.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Finds the native filesystem helper embedded in a host, shipped with this package, or built in a\n * source checkout, without accepting an executable from the workspace.\n * @since 1.0.0\n */\n\nimport { createHash, randomBytes } from \"node:crypto\"\nimport {\n chmodSync,\n existsSync,\n lstatSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n realpathSync,\n renameSync,\n rmSync,\n statSync,\n utimes,\n utimesSync,\n writeFileSync\n} from \"node:fs\"\nimport { createRequire } from \"node:module\"\nimport { homedir, tmpdir } from \"node:os\"\nimport { basename, dirname, join, resolve } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\nimport { inside, usableExecutable } from \"./AtomicFileSystemTransport.ts\"\nimport { AtomicHelperError } from \"./AtomicHelperError.ts\"\n\n/* v8 ignore next -- the packed CJS consumer uses its loader's __dirname; source tests use the ESM loader */\nconst moduleDirectory = typeof __dirname === \"string\" ? __dirname : dirname(fileURLToPath(import.meta.url))\n\n/**\n * The same source module lives one directory deeper after an npm build.\n * @private\n * @since 1.0.0\n */\nexport const resolvePackageRoot = (directory: string): string => {\n const sourcePackageRoot = resolve(directory, \"../..\")\n return existsSync(join(sourcePackageRoot, \"package.json\"))\n ? sourcePackageRoot\n : resolve(directory, \"../../..\")\n}\n\n/**\n * Finds the installed package even when a host bundles this adapter elsewhere.\n * @private\n * @since 1.0.0\n */\nexport const installedPackageRoot = (modulePath: string, fallback: string): string => {\n try {\n return dirname(createRequire(modulePath).resolve(\"@smthrs/platform-node/package.json\"))\n } catch {\n // A compiled executable has no installed package; its bootstrap supplies\n // the embedded helper. Source-only fixtures retain the directory fallback.\n return fallback\n }\n}\n\n/**\n * Package containing the currently loaded helper adapter.\n * @private\n * @since 1.0.0\n */\nexport const packageRoot = installedPackageRoot(\n join(moduleDirectory, \"resolver.cjs\"),\n resolvePackageRoot(moduleDirectory)\n)\n\n/** Each source's staged copy, and when this process last marked its directory in use. */\nconst staged = new Map<string, { readonly path: string; touchedAt: number }>()\n/**\n * Package roots already staged, and the sources that staging copied. Staging\n * happens once per root per process: a later layer build runs after flows may\n * have planted a helper, so only what existed at the FIRST build is trusted.\n */\nconst stagedRoots = new Set<string>()\nconst trusted = new Set<string>()\nconst installHint = \"install @smthrs/platform-node with its native helper, \" +\n \"run cargo build --locked --release -p smithers-ffi --bin smithers-jj-export in a source checkout, \" +\n \"or set SMITHERS_WORKSPACE_JJ_EXPORT_BINARY to its absolute path\"\n\nconst helperName = process.platform === \"win32\" ? \"smithers-jj-export.exe\" : \"smithers-jj-export\"\n\nconst sha256 = (bytes: Uint8Array): string => createHash(\"sha256\").update(bytes).digest(\"hex\")\n\n/** Whether this user owns `info`; Windows has no POSIX owner and relies on the per-user profile ACL. */\nconst ownedByThisUser = (info: { readonly uid: number }): boolean => {\n const uid = process.getuid?.()\n return uid === undefined || info.uid === uid\n}\n\n/** Creates or adopts the per-user staging directory, refusing links and other owners. */\nconst privateDirectory = (directory: string): void => {\n try {\n mkdirSync(directory, { mode: 0o700 })\n } catch (cause) {\n if ((cause as NodeJS.ErrnoException).code !== \"EEXIST\") throw cause\n }\n const info = lstatSync(directory)\n if (!info.isDirectory() || !ownedByThisUser(info)) {\n throw new AtomicHelperError({\n code: \"staging_directory_not_private\",\n message: `atomic helper staging directory is not a private directory: ${directory}`\n })\n }\n chmodSync(directory, 0o700)\n}\n\n/**\n * Whether the staged copy is this user's own single-link file holding exactly\n * the helper's bytes. A planted link, even one with the right bytes, is\n * replaced: rename swaps the directory entry, never the linked inode.\n */\nconst matches = (destination: string, digest: string): boolean => {\n try {\n const info = lstatSync(destination)\n if (!info.isFile() || info.nlink !== 1 || !ownedByThisUser(info)) return false\n return sha256(readFileSync(destination)) === digest\n } catch {\n return false\n }\n}\n\n/** A staged copy no process has used for this long is removed; use refreshes the directory's time. */\nconst staleMs = 7 * 24 * 60 * 60 * 1000\nconst refreshMs = 60 * 60 * 1000\n\n/** Marks a staging directory in use, at most hourly, so no other process prunes it while this one runs. */\nconst refresh = (copy: { readonly path: string; touchedAt: number }): void => {\n const now = Date.now()\n if (now - copy.touchedAt < refreshMs) return\n copy.touchedAt = now\n // Best effort and off the request path: a failed touch only risks a later re-stage.\n utimes(dirname(copy.path), now / 1000, now / 1000, () => {})\n}\n\n/**\n * Removes this user's stale staging directories beside `keep`, and incomplete\n * temporary files left in live directories when a writer exited on a signal.\n */\nconst prune = (base: string, keep: string): void => {\n const now = Date.now()\n let names: Array<string>\n try {\n names = readdirSync(base)\n } catch {\n return\n }\n const temporaryPrefix = `.${helperName}.`\n for (const name of names) {\n if (!name.startsWith(\".smthrs-atomic-helper-\")) continue\n const directory = join(base, name)\n try {\n const info = lstatSync(directory)\n if (!info.isDirectory() || !ownedByThisUser(info)) continue\n if (name !== keep && now - info.mtimeMs > staleMs) {\n rmSync(directory, { recursive: true, force: true })\n continue\n }\n for (const entry of readdirSync(directory)) {\n if (!entry.startsWith(temporaryPrefix) || !/^\\d+\\.[0-9a-f]{12}$/.test(entry.slice(temporaryPrefix.length))) {\n continue\n }\n const temporary = join(directory, entry)\n try {\n const file = lstatSync(temporary)\n if (file.isFile() && ownedByThisUser(file) && now - file.mtimeMs > staleMs) {\n rmSync(temporary, { force: true })\n }\n } catch {\n // A writer or another pruner removed this entry first.\n }\n }\n } catch {\n // Another process removed or replaced it first.\n }\n }\n}\n\nlet embeddedHelper: string | undefined\n\n/**\n * Supplies the build's native asset without touching disk during --help.\n * @private\n * @since 1.0.0\n */\nexport const registerEmbeddedHelper = (source: string): void => {\n embeddedHelper = source\n}\n\n/**\n * Pin an install inside the workspace before any flow can modify its bytes.\n * @private\n * @since 1.0.0\n */\nexport const outsideWorkspace = (\n source: string,\n boundaryRoot: string | undefined,\n bases: ReadonlyArray<string> = [tmpdir(), homedir()]\n): string => {\n const cached = staged.get(source)\n if (cached !== undefined) {\n if (existsSync(cached.path)) {\n refresh(cached)\n return usableExecutable(cached.path, boundaryRoot)\n }\n // A newer build's process pruned this copy after a week unused: stage it again.\n staged.delete(source)\n }\n // readFile also supports assets embedded in a Bun executable; copyfile\n // delegates to the OS, which cannot open its virtual /$bunfs path.\n const bytes = readFileSync(source)\n const digest = sha256(bytes)\n for (const [index, base] of bases.entries()) {\n const directory = join(base, `.smthrs-atomic-helper-${digest}`)\n const destination = join(directory, helperName)\n let temporary: string | undefined\n try {\n privateDirectory(directory)\n // Fresh before it is read, so a concurrent prune passes it by.\n const now = new Date()\n utimesSync(directory, now, now)\n if (!matches(destination, digest)) {\n // One copy per user and helper: concurrent processes each write a\n // private temporary file and rename it over the shared name, so a\n // reader only ever sees a complete copy.\n temporary = join(directory, `.${helperName}.${process.pid}.${randomBytes(6).toString(\"hex\")}`)\n writeFileSync(temporary, bytes, { flag: \"wx\", mode: 0o500 })\n chmodSync(temporary, 0o500)\n renameSync(temporary, destination)\n temporary = undefined\n }\n const executable = usableExecutable(destination, boundaryRoot)\n prune(base, `.smthrs-atomic-helper-${digest}`)\n staged.set(source, { path: executable, touchedAt: now.getTime() })\n return executable\n } catch (cause) {\n if (temporary !== undefined) rmSync(temporary, { force: true })\n if (index === bases.length - 1) throw cause\n }\n }\n throw new AtomicHelperError({\n code: \"staging_unavailable\",\n message: \"no staging location for smithers-jj-export\"\n })\n}\n\n/** The helper an installed package ships for this platform. */\nconst packagedHelper = (root: string): string => join(root, \"bin\", `${process.platform}-${process.arch}`, helperName)\n\n/** Source-checkout builds, when `root` is this package inside a checkout. */\nconst checkoutHelpers = (root: string): ReadonlyArray<string> => {\n const checkout = resolve(root, \"../../../..\")\n return existsSync(join(checkout, \"pnpm-workspace.yaml\"))\n ? [join(checkout, \"target/release\", helperName), join(checkout, \"target/debug\", helperName)]\n : []\n}\n\n/**\n * Stages the packaged helper and any source-checkout build the first time a\n * host layer over `root` is built in this process, so the bytes later requests\n * execute are the ones present before any flow ran. Later builds stage\n * nothing: a flow of an earlier run may already have planted a helper by then.\n * A flow that rewrites a workspace-local install or build afterwards changes\n * nothing that is executed. A missing or unusable helper is left for the first\n * request to report.\n * @private\n * @since 1.0.0\n */\nexport const stagePackaged = (root: string): void => {\n if (stagedRoots.has(root)) return\n stagedRoots.add(root)\n const candidate = embeddedHelper ?? packagedHelper(root)\n try {\n if (existsSync(candidate) && statSync(candidate).isFile()) {\n outsideWorkspace(candidate, undefined)\n trusted.add(candidate)\n }\n } catch {\n // The request path resolves again and reports the refusal it meets.\n }\n if (embeddedHelper !== undefined) return\n for (const build of checkoutHelpers(root)) {\n try {\n if (existsSync(build)) {\n const executable = usableExecutable(build, undefined)\n outsideWorkspace(executable, undefined)\n trusted.add(executable)\n }\n } catch {\n // As above: the request path reports it.\n }\n }\n}\n\n/**\n * Whether a flow confined to `boundaryRoot` could have supplied what\n * `candidate` runs: the name itself lies inside the workspace (so a flow could\n * have replaced it with a link to any host binary), its directory resolves\n * inside it, or the file it resolves to does.\n */\nconst workspaceSupplied = (candidate: string, source: string, boundaryRoot: string): boolean =>\n inside(boundaryRoot, resolve(candidate)) ||\n inside(boundaryRoot, join(realpathSync.native(dirname(candidate)), basename(candidate))) ||\n inside(boundaryRoot, realpathSync.native(source))\n\n/**\n * Copies `source` to a private directory only when the workspace cannot have\n * supplied its bytes: neither `candidate` nor what it resolves to lies inside\n * the confined workspace, or `source` was staged at the first host build,\n * before any flow ran. A helper, or a link to one, that appeared inside the\n * workspace later is exactly what a flow would plant.\n */\nconst pinned = (candidate: string, source: string, boundaryRoot: string | undefined): string => {\n if (boundaryRoot !== undefined && !trusted.has(source) && workspaceSupplied(candidate, source, boundaryRoot)) {\n throw new AtomicHelperError({\n code: \"helper_inside_workspace\",\n message: `atomic helper executable must live outside the confined workspace: ${candidate} ` +\n \"was not present when the host was built\"\n })\n }\n return outsideWorkspace(source, boundaryRoot)\n}\n\n/**\n * Select only trusted package or checkout locations; never consult PATH or cwd.\n * @private\n * @since 1.0.0\n */\nexport const resolveDefaultExecutable = (\n root: string,\n boundaryRoot: string | undefined,\n fallback = \"/usr/local/bin/smithers-jj-export\"\n): string => {\n if (embeddedHelper !== undefined) return outsideWorkspace(embeddedHelper, boundaryRoot)\n const candidates = [packagedHelper(root), ...checkoutHelpers(root), fallback]\n for (const [index, candidate] of candidates.entries()) {\n if (!existsSync(candidate)) continue\n if (index === 0) {\n if (!statSync(candidate).isFile()) {\n throw new AtomicHelperError({\n code: \"helper_not_regular_file\",\n message: `packaged atomic helper is not a regular file: ${candidate}`\n })\n }\n // npm/pnpm tarballs may store package files without executable bits.\n return pinned(candidate, candidate, boundaryRoot)\n }\n const executable = usableExecutable(candidate, undefined)\n return boundaryRoot !== undefined && workspaceSupplied(candidate, executable, boundaryRoot)\n ? pinned(candidate, executable, boundaryRoot)\n : executable\n }\n throw new AtomicHelperError({\n code: \"helper_missing\",\n message: `smithers-jj-export is missing; ${installHint} (searched ${candidates.join(\", \")})`\n })\n}\n\n/**\n * The helper `SMITHERS_WORKSPACE_JJ_EXPORT_BINARY` names, refused with the same\n * install hint as a missing one.\n * @private\n * @since 1.0.0\n */\nexport const resolveConfiguredExecutable = (configured: string, boundaryRoot: string | undefined): string => {\n try {\n return usableExecutable(configured, boundaryRoot)\n } catch (cause) {\n // `usableExecutable` and the node:fs calls it makes throw only Error objects.\n const reason = (cause as Error).message\n throw new AtomicHelperError({\n code: \"helper_unusable\",\n message:\n `smithers-jj-export is unusable at SMITHERS_WORKSPACE_JJ_EXPORT_BINARY=${configured}: ${reason}; ${installHint}`\n })\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;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WAAW,WAAW,YAAY;AAAA,IAClD;AACA,UAAM,iBAAa,mDAAiB,WAAW,MAAS;AACxD,WAAO,iBAAiB,UAAa,kBAAkB,WAAW,YAAY,YAAY,IACtF,OAAO,WAAW,YAAY,YAAY,IAC1C;AAAA,EACN;AACA,QAAM,IAAI,2CAAkB;AAAA,IAC1B,MAAM;AAAA,IACN,SAAS,kCAAkC,WAAW,cAAc,WAAW,KAAK,IAAI,CAAC;AAAA,EAC3F,CAAC;AACH;AAQO,MAAM,8BAA8B,CAAC,YAAoB,iBAA6C;AAC3G,MAAI;AACF,eAAO,mDAAiB,YAAY,YAAY;AAAA,EAClD,SAAS,OAAO;AAEd,UAAM,SAAU,MAAgB;AAChC,UAAM,IAAI,2CAAkB;AAAA,MAC1B,MAAM;AAAA,MACN,SACE,yEAAyE,UAAU,KAAK,MAAM,KAAK,WAAW;AAAA,IAClH,CAAC;AAAA,EACH;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The adapter's half of the helper wire protocol: the request frame it sends,
|
|
3
|
+
* the response frame it accepts, and the typed value or `PlatformError` each
|
|
4
|
+
* operation's answer decodes to. Every check a helper answer has to pass lives
|
|
5
|
+
* here, so a malformed or hostile response fails closed in one place.
|
|
6
|
+
* @since 1.0.0
|
|
7
|
+
*/
|
|
8
|
+
import type * as KernelFileSystem from "@smthrs/kernel/FileSystem";
|
|
9
|
+
import { Effect, PlatformError } from "effect";
|
|
10
|
+
import type { Limits } from "../AtomicFileSystem.ts";
|
|
11
|
+
/**
|
|
12
|
+
* One helper answer: a value, or a rejection carrying the errno name and the
|
|
13
|
+
* syscall the helper observed.
|
|
14
|
+
* @private
|
|
15
|
+
* @since 1.0.0
|
|
16
|
+
*/
|
|
17
|
+
export interface HelperResult {
|
|
18
|
+
readonly ok: boolean;
|
|
19
|
+
readonly value?: unknown;
|
|
20
|
+
readonly code?: string | null;
|
|
21
|
+
readonly syscall?: string | null;
|
|
22
|
+
readonly badArgument?: boolean;
|
|
23
|
+
readonly message?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The `module` every `PlatformError` this adapter reports names.
|
|
27
|
+
* @private
|
|
28
|
+
* @since 1.0.0
|
|
29
|
+
*/
|
|
30
|
+
export declare const moduleName = "AtomicFileSystem";
|
|
31
|
+
/**
|
|
32
|
+
* Room for `flows-atomic/1 <digits>\n` above the payload ceiling.
|
|
33
|
+
* @private
|
|
34
|
+
* @since 1.0.0
|
|
35
|
+
*/
|
|
36
|
+
export declare const frameHeaderBytes = 64;
|
|
37
|
+
/**
|
|
38
|
+
* A request framed for the helper: one atomic operation, or one member of a
|
|
39
|
+
* batch. The two protocols name their operands differently — a batch `glob`
|
|
40
|
+
* carries the `path` it expands where an atomic `glob` carries a `pattern` —
|
|
41
|
+
* so the reporting helpers read the operand by narrowing on the operation
|
|
42
|
+
* rather than by taking whichever of three optional fields happened to be set.
|
|
43
|
+
* @private
|
|
44
|
+
* @since 1.0.0
|
|
45
|
+
*/
|
|
46
|
+
export type FramedRequest = KernelFileSystem.AtomicRequest | KernelFileSystem.AtomicBatchRequest;
|
|
47
|
+
/**
|
|
48
|
+
* A rejection carrying no errno is a transport or host failure — an absent
|
|
49
|
+
* helper, a killed child, output that is not a helper result — and stays
|
|
50
|
+
* `PermissionDenied` so the boundary fails closed rather than reporting a
|
|
51
|
+
* benign-looking reason for an operation that never ran.
|
|
52
|
+
* @private
|
|
53
|
+
* @since 1.0.0
|
|
54
|
+
*/
|
|
55
|
+
export declare const failure: (request: FramedRequest, cause: unknown, rejection?: HelperResult) => PlatformError.PlatformError;
|
|
56
|
+
/**
|
|
57
|
+
* Frames a serialized request: the protocol tag, the body length, and the
|
|
58
|
+
* request, content, and response ceilings the helper enforces on its side,
|
|
59
|
+
* then the body.
|
|
60
|
+
* @private
|
|
61
|
+
* @since 1.0.0
|
|
62
|
+
*/
|
|
63
|
+
export declare const encode: (body: Buffer, limits: Limits) => Buffer;
|
|
64
|
+
/**
|
|
65
|
+
* Decodes one complete response frame into a result envelope. Anything that
|
|
66
|
+
* is not exactly one well-formed frame within the response ceiling throws.
|
|
67
|
+
* @private
|
|
68
|
+
* @since 1.0.0
|
|
69
|
+
*/
|
|
70
|
+
export declare const decode: (frame: Buffer, limits: Limits) => HelperResult;
|
|
71
|
+
/**
|
|
72
|
+
* Converts a successful helper value into the result the request's operation
|
|
73
|
+
* promises, and throws when the value does not have that shape.
|
|
74
|
+
* @private
|
|
75
|
+
* @since 1.0.0
|
|
76
|
+
*/
|
|
77
|
+
export declare const convert: <A>(request: FramedRequest, value: unknown, limits: Limits) => Effect.Effect<A, PlatformError.PlatformError>;
|
|
78
|
+
//# sourceMappingURL=AtomicFileSystemProtocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AtomicFileSystemProtocol.d.ts","sourceRoot":"","sources":["../../../src/internal/AtomicFileSystemProtocol.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,gBAAgB,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAE,MAAM,EAA2B,aAAa,EAAU,MAAM,QAAQ,CAAA;AAG/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAGpD;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAA;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,qBAAqB,CAAA;A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