@smthrs/platform-node 0.0.0-stage → 1.0.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (442) hide show
  1. package/CHANGELOG.md +211 -0
  2. package/LICENSE +21 -0
  3. package/README.md +165 -2
  4. package/bin/darwin-arm64/smithers-jj-export +0 -0
  5. package/bin/darwin-x64/smithers-jj-export +0 -0
  6. package/bin/linux-arm64/smithers-jj-export +0 -0
  7. package/bin/linux-x64/smithers-jj-export +4 -0
  8. package/bin/win32-x64/smithers-jj-export.exe +0 -0
  9. package/dist/cjs/AtomicFileSystem.d.ts +147 -0
  10. package/dist/cjs/AtomicFileSystem.d.ts.map +1 -0
  11. package/dist/cjs/AtomicFileSystem.js +234 -0
  12. package/dist/cjs/AtomicFileSystem.js.map +7 -0
  13. package/dist/cjs/EgressHttpClient.d.ts +106 -0
  14. package/dist/cjs/EgressHttpClient.d.ts.map +1 -0
  15. package/dist/cjs/EgressHttpClient.js +202 -0
  16. package/dist/cjs/EgressHttpClient.js.map +7 -0
  17. package/dist/cjs/HostLiveness.d.ts +81 -0
  18. package/dist/cjs/HostLiveness.d.ts.map +1 -0
  19. package/dist/cjs/HostLiveness.js +49 -0
  20. package/dist/cjs/HostLiveness.js.map +7 -0
  21. package/dist/cjs/NodeHost.d.ts +145 -0
  22. package/dist/cjs/NodeHost.d.ts.map +1 -0
  23. package/dist/cjs/NodeHost.js +128 -0
  24. package/dist/cjs/NodeHost.js.map +7 -0
  25. package/dist/cjs/ProcessConfinement.d.ts +61 -0
  26. package/dist/cjs/ProcessConfinement.d.ts.map +1 -0
  27. package/dist/cjs/ProcessConfinement.js +287 -0
  28. package/dist/cjs/ProcessConfinement.js.map +7 -0
  29. package/dist/cjs/ProcessReaper.d.ts +457 -0
  30. package/dist/cjs/ProcessReaper.d.ts.map +1 -0
  31. package/dist/cjs/ProcessReaper.js +349 -0
  32. package/dist/cjs/ProcessReaper.js.map +7 -0
  33. package/dist/cjs/ProcessSandbox.d.ts +377 -0
  34. package/dist/cjs/ProcessSandbox.d.ts.map +1 -0
  35. package/dist/cjs/ProcessSandbox.js +759 -0
  36. package/dist/cjs/ProcessSandbox.js.map +7 -0
  37. package/dist/cjs/ScopedProcess.d.ts +65 -0
  38. package/dist/cjs/ScopedProcess.d.ts.map +1 -0
  39. package/dist/cjs/ScopedProcess.js +87 -0
  40. package/dist/cjs/ScopedProcess.js.map +7 -0
  41. package/dist/cjs/index.d.ts +38 -0
  42. package/dist/cjs/index.d.ts.map +1 -0
  43. package/dist/cjs/index.js +47 -0
  44. package/dist/cjs/index.js.map +7 -0
  45. package/dist/cjs/internal/AtomicFileSystemExecutable.d.ts +61 -0
  46. package/dist/cjs/internal/AtomicFileSystemExecutable.d.ts.map +1 -0
  47. package/dist/cjs/internal/AtomicFileSystemExecutable.js +250 -0
  48. package/dist/cjs/internal/AtomicFileSystemExecutable.js.map +7 -0
  49. package/dist/cjs/internal/AtomicFileSystemProtocol.d.ts +78 -0
  50. package/dist/cjs/internal/AtomicFileSystemProtocol.d.ts.map +1 -0
  51. package/dist/cjs/internal/AtomicFileSystemProtocol.js +382 -0
  52. package/dist/cjs/internal/AtomicFileSystemProtocol.js.map +7 -0
  53. package/dist/cjs/internal/AtomicFileSystemTransport.d.ts +44 -0
  54. package/dist/cjs/internal/AtomicFileSystemTransport.d.ts.map +1 -0
  55. package/dist/cjs/internal/AtomicFileSystemTransport.js +197 -0
  56. package/dist/cjs/internal/AtomicFileSystemTransport.js.map +7 -0
  57. package/dist/cjs/internal/AtomicHelperError.d.ts +35 -0
  58. package/dist/cjs/internal/AtomicHelperError.d.ts.map +1 -0
  59. package/dist/cjs/internal/AtomicHelperError.js +45 -0
  60. package/dist/cjs/internal/AtomicHelperError.js.map +7 -0
  61. package/dist/cjs/internal/AtomicHelperFault.d.ts +59 -0
  62. package/dist/cjs/internal/AtomicHelperFault.d.ts.map +1 -0
  63. package/dist/cjs/internal/AtomicHelperFault.js +66 -0
  64. package/dist/cjs/internal/AtomicHelperFault.js.map +7 -0
  65. package/dist/cjs/internal/PipedProcess.d.ts +35 -0
  66. package/dist/cjs/internal/PipedProcess.d.ts.map +1 -0
  67. package/dist/cjs/internal/PipedProcess.js +309 -0
  68. package/dist/cjs/internal/PipedProcess.js.map +7 -0
  69. package/dist/cjs/internal/ProcSnapshot.d.ts +85 -0
  70. package/dist/cjs/internal/ProcSnapshot.d.ts.map +1 -0
  71. package/dist/cjs/internal/ProcSnapshot.js +123 -0
  72. package/dist/cjs/internal/ProcSnapshot.js.map +7 -0
  73. package/dist/cjs/internal/ProcessCleanup.d.ts +64 -0
  74. package/dist/cjs/internal/ProcessCleanup.d.ts.map +1 -0
  75. package/dist/cjs/internal/ProcessCleanup.js +62 -0
  76. package/dist/cjs/internal/ProcessCleanup.js.map +7 -0
  77. package/dist/cjs/internal/ProcessCleanupPolicyError.d.ts +30 -0
  78. package/dist/cjs/internal/ProcessCleanupPolicyError.d.ts.map +1 -0
  79. package/dist/cjs/internal/ProcessCleanupPolicyError.js +33 -0
  80. package/dist/cjs/internal/ProcessCleanupPolicyError.js.map +7 -0
  81. package/dist/cjs/internal/ProcessFault.d.ts +63 -0
  82. package/dist/cjs/internal/ProcessFault.d.ts.map +1 -0
  83. package/dist/cjs/internal/ProcessFault.js +63 -0
  84. package/dist/cjs/internal/ProcessFault.js.map +7 -0
  85. package/dist/cjs/internal/ProcessSupervisor.d.ts +141 -0
  86. package/dist/cjs/internal/ProcessSupervisor.d.ts.map +1 -0
  87. package/dist/cjs/internal/ProcessSupervisor.js +682 -0
  88. package/dist/cjs/internal/ProcessSupervisor.js.map +7 -0
  89. package/dist/cjs/internal/SupervisorProgram.d.ts +9 -0
  90. package/dist/cjs/internal/SupervisorProgram.d.ts.map +1 -0
  91. package/dist/cjs/internal/SupervisorProgram.js +306 -0
  92. package/dist/cjs/internal/SupervisorProgram.js.map +7 -0
  93. package/dist/cjs/internal/WindowsProcessJob.d.ts +39 -0
  94. package/dist/cjs/internal/WindowsProcessJob.d.ts.map +1 -0
  95. package/dist/cjs/internal/WindowsProcessJob.js +113 -0
  96. package/dist/cjs/internal/WindowsProcessJob.js.map +7 -0
  97. package/dist/cjs/package.json +1 -0
  98. package/dist/esm/AtomicFileSystem.d.ts +147 -0
  99. package/dist/esm/AtomicFileSystem.d.ts.map +1 -0
  100. package/dist/esm/AtomicFileSystem.js +290 -0
  101. package/dist/esm/AtomicFileSystem.js.map +1 -0
  102. package/dist/esm/EgressHttpClient.d.ts +106 -0
  103. package/dist/esm/EgressHttpClient.d.ts.map +1 -0
  104. package/dist/esm/EgressHttpClient.js +259 -0
  105. package/dist/esm/EgressHttpClient.js.map +1 -0
  106. package/dist/esm/HostLiveness.d.ts +81 -0
  107. package/dist/esm/HostLiveness.d.ts.map +1 -0
  108. package/dist/esm/HostLiveness.js +68 -0
  109. package/dist/esm/HostLiveness.js.map +1 -0
  110. package/dist/esm/NodeHost.d.ts +145 -0
  111. package/dist/esm/NodeHost.d.ts.map +1 -0
  112. package/dist/esm/NodeHost.js +162 -0
  113. package/dist/esm/NodeHost.js.map +1 -0
  114. package/dist/esm/ProcessConfinement.d.ts +61 -0
  115. package/dist/esm/ProcessConfinement.d.ts.map +1 -0
  116. package/dist/esm/ProcessConfinement.js +311 -0
  117. package/dist/esm/ProcessConfinement.js.map +1 -0
  118. package/dist/esm/ProcessReaper.d.ts +457 -0
  119. package/dist/esm/ProcessReaper.d.ts.map +1 -0
  120. package/dist/esm/ProcessReaper.js +711 -0
  121. package/dist/esm/ProcessReaper.js.map +1 -0
  122. package/dist/esm/ProcessSandbox.d.ts +377 -0
  123. package/dist/esm/ProcessSandbox.d.ts.map +1 -0
  124. package/dist/esm/ProcessSandbox.js +1014 -0
  125. package/dist/esm/ProcessSandbox.js.map +1 -0
  126. package/dist/esm/ScopedProcess.d.ts +65 -0
  127. package/dist/esm/ScopedProcess.d.ts.map +1 -0
  128. package/dist/esm/ScopedProcess.js +66 -0
  129. package/dist/esm/ScopedProcess.js.map +1 -0
  130. package/dist/esm/index.d.ts +38 -0
  131. package/dist/esm/index.d.ts.map +1 -0
  132. package/dist/esm/index.js +38 -0
  133. package/dist/esm/index.js.map +1 -0
  134. package/dist/esm/internal/AtomicFileSystemExecutable.d.ts +61 -0
  135. package/dist/esm/internal/AtomicFileSystemExecutable.d.ts.map +1 -0
  136. package/dist/esm/internal/AtomicFileSystemExecutable.js +350 -0
  137. package/dist/esm/internal/AtomicFileSystemExecutable.js.map +1 -0
  138. package/dist/esm/internal/AtomicFileSystemProtocol.d.ts +78 -0
  139. package/dist/esm/internal/AtomicFileSystemProtocol.d.ts.map +1 -0
  140. package/dist/esm/internal/AtomicFileSystemProtocol.js +412 -0
  141. package/dist/esm/internal/AtomicFileSystemProtocol.js.map +1 -0
  142. package/dist/esm/internal/AtomicFileSystemTransport.d.ts +44 -0
  143. package/dist/esm/internal/AtomicFileSystemTransport.d.ts.map +1 -0
  144. package/dist/esm/internal/AtomicFileSystemTransport.js +242 -0
  145. package/dist/esm/internal/AtomicFileSystemTransport.js.map +1 -0
  146. package/dist/esm/internal/AtomicHelperError.d.ts +35 -0
  147. package/dist/esm/internal/AtomicHelperError.d.ts.map +1 -0
  148. package/dist/esm/internal/AtomicHelperError.js +39 -0
  149. package/dist/esm/internal/AtomicHelperError.js.map +1 -0
  150. package/dist/esm/internal/AtomicHelperFault.d.ts +59 -0
  151. package/dist/esm/internal/AtomicHelperFault.d.ts.map +1 -0
  152. package/dist/esm/internal/AtomicHelperFault.js +66 -0
  153. package/dist/esm/internal/AtomicHelperFault.js.map +1 -0
  154. package/dist/esm/internal/PipedProcess.d.ts +35 -0
  155. package/dist/esm/internal/PipedProcess.d.ts.map +1 -0
  156. package/dist/esm/internal/PipedProcess.js +321 -0
  157. package/dist/esm/internal/PipedProcess.js.map +1 -0
  158. package/dist/esm/internal/ProcSnapshot.d.ts +85 -0
  159. package/dist/esm/internal/ProcSnapshot.d.ts.map +1 -0
  160. package/dist/esm/internal/ProcSnapshot.js +188 -0
  161. package/dist/esm/internal/ProcSnapshot.js.map +1 -0
  162. package/dist/esm/internal/ProcessCleanup.d.ts +64 -0
  163. package/dist/esm/internal/ProcessCleanup.d.ts.map +1 -0
  164. package/dist/esm/internal/ProcessCleanup.js +45 -0
  165. package/dist/esm/internal/ProcessCleanup.js.map +1 -0
  166. package/dist/esm/internal/ProcessCleanupPolicyError.d.ts +30 -0
  167. package/dist/esm/internal/ProcessCleanupPolicyError.d.ts.map +1 -0
  168. package/dist/esm/internal/ProcessCleanupPolicyError.js +25 -0
  169. package/dist/esm/internal/ProcessCleanupPolicyError.js.map +1 -0
  170. package/dist/esm/internal/ProcessFault.d.ts +63 -0
  171. package/dist/esm/internal/ProcessFault.d.ts.map +1 -0
  172. package/dist/esm/internal/ProcessFault.js +64 -0
  173. package/dist/esm/internal/ProcessFault.js.map +1 -0
  174. package/dist/esm/internal/ProcessSupervisor.d.ts +141 -0
  175. package/dist/esm/internal/ProcessSupervisor.d.ts.map +1 -0
  176. package/dist/esm/internal/ProcessSupervisor.js +682 -0
  177. package/dist/esm/internal/ProcessSupervisor.js.map +1 -0
  178. package/dist/esm/internal/SupervisorProgram.d.ts +9 -0
  179. package/dist/esm/internal/SupervisorProgram.d.ts.map +1 -0
  180. package/dist/esm/internal/SupervisorProgram.js +290 -0
  181. package/dist/esm/internal/SupervisorProgram.js.map +1 -0
  182. package/dist/esm/internal/WindowsProcessJob.d.ts +39 -0
  183. package/dist/esm/internal/WindowsProcessJob.d.ts.map +1 -0
  184. package/dist/esm/internal/WindowsProcessJob.js +115 -0
  185. package/dist/esm/internal/WindowsProcessJob.js.map +1 -0
  186. package/dist/vendor/adapters.json +1757 -0
  187. package/dist/vendor/chunk-2Y7WC4KU.js +109 -0
  188. package/dist/vendor/chunk-3GR5VZ2M.js +118 -0
  189. package/dist/vendor/chunk-42QKY6T6.js +40 -0
  190. package/dist/vendor/chunk-54RLBMTZ.js +61 -0
  191. package/dist/vendor/chunk-5ZMHBXIK.js +55 -0
  192. package/dist/vendor/chunk-6ME2W7TF.js +28 -0
  193. package/dist/vendor/chunk-AMQKOQNT.js +34 -0
  194. package/dist/vendor/chunk-B3FZ67QU.js +59 -0
  195. package/dist/vendor/chunk-BKTBUBQY.js +437 -0
  196. package/dist/vendor/chunk-DS7GF46S.js +34 -0
  197. package/dist/vendor/chunk-DVOAHXPG.js +104 -0
  198. package/dist/vendor/chunk-DWSHTSVX.js +229 -0
  199. package/dist/vendor/chunk-EGBNVEEW.js +14 -0
  200. package/dist/vendor/chunk-EZWY45HP.js +18 -0
  201. package/dist/vendor/chunk-FNZOJHSV.js +71 -0
  202. package/dist/vendor/chunk-GXCHI7BM.js +131 -0
  203. package/dist/vendor/chunk-IIJ52ZU6.js +20 -0
  204. package/dist/vendor/chunk-J7A4CZDO.js +92 -0
  205. package/dist/vendor/chunk-JG5TTWPT.js +85 -0
  206. package/dist/vendor/chunk-JJ24ARBQ.js +394 -0
  207. package/dist/vendor/chunk-KOZMM5PZ.js +426 -0
  208. package/dist/vendor/chunk-KUUXSID7.js +18 -0
  209. package/dist/vendor/chunk-LEUPYT3Q.js +36 -0
  210. package/dist/vendor/chunk-M32LDTW7.js +18 -0
  211. package/dist/vendor/chunk-M7CLUILA.js +0 -0
  212. package/dist/vendor/chunk-MBSKBQ5D.js +21 -0
  213. package/dist/vendor/chunk-MLKGABMK.js +9 -0
  214. package/dist/vendor/chunk-NBVRTDTV.js +129 -0
  215. package/dist/vendor/chunk-OXNGN5H7.js +81 -0
  216. package/dist/vendor/chunk-QPLDT6A6.js +564 -0
  217. package/dist/vendor/chunk-QYBKAIA6.js +18 -0
  218. package/dist/vendor/chunk-RO2R4MJH.js +62 -0
  219. package/dist/vendor/chunk-SIR62W3Y.js +398 -0
  220. package/dist/vendor/chunk-TFIKFFSC.js +26 -0
  221. package/dist/vendor/chunk-TXKLEBBL.js +143 -0
  222. package/dist/vendor/chunk-UFH5UUZK.js +48 -0
  223. package/dist/vendor/chunk-VANKHF46.js +96 -0
  224. package/dist/vendor/chunk-VZBDV3TV.js +18 -0
  225. package/dist/vendor/chunk-XDKNKFBW.js +22 -0
  226. package/dist/vendor/chunk-XH4U3JSV.js +249 -0
  227. package/dist/vendor/chunk-Y35ZAO5U.js +53 -0
  228. package/dist/vendor/chunk-ZJMRMY57.js +0 -0
  229. package/dist/vendor/cjs/node/NodeChildProcessSpawner.d.ts +7 -0
  230. package/dist/vendor/cjs/node/NodeChildProcessSpawner.js +1 -0
  231. package/dist/vendor/cjs/node/NodeClusterHttp.d.ts +63 -0
  232. package/dist/vendor/cjs/node/NodeClusterHttp.js +1 -0
  233. package/dist/vendor/cjs/node/NodeClusterSocket.d.ts +79 -0
  234. package/dist/vendor/cjs/node/NodeClusterSocket.js +1 -0
  235. package/dist/vendor/cjs/node/NodeCrypto.d.ts +10 -0
  236. package/dist/vendor/cjs/node/NodeCrypto.js +1 -0
  237. package/dist/vendor/cjs/node/NodeFileSystem.d.ts +10 -0
  238. package/dist/vendor/cjs/node/NodeFileSystem.js +1 -0
  239. package/dist/vendor/cjs/node/NodeHttpClient.d.ts +179 -0
  240. package/dist/vendor/cjs/node/NodeHttpClient.js +1 -0
  241. package/dist/vendor/cjs/node/NodeHttpIncomingMessage.d.ts +62 -0
  242. package/dist/vendor/cjs/node/NodeHttpIncomingMessage.js +1 -0
  243. package/dist/vendor/cjs/node/NodeHttpPlatform.d.ts +36 -0
  244. package/dist/vendor/cjs/node/NodeHttpPlatform.js +1 -0
  245. package/dist/vendor/cjs/node/NodeHttpServer.d.ts +120 -0
  246. package/dist/vendor/cjs/node/NodeHttpServer.js +1 -0
  247. package/dist/vendor/cjs/node/NodeHttpServerRequest.d.ts +29 -0
  248. package/dist/vendor/cjs/node/NodeHttpServerRequest.js +1 -0
  249. package/dist/vendor/cjs/node/NodeMultipart.d.ts +46 -0
  250. package/dist/vendor/cjs/node/NodeMultipart.js +1 -0
  251. package/dist/vendor/cjs/node/NodeMultipartParser.d.ts +97 -0
  252. package/dist/vendor/cjs/node/NodeMultipartParser.js +1 -0
  253. package/dist/vendor/cjs/node/NodePath.d.ts +27 -0
  254. package/dist/vendor/cjs/node/NodePath.js +1 -0
  255. package/dist/vendor/cjs/node/NodeRedis.d.ts +74 -0
  256. package/dist/vendor/cjs/node/NodeRedis.js +1 -0
  257. package/dist/vendor/cjs/node/NodeRuntime.d.ts +85 -0
  258. package/dist/vendor/cjs/node/NodeRuntime.js +1 -0
  259. package/dist/vendor/cjs/node/NodeServices.d.ts +34 -0
  260. package/dist/vendor/cjs/node/NodeServices.js +1 -0
  261. package/dist/vendor/cjs/node/NodeSink.d.ts +8 -0
  262. package/dist/vendor/cjs/node/NodeSink.js +1 -0
  263. package/dist/vendor/cjs/node/NodeSocket.d.ts +38 -0
  264. package/dist/vendor/cjs/node/NodeSocket.js +1 -0
  265. package/dist/vendor/cjs/node/NodeSocketServer.d.ts +8 -0
  266. package/dist/vendor/cjs/node/NodeSocketServer.js +1 -0
  267. package/dist/vendor/cjs/node/NodeStdio.d.ts +11 -0
  268. package/dist/vendor/cjs/node/NodeStdio.js +1 -0
  269. package/dist/vendor/cjs/node/NodeStream.d.ts +8 -0
  270. package/dist/vendor/cjs/node/NodeStream.js +1 -0
  271. package/dist/vendor/cjs/node/NodeTerminal.d.ts +21 -0
  272. package/dist/vendor/cjs/node/NodeTerminal.js +1 -0
  273. package/dist/vendor/cjs/node/NodeWorker.d.ts +22 -0
  274. package/dist/vendor/cjs/node/NodeWorker.js +1 -0
  275. package/dist/vendor/cjs/node/NodeWorkerRunner.d.ts +12 -0
  276. package/dist/vendor/cjs/node/NodeWorkerRunner.js +1 -0
  277. package/dist/vendor/cjs/node/Undici.d.ts +28 -0
  278. package/dist/vendor/cjs/node/Undici.js +1 -0
  279. package/dist/vendor/cjs/node/index.d.ts +100 -0
  280. package/dist/vendor/cjs/node/index.js +1 -0
  281. package/dist/vendor/cjs/node-shared/NodeChildProcessSpawner.d.ts +57 -0
  282. package/dist/vendor/cjs/node-shared/NodeChildProcessSpawner.js +1 -0
  283. package/dist/vendor/cjs/node-shared/NodeClusterSocket.d.ts +22 -0
  284. package/dist/vendor/cjs/node-shared/NodeClusterSocket.js +1 -0
  285. package/dist/vendor/cjs/node-shared/NodeCrypto.d.ts +27 -0
  286. package/dist/vendor/cjs/node-shared/NodeCrypto.js +1 -0
  287. package/dist/vendor/cjs/node-shared/NodeFileSystem.d.ts +11 -0
  288. package/dist/vendor/cjs/node-shared/NodeFileSystem.js +1 -0
  289. package/dist/vendor/cjs/node-shared/NodeHttpCompression.d.ts +36 -0
  290. package/dist/vendor/cjs/node-shared/NodeHttpCompression.js +1 -0
  291. package/dist/vendor/cjs/node-shared/NodePath.d.ts +27 -0
  292. package/dist/vendor/cjs/node-shared/NodePath.js +1 -0
  293. package/dist/vendor/cjs/node-shared/NodeRuntime.d.ts +47 -0
  294. package/dist/vendor/cjs/node-shared/NodeRuntime.js +1 -0
  295. package/dist/vendor/cjs/node-shared/NodeSink.d.ts +69 -0
  296. package/dist/vendor/cjs/node-shared/NodeSink.js +1 -0
  297. package/dist/vendor/cjs/node-shared/NodeSocket.d.ts +134 -0
  298. package/dist/vendor/cjs/node-shared/NodeSocket.js +1 -0
  299. package/dist/vendor/cjs/node-shared/NodeSocketServer.d.ts +80 -0
  300. package/dist/vendor/cjs/node-shared/NodeSocketServer.js +1 -0
  301. package/dist/vendor/cjs/node-shared/NodeStdio.d.ts +12 -0
  302. package/dist/vendor/cjs/node-shared/NodeStdio.js +1 -0
  303. package/dist/vendor/cjs/node-shared/NodeStream.d.ts +179 -0
  304. package/dist/vendor/cjs/node-shared/NodeStream.js +1 -0
  305. package/dist/vendor/cjs/node-shared/NodeTerminal.d.ts +22 -0
  306. package/dist/vendor/cjs/node-shared/NodeTerminal.js +1 -0
  307. package/dist/vendor/cjs/node-shared/index.d.ts +56 -0
  308. package/dist/vendor/cjs/node-shared/index.js +1 -0
  309. package/dist/vendor/cjs/node-shared/internal/nodeChildProcessSpawner.d.ts +4 -0
  310. package/dist/vendor/cjs/node-shared/internal/nodeChildProcessSpawner.js +1 -0
  311. package/dist/vendor/cjs/node-shared/internal/utils.d.ts +2 -0
  312. package/dist/vendor/cjs/node-shared/internal/utils.js +1 -0
  313. package/dist/vendor/cjs/package.json +1 -0
  314. package/dist/vendor/cjs/platform-node-shared.d.ts +56 -0
  315. package/dist/vendor/cjs/platform-node-shared.js +1 -0
  316. package/dist/vendor/cjs/platform-node.d.ts +100 -0
  317. package/dist/vendor/cjs/platform-node.js +1 -0
  318. package/dist/vendor/node/LICENSE +21 -0
  319. package/dist/vendor/node/NodeChildProcessSpawner.d.ts +7 -0
  320. package/dist/vendor/node/NodeChildProcessSpawner.js +14 -0
  321. package/dist/vendor/node/NodeClusterHttp.d.ts +63 -0
  322. package/dist/vendor/node/NodeClusterHttp.js +43 -0
  323. package/dist/vendor/node/NodeClusterSocket.d.ts +79 -0
  324. package/dist/vendor/node/NodeClusterSocket.js +30 -0
  325. package/dist/vendor/node/NodeCrypto.d.ts +10 -0
  326. package/dist/vendor/node/NodeCrypto.js +8 -0
  327. package/dist/vendor/node/NodeFileSystem.d.ts +10 -0
  328. package/dist/vendor/node/NodeFileSystem.js +9 -0
  329. package/dist/vendor/node/NodeHttpClient.d.ts +179 -0
  330. package/dist/vendor/node/NodeHttpClient.js +46 -0
  331. package/dist/vendor/node/NodeHttpIncomingMessage.d.ts +62 -0
  332. package/dist/vendor/node/NodeHttpIncomingMessage.js +10 -0
  333. package/dist/vendor/node/NodeHttpPlatform.d.ts +36 -0
  334. package/dist/vendor/node/NodeHttpPlatform.js +16 -0
  335. package/dist/vendor/node/NodeHttpServer.d.ts +120 -0
  336. package/dist/vendor/node/NodeHttpServer.js +46 -0
  337. package/dist/vendor/node/NodeHttpServerRequest.d.ts +29 -0
  338. package/dist/vendor/node/NodeHttpServerRequest.js +9 -0
  339. package/dist/vendor/node/NodeMultipart.d.ts +46 -0
  340. package/dist/vendor/node/NodeMultipart.js +15 -0
  341. package/dist/vendor/node/NodeMultipartParser.d.ts +97 -0
  342. package/dist/vendor/node/NodeMultipartParser.js +11 -0
  343. package/dist/vendor/node/NodePath.d.ts +27 -0
  344. package/dist/vendor/node/NodePath.js +12 -0
  345. package/dist/vendor/node/NodeRedis.d.ts +74 -0
  346. package/dist/vendor/node/NodeRedis.js +11 -0
  347. package/dist/vendor/node/NodeRuntime.d.ts +85 -0
  348. package/dist/vendor/node/NodeRuntime.js +8 -0
  349. package/dist/vendor/node/NodeServices.d.ts +34 -0
  350. package/dist/vendor/node/NodeServices.js +23 -0
  351. package/dist/vendor/node/NodeSink.d.ts +8 -0
  352. package/dist/vendor/node/NodeSink.js +12 -0
  353. package/dist/vendor/node/NodeSocket.d.ts +38 -0
  354. package/dist/vendor/node/NodeSocket.js +31 -0
  355. package/dist/vendor/node/NodeSocketServer.d.ts +8 -0
  356. package/dist/vendor/node/NodeSocketServer.js +21 -0
  357. package/dist/vendor/node/NodeStdio.d.ts +11 -0
  358. package/dist/vendor/node/NodeStdio.js +10 -0
  359. package/dist/vendor/node/NodeStream.d.ts +8 -0
  360. package/dist/vendor/node/NodeStream.js +27 -0
  361. package/dist/vendor/node/NodeTerminal.d.ts +21 -0
  362. package/dist/vendor/node/NodeTerminal.js +10 -0
  363. package/dist/vendor/node/NodeWorker.d.ts +22 -0
  364. package/dist/vendor/node/NodeWorker.js +9 -0
  365. package/dist/vendor/node/NodeWorkerRunner.d.ts +12 -0
  366. package/dist/vendor/node/NodeWorkerRunner.js +7 -0
  367. package/dist/vendor/node/Undici.d.ts +28 -0
  368. package/dist/vendor/node/Undici.js +9 -0
  369. package/dist/vendor/node/index.d.ts +100 -0
  370. package/dist/vendor/node/index.js +115 -0
  371. package/dist/vendor/node-shared/LICENSE +21 -0
  372. package/dist/vendor/node-shared/NodeChildProcessSpawner.d.ts +57 -0
  373. package/dist/vendor/node-shared/NodeChildProcessSpawner.js +13 -0
  374. package/dist/vendor/node-shared/NodeClusterSocket.d.ts +22 -0
  375. package/dist/vendor/node-shared/NodeClusterSocket.js +11 -0
  376. package/dist/vendor/node-shared/NodeCrypto.d.ts +27 -0
  377. package/dist/vendor/node-shared/NodeCrypto.js +9 -0
  378. package/dist/vendor/node-shared/NodeFileSystem.d.ts +11 -0
  379. package/dist/vendor/node-shared/NodeFileSystem.js +8 -0
  380. package/dist/vendor/node-shared/NodeHttpCompression.d.ts +36 -0
  381. package/dist/vendor/node-shared/NodeHttpCompression.js +13 -0
  382. package/dist/vendor/node-shared/NodePath.d.ts +27 -0
  383. package/dist/vendor/node-shared/NodePath.js +11 -0
  384. package/dist/vendor/node-shared/NodeRuntime.d.ts +47 -0
  385. package/dist/vendor/node-shared/NodeRuntime.js +7 -0
  386. package/dist/vendor/node-shared/NodeSink.d.ts +69 -0
  387. package/dist/vendor/node-shared/NodeSink.js +11 -0
  388. package/dist/vendor/node-shared/NodeSocket.d.ts +134 -0
  389. package/dist/vendor/node-shared/NodeSocket.js +23 -0
  390. package/dist/vendor/node-shared/NodeSocketServer.d.ts +80 -0
  391. package/dist/vendor/node-shared/NodeSocketServer.js +20 -0
  392. package/dist/vendor/node-shared/NodeStdio.d.ts +12 -0
  393. package/dist/vendor/node-shared/NodeStdio.js +9 -0
  394. package/dist/vendor/node-shared/NodeStream.d.ts +179 -0
  395. package/dist/vendor/node-shared/NodeStream.js +26 -0
  396. package/dist/vendor/node-shared/NodeTerminal.d.ts +22 -0
  397. package/dist/vendor/node-shared/NodeTerminal.js +9 -0
  398. package/dist/vendor/node-shared/index.d.ts +56 -0
  399. package/dist/vendor/node-shared/index.js +58 -0
  400. package/dist/vendor/node-shared/internal/nodeChildProcessSpawner.d.ts +4 -0
  401. package/dist/vendor/node-shared/internal/nodeChildProcessSpawner.js +7 -0
  402. package/dist/vendor/node-shared/internal/utils.d.ts +2 -0
  403. package/dist/vendor/node-shared/internal/utils.js +7 -0
  404. package/dist/vendor/platform-node-shared.d.ts +56 -0
  405. package/dist/vendor/platform-node-shared.js +58 -0
  406. package/dist/vendor/platform-node.d.ts +100 -0
  407. package/dist/vendor/platform-node.js +115 -0
  408. package/docs/README.md +129 -0
  409. package/docs/api.md +552 -0
  410. package/docs/concepts/descriptor-relative-filesystem.md +181 -0
  411. package/docs/concepts/host-bundle.md +125 -0
  412. package/docs/concepts/process-containment.md +182 -0
  413. package/docs/guides/answer-run-ownership.md +87 -0
  414. package/docs/guides/configure-the-filesystem-helper.md +152 -0
  415. package/docs/guides/contain-child-processes.md +139 -0
  416. package/docs/guides/match-files-with-glob.md +151 -0
  417. package/docs/installation.md +204 -0
  418. package/docs/quickstart.md +147 -0
  419. package/docs/troubleshooting.md +130 -0
  420. package/package.json +202 -3
  421. package/src/AtomicFileSystem.ts +415 -0
  422. package/src/EgressHttpClient.ts +327 -0
  423. package/src/HostLiveness.ts +103 -0
  424. package/src/NodeHost.ts +253 -0
  425. package/src/ProcessConfinement.ts +356 -0
  426. package/src/ProcessReaper.ts +951 -0
  427. package/src/ProcessSandbox.ts +1273 -0
  428. package/src/ScopedProcess.ts +123 -0
  429. package/src/index.ts +44 -0
  430. package/src/internal/AtomicFileSystemExecutable.ts +379 -0
  431. package/src/internal/AtomicFileSystemProtocol.ts +502 -0
  432. package/src/internal/AtomicFileSystemTransport.ts +272 -0
  433. package/src/internal/AtomicHelperError.ts +50 -0
  434. package/src/internal/AtomicHelperFault.ts +84 -0
  435. package/src/internal/PipedProcess.ts +357 -0
  436. package/src/internal/ProcSnapshot.ts +193 -0
  437. package/src/internal/ProcessCleanup.ts +99 -0
  438. package/src/internal/ProcessCleanupPolicyError.ts +30 -0
  439. package/src/internal/ProcessFault.ts +82 -0
  440. package/src/internal/ProcessSupervisor.ts +801 -0
  441. package/src/internal/SupervisorProgram.ts +289 -0
  442. package/src/internal/WindowsProcessJob.ts +114 -0
@@ -0,0 +1,356 @@
1
+ /**
2
+ * The kernel's `ProcessConfinement` seam, filled with this host's native
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
+
26
+ import * as KernelProcessConfinement from "@smthrs/kernel/ProcessConfinement"
27
+ import * as Effect from "effect/Effect"
28
+ import * as Layer from "effect/Layer"
29
+ import * as PlatformError from "effect/PlatformError"
30
+ import type * as Scope from "effect/Scope"
31
+ import * as ChildProcess from "effect/unstable/process/ChildProcess"
32
+ import * as NodeFs from "node:fs"
33
+ import * as NodeOs from "node:os"
34
+ import * as NodePath from "node:path"
35
+ import * as ProcessSandbox from "./ProcessSandbox.ts"
36
+
37
+ /**
38
+ * How the confinement is built.
39
+ *
40
+ * @category models
41
+ * @since 1.0.0-rc.1
42
+ */
43
+ export interface Options {
44
+ /**
45
+ * What happens when this host has no mechanism to enforce a profile with.
46
+ * `"refuse"` fails the spawn, so a command never runs with more than the
47
+ * profile allows; `"unconfined"` runs it as given and logs a
48
+ * warning naming what the host lacks.
49
+ */
50
+ readonly unavailable?: "refuse" | "unconfined" | undefined
51
+ /** The host facts mechanism selection reads; defaults to the real host. */
52
+ readonly host?: ProcessSandbox.Host | undefined
53
+ /** Where each run's private temporary directory is created; defaults to the OS temporary directory. */
54
+ readonly temporaryDirectory?: string | undefined
55
+ }
56
+
57
+ const shellLine = (command: ChildProcess.StandardCommand): string => [command.command, ...command.args].join(" ")
58
+
59
+ /**
60
+ * The argv a stage executes, with a shell request made explicit.
61
+ *
62
+ * Node runs a `shell: true` stage as `/bin/sh -c <line>` on POSIX, and a
63
+ * string shell as `<shell> -c <line>`; the wrapper needs that program to be
64
+ * the one it confines, so the shell becomes the argv's first token and the
65
+ * spawned stage no longer asks for one.
66
+ */
67
+ const argvOf = (command: ChildProcess.StandardCommand): ReadonlyArray<string> => {
68
+ const shell = command.options.shell
69
+ if (shell === undefined || shell === false) return [command.command, ...command.args]
70
+ return [shell === true ? "/bin/sh" : shell, "-c", shellLine(command)]
71
+ }
72
+
73
+ const failure = (
74
+ tag: "NotFound" | "PermissionDenied" | "Unknown",
75
+ command: ChildProcess.StandardCommand,
76
+ description: string,
77
+ cause: unknown
78
+ ): PlatformError.PlatformError =>
79
+ PlatformError.systemError({
80
+ _tag: tag,
81
+ module: "ProcessConfinement",
82
+ method: "confine",
83
+ pathOrDescriptor: shellLine(command),
84
+ description,
85
+ cause
86
+ })
87
+
88
+ const messageOf = (cause: unknown): string =>
89
+ ProcessSandbox.isUnenforceable(cause)
90
+ ? cause.message
91
+ : cause instanceof Error
92
+ ? cause.message
93
+ : String(cause)
94
+
95
+ /** Classic BPF for seccomp_data: deny host Unix sockets and io_uring, preserving stream socketpair.
96
+ * Closed networking additionally denies every IP socket family.
97
+ * Wrong ABI and x32 syscall encodings fail closed rather than bypassing socket(). */
98
+ const networkFilter = (architecture: string, network: "none" | "open"): Uint8Array => {
99
+ const abi = architecture === "x64"
100
+ ? { audit: 0xc000003e, socket: 41, socketpair: 53 }
101
+ : architecture === "arm64"
102
+ ? { audit: 0xc00000b7, socket: 198, socketpair: 199 }
103
+ : undefined
104
+ if (abi === undefined) throw new Error(`native-network seccomp is unavailable on ${architecture}`)
105
+ const instructions: Array<readonly [number, number, number, number]> = [
106
+ [0x20, 0, 0, 4], // load audit architecture
107
+ [0x15, 1, 0, abi.audit],
108
+ [0x06, 0, 0, 0x80000000], // kill unsupported ABI
109
+ [0x20, 0, 0, 0], // load syscall number
110
+ [0x35, 0, 1, 0x40000000],
111
+ [0x06, 0, 0, 0x80000000], // kill x32 / invalid high syscall numbers
112
+ [0x15, 0, 1, 425], // io_uring_setup on both supported ABIs
113
+ [0x06, 0, 0, 0x00050001], // io_uring can otherwise create sockets without socket()
114
+ [0x15, 0, 6, abi.socketpair],
115
+ [0x20, 0, 0, 16], // socketpair domain
116
+ [0x15, 0, 4, 1], // AF_UNIX
117
+ [0x20, 0, 0, 24], // socketpair type, low 32 bits of args[1]
118
+ [0x54, 0, 0, 0xf], // strip SOCK_NONBLOCK and SOCK_CLOEXEC
119
+ [0x15, 1, 0, 1], // only SOCK_STREAM; Linux aliases SOCK_RAW to datagram operations
120
+ [0x06, 0, 0, 0x00050001],
121
+ [0x20, 0, 0, 0] // reload syscall number before the socket() policy
122
+ ]
123
+ if (network === "none") {
124
+ instructions.push([0x15, 0, 1, abi.socket], [0x06, 0, 0, 0x00050001]) // EPERM for every socket family
125
+ } else {
126
+ instructions.push(
127
+ [0x15, 0, 3, abi.socket],
128
+ [0x20, 0, 0, 16], // socket domain, low 32 bits of args[0]
129
+ [0x15, 0, 1, 1], // AF_UNIX; IP families remain available
130
+ [0x06, 0, 0, 0x00050001]
131
+ )
132
+ }
133
+ instructions.push([0x06, 0, 0, 0x7fff0000]) // SECCOMP_RET_ALLOW
134
+ const bytes = new Uint8Array(instructions.length * 8)
135
+ const view = new DataView(bytes.buffer)
136
+ for (const [index, [code, jt, jf, value]] of instructions.entries()) {
137
+ view.setUint16(index * 8, code, true)
138
+ view.setUint8(index * 8 + 2, jt)
139
+ view.setUint8(index * 8 + 3, jf)
140
+ view.setUint32(index * 8 + 4, value, true)
141
+ }
142
+ return bytes
143
+ }
144
+
145
+ /**
146
+ * Builds the native confinement.
147
+ *
148
+ * @category constructors
149
+ * @since 1.0.0-rc.1
150
+ */
151
+ export const make = (options: Options = {}): KernelProcessConfinement.Service => {
152
+ const hostFacts = options.host ?? ProcessSandbox.host()
153
+ const temporaryRoot = options.temporaryDirectory ?? NodeOs.tmpdir()
154
+ const unavailable = options.unavailable ?? "refuse"
155
+ const confine = Effect.fn("ProcessConfinement.confine")(function*(
156
+ command: ChildProcess.StandardCommand,
157
+ profile: KernelProcessConfinement.Profile
158
+ ): Effect.fn.Return<ChildProcess.StandardCommand, PlatformError.PlatformError, Scope.Scope> {
159
+ const request: ProcessSandbox.Request = {
160
+ network: profile.network,
161
+ unixSockets: false,
162
+ strict: true,
163
+ reads: profile.reads,
164
+ writes: profile.writes,
165
+ readOnly: profile.readOnly
166
+ }
167
+ const selected = ProcessSandbox.select(request, hostFacts)
168
+ if (ProcessSandbox.isUnenforceable(selected)) {
169
+ if (unavailable === "refuse") {
170
+ return yield* failure(
171
+ "NotFound",
172
+ command,
173
+ `${selected.message} This host refuses to spawn unconfined.`,
174
+ selected
175
+ )
176
+ }
177
+ yield* Effect.logWarning(`${selected.message} Running unconfined.`)
178
+ return command
179
+ }
180
+ // The stage's directory is absolute: the kernel spawner roots it first.
181
+ const cwd = command.options.cwd ?? profile.workspaceRoot
182
+ const within = (root: string, path: string): boolean => {
183
+ const relative = NodePath.relative(root, path)
184
+ return relative !== ".." && !relative.startsWith(`..${NodePath.sep}`) && !NodePath.isAbsolute(relative)
185
+ }
186
+ if (!within(profile.workspaceRoot, cwd)) {
187
+ return yield* failure("PermissionDenied", command, "command directory is outside the workspace", undefined)
188
+ }
189
+ // A lexical workspace path can enter an unrelated host directory through
190
+ // a symlink. Check the real directory before granting or preparing a run.
191
+ const canonical = yield* Effect.try({
192
+ try: () => {
193
+ const root = NodeFs.realpathSync(profile.workspaceRoot)
194
+ const directory = NodeFs.realpathSync(cwd)
195
+ if (!within(root, directory)) throw new Error("command directory is outside the workspace")
196
+ for (const relative of profile.reads) {
197
+ const lexical = NodePath.resolve(root, relative)
198
+ if (!within(root, lexical)) continue
199
+ // A read bind follows its source symlink. Refuse a grant that would
200
+ // therefore mount unrelated host bytes inside the workspace.
201
+ if (NodeFs.existsSync(lexical)) {
202
+ const real = NodeFs.realpathSync(lexical)
203
+ if (!within(root, real)) throw new Error("read grant resolves outside the workspace")
204
+ if (real !== lexical) throw new Error("read grant is a symbolic link")
205
+ }
206
+ }
207
+ return { root, cwd: directory }
208
+ },
209
+ catch: (cause) => failure("PermissionDenied", command, messageOf(cause), cause)
210
+ })
211
+ // The private tmp lives as long as the spawn's scope, however preparation
212
+ // ends; the declared write directories are created so the mechanism has
213
+ // something to bind, which the grant that opened them already permits.
214
+ const allocatedTmp = yield* Effect.acquireRelease(
215
+ Effect.try({
216
+ try: () => NodeFs.mkdtempSync(NodePath.join(temporaryRoot, "smithers-confinement-")),
217
+ catch: (cause) => failure("Unknown", command, `could not prepare the confinement: ${messageOf(cause)}`, cause)
218
+ }),
219
+ (directory) =>
220
+ Effect.sync(() => {
221
+ try {
222
+ NodeFs.rmSync(directory, { recursive: true, force: true })
223
+ } catch {
224
+ // Cleanup is best-effort when the host refuses directory removal.
225
+ }
226
+ })
227
+ )
228
+ const tmp = yield* Effect.try({
229
+ try: () => NodeFs.realpathSync(allocatedTmp),
230
+ catch: (cause) => failure("Unknown", command, `could not prepare the confinement: ${messageOf(cause)}`, cause)
231
+ })
232
+ const planned = yield* Effect.try({
233
+ try: () => ProcessSandbox.plan(request, { workspaceRoot: canonical.root, cwd: canonical.cwd, tmp }, hostFacts),
234
+ catch: (cause) => failure("Unknown", command, `could not plan the confinement: ${messageOf(cause)}`, cause)
235
+ })
236
+ if (ProcessSandbox.isUnenforceable(planned)) {
237
+ return yield* failure("PermissionDenied", command, planned.message, planned)
238
+ }
239
+ // Build outputs may grant their parent directory. An agent grant must
240
+ // never inherit that widening when a requested tree is already a file.
241
+ const exactWrites = profile.writes.map((relative) => NodePath.resolve(planned.workspaceRoot, relative))
242
+ if (planned.writes.some((write) => !exactWrites.includes(write))) {
243
+ return yield* failure("PermissionDenied", command, "write grant is not a directory tree", undefined)
244
+ }
245
+ // A workspace link does not grant authority to its target on the host.
246
+ const confinement: ProcessSandbox.Plan = { ...planned, externalReads: [] }
247
+ yield* Effect.try({
248
+ try: () => {
249
+ ProcessSandbox.validateWrites(confinement, hostFacts)
250
+ NodeFs.mkdirSync(NodePath.join(tmp, "home"), { recursive: true })
251
+ NodeFs.mkdirSync(NodePath.join(tmp, "cache"), { recursive: true })
252
+ for (const write of planned.writes) NodeFs.mkdirSync(write, { recursive: true })
253
+ },
254
+ catch: (cause) => failure("Unknown", command, `could not prepare the confinement: ${messageOf(cause)}`, cause)
255
+ })
256
+ // Only the target receives its requested environment. Dynamic-loader and
257
+ // other startup variables must never configure the host sandbox launcher.
258
+ const targetEnvironment: Record<string, string> = {}
259
+ const inherited = command.options.env === undefined || command.options.extendEnv === true
260
+ for (const [name, value] of Object.entries(inherited ? process.env : {})) {
261
+ // Bash exports functions as names such as BASH_FUNC_which%%. These
262
+ // ambient entries cannot be exported by the portable inner launcher.
263
+ if (typeof value === "string" && /^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) targetEnvironment[name] = value
264
+ }
265
+ for (const [name, value] of Object.entries(command.options.env ?? {})) {
266
+ if (typeof value === "string") targetEnvironment[name] = value
267
+ else delete targetEnvironment[name]
268
+ }
269
+ const privateEnvironment = ProcessSandbox.environment(confinement)
270
+ const script = yield* Effect.try({
271
+ try: () => {
272
+ const quote = (value: string): string => `'${value.replaceAll("'", "'\\''")}'`
273
+ const exports: Array<string> = []
274
+ for (const [name, value] of Object.entries({ ...targetEnvironment, ...privateEnvironment })) {
275
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) throw new Error("environment variable name is not portable")
276
+ if (value.includes("\0")) throw new Error("environment variable contains a null byte")
277
+ exports.push(`export ${name}=${quote(value)}`)
278
+ }
279
+ const file = NodePath.join(tmp, "environment.sh")
280
+ // Values stay off argv and journal receipts; the script is private,
281
+ // removed with the scope, and interpreted only inside confinement.
282
+ NodeFs.writeFileSync(
283
+ file,
284
+ [
285
+ "#!/bin/sh",
286
+ "unset ENV BASH_ENV CDPATH PWD OLDPWD SHLVL _",
287
+ ...exports,
288
+ "exec \"$@\"",
289
+ ""
290
+ ].join("\n"),
291
+ { flag: "wx", mode: 0o600 }
292
+ )
293
+ return file
294
+ },
295
+ catch: (cause) => failure("PermissionDenied", command, messageOf(cause), cause)
296
+ })
297
+ // Resolve the actual program before wrapping it in the environment shell.
298
+ // Otherwise the sandbox sees only /usr/bin/env and omits a native helper
299
+ // installed outside its ordinary runtime paths.
300
+ const originalArgv = argvOf(command)
301
+ const launch = ProcessSandbox.launcher(
302
+ originalArgv[0]!, targetEnvironment.PATH,
303
+ [...confinement.reads, ...confinement.writes, ...confinement.externalReads],
304
+ confinement.workspaceRoot, hostFacts
305
+ )
306
+ const targetArgv = ["/usr/bin/env", "-i", "/bin/sh", script, launch.program, ...originalArgv.slice(1)]
307
+ const wrapped = yield* Effect.try({
308
+ try: () =>
309
+ ProcessSandbox.wrap({ ...confinement, externalReads: [...confinement.externalReads, ...launch.reads, script] }, targetArgv, targetEnvironment, hostFacts),
310
+ catch: (cause) => failure("Unknown", command, `could not render the confinement: ${messageOf(cause)}`, cause)
311
+ })
312
+ let [executable, ...args] = wrapped.argv
313
+ if (selected._tag === "bubblewrap") {
314
+ const filter = yield* Effect.try({
315
+ try: () => {
316
+ const file = NodePath.join(tmp, "network.seccomp")
317
+ NodeFs.writeFileSync(file, networkFilter(process.arch, profile.network), { flag: "wx", mode: 0o600 })
318
+ return file
319
+ },
320
+ catch: (cause) => failure("PermissionDenied", command, messageOf(cause), cause)
321
+ })
322
+ let fd = 3
323
+ while (command.options.additionalFds?.[`fd${fd}`] !== undefined) fd++
324
+ // A regular file avoids a filter-input pipe whose early closure can
325
+ // surface as an unhandled ECONNRESET before bwrap reports its refusal.
326
+ args = [
327
+ "-c",
328
+ `exec ${fd}<"$1"; shift; exec "$@"`,
329
+ "smithers-seccomp",
330
+ filter,
331
+ executable!,
332
+ "--seccomp",
333
+ String(fd),
334
+ ...args
335
+ ]
336
+ executable = "/bin/sh"
337
+ }
338
+ return ChildProcess.make(executable!, args, {
339
+ ...command.options,
340
+ cwd: canonical.cwd,
341
+ shell: false,
342
+ env: { PATH: "/usr/bin:/bin:/usr/sbin:/sbin", LANG: "C", ...privateEnvironment },
343
+ extendEnv: false
344
+ })
345
+ })
346
+ return KernelProcessConfinement.ProcessConfinement.of({ confine })
347
+ }
348
+
349
+ /**
350
+ * Provides the native confinement.
351
+ *
352
+ * @category layers
353
+ * @since 1.0.0-rc.1
354
+ */
355
+ export const layer = (options: Options = {}): Layer.Layer<KernelProcessConfinement.ProcessConfinement> =>
356
+ Layer.succeed(KernelProcessConfinement.ProcessConfinement)(make(options))