reeval 0.22.0 → 0.23.0

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 (346) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +15 -15
  3. package/dist/{adapter-Di9H2etg.js → adapter-Dlq3-4OS.js} +5 -5
  4. package/dist/{adapter-Di9H2etg.js.map → adapter-Dlq3-4OS.js.map} +1 -1
  5. package/dist/{agent-B-6GFDqA.js → agent-OsAfayRf.js} +4 -4
  6. package/dist/{agent-B-6GFDqA.js.map → agent-OsAfayRf.js.map} +1 -1
  7. package/dist/{agents-KBTYhSSh.js → agents-BztvTkfM.js} +15 -15
  8. package/dist/{agents-KBTYhSSh.js.map → agents-BztvTkfM.js.map} +1 -1
  9. package/dist/{app-files-Cmh9FGr5.js → app-files-6NHzghym.js} +3 -3
  10. package/dist/app-files-6NHzghym.js.map +1 -0
  11. package/dist/{assemble-DNVBTBp_.js → assemble-Doa1m-HW.js} +14 -13
  12. package/dist/{assemble-DNVBTBp_.js.map → assemble-Doa1m-HW.js.map} +1 -1
  13. package/dist/{assemble-CBMRIhso.js → assemble-XrZskSNj.js} +1 -1
  14. package/dist/{attach-EbDGKGTO.js → attach-BH2HdwH_.js} +71 -4
  15. package/dist/attach-BH2HdwH_.js.map +1 -0
  16. package/dist/{attempt-host-DQvynDHk.js → attempt-host-8mQV8Uee.js} +6 -6
  17. package/dist/{attempt-host-DQvynDHk.js.map → attempt-host-8mQV8Uee.js.map} +1 -1
  18. package/dist/boat-DKRH0Gv7.js +1 -0
  19. package/dist/boat-DKjqo_ie.js +704 -0
  20. package/dist/boat-DKjqo_ie.js.map +1 -0
  21. package/dist/boat-images-CRN_U_eG.js +366 -0
  22. package/dist/boat-images-CRN_U_eG.js.map +1 -0
  23. package/dist/{bundle-DZstHDeW.js → bundle-DU2aQVeq.js} +95 -33
  24. package/dist/bundle-DU2aQVeq.js.map +1 -0
  25. package/dist/{capture-BkbPsfej.js → capture-By1byHaX.js} +43 -21
  26. package/dist/capture-By1byHaX.js.map +1 -0
  27. package/dist/capture-BzjNv0qP.js +1 -0
  28. package/dist/{cli-BgBBuxxJ.js → cli-DMHOwdVr.js} +374 -121
  29. package/dist/cli-DMHOwdVr.js.map +1 -0
  30. package/dist/{cli-spec-B5L9n-DV.js → cli-spec-D0wuUaj9.js} +98 -42
  31. package/dist/cli-spec-D0wuUaj9.js.map +1 -0
  32. package/dist/cli.js +2 -2
  33. package/dist/{client-DMEYR3MA.js → client-B41UK150.js} +2 -2
  34. package/dist/{client-DMEYR3MA.js.map → client-B41UK150.js.map} +1 -1
  35. package/dist/{command-BKb8eN_X.js → command-8GIHYGZf.js} +9 -9
  36. package/dist/{command-BKb8eN_X.js.map → command-8GIHYGZf.js.map} +1 -1
  37. package/dist/{command-D_w_kDpI.js → command-CAmnWLFL.js} +14 -14
  38. package/dist/{command-D_w_kDpI.js.map → command-CAmnWLFL.js.map} +1 -1
  39. package/dist/{command-loXH2jHr.js → command-CXxckfsq.js} +12 -12
  40. package/dist/{command-loXH2jHr.js.map → command-CXxckfsq.js.map} +1 -1
  41. package/dist/{command-Dwlh0Vhu.js → command-ao0NZ8h0.js} +14 -14
  42. package/dist/{command-Dwlh0Vhu.js.map → command-ao0NZ8h0.js.map} +1 -1
  43. package/dist/{commands-Dqli45sR.js → commands-B3lnIPj5.js} +1 -1
  44. package/dist/{commands-Cuf57OYb.js → commands-ttChCsAy.js} +15 -15
  45. package/dist/{commands-Cuf57OYb.js.map → commands-ttChCsAy.js.map} +1 -1
  46. package/dist/{config-C0RKt00M.js → config-myJT1Qjc.js} +25 -16
  47. package/dist/config-myJT1Qjc.js.map +1 -0
  48. package/dist/{context-DrEAtUyg.js → context-DnzR9TNK.js} +2 -2
  49. package/dist/{context-DrEAtUyg.js.map → context-DnzR9TNK.js.map} +1 -1
  50. package/dist/cost-CdRX1s2p.js +1 -0
  51. package/dist/{cursor-catalog-CRsFxorF.js → cursor-catalog-CUQrabJ_.js} +2 -2
  52. package/dist/{cursor-catalog-CRsFxorF.js.map → cursor-catalog-CUQrabJ_.js.map} +1 -1
  53. package/dist/daytona-Dfhwtr9P.js +677 -0
  54. package/dist/daytona-Dfhwtr9P.js.map +1 -0
  55. package/dist/daytona-image-CnG6G00x.js +183 -0
  56. package/dist/daytona-image-CnG6G00x.js.map +1 -0
  57. package/dist/daytona-image-yJK3c4EV.js +1 -0
  58. package/dist/{db-ErnJ-gMD.js → db-5H95sFii.js} +7 -7
  59. package/dist/{db-ErnJ-gMD.js.map → db-5H95sFii.js.map} +1 -1
  60. package/dist/db-Bbg1n_2M.js +2 -0
  61. package/dist/{default-effort-DHzj84dD.js → default-effort-CtNY9CGW.js} +1 -1
  62. package/dist/{default-effort-D70cTG00.js → default-effort-DYpCkJRk.js} +2 -2
  63. package/dist/{default-effort-D70cTG00.js.map → default-effort-DYpCkJRk.js.map} +1 -1
  64. package/dist/{docker-CFWzZOEk.js → docker-CR0JZ1FE.js} +2 -2
  65. package/dist/{docker-CFWzZOEk.js.map → docker-CR0JZ1FE.js.map} +1 -1
  66. package/dist/docker-kpudeSxV.js +1 -0
  67. package/dist/{doctor-B7utCSdh.js → doctor-aE-RMbB_.js} +25 -20
  68. package/dist/doctor-aE-RMbB_.js.map +1 -0
  69. package/dist/{environment-C0Gg8kyN.js → environment-C8pUCD_A.js} +137 -52
  70. package/dist/environment-C8pUCD_A.js.map +1 -0
  71. package/dist/{errors-C1GBcWE2.js → errors-DPUoUTdK.js} +2 -2
  72. package/dist/{errors-C1GBcWE2.js.map → errors-DPUoUTdK.js.map} +1 -1
  73. package/dist/{eval-source-CsW5VIXS.js → eval-source-CaLIGH3U.js} +5 -5
  74. package/dist/{eval-source-CsW5VIXS.js.map → eval-source-CaLIGH3U.js.map} +1 -1
  75. package/dist/{evaluate-BHQyAszQ.js → evaluate-4kBVtwZZ.js} +37 -28
  76. package/dist/evaluate-4kBVtwZZ.js.map +1 -0
  77. package/dist/{evaluate-DzHq4EsU.d.ts → evaluate-DHaNtgVf.d.ts} +2 -2
  78. package/dist/events-CXxFvVMK.js +475 -0
  79. package/dist/events-CXxFvVMK.js.map +1 -0
  80. package/dist/{fake-bootstrap-VpisF1WE.js → fake-bootstrap-CzxrCqO3.js} +2 -2
  81. package/dist/{fake-bootstrap-VpisF1WE.js.map → fake-bootstrap-CzxrCqO3.js.map} +1 -1
  82. package/dist/files-BFnkOAhn.js +1 -0
  83. package/dist/files-BgQxoDlN.js +1 -0
  84. package/dist/{files-Cv856jLN.js → files-BkvxIqfI.js} +4 -4
  85. package/dist/{files-Cv856jLN.js.map → files-BkvxIqfI.js.map} +1 -1
  86. package/dist/{files-g1watgRC.js → files-CDfG8swM.js} +2 -2
  87. package/dist/{files-g1watgRC.js.map → files-CDfG8swM.js.map} +1 -1
  88. package/dist/files-CSe4VaMj.js +1 -0
  89. package/dist/{files-qjeqXnfE.js → files-CX_mmvCc.js} +6 -6
  90. package/dist/{files-qjeqXnfE.js.map → files-CX_mmvCc.js.map} +1 -1
  91. package/dist/{files-BrGVs4gY.js → files-Cs2dtb7-.js} +2 -2
  92. package/dist/{files-BrGVs4gY.js.map → files-Cs2dtb7-.js.map} +1 -1
  93. package/dist/{files-CAzVG3Rr.js → files-D6M7J3iX.js} +1 -1
  94. package/dist/{files-BuKWZCzY.js → files-DgHeTdCZ.js} +5 -5
  95. package/dist/{files-BuKWZCzY.js.map → files-DgHeTdCZ.js.map} +1 -1
  96. package/dist/{files-BCraBodb.js → files-DpwJW3w6.js} +3 -3
  97. package/dist/{files-BCraBodb.js.map → files-DpwJW3w6.js.map} +1 -1
  98. package/dist/gateway.d.ts +1 -1
  99. package/dist/{git-DOrOtAiD.js → git-BnnNEXqh.js} +2 -2
  100. package/dist/{git-DOrOtAiD.js.map → git-BnnNEXqh.js.map} +1 -1
  101. package/dist/{harness-install-Dxho1yaU.js → harness-install-BfMBYDfP.js} +3 -3
  102. package/dist/{harness-install-Dxho1yaU.js.map → harness-install-BfMBYDfP.js.map} +1 -1
  103. package/dist/harness.d.ts +1 -1
  104. package/dist/hosted-5Zz2peTR.js +260 -0
  105. package/dist/hosted-5Zz2peTR.js.map +1 -0
  106. package/dist/hosted-Co-waHe0.js +131 -0
  107. package/dist/hosted-Co-waHe0.js.map +1 -0
  108. package/dist/hosted-run-202QicZ-.js +1 -0
  109. package/dist/hosted-run-BfAPIMyT.js +230 -0
  110. package/dist/hosted-run-BfAPIMyT.js.map +1 -0
  111. package/dist/{ids-B-JKTCP8.js → ids-a6cr243_.js} +17 -12
  112. package/dist/ids-a6cr243_.js.map +1 -0
  113. package/dist/{images-Ch1y1t6_.js → images-DtXwj2wL.js} +13 -12
  114. package/dist/images-DtXwj2wL.js.map +1 -0
  115. package/dist/index.d.ts +2 -2
  116. package/dist/index.js +5 -5
  117. package/dist/init-BiL6B3S4.js +1 -0
  118. package/dist/{init-C2HqCwnt.js → init-Ci_IAp8p.js} +4 -4
  119. package/dist/{init-C2HqCwnt.js.map → init-Ci_IAp8p.js.map} +1 -1
  120. package/dist/{ink-list-BbKXElcQ.js → ink-list-Dnh6XD3C.js} +2 -2
  121. package/dist/{ink-list-BbKXElcQ.js.map → ink-list-Dnh6XD3C.js.map} +1 -1
  122. package/dist/{inputs-load-CGPyigMC.js → inputs-load-DPUP_IFL.js} +2 -2
  123. package/dist/{inputs-load-CGPyigMC.js.map → inputs-load-DPUP_IFL.js.map} +1 -1
  124. package/dist/inputs-load-M-BGe7gd.js +1 -0
  125. package/dist/{inputs-5UIDpjz-.js → inputs-z4JqnQ5g.js} +6 -6
  126. package/dist/{inputs-5UIDpjz-.js.map → inputs-z4JqnQ5g.js.map} +1 -1
  127. package/dist/internal/vm.d.ts +16 -0
  128. package/dist/internal/vm.js +22 -0
  129. package/dist/internal/vm.js.map +1 -0
  130. package/dist/{invocations-BrZAMuTb.js → invocations-C1gY3E0J.js} +3 -3
  131. package/dist/{invocations-BrZAMuTb.js.map → invocations-C1gY3E0J.js.map} +1 -1
  132. package/dist/{jiti-radm1Soi.js → jiti-ILwyxt93.js} +3 -1
  133. package/dist/{jiti-radm1Soi.js.map → jiti-ILwyxt93.js.map} +1 -1
  134. package/dist/judge.d.ts +1 -1
  135. package/dist/kinds-DEKXOWVJ.js +592 -0
  136. package/dist/kinds-DEKXOWVJ.js.map +1 -0
  137. package/dist/{layout-Czh5wOpz.js → layout-nCnU9Vu2.js} +2 -2
  138. package/dist/{layout-Czh5wOpz.js.map → layout-nCnU9Vu2.js.map} +1 -1
  139. package/dist/{list-B_C0k5ex.js → list-MK4L8tfW.js} +4 -4
  140. package/dist/{list-B_C0k5ex.js.map → list-MK4L8tfW.js.map} +1 -1
  141. package/dist/{live-DgFm0H90.js → live-BkPNXVmN.js} +7 -7
  142. package/dist/{live-DgFm0H90.js.map → live-BkPNXVmN.js.map} +1 -1
  143. package/dist/{live-DGgIrVw0.js → live-Dlq-S2yy.js} +2 -2
  144. package/dist/{live-DGgIrVw0.js.map → live-Dlq-S2yy.js.map} +1 -1
  145. package/dist/live-gZtkBwuo.js +1 -0
  146. package/dist/{machine-service-2lIv5UWF.js → machine-service-Byl0BlcT.js} +1 -1
  147. package/dist/{machine-service-Ct_1XMMi.js → machine-service-CZiXiVsS.js} +286 -97
  148. package/dist/machine-service-CZiXiVsS.js.map +1 -0
  149. package/dist/machines-Ch5bhgvk.js +279 -0
  150. package/dist/machines-Ch5bhgvk.js.map +1 -0
  151. package/dist/model-C6aoJLg_.js +1 -0
  152. package/dist/{model-E5X8YBJM.js → model-CRh8aiYS.js} +2 -2
  153. package/dist/{model-E5X8YBJM.js.map → model-CRh8aiYS.js.map} +1 -1
  154. package/dist/{model-DF77SgZv.js → model-LoLnq9y1.js} +2 -2
  155. package/dist/{model-DF77SgZv.js.map → model-LoLnq9y1.js.map} +1 -1
  156. package/dist/{model-B1tdv9-d.js → model-lLaUxxno.js} +1 -1
  157. package/dist/{node-BjuhqQwa.js → node-BQjSQw0d.js} +4 -4
  158. package/dist/{node-BjuhqQwa.js.map → node-BQjSQw0d.js.map} +1 -1
  159. package/dist/options-I9I3FwMl.js +1 -0
  160. package/dist/{patch-BR8rdl7r.js → patch-D8X6VB-e.js} +2 -2
  161. package/dist/{patch-BR8rdl7r.js.map → patch-D8X6VB-e.js.map} +1 -1
  162. package/dist/{plan-BcT4G5jj.js → plan-DgIVIrXJ.js} +7 -7
  163. package/dist/{plan-BcT4G5jj.js.map → plan-DgIVIrXJ.js.map} +1 -1
  164. package/dist/{plugins-cC0sqoDA.js → plugins-DvEbow6a.js} +6 -595
  165. package/dist/plugins-DvEbow6a.js.map +1 -0
  166. package/dist/{preflight-DySHXeFJ.js → preflight-BKGbxN67.js} +8 -7
  167. package/dist/preflight-BKGbxN67.js.map +1 -0
  168. package/dist/{preflight-C9OtTb7k.js → preflight-Qm4wE094.js} +9 -4
  169. package/dist/preflight-Qm4wE094.js.map +1 -0
  170. package/dist/preflight-dJqs5x3r.js +1 -0
  171. package/dist/preflight-fyV5nnea.js +1 -0
  172. package/dist/{prepare-nbX1CXXg.js → prepare-BAjRSoku.js} +19 -39
  173. package/dist/prepare-BAjRSoku.js.map +1 -0
  174. package/dist/prepare-CRPPfRJf.js +2 -0
  175. package/dist/prices-C0gKS_8G.js +1 -0
  176. package/dist/{prices-BrY_ihLs.js → prices-DCokI_Ka.js} +3 -3
  177. package/dist/{prices-BrY_ihLs.js.map → prices-DCokI_Ka.js.map} +1 -1
  178. package/dist/{provenance-CkykifD9.js → provenance-CSyRCc9B.js} +3 -3
  179. package/dist/{provenance-CkykifD9.js.map → provenance-CSyRCc9B.js.map} +1 -1
  180. package/dist/{providers-bNgfKa6m.js → providers-DkaEJvF5.js} +173 -31
  181. package/dist/providers-DkaEJvF5.js.map +1 -0
  182. package/dist/providers-DxZ26YoG.js +1 -0
  183. package/dist/{query-DhV3a8lM.js → query-BL66BOqL.js} +2 -2
  184. package/dist/{query-DhV3a8lM.js.map → query-BL66BOqL.js.map} +1 -1
  185. package/dist/query-C9OKU1Vz.js +1 -0
  186. package/dist/{questions-Csv64WCb.js → questions-boVPzGoC.js} +5 -5
  187. package/dist/{questions-Csv64WCb.js.map → questions-boVPzGoC.js.map} +1 -1
  188. package/dist/recipe-qyIpP96r.js +128 -0
  189. package/dist/recipe-qyIpP96r.js.map +1 -0
  190. package/dist/{record--vHreTLk.js → record-D1_D1KFY.js} +5 -3
  191. package/dist/record-D1_D1KFY.js.map +1 -0
  192. package/dist/{remarks-CYFOsnz5.js → remarks-DEvk5f8v.js} +7 -7
  193. package/dist/{remarks-CYFOsnz5.js.map → remarks-DEvk5f8v.js.map} +1 -1
  194. package/dist/{remote-0CHog7Oq.js → remote-CQoBRpOv.js} +5 -5
  195. package/dist/{remote-0CHog7Oq.js.map → remote-CQoBRpOv.js.map} +1 -1
  196. package/dist/resolve-BdpO8BN1.js +1 -0
  197. package/dist/{resolve-Bul8lHaa.js → resolve-Bfo8sjd-.js} +2 -2
  198. package/dist/{resolve-Bul8lHaa.js.map → resolve-Bfo8sjd-.js.map} +1 -1
  199. package/dist/{resolve-DorSHDBs.js → resolve-D2RqmybX.js} +8 -8
  200. package/dist/{resolve-DorSHDBs.js.map → resolve-D2RqmybX.js.map} +1 -1
  201. package/dist/{results-DhMgRkR0.js → results-BpxzyoMd.js} +5 -5
  202. package/dist/{results-DhMgRkR0.js.map → results-BpxzyoMd.js.map} +1 -1
  203. package/dist/{resume-C8Ihfy-C.js → resume-2ekm_9OB.js} +5 -5
  204. package/dist/{resume-C8Ihfy-C.js.map → resume-2ekm_9OB.js.map} +1 -1
  205. package/dist/{retry-Bfk7pDti.js → retry-CAhpW1hH.js} +4 -4
  206. package/dist/{retry-Bfk7pDti.js.map → retry-CAhpW1hH.js.map} +1 -1
  207. package/dist/{runtime-CPUH0Vk5.js → runtime-C5fKSFCz.js} +4 -4
  208. package/dist/{runtime-CPUH0Vk5.js.map → runtime-C5fKSFCz.js.map} +1 -1
  209. package/dist/sandbox/boat.d.ts +11 -3
  210. package/dist/sandbox/boat.js +18 -4
  211. package/dist/sandbox/boat.js.map +1 -1
  212. package/dist/sandbox/daytona.d.ts +30 -0
  213. package/dist/sandbox/daytona.js +49 -0
  214. package/dist/sandbox/daytona.js.map +1 -0
  215. package/dist/{sandbox-z8q_4Ywn.js → sandbox-t-Q-8lA_.js} +2 -2
  216. package/dist/{sandbox-z8q_4Ywn.js.map → sandbox-t-Q-8lA_.js.map} +1 -1
  217. package/dist/sandbox.d.ts +1 -1
  218. package/dist/sandbox.js +1 -1
  219. package/dist/{server-BsQZtuF9.js → server-BcLg9WzE.js} +10 -10
  220. package/dist/{server-BsQZtuF9.js.map → server-BcLg9WzE.js.map} +1 -1
  221. package/dist/server-Buav2-CG.js +1 -0
  222. package/dist/{source-9HWaTEgV.js → source-CrXM19HD.js} +2 -2
  223. package/dist/{source-9HWaTEgV.js.map → source-CrXM19HD.js.map} +1 -1
  224. package/dist/source-dvxkqYvk.js +1 -0
  225. package/dist/{src-CotUxxQV.js → src-5dCrqbFd.js} +1 -1
  226. package/dist/{src-boB6D-5T.js → src-Bf5RZlPi.js} +2 -2
  227. package/dist/{src-boB6D-5T.js.map → src-Bf5RZlPi.js.map} +1 -1
  228. package/dist/{src-CWfy8ct8.js → src-C5rrQlt8.js} +1107 -382
  229. package/dist/src-C5rrQlt8.js.map +1 -0
  230. package/dist/{src-BuGc40IF.js → src-C6MsGyD6.js} +1 -1
  231. package/dist/{src-C2K5_afU.js → src-Cf4vRyea.js} +1 -1
  232. package/dist/src-DEbNp-rx.js +1 -0
  233. package/dist/{src-D-PwBaBB.js → src-DrLbG1HM.js} +1 -1
  234. package/dist/{src-CcrQQB0_.js → src-Ds1pmXTg.js} +1 -1
  235. package/dist/{src-CSVJjghq.js → src-DwcCKsV0.js} +2 -2
  236. package/dist/{src-B2eHTCnp.js → src-VG2IRoT4.js} +1 -1
  237. package/dist/{src-BfOlH_Bu.js → src-io_SKoZ5.js} +1 -1
  238. package/dist/ssh-pool-BorCizYw.js +1 -0
  239. package/dist/ssh-pool-Dvfx5GuV.js +174 -0
  240. package/dist/ssh-pool-Dvfx5GuV.js.map +1 -0
  241. package/dist/{start-Db5VRcRZ.js → start-COB07NpH.js} +126 -68
  242. package/dist/start-COB07NpH.js.map +1 -0
  243. package/dist/{state-DUYdzNA7.js → state-B319V1p8.js} +5 -5
  244. package/dist/{state-DUYdzNA7.js.map → state-B319V1p8.js.map} +1 -1
  245. package/dist/state-C5oBvmoZ.js +1 -0
  246. package/dist/store/local.d.ts +1 -1
  247. package/dist/store/s3.d.ts +1 -1
  248. package/dist/suite-BwJGOhCZ.js +2 -0
  249. package/dist/{suite-DjGxmDSY.js → suite-D1tgXZxM.js} +2 -2
  250. package/dist/{suite-DjGxmDSY.js.map → suite-D1tgXZxM.js.map} +1 -1
  251. package/dist/{summary-BK5Sa_N0.js → summary-ClLns_wv.js} +5 -5
  252. package/dist/{summary-BK5Sa_N0.js.map → summary-ClLns_wv.js.map} +1 -1
  253. package/dist/{sync-DUi_P2UJ.js → sync-mOG74RXH.js} +5 -5
  254. package/dist/{sync-DUi_P2UJ.js.map → sync-mOG74RXH.js.map} +1 -1
  255. package/dist/{tart-BQ_Ap0l4.js → tart-DMppfbEm.js} +7 -6
  256. package/dist/{tart-BQ_Ap0l4.js.map → tart-DMppfbEm.js.map} +1 -1
  257. package/dist/{tart-bake-D1RttYfM.js → tart-bake-Cva_qdir.js} +7 -7
  258. package/dist/{tart-bake-D1RttYfM.js.map → tart-bake-Cva_qdir.js.map} +1 -1
  259. package/dist/{tart-bake-DjFcsG3N.js → tart-bake-DVIoXWr_.js} +1 -1
  260. package/dist/{tart-cli-BOcluha1.js → tart-cli-D88c5YYJ.js} +1 -1
  261. package/dist/{tart-cli-gA9xEaQL.js → tart-cli-LzDud2Z6.js} +2 -2
  262. package/dist/{tart-cli-gA9xEaQL.js.map → tart-cli-LzDud2Z6.js.map} +1 -1
  263. package/dist/{tart-hosts-CWse-ASo.js → tart-hosts-8N6Tt7Yb.js} +1 -1
  264. package/dist/{tart-hosts-CHNrfV6u.js → tart-hosts-CTRY5kQ2.js} +3 -3
  265. package/dist/{tart-hosts-CHNrfV6u.js.map → tart-hosts-CTRY5kQ2.js.map} +1 -1
  266. package/dist/{tart-images-CLBjfF9u.js → tart-images-JfHirU8W.js} +2 -2
  267. package/dist/{tart-images-CLBjfF9u.js.map → tart-images-JfHirU8W.js.map} +1 -1
  268. package/dist/testing.d.ts +2 -2
  269. package/dist/testing.js +4 -4
  270. package/dist/{tool-class-krsmEo44.js → tool-class-CncfCw03.js} +2 -2
  271. package/dist/{tool-class-krsmEo44.js.map → tool-class-CncfCw03.js.map} +1 -1
  272. package/dist/{types-DKK8jj--.d.ts → types-BDo8ttQo.d.ts} +157 -17
  273. package/dist/{ui-DKYjTVpn.js → ui-DUiVPbQ2.js} +53 -484
  274. package/dist/ui-DUiVPbQ2.js.map +1 -0
  275. package/dist/view/index.d.ts +1 -1
  276. package/dist/view/index.js +4 -4
  277. package/dist/views-B0qZR5Ef.js +2 -0
  278. package/dist/{views-B1zVLJsF.js → views-CiZGh3ws.js} +6 -6
  279. package/dist/{views-B1zVLJsF.js.map → views-CiZGh3ws.js.map} +1 -1
  280. package/dist/vm-container-BVn7pXfD.js +148 -0
  281. package/dist/vm-container-BVn7pXfD.js.map +1 -0
  282. package/dist/vm-images-CNk-Zl2a.js +375 -0
  283. package/dist/vm-images-CNk-Zl2a.js.map +1 -0
  284. package/dist/{worker-entry-DrAYYt0M.js → worker-entry-DmXQ2Znu.js} +5 -5
  285. package/dist/{worker-entry-DrAYYt0M.js.map → worker-entry-DmXQ2Znu.js.map} +1 -1
  286. package/dist/workspace-CRgFdmgW.js +1 -0
  287. package/dist/{workspace-DwTe1zo6.js → workspace-wwvwEHzP.js} +5 -5
  288. package/dist/{workspace-DwTe1zo6.js.map → workspace-wwvwEHzP.js.map} +1 -1
  289. package/package.json +14 -2
  290. package/skills/reeval/references/environments.md +4 -3
  291. package/dist/app-files-Cmh9FGr5.js.map +0 -1
  292. package/dist/attach-EbDGKGTO.js.map +0 -1
  293. package/dist/boat-Bzz8L-KQ.js +0 -701
  294. package/dist/boat-Bzz8L-KQ.js.map +0 -1
  295. package/dist/boat-Dek8ftIt.js +0 -120
  296. package/dist/boat-Dek8ftIt.js.map +0 -1
  297. package/dist/bundle-DZstHDeW.js.map +0 -1
  298. package/dist/capture-BkbPsfej.js.map +0 -1
  299. package/dist/capture-CUAvk9KM.js +0 -1
  300. package/dist/cli-BgBBuxxJ.js.map +0 -1
  301. package/dist/cli-spec-B5L9n-DV.js.map +0 -1
  302. package/dist/config-C0RKt00M.js.map +0 -1
  303. package/dist/cost-IM80LyGD.js +0 -1
  304. package/dist/db-3o8s2EyD.js +0 -2
  305. package/dist/docker-DrMnpL84.js +0 -1
  306. package/dist/doctor-B7utCSdh.js.map +0 -1
  307. package/dist/environment-C0Gg8kyN.js.map +0 -1
  308. package/dist/evaluate-BHQyAszQ.js.map +0 -1
  309. package/dist/files-BjOJw4sn.js +0 -1
  310. package/dist/files-D-Lir4aE.js +0 -1
  311. package/dist/files-DRlJ0Xr2.js +0 -1
  312. package/dist/ids-B-JKTCP8.js.map +0 -1
  313. package/dist/images-Ch1y1t6_.js.map +0 -1
  314. package/dist/init-CM9xwyre.js +0 -1
  315. package/dist/inputs-load-C82HOKnb.js +0 -1
  316. package/dist/live-C9Et_BVT.js +0 -1
  317. package/dist/machine-service-Ct_1XMMi.js.map +0 -1
  318. package/dist/machines-BnquHcBZ.js +0 -120
  319. package/dist/machines-BnquHcBZ.js.map +0 -1
  320. package/dist/model-Bcy4Qjmm.js +0 -1
  321. package/dist/options-C989kuVE.js +0 -1
  322. package/dist/plugins-cC0sqoDA.js.map +0 -1
  323. package/dist/preflight-BMVDBcux.js +0 -1
  324. package/dist/preflight-C9OtTb7k.js.map +0 -1
  325. package/dist/preflight-DySHXeFJ.js.map +0 -1
  326. package/dist/preflight-zsAn3heN.js +0 -1
  327. package/dist/prepare-MaRWRhNT.js +0 -2
  328. package/dist/prepare-nbX1CXXg.js.map +0 -1
  329. package/dist/prices-B1vm_lPk.js +0 -1
  330. package/dist/providers-BkLGzaSY.js +0 -1
  331. package/dist/providers-bNgfKa6m.js.map +0 -1
  332. package/dist/query-B2SQddoV.js +0 -1
  333. package/dist/record--vHreTLk.js.map +0 -1
  334. package/dist/resolve-Bm9ZyFR-.js +0 -1
  335. package/dist/server-ZaMzUNmV.js +0 -1
  336. package/dist/source-BcBDj-R0.js +0 -1
  337. package/dist/src-CWfy8ct8.js.map +0 -1
  338. package/dist/src-jYqNkT-F.js +0 -1
  339. package/dist/start-Db5VRcRZ.js.map +0 -1
  340. package/dist/state-CKIjZZRK.js +0 -1
  341. package/dist/suite-CH1aaAbs.js +0 -2
  342. package/dist/tarball-C8BSTAMk.js +0 -257
  343. package/dist/tarball-C8BSTAMk.js.map +0 -1
  344. package/dist/ui-DKYjTVpn.js.map +0 -1
  345. package/dist/views-DCjtw1jF.js +0 -2
  346. package/dist/workspace-CnRbV8cM.js +0 -1
@@ -1,13 +1,14 @@
1
1
  import { u as ownFileURL } from "./root-BzeoyfGd.js";
2
- import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, renameSync, writeFileSync } from "node:fs";
3
- import { basename, dirname, join, posix, relative, win32 } from "node:path";
2
+ import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, renameSync, statSync, writeFileSync } from "node:fs";
3
+ import { basename, dirname, isAbsolute, join, posix, relative, resolve, sep, win32 } from "node:path";
4
4
  import { execFileSync, spawn } from "node:child_process";
5
5
  import { createHash, generateKeyPairSync, randomBytes, randomInt, sign } from "node:crypto";
6
6
  import { tmpdir } from "node:os";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import { createHarnessSandboxTemplate } from "@ai-sdk/harness/agent";
9
- import { isUtf8 } from "node:buffer";
10
9
  import dockerignore from "@balena/dockerignore";
10
+ import { lstat, mkdir, readFile, readdir, readlink, symlink, utimes, writeFile } from "node:fs/promises";
11
+ import { isUtf8 } from "node:buffer";
11
12
  import { Duplex, Readable, Transform } from "node:stream";
12
13
  import net, { BlockList, isIP } from "node:net";
13
14
  import http from "node:http";
@@ -17,6 +18,7 @@ import tls from "node:tls";
17
18
  import zlib from "node:zlib";
18
19
  import { lookup } from "node:dns/promises";
19
20
  // ../sandbox-docker/src/engine.ts
21
+ const isRemoteEngine = (engine) => typeof engine === "object";
20
22
  /**
21
23
  * Docker's default seccomp profile, copied unmodified from moby/profiles (Apache-2.0),
22
24
  * seccomp/default.json at 6fe7deb1b9fb7c0397a4593480d7d22b9ee8caef. Podman gets it on every
@@ -75,7 +77,8 @@ const ENGINES = {
75
77
  createsWorkdir: false
76
78
  }
77
79
  };
78
- const engineSpec = (engine = "docker") => ENGINES[engine];
80
+ /** A remote engine is Docker's CLI, as on this machine. */
81
+ const engineSpec = (engine = "docker") => ENGINES[isRemoteEngine(engine) ? "docker" : engine];
79
82
  /**
80
83
  * The `CONTAINER_HOST` that reaches a `podman machine` straight through its API socket (macOS) or
81
84
  * named pipe (Windows), from `podman machine inspect`'s JSON.
@@ -364,6 +367,631 @@ function run(cmd, args, options = {}) {
364
367
  child.stdin.end(options.input ?? "");
365
368
  });
366
369
  }
370
+ // ../sandbox-docker/src/dockerignore.ts
371
+ const ignore = dockerignore.default;
372
+ /**
373
+ * A pattern `@balena/dockerignore` may match differently from BuildKit: escapes, character
374
+ * classes and the regexp characters it doesn't escape, a `**` joined to other characters, and the
375
+ * whitespace Go and JavaScript trim differently. One over 1024 characters is risky too, since
376
+ * JavaScript refuses a regexp that long that Go accepts, and so is one with more than four `*`
377
+ * runs, whose JavaScript regexp can backtrack for minutes where Go's runs in linear time.
378
+ */
379
+ const RISKY = /[\\[\]^+(){}|\u0085\uFEFF]|[^/]\*\*|\*\*[^/]/;
380
+ const MAX_STARS = 4;
381
+ /**
382
+ * Names `@balena/dockerignore` may match differently: `?` matches one UTF-16 unit there and one
383
+ * code point in BuildKit, and `.` doesn't match a line terminator there but does in Go.
384
+ */
385
+ const ODD_NAME = /[\n\r\u2028\u2029\u{10000}-\u{10FFFF}]/u;
386
+ const clean = (pattern) => posix.normalize(pattern).replace(/^\/+/, "").replace(/\/+$/, "");
387
+ /**
388
+ * `.dockerignore` lines as Docker reads them: a BOM is dropped, a line starting `#` is a comment,
389
+ * and `!` re-includes. A path is left out when a rule excludes it and no `!` rule matches it or a
390
+ * directory it's in: BuildKit then excludes it whatever order the rules are in, so this never
391
+ * leaves out a file `docker build` sends, though it keeps some it doesn't. A risky exclusion is
392
+ * dropped, and a risky `!` rule keeps everything, as does one `@balena/dockerignore` would read
393
+ * as a comment or a pattern that cleans to a leading `!` (`!!a`, `/ !a`), which the two read
394
+ * differently.
395
+ */
396
+ function parseRules(text) {
397
+ const excludes = [];
398
+ const reincludes = [];
399
+ for (const line of text.replace(/^\uFEFF/, "").split(/\r?\n/)) {
400
+ if (line.startsWith("#")) continue;
401
+ let pattern = line.trim();
402
+ const negate = pattern.startsWith("!");
403
+ if (negate) pattern = pattern.slice(1).trim();
404
+ if (!pattern) continue;
405
+ const cleaned = clean(pattern);
406
+ const risky = RISKY.test(pattern) || pattern.length > 1024 || (pattern.match(/\*+/g)?.length ?? 0) > MAX_STARS || [".", ""].includes(cleaned);
407
+ if (cleaned.trim().startsWith("!") || negate && pattern.startsWith("#") || negate && risky) return {
408
+ left: () => false,
409
+ literal: null
410
+ };
411
+ if (!negate) {
412
+ if (!risky) excludes.push(line);
413
+ } else reincludes.push(pattern);
414
+ }
415
+ const exclude = ignore({ ignorecase: false }).add(excludes);
416
+ const reinclude = ignore({ ignorecase: false }).add(reincludes);
417
+ return {
418
+ left: (path) => !ODD_NAME.test(path) && exclude.ignores(path) && !reinclude.ignores(path),
419
+ literal: reincludes.some((p) => /[*?]/.test(p)) ? null : reincludes.map(clean)
420
+ };
421
+ }
422
+ /** Whether reeval leaves `path` out of a hash under these `.dockerignore` rules. */
423
+ function dockerignoreMatcher(text) {
424
+ return parseRules(text).left;
425
+ }
426
+ /**
427
+ * Files in the build context that reeval hashes, sorted, relative to `context`: every file
428
+ * `docker build` sends (and some it doesn't), plus the Dockerfile and `.dockerignore`. A
429
+ * Dockerfile read from stdin (`dockerfile` null) has no `<Dockerfile>.dockerignore` of its own.
430
+ * A left-out directory is skipped only when every `!` rule is a literal path outside it. Docker
431
+ * doesn't apply an ignore file that's a symlink or not a file, so then every file is hashed; nor
432
+ * can it send what's in a directory it can't read.
433
+ */
434
+ function contextFiles(context, dockerfile) {
435
+ const own = [...dockerfile ? [`${dockerfile}.dockerignore`] : [], join(context, ".dockerignore")].map((path) => ({
436
+ path,
437
+ stat: lstatSync(path, { throwIfNoEntry: false })
438
+ })).find(({ stat }) => stat);
439
+ const { left, literal } = parseRules(own?.stat?.isFile() ? readFileSync(own.path, "utf8") : "");
440
+ const always = [...dockerfile ? [relative(context, dockerfile)] : [], ".dockerignore"].map((path) => path.split("\\").join("/"));
441
+ const reach = [...always, ...literal ?? []];
442
+ const files = [];
443
+ const walk = (rel) => {
444
+ let entries;
445
+ try {
446
+ entries = readdirSync(join(context, rel), { withFileTypes: true });
447
+ } catch (error) {
448
+ if (rel && ["EACCES", "EPERM"].includes(error.code ?? "")) return;
449
+ throw error;
450
+ }
451
+ for (const entry of entries) {
452
+ const path = rel ? `${rel}/${entry.name}` : entry.name;
453
+ if (entry.isDirectory()) {
454
+ if (!(left(path) && literal && !reach.some((p) => p.startsWith(`${path}/`)))) walk(path);
455
+ } else if (!left(path) || always.includes(path)) files.push(path);
456
+ }
457
+ };
458
+ walk("");
459
+ return files.sort();
460
+ }
461
+ // ../sandbox-docker/src/tarball.ts
462
+ const BLOCK = 512;
463
+ const text$1 = (b, at, len) => {
464
+ const field = b.subarray(at, at + len);
465
+ const end = field.indexOf(0);
466
+ return (end < 0 ? field : field.subarray(0, end)).toString("utf8");
467
+ };
468
+ function octal(b, at, len) {
469
+ if ((b[at] ?? 0) & 128) {
470
+ let n = (b[at] ?? 0) & 127;
471
+ for (let i = 1; i < len; i++) n = n * 256 + (b[at + i] ?? 0);
472
+ return n;
473
+ }
474
+ const digits = text$1(b, at, len).trim();
475
+ return digits ? Number.parseInt(digits, 8) : 0;
476
+ }
477
+ /** `a/./b/` as `a/b`; null for a path that's absolute, empty or climbs out with `..`. */
478
+ function safeTarPath(path) {
479
+ if (path.startsWith("/") || /^[A-Za-z]:/.test(path) || path.includes("\\")) return null;
480
+ const parts = path.split("/").filter((p) => p !== "" && p !== ".");
481
+ if (!parts.length || parts.includes("..")) return null;
482
+ return parts.join("/");
483
+ }
484
+ function paxRecords(data) {
485
+ const out = {};
486
+ let at = 0;
487
+ while (at < data.length) {
488
+ const space = data.indexOf(32, at);
489
+ if (space < 0) break;
490
+ const len = Number(data.subarray(at, space).toString());
491
+ if (!(len > 0)) break;
492
+ const record = data.subarray(space + 1, at + len - 1).toString("utf8");
493
+ const eq = record.indexOf("=");
494
+ if (eq > 0) out[record.slice(0, eq)] = record.slice(eq + 1);
495
+ at += len;
496
+ }
497
+ return out;
498
+ }
499
+ /** The entries of an uncompressed tar, hard links resolved to copies of what they link to. */
500
+ function readTar(tar) {
501
+ const out = [];
502
+ const files = /* @__PURE__ */ new Map();
503
+ let longName;
504
+ let longLink;
505
+ let pax = {};
506
+ let at = 0;
507
+ while (at + BLOCK <= tar.length) {
508
+ const h = tar.subarray(at, at + BLOCK);
509
+ if (h.every((byte) => byte === 0)) break;
510
+ const type = String.fromCharCode(h[156] ?? 0);
511
+ const size = pax.size !== void 0 ? Number(pax.size) : octal(h, 124, 12);
512
+ if (!Number.isSafeInteger(size) || size < 0) break;
513
+ const data = tar.subarray(at + BLOCK, at + BLOCK + size);
514
+ at += BLOCK + Math.ceil(size / BLOCK) * BLOCK;
515
+ if (type === "L") {
516
+ longName = text$1(data, 0, data.length);
517
+ continue;
518
+ }
519
+ if (type === "K") {
520
+ longLink = text$1(data, 0, data.length);
521
+ continue;
522
+ }
523
+ if (type === "x") {
524
+ pax = {
525
+ ...pax,
526
+ ...paxRecords(data)
527
+ };
528
+ continue;
529
+ }
530
+ if (type === "g") continue;
531
+ const prefix = text$1(h, 257, 6).startsWith("ustar") ? text$1(h, 345, 155) : "";
532
+ const name = text$1(h, 0, 100);
533
+ const raw = pax.path ?? longName ?? (prefix ? `${prefix}/${name}` : name);
534
+ const link = pax.linkpath ?? longLink ?? text$1(h, 157, 100);
535
+ const mtime = pax.mtime !== void 0 ? Math.floor(Number(pax.mtime)) : octal(h, 136, 12);
536
+ longName = longLink = void 0;
537
+ pax = {};
538
+ const path = safeTarPath(raw);
539
+ if (!path) continue;
540
+ const mode = octal(h, 100, 8) & 4095;
541
+ if (type === "0" || type === "\0" || type === "7") {
542
+ const copy = Buffer.from(data);
543
+ files.set(path, copy);
544
+ out.push({
545
+ type: "file",
546
+ path,
547
+ mode,
548
+ mtime,
549
+ data: copy
550
+ });
551
+ } else if (type === "1") {
552
+ const target = safeTarPath(link);
553
+ const linked = target ? files.get(target) : void 0;
554
+ if (linked) out.push({
555
+ type: "file",
556
+ path,
557
+ mode,
558
+ mtime,
559
+ data: linked
560
+ });
561
+ } else if (type === "2") out.push({
562
+ type: "symlink",
563
+ path,
564
+ mode,
565
+ mtime,
566
+ target: link
567
+ });
568
+ else if (type === "5") out.push({
569
+ type: "dir",
570
+ path,
571
+ mode,
572
+ mtime
573
+ });
574
+ }
575
+ return out;
576
+ }
577
+ function paxEntry(fields) {
578
+ const body = Object.entries(fields).map(([k, v]) => {
579
+ const rest = ` ${k}=${v}\n`;
580
+ const restBytes = Buffer.byteLength(rest);
581
+ let len = restBytes + String(restBytes).length;
582
+ if (String(len).length > String(restBytes).length) len = restBytes + String(len).length;
583
+ return `${len}${rest}`;
584
+ }).join("");
585
+ const data = Buffer.from(body);
586
+ return Buffer.concat([header("PaxHeader", 420, data.length, 0, "x", ""), pad(data)]);
587
+ }
588
+ const pad = (data) => Buffer.concat([data, Buffer.alloc((BLOCK - data.length % BLOCK) % BLOCK)]);
589
+ function header(name, mode, size, mtime, type, link) {
590
+ const h = Buffer.alloc(BLOCK);
591
+ const put = (value, at, len) => {
592
+ Buffer.from(value).copy(h, at, 0, Math.min(len, Buffer.byteLength(value)));
593
+ };
594
+ const num = (value, at, len) => put(`${value.toString(8).padStart(len - 1, "0")}\0`, at, len);
595
+ put(name, 0, 100);
596
+ num(mode, 100, 8);
597
+ num(0, 108, 8);
598
+ num(0, 116, 8);
599
+ num(size, 124, 12);
600
+ num(Math.max(0, mtime), 136, 12);
601
+ h.fill(32, 148, 156);
602
+ put(type, 156, 1);
603
+ put(link, 157, 100);
604
+ put("ustar\0", 257, 6);
605
+ put("00", 263, 2);
606
+ let sum = 0;
607
+ for (const byte of h) sum += byte;
608
+ put(`${sum.toString(8).padStart(6, "0")}\0 `, 148, 8);
609
+ return h;
610
+ }
611
+ const fits = (s) => Buffer.byteLength(s) <= 100 && /^[\x20-\x7e]*$/.test(s);
612
+ /** An uncompressed tar of `entries`, with a pax header for a path or link target ustar can't hold. */
613
+ function writeTar(entries) {
614
+ const parts = [];
615
+ for (const e of entries) {
616
+ const name = e.type === "dir" ? `${e.path}/` : e.path;
617
+ const link = e.type === "symlink" ? e.target : "";
618
+ const long = {};
619
+ if (!fits(name)) long.path = name;
620
+ if (!fits(link)) long.linkpath = link;
621
+ if (Object.keys(long).length) parts.push(paxEntry(long));
622
+ const shortName = fits(name) ? name : "long-name";
623
+ const shortLink = fits(link) ? link : "long-link";
624
+ if (e.type === "file") parts.push(header(shortName, e.mode, e.data.length, e.mtime, "0", ""), pad(e.data));
625
+ else parts.push(header(shortName, e.mode, 0, e.mtime, e.type === "dir" ? "5" : "2", shortLink));
626
+ }
627
+ parts.push(Buffer.alloc(BLOCK * 2));
628
+ return Buffer.concat(parts);
629
+ }
630
+ /**
631
+ * Writes `entries` under `dir`, never through a symbolic link: an entry whose parent on disk is a
632
+ * link or a file is skipped, as is one whose path exists already, so nothing lands outside `dir`
633
+ * even where the filesystem folds case. An entry the platform refuses (a name Windows can't hold,
634
+ * a link without the right to make one) is skipped too. Returns the paths it skipped.
635
+ */
636
+ async function extractTar(entries, dir) {
637
+ const root = resolve(dir);
638
+ const skipped = [];
639
+ await mkdir(root, { recursive: true });
640
+ const times = [];
641
+ const parentsAreDirs = async (parts) => {
642
+ let at = root;
643
+ for (const part of parts.slice(0, -1)) {
644
+ at = join(at, part);
645
+ const info = await lstat(at).catch(() => null);
646
+ if (!info) await mkdir(at);
647
+ else if (!info.isDirectory()) return false;
648
+ }
649
+ return true;
650
+ };
651
+ for (const e of entries) {
652
+ const parts = e.path.split("/");
653
+ const target = join(root, ...parts);
654
+ try {
655
+ if (!target.startsWith(root + sep) || !await parentsAreDirs(parts)) {
656
+ skipped.push(e.path);
657
+ continue;
658
+ }
659
+ const existing = await lstat(target).catch(() => null);
660
+ if (e.type === "dir") {
661
+ if (!existing) await mkdir(target);
662
+ else if (!existing.isDirectory()) skipped.push(e.path);
663
+ continue;
664
+ }
665
+ if (existing) {
666
+ skipped.push(e.path);
667
+ continue;
668
+ }
669
+ if (e.type === "symlink") await symlink(e.target, target);
670
+ else {
671
+ await writeFile(target, e.data, {
672
+ mode: e.mode & 511 || 420,
673
+ flag: "wx"
674
+ });
675
+ times.push([target, e.mtime]);
676
+ }
677
+ } catch {
678
+ skipped.push(e.path);
679
+ }
680
+ }
681
+ for (const [path, mtime] of times) await utimes(path, mtime, mtime).catch(() => {});
682
+ return skipped;
683
+ }
684
+ /** The tree under `dir` as entries, in a stable order; a symbolic link is kept as one, never followed. */
685
+ async function readTree(dir, prefix = "") {
686
+ const entries = [];
687
+ for (const name of (await readdir(dir)).sort()) {
688
+ const full = join(dir, name);
689
+ const path = prefix ? `${prefix}/${name}` : name;
690
+ const info = await lstat(full);
691
+ const meta = {
692
+ path,
693
+ mode: info.mode & 4095,
694
+ mtime: Math.floor(info.mtimeMs / 1e3)
695
+ };
696
+ if (info.isSymbolicLink()) entries.push({
697
+ type: "symlink",
698
+ ...meta,
699
+ target: await readlink(full)
700
+ });
701
+ else if (info.isDirectory()) entries.push({
702
+ type: "dir",
703
+ ...meta
704
+ }, ...await readTree(full, path));
705
+ else if (info.isFile()) entries.push({
706
+ type: "file",
707
+ ...meta,
708
+ data: await readFile(full)
709
+ });
710
+ }
711
+ return entries;
712
+ }
713
+ // ../sandbox-docker/src/remote-engine.ts
714
+ /**
715
+ * The remote side of a command with an environment: its first stdin line is the base64 of the
716
+ * `export`s, which `read` takes a byte at a time (stdin is a pipe), so the rest of stdin is the
717
+ * CLI's own.
718
+ */
719
+ const WITH_ENV = "IFS= read -r reeval_env || exit 125; reeval_env=$(printf %s \"$reeval_env\" | base64 -d) || exit 125; eval \"$reeval_env\" || exit 125; unset reeval_env; exec \"$@\"";
720
+ /**
721
+ * How to run the engine's CLI with `args`: the CLI itself here, or ssh to it on a remote engine.
722
+ * `env` reaches the CLI's environment, never argv: on a remote engine it's the {@link
723
+ * EngineCommand.preamble}.
724
+ */
725
+ function hostCommand(engine, args, env = {}) {
726
+ if (!isRemoteEngine(engine)) return {
727
+ bin: engineSpec(engine).bin,
728
+ args: [...args],
729
+ env: {
730
+ ...engineEnv(engine),
731
+ ...env
732
+ },
733
+ preamble: null
734
+ };
735
+ const docker = ["docker", ...args].map(shellQuote).join(" ");
736
+ const names = Object.keys(env);
737
+ for (const name of names) if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) throw new Error(`${name} isn't a variable name`);
738
+ const remote = names.length ? `sh -c ${shellQuote(WITH_ENV)} sh ${docker}` : `exec ${docker}`;
739
+ const [bin = "ssh", ...rest] = sshArgv(engine.target, remote);
740
+ const exports = names.map((name) => `export ${name}=${shellQuote(env[name] ?? "")}`).join("\n");
741
+ return {
742
+ bin,
743
+ args: rest,
744
+ env: {},
745
+ preamble: names.length ? Buffer.from(`${Buffer.from(exports).toString("base64")}\n`) : null
746
+ };
747
+ }
748
+ /**
749
+ * Spawns the engine's CLI with `args` in its own process group, its output piped and no stdin of
750
+ * its own; on a remote engine stdin carries only the environment.
751
+ */
752
+ function spawnEngine(engine, args, env = {}) {
753
+ const command = hostCommand(engine, args, env);
754
+ const child = spawn(command.bin, command.args, {
755
+ stdio: [
756
+ command.preamble ? "pipe" : "ignore",
757
+ "pipe",
758
+ "pipe"
759
+ ],
760
+ detached: true,
761
+ env: {
762
+ ...process.env,
763
+ ...command.env
764
+ }
765
+ });
766
+ if (command.preamble && child.stdin) {
767
+ child.stdin.on("error", () => {});
768
+ child.stdin.end(command.preamble);
769
+ }
770
+ return child;
771
+ }
772
+ const literal = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
773
+ /**
774
+ * ssh failing to connect to `target`, so the remote CLI never ran and running it again is safe:
775
+ * the whole of stderr is ssh's own message naming the machine. A connection that drops later
776
+ * isn't one, since the command may have run, and nor is a remote command that printed the same.
777
+ */
778
+ const isSshFailure = (r, target) => {
779
+ if (r.exitCode !== 255) return false;
780
+ const at = `${literal(target.host)} port ${target.port}`;
781
+ return new RegExp(`^(?:ssh: connect to host ${at}: [^\\n]+|kex_exchange_identification: [^\\n]+\\n(?:Connection (?:closed|reset) by \\S+ port ${target.port}|banner exchange: Connection to \\S+ port ${target.port}: [^\\n]+)|Connection timed out during banner exchange\\nConnection to \\S+ port ${target.port} timed out)$`).test(r.stderr.trim());
782
+ };
783
+ /** Commands that run a container's process, whose output and exit code are that process's. */
784
+ const RUNS_A_PROCESS = /* @__PURE__ */ new Set([
785
+ "exec",
786
+ "run",
787
+ "start",
788
+ "attach"
789
+ ]);
790
+ /** Whether `args` is safe to run again after ssh failed to connect. */
791
+ const retriesSafely = (args) => !RUNS_A_PROCESS.has(args[0] ?? "");
792
+ /** How traces and messages name the engine's CLI. */
793
+ const engineLabel = (engine) => isRemoteEngine(engine) ? `docker on ${engine.description}` : engineSpec(engine).bin;
794
+ /** Option flags of `docker build` that take a value as the next argument. */
795
+ const BUILD_VALUE_FLAGS = /* @__PURE__ */ new Set([
796
+ "--add-host",
797
+ "--allow",
798
+ "--annotation",
799
+ "--attest",
800
+ "--build-arg",
801
+ "--build-context",
802
+ "--builder",
803
+ "--cache-from",
804
+ "--cache-to",
805
+ "--call",
806
+ "--cgroup-parent",
807
+ "--cpu-period",
808
+ "--cpu-quota",
809
+ "--cpu-shares",
810
+ "-c",
811
+ "--cpuset-cpus",
812
+ "--cpuset-mems",
813
+ "--file",
814
+ "-f",
815
+ "--iidfile",
816
+ "--isolation",
817
+ "--label",
818
+ "--memory",
819
+ "-m",
820
+ "--memory-swap",
821
+ "--metadata-file",
822
+ "--network",
823
+ "--no-cache-filter",
824
+ "--output",
825
+ "-o",
826
+ "--platform",
827
+ "--progress",
828
+ "--provenance",
829
+ "--sbom",
830
+ "--secret",
831
+ "--security-opt",
832
+ "--shm-size",
833
+ "--ssh",
834
+ "--tag",
835
+ "-t",
836
+ "--target",
837
+ "--ulimit"
838
+ ]);
839
+ /** Whether a `docker build` flag's value names a file, directory or socket on this machine. */
840
+ function namesLocalPath(flag, value) {
841
+ switch (flag) {
842
+ case "--iidfile":
843
+ case "--metadata-file":
844
+ case "--ssh": return true;
845
+ case "--secret": return !/(?:^|,)env=/.test(value);
846
+ case "--build-context": {
847
+ const source = value.slice(value.indexOf("=") + 1);
848
+ return source.startsWith("oci-layout://") || !/^[a-z][a-z0-9+.-]*:\/\//.test(source);
849
+ }
850
+ case "--output":
851
+ case "-o": return !/(?:^|,)type=/.test(value) || /(?:^|,)(?:type=(?:local|tar)|dest=)/.test(value);
852
+ case "--cache-to":
853
+ case "--cache-from": return /(?:^|,)type=local/.test(value);
854
+ default: return false;
855
+ }
856
+ }
857
+ const STDIN_DOCKERFILE = ".reeval-stdin.Dockerfile";
858
+ function contextEntries(context, files) {
859
+ const entries = [];
860
+ const dirs = /* @__PURE__ */ new Set();
861
+ for (const path of files) for (let at = path.indexOf("/"); at !== -1; at = path.indexOf("/", at + 1)) dirs.add(path.slice(0, at));
862
+ for (const path of [...dirs].sort()) {
863
+ const stat = lstatSync(join(context, path));
864
+ const mtime = Math.floor(stat.mtimeMs / 1e3);
865
+ entries.push({
866
+ type: "dir",
867
+ path,
868
+ mode: stat.mode & 4095,
869
+ mtime
870
+ });
871
+ }
872
+ for (const path of files) {
873
+ const full = join(context, path);
874
+ const stat = lstatSync(full, { throwIfNoEntry: false });
875
+ if (!stat) continue;
876
+ const mtime = Math.floor(stat.mtimeMs / 1e3);
877
+ const mode = stat.mode & 4095;
878
+ if (stat.isSymbolicLink()) entries.push({
879
+ type: "symlink",
880
+ path,
881
+ mode,
882
+ mtime,
883
+ target: readlinkSync(full)
884
+ });
885
+ else if (stat.isFile()) entries.push({
886
+ type: "file",
887
+ path,
888
+ mode,
889
+ mtime,
890
+ data: readFileSync(full)
891
+ });
892
+ }
893
+ return entries;
894
+ }
895
+ /**
896
+ * `docker build` arguments and input for a remote engine: a build context on this machine goes as
897
+ * a tar on stdin (`-`), with its `.dockerignore` rules applied by the builder as they would be
898
+ * here. The Dockerfile keeps its path in the context; one outside it, or one read from stdin,
899
+ * goes in the tar under a name of its own. Directories go as the files' parents, with their modes,
900
+ * so an empty one isn't sent. The context is read into memory whole. A flag that names a path on
901
+ * this machine (`--iidfile`, `--secret`, a local `--output`, …) is refused: the CLI would read or
902
+ * write it on the other one. Any other command, and a build whose context is stdin, a URL or a
903
+ * git repository, is as is.
904
+ */
905
+ function remoteBuild(args, input) {
906
+ if (args[0] !== "build") return {
907
+ args: [...args],
908
+ input
909
+ };
910
+ let file = null;
911
+ let contextAt = -1;
912
+ for (let i = 1; i < args.length; i++) {
913
+ const arg = args[i];
914
+ const [flag = arg, joined] = arg.startsWith("--") ? arg.split(/=(.*)/s) : /^-(?:f|o)./.test(arg) ? [arg.slice(0, 2), arg.slice(2).replace(/^=/, "")] : [arg];
915
+ if (namesLocalPath(flag, joined ?? args[i + 1] ?? "")) throw new Error(`docker build ${flag} names a path on this machine, which a remote engine can't reach`);
916
+ if (BUILD_VALUE_FLAGS.has(arg)) {
917
+ if (arg === "--file" || arg === "-f") file = {
918
+ at: i + 1,
919
+ value: args[i + 1] ?? ""
920
+ };
921
+ i++;
922
+ } else if (flag === "-f" && joined !== void 0) file = {
923
+ at: i,
924
+ value: joined
925
+ };
926
+ else if (arg.startsWith("--file=")) file = {
927
+ at: i,
928
+ value: arg.slice(7)
929
+ };
930
+ else if (!arg.startsWith("-") || arg === "-") contextAt = i;
931
+ }
932
+ const context = contextAt === -1 ? null : args[contextAt];
933
+ if (context === null || context === "-") return {
934
+ args: [...args],
935
+ input
936
+ };
937
+ if (!statSync(context, { throwIfNoEntry: false })?.isDirectory()) return {
938
+ args: [...args],
939
+ input
940
+ };
941
+ const root = resolve(context);
942
+ const out = [...args];
943
+ out[contextAt] = "-";
944
+ const setFile = (value) => {
945
+ if (!file) out.splice(contextAt, 0, "--file", value);
946
+ else if (out[file.at]?.startsWith("--file=")) out[file.at] = `--file=${value}`;
947
+ else if (/^-f[^-]/.test(out[file.at] ?? "") && file.at !== contextAt) out[file.at] = `-f${value}`;
948
+ else out[file.at] = value;
949
+ };
950
+ const extra = [];
951
+ const now = Math.floor(Date.now() / 1e3);
952
+ let dockerfile = null;
953
+ if (file?.value === "-") {
954
+ const data = Buffer.from(input ?? "");
955
+ extra.push({
956
+ type: "file",
957
+ path: STDIN_DOCKERFILE,
958
+ mode: 420,
959
+ mtime: now,
960
+ data
961
+ });
962
+ setFile(STDIN_DOCKERFILE);
963
+ } else {
964
+ dockerfile = file ? resolve(file.value) : join(root, "Dockerfile");
965
+ const inside = relative(root, dockerfile);
966
+ if (inside && !inside.startsWith("..") && !isAbsolute(inside)) {
967
+ if (file) setFile(inside.split(sep).join("/"));
968
+ } else {
969
+ const name = `.reeval-${createHash("sha256").update(dockerfile).digest("hex").slice(0, 12)}.Dockerfile`;
970
+ extra.push({
971
+ type: "file",
972
+ path: name,
973
+ mode: 420,
974
+ mtime: now,
975
+ data: readFileSync(dockerfile)
976
+ });
977
+ if (lstatSync(`${dockerfile}.dockerignore`, { throwIfNoEntry: false })?.isFile()) {
978
+ const data = readFileSync(`${dockerfile}.dockerignore`);
979
+ extra.push({
980
+ type: "file",
981
+ path: `${name}.dockerignore`,
982
+ mode: 420,
983
+ mtime: now,
984
+ data
985
+ });
986
+ }
987
+ setFile(name);
988
+ }
989
+ }
990
+ return {
991
+ args: out,
992
+ input: writeTar([...contextEntries(root, contextFiles(root, dockerfile).filter((path) => !/^\.\.(?:[\\/]|$)/.test(path) && !extra.some((e) => e.path === path))), ...extra])
993
+ };
994
+ }
367
995
  // ../sandbox-docker/src/trace.ts
368
996
  /** Most of each stream a trace keeps; the rest is counted. */
369
997
  const MAX_STREAM = 4096;
@@ -433,6 +1061,174 @@ function traceDocker(args, startedAt, result, bin = "docker") {
433
1061
  });
434
1062
  } catch {}
435
1063
  }
1064
+ // ../sandbox-docker/src/egress/transport.ts
1065
+ /** Runs `command` in the sandbox to its end. */
1066
+ async function execRun(transport, command, options) {
1067
+ if (transport.run) return transport.run(command, options);
1068
+ const [bin = "", ...args] = transport.argv(command);
1069
+ const startedAt = Date.now();
1070
+ try {
1071
+ const r = await run(bin, args, {
1072
+ ...options,
1073
+ env: transport.env,
1074
+ binary: true
1075
+ });
1076
+ transport.trace?.([bin, ...args], startedAt, {
1077
+ ...r,
1078
+ stdin: options.input.length
1079
+ });
1080
+ return r;
1081
+ } catch (error) {
1082
+ transport.trace?.([bin, ...args], startedAt, { error });
1083
+ throw error;
1084
+ }
1085
+ }
1086
+ /** Starts `command` in the sandbox and leaves it running, its stdio piped. */
1087
+ function execSpawn(transport, command) {
1088
+ const argv = transport.argv(command);
1089
+ const [bin = "", ...args] = argv;
1090
+ const startedAt = Date.now();
1091
+ const child = spawn(bin, args, {
1092
+ stdio: "pipe",
1093
+ detached: true,
1094
+ env: {
1095
+ ...process.env,
1096
+ ...transport.env
1097
+ }
1098
+ });
1099
+ let stderr = "";
1100
+ child.stderr.on("data", (d) => {
1101
+ stderr += d;
1102
+ });
1103
+ child.once("close", (code) => transport.trace?.(argv, startedAt, {
1104
+ exitCode: code,
1105
+ stderr
1106
+ }));
1107
+ return child;
1108
+ }
1109
+ /** What every `ssh` reeval runs passes: no prompt, a dropped connection noticed within a minute. */
1110
+ const SSH_OPTIONS = [
1111
+ "-o",
1112
+ "BatchMode=yes",
1113
+ "-o",
1114
+ "ServerAliveInterval=15",
1115
+ "-o",
1116
+ "ServerAliveCountMax=4",
1117
+ "-o",
1118
+ "LogLevel=ERROR"
1119
+ ];
1120
+ /**
1121
+ * Whether `dir` is a directory only this user can enter, made (0700) first with `make`. An ssh
1122
+ * client trusts whatever listens at its ControlPath, so a socket in a directory another user can
1123
+ * write lets them stand in for the host.
1124
+ */
1125
+ function privateDir(dir, o = {}) {
1126
+ try {
1127
+ if (o.make) mkdirSync(dir, {
1128
+ recursive: true,
1129
+ mode: 448
1130
+ });
1131
+ const st = lstatSync(dir);
1132
+ return st.isDirectory() && st.uid === process.getuid?.() && (st.mode & 63) === 0;
1133
+ } catch {
1134
+ return false;
1135
+ }
1136
+ }
1137
+ /**
1138
+ * Whether ssh can listen on a control socket at `path` on `platform`. A socket's path has
1139
+ * `sizeof(sun_path)` bytes with its NUL (104 on macOS and the BSDs, 108 on Linux), and the master
1140
+ * first listens on `path` plus a 17-byte random suffix. `%C` expands to a 40-character hash.
1141
+ */
1142
+ function controlPathFits(path, platform = process.platform) {
1143
+ const room = platform === "linux" ? 108 : 104;
1144
+ return Buffer.byteLength(path.replaceAll("%C", "C".repeat(40))) + 17 < room;
1145
+ }
1146
+ /**
1147
+ * The options that share one connection through a control socket at `path`, kept open `persistS`
1148
+ * seconds after the last command; none on Windows, whose OpenSSH has no ControlMaster, when the
1149
+ * path is too long for a socket ({@link controlPathFits}), or when the socket's directory isn't
1150
+ * {@link privateDir}. `path` may end in an ssh token such as `%C`.
1151
+ */
1152
+ function controlOptions(path, persistS) {
1153
+ if (!path || process.platform === "win32" || !controlPathFits(path)) return [];
1154
+ if (!privateDir(dirname(path))) return [];
1155
+ return [
1156
+ "-o",
1157
+ "ControlMaster=auto",
1158
+ "-o",
1159
+ `ControlPath=${path}`,
1160
+ "-o",
1161
+ `ControlPersist=${persistS}`
1162
+ ];
1163
+ }
1164
+ /**
1165
+ * The host argv that runs `remote`, one shell command line, on `target`. ssh joins its remote
1166
+ * arguments into one line for the login shell, so the caller quotes it. No user config applies.
1167
+ */
1168
+ function sshArgv(target, remote) {
1169
+ return [
1170
+ "ssh",
1171
+ "-T",
1172
+ "-F",
1173
+ "none",
1174
+ "-i",
1175
+ target.identityFile,
1176
+ "-p",
1177
+ String(target.port),
1178
+ ...SSH_OPTIONS,
1179
+ "-o",
1180
+ "IdentitiesOnly=yes",
1181
+ "-o",
1182
+ "StrictHostKeyChecking=yes",
1183
+ "-o",
1184
+ `UserKnownHostsFile=${target.knownHostsFile}`,
1185
+ "-o",
1186
+ "GlobalKnownHostsFile=none",
1187
+ "-o",
1188
+ `HostKeyAlias=${target.hostKeyAlias}`,
1189
+ "-o",
1190
+ "ConnectTimeout=20",
1191
+ ...controlOptions(target.controlPath, 300),
1192
+ `${target.user}@${target.host}`,
1193
+ remote
1194
+ ];
1195
+ }
1196
+ /** How a command line on `target` runs as root: through `sudo -n`, unless it logs in as root. */
1197
+ const asRootPrefix = (target) => target.loginRoot ? "" : "sudo -n -- ";
1198
+ /** `ssh -T` into a VM, as root through `sudo -n` (with sudo's own `secure_path`) or as its login. */
1199
+ function sshTransport(target) {
1200
+ return {
1201
+ argv: (command) => sshArgv(target, `${asRootPrefix(target)}${command.map(shellQuote).join(" ")}`),
1202
+ trace: (argv, startedAt, end) => traceDocker(argv.slice(1), startedAt, end, "ssh")
1203
+ };
1204
+ }
1205
+ /** `docker exec` (or `podman exec`) into a running container, as root. */
1206
+ function containerTransport(containerId, engine) {
1207
+ const sent = /* @__PURE__ */ new WeakMap();
1208
+ const exec = (command) => [
1209
+ "exec",
1210
+ "--interactive",
1211
+ "--user",
1212
+ "0:0",
1213
+ containerId,
1214
+ ...command
1215
+ ];
1216
+ return {
1217
+ argv: (command) => {
1218
+ const host = hostCommand(engine, exec(command));
1219
+ const argv = [host.bin, ...host.args];
1220
+ sent.set(argv, exec(command));
1221
+ return argv;
1222
+ },
1223
+ env: hostCommand(engine, []).env,
1224
+ run: (command, { input, signal }) => docker(exec(command), {
1225
+ input,
1226
+ signal,
1227
+ engine
1228
+ }),
1229
+ trace: (argv, startedAt, end) => traceDocker(sent.get(argv) ?? argv.slice(1), startedAt, end, engineLabel(engine))
1230
+ };
1231
+ }
436
1232
  // ../sandbox-docker/src/docker-cli.ts
437
1233
  /** How long to wait before each retry of a command that never reached Podman. */
438
1234
  const CONNECTION_RETRY_MS = [
@@ -461,43 +1257,58 @@ const sleep = (ms, signal) => new Promise((resolve) => {
461
1257
  * {@link isConnectionFailure}), and returns the last result.
462
1258
  */
463
1259
  async function retryConnection(attempt, options = {}) {
464
- const { delays = CONNECTION_RETRY_MS, signal, wait = sleep } = options;
1260
+ const { delays = CONNECTION_RETRY_MS, signal, wait = sleep, failed = isConnectionFailure } = options;
465
1261
  let r = await attempt();
466
1262
  for (const ms of delays) {
467
- if (!isConnectionFailure(r) || signal?.aborted) break;
1263
+ if (!failed(r) || signal?.aborted) break;
468
1264
  await wait(ms, signal);
469
1265
  r = await attempt();
470
1266
  }
471
1267
  return r;
472
1268
  }
473
- /** Runs the docker (or podman) CLI. `env` values are passed via the CLI's environment, never argv. */
1269
+ /**
1270
+ * Runs the docker (or podman) CLI, here or on a remote engine's machine. `env` values are passed
1271
+ * via the CLI's environment, never argv.
1272
+ */
474
1273
  async function docker(args, options = {}) {
475
- const { engine, ...rest } = options;
476
- const { bin } = engineSpec(engine);
477
- const stdin = options.input?.length ?? 0;
478
- const env = {
479
- ...engineEnv(engine),
480
- ...rest.env
1274
+ const { engine, signal } = options;
1275
+ const remote = isRemoteEngine(engine);
1276
+ const call = remote ? remoteBuild(args, options.input) : {
1277
+ args,
1278
+ input: options.input
481
1279
  };
1280
+ const command = hostCommand(engine, call.args, options.env);
1281
+ const input = command.preamble ? Buffer.concat([command.preamble, Buffer.from(call.input ?? "")]) : call.input;
1282
+ const bin = engineLabel(engine);
1283
+ const stdin = call.input?.length ?? 0;
482
1284
  const once = async () => {
483
1285
  const startedAt = Date.now();
484
1286
  try {
485
- const r = await run(bin, args, {
486
- ...rest,
487
- env,
488
- binary: true
1287
+ const r = await run(command.bin, command.args, {
1288
+ env: command.env,
1289
+ binary: true,
1290
+ ...input !== void 0 ? { input } : {},
1291
+ ...signal ? { signal } : {}
489
1292
  });
490
- traceDocker(args, startedAt, {
1293
+ traceDocker(call.args, startedAt, {
491
1294
  ...r,
492
1295
  stdin
493
1296
  }, bin);
494
1297
  return r;
495
1298
  } catch (error) {
496
- traceDocker(args, startedAt, { error }, bin);
1299
+ traceDocker(call.args, startedAt, { error }, bin);
497
1300
  throw error;
498
1301
  }
499
1302
  };
500
- return engine === "podman" ? retryConnection(once, { signal: options.signal }) : once();
1303
+ if (remote) {
1304
+ if (!retriesSafely(call.args)) return once();
1305
+ const { target } = engine;
1306
+ return retryConnection(once, {
1307
+ signal,
1308
+ failed: (r) => isSshFailure(r, target)
1309
+ });
1310
+ }
1311
+ return engine === "podman" ? retryConnection(once, { signal }) : once();
501
1312
  }
502
1313
  async function dockerOk(args, opts) {
503
1314
  const r = await docker(args, opts);
@@ -519,12 +1330,14 @@ const REMOVAL_RETRY_MS = [
519
1330
  * and tries again while it fails. Resolves either way.
520
1331
  */
521
1332
  async function removeContainerDetached(id, engine, options = {}) {
522
- const { bin, rmForce } = engineSpec(engine);
1333
+ const { rmForce } = engineSpec(engine);
523
1334
  const { delays = REMOVAL_RETRY_MS, wait = sleep } = options;
524
1335
  const args = [...rmForce, id];
1336
+ const command = hostCommand(engine, args);
1337
+ const bin = command.bin;
525
1338
  const env = {
526
1339
  ...process.env,
527
- ...engineEnv(engine)
1340
+ ...command.env
528
1341
  };
529
1342
  const once = () => new Promise((resolve) => {
530
1343
  const keepAlive = setInterval(() => {}, 1e3);
@@ -538,13 +1351,13 @@ async function removeContainerDetached(id, engine, options = {}) {
538
1351
  traceDocker(args, startedAt, {
539
1352
  exitCode,
540
1353
  stderr
541
- }, bin);
1354
+ }, engineLabel(engine));
542
1355
  resolve({
543
1356
  exitCode,
544
1357
  stderr
545
1358
  });
546
1359
  };
547
- const child = spawn(bin, args, {
1360
+ const child = spawn(bin, command.args, {
548
1361
  detached: true,
549
1362
  stdio: [
550
1363
  "ignore",
@@ -577,6 +1390,19 @@ async function removeContainerDetached(id, engine, options = {}) {
577
1390
  */
578
1391
  function sweepLabelDetached(label, seconds = 15, engine) {
579
1392
  const { bin, rmForce } = engineSpec(engine);
1393
+ if (isRemoteEngine(engine)) {
1394
+ const filter = shellQuote(`label=${label}`);
1395
+ const loop = `for i in $(seq ${Math.max(1, Math.floor(seconds))}); do ids=$(docker ps -aq --filter ${filter}); [ -z "$ids" ] || docker ${rmForce.join(" ")} $ids >/dev/null 2>&1; sleep 1; done`;
1396
+ const [ssh = "ssh", ...rest] = sshArgv(engine.target, `sh -c ${shellQuote(loop)}`);
1397
+ const child = spawn(ssh, rest, {
1398
+ detached: true,
1399
+ stdio: "ignore",
1400
+ windowsHide: true
1401
+ });
1402
+ child.on("error", () => {});
1403
+ child.unref();
1404
+ return;
1405
+ }
580
1406
  const child = spawn(process.execPath, [
581
1407
  "-e",
582
1408
  `const { execFileSync } = require('node:child_process')
@@ -672,124 +1498,33 @@ async function imageTags(repository, engine) {
672
1498
  const isNoSuchImage = (stderr) => /no such image|image not known/i.test(stderr);
673
1499
  /**
674
1500
  * The image, or null when the engine says it has no such image. A CLI that can't start or a daemon
675
- * that doesn't answer throws instead, naming the error: that's not knowing, not a missing image.
676
- */
677
- async function imageInfo(image, engine) {
678
- const { bin, imageId } = engineSpec(engine);
679
- const r = await docker([
680
- "image",
681
- "inspect",
682
- "--format",
683
- `{"config":{{json .Config}},"id":{{json ${imageId}}},"repoDigests":{{json .RepoDigests}},"os":{{json .Os}},"arch":{{json .Architecture}}}`,
684
- image
685
- ], { engine }).catch((error) => {
686
- throw new Error(`${bin} image inspect ${image} couldn't run: ${error.message}`);
687
- });
688
- if (r.exitCode !== 0) {
689
- const stderr = r.stderr.trim();
690
- if (isNoSuchImage(stderr)) return null;
691
- throw new Error(`${bin} image inspect ${image} failed: ${stderr || `exit ${r.exitCode}`}`);
692
- }
693
- const info = JSON.parse(r.stdout.toString("utf8"));
694
- const repoDigests = (info.repoDigests ?? []).filter(isRegistryDigest);
695
- const platform = info.os && info.arch ? `${info.os}/${info.arch}` : null;
696
- return {
697
- labels: info.config?.Labels ?? {},
698
- id: normalizeImageId(info.id),
699
- repoDigests,
700
- platform
701
- };
702
- }
703
- // ../sandbox-docker/src/dockerignore.ts
704
- const ignore = dockerignore.default;
705
- /**
706
- * A pattern `@balena/dockerignore` may match differently from BuildKit: escapes, character
707
- * classes and the regexp characters it doesn't escape, a `**` joined to other characters, and the
708
- * whitespace Go and JavaScript trim differently. One over 1024 characters is risky too, since
709
- * JavaScript refuses a regexp that long that Go accepts, and so is one with more than four `*`
710
- * runs, whose JavaScript regexp can backtrack for minutes where Go's runs in linear time.
711
- */
712
- const RISKY = /[\\[\]^+(){}|\u0085\uFEFF]|[^/]\*\*|\*\*[^/]/;
713
- const MAX_STARS = 4;
714
- /**
715
- * Names `@balena/dockerignore` may match differently: `?` matches one UTF-16 unit there and one
716
- * code point in BuildKit, and `.` doesn't match a line terminator there but does in Go.
717
- */
718
- const ODD_NAME = /[\n\r\u2028\u2029\u{10000}-\u{10FFFF}]/u;
719
- const clean = (pattern) => posix.normalize(pattern).replace(/^\/+/, "").replace(/\/+$/, "");
720
- /**
721
- * `.dockerignore` lines as Docker reads them: a BOM is dropped, a line starting `#` is a comment,
722
- * and `!` re-includes. A path is left out when a rule excludes it and no `!` rule matches it or a
723
- * directory it's in: BuildKit then excludes it whatever order the rules are in, so this never
724
- * leaves out a file `docker build` sends, though it keeps some it doesn't. A risky exclusion is
725
- * dropped, and a risky `!` rule keeps everything, as does one `@balena/dockerignore` would read
726
- * as a comment or a pattern that cleans to a leading `!` (`!!a`, `/ !a`), which the two read
727
- * differently.
728
- */
729
- function parseRules(text) {
730
- const excludes = [];
731
- const reincludes = [];
732
- for (const line of text.replace(/^\uFEFF/, "").split(/\r?\n/)) {
733
- if (line.startsWith("#")) continue;
734
- let pattern = line.trim();
735
- const negate = pattern.startsWith("!");
736
- if (negate) pattern = pattern.slice(1).trim();
737
- if (!pattern) continue;
738
- const cleaned = clean(pattern);
739
- const risky = RISKY.test(pattern) || pattern.length > 1024 || (pattern.match(/\*+/g)?.length ?? 0) > MAX_STARS || [".", ""].includes(cleaned);
740
- if (cleaned.trim().startsWith("!") || negate && pattern.startsWith("#") || negate && risky) return {
741
- left: () => false,
742
- literal: null
743
- };
744
- if (!negate) {
745
- if (!risky) excludes.push(line);
746
- } else reincludes.push(pattern);
747
- }
748
- const exclude = ignore({ ignorecase: false }).add(excludes);
749
- const reinclude = ignore({ ignorecase: false }).add(reincludes);
750
- return {
751
- left: (path) => !ODD_NAME.test(path) && exclude.ignores(path) && !reinclude.ignores(path),
752
- literal: reincludes.some((p) => /[*?]/.test(p)) ? null : reincludes.map(clean)
753
- };
754
- }
755
- /** Whether reeval leaves `path` out of a hash under these `.dockerignore` rules. */
756
- function dockerignoreMatcher(text) {
757
- return parseRules(text).left;
758
- }
759
- /**
760
- * Files in the build context that reeval hashes, sorted, relative to `context`: every file
761
- * `docker build` sends (and some it doesn't), plus the Dockerfile and `.dockerignore`. A
762
- * Dockerfile read from stdin (`dockerfile` null) has no `<Dockerfile>.dockerignore` of its own.
763
- * A left-out directory is skipped only when every `!` rule is a literal path outside it. Docker
764
- * doesn't apply an ignore file that's a symlink or not a file, so then every file is hashed; nor
765
- * can it send what's in a directory it can't read.
766
- */
767
- function contextFiles(context, dockerfile) {
768
- const own = [...dockerfile ? [`${dockerfile}.dockerignore`] : [], join(context, ".dockerignore")].map((path) => ({
769
- path,
770
- stat: lstatSync(path, { throwIfNoEntry: false })
771
- })).find(({ stat }) => stat);
772
- const { left, literal } = parseRules(own?.stat?.isFile() ? readFileSync(own.path, "utf8") : "");
773
- const always = [...dockerfile ? [relative(context, dockerfile)] : [], ".dockerignore"].map((path) => path.split("\\").join("/"));
774
- const reach = [...always, ...literal ?? []];
775
- const files = [];
776
- const walk = (rel) => {
777
- let entries;
778
- try {
779
- entries = readdirSync(join(context, rel), { withFileTypes: true });
780
- } catch (error) {
781
- if (rel && ["EACCES", "EPERM"].includes(error.code ?? "")) return;
782
- throw error;
783
- }
784
- for (const entry of entries) {
785
- const path = rel ? `${rel}/${entry.name}` : entry.name;
786
- if (entry.isDirectory()) {
787
- if (!(left(path) && literal && !reach.some((p) => p.startsWith(`${path}/`)))) walk(path);
788
- } else if (!left(path) || always.includes(path)) files.push(path);
789
- }
1501
+ * that doesn't answer throws instead, naming the error: that's not knowing, not a missing image.
1502
+ */
1503
+ async function imageInfo(image, engine) {
1504
+ const { bin, imageId } = engineSpec(engine);
1505
+ const r = await docker([
1506
+ "image",
1507
+ "inspect",
1508
+ "--format",
1509
+ `{"config":{{json .Config}},"id":{{json ${imageId}}},"repoDigests":{{json .RepoDigests}},"os":{{json .Os}},"arch":{{json .Architecture}}}`,
1510
+ image
1511
+ ], { engine }).catch((error) => {
1512
+ throw new Error(`${bin} image inspect ${image} couldn't run: ${error.message}`);
1513
+ });
1514
+ if (r.exitCode !== 0) {
1515
+ const stderr = r.stderr.trim();
1516
+ if (isNoSuchImage(stderr)) return null;
1517
+ throw new Error(`${bin} image inspect ${image} failed: ${stderr || `exit ${r.exitCode}`}`);
1518
+ }
1519
+ const info = JSON.parse(r.stdout.toString("utf8"));
1520
+ const repoDigests = (info.repoDigests ?? []).filter(isRegistryDigest);
1521
+ const platform = info.os && info.arch ? `${info.os}/${info.arch}` : null;
1522
+ return {
1523
+ labels: info.config?.Labels ?? {},
1524
+ id: normalizeImageId(info.id),
1525
+ repoDigests,
1526
+ platform
790
1527
  };
791
- walk("");
792
- return files.sort();
793
1528
  }
794
1529
  // ../sandbox-docker/src/image.ts
795
1530
  /**
@@ -806,7 +1541,7 @@ const HARNESS_PACKAGES = {
806
1541
  name: "Cursor",
807
1542
  cli: "@cursor/sdk",
808
1543
  probe: `node -p "'@cursor/sdk ' + require(process.env.HOME + '/.ai-sdk-harness/.harness-bootstrap/cursor-sdk/node_modules/@cursor/sdk/package.json').version"`,
809
- adapter: async () => (await import("./src-BuGc40IF.js")).createCursorSdk()
1544
+ adapter: async () => (await import("./src-C6MsGyD6.js")).createCursorSdk()
810
1545
  }
811
1546
  },
812
1547
  "claude-code": {
@@ -825,7 +1560,7 @@ const HARNESS_PACKAGES = {
825
1560
  bootstrap: {
826
1561
  name: "Antigravity",
827
1562
  cli: "agy",
828
- adapter: async () => (await import("./src-CotUxxQV.js")).createAntigravity()
1563
+ adapter: async () => (await import("./src-5dCrqbFd.js")).createAntigravity()
829
1564
  }
830
1565
  },
831
1566
  opencode: {
@@ -834,7 +1569,7 @@ const HARNESS_PACKAGES = {
834
1569
  bootstrap: {
835
1570
  name: "OpenCode",
836
1571
  cli: "opencode",
837
- adapter: async () => (await import("./src-B2eHTCnp.js")).createOpenCode({
1572
+ adapter: async () => (await import("./src-VG2IRoT4.js")).createOpenCode({
838
1573
  auth: { GOOGLE_GENERATIVE_AI_API_KEY: "unused" },
839
1574
  model: "google/unused"
840
1575
  })
@@ -847,7 +1582,7 @@ const HARNESS_PACKAGES = {
847
1582
  name: "Goose",
848
1583
  cli: "goose",
849
1584
  adapter: async () => {
850
- const goose = await import("./src-BfOlH_Bu.js");
1585
+ const goose = await import("./src-io_SKoZ5.js");
851
1586
  return goose.createGoose({
852
1587
  auth: { GOOGLE_API_KEY: "unused" },
853
1588
  provider: goose.GEMINI_PROVIDER,
@@ -863,7 +1598,7 @@ const HARNESS_PACKAGES = {
863
1598
  name: "pi",
864
1599
  cli: "pi",
865
1600
  adapter: async () => {
866
- const pi = await import("./src-CSVJjghq.js");
1601
+ const pi = await import("./src-DwcCKsV0.js");
867
1602
  const provider = pi.piProvider("google");
868
1603
  if ("refused" in provider) throw new Error(provider.refused);
869
1604
  return pi.createPi({
@@ -879,7 +1614,7 @@ const HARNESS_PACKAGES = {
879
1614
  bootstrap: {
880
1615
  name: "Codex",
881
1616
  cli: "codex",
882
- adapter: async () => (await import("./src-CcrQQB0_.js")).createCodex({ auth: { OPENAI_API_KEY: "unused" } })
1617
+ adapter: async () => (await import("./src-Ds1pmXTg.js")).createCodex({ auth: { OPENAI_API_KEY: "unused" } })
883
1618
  }
884
1619
  },
885
1620
  fx: {
@@ -888,7 +1623,7 @@ const HARNESS_PACKAGES = {
888
1623
  bootstrap: {
889
1624
  name: "fx",
890
1625
  cli: "fx",
891
- adapter: async () => (await import("./src-D-PwBaBB.js")).createFx({
1626
+ adapter: async () => (await import("./src-DrLbG1HM.js")).createFx({
892
1627
  auth: { AI_GATEWAY_API_KEY: "unused" },
893
1628
  model: "unused/unused"
894
1629
  })
@@ -900,7 +1635,7 @@ const HARNESS_PACKAGES = {
900
1635
  bootstrap: {
901
1636
  name: "Grok Build",
902
1637
  cli: "grok",
903
- adapter: async () => (await import("./src-C2K5_afU.js")).createGrokBuild({
1638
+ adapter: async () => (await import("./src-Cf4vRyea.js")).createGrokBuild({
904
1639
  auth: { XAI_API_KEY: "unused" },
905
1640
  model: "unused"
906
1641
  })
@@ -922,7 +1657,7 @@ const imageFor = (harness) => `reeval-sandbox:${harness}-${adapterVersion(harnes
922
1657
  const DEFAULT_IMAGE = imageFor("cursor");
923
1658
  /** The `ai.reeval.harness` label value an image baked for `harness` carries. */
924
1659
  const harnessLabel = (harness) => `${HARNESS_PACKAGES[harness].name}@${adapterVersion(harness)}`;
925
- const LABEL = {
1660
+ const LABEL$1 = {
926
1661
  managed: "ai.reeval.managed",
927
1662
  run: "ai.reeval.run",
928
1663
  /** Unique per session, so a create cut short can find what it made. */
@@ -1297,7 +2032,7 @@ function createMux(options) {
1297
2032
  * Pipes two duplexes into each other. An error, or one side closing before its end, tears both
1298
2033
  * down; a clean end half-closes the other side through `pipe`.
1299
2034
  */
1300
- function link(a, b) {
2035
+ function link$1(a, b) {
1301
2036
  a.pipe(b);
1302
2037
  b.pipe(a);
1303
2038
  const kill = () => {
@@ -1356,7 +2091,7 @@ function forwarderMain(io, makeMux, linkStreams, proxyPort) {
1356
2091
  server.listen(proxyPort, "127.0.0.1", () => mux.ready());
1357
2092
  }
1358
2093
  /** The `node -e` script that runs {@link forwarderMain} in the container. */
1359
- const forwarderScript = (proxyPort) => `(${forwarderMain.toString()})({ net: require('node:net'), Duplex: require('node:stream').Duplex, input: process.stdin, output: process.stdout, error: (m) => process.stderr.write(m + '\\n'), exit: (c) => process.exit(c) }, ${createMux.toString()}, ${link.toString()}, ${proxyPort})`;
2094
+ const forwarderScript = (proxyPort) => `(${forwarderMain.toString()})({ net: require('node:net'), Duplex: require('node:stream').Duplex, input: process.stdin, output: process.stdout, error: (m) => process.stderr.write(m + '\\n'), exit: (c) => process.exit(c) }, ${createMux.toString()}, ${link$1.toString()}, ${proxyPort})`;
1360
2095
  // ../sandbox-docker/src/egress/effort.ts
1361
2096
  /** The paths read, in order; `*` is any key of an object (a gateway's provider name). */
1362
2097
  const PATHS = [
@@ -2543,7 +3278,7 @@ function createEgressProxy(options) {
2543
3278
  upstream.once("connect", () => {
2544
3279
  socket.write("HTTP/1.1 200 Connection Established\r\n\r\n");
2545
3280
  if (head.length) upstream.write(head);
2546
- link(socket, upstream);
3281
+ link$1(socket, upstream);
2547
3282
  });
2548
3283
  upstream.once("error", (error) => {
2549
3284
  log(`reeval:egress CONNECT ${host}:${port} failed (${failure(error)})`);
@@ -2833,7 +3568,7 @@ function createEgressProxy(options) {
2833
3568
  socket.write(`${lines.join("\r\n")}\r\n\r\n`);
2834
3569
  if (head.length) upSocket.write(head);
2835
3570
  if (upHead.length) socket.write(upHead);
2836
- link(socket, track(upSocket));
3571
+ link$1(socket, track(upSocket));
2837
3572
  });
2838
3573
  upstream.once("response", (up) => {
2839
3574
  upgraded({ status: up.statusCode });
@@ -3387,13 +4122,13 @@ function createEgressProxy(options) {
3387
4122
  track(upSocket);
3388
4123
  if (!all.length) {
3389
4124
  if (upHead.length) socket.write(upHead);
3390
- return link(socket, upSocket);
4125
+ return link$1(socket, upSocket);
3391
4126
  }
3392
4127
  const frames = webSocketScrubber(all);
3393
4128
  if (upHead.length) frames.write(upHead);
3394
4129
  upSocket.pipe(frames);
3395
4130
  upSocket.once("error", (error) => frames.destroy(error));
3396
- link(socket, Duplex.from({
4131
+ link$1(socket, Duplex.from({
3397
4132
  readable: frames,
3398
4133
  writable: upSocket
3399
4134
  }));
@@ -3491,167 +4226,6 @@ function createEgressProxy(options) {
3491
4226
  }
3492
4227
  };
3493
4228
  }
3494
- // ../sandbox-docker/src/egress/transport.ts
3495
- /** Runs `command` in the sandbox to its end. */
3496
- async function execRun(transport, command, options) {
3497
- if (transport.run) return transport.run(command, options);
3498
- const [bin = "", ...args] = transport.argv(command);
3499
- const startedAt = Date.now();
3500
- try {
3501
- const r = await run(bin, args, {
3502
- ...options,
3503
- env: transport.env,
3504
- binary: true
3505
- });
3506
- transport.trace?.([bin, ...args], startedAt, {
3507
- ...r,
3508
- stdin: options.input.length
3509
- });
3510
- return r;
3511
- } catch (error) {
3512
- transport.trace?.([bin, ...args], startedAt, { error });
3513
- throw error;
3514
- }
3515
- }
3516
- /** Starts `command` in the sandbox and leaves it running, its stdio piped. */
3517
- function execSpawn(transport, command) {
3518
- const argv = transport.argv(command);
3519
- const [bin = "", ...args] = argv;
3520
- const startedAt = Date.now();
3521
- const child = spawn(bin, args, {
3522
- stdio: "pipe",
3523
- detached: true,
3524
- env: {
3525
- ...process.env,
3526
- ...transport.env
3527
- }
3528
- });
3529
- let stderr = "";
3530
- child.stderr.on("data", (d) => {
3531
- stderr += d;
3532
- });
3533
- child.once("close", (code) => transport.trace?.(argv, startedAt, {
3534
- exitCode: code,
3535
- stderr
3536
- }));
3537
- return child;
3538
- }
3539
- /** What every `ssh` reeval runs passes: no prompt, a dropped connection noticed within a minute. */
3540
- const SSH_OPTIONS = [
3541
- "-o",
3542
- "BatchMode=yes",
3543
- "-o",
3544
- "ServerAliveInterval=15",
3545
- "-o",
3546
- "ServerAliveCountMax=4",
3547
- "-o",
3548
- "LogLevel=ERROR"
3549
- ];
3550
- /**
3551
- * Whether `dir` is a directory only this user can enter, made (0700) first with `make`. An ssh
3552
- * client trusts whatever listens at its ControlPath, so a socket in a directory another user can
3553
- * write lets them stand in for the host.
3554
- */
3555
- function privateDir(dir, o = {}) {
3556
- try {
3557
- if (o.make) mkdirSync(dir, {
3558
- recursive: true,
3559
- mode: 448
3560
- });
3561
- const st = lstatSync(dir);
3562
- return st.isDirectory() && st.uid === process.getuid?.() && (st.mode & 63) === 0;
3563
- } catch {
3564
- return false;
3565
- }
3566
- }
3567
- /**
3568
- * Whether ssh can listen on a control socket at `path` on `platform`. A socket's path has
3569
- * `sizeof(sun_path)` bytes with its NUL (104 on macOS and the BSDs, 108 on Linux), and the master
3570
- * first listens on `path` plus a 17-byte random suffix. `%C` expands to a 40-character hash.
3571
- */
3572
- function controlPathFits(path, platform = process.platform) {
3573
- const room = platform === "linux" ? 108 : 104;
3574
- return Buffer.byteLength(path.replaceAll("%C", "C".repeat(40))) + 17 < room;
3575
- }
3576
- /**
3577
- * The options that share one connection through a control socket at `path`, kept open `persistS`
3578
- * seconds after the last command; none on Windows, whose OpenSSH has no ControlMaster, when the
3579
- * path is too long for a socket ({@link controlPathFits}), or when the socket's directory isn't
3580
- * {@link privateDir}. `path` may end in an ssh token such as `%C`.
3581
- */
3582
- function controlOptions(path, persistS) {
3583
- if (!path || process.platform === "win32" || !controlPathFits(path)) return [];
3584
- if (!privateDir(dirname(path))) return [];
3585
- return [
3586
- "-o",
3587
- "ControlMaster=auto",
3588
- "-o",
3589
- `ControlPath=${path}`,
3590
- "-o",
3591
- `ControlPersist=${persistS}`
3592
- ];
3593
- }
3594
- /**
3595
- * The host argv that runs `remote`, one shell command line, on `target`. ssh joins its remote
3596
- * arguments into one line for the login shell, so the caller quotes it. No user config applies.
3597
- */
3598
- function sshArgv(target, remote) {
3599
- return [
3600
- "ssh",
3601
- "-T",
3602
- "-F",
3603
- "none",
3604
- "-i",
3605
- target.identityFile,
3606
- "-p",
3607
- String(target.port),
3608
- ...SSH_OPTIONS,
3609
- "-o",
3610
- "IdentitiesOnly=yes",
3611
- "-o",
3612
- "StrictHostKeyChecking=yes",
3613
- "-o",
3614
- `UserKnownHostsFile=${target.knownHostsFile}`,
3615
- "-o",
3616
- "GlobalKnownHostsFile=none",
3617
- "-o",
3618
- `HostKeyAlias=${target.hostKeyAlias}`,
3619
- "-o",
3620
- "ConnectTimeout=20",
3621
- ...controlOptions(target.controlPath, 300),
3622
- `${target.user}@${target.host}`,
3623
- remote
3624
- ];
3625
- }
3626
- /** `ssh -T` into a VM, as root through `sudo -n`, with sudo's own `secure_path`. */
3627
- function sshTransport(target) {
3628
- return {
3629
- argv: (command) => sshArgv(target, `sudo -n -- ${command.map(shellQuote).join(" ")}`),
3630
- trace: (argv, startedAt, end) => traceDocker(argv.slice(1), startedAt, end, "ssh")
3631
- };
3632
- }
3633
- /** `docker exec` (or `podman exec`) into a running container, as root. */
3634
- function containerTransport(containerId, engine) {
3635
- const { bin } = engineSpec(engine);
3636
- const exec = (command) => [
3637
- "exec",
3638
- "--interactive",
3639
- "--user",
3640
- "0:0",
3641
- containerId,
3642
- ...command
3643
- ];
3644
- return {
3645
- argv: (command) => [bin, ...exec(command)],
3646
- env: engineEnv(engine),
3647
- run: (command, { input, signal }) => docker(exec(command), {
3648
- input,
3649
- signal,
3650
- engine
3651
- }),
3652
- trace: (argv, startedAt, end) => traceDocker(argv.slice(1), startedAt, end, bin)
3653
- };
3654
- }
3655
4229
  // ../sandbox-docker/src/egress/gateway.ts
3656
4230
  /** Where the forwarder listens inside the sandbox; every exec gets it as its HTTP(S) proxy. */
3657
4231
  const PROXY_PORT = BASE_PROXY_PORT;
@@ -3867,7 +4441,7 @@ async function startGateway(transport, options, signal) {
3867
4441
  if (stopped) return socket.destroy();
3868
4442
  tunnels.add(socket);
3869
4443
  socket.once("close", () => tunnels.delete(socket));
3870
- link(socket, mux.open(port));
4444
+ link$1(socket, mux.open(port));
3871
4445
  });
3872
4446
  server.once("error", reject);
3873
4447
  server.listen(0, "127.0.0.1", () => resolve(server));
@@ -4138,8 +4712,8 @@ async function networkMode(id, engine) {
4138
4712
  async function createDockerSession(options) {
4139
4713
  const nonce = randomBytes(8).toString("hex");
4140
4714
  const labels = {
4141
- [LABEL.managed]: "true",
4142
- [LABEL.session]: nonce,
4715
+ [LABEL$1.managed]: "true",
4716
+ [LABEL$1.session]: nonce,
4143
4717
  ...options.labels
4144
4718
  };
4145
4719
  const lifetime = Math.ceil((options.lifetimeMs ?? 864e5) / 1e3);
@@ -4170,15 +4744,16 @@ async function createDockerSession(options) {
4170
4744
  env,
4171
4745
  engine
4172
4746
  }).catch((error) => {
4173
- if (signal?.aborted) sweepLabelDetached(`${LABEL.session}=${nonce}`, void 0, engine);
4747
+ if (signal?.aborted) sweepLabelDetached(`${LABEL$1.session}=${nonce}`, void 0, engine);
4174
4748
  throw error;
4175
4749
  });
4176
4750
  let gateway;
4177
4751
  let removed;
4178
4752
  const observers = [];
4753
+ const creating = /* @__PURE__ */ new Set();
4179
4754
  const remove = () => {
4180
4755
  gateway?.close();
4181
- removed ??= Promise.all([id, ...observers].map((c) => removeContainerDetached(c, engine))).then(() => {});
4756
+ removed ??= Promise.allSettled(creating).then(() => Promise.all([id, ...observers].map((c) => removeContainerDetached(c, engine)))).then(() => {});
4182
4757
  return removed;
4183
4758
  };
4184
4759
  if (signal?.aborted) {
@@ -4363,18 +4938,7 @@ async function createDockerSession(options) {
4363
4938
  /** Runs the engine's CLI with its output streamed; `stop` ends what it started. */
4364
4939
  const streamed = (args, stop) => {
4365
4940
  const startedAt = Date.now();
4366
- const child = spawn(spec.bin, args, {
4367
- stdio: [
4368
- "ignore",
4369
- "pipe",
4370
- "pipe"
4371
- ],
4372
- detached: true,
4373
- env: {
4374
- ...process.env,
4375
- ...engineEnv(engine)
4376
- }
4377
- });
4941
+ const child = spawnEngine(engine, args);
4378
4942
  child.stderr.resume();
4379
4943
  const exited = new Promise((resolve) => {
4380
4944
  child.once("error", () => resolve({ exitCode: 127 }));
@@ -4382,7 +4946,7 @@ async function createDockerSession(options) {
4382
4946
  traceDocker(args, startedAt, {
4383
4947
  exitCode: code,
4384
4948
  stdout: "<streamed>"
4385
- }, spec.bin);
4949
+ }, engineLabel(engine));
4386
4950
  resolve({ exitCode: code ?? 1 });
4387
4951
  });
4388
4952
  });
@@ -4417,11 +4981,12 @@ async function createDockerSession(options) {
4417
4981
  const observer = {
4418
4982
  target: id,
4419
4983
  async spawn(o) {
4420
- if (removed) throw new Error(`${spec.name} container ${id.slice(0, 12)} is gone`);
4984
+ const gone = () => /* @__PURE__ */ new Error(`${spec.name} container ${id.slice(0, 12)} is gone`);
4985
+ if (removed) throw gone();
4421
4986
  const name = `reeval-observer-${nonce}-${observers.length + 1}`;
4422
4987
  observers.push(name);
4423
- const args = [
4424
- "run",
4988
+ const created = docker([
4989
+ "create",
4425
4990
  "--rm",
4426
4991
  "--name",
4427
4992
  name,
@@ -4446,8 +5011,16 @@ async function createDockerSession(options) {
4446
5011
  options.image,
4447
5012
  "-c",
4448
5013
  o.command
4449
- ];
4450
- return streamed(args, () => removeContainerDetached(name, engine));
5014
+ ], { engine });
5015
+ creating.add(created);
5016
+ const r = await created.finally(() => creating.delete(created));
5017
+ if (r.exitCode !== 0) throw new Error(`${spec.bin} create failed: ${r.stderr.trim()}`);
5018
+ if (removed) throw gone();
5019
+ return streamed([
5020
+ "start",
5021
+ "--attach",
5022
+ name
5023
+ ], () => removeContainerDetached(name, engine));
4451
5024
  },
4452
5025
  async run(o) {
4453
5026
  const name = observers.at(-1);
@@ -4587,24 +5160,12 @@ async function createDockerSession(options) {
4587
5160
  const marker = nextMarker();
4588
5161
  const args = execArgs(o.command, marker, o.workingDirectory, env);
4589
5162
  const startedAt = Date.now();
4590
- const child = spawn(spec.bin, args, {
4591
- stdio: [
4592
- "ignore",
4593
- "pipe",
4594
- "pipe"
4595
- ],
4596
- detached: true,
4597
- env: {
4598
- ...process.env,
4599
- ...engineEnv(engine),
4600
- ...env
4601
- }
4602
- });
5163
+ const child = spawnEngine(engine, args, env);
4603
5164
  const exited = new Promise((resolve) => child.on("close", (code) => {
4604
5165
  traceDocker(args, startedAt, {
4605
5166
  exitCode: code,
4606
5167
  stdout: "<streamed>"
4607
- }, spec.bin);
5168
+ }, engineLabel(engine));
4608
5169
  resolve({ exitCode: code ?? 1 });
4609
5170
  }));
4610
5171
  const kill = async () => {
@@ -4823,8 +5384,8 @@ function buildError(output, what, reason, keep = () => true) {
4823
5384
  });
4824
5385
  }
4825
5386
  /** Every image reeval builds carries this label, so `reeval clean --images` can find what it left. */
4826
- const BUILT_BY = ["--label", `${LABEL.managed}=image`];
4827
- const keyLabel = (key) => ["--label", `${LABEL.key}=${key}`];
5387
+ const BUILT_BY = ["--label", `${LABEL$1.managed}=image`];
5388
+ const keyLabel = (key) => ["--label", `${LABEL$1.key}=${key}`];
4828
5389
  /** Removes the image `tag` pointed at before a rebuild, once the tag points elsewhere. */
4829
5390
  async function replaced(tag, previous, engine) {
4830
5391
  if (!previous) return;
@@ -4845,13 +5406,13 @@ async function pruneImages(engine) {
4845
5406
  "--filter",
4846
5407
  "dangling=true",
4847
5408
  "--filter",
4848
- `label=${LABEL.managed}=image`
5409
+ `label=${LABEL$1.managed}=image`
4849
5410
  ]), ...await list([
4850
5411
  "-q",
4851
5412
  "--filter",
4852
5413
  "dangling=true",
4853
5414
  "--filter",
4854
- `label=${LABEL.harness}`
5415
+ `label=${LABEL$1.harness}`
4855
5416
  ])];
4856
5417
  const bases = (await list([
4857
5418
  "--format",
@@ -5051,7 +5612,7 @@ async function buildImage(log, options) {
5051
5612
  await dockerOk([
5052
5613
  "commit",
5053
5614
  "--change",
5054
- `LABEL ${LABEL.agentVersion}="${agentVersion}" ${LABEL.harness}="${harnessLabel(harness)}"${from ? digest ? ` ${LABEL.fromDigest}="${digest}"` : "" : ` ${LABEL.context}="${contextHash()}"`} ${LABEL.key}="${key}"`,
5615
+ `LABEL ${LABEL$1.agentVersion}="${agentVersion}" ${LABEL$1.harness}="${harnessLabel(harness)}"${from ? digest ? ` ${LABEL$1.fromDigest}="${digest}"` : "" : ` ${LABEL$1.context}="${contextHash()}"`} ${LABEL$1.key}="${key}"`,
5055
5616
  "--change",
5056
5617
  `WORKDIR ${SANDBOX_ROOT}`,
5057
5618
  "--change",
@@ -5150,26 +5711,33 @@ function installScript(steps) {
5150
5711
  return `${lines.join("\n")}\n`;
5151
5712
  }
5152
5713
  /**
5153
- * Builds the install layer if it's missing, or again with `force` (`reeval image build --force`,
5154
- * whose rebuilt parent keeps its key). `output` gets the build's output, for a log file.
5714
+ * The Dockerfile lines after `FROM` that run an install `script`: as root, but with the sandbox
5715
+ * user's home as HOME, so what an installer puts in `~` (uv, bun, rustup…) is where the agent
5716
+ * runs, and is then handed to that user.
5155
5717
  */
5156
- async function buildInstallLayer(parent, steps, options = {}) {
5157
- const { signal, engine } = options;
5158
- const tag = installLayerTag(parent, steps);
5159
- const previous = (await imageInfo(tag, engine))?.id;
5160
- if (previous && !options.force) return tag;
5161
- const script = installScript(steps);
5718
+ function installLayerLines(script) {
5162
5719
  const encoded = Buffer.from(script).toString("base64");
5163
5720
  const home = `$(getent passwd ${SANDBOX_USER} | cut -d: -f6)`;
5164
- const dockerfile = [
5165
- `FROM ${parent.ref}`,
5721
+ return [
5166
5722
  "USER root",
5167
5723
  `RUN echo ${encoded} | base64 -d > /tmp/reeval-install.sh \\`,
5168
5724
  ` && if id -u ${SANDBOX_USER} >/dev/null 2>&1; then export HOME="${home}"; fi \\`,
5169
5725
  " && bash /tmp/reeval-install.sh && rm /tmp/reeval-install.sh \\",
5170
5726
  ` && { ! id -u ${SANDBOX_USER} >/dev/null 2>&1 || find "$HOME" -xdev ! -user ${SANDBOX_USER} -exec chown -h ${SANDBOX_USER}: {} +; }`,
5171
5727
  `WORKDIR ${SANDBOX_ROOT}`
5172
- ].join("\n");
5728
+ ];
5729
+ }
5730
+ /**
5731
+ * Builds the install layer if it's missing, or again with `force` (`reeval image build --force`,
5732
+ * whose rebuilt parent keeps its key). `output` gets the build's output, for a log file.
5733
+ */
5734
+ async function buildInstallLayer(parent, steps, options = {}) {
5735
+ const { signal, engine } = options;
5736
+ const tag = installLayerTag(parent, steps);
5737
+ const previous = (await imageInfo(tag, engine))?.id;
5738
+ if (previous && !options.force) return tag;
5739
+ const script = installScript(steps);
5740
+ const dockerfile = [`FROM ${parent.ref}`, ...installLayerLines(script)].join("\n");
5173
5741
  const build = await docker([
5174
5742
  "build",
5175
5743
  "--progress",
@@ -5361,6 +5929,24 @@ function dockerfileBases(dockerfile) {
5361
5929
  };
5362
5930
  }
5363
5931
  /**
5932
+ * The image a Dockerfile's last stage starts from, through the stages it names, as its `FROM`
5933
+ * writes it: `${REEVAL_BASE}` for one built on the harness's image. The built image inherits its
5934
+ * labels, so this says whether it already has a harness's CLI. Null with no `FROM`.
5935
+ */
5936
+ function dockerfileFinalBase(dockerfile) {
5937
+ const stages = /* @__PURE__ */ new Map();
5938
+ let last = null;
5939
+ const text = readFileSync(dockerfile, "utf8").replace(/\\[ \t]*\r?\n/g, " ");
5940
+ for (const line of text.split("\n")) {
5941
+ if (/^\s*#/.test(line)) continue;
5942
+ const from = /^\s*FROM\s+(?:--platform=\S+\s+)?(\S+)(?:\s+AS\s+(\S+))?/i.exec(line);
5943
+ if (!from?.[1]) continue;
5944
+ last = stages.get(from[1].toLowerCase()) ?? from[1];
5945
+ if (from[2]) stages.set(from[2].toLowerCase(), last);
5946
+ }
5947
+ return last;
5948
+ }
5949
+ /**
5364
5950
  * A Dockerfile image's content key: its tag, plus the digest each of its {@link dockerfileBases}
5365
5951
  * named when it was built, so a base that moved upstream is another image. One whose bases can't all
5366
5952
  * be named this way is keyed on its local image id instead ({@link localKey}).
@@ -5483,11 +6069,11 @@ async function pullLayer(registry, layer, options = {}) {
5483
6069
  };
5484
6070
  try {
5485
6071
  const info = await imageInfo(remote, engine).catch(() => null);
5486
- const key = info?.labels[LABEL.key];
6072
+ const key = info?.labels[LABEL$1.key];
5487
6073
  if (key !== layer.key) return {
5488
6074
  pulled: false,
5489
6075
  remote,
5490
- reason: key ? `its ${LABEL.key} label is ${key}, not ${layer.key}` : `it has no ${LABEL.key} label`
6076
+ reason: key ? `its ${LABEL$1.key} label is ${key}, not ${layer.key}` : `it has no ${LABEL$1.key} label`
5491
6077
  };
5492
6078
  if (info?.platform !== platform) return {
5493
6079
  pulled: false,
@@ -5552,6 +6138,136 @@ async function pushLayer(registry, layer, options = {}) {
5552
6138
  }
5553
6139
  return remote;
5554
6140
  }
6141
+ // ../sandbox-docker/src/registry-api.ts
6142
+ const DIGEST = /^sha256:[0-9a-f]{64}$/;
6143
+ const LABEL = "[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?";
6144
+ const HOST = new RegExp(`^(?:${LABEL}(?:\\.${LABEL})*|\\[[0-9a-fA-F:]+\\])(?::\\d+)?$`);
6145
+ /**
6146
+ * The manifest types asked for, an index first: the digest is then the top-level manifest's, as
6147
+ * `docker buildx imagetools inspect` reports it and as `fromImageKey` keys a `from` image.
6148
+ */
6149
+ const ACCEPT = [
6150
+ "application/vnd.oci.image.index.v1+json",
6151
+ "application/vnd.docker.distribution.manifest.list.v2+json",
6152
+ "application/vnd.oci.image.manifest.v1+json",
6153
+ "application/vnd.docker.distribution.manifest.v2+json"
6154
+ ].join(", ");
6155
+ /**
6156
+ * `ref` as the registry API addresses it, normalized as Docker does: no registry is Docker Hub, a
6157
+ * one-part Docker Hub name is under `library/`, and no tag is `latest`. Null when it isn't a
6158
+ * reference.
6159
+ */
6160
+ function parseImageRef(ref) {
6161
+ const at = ref.indexOf("@");
6162
+ const digest = at === -1 ? null : ref.slice(at + 1);
6163
+ if (digest !== null && !DIGEST.test(digest)) return null;
6164
+ let name = at === -1 ? ref : ref.slice(0, at);
6165
+ const slash = name.indexOf("/");
6166
+ const first = slash === -1 ? "" : name.slice(0, slash);
6167
+ let host = "docker.io";
6168
+ if (first && (first.includes(".") || first.includes(":") || first === "localhost")) {
6169
+ if (!HOST.test(first)) return null;
6170
+ host = first;
6171
+ name = name.slice(slash + 1);
6172
+ }
6173
+ const colon = name.lastIndexOf(":");
6174
+ const tag = colon === -1 ? null : name.slice(colon + 1);
6175
+ if (colon !== -1) name = name.slice(0, colon);
6176
+ if (tag !== null && !/^[\w][\w.-]{0,127}$/.test(tag)) return null;
6177
+ if (!/^[a-z0-9]+(?:(?:[._]|__|-+)[a-z0-9]+)*(?:\/[a-z0-9]+(?:(?:[._]|__|-+)[a-z0-9]+)*)*$/.test(name)) return null;
6178
+ if (host === "docker.io" || host === "index.docker.io") {
6179
+ host = "registry-1.docker.io";
6180
+ if (!name.includes("/")) name = `library/${name}`;
6181
+ }
6182
+ return {
6183
+ host,
6184
+ repository: name,
6185
+ reference: digest ?? tag ?? "latest"
6186
+ };
6187
+ }
6188
+ const loopback = (host) => /^(localhost|127\.\d+\.\d+\.\d+|\[::1\])(:\d+)?$/.test(host);
6189
+ /** A loopback registry speaks plain HTTP, as Docker allows without an insecure-registries entry. */
6190
+ const scheme = (host) => loopback(host) ? "http" : "https";
6191
+ /** The parameters of a `WWW-Authenticate` challenge: its scheme, lowercase, and its fields. */
6192
+ function challenge(header) {
6193
+ const match = /^\s*(\w+)\s*(.*)$/s.exec(header ?? "");
6194
+ const params = {};
6195
+ for (const [, key, quoted, bare] of (match?.[2] ?? "").matchAll(/(\w+)=(?:"((?:[^"\\]|\\.)*)"|([^\s,]*))/g)) if (key) params[key.toLowerCase()] = quoted?.replace(/\\(.)/g, "$1") ?? bare ?? "";
6196
+ return {
6197
+ scheme: match?.[1]?.toLowerCase() ?? "",
6198
+ params
6199
+ };
6200
+ }
6201
+ const basic = (c) => `Basic ${Buffer.from(`${c.username}:${c.password}`).toString("base64")}`;
6202
+ /**
6203
+ * What `ref` names in its registry now, without Docker: the digest of its top-level manifest (an
6204
+ * index for a multi-platform image), through the registry HTTP API. It follows the registry's
6205
+ * token challenge, anonymously or with `credential`'s login. A reference pinned by digest is that
6206
+ * digest. `error` when it doesn't resolve: no such image, access refused or no network.
6207
+ */
6208
+ async function registryDigest(ref, options = {}) {
6209
+ const parsed = parseImageRef(ref);
6210
+ if (!parsed) return { error: `${ref} isn't an image reference` };
6211
+ if (DIGEST.test(parsed.reference)) return { digest: parsed.reference };
6212
+ const { host, repository, reference } = parsed;
6213
+ const fetchFn = options.fetch ?? fetch;
6214
+ const signal = AbortSignal.any([AbortSignal.timeout(options.timeoutMs ?? 15e3), ...options.signal ? [options.signal] : []]);
6215
+ const login = options.credential?.(host);
6216
+ const url = `${scheme(host)}://${host}/v2/${repository}/manifests/${encodeURIComponent(reference)}`;
6217
+ const ask = (method, authorization) => fetchFn(url, {
6218
+ method,
6219
+ headers: {
6220
+ accept: ACCEPT,
6221
+ ...authorization ? { authorization } : {}
6222
+ },
6223
+ signal
6224
+ });
6225
+ try {
6226
+ let authorization = login && "token" in login ? `Bearer ${login.token}` : null;
6227
+ let response = await ask("HEAD", authorization);
6228
+ if (response.status === 401 && !(login && "token" in login)) {
6229
+ const asked = challenge(response.headers.get("www-authenticate"));
6230
+ if (asked.scheme === "bearer" && asked.params.realm) {
6231
+ const token = await bearerToken(asked.params, repository, login, fetchFn, signal);
6232
+ if ("error" in token) return { error: `${host} refused a token for ${repository}: ${token.error}` };
6233
+ authorization = `Bearer ${token.token}`;
6234
+ } else if (asked.scheme === "basic" && login) authorization = basic(login);
6235
+ if (authorization) response = await ask("HEAD", authorization);
6236
+ }
6237
+ if (response.ok) {
6238
+ const said = response.headers.get("docker-content-digest");
6239
+ if (said && DIGEST.test(said)) return { digest: said };
6240
+ const body = await ask("GET", authorization);
6241
+ if (body.ok) {
6242
+ const header = body.headers.get("docker-content-digest");
6243
+ if (header && DIGEST.test(header)) return { digest: header };
6244
+ const bytes = Buffer.from(await body.arrayBuffer());
6245
+ return { digest: `sha256:${createHash("sha256").update(bytes).digest("hex")}` };
6246
+ }
6247
+ response = body;
6248
+ }
6249
+ if (response.status === 401 || response.status === 403) return { error: `${host} refused ${repository} (${response.status}): it doesn't exist, or it's private and needs a registry login` };
6250
+ if (response.status === 404) return { error: `${ref} isn't in ${host}` };
6251
+ return { error: `${host} answered ${response.status} for ${ref}` };
6252
+ } catch (cause) {
6253
+ if (options.signal?.aborted) throw cause;
6254
+ return { error: `couldn't reach ${host}: ${cause instanceof Error ? cause.cause instanceof Error ? cause.cause.message : cause.message : String(cause)}` };
6255
+ }
6256
+ }
6257
+ async function bearerToken(params, repository, login, fetchFn, signal) {
6258
+ const url = new URL(params.realm);
6259
+ const protectedRealm = url.protocol === "https:" || loopback(url.host);
6260
+ if (params.service) url.searchParams.set("service", params.service);
6261
+ url.searchParams.set("scope", params.scope ?? `repository:${repository}:pull`);
6262
+ const response = await fetchFn(url, {
6263
+ headers: login && "username" in login && protectedRealm ? { authorization: basic(login) } : {},
6264
+ signal
6265
+ });
6266
+ if (!response.ok) return { error: `${response.status}` };
6267
+ const body = await response.json().catch(() => null);
6268
+ const token = body?.token ?? body?.access_token;
6269
+ return typeof token === "string" && token ? { token } : { error: "no token in the answer" };
6270
+ }
5555
6271
  // ../sandbox-docker/src/shells.ts
5556
6272
  const SYSTEM_PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
5557
6273
  const EXEC_UMASK = "umask 022";
@@ -5565,7 +6281,7 @@ const envStream = (env) => Object.entries(env).map(([k, v]) => `${k}=${v}\0`).jo
5565
6281
  */
5566
6282
  const READER = `${EXEC_UMASK}; while IFS= read -r -d "" kv; do export "$kv"; done; cd -- "$1" || exit 1; exec /usr/bin/perl -e 'setpgrp(0, 0); exec @ARGV' bash -c "$2" </dev/null`;
5567
6283
  /**
5568
- * The Linux profile: the login user has passwordless `sudo`, the agent's commands run as
6284
+ * The Linux profile: the login user has passwordless `sudo` or is root, the agent's commands run as
5569
6285
  * {@link SANDBOX_USER} with only `user`'s variables, and reeval's own run as root in
5570
6286
  * {@link SANDBOX_STATE}. Each command carries a marker in its environment, which `kill` finds in
5571
6287
  * `/proc`. `remote` is the host argv that runs one command line as the login user (`ssh`).
@@ -5576,9 +6292,11 @@ function linuxShell(o) {
5576
6292
  const seenHome = o.user.HOME;
5577
6293
  const bind = o.layout && seenHome && o.layout.home !== seenHome ? o.layout.home : void 0;
5578
6294
  const marker = (exec) => `${o.id}-${exec}`;
5579
- const asSandboxUser = (command) => bind ? `sudo -n -- unshare --mount --propagation private /bin/sh -c ${shellQuote(`mount --bind ${shellQuote(bind)} ${shellQuote(seenHome ?? "")} && exec setpriv --reuid=${sandboxUser} --regid=${sandboxUser} --init-groups -- ${command}`)}` : `sudo -n -H -u ${sandboxUser} -- ${command}`;
6295
+ const sudo = o.loginRoot ? "" : "sudo -n -- ";
6296
+ const setpriv = `setpriv --reuid=${sandboxUser} --regid=${sandboxUser} --init-groups --`;
6297
+ const asSandboxUser = (command) => bind ? `${sudo}unshare --mount --propagation private /bin/sh -c ${shellQuote(`mount --bind ${shellQuote(bind)} ${shellQuote(seenHome ?? "")} && exec ${setpriv} ${command}`)}` : o.loginRoot ? `${setpriv} env -i HOME=${shellQuote(seenHome ?? "/")} PATH=${SYSTEM_PATH} ${command}` : `sudo -n -H -u ${sandboxUser} -- ${command}`;
5580
6298
  const asUser = (cwd, command) => asSandboxUser(`env -i ${Object.entries(o.user).map(([k, v]) => shellQuote(`${k}=${v}`)).join(" ")} bash -c ${shellQuote(READER)} bash ${shellQuote(cwd)} ${shellQuote(command)}`);
5581
- const asRoot = (command, mark) => `sudo -n -- env -i PATH=${SYSTEM_PATH} HOME=/root${mark ? ` ${EXEC_MARKER}=${mark}` : ""} /bin/sh -c ${shellQuote(`cd ${stateDir} || exit 1; ${EXEC_UMASK}; ${command}`)}`;
6299
+ const asRoot = (command, mark) => `${sudo}env -i PATH=${SYSTEM_PATH} HOME=/root${mark ? ` ${EXEC_MARKER}=${mark}` : ""} /bin/sh -c ${shellQuote(`cd ${stateDir} || exit 1; ${EXEC_UMASK}; ${command}`)}`;
5582
6300
  /**
5583
6301
  * Killing the host's program leaves the command running on the machine, so kill what has its
5584
6302
  * marker, and the process group of each: a process that cleared its environment (`env -i`)
@@ -5926,6 +6644,11 @@ const homeFiles = (label) => {
5926
6644
  };
5927
6645
  };
5928
6646
  /**
6647
+ * Root commands that keep the sandbox user's home as the machine's copy for `label`, which a slot
6648
+ * unpacks into its own home rather than installing: what an image with the install baked in runs.
6649
+ */
6650
+ const keepHomeCopy = (label) => `mkdir -p ${shellQuote(HOMES)} && chmod 700 ${shellQuote(HOMES)} && tar -C ${shellQuote(posix.dirname(SANDBOX_HOME))} -cf ${shellQuote(homeFiles(label).tar)} ${shellQuote(posix.basename(SANDBOX_HOME))}`;
6651
+ /**
5929
6652
  * Root commands that empty a slot's home back to the skeleton. The directory itself stays: on a
5930
6653
  * shared machine, slot 0's is where the other slots' commands see their own homes.
5931
6654
  */
@@ -5980,7 +6703,7 @@ function slotHome(layout, label) {
5980
6703
  }
5981
6704
  /**
5982
6705
  * Sets up a Linux VM reached over SSH for a harness session: the login user has passwordless
5983
- * `sudo`, and the agent, setup steps and checks run as {@link SANDBOX_USER}, a user made here with
6706
+ * `sudo` or is root ({@link SshTarget.loginRoot}), and the agent, setup steps and checks run as {@link SANDBOX_USER}, a user made here with
5984
6707
  * no `sudo` and none of the login user's groups or variables. Ports are reached through the
5985
6708
  * egress gateway's tunnel. When setting up fails, the connection is closed.
5986
6709
  */
@@ -6057,7 +6780,8 @@ async function connectSsh(options) {
6057
6780
  `mkdir -p ${layout.state} && chown 0:0 ${layout.state} && chmod 700 ${layout.state}`,
6058
6781
  ...options.prepare ? [options.prepare] : []
6059
6782
  ].join(" && ");
6060
- const asRoot = options.layout ? `sudo -n -- flock ${SETUP_LOCK} /bin/sh -c ${shellQuote(setup)}` : `sudo -n -- /bin/sh -c ${shellQuote(setup)}`;
6783
+ const sudo = asRootPrefix(target);
6784
+ const asRoot = options.layout ? `${sudo}flock ${SETUP_LOCK} /bin/sh -c ${shellQuote(setup)} sh "$PATH"` : `${sudo}/bin/sh -c ${shellQuote(setup)} sh "$PATH"`;
6061
6785
  const deadline = Date.now() + (options.connectTimeoutMs ?? 6e4);
6062
6786
  for (let wait = 500;; wait = Math.min(wait * 2, 5e3)) {
6063
6787
  const made = await ssh(asRoot).catch(fail);
@@ -6087,7 +6811,8 @@ async function connectSsh(options) {
6087
6811
  id: `${target.hostKeyAlias}-${layout.user}`,
6088
6812
  user: baseEnv,
6089
6813
  signal,
6090
- layout
6814
+ layout,
6815
+ ...target.loginRoot && { loginRoot: true }
6091
6816
  });
6092
6817
  return {
6093
6818
  root: sshTransport(target),
@@ -6096,7 +6821,7 @@ async function connectSsh(options) {
6096
6821
  restored: false,
6097
6822
  waitedMs: 0
6098
6823
  };
6099
- const [bin = "ssh", ...args] = sshArgv(target, `sudo -n -- /bin/sh -c ${shellQuote(`${EXEC_UMASK}\n${slotHome(layout, options.home)}`)}`);
6824
+ const [bin = "ssh", ...args] = sshArgv(target, `${sudo}/bin/sh -c ${shellQuote(`${EXEC_UMASK}\n${slotHome(layout, options.home)}`)}`);
6100
6825
  const startedAt = Date.now();
6101
6826
  const child = spawn(bin, args, { stdio: [
6102
6827
  "pipe",
@@ -6152,7 +6877,7 @@ async function connectSsh(options) {
6152
6877
  `mv ${shellQuote(f.tar)}.$$ ${shellQuote(f.tar)}`
6153
6878
  ].join(" && ");
6154
6879
  try {
6155
- const r = await ssh(`sudo -n -- /bin/sh -c ${shellQuote(command)}`);
6880
+ const r = await ssh(`${sudo}/bin/sh -c ${shellQuote(command)}`);
6156
6881
  if (r.exitCode !== 0) throw new Error(`Couldn't keep ${layout.user}'s home in ${options.description}: ${r.stderr.trim().slice(-500)}`);
6157
6882
  } finally {
6158
6883
  await release();
@@ -6184,6 +6909,6 @@ async function connectSsh(options) {
6184
6909
  })
6185
6910
  };
6186
6911
  }
6187
- export { startGateway as $, failureCause as $t, harnessImageFor as A, harnessLabel as At, reevalImageKey as B, dockerState as Bt, buildInstallLayer as C, LABEL as Ct, dockerfileKey as D, SANDBOX_USER as Dt, dockerfileBases as E, SANDBOX_STATE as Et, localKey as F, dockerignoreMatcher as Ft, EgressUnavailableError as G, OPAQUE_OUTPUT as Gt, sourceTreeHash as H, imageTags as Ht, pluginBuildDir as I, docker as It, createDockerSession as J, run as Jt, PRIVILEGED_CAPABILITIES as K, onDockerCommand as Kt, pluginBuildKey as L, dockerAvailable as Lt, installLayerTag as M, isBakedHarness as Mt, installScript as N, slotLayout as Nt, dockerfileTag as O, WORKSPACE_DIR as Ot, isLocalKey as P, contextFiles as Pt, PROXY_PORT as Q, causeLine as Qt, pluginLayerTag as R, dockerCapacity as Rt, buildImage as S, HARNESS_PACKAGES as St, contextHash as T, SANDBOX_ROOT as Tt, usesReevalBase as U, isRegistryDigest as Ut, resolveFrom as V, imageInfo as Vt, DEFAULT_LIMITS as W, removeContainerDetached as Wt, pathOperations as X, ImageBuildError as Xt, dockerSandboxProvider as Y, shellQuote as Yt, CA_PATH as Z, RETRY_DELAYS as Zt, bakeKey as _, requestFacts as _t, enginePlatform as a, engineSpec as an, sshTransport as at, bakedRecipe as b, BRIDGE_PORT as bt, registryProblem as c, placeholder as ct, DOCKER_CONTEXT as d, onEndpoint as dt, isTransient as en, SSH_OPTIONS as et, PLATFORM as f, DOCKER_EGRESS as ft, bakeHarness as g, hostAllowed as gt, REEVAL_BASE_ARG as h, defaultAllowedHosts as ht, darwinShell as i, dockerSeccompFile as in, sshArgv as it, imageKey as j, imageFor as jt, fromImageKey as k, adapterVersion as kt, registryRef as l, applyTransformations as lt, PNPM_VERSION as m, PACKAGE_HOSTS as mt, resetSlot as n, retryTransient as nn, controlPathFits as nt, pullLayer as o, normalizeImageId as on, MODEL_FIELD as ot, PLUGIN_BUILDS_DIR as p, HARNESS_HOSTS as pt, ROOT_CAPABILITIES as q, traceDocker as qt, transportSession as r, ENGINES as rn, privateDir as rt, pushLayer as s, usageReader as st, connectSsh as t, parseBuildOutput as tn, controlOptions as tt, MCP_TIMER as u, matches as ut, bakedAdapter as v, BAKED_HARNESSES as vt, buildPluginLayer as w, SANDBOX_HOME as wt, buildDockerfile as x, DEFAULT_IMAGE as xt, bakedHarnessName as y, BASE_IMAGE as yt, pruneImages as z, dockerOk as zt };
6912
+ export { PRIVILEGED_CAPABILITIES as $, hostCommand as $t, dockerfileBases as A, adapterVersion as At, isLocalKey as B, imageInfo as Bt, bakedHarnessName as C, normalizeImageId as Cn, HARNESS_PACKAGES as Ct, buildInstallLayer as D, SANDBOX_STATE as Dt, buildImage as E, SANDBOX_ROOT as Et, harnessImageFor as F, docker as Ft, pruneImages as G, controlOptions as Gt, pluginBuildDir as H, isRegistryDigest as Ht, imageKey as I, dockerAvailable as It, sourceTreeHash as J, sshArgv as Jt, reevalImageKey as K, controlPathFits as Kt, installLayerLines as L, dockerCapacity as Lt, dockerfileKey as M, imageFor as Mt, dockerfileTag as N, isBakedHarness as Nt, buildPluginLayer as O, SANDBOX_USER as Ot, fromImageKey as P, slotLayout as Pt, EgressUnavailableError as Q, traceDocker as Qt, installLayerTag as R, dockerOk as Rt, bakedAdapter as S, isRemoteEngine as Sn, DEFAULT_IMAGE as St, buildDockerfile as T, SANDBOX_HOME as Tt, pluginBuildKey as U, removeContainerDetached as Ut, localKey as V, imageTags as Vt, pluginLayerTag as W, SSH_OPTIONS as Wt, usesReevalBase as X, OPAQUE_OUTPUT as Xt, toolchainDockerfile as Y, sshTransport as Yt, DEFAULT_LIMITS as Z, onDockerCommand as Zt, PLUGIN_BUILDS_DIR as _, parseBuildOutput as _n, hostAllowed as _t, darwinShell as a, readTree as an, PROXY_PORT as at, bakeHarness as b, dockerSeccompFile as bn, BASE_IMAGE as bt, enginePlatform as c, contextFiles as cn, usageReader as ct, registryProblem as d, shellQuote as dn, matches as dt, isSshFailure as en, ROOT_CAPABILITIES as et, registryRef as f, ImageBuildError as fn, onEndpoint as ft, PLATFORM as g, isTransient as gn, defaultAllowedHosts as gt, NODE_IMAGE as h, failureCause as hn, PACKAGE_HOSTS as ht, transportSession as i, readTar as in, CA_PATH as it, dockerfileFinalBase as j, harnessLabel as jt, contextHash as k, WORKSPACE_DIR as kt, pullLayer as l, dockerignoreMatcher as ln, placeholder as lt, DOCKER_CONTEXT as m, causeLine as mn, HARNESS_HOSTS as mt, keepHomeCopy as n, spawnEngine as nn, dockerSandboxProvider as nt, parseImageRef as o, safeTarPath as on, startGateway as ot, MCP_TIMER as p, RETRY_DELAYS as pn, DOCKER_EGRESS as pt, resolveFrom as q, privateDir as qt, resetSlot as r, extractTar as rn, pathOperations as rt, registryDigest as s, writeTar as sn, MODEL_FIELD as st, connectSsh as t, remoteBuild as tn, createDockerSession as tt, pushLayer as u, run as un, applyTransformations as ut, PNPM_VERSION as v, retryTransient as vn, requestFacts as vt, bakedRecipe as w, LABEL$1 as wt, bakeKey as x, engineSpec as xn, BRIDGE_PORT as xt, REEVAL_BASE_ARG as y, ENGINES as yn, BAKED_HARNESSES as yt, installScript as z, dockerState as zt };
6188
6913
 
6189
- //# sourceMappingURL=src-CWfy8ct8.js.map
6914
+ //# sourceMappingURL=src-C5rrQlt8.js.map