@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.
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 +292 -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 +391 -0
  34. package/dist/cjs/ProcessSandbox.d.ts.map +1 -0
  35. package/dist/cjs/ProcessSandbox.js +774 -0
  36. package/dist/cjs/ProcessSandbox.js.map +7 -0
  37. package/dist/cjs/ScopedProcess.d.ts +66 -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 +143 -0
  86. package/dist/cjs/internal/ProcessSupervisor.d.ts.map +1 -0
  87. package/dist/cjs/internal/ProcessSupervisor.js +685 -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 +326 -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 +391 -0
  123. package/dist/esm/ProcessSandbox.d.ts.map +1 -0
  124. package/dist/esm/ProcessSandbox.js +1043 -0
  125. package/dist/esm/ProcessSandbox.js.map +1 -0
  126. package/dist/esm/ScopedProcess.d.ts +66 -0
  127. package/dist/esm/ScopedProcess.d.ts.map +1 -0
  128. package/dist/esm/ScopedProcess.js +67 -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 +143 -0
  175. package/dist/esm/internal/ProcessSupervisor.d.ts.map +1 -0
  176. package/dist/esm/internal/ProcessSupervisor.js +689 -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 +310 -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 +553 -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 +190 -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 +363 -0
  426. package/src/ProcessReaper.ts +951 -0
  427. package/src/ProcessSandbox.ts +1307 -0
  428. package/src/ScopedProcess.ts +124 -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 +807 -0
  441. package/src/internal/SupervisorProgram.ts +309 -0
  442. package/src/internal/WindowsProcessJob.ts +114 -0
@@ -0,0 +1,311 @@
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
+ import * as KernelProcessConfinement from "@smthrs/kernel/ProcessConfinement";
26
+ import * as Effect from "effect/Effect";
27
+ import * as Layer from "effect/Layer";
28
+ import * as PlatformError from "effect/PlatformError";
29
+ import * as ChildProcess from "effect/unstable/process/ChildProcess";
30
+ import * as NodeFs from "node:fs";
31
+ import * as NodeOs from "node:os";
32
+ import * as NodePath from "node:path";
33
+ import * as ProcessSandbox from "./ProcessSandbox.js";
34
+ const shellLine = (command) => [command.command, ...command.args].join(" ");
35
+ /**
36
+ * The argv a stage executes, with a shell request made explicit.
37
+ *
38
+ * Node runs a `shell: true` stage as `/bin/sh -c <line>` on POSIX, and a
39
+ * string shell as `<shell> -c <line>`; the wrapper needs that program to be
40
+ * the one it confines, so the shell becomes the argv's first token and the
41
+ * spawned stage no longer asks for one.
42
+ */
43
+ const argvOf = (command) => {
44
+ const shell = command.options.shell;
45
+ if (shell === undefined || shell === false)
46
+ return [command.command, ...command.args];
47
+ return [shell === true ? "/bin/sh" : shell, "-c", shellLine(command)];
48
+ };
49
+ const failure = (tag, command, description, cause) => PlatformError.systemError({
50
+ _tag: tag,
51
+ module: "ProcessConfinement",
52
+ method: "confine",
53
+ pathOrDescriptor: shellLine(command),
54
+ description,
55
+ cause
56
+ });
57
+ const messageOf = (cause) => ProcessSandbox.isUnenforceable(cause)
58
+ ? cause.message
59
+ : cause instanceof Error
60
+ ? cause.message
61
+ : String(cause);
62
+ /** Classic BPF for seccomp_data: deny host Unix sockets and io_uring, preserving stream socketpair.
63
+ * Closed networking additionally denies every IP socket family.
64
+ * Wrong ABI and x32 syscall encodings fail closed rather than bypassing socket(). */
65
+ const networkFilter = (architecture, network) => {
66
+ const abi = architecture === "x64"
67
+ ? { audit: 0xc000003e, socket: 41, socketpair: 53 }
68
+ : architecture === "arm64"
69
+ ? { audit: 0xc00000b7, socket: 198, socketpair: 199 }
70
+ : undefined;
71
+ if (abi === undefined)
72
+ throw new Error(`native-network seccomp is unavailable on ${architecture}`);
73
+ const instructions = [
74
+ [0x20, 0, 0, 4], // load audit architecture
75
+ [0x15, 1, 0, abi.audit],
76
+ [0x06, 0, 0, 0x80000000], // kill unsupported ABI
77
+ [0x20, 0, 0, 0], // load syscall number
78
+ [0x35, 0, 1, 0x40000000],
79
+ [0x06, 0, 0, 0x80000000], // kill x32 / invalid high syscall numbers
80
+ [0x15, 0, 1, 425], // io_uring_setup on both supported ABIs
81
+ [0x06, 0, 0, 0x00050001], // io_uring can otherwise create sockets without socket()
82
+ [0x15, 0, 6, abi.socketpair],
83
+ [0x20, 0, 0, 16], // socketpair domain
84
+ [0x15, 0, 4, 1], // AF_UNIX
85
+ [0x20, 0, 0, 24], // socketpair type, low 32 bits of args[1]
86
+ [0x54, 0, 0, 0xf], // strip SOCK_NONBLOCK and SOCK_CLOEXEC
87
+ [0x15, 1, 0, 1], // only SOCK_STREAM; Linux aliases SOCK_RAW to datagram operations
88
+ [0x06, 0, 0, 0x00050001],
89
+ [0x20, 0, 0, 0] // reload syscall number before the socket() policy
90
+ ];
91
+ if (network === "none") {
92
+ instructions.push([0x15, 0, 1, abi.socket], [0x06, 0, 0, 0x00050001]); // EPERM for every socket family
93
+ }
94
+ else {
95
+ instructions.push([0x15, 0, 3, abi.socket], [0x20, 0, 0, 16], // socket domain, low 32 bits of args[0]
96
+ [0x15, 0, 1, 1], // AF_UNIX; IP families remain available
97
+ [0x06, 0, 0, 0x00050001]);
98
+ }
99
+ instructions.push([0x06, 0, 0, 0x7fff0000]); // SECCOMP_RET_ALLOW
100
+ const bytes = new Uint8Array(instructions.length * 8);
101
+ const view = new DataView(bytes.buffer);
102
+ for (const [index, [code, jt, jf, value]] of instructions.entries()) {
103
+ view.setUint16(index * 8, code, true);
104
+ view.setUint8(index * 8 + 2, jt);
105
+ view.setUint8(index * 8 + 3, jf);
106
+ view.setUint32(index * 8 + 4, value, true);
107
+ }
108
+ return bytes;
109
+ };
110
+ /**
111
+ * Builds the native confinement.
112
+ *
113
+ * @category constructors
114
+ * @since 1.0.0-rc.1
115
+ */
116
+ export const make = (options = {}) => {
117
+ const hostFacts = options.host ?? ProcessSandbox.host();
118
+ const temporaryRoot = options.temporaryDirectory ?? NodeOs.tmpdir();
119
+ const unavailable = options.unavailable ?? "refuse";
120
+ const confine = Effect.fn("ProcessConfinement.confine")(function* (command, profile) {
121
+ const request = {
122
+ network: profile.network,
123
+ unixSockets: false,
124
+ strict: true,
125
+ reads: profile.reads,
126
+ writes: profile.writes,
127
+ readOnly: profile.readOnly
128
+ };
129
+ const selected = ProcessSandbox.select(request, hostFacts);
130
+ if (ProcessSandbox.isUnenforceable(selected)) {
131
+ if (unavailable === "refuse") {
132
+ return yield* failure("NotFound", command, `${selected.message} This host refuses to spawn unconfined.`, selected);
133
+ }
134
+ yield* Effect.logWarning(`${selected.message} Running unconfined.`);
135
+ return command;
136
+ }
137
+ // The stage's directory is absolute: the kernel spawner roots it first.
138
+ const cwd = command.options.cwd ?? profile.workspaceRoot;
139
+ const within = (root, path) => {
140
+ const relative = NodePath.relative(root, path);
141
+ return relative !== ".." && !relative.startsWith(`..${NodePath.sep}`) && !NodePath.isAbsolute(relative);
142
+ };
143
+ if (!within(profile.workspaceRoot, cwd)) {
144
+ return yield* failure("PermissionDenied", command, "command directory is outside the workspace", undefined);
145
+ }
146
+ // A lexical workspace path can enter an unrelated host directory through
147
+ // a symlink. Check the real directory before granting or preparing a run.
148
+ const canonical = yield* Effect.try({
149
+ try: () => {
150
+ const root = NodeFs.realpathSync(profile.workspaceRoot);
151
+ const directory = NodeFs.realpathSync(cwd);
152
+ if (!within(root, directory))
153
+ throw new Error("command directory is outside the workspace");
154
+ for (const relative of profile.reads) {
155
+ const lexical = NodePath.resolve(root, relative);
156
+ if (!within(root, lexical))
157
+ continue;
158
+ // A read bind follows its source symlink. Refuse a grant that would
159
+ // therefore mount unrelated host bytes inside the workspace.
160
+ if (NodeFs.existsSync(lexical)) {
161
+ const real = NodeFs.realpathSync(lexical);
162
+ if (!within(root, real))
163
+ throw new Error("read grant resolves outside the workspace");
164
+ if (real !== lexical)
165
+ throw new Error("read grant is a symbolic link");
166
+ }
167
+ }
168
+ return { root, cwd: directory };
169
+ },
170
+ catch: (cause) => failure("PermissionDenied", command, messageOf(cause), cause)
171
+ });
172
+ // The private tmp lives as long as the spawn's scope, however preparation
173
+ // ends; the declared write directories are created so the mechanism has
174
+ // something to bind, which the grant that opened them already permits.
175
+ const allocatedTmp = yield* Effect.acquireRelease(Effect.try({
176
+ try: () => NodeFs.mkdtempSync(NodePath.join(temporaryRoot, "smithers-confinement-")),
177
+ catch: (cause) => failure("Unknown", command, `could not prepare the confinement: ${messageOf(cause)}`, cause)
178
+ }), (directory) => Effect.sync(() => {
179
+ try {
180
+ NodeFs.rmSync(directory, { recursive: true, force: true });
181
+ }
182
+ catch {
183
+ // Cleanup is best-effort when the host refuses directory removal.
184
+ }
185
+ }));
186
+ const tmp = yield* Effect.try({
187
+ try: () => NodeFs.realpathSync(allocatedTmp),
188
+ catch: (cause) => failure("Unknown", command, `could not prepare the confinement: ${messageOf(cause)}`, cause)
189
+ });
190
+ const planned = yield* Effect.try({
191
+ try: () => ProcessSandbox.plan(request, { workspaceRoot: canonical.root, cwd: canonical.cwd, tmp }, hostFacts),
192
+ catch: (cause) => failure("Unknown", command, `could not plan the confinement: ${messageOf(cause)}`, cause)
193
+ });
194
+ if (ProcessSandbox.isUnenforceable(planned)) {
195
+ return yield* failure("PermissionDenied", command, planned.message, planned);
196
+ }
197
+ // Build outputs may grant their parent directory. An agent grant must
198
+ // never inherit that widening when a requested tree is already a file.
199
+ const exactWrites = profile.writes.map((relative) => NodePath.resolve(planned.workspaceRoot, relative));
200
+ if (planned.writes.some((write) => !exactWrites.includes(write))) {
201
+ return yield* failure("PermissionDenied", command, "write grant is not a directory tree", undefined);
202
+ }
203
+ // A workspace link does not grant authority to its target on the host.
204
+ const confinement = { ...planned, externalReads: [] };
205
+ yield* Effect.try({
206
+ try: () => {
207
+ ProcessSandbox.validateWrites(confinement, hostFacts);
208
+ NodeFs.mkdirSync(NodePath.join(tmp, "home"), { recursive: true });
209
+ NodeFs.mkdirSync(NodePath.join(tmp, "cache"), { recursive: true });
210
+ for (const write of planned.writes)
211
+ NodeFs.mkdirSync(write, { recursive: true });
212
+ },
213
+ catch: (cause) => failure("Unknown", command, `could not prepare the confinement: ${messageOf(cause)}`, cause)
214
+ });
215
+ // Only the target receives its requested environment. Dynamic-loader and
216
+ // other startup variables must never configure the host sandbox launcher.
217
+ const targetEnvironment = {};
218
+ const inherited = command.options.env === undefined || command.options.extendEnv === true;
219
+ for (const [name, value] of Object.entries(inherited ? process.env : {})) {
220
+ // Bash exports functions as names such as BASH_FUNC_which%%. These
221
+ // ambient entries cannot be exported by the portable inner launcher.
222
+ if (typeof value === "string" && /^[A-Za-z_][A-Za-z0-9_]*$/.test(name))
223
+ targetEnvironment[name] = value;
224
+ }
225
+ for (const [name, value] of Object.entries(command.options.env ?? {})) {
226
+ if (typeof value === "string")
227
+ targetEnvironment[name] = value;
228
+ else
229
+ delete targetEnvironment[name];
230
+ }
231
+ const privateEnvironment = ProcessSandbox.environment(confinement);
232
+ const script = yield* Effect.try({
233
+ try: () => {
234
+ const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
235
+ const exports = [];
236
+ for (const [name, value] of Object.entries({ ...targetEnvironment, ...privateEnvironment })) {
237
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name))
238
+ throw new Error("environment variable name is not portable");
239
+ if (value.includes("\0"))
240
+ throw new Error("environment variable contains a null byte");
241
+ exports.push(`export ${name}=${quote(value)}`);
242
+ }
243
+ const file = NodePath.join(tmp, "environment.sh");
244
+ // Values stay off argv and journal receipts; the script is private,
245
+ // removed with the scope, and interpreted only inside confinement.
246
+ NodeFs.writeFileSync(file, [
247
+ "#!/bin/sh",
248
+ "unset ENV BASH_ENV CDPATH PWD OLDPWD SHLVL _",
249
+ ...exports,
250
+ "exec \"$@\"",
251
+ ""
252
+ ].join("\n"), { flag: "wx", mode: 0o600 });
253
+ return file;
254
+ },
255
+ catch: (cause) => failure("PermissionDenied", command, messageOf(cause), cause)
256
+ });
257
+ // Resolve the actual program before wrapping it in the environment shell.
258
+ // Otherwise the sandbox sees only /usr/bin/env and omits a native helper
259
+ // installed outside its ordinary runtime paths.
260
+ const originalArgv = argvOf(command);
261
+ const launch = ProcessSandbox.launcher(originalArgv[0], targetEnvironment.PATH, [...confinement.reads, ...confinement.writes, ...confinement.externalReads], confinement.workspaceRoot, hostFacts);
262
+ const targetArgv = ["/usr/bin/env", "-i", "/bin/sh", script, launch.program, ...originalArgv.slice(1)];
263
+ const wrapped = yield* Effect.try({
264
+ try: () => ProcessSandbox.wrap({ ...confinement, externalReads: [...confinement.externalReads, ...launch.reads, script] }, targetArgv, targetEnvironment, hostFacts),
265
+ catch: (cause) => failure("Unknown", command, `could not render the confinement: ${messageOf(cause)}`, cause)
266
+ });
267
+ let [executable, ...args] = wrapped.argv;
268
+ if (selected._tag === "bubblewrap") {
269
+ const filter = yield* Effect.try({
270
+ try: () => {
271
+ const file = NodePath.join(tmp, "network.seccomp");
272
+ NodeFs.writeFileSync(file, networkFilter(process.arch, profile.network), { flag: "wx", mode: 0o600 });
273
+ return file;
274
+ },
275
+ catch: (cause) => failure("PermissionDenied", command, messageOf(cause), cause)
276
+ });
277
+ let fd = 3;
278
+ while (command.options.additionalFds?.[`fd${fd}`] !== undefined)
279
+ fd++;
280
+ // A regular file avoids a filter-input pipe whose early closure can
281
+ // surface as an unhandled ECONNRESET before bwrap reports its refusal.
282
+ args = [
283
+ "-c",
284
+ `exec ${fd}<"$1"; shift; exec "$@"`,
285
+ "smithers-seccomp",
286
+ filter,
287
+ executable,
288
+ "--seccomp",
289
+ String(fd),
290
+ ...args
291
+ ];
292
+ executable = "/bin/sh";
293
+ }
294
+ return ChildProcess.make(executable, args, {
295
+ ...command.options,
296
+ cwd: canonical.cwd,
297
+ shell: false,
298
+ env: { PATH: "/usr/bin:/bin:/usr/sbin:/sbin", LANG: "C", ...privateEnvironment },
299
+ extendEnv: false
300
+ });
301
+ });
302
+ return KernelProcessConfinement.ProcessConfinement.of({ confine });
303
+ };
304
+ /**
305
+ * Provides the native confinement.
306
+ *
307
+ * @category layers
308
+ * @since 1.0.0-rc.1
309
+ */
310
+ export const layer = (options = {}) => Layer.succeed(KernelProcessConfinement.ProcessConfinement)(make(options));
311
+ //# sourceMappingURL=ProcessConfinement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProcessConfinement.js","sourceRoot":"","sources":["../../src/ProcessConfinement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,wBAAwB,MAAM,mCAAmC,CAAA;AAC7E,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,aAAa,MAAM,sBAAsB,CAAA;AAErD,OAAO,KAAK,YAAY,MAAM,sCAAsC,CAAA;AACpE,OAAO,KAAK,MAAM,MAAM,SAAS,CAAA;AACjC,OAAO,KAAK,MAAM,MAAM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A;gBACb,CAAC;gBACD,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,kBAAkB,EAAE,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;aAChF,CAAC,CAAA;YACF,IAAI,EAAE,GAAG,CAAC,CAAA;YACV,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,SAAS;gBAAE,EAAE,EAAE,CAAA;YACrE,oEAAoE;YACpE,uEAAuE;YACvE,IAAI,GAAG;gBACL,IAAI;gBACJ,QAAQ,EAAE,yBAAyB;gBACnC,kBAAkB;gBAClB,MAAM;gBACN,UAAW;gBACX,WAAW;gBACX,MAAM,CAAC,EAAE,CAAC;gBACV,GAAG,IAAI;aACR,CAAA;YACD,UAAU,GAAG,SAAS,CAAA;QACxB,CAAC;QACD,OAAO,YAAY,CAAC,IAAI,CAAC,UAAW,EAAE,IAAI,EAAE;YAC1C,GAAG,OAAO,CAAC,OAAO;YAClB,GAAG,EAAE,SAAS,CAAC,GAAG;YAClB,KAAK,EAAE,KAAK;YACZ,GAAG,EAAE,EAAE,IAAI,EAAE,+BAA+B,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,kBAAkB,EAAE;YAChF,SAAS,EAAE,KAAK;SACjB,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IACF,OAAO,wBAAwB,CAAC,kBAAkB,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;AACpE,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,UAAmB,EAAE,EAA4D,EAAE,CACvG,KAAK,CAAC,OAAO,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA","sourcesContent":["/**\n * The kernel's `ProcessConfinement` seam, filled with this host's native\n * sandbox: bubblewrap on Linux, seatbelt on macOS.\n *\n * `@smthrs/kernel`'s `ChildProcessSpawner.layer` hands every stage that passed\n * its `proc:spawn` check to the confinement in its context, together with the\n * `ProcessConfinement.Profile` the grants in force admit. This module turns\n * that profile into a {@link ProcessSandbox.Request}, plans it against the\n * workspace, and wraps the stage's argv in the mechanism the host has, so an\n * approved `bash` can write only where an `fs:write` grant says and reach the\n * network only when a `net:*` grant says. A stage that asked for the platform\n * shell is spelled out as `/bin/sh -c <line>` first: wrapping a `shell: true`\n * command line would otherwise leave its redirections and pipes to a shell\n * outside the sandbox.\n *\n * A host with no mechanism is the one decision this module leaves to its\n * caller: {@link Options.unavailable} either refuses the spawn, so nothing\n * runs that the profile would not have confined, or runs it unconfined with\n * a warning, the way every host did before this seam existed. A write set\n * the mechanism cannot enforce safely, a symbolic link below the workspace\n * root, is always refused.\n *\n * @since 1.0.0-rc.1\n */\n\nimport * as KernelProcessConfinement from \"@smthrs/kernel/ProcessConfinement\"\nimport * as Effect from \"effect/Effect\"\nimport * as Layer from \"effect/Layer\"\nimport * as PlatformError from \"effect/PlatformError\"\nimport type * as Scope from \"effect/Scope\"\nimport * as ChildProcess from \"effect/unstable/process/ChildProcess\"\nimport * as NodeFs from \"node:fs\"\nimport * as NodeOs from \"node:os\"\nimport * as NodePath from \"node:path\"\nimport * as ProcessSandbox from \"./ProcessSandbox.ts\"\n\n/**\n * How the confinement is built.\n *\n * @category models\n * @since 1.0.0-rc.1\n */\nexport interface Options {\n /**\n * What happens when this host has no mechanism to enforce a profile with.\n * `\"refuse\"` fails the spawn, so a command never runs with more than the\n * profile allows; `\"unconfined\"` runs it as given and logs a\n * warning naming what the host lacks.\n */\n readonly unavailable?: \"refuse\" | \"unconfined\" | undefined\n /** The host facts mechanism selection reads; defaults to the real host. */\n readonly host?: ProcessSandbox.Host | undefined\n /** Where each run's private temporary directory is created; defaults to the OS temporary directory. */\n readonly temporaryDirectory?: string | undefined\n}\n\nconst shellLine = (command: ChildProcess.StandardCommand): string => [command.command, ...command.args].join(\" \")\n\n/**\n * The argv a stage executes, with a shell request made explicit.\n *\n * Node runs a `shell: true` stage as `/bin/sh -c <line>` on POSIX, and a\n * string shell as `<shell> -c <line>`; the wrapper needs that program to be\n * the one it confines, so the shell becomes the argv's first token and the\n * spawned stage no longer asks for one.\n */\nconst argvOf = (command: ChildProcess.StandardCommand): ReadonlyArray<string> => {\n const shell = command.options.shell\n if (shell === undefined || shell === false) return [command.command, ...command.args]\n return [shell === true ? \"/bin/sh\" : shell, \"-c\", shellLine(command)]\n}\n\nconst failure = (\n tag: \"NotFound\" | \"PermissionDenied\" | \"Unknown\",\n command: ChildProcess.StandardCommand,\n description: string,\n cause: unknown\n): PlatformError.PlatformError =>\n PlatformError.systemError({\n _tag: tag,\n module: \"ProcessConfinement\",\n method: \"confine\",\n pathOrDescriptor: shellLine(command),\n description,\n cause\n })\n\nconst messageOf = (cause: unknown): string =>\n ProcessSandbox.isUnenforceable(cause)\n ? cause.message\n : cause instanceof Error\n ? cause.message\n : String(cause)\n\n/** Classic BPF for seccomp_data: deny host Unix sockets and io_uring, preserving stream socketpair.\n * Closed networking additionally denies every IP socket family.\n * Wrong ABI and x32 syscall encodings fail closed rather than bypassing socket(). */\nconst networkFilter = (architecture: string, network: \"none\" | \"open\"): Uint8Array => {\n const abi = architecture === \"x64\"\n ? { audit: 0xc000003e, socket: 41, socketpair: 53 }\n : architecture === \"arm64\"\n ? { audit: 0xc00000b7, socket: 198, socketpair: 199 }\n : undefined\n if (abi === undefined) throw new Error(`native-network seccomp is unavailable on ${architecture}`)\n const instructions: Array<readonly [number, number, number, number]> = [\n [0x20, 0, 0, 4], // load audit architecture\n [0x15, 1, 0, abi.audit],\n [0x06, 0, 0, 0x80000000], // kill unsupported ABI\n [0x20, 0, 0, 0], // load syscall number\n [0x35, 0, 1, 0x40000000],\n [0x06, 0, 0, 0x80000000], // kill x32 / invalid high syscall numbers\n [0x15, 0, 1, 425], // io_uring_setup on both supported ABIs\n [0x06, 0, 0, 0x00050001], // io_uring can otherwise create sockets without socket()\n [0x15, 0, 6, abi.socketpair],\n [0x20, 0, 0, 16], // socketpair domain\n [0x15, 0, 4, 1], // AF_UNIX\n [0x20, 0, 0, 24], // socketpair type, low 32 bits of args[1]\n [0x54, 0, 0, 0xf], // strip SOCK_NONBLOCK and SOCK_CLOEXEC\n [0x15, 1, 0, 1], // only SOCK_STREAM; Linux aliases SOCK_RAW to datagram operations\n [0x06, 0, 0, 0x00050001],\n [0x20, 0, 0, 0] // reload syscall number before the socket() policy\n ]\n if (network === \"none\") {\n instructions.push([0x15, 0, 1, abi.socket], [0x06, 0, 0, 0x00050001]) // EPERM for every socket family\n } else {\n instructions.push(\n [0x15, 0, 3, abi.socket],\n [0x20, 0, 0, 16], // socket domain, low 32 bits of args[0]\n [0x15, 0, 1, 1], // AF_UNIX; IP families remain available\n [0x06, 0, 0, 0x00050001]\n )\n }\n instructions.push([0x06, 0, 0, 0x7fff0000]) // SECCOMP_RET_ALLOW\n const bytes = new Uint8Array(instructions.length * 8)\n const view = new DataView(bytes.buffer)\n for (const [index, [code, jt, jf, value]] of instructions.entries()) {\n view.setUint16(index * 8, code, true)\n view.setUint8(index * 8 + 2, jt)\n view.setUint8(index * 8 + 3, jf)\n view.setUint32(index * 8 + 4, value, true)\n }\n return bytes\n}\n\n/**\n * Builds the native confinement.\n *\n * @category constructors\n * @since 1.0.0-rc.1\n */\nexport const make = (options: Options = {}): KernelProcessConfinement.Service => {\n const hostFacts = options.host ?? ProcessSandbox.host()\n const temporaryRoot = options.temporaryDirectory ?? NodeOs.tmpdir()\n const unavailable = options.unavailable ?? \"refuse\"\n const confine = Effect.fn(\"ProcessConfinement.confine\")(function*(\n command: ChildProcess.StandardCommand,\n profile: KernelProcessConfinement.Profile\n ): Effect.fn.Return<ChildProcess.StandardCommand, PlatformError.PlatformError, Scope.Scope> {\n const request: ProcessSandbox.Request = {\n network: profile.network,\n unixSockets: false,\n strict: true,\n reads: profile.reads,\n writes: profile.writes,\n readOnly: profile.readOnly\n }\n const selected = ProcessSandbox.select(request, hostFacts)\n if (ProcessSandbox.isUnenforceable(selected)) {\n if (unavailable === \"refuse\") {\n return yield* failure(\n \"NotFound\",\n command,\n `${selected.message} This host refuses to spawn unconfined.`,\n selected\n )\n }\n yield* Effect.logWarning(`${selected.message} Running unconfined.`)\n return command\n }\n // The stage's directory is absolute: the kernel spawner roots it first.\n const cwd = command.options.cwd ?? profile.workspaceRoot\n const within = (root: string, path: string): boolean => {\n const relative = NodePath.relative(root, path)\n return relative !== \"..\" && !relative.startsWith(`..${NodePath.sep}`) && !NodePath.isAbsolute(relative)\n }\n if (!within(profile.workspaceRoot, cwd)) {\n return yield* failure(\"PermissionDenied\", command, \"command directory is outside the workspace\", undefined)\n }\n // A lexical workspace path can enter an unrelated host directory through\n // a symlink. Check the real directory before granting or preparing a run.\n const canonical = yield* Effect.try({\n try: () => {\n const root = NodeFs.realpathSync(profile.workspaceRoot)\n const directory = NodeFs.realpathSync(cwd)\n if (!within(root, directory)) throw new Error(\"command directory is outside the workspace\")\n for (const relative of profile.reads) {\n const lexical = NodePath.resolve(root, relative)\n if (!within(root, lexical)) continue\n // A read bind follows its source symlink. Refuse a grant that would\n // therefore mount unrelated host bytes inside the workspace.\n if (NodeFs.existsSync(lexical)) {\n const real = NodeFs.realpathSync(lexical)\n if (!within(root, real)) throw new Error(\"read grant resolves outside the workspace\")\n if (real !== lexical) throw new Error(\"read grant is a symbolic link\")\n }\n }\n return { root, cwd: directory }\n },\n catch: (cause) => failure(\"PermissionDenied\", command, messageOf(cause), cause)\n })\n // The private tmp lives as long as the spawn's scope, however preparation\n // ends; the declared write directories are created so the mechanism has\n // something to bind, which the grant that opened them already permits.\n const allocatedTmp = yield* Effect.acquireRelease(\n Effect.try({\n try: () => NodeFs.mkdtempSync(NodePath.join(temporaryRoot, \"smithers-confinement-\")),\n catch: (cause) => failure(\"Unknown\", command, `could not prepare the confinement: ${messageOf(cause)}`, cause)\n }),\n (directory) =>\n Effect.sync(() => {\n try {\n NodeFs.rmSync(directory, { recursive: true, force: true })\n } catch {\n // Cleanup is best-effort when the host refuses directory removal.\n }\n })\n )\n const tmp = yield* Effect.try({\n try: () => NodeFs.realpathSync(allocatedTmp),\n catch: (cause) => failure(\"Unknown\", command, `could not prepare the confinement: ${messageOf(cause)}`, cause)\n })\n const planned = yield* Effect.try({\n try: () => ProcessSandbox.plan(request, { workspaceRoot: canonical.root, cwd: canonical.cwd, tmp }, hostFacts),\n catch: (cause) => failure(\"Unknown\", command, `could not plan the confinement: ${messageOf(cause)}`, cause)\n })\n if (ProcessSandbox.isUnenforceable(planned)) {\n return yield* failure(\"PermissionDenied\", command, planned.message, planned)\n }\n // Build outputs may grant their parent directory. An agent grant must\n // never inherit that widening when a requested tree is already a file.\n const exactWrites = profile.writes.map((relative) => NodePath.resolve(planned.workspaceRoot, relative))\n if (planned.writes.some((write) => !exactWrites.includes(write))) {\n return yield* failure(\"PermissionDenied\", command, \"write grant is not a directory tree\", undefined)\n }\n // A workspace link does not grant authority to its target on the host.\n const confinement: ProcessSandbox.Plan = { ...planned, externalReads: [] }\n yield* Effect.try({\n try: () => {\n ProcessSandbox.validateWrites(confinement, hostFacts)\n NodeFs.mkdirSync(NodePath.join(tmp, \"home\"), { recursive: true })\n NodeFs.mkdirSync(NodePath.join(tmp, \"cache\"), { recursive: true })\n for (const write of planned.writes) NodeFs.mkdirSync(write, { recursive: true })\n },\n catch: (cause) => failure(\"Unknown\", command, `could not prepare the confinement: ${messageOf(cause)}`, cause)\n })\n // Only the target receives its requested environment. Dynamic-loader and\n // other startup variables must never configure the host sandbox launcher.\n const targetEnvironment: Record<string, string> = {}\n const inherited = command.options.env === undefined || command.options.extendEnv === true\n for (const [name, value] of Object.entries(inherited ? process.env : {})) {\n // Bash exports functions as names such as BASH_FUNC_which%%. These\n // ambient entries cannot be exported by the portable inner launcher.\n if (typeof value === \"string\" && /^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) targetEnvironment[name] = value\n }\n for (const [name, value] of Object.entries(command.options.env ?? {})) {\n if (typeof value === \"string\") targetEnvironment[name] = value\n else delete targetEnvironment[name]\n }\n const privateEnvironment = ProcessSandbox.environment(confinement)\n const script = yield* Effect.try({\n try: () => {\n const quote = (value: string): string => `'${value.replaceAll(\"'\", \"'\\\\''\")}'`\n const exports: Array<string> = []\n for (const [name, value] of Object.entries({ ...targetEnvironment, ...privateEnvironment })) {\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) throw new Error(\"environment variable name is not portable\")\n if (value.includes(\"\\0\")) throw new Error(\"environment variable contains a null byte\")\n exports.push(`export ${name}=${quote(value)}`)\n }\n const file = NodePath.join(tmp, \"environment.sh\")\n // Values stay off argv and journal receipts; the script is private,\n // removed with the scope, and interpreted only inside confinement.\n NodeFs.writeFileSync(\n file,\n [\n \"#!/bin/sh\",\n \"unset ENV BASH_ENV CDPATH PWD OLDPWD SHLVL _\",\n ...exports,\n \"exec \\\"$@\\\"\",\n \"\"\n ].join(\"\\n\"),\n { flag: \"wx\", mode: 0o600 }\n )\n return file\n },\n catch: (cause) => failure(\"PermissionDenied\", command, messageOf(cause), cause)\n })\n // Resolve the actual program before wrapping it in the environment shell.\n // Otherwise the sandbox sees only /usr/bin/env and omits a native helper\n // installed outside its ordinary runtime paths.\n const originalArgv = argvOf(command)\n const launch = ProcessSandbox.launcher(\n originalArgv[0]!,\n targetEnvironment.PATH,\n [...confinement.reads, ...confinement.writes, ...confinement.externalReads],\n confinement.workspaceRoot,\n hostFacts\n )\n const targetArgv = [\"/usr/bin/env\", \"-i\", \"/bin/sh\", script, launch.program, ...originalArgv.slice(1)]\n const wrapped = yield* Effect.try({\n try: () =>\n ProcessSandbox.wrap(\n { ...confinement, externalReads: [...confinement.externalReads, ...launch.reads, script] },\n targetArgv,\n targetEnvironment,\n hostFacts\n ),\n catch: (cause) => failure(\"Unknown\", command, `could not render the confinement: ${messageOf(cause)}`, cause)\n })\n let [executable, ...args] = wrapped.argv\n if (selected._tag === \"bubblewrap\") {\n const filter = yield* Effect.try({\n try: () => {\n const file = NodePath.join(tmp, \"network.seccomp\")\n NodeFs.writeFileSync(file, networkFilter(process.arch, profile.network), { flag: \"wx\", mode: 0o600 })\n return file\n },\n catch: (cause) => failure(\"PermissionDenied\", command, messageOf(cause), cause)\n })\n let fd = 3\n while (command.options.additionalFds?.[`fd${fd}`] !== undefined) fd++\n // A regular file avoids a filter-input pipe whose early closure can\n // surface as an unhandled ECONNRESET before bwrap reports its refusal.\n args = [\n \"-c\",\n `exec ${fd}<\"$1\"; shift; exec \"$@\"`,\n \"smithers-seccomp\",\n filter,\n executable!,\n \"--seccomp\",\n String(fd),\n ...args\n ]\n executable = \"/bin/sh\"\n }\n return ChildProcess.make(executable!, args, {\n ...command.options,\n cwd: canonical.cwd,\n shell: false,\n env: { PATH: \"/usr/bin:/bin:/usr/sbin:/sbin\", LANG: \"C\", ...privateEnvironment },\n extendEnv: false\n })\n })\n return KernelProcessConfinement.ProcessConfinement.of({ confine })\n}\n\n/**\n * Provides the native confinement.\n *\n * @category layers\n * @since 1.0.0-rc.1\n */\nexport const layer = (options: Options = {}): Layer.Layer<KernelProcessConfinement.ProcessConfinement> =>\n Layer.succeed(KernelProcessConfinement.ProcessConfinement)(make(options))\n"]}