@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,113 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var WindowsProcessJob_exports = {};
20
+ __export(WindowsProcessJob_exports, {
21
+ WindowsProcessJob: () => WindowsProcessJob,
22
+ resolveJobExecutable: () => resolveJobExecutable
23
+ });
24
+ module.exports = __toCommonJS(WindowsProcessJob_exports);
25
+ var import_node_child_process = require("node:child_process");
26
+ var import_node_path = require("node:path");
27
+ var import_AtomicFileSystemExecutable = require("./AtomicFileSystemExecutable.js");
28
+ var import_ProcessFault = require("./ProcessFault.js");
29
+ const deferred = () => {
30
+ let resolve;
31
+ let reject;
32
+ const promise = new Promise((yes, no) => {
33
+ resolve = yes;
34
+ reject = no;
35
+ });
36
+ void promise.catch(() => {
37
+ });
38
+ return { promise, resolve, reject };
39
+ };
40
+ const resolveJobExecutable = () => {
41
+ const configured = process.env.SMITHERS_WORKSPACE_JJ_EXPORT_BINARY;
42
+ return configured === void 0 ? (0, import_AtomicFileSystemExecutable.resolveDefaultExecutable)(import_AtomicFileSystemExecutable.packageRoot, void 0) : (0, import_AtomicFileSystemExecutable.resolveConfiguredExecutable)(configured, void 0);
43
+ };
44
+ class WindowsProcessJob {
45
+ ready = deferred();
46
+ settled = deferred();
47
+ child;
48
+ receivedReady = false;
49
+ receivedSettled = false;
50
+ failed = false;
51
+ constructor(ownerPid, created, executable) {
52
+ if (typeof created !== "string" || !/^[1-9][0-9]{0,19}$/.test(created)) {
53
+ throw (0, import_ProcessFault.processFault)("owner_identity_missing", "Windows process owner has no exact creation identity");
54
+ }
55
+ const options = { cwd: (0, import_node_path.parse)(process.execPath).root, env: {}, windowsHide: true };
56
+ this.child = (0, import_node_child_process.spawn)(executable, ["--process-job", String(ownerPid), created], {
57
+ ...options,
58
+ stdio: ["pipe", "pipe", "pipe"]
59
+ });
60
+ let buffer = "";
61
+ this.child.stdout.setEncoding("utf8");
62
+ this.child.stdout.on("data", (data) => {
63
+ if (this.failed) return;
64
+ try {
65
+ buffer += data;
66
+ if (Buffer.byteLength(buffer) > 4096) {
67
+ throw (0, import_ProcessFault.processFault)("status_too_large", "Windows job status exceeds its bound");
68
+ }
69
+ for (; ; ) {
70
+ const end = buffer.indexOf("\n");
71
+ if (end < 0) break;
72
+ const frame = JSON.parse(buffer.slice(0, end));
73
+ buffer = buffer.slice(end + 1);
74
+ if (frame?.status === "ready" && frame.ownerPid === ownerPid && !this.receivedReady) {
75
+ this.receivedReady = true;
76
+ this.ready.resolve();
77
+ } else if (frame?.status === "settled" && this.receivedReady && !this.receivedSettled) {
78
+ this.receivedSettled = true;
79
+ } else throw (0, import_ProcessFault.processFault)("status_invalid", "Invalid Windows job status");
80
+ }
81
+ } catch (cause) {
82
+ this.fail(cause);
83
+ }
84
+ });
85
+ this.child.stderr.resume();
86
+ this.child.once("error", (cause) => this.fail(cause));
87
+ this.child.stdin.on("error", (cause) => this.fail(cause));
88
+ this.child.stdout.on("error", (cause) => this.fail(cause));
89
+ this.child.stderr.on("error", (cause) => this.fail(cause));
90
+ this.child.once("close", (code, signal) => {
91
+ if (!this.failed && code === 0 && signal === null && this.receivedSettled && buffer === "") {
92
+ this.settled.resolve();
93
+ } else this.fail((0, import_ProcessFault.processFault)("cleanup_unverified", "Windows job cleanup could not be verified"));
94
+ });
95
+ }
96
+ fail(cause) {
97
+ this.failed = true;
98
+ this.ready.reject(cause);
99
+ this.settled.reject(cause);
100
+ this.stop();
101
+ }
102
+ /** Closing this pipe asks the native guardian to terminate its job. */
103
+ stop() {
104
+ this.child.stdin.destroy();
105
+ }
106
+ /** Keep the guardian and all three pipes consistent with the host handle. */
107
+ reference(referenced) {
108
+ const method = referenced ? "ref" : "unref";
109
+ this.child[method]();
110
+ for (const pipe of [this.child.stdin, this.child.stdout, this.child.stderr]) pipe[method]();
111
+ }
112
+ }
113
+ //# sourceMappingURL=WindowsProcessJob.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/internal/WindowsProcessJob.ts"],
4
+ "sourcesContent": ["/**\n * A native Windows job guardian, attached before the owner can launch a target.\n * @since 1.0.0\n */\n\nimport { spawn } from \"node:child_process\"\nimport type { Socket } from \"node:net\"\nimport { parse } from \"node:path\"\nimport { packageRoot, resolveConfiguredExecutable, resolveDefaultExecutable } from \"./AtomicFileSystemExecutable.ts\"\nimport { processFault } from \"./ProcessFault.ts\"\n\nconst deferred = <A>() => {\n let resolve!: (value: A) => void\n let reject!: (cause: unknown) => void\n const promise = new Promise<A>((yes, no) => {\n resolve = yes\n reject = no\n })\n void promise.catch(() => {})\n return { promise, resolve, reject }\n}\n\n/**\n * Resolve the same trusted helper for the owner's self-observation and guardian.\n * @private\n * @since 1.0.0\n */\nexport const resolveJobExecutable = (): string => {\n const configured = process.env.SMITHERS_WORKSPACE_JJ_EXPORT_BINARY\n return configured === undefined\n ? resolveDefaultExecutable(packageRoot, undefined)\n : resolveConfiguredExecutable(configured, undefined)\n}\n\n/**\n * Retains the guardian's dedicated control pipe until cleanup. EOF, including\n * host death, terminates the job independently of the Node owner's event loop.\n * @private\n * @since 1.0.0\n */\nexport class WindowsProcessJob {\n readonly ready = deferred<void>()\n readonly settled = deferred<void>()\n private readonly child\n private receivedReady = false\n private receivedSettled = false\n private failed = false\n\n constructor(ownerPid: number, created: unknown, executable: string) {\n if (typeof created !== \"string\" || !/^[1-9][0-9]{0,19}$/.test(created)) {\n throw processFault(\"owner_identity_missing\", \"Windows process owner has no exact creation identity\")\n }\n const options = { cwd: parse(process.execPath).root, env: {}, windowsHide: true }\n this.child = spawn(executable, [\"--process-job\", String(ownerPid), created], {\n ...options,\n stdio: [\"pipe\", \"pipe\", \"pipe\"]\n })\n let buffer = \"\"\n this.child.stdout.setEncoding(\"utf8\")\n this.child.stdout.on(\"data\", (data: string) => {\n if (this.failed) return\n try {\n buffer += data\n if (Buffer.byteLength(buffer) > 4096) {\n throw processFault(\"status_too_large\", \"Windows job status exceeds its bound\")\n }\n for (;;) {\n const end = buffer.indexOf(\"\\n\")\n if (end < 0) break\n const frame = JSON.parse(buffer.slice(0, end)) as { status?: unknown; ownerPid?: unknown } | null\n buffer = buffer.slice(end + 1)\n if (frame?.status === \"ready\" && frame.ownerPid === ownerPid && !this.receivedReady) {\n this.receivedReady = true\n this.ready.resolve()\n } else if (frame?.status === \"settled\" && this.receivedReady && !this.receivedSettled) {\n this.receivedSettled = true\n } else throw processFault(\"status_invalid\", \"Invalid Windows job status\")\n }\n } catch (cause) {\n this.fail(cause)\n }\n })\n // Drain diagnostics without retaining unbounded native output.\n this.child.stderr.resume()\n this.child.once(\"error\", (cause) => this.fail(cause))\n this.child.stdin.on(\"error\", (cause) => this.fail(cause))\n this.child.stdout.on(\"error\", (cause) => this.fail(cause))\n this.child.stderr.on(\"error\", (cause) => this.fail(cause))\n this.child.once(\"close\", (code, signal) => {\n if (!this.failed && code === 0 && signal === null && this.receivedSettled && buffer === \"\") {\n this.settled.resolve()\n } else this.fail(processFault(\"cleanup_unverified\", \"Windows job cleanup could not be verified\"))\n })\n }\n\n private fail(cause: unknown): void {\n this.failed = true\n this.ready.reject(cause)\n this.settled.reject(cause)\n this.stop()\n }\n\n /** Closing this pipe asks the native guardian to terminate its job. */\n stop(): void {\n this.child.stdin.destroy()\n }\n\n /** Keep the guardian and all three pipes consistent with the host handle. */\n reference(referenced: boolean): void {\n const method = referenced ? \"ref\" : \"unref\"\n this.child[method]()\n for (const pipe of [this.child.stdin, this.child.stdout, this.child.stderr]) (pipe as Socket)[method]()\n }\n}\n"],
5
+ "mappings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AAK,KAAK;AAAA,EACZ;AAAA;AAAA,EAGA,OAAa;AACX,SAAK,MAAM,MAAM,QAAQ;AAAA,EAC3B;AAAA;AAAA,EAGA,UAAU,YAA2B;AACnC,UAAM,SAAS,aAAa,QAAQ;AACpC,SAAK,MAAM,MAAM,EAAE;AACnB,eAAW,QAAQ,CAAC,KAAK,MAAM,OAAO,KAAK,MAAM,QAAQ,KAAK,MAAM,MAAM,EAAG,CAAC,KAAgB,MAAM,EAAE;AAAA,EACxG;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Descriptor-relative filesystem operations through the packaged Rust helper.
3
+ * The helper pins the workspace root and walks each component with O_NOFOLLOW.
4
+ * Requests and responses are length-framed, size-limited, and cancellable.
5
+ * @since 0.1.0
6
+ */
7
+ import { FileSystem, Layer } from "effect";
8
+ export { AtomicHelperError, AtomicHelperErrorCode } from "./internal/AtomicHelperError.ts";
9
+ /**
10
+ * The legacy system installation path, used after package and checkout paths.
11
+ * Helper selection never consults `PATH` or the process working directory.
12
+ *
13
+ * @since 0.1.0
14
+ * @category constants
15
+ */
16
+ export declare const defaultExecutable = "/usr/local/bin/smithers-jj-export";
17
+ /**
18
+ * Byte ceilings for the helper protocol. Every one of them is a contract, not
19
+ * a tuning knob: without them a large file, a large directory tree, or a
20
+ * malfunctioning helper makes the host allocate until it dies.
21
+ *
22
+ * - `content` bounds the bytes a single `readFile`/`writeFile` may carry.
23
+ * - `request` bounds the framed request; an over-limit request is refused
24
+ * before an helper is even started.
25
+ * - `response` bounds the framed response, and is what a directory listing is
26
+ * charged against as it is built. It bounds the REJECTION envelope too, so a
27
+ * ceiling small enough to cut one off degrades that operation's typed reason
28
+ * to the fail-closed one.
29
+ * - `stderr` bounds the diagnostic text retained from a failing helper.
30
+ * - `batchEntry` bounds one batch member's encoded success or failure envelope.
31
+ * - `batchSize` bounds the number of operations in one batch, at most 128.
32
+ *
33
+ * All except `batchSize` count bytes. The two ceilings that decide whether the host
34
+ * survives a wide fan-out are {@link Options.concurrency}, which bounds how
35
+ * many helpers run at once, and {@link Options.timeoutMs}, which bounds
36
+ * how long any one of them may take.
37
+ *
38
+ * @since 0.1.0
39
+ * @category models
40
+ */
41
+ export interface Limits {
42
+ readonly content: number;
43
+ readonly request: number;
44
+ readonly response: number;
45
+ readonly stderr: number;
46
+ /** Maximum operations in one helper invocation, at most 128. */
47
+ readonly batchSize: number;
48
+ /** Maximum encoded result bytes for one batch member. */
49
+ readonly batchEntry: number;
50
+ }
51
+ /**
52
+ * 16 MiB of file content, 24 MiB of framed request and response (base64
53
+ * expands 16 MiB to 22369624 bytes, which has to fit), and 64 KiB of retained
54
+ * helper diagnostics.
55
+ *
56
+ * @since 0.1.0
57
+ * @category constants
58
+ */
59
+ export declare const defaultLimits: Limits;
60
+ /**
61
+ * The default number of helper processes that may run at once:
62
+ * `os.availableParallelism()`.
63
+ *
64
+ * @since 1.0.0-rc.0
65
+ * @category constants
66
+ */
67
+ export declare const defaultConcurrency: number;
68
+ /**
69
+ * How long one helper may run before it is killed and the operation fails
70
+ * closed: five minutes.
71
+ *
72
+ * It is a backstop, not a latency budget. A read at the content ceiling over a
73
+ * slow disk has to fit under it, so it is generous; what it bounds is a helper
74
+ * that will never answer at all.
75
+ *
76
+ * @since 1.0.0-rc.0
77
+ * @category constants
78
+ */
79
+ export declare const defaultTimeoutMs = 300000;
80
+ /**
81
+ * The deliberate seam for a POSIX host that installs the native helper somewhere other
82
+ * than {@link defaultExecutable}, or that needs different ceilings. It is
83
+ * configuration, never discovery: the executable is validated as an absolute,
84
+ * executable regular file outside the confined workspace on every request, and
85
+ * every other field is read ONCE, when the layer is built.
86
+ *
87
+ * @since 0.1.0
88
+ * @category models
89
+ */
90
+ export interface Options {
91
+ readonly executable?: string | undefined;
92
+ readonly limits?: Partial<Limits> | undefined;
93
+ /**
94
+ * How many helper processes may run at once. Default
95
+ * {@link defaultConcurrency}.
96
+ *
97
+ * Each ordinary operation or batch starts one helper, so an unbounded
98
+ * `Effect.forEach` over a directory would start
99
+ * one helper per entry. This ceiling is what keeps a wide fan-out from
100
+ * pinning every core; it is a contract, not a tuning knob.
101
+ */
102
+ readonly concurrency?: number | undefined;
103
+ /**
104
+ * How long one helper may run before it is killed and the operation fails
105
+ * closed, in milliseconds. Default {@link defaultTimeoutMs}.
106
+ */
107
+ readonly timeoutMs?: number | undefined;
108
+ }
109
+ /**
110
+ * Process-local helper starts, for cost counters and local measurements.
111
+ * Includes helpers later cancelled or refused; rejected preflight starts none.
112
+ *
113
+ * @since 1.0.0
114
+ * @category metrics
115
+ */
116
+ export declare const helperSpawns: () => number;
117
+ /**
118
+ * The helper this process would start for an atomic operation, resolved exactly
119
+ * as an operation resolves it: `SMITHERS_WORKSPACE_JJ_EXPORT_BINARY`, then the
120
+ * packaged and checkout locations. Nothing is spawned. Throws an {@link AtomicHelperError} whose
121
+ * message names what was searched and how to install the helper when none is
122
+ * usable, so a diagnostic can report it before any operation needs it.
123
+ *
124
+ * @since 1.0.0
125
+ * @category constructors
126
+ */
127
+ export declare const resolveHelper: () => string;
128
+ /**
129
+ * A Node filesystem layer carrying the kernel's atomic host extension, built
130
+ * against an explicitly configured helper, byte limits, process ceiling,
131
+ * and helper timeout.
132
+ *
133
+ * Every field of {@link Options} except `executable` is read once, here. The
134
+ * concurrency ceiling is one semaphore for the whole layer rather than one per
135
+ * request, which is the only arrangement that bounds anything.
136
+ *
137
+ * @since 0.1.0
138
+ * @category layers
139
+ */
140
+ export declare const layerWith: (options: Options) => Layer.Layer<FileSystem.FileSystem>;
141
+ /** A Node filesystem layer carrying the kernel's atomic host extension.
142
+ *
143
+ * @since 0.1.0
144
+ * @category layers
145
+ */
146
+ export declare const layer: Layer.Layer<FileSystem.FileSystem>;
147
+ //# sourceMappingURL=AtomicFileSystem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AtomicFileSystem.d.ts","sourceRoot":"","sources":["../../src/At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a,QAAO,MAA0C,CAAA;AAuB3E;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,GAAI,SAAS,OAAO,KAAG,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAuD7E,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAiB,CAAA"}
@@ -0,0 +1,290 @@
1
+ /**
2
+ * Descriptor-relative filesystem operations through the packaged Rust helper.
3
+ * The helper pins the workspace root and walks each component with O_NOFOLLOW.
4
+ * Requests and responses are length-framed, size-limited, and cancellable.
5
+ * @since 0.1.0
6
+ */
7
+ import * as NodeFileSystem from "../vendor/node/NodeFileSystem.js";
8
+ import * as KernelFileSystem from "@smthrs/kernel/FileSystem";
9
+ import { Effect, FileSystem, Layer, PlatformError, Semaphore, Stream } from "effect";
10
+ import { realpath, stat } from "node:fs/promises";
11
+ import { availableParallelism } from "node:os";
12
+ import { packageRoot, resolveConfiguredExecutable, resolveDefaultExecutable, stagePackaged } from "./internal/AtomicFileSystemExecutable.js";
13
+ import * as Protocol from "./internal/AtomicFileSystemProtocol.js";
14
+ import * as Transport from "./internal/AtomicFileSystemTransport.js";
15
+ import { AtomicHelperError } from "./internal/AtomicHelperError.js";
16
+ export { AtomicHelperError, AtomicHelperErrorCode } from "./internal/AtomicHelperError.js";
17
+ /**
18
+ * The legacy system installation path, used after package and checkout paths.
19
+ * Helper selection never consults `PATH` or the process working directory.
20
+ *
21
+ * @since 0.1.0
22
+ * @category constants
23
+ */
24
+ export const defaultExecutable = "/usr/local/bin/smithers-jj-export";
25
+ /**
26
+ * 16 MiB of file content, 24 MiB of framed request and response (base64
27
+ * expands 16 MiB to 22369624 bytes, which has to fit), and 64 KiB of retained
28
+ * helper diagnostics.
29
+ *
30
+ * @since 0.1.0
31
+ * @category constants
32
+ */
33
+ export const defaultLimits = {
34
+ content: 16 * 1024 * 1024,
35
+ request: 24 * 1024 * 1024,
36
+ response: 24 * 1024 * 1024,
37
+ stderr: 64 * 1024,
38
+ batchSize: KernelFileSystem.maxBatchSize,
39
+ batchEntry: 24 * 1024 * 1024
40
+ };
41
+ /**
42
+ * The default number of helper processes that may run at once:
43
+ * `os.availableParallelism()`.
44
+ *
45
+ * @since 1.0.0-rc.0
46
+ * @category constants
47
+ */
48
+ export const defaultConcurrency = availableParallelism();
49
+ /**
50
+ * How long one helper may run before it is killed and the operation fails
51
+ * closed: five minutes.
52
+ *
53
+ * It is a backstop, not a latency budget. A read at the content ceiling over a
54
+ * slow disk has to fit under it, so it is generous; what it bounds is a helper
55
+ * that will never answer at all.
56
+ *
57
+ * @since 1.0.0-rc.0
58
+ * @category constants
59
+ */
60
+ export const defaultTimeoutMs = 300_000;
61
+ /**
62
+ * Process-local helper starts, for cost counters and local measurements.
63
+ * Includes helpers later cancelled or refused; rejected preflight starts none.
64
+ *
65
+ * @since 1.0.0
66
+ * @category metrics
67
+ */
68
+ export const helperSpawns = () => Transport.started();
69
+ /** The helper enforces the same ceiling before it trusts a declared limit. */
70
+ const hardLimitBytes = 256 * 1024 * 1024;
71
+ /** `setTimeout` clamps a longer delay to 1 ms, so a bigger backstop is none. */
72
+ const maxTimeoutMs = 2_147_483_647;
73
+ /** Resolves every optional byte ceiling and refuses values that could disable a bound. */
74
+ const resolveLimits = (overrides) => {
75
+ const limits = {
76
+ content: overrides?.content ?? defaultLimits.content,
77
+ request: overrides?.request ?? defaultLimits.request,
78
+ response: overrides?.response ?? defaultLimits.response,
79
+ stderr: overrides?.stderr ?? defaultLimits.stderr,
80
+ batchSize: overrides?.batchSize ?? defaultLimits.batchSize,
81
+ batchEntry: overrides?.batchEntry ?? defaultLimits.batchEntry
82
+ };
83
+ for (const [name, value] of Object.entries(limits)) {
84
+ if (!Number.isSafeInteger(value) || value <= 0 || value > hardLimitBytes) {
85
+ throw new AtomicHelperError({
86
+ code: "limit_invalid",
87
+ message: `atomic helper ${name} limit must be a positive integer no greater than ${hardLimitBytes}`
88
+ });
89
+ }
90
+ }
91
+ if (limits.batchSize > KernelFileSystem.maxBatchSize) {
92
+ throw new AtomicHelperError({
93
+ code: "limit_invalid",
94
+ message: `atomic helper batchSize limit must be no greater than ${KernelFileSystem.maxBatchSize}`
95
+ });
96
+ }
97
+ return limits;
98
+ };
99
+ /**
100
+ * Reads the whole of {@link Options} once, at layer construction.
101
+ *
102
+ * A rejected value is carried rather than thrown, because the failure a caller
103
+ * sees for it is a typed `BadArgument` on the first operation and not an
104
+ * exception escaping a layer.
105
+ */
106
+ const resolveSettings = (options) => {
107
+ try {
108
+ const limits = resolveLimits(options.limits);
109
+ const concurrency = options.concurrency ?? defaultConcurrency;
110
+ if (!Number.isSafeInteger(concurrency) || concurrency <= 0) {
111
+ throw new AtomicHelperError({
112
+ code: "concurrency_invalid",
113
+ message: "atomic helper concurrency must be a positive integer"
114
+ });
115
+ }
116
+ const timeoutMs = options.timeoutMs ?? defaultTimeoutMs;
117
+ if (!Number.isSafeInteger(timeoutMs) || timeoutMs <= 0 || timeoutMs > maxTimeoutMs) {
118
+ throw new AtomicHelperError({
119
+ code: "timeout_invalid",
120
+ message: "atomic helper timeoutMs must be a positive integer no greater than 2147483647"
121
+ });
122
+ }
123
+ return { limits, timeoutMs, semaphore: Semaphore.makeUnsafe(concurrency) };
124
+ }
125
+ catch (invalid) {
126
+ return { invalid };
127
+ }
128
+ };
129
+ /**
130
+ * The framed half, one concrete result type. Nothing on this side of the pipe
131
+ * can prove what the helper answered: the protocol pairs an operation with its
132
+ * result, and {@link execute} restates that pairing for the kernel's typed
133
+ * request. Keeping the decode `unknown` here confines that promise to one
134
+ * assertion instead of one per caller.
135
+ */
136
+ const executeFramed = (options, resolved) => (request) => Effect.suspend(() => {
137
+ if ("invalid" in resolved) {
138
+ const cause = resolved.invalid;
139
+ return Effect.fail(PlatformError.badArgument({
140
+ module: Protocol.moduleName,
141
+ method: request.operation,
142
+ description: cause instanceof Error ? cause.message : "atomic helper limits are invalid",
143
+ cause
144
+ }));
145
+ }
146
+ const limits = resolved.limits;
147
+ if (request.operation === "batch" &&
148
+ (!Array.isArray(request.requests) || request.requests.length === 0 || request.requests.length > limits.batchSize)) {
149
+ return Effect.fail(PlatformError.badArgument({
150
+ module: Protocol.moduleName,
151
+ method: "batch",
152
+ description: `atomic batch must contain 1 to ${limits.batchSize} operations`
153
+ }));
154
+ }
155
+ // Admission bounds request serialization and framing as well as children.
156
+ // Queued callers retain their input, without another full payload copy.
157
+ return resolved.semaphore.withPermits(1)(Effect.suspend(() => {
158
+ let body;
159
+ try {
160
+ const serialized = JSON.stringify(request.operation === "batch"
161
+ ? { ...request, batchSize: limits.batchSize, batchEntry: limits.batchEntry }
162
+ : request);
163
+ if (serialized === undefined) {
164
+ throw new AtomicHelperError({
165
+ code: "request_not_serializable",
166
+ message: "atomic request is not serializable"
167
+ });
168
+ }
169
+ body = Buffer.from(serialized, "utf8");
170
+ }
171
+ catch (cause) {
172
+ return Effect.fail(PlatformError.badArgument({
173
+ module: Protocol.moduleName,
174
+ method: request.operation,
175
+ description: "atomic request is not serializable",
176
+ cause
177
+ }));
178
+ }
179
+ if (body.byteLength > limits.request) {
180
+ // Refused before an helper exists: an over-limit request is caller
181
+ // input, and nothing about it improves by being sent.
182
+ return Effect.fail(PlatformError.badArgument({
183
+ module: Protocol.moduleName,
184
+ method: request.operation,
185
+ description: `atomic request of ${body.byteLength} bytes exceeds the ${limits.request} byte limit`
186
+ }));
187
+ }
188
+ let executable;
189
+ try {
190
+ executable = resolveExecutable(options, request.boundaryRoot);
191
+ }
192
+ catch (cause) {
193
+ return Effect.fail(Protocol.failure(request, cause));
194
+ }
195
+ return Transport.spawnHelper(request, executable, Protocol.encode(body, limits), resolved);
196
+ }));
197
+ });
198
+ const resolveExecutable = (options, boundaryRoot) => {
199
+ const configured = process.env.SMITHERS_WORKSPACE_JJ_EXPORT_BINARY;
200
+ return options.executable !== undefined
201
+ ? Transport.usableExecutable(options.executable, boundaryRoot)
202
+ : configured === undefined
203
+ ? resolveDefaultExecutable(packageRoot, boundaryRoot, defaultExecutable)
204
+ : resolveConfiguredExecutable(configured, boundaryRoot);
205
+ };
206
+ /**
207
+ * The helper this process would start for an atomic operation, resolved exactly
208
+ * as an operation resolves it: `SMITHERS_WORKSPACE_JJ_EXPORT_BINARY`, then the
209
+ * packaged and checkout locations. Nothing is spawned. Throws an {@link AtomicHelperError} whose
210
+ * message names what was searched and how to install the helper when none is
211
+ * usable, so a diagnostic can report it before any operation needs it.
212
+ *
213
+ * @since 1.0.0
214
+ * @category constructors
215
+ */
216
+ export const resolveHelper = () => resolveExecutable({}, undefined);
217
+ const execute = (options, resolved) => {
218
+ const framed = executeFramed(options, resolved);
219
+ return (request) => framed(request);
220
+ };
221
+ const nativeRealPath = (path) => Effect.tryPromise({
222
+ try: () => realpath(path),
223
+ catch: (cause) => Protocol.failure({ operation: "realPath", path }, cause, {
224
+ ok: false,
225
+ code: cause.code ?? null,
226
+ message: cause.message,
227
+ syscall: "realpath"
228
+ })
229
+ });
230
+ /**
231
+ * A Node filesystem layer carrying the kernel's atomic host extension, built
232
+ * against an explicitly configured helper, byte limits, process ceiling,
233
+ * and helper timeout.
234
+ *
235
+ * Every field of {@link Options} except `executable` is read once, here. The
236
+ * concurrency ceiling is one semaphore for the whole layer rather than one per
237
+ * request, which is the only arrangement that bounds anything.
238
+ *
239
+ * @since 0.1.0
240
+ * @category layers
241
+ */
242
+ export const layerWith = (options) => {
243
+ // Outside the layer body on purpose. Inside it the settings would be read
244
+ // again on every BUILD, so two compositions of the same layer value could
245
+ // enforce two different ceilings out of one mutated object, and each would
246
+ // get a process ceiling of its own instead of sharing one.
247
+ const settings = resolveSettings(options);
248
+ return Layer.effect(FileSystem.FileSystem, Effect.map(
249
+ // The packaged helper is pinned while the host is built, before any flow
250
+ // can rewrite a workspace-local install of this package.
251
+ Effect.andThen(Effect.sync(() => {
252
+ if (options.executable === undefined && process.env.SMITHERS_WORKSPACE_JJ_EXPORT_BINARY === undefined) {
253
+ stagePackaged(packageRoot);
254
+ }
255
+ }), FileSystem.FileSystem), (fileSystem) => KernelFileSystem.withAtomicFileSystem({
256
+ ...fileSystem,
257
+ // Expand DOS names before pinning roots or opening native watchers.
258
+ realPath: nativeRealPath,
259
+ watch: (path, options) => process.platform !== "win32"
260
+ ? fileSystem.watch(path, options)
261
+ : Stream.unwrap(nativeRealPath(path).pipe(Effect.map((canonical) => fileSystem.watch(canonical, options))))
262
+ }, {
263
+ noFollowAuthorization: true,
264
+ execute: execute(options, settings),
265
+ identifyRoot: (path) => Effect.tryPromise({
266
+ try: async () => {
267
+ const info = await stat(path, { bigint: true });
268
+ return `${info.dev}:${info.ino}`;
269
+ },
270
+ catch: (cause) => Protocol.failure({ operation: "stat", path }, cause, {
271
+ ok: false,
272
+ code: cause.code ?? null,
273
+ message: cause.message,
274
+ syscall: "stat"
275
+ })
276
+ }),
277
+ batchLimits: {
278
+ size: "invalid" in settings ? defaultLimits.batchSize : settings.limits.batchSize,
279
+ response: "invalid" in settings ? defaultLimits.response : settings.limits.response
280
+ },
281
+ contentLimit: "invalid" in settings ? defaultLimits.content : settings.limits.content
282
+ }))).pipe(Layer.provide(NodeFileSystem.layer));
283
+ };
284
+ /** A Node filesystem layer carrying the kernel's atomic host extension.
285
+ *
286
+ * @since 0.1.0
287
+ * @category layers
288
+ */
289
+ export const layer = layerWith({});
290
+ //# sourceMappingURL=AtomicFileSystem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AtomicFileSystem.js","sourceRoot":"","sources":["../../src/AtomicFileSystem.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,cAAc,MAAM,sCAAsC,CAAA;AACtE,OAAO,KAAK,gBAAgB,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACpF,OAAO,EAAE,QAAQ,EAAE,IA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,OAAO,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE;gBACnD,EAAE,EAAE,KAAK;gBACT,IAAI,EAAG,KAA+B,CAAC,IAAI,IAAI,IAAI;gBACnD,OAAO,EAAG,KAA+B,CAAC,OAAO;gBACjD,OAAO,EAAE,MAAM;aAChB,CAAC;SACL,CAAC;QACJ,WAAW,EAAE;YACX,IAAI,EAAE,SAAS,IAAI,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS;YACjF,QAAQ,EAAE,SAAS,IAAI,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ;SACpF;QACD,YAAY,EAAE,SAAS,IAAI,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO;KACtF,CAAC,CACL,CACF,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAA;AAC7C,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAuC,SAAS,CAAC,EAAE,CAAC,CAAA","sourcesContent":["/**\n * Descriptor-relative filesystem operations through the packaged Rust helper.\n * The helper pins the workspace root and walks each component with O_NOFOLLOW.\n * Requests and responses are length-framed, size-limited, and cancellable.\n * @since 0.1.0\n */\n\nimport * as NodeFileSystem from \"@effect/platform-node/NodeFileSystem\"\nimport * as KernelFileSystem from \"@smthrs/kernel/FileSystem\"\nimport { Effect, FileSystem, Layer, PlatformError, Semaphore, Stream } from \"effect\"\nimport { realpath, stat } from \"node:fs/promises\"\nimport { availableParallelism } from \"node:os\"\nimport {\n packageRoot,\n resolveConfiguredExecutable,\n resolveDefaultExecutable,\n stagePackaged\n} from \"./internal/AtomicFileSystemExecutable.ts\"\nimport * as Protocol from \"./internal/AtomicFileSystemProtocol.ts\"\nimport * as Transport from \"./internal/AtomicFileSystemTransport.ts\"\nimport { AtomicHelperError } from \"./internal/AtomicHelperError.ts\"\n\nexport { AtomicHelperError, AtomicHelperErrorCode } from \"./internal/AtomicHelperError.ts\"\n\n/**\n * The legacy system installation path, used after package and checkout paths.\n * Helper selection never consults `PATH` or the process working directory.\n *\n * @since 0.1.0\n * @category constants\n */\nexport const defaultExecutable = \"/usr/local/bin/smithers-jj-export\"\n\n/**\n * Byte ceilings for the helper protocol. Every one of them is a contract, not\n * a tuning knob: without them a large file, a large directory tree, or a\n * malfunctioning helper makes the host allocate until it dies.\n *\n * - `content` bounds the bytes a single `readFile`/`writeFile` may carry.\n * - `request` bounds the framed request; an over-limit request is refused\n * before an helper is even started.\n * - `response` bounds the framed response, and is what a directory listing is\n * charged against as it is built. It bounds the REJECTION envelope too, so a\n * ceiling small enough to cut one off degrades that operation's typed reason\n * to the fail-closed one.\n * - `stderr` bounds the diagnostic text retained from a failing helper.\n * - `batchEntry` bounds one batch member's encoded success or failure envelope.\n * - `batchSize` bounds the number of operations in one batch, at most 128.\n *\n * All except `batchSize` count bytes. The two ceilings that decide whether the host\n * survives a wide fan-out are {@link Options.concurrency}, which bounds how\n * many helpers run at once, and {@link Options.timeoutMs}, which bounds\n * how long any one of them may take.\n *\n * @since 0.1.0\n * @category models\n */\nexport interface Limits {\n readonly content: number\n readonly request: number\n readonly response: number\n readonly stderr: number\n /** Maximum operations in one helper invocation, at most 128. */\n readonly batchSize: number\n /** Maximum encoded result bytes for one batch member. */\n readonly batchEntry: number\n}\n\n/**\n * 16 MiB of file content, 24 MiB of framed request and response (base64\n * expands 16 MiB to 22369624 bytes, which has to fit), and 64 KiB of retained\n * helper diagnostics.\n *\n * @since 0.1.0\n * @category constants\n */\nexport const defaultLimits: Limits = {\n content: 16 * 1024 * 1024,\n request: 24 * 1024 * 1024,\n response: 24 * 1024 * 1024,\n stderr: 64 * 1024,\n batchSize: KernelFileSystem.maxBatchSize,\n batchEntry: 24 * 1024 * 1024\n}\n\n/**\n * The default number of helper processes that may run at once:\n * `os.availableParallelism()`.\n *\n * @since 1.0.0-rc.0\n * @category constants\n */\nexport const defaultConcurrency: number = availableParallelism()\n\n/**\n * How long one helper may run before it is killed and the operation fails\n * closed: five minutes.\n *\n * It is a backstop, not a latency budget. A read at the content ceiling over a\n * slow disk has to fit under it, so it is generous; what it bounds is a helper\n * that will never answer at all.\n *\n * @since 1.0.0-rc.0\n * @category constants\n */\nexport const defaultTimeoutMs = 300_000\n\n/**\n * The deliberate seam for a POSIX host that installs the native helper somewhere other\n * than {@link defaultExecutable}, or that needs different ceilings. It is\n * configuration, never discovery: the executable is validated as an absolute,\n * executable regular file outside the confined workspace on every request, and\n * every other field is read ONCE, when the layer is built.\n *\n * @since 0.1.0\n * @category models\n */\nexport interface Options {\n readonly executable?: string | undefined\n readonly limits?: Partial<Limits> | undefined\n /**\n * How many helper processes may run at once. Default\n * {@link defaultConcurrency}.\n *\n * Each ordinary operation or batch starts one helper, so an unbounded\n * `Effect.forEach` over a directory would start\n * one helper per entry. This ceiling is what keeps a wide fan-out from\n * pinning every core; it is a contract, not a tuning knob.\n */\n readonly concurrency?: number | undefined\n /**\n * How long one helper may run before it is killed and the operation fails\n * closed, in milliseconds. Default {@link defaultTimeoutMs}.\n */\n readonly timeoutMs?: number | undefined\n}\n\n/**\n * Everything read out of {@link Options} once, when the layer is built.\n *\n * Snapshotted rather than re-read per request: `Options` is a plain object the\n * caller still holds, and a byte ceiling that changes under a running host is\n * not a ceiling. The executable is deliberately NOT here — it is re-validated\n * per request, because the file it names can be replaced while the host runs.\n */\ninterface Settings {\n readonly limits: Limits\n readonly timeoutMs: number\n readonly semaphore: Semaphore.Semaphore\n}\n\n/**\n * Process-local helper starts, for cost counters and local measurements.\n * Includes helpers later cancelled or refused; rejected preflight starts none.\n *\n * @since 1.0.0\n * @category metrics\n */\nexport const helperSpawns = (): number => Transport.started()\n\n/** The helper enforces the same ceiling before it trusts a declared limit. */\nconst hardLimitBytes = 256 * 1024 * 1024\n/** `setTimeout` clamps a longer delay to 1 ms, so a bigger backstop is none. */\nconst maxTimeoutMs = 2_147_483_647\n\n/** Resolves every optional byte ceiling and refuses values that could disable a bound. */\nconst resolveLimits = (overrides: Partial<Limits> | undefined): Limits => {\n const limits: Limits = {\n content: overrides?.content ?? defaultLimits.content,\n request: overrides?.request ?? defaultLimits.request,\n response: overrides?.response ?? defaultLimits.response,\n stderr: overrides?.stderr ?? defaultLimits.stderr,\n batchSize: overrides?.batchSize ?? defaultLimits.batchSize,\n batchEntry: overrides?.batchEntry ?? defaultLimits.batchEntry\n }\n for (const [name, value] of Object.entries(limits)) {\n if (!Number.isSafeInteger(value) || value <= 0 || value > hardLimitBytes) {\n throw new AtomicHelperError({\n code: \"limit_invalid\",\n message: `atomic helper ${name} limit must be a positive integer no greater than ${hardLimitBytes}`\n })\n }\n }\n if (limits.batchSize > KernelFileSystem.maxBatchSize) {\n throw new AtomicHelperError({\n code: \"limit_invalid\",\n message: `atomic helper batchSize limit must be no greater than ${KernelFileSystem.maxBatchSize}`\n })\n }\n return limits\n}\n\n/**\n * Reads the whole of {@link Options} once, at layer construction.\n *\n * A rejected value is carried rather than thrown, because the failure a caller\n * sees for it is a typed `BadArgument` on the first operation and not an\n * exception escaping a layer.\n */\nconst resolveSettings = (options: Options): Settings | { readonly invalid: unknown } => {\n try {\n const limits = resolveLimits(options.limits)\n const concurrency = options.concurrency ?? defaultConcurrency\n if (!Number.isSafeInteger(concurrency) || concurrency <= 0) {\n throw new AtomicHelperError({\n code: \"concurrency_invalid\",\n message: \"atomic helper concurrency must be a positive integer\"\n })\n }\n const timeoutMs = options.timeoutMs ?? defaultTimeoutMs\n if (!Number.isSafeInteger(timeoutMs) || timeoutMs <= 0 || timeoutMs > maxTimeoutMs) {\n throw new AtomicHelperError({\n code: \"timeout_invalid\",\n message: \"atomic helper timeoutMs must be a positive integer no greater than 2147483647\"\n })\n }\n return { limits, timeoutMs, semaphore: Semaphore.makeUnsafe(concurrency) }\n } catch (invalid) {\n return { invalid }\n }\n}\n\n/**\n * The framed half, one concrete result type. Nothing on this side of the pipe\n * can prove what the helper answered: the protocol pairs an operation with its\n * result, and {@link execute} restates that pairing for the kernel's typed\n * request. Keeping the decode `unknown` here confines that promise to one\n * assertion instead of one per caller.\n */\nconst executeFramed = (options: Options, resolved: Settings | { readonly invalid: unknown }) =>\n(\n request: KernelFileSystem.AtomicRequest\n): Effect.Effect<unknown, PlatformError.PlatformError> =>\n Effect.suspend(() => {\n if (\"invalid\" in resolved) {\n const cause = resolved.invalid\n return Effect.fail(PlatformError.badArgument({\n module: Protocol.moduleName,\n method: request.operation,\n description: cause instanceof Error ? cause.message : \"atomic helper limits are invalid\",\n cause\n }))\n }\n const limits = resolved.limits\n if (\n request.operation === \"batch\" &&\n (!Array.isArray(request.requests) || request.requests.length === 0 || request.requests.length > limits.batchSize)\n ) {\n return Effect.fail(PlatformError.badArgument({\n module: Protocol.moduleName,\n method: \"batch\",\n description: `atomic batch must contain 1 to ${limits.batchSize} operations`\n }))\n }\n // Admission bounds request serialization and framing as well as children.\n // Queued callers retain their input, without another full payload copy.\n return resolved.semaphore.withPermits(1)(Effect.suspend(() => {\n let body: Buffer\n try {\n const serialized = JSON.stringify(\n request.operation === \"batch\"\n ? { ...request, batchSize: limits.batchSize, batchEntry: limits.batchEntry }\n : request\n )\n if (serialized === undefined) {\n throw new AtomicHelperError({\n code: \"request_not_serializable\",\n message: \"atomic request is not serializable\"\n })\n }\n body = Buffer.from(serialized, \"utf8\")\n } catch (cause) {\n return Effect.fail(PlatformError.badArgument({\n module: Protocol.moduleName,\n method: request.operation,\n description: \"atomic request is not serializable\",\n cause\n }))\n }\n if (body.byteLength > limits.request) {\n // Refused before an helper exists: an over-limit request is caller\n // input, and nothing about it improves by being sent.\n return Effect.fail(PlatformError.badArgument({\n module: Protocol.moduleName,\n method: request.operation,\n description: `atomic request of ${body.byteLength} bytes exceeds the ${limits.request} byte limit`\n }))\n }\n let executable: string\n try {\n executable = resolveExecutable(options, request.boundaryRoot)\n } catch (cause) {\n return Effect.fail(Protocol.failure(request, cause))\n }\n return Transport.spawnHelper<unknown>(request, executable, Protocol.encode(body, limits), resolved)\n }))\n })\n\nconst resolveExecutable = (options: Pick<Options, \"executable\">, boundaryRoot: string | undefined): string => {\n const configured = process.env.SMITHERS_WORKSPACE_JJ_EXPORT_BINARY\n return options.executable !== undefined\n ? Transport.usableExecutable(options.executable, boundaryRoot)\n : configured === undefined\n ? resolveDefaultExecutable(packageRoot, boundaryRoot, defaultExecutable)\n : resolveConfiguredExecutable(configured, boundaryRoot)\n}\n\n/**\n * The helper this process would start for an atomic operation, resolved exactly\n * as an operation resolves it: `SMITHERS_WORKSPACE_JJ_EXPORT_BINARY`, then the\n * packaged and checkout locations. Nothing is spawned. Throws an {@link AtomicHelperError} whose\n * message names what was searched and how to install the helper when none is\n * usable, so a diagnostic can report it before any operation needs it.\n *\n * @since 1.0.0\n * @category constructors\n */\nexport const resolveHelper = (): string => resolveExecutable({}, undefined)\n\nconst execute = (\n options: Options,\n resolved: Settings | { readonly invalid: unknown }\n): KernelFileSystem.AtomicFileSystem[\"execute\"] => {\n const framed = executeFramed(options, resolved)\n return <R extends KernelFileSystem.AtomicRequest>(request: R) =>\n framed(request) as Effect.Effect<KernelFileSystem.AtomicResult<R>, PlatformError.PlatformError>\n}\n\nconst nativeRealPath = (path: string) =>\n Effect.tryPromise({\n try: () => realpath(path),\n catch: (cause) =>\n Protocol.failure({ operation: \"realPath\", path }, cause, {\n ok: false,\n code: (cause as NodeJS.ErrnoException).code ?? null,\n message: (cause as NodeJS.ErrnoException).message,\n syscall: \"realpath\"\n })\n })\n\n/**\n * A Node filesystem layer carrying the kernel's atomic host extension, built\n * against an explicitly configured helper, byte limits, process ceiling,\n * and helper timeout.\n *\n * Every field of {@link Options} except `executable` is read once, here. The\n * concurrency ceiling is one semaphore for the whole layer rather than one per\n * request, which is the only arrangement that bounds anything.\n *\n * @since 0.1.0\n * @category layers\n */\nexport const layerWith = (options: Options): Layer.Layer<FileSystem.FileSystem> => {\n // Outside the layer body on purpose. Inside it the settings would be read\n // again on every BUILD, so two compositions of the same layer value could\n // enforce two different ceilings out of one mutated object, and each would\n // get a process ceiling of its own instead of sharing one.\n const settings = resolveSettings(options)\n return Layer.effect(\n FileSystem.FileSystem,\n Effect.map(\n // The packaged helper is pinned while the host is built, before any flow\n // can rewrite a workspace-local install of this package.\n Effect.andThen(\n Effect.sync(() => {\n if (options.executable === undefined && process.env.SMITHERS_WORKSPACE_JJ_EXPORT_BINARY === undefined) {\n stagePackaged(packageRoot)\n }\n }),\n FileSystem.FileSystem\n ),\n (fileSystem) =>\n KernelFileSystem.withAtomicFileSystem({\n ...fileSystem,\n // Expand DOS names before pinning roots or opening native watchers.\n realPath: nativeRealPath,\n watch: (path, options) =>\n process.platform !== \"win32\"\n ? fileSystem.watch(path, options)\n : Stream.unwrap(\n nativeRealPath(path).pipe(Effect.map((canonical) => fileSystem.watch(canonical, options)))\n )\n }, {\n noFollowAuthorization: true,\n execute: execute(options, settings),\n identifyRoot: (path) =>\n Effect.tryPromise({\n try: async () => {\n const info = await stat(path, { bigint: true })\n return `${info.dev}:${info.ino}`\n },\n catch: (cause) =>\n Protocol.failure({ operation: \"stat\", path }, cause, {\n ok: false,\n code: (cause as NodeJS.ErrnoException).code ?? null,\n message: (cause as NodeJS.ErrnoException).message,\n syscall: \"stat\"\n })\n }),\n batchLimits: {\n size: \"invalid\" in settings ? defaultLimits.batchSize : settings.limits.batchSize,\n response: \"invalid\" in settings ? defaultLimits.response : settings.limits.response\n },\n contentLimit: \"invalid\" in settings ? defaultLimits.content : settings.limits.content\n })\n )\n ).pipe(Layer.provide(NodeFileSystem.layer))\n}\n\n/** A Node filesystem layer carrying the kernel's atomic host extension.\n *\n * @since 0.1.0\n * @category layers\n */\nexport const layer: Layer.Layer<FileSystem.FileSystem> = layerWith({})\n"]}