reeval 0.23.0 → 0.24.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 (413) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +16 -16
  3. package/THIRD_PARTY_NOTICES.md +14 -14
  4. package/dist/{adapter-Dlq3-4OS.js → adapter-dHdepWKb.js} +7 -7
  5. package/dist/{adapter-Dlq3-4OS.js.map → adapter-dHdepWKb.js.map} +1 -1
  6. package/dist/{agent-OsAfayRf.js → agent-CZpiwA_r.js} +8 -8
  7. package/dist/{agent-OsAfayRf.js.map → agent-CZpiwA_r.js.map} +1 -1
  8. package/dist/{agents-BztvTkfM.js → agents-CEapsHV-.js} +26 -19
  9. package/dist/agents-CEapsHV-.js.map +1 -0
  10. package/dist/app-files-Dsr3U1Q7.js +10 -0
  11. package/dist/app-files-Dsr3U1Q7.js.map +1 -0
  12. package/dist/{assemble-XrZskSNj.js → assemble-DUtbByvj.js} +1 -1
  13. package/dist/{assemble-Doa1m-HW.js → assemble-Dw1bF13I.js} +30 -17
  14. package/dist/{assemble-Doa1m-HW.js.map → assemble-Dw1bF13I.js.map} +1 -1
  15. package/dist/{attach-BH2HdwH_.js → attach-DvYiMu6w.js} +18 -10
  16. package/dist/attach-DvYiMu6w.js.map +1 -0
  17. package/dist/{attempt-_dUsblVx.js → attempt-DxR1agFo.js} +2 -2
  18. package/dist/{attempt-_dUsblVx.js.map → attempt-DxR1agFo.js.map} +1 -1
  19. package/dist/{attempt-host-8mQV8Uee.js → attempt-host-DgeJFSZw.js} +7 -7
  20. package/dist/{attempt-host-8mQV8Uee.js.map → attempt-host-DgeJFSZw.js.map} +1 -1
  21. package/dist/boat-BBPOc_bs.js +1 -0
  22. package/dist/{boat-DKjqo_ie.js → boat-CUNgSc75.js} +10 -9
  23. package/dist/boat-CUNgSc75.js.map +1 -0
  24. package/dist/{boat-images-CRN_U_eG.js → boat-images-BuFigiEb.js} +8 -8
  25. package/dist/{boat-images-CRN_U_eG.js.map → boat-images-BuFigiEb.js.map} +1 -1
  26. package/dist/{bundle-DU2aQVeq.js → bundle-yEgI3RsI.js} +21 -15
  27. package/dist/bundle-yEgI3RsI.js.map +1 -0
  28. package/dist/{capture-By1byHaX.js → capture-DdEKVrwk.js} +15 -15
  29. package/dist/{capture-By1byHaX.js.map → capture-DdEKVrwk.js.map} +1 -1
  30. package/dist/capture-DxxB3d7p.js +1 -0
  31. package/dist/{cases-CM-MQRQp.js → cases-B7QkvMGE.js} +2 -2
  32. package/dist/{cases-CM-MQRQp.js.map → cases-B7QkvMGE.js.map} +1 -1
  33. package/dist/cases-CA7gxxdr.js +1 -0
  34. package/dist/{cli-DMHOwdVr.js → cli-Z7aw8k25.js} +274 -165
  35. package/dist/cli-Z7aw8k25.js.map +1 -0
  36. package/dist/{cli-spec-D0wuUaj9.js → cli-spec-3zvLC9YW.js} +117 -15
  37. package/dist/cli-spec-3zvLC9YW.js.map +1 -0
  38. package/dist/cli.js +6 -2
  39. package/dist/cli.js.map +1 -1
  40. package/dist/{client-B41UK150.js → client-kUwtq-vt.js} +3 -3
  41. package/dist/{client-B41UK150.js.map → client-kUwtq-vt.js.map} +1 -1
  42. package/dist/{hosted-Co-waHe0.js → cloud-DuHcNQVV.js} +38 -38
  43. package/dist/cloud-DuHcNQVV.js.map +1 -0
  44. package/dist/cloud-files-BjinrTTe.js +301 -0
  45. package/dist/cloud-files-BjinrTTe.js.map +1 -0
  46. package/dist/{hosted-5Zz2peTR.js → cloud-owVBaSRt.js} +30 -30
  47. package/dist/cloud-owVBaSRt.js.map +1 -0
  48. package/dist/cloud-run-C08P_Uap.js +1 -0
  49. package/dist/cloud-run-DqMkSGYB.js +500 -0
  50. package/dist/cloud-run-DqMkSGYB.js.map +1 -0
  51. package/dist/cloud-secrets-Bak83tik.js +337 -0
  52. package/dist/cloud-secrets-Bak83tik.js.map +1 -0
  53. package/dist/{command-8GIHYGZf.js → command-Bs6Knfm4.js} +13 -13
  54. package/dist/{command-8GIHYGZf.js.map → command-Bs6Knfm4.js.map} +1 -1
  55. package/dist/{command-CAmnWLFL.js → command-CeygdoVe.js} +19 -19
  56. package/dist/{command-CAmnWLFL.js.map → command-CeygdoVe.js.map} +1 -1
  57. package/dist/command-CoHN1ibe.js +183 -0
  58. package/dist/command-CoHN1ibe.js.map +1 -0
  59. package/dist/{command-ao0NZ8h0.js → command-CtmSJzPC.js} +18 -18
  60. package/dist/{command-ao0NZ8h0.js.map → command-CtmSJzPC.js.map} +1 -1
  61. package/dist/{command-CXxckfsq.js → command-efTGfUYb.js} +18 -130
  62. package/dist/command-efTGfUYb.js.map +1 -0
  63. package/dist/{commands-B3lnIPj5.js → commands-B_cAs8nG.js} +1 -1
  64. package/dist/{commands-ttChCsAy.js → commands-DR-NolV2.js} +25 -20
  65. package/dist/{commands-ttChCsAy.js.map → commands-DR-NolV2.js.map} +1 -1
  66. package/dist/{config-myJT1Qjc.js → config-Bn2OhCN_.js} +40 -34
  67. package/dist/config-Bn2OhCN_.js.map +1 -0
  68. package/dist/{context-DnzR9TNK.js → context-Ba7PNMMe.js} +2 -2
  69. package/dist/{context-DnzR9TNK.js.map → context-Ba7PNMMe.js.map} +1 -1
  70. package/dist/{cost-C21gGrju.js → cost-Dp-xFGJ1.js} +2 -2
  71. package/dist/{cost-C21gGrju.js.map → cost-Dp-xFGJ1.js.map} +1 -1
  72. package/dist/{cost-CdRX1s2p.js → cost-a_rUSdsf.js} +1 -1
  73. package/dist/{cursor-catalog-CUQrabJ_.js → cursor-catalog-BYIDSsLn.js} +5 -5
  74. package/dist/{cursor-catalog-CUQrabJ_.js.map → cursor-catalog-BYIDSsLn.js.map} +1 -1
  75. package/dist/{daytona-Dfhwtr9P.js → daytona-CWs9j9mt.js} +18 -15
  76. package/dist/daytona-CWs9j9mt.js.map +1 -0
  77. package/dist/daytona-image-BjVpi3KS.js +1 -0
  78. package/dist/{daytona-image-CnG6G00x.js → daytona-image-DmGlFAyq.js} +6 -5
  79. package/dist/daytona-image-DmGlFAyq.js.map +1 -0
  80. package/dist/db-Bjq6qr6c.js +2 -0
  81. package/dist/{db-5H95sFii.js → db-D6yQib7M.js} +12 -12
  82. package/dist/{db-5H95sFii.js.map → db-D6yQib7M.js.map} +1 -1
  83. package/dist/{default-effort-DYpCkJRk.js → default-effort-Bpz5ULfC.js} +2 -2
  84. package/dist/{default-effort-DYpCkJRk.js.map → default-effort-Bpz5ULfC.js.map} +1 -1
  85. package/dist/{default-effort-CtNY9CGW.js → default-effort-Ck6ViSaI.js} +1 -1
  86. package/dist/{dist-DeqeCUZe.js → dist-CZtW7eI5.js} +4 -4
  87. package/dist/{dist-DeqeCUZe.js.map → dist-CZtW7eI5.js.map} +1 -1
  88. package/dist/{docker-kpudeSxV.js → docker-Bbi4kmFj.js} +1 -1
  89. package/dist/{docker-CR0JZ1FE.js → docker-Dgw4aaRk.js} +4 -4
  90. package/dist/{docker-CR0JZ1FE.js.map → docker-Dgw4aaRk.js.map} +1 -1
  91. package/dist/{doctor-aE-RMbB_.js → doctor-BfS6jswW.js} +30 -30
  92. package/dist/{doctor-aE-RMbB_.js.map → doctor-BfS6jswW.js.map} +1 -1
  93. package/dist/{environment-C8pUCD_A.js → environment-BY8lVFFK.js} +9 -9
  94. package/dist/{environment-C8pUCD_A.js.map → environment-BY8lVFFK.js.map} +1 -1
  95. package/dist/{errors-DPUoUTdK.js → errors-P8oHhNzy.js} +2 -2
  96. package/dist/{errors-DPUoUTdK.js.map → errors-P8oHhNzy.js.map} +1 -1
  97. package/dist/{eval-source-CaLIGH3U.js → eval-source-BB8In3xo.js} +6 -6
  98. package/dist/{eval-source-CaLIGH3U.js.map → eval-source-BB8In3xo.js.map} +1 -1
  99. package/dist/{evaluate-4kBVtwZZ.js → evaluate-B8I9AKgw.js} +50 -40
  100. package/dist/evaluate-B8I9AKgw.js.map +1 -0
  101. package/dist/{evaluate-DHaNtgVf.d.ts → evaluate-B9_nukrc.d.ts} +2 -3
  102. package/dist/{events-CXxFvVMK.js → events-D97ZzAeq.js} +5 -5
  103. package/dist/{events-CXxFvVMK.js.map → events-D97ZzAeq.js.map} +1 -1
  104. package/dist/{fake-bootstrap-CzxrCqO3.js → fake-bootstrap-4DFtzib0.js} +2 -2
  105. package/dist/{fake-bootstrap-CzxrCqO3.js.map → fake-bootstrap-4DFtzib0.js.map} +1 -1
  106. package/dist/files-5HsFIpxw.js +1 -0
  107. package/dist/{files-CDfG8swM.js → files-B0DbptiO.js} +25 -16
  108. package/dist/files-B0DbptiO.js.map +1 -0
  109. package/dist/{files-BkvxIqfI.js → files-B4K1k__s.js} +5 -5
  110. package/dist/{files-BkvxIqfI.js.map → files-B4K1k__s.js.map} +1 -1
  111. package/dist/files-BNg3wgw_.js +1 -0
  112. package/dist/files-BesexM88.js +1477 -0
  113. package/dist/files-BesexM88.js.map +1 -0
  114. package/dist/{files-Cs2dtb7-.js → files-DE13BqBC.js} +2 -2
  115. package/dist/{files-Cs2dtb7-.js.map → files-DE13BqBC.js.map} +1 -1
  116. package/dist/files-DNgQwgA0.js +1 -0
  117. package/dist/files-DvDUSrWL.js +1 -0
  118. package/dist/{files-DpwJW3w6.js → files-GBTUBAek.js} +3 -3
  119. package/dist/{files-DpwJW3w6.js.map → files-GBTUBAek.js.map} +1 -1
  120. package/dist/{files-DgHeTdCZ.js → files-TwSVeWwM.js} +6 -6
  121. package/dist/{files-DgHeTdCZ.js.map → files-TwSVeWwM.js.map} +1 -1
  122. package/dist/gateway.d.ts +2 -3
  123. package/dist/{git-BnnNEXqh.js → git-DatgUcnf.js} +3 -3
  124. package/dist/{git-BnnNEXqh.js.map → git-DatgUcnf.js.map} +1 -1
  125. package/dist/{harness-nwnyghJZ.js → harness-EZNoeUBf.js} +2 -2
  126. package/dist/{harness-nwnyghJZ.js.map → harness-EZNoeUBf.js.map} +1 -1
  127. package/dist/{harness-install-BfMBYDfP.js → harness-install-HgR73tpF.js} +4 -3
  128. package/dist/harness-install-HgR73tpF.js.map +1 -0
  129. package/dist/harness.d.ts +2 -3
  130. package/dist/harness.js +1 -1
  131. package/dist/{ids-a6cr243_.js → ids-DqEvrBFZ.js} +2 -2
  132. package/dist/{ids-a6cr243_.js.map → ids-DqEvrBFZ.js.map} +1 -1
  133. package/dist/{images-DtXwj2wL.js → images-SRE4f3SM.js} +13 -13
  134. package/dist/{images-DtXwj2wL.js.map → images-SRE4f3SM.js.map} +1 -1
  135. package/dist/index.d.ts +4 -5
  136. package/dist/index.js +5 -5
  137. package/dist/init-CS5kEaVg.js +1 -0
  138. package/dist/{init-Ci_IAp8p.js → init-D5F9MYPC.js} +6 -6
  139. package/dist/{init-Ci_IAp8p.js.map → init-D5F9MYPC.js.map} +1 -1
  140. package/dist/{ink-list-Dnh6XD3C.js → ink-list-CLq6YVB8.js} +3 -3
  141. package/dist/{ink-list-Dnh6XD3C.js.map → ink-list-CLq6YVB8.js.map} +1 -1
  142. package/dist/{inputs-z4JqnQ5g.js → inputs-B_FsOD2N.js} +6 -6
  143. package/dist/{inputs-z4JqnQ5g.js.map → inputs-B_FsOD2N.js.map} +1 -1
  144. package/dist/{inputs-load-DPUP_IFL.js → inputs-load-B4MFkp0Q.js} +3 -3
  145. package/dist/{inputs-load-DPUP_IFL.js.map → inputs-load-B4MFkp0Q.js.map} +1 -1
  146. package/dist/inputs-load-D4IsEjq3.js +1 -0
  147. package/dist/internal/vm.d.ts +7 -8
  148. package/dist/internal/vm.js +6 -6
  149. package/dist/internal/vm.js.map +1 -1
  150. package/dist/{invocations-C1gY3E0J.js → invocations-BxQqe5GU.js} +5 -5
  151. package/dist/{invocations-C1gY3E0J.js.map → invocations-BxQqe5GU.js.map} +1 -1
  152. package/dist/issue-DmSorsTF.js +1 -0
  153. package/dist/issue-iErT9KkK.js +120 -0
  154. package/dist/issue-iErT9KkK.js.map +1 -0
  155. package/dist/{jiti-ILwyxt93.js → jiti-CtahaHaY.js} +2 -2
  156. package/dist/{jiti-ILwyxt93.js.map → jiti-CtahaHaY.js.map} +1 -1
  157. package/dist/{judge-DwzqucLS.js → judge-MOKPsr6R.js} +7 -4
  158. package/dist/judge-MOKPsr6R.js.map +1 -0
  159. package/dist/judge.d.ts +5 -6
  160. package/dist/judge.js +1 -1
  161. package/dist/{judgments-Cj8bFaDG.js → judgments-Dur4D2pj.js} +2 -2
  162. package/dist/{judgments-Cj8bFaDG.js.map → judgments-Dur4D2pj.js.map} +1 -1
  163. package/dist/{kinds-DEKXOWVJ.js → kinds-Dohijzi-.js} +11 -10
  164. package/dist/kinds-Dohijzi-.js.map +1 -0
  165. package/dist/{layout-nCnU9Vu2.js → layout-BhhJAEgf.js} +3 -3
  166. package/dist/{layout-nCnU9Vu2.js.map → layout-BhhJAEgf.js.map} +1 -1
  167. package/dist/{list-MK4L8tfW.js → list-ClDb8qiX.js} +9 -7
  168. package/dist/list-ClDb8qiX.js.map +1 -0
  169. package/dist/{live-BkPNXVmN.js → live-C7iGaDCA.js} +9 -9
  170. package/dist/{live-BkPNXVmN.js.map → live-C7iGaDCA.js.map} +1 -1
  171. package/dist/live-C7kN5v2P.js +1 -0
  172. package/dist/{live-Dlq-S2yy.js → live-QFILMmql.js} +2 -2
  173. package/dist/{live-Dlq-S2yy.js.map → live-QFILMmql.js.map} +1 -1
  174. package/dist/{machine-service-Byl0BlcT.js → machine-service-DpJScNtA.js} +1 -1
  175. package/dist/{machine-service-CZiXiVsS.js → machine-service-xFhakTs5.js} +3 -3
  176. package/dist/{machine-service-CZiXiVsS.js.map → machine-service-xFhakTs5.js.map} +1 -1
  177. package/dist/{machines-Ch5bhgvk.js → machines-Cm-rU7jp.js} +36 -36
  178. package/dist/{machines-Ch5bhgvk.js.map → machines-Cm-rU7jp.js.map} +1 -1
  179. package/dist/{model-DRa7yv6K.js → model-CcvSrrq9.js} +5 -5
  180. package/dist/{model-DRa7yv6K.js.map → model-CcvSrrq9.js.map} +1 -1
  181. package/dist/model-Colu5mEp.js +1 -0
  182. package/dist/{model-CRh8aiYS.js → model-D9WMMEWD.js} +4 -4
  183. package/dist/{model-CRh8aiYS.js.map → model-D9WMMEWD.js.map} +1 -1
  184. package/dist/{model-lLaUxxno.js → model-Rmv-L9Jb.js} +1 -1
  185. package/dist/{model-LoLnq9y1.js → model-mTaaEkeQ.js} +6 -6
  186. package/dist/{model-LoLnq9y1.js.map → model-mTaaEkeQ.js.map} +1 -1
  187. package/dist/{node-BQjSQw0d.js → node-Bl2CtSjB.js} +8 -8
  188. package/dist/{node-BQjSQw0d.js.map → node-Bl2CtSjB.js.map} +1 -1
  189. package/dist/options-CmRy82gl.js +1 -0
  190. package/dist/{patch-D8X6VB-e.js → patch-DhJDHRFs.js} +2 -2
  191. package/dist/{patch-D8X6VB-e.js.map → patch-DhJDHRFs.js.map} +1 -1
  192. package/dist/{plan-DgIVIrXJ.js → plan-CC0bKbm9.js} +11 -11
  193. package/dist/{plan-DgIVIrXJ.js.map → plan-CC0bKbm9.js.map} +1 -1
  194. package/dist/{plugins-DvEbow6a.js → plugins-PwEtW8GH.js} +6 -6
  195. package/dist/{plugins-DvEbow6a.js.map → plugins-PwEtW8GH.js.map} +1 -1
  196. package/dist/{preflight-Qm4wE094.js → preflight-BHUEfA4m.js} +3 -3
  197. package/dist/{preflight-Qm4wE094.js.map → preflight-BHUEfA4m.js.map} +1 -1
  198. package/dist/{preflight-BKGbxN67.js → preflight-BzvLYQ70.js} +8 -8
  199. package/dist/{preflight-BKGbxN67.js.map → preflight-BzvLYQ70.js.map} +1 -1
  200. package/dist/{preflight-dJqs5x3r.js → preflight-DEV_vrdB.js} +1 -1
  201. package/dist/preflight-xa8_eGOW.js +1 -0
  202. package/dist/{prepare-BAjRSoku.js → prepare-D7hPrh7Q.js} +7 -7
  203. package/dist/{prepare-BAjRSoku.js.map → prepare-D7hPrh7Q.js.map} +1 -1
  204. package/dist/{prepare-CRPPfRJf.js → prepare-DS42k409.js} +2 -2
  205. package/dist/prices-C_mbZa5a.js +1 -0
  206. package/dist/{prices-DCokI_Ka.js → prices-DXJsP2Ha.js} +3 -3
  207. package/dist/{prices-DCokI_Ka.js.map → prices-DXJsP2Ha.js.map} +1 -1
  208. package/dist/process-RPlEhpHz.js +118 -0
  209. package/dist/process-RPlEhpHz.js.map +1 -0
  210. package/dist/{provenance-CSyRCc9B.js → provenance-DgQJ-dq7.js} +5 -5
  211. package/dist/{provenance-CSyRCc9B.js.map → provenance-DgQJ-dq7.js.map} +1 -1
  212. package/dist/{providers-DkaEJvF5.js → providers-B5Vr0hKH.js} +32 -32
  213. package/dist/{providers-DkaEJvF5.js.map → providers-B5Vr0hKH.js.map} +1 -1
  214. package/dist/{providers-DxZ26YoG.js → providers-N4HDMeeo.js} +1 -1
  215. package/dist/query-BXV6pRyI.js +1 -0
  216. package/dist/{query-BL66BOqL.js → query-CmTjYbqh.js} +2 -2
  217. package/dist/{query-BL66BOqL.js.map → query-CmTjYbqh.js.map} +1 -1
  218. package/dist/{questions-boVPzGoC.js → questions-DnqkJga0.js} +7 -7
  219. package/dist/{questions-boVPzGoC.js.map → questions-DnqkJga0.js.map} +1 -1
  220. package/dist/{recipe-qyIpP96r.js → recipe-B0NeT_Sn.js} +3 -3
  221. package/dist/{recipe-qyIpP96r.js.map → recipe-B0NeT_Sn.js.map} +1 -1
  222. package/dist/{record-D1_D1KFY.js → record-2liAelrB.js} +11 -5
  223. package/dist/record-2liAelrB.js.map +1 -0
  224. package/dist/{redact-t-L3VGy8.js → redact-DMueYS-v.js} +28 -6
  225. package/dist/redact-DMueYS-v.js.map +1 -0
  226. package/dist/{remarks-DEvk5f8v.js → remarks-D-9f1y1B.js} +10 -10
  227. package/dist/{remarks-DEvk5f8v.js.map → remarks-D-9f1y1B.js.map} +1 -1
  228. package/dist/{remarks-DqriPKxm.js → remarks-D5qOZzcX.js} +2 -2
  229. package/dist/{remarks-DqriPKxm.js.map → remarks-D5qOZzcX.js.map} +1 -1
  230. package/dist/{remote-CQoBRpOv.js → remote-B7BIRUTK.js} +6 -6
  231. package/dist/{remote-CQoBRpOv.js.map → remote-B7BIRUTK.js.map} +1 -1
  232. package/dist/{resolve-Bfo8sjd-.js → resolve-B60w6DcB.js} +20 -5
  233. package/dist/resolve-B60w6DcB.js.map +1 -0
  234. package/dist/resolve-CCLiJX4i.js +1 -0
  235. package/dist/{resolve-D2RqmybX.js → resolve-t9sOkGGS.js} +50 -17
  236. package/dist/resolve-t9sOkGGS.js.map +1 -0
  237. package/dist/{results-BpxzyoMd.js → results-Df910ONm.js} +6 -6
  238. package/dist/{results-BpxzyoMd.js.map → results-Df910ONm.js.map} +1 -1
  239. package/dist/{resume-2ekm_9OB.js → resume-4Q9q8AcE.js} +6 -6
  240. package/dist/{resume-2ekm_9OB.js.map → resume-4Q9q8AcE.js.map} +1 -1
  241. package/dist/{retry-CAhpW1hH.js → retry-C15f5yyy.js} +4 -4
  242. package/dist/{retry-CAhpW1hH.js.map → retry-C15f5yyy.js.map} +1 -1
  243. package/dist/{root-BzeoyfGd.js → root-Cm93-6ix.js} +3 -3
  244. package/dist/{root-BzeoyfGd.js.map → root-Cm93-6ix.js.map} +1 -1
  245. package/dist/{runtime-C5fKSFCz.js → runtime-CIsljVBy.js} +5 -5
  246. package/dist/{runtime-C5fKSFCz.js.map → runtime-CIsljVBy.js.map} +1 -1
  247. package/dist/sandbox/boat.d.ts +4 -5
  248. package/dist/sandbox/boat.js +2 -2
  249. package/dist/sandbox/daytona.d.ts +4 -5
  250. package/dist/sandbox/daytona.js +1 -1
  251. package/dist/{sandbox-t-Q-8lA_.js → sandbox-BffNervX.js} +3 -3
  252. package/dist/{sandbox-t-Q-8lA_.js.map → sandbox-BffNervX.js.map} +1 -1
  253. package/dist/sandbox.d.ts +4 -5
  254. package/dist/sandbox.js +1 -1
  255. package/dist/secrets-file-Dtd3h3kY.js +100 -0
  256. package/dist/secrets-file-Dtd3h3kY.js.map +1 -0
  257. package/dist/secrets-file-take-BXfYMTM-.js +33 -0
  258. package/dist/secrets-file-take-BXfYMTM-.js.map +1 -0
  259. package/dist/server-CeYUmuuu.js +1 -0
  260. package/dist/{server-BcLg9WzE.js → server-fSNuT3Z4.js} +12 -12
  261. package/dist/{server-BcLg9WzE.js.map → server-fSNuT3Z4.js.map} +1 -1
  262. package/dist/shared-B3iLKAiu.d.ts +1 -0
  263. package/dist/source-n7nUVm9p.js +1 -0
  264. package/dist/{source-CrXM19HD.js → source-zoRWRMql.js} +2 -2
  265. package/dist/{source-CrXM19HD.js.map → source-zoRWRMql.js.map} +1 -1
  266. package/dist/{src-DrLbG1HM.js → src-9V3C6A7C.js} +1 -1
  267. package/dist/{src-Bf5RZlPi.js → src-BQWAxhKD.js} +3 -3
  268. package/dist/{src-Bf5RZlPi.js.map → src-BQWAxhKD.js.map} +1 -1
  269. package/dist/{src-io_SKoZ5.js → src-Bj3WJs3t.js} +2 -2
  270. package/dist/{src-5dCrqbFd.js → src-CB5cZhaN.js} +1 -1
  271. package/dist/{src-C-ChdnG6.js → src-CDoAEO4u.js} +2 -2
  272. package/dist/{src-C-ChdnG6.js.map → src-CDoAEO4u.js.map} +1 -1
  273. package/dist/{src-Cf4vRyea.js → src-CFBg2ecq.js} +1 -1
  274. package/dist/{src-DNWiU__5.js → src-CGBwMZgM.js} +2 -2
  275. package/dist/{src-DNWiU__5.js.map → src-CGBwMZgM.js.map} +1 -1
  276. package/dist/{src-C6MsGyD6.js → src-CUrcaZ91.js} +1 -1
  277. package/dist/{src-DwcCKsV0.js → src-CcbV6VpV.js} +2 -2
  278. package/dist/{src-DEbNp-rx.js → src-DB0vml0O.js} +1 -1
  279. package/dist/{src-VG2IRoT4.js → src-DiS13D_q.js} +2 -2
  280. package/dist/{src-C5rrQlt8.js → src-OC89dAjO.js} +65 -129
  281. package/dist/src-OC89dAjO.js.map +1 -0
  282. package/dist/{src-Ds1pmXTg.js → src-TMKittwH.js} +1 -1
  283. package/dist/ssh-pool-ChpT-fDU.js +1 -0
  284. package/dist/{ssh-pool-Dvfx5GuV.js → ssh-pool-DwboLN9O.js} +10 -9
  285. package/dist/ssh-pool-DwboLN9O.js.map +1 -0
  286. package/dist/{start-COB07NpH.js → start-BwMyDneA.js} +27 -7
  287. package/dist/start-BwMyDneA.js.map +1 -0
  288. package/dist/{state-B319V1p8.js → state-CXTaT0t8.js} +10 -10
  289. package/dist/{state-B319V1p8.js.map → state-CXTaT0t8.js.map} +1 -1
  290. package/dist/state-CltRWlCu.js +1 -0
  291. package/dist/store/local.d.ts +2 -3
  292. package/dist/store/s3.d.ts +2 -3
  293. package/dist/{suite-D1tgXZxM.js → suite-C4XSg6Ls.js} +6 -6
  294. package/dist/{suite-D1tgXZxM.js.map → suite-C4XSg6Ls.js.map} +1 -1
  295. package/dist/suite-CIsyPqPA.js +2 -0
  296. package/dist/{summary-ClLns_wv.js → summary-DeeQJAR5.js} +8 -8
  297. package/dist/{summary-ClLns_wv.js.map → summary-DeeQJAR5.js.map} +1 -1
  298. package/dist/{sync-mOG74RXH.js → sync-bnI6WWaL.js} +6 -6
  299. package/dist/{sync-mOG74RXH.js.map → sync-bnI6WWaL.js.map} +1 -1
  300. package/dist/{tart-DMppfbEm.js → tart-CSP5Q0qV.js} +9 -8
  301. package/dist/tart-CSP5Q0qV.js.map +1 -0
  302. package/dist/{tart-bake-Cva_qdir.js → tart-bake-BCKRfyKm.js} +9 -8
  303. package/dist/tart-bake-BCKRfyKm.js.map +1 -0
  304. package/dist/{tart-bake-DVIoXWr_.js → tart-bake-d9UvIfe3.js} +1 -1
  305. package/dist/{tart-cli-D88c5YYJ.js → tart-cli-C4d5FXG1.js} +1 -1
  306. package/dist/{tart-cli-LzDud2Z6.js → tart-cli-CqSpUYGV.js} +3 -2
  307. package/dist/tart-cli-CqSpUYGV.js.map +1 -0
  308. package/dist/{tart-hosts-8N6Tt7Yb.js → tart-hosts-Du7SZM4w.js} +1 -1
  309. package/dist/{tart-hosts-CTRY5kQ2.js → tart-hosts-G0EUDt07.js} +5 -4
  310. package/dist/tart-hosts-G0EUDt07.js.map +1 -0
  311. package/dist/{tart-images-JfHirU8W.js → tart-images-De0-ib7R.js} +4 -4
  312. package/dist/{tart-images-JfHirU8W.js.map → tart-images-De0-ib7R.js.map} +1 -1
  313. package/dist/testing.d.ts +4 -5
  314. package/dist/testing.js +4 -4
  315. package/dist/{tool-class-CncfCw03.js → tool-class-B3ZFTSOw.js} +2 -2
  316. package/dist/{tool-class-CncfCw03.js.map → tool-class-B3ZFTSOw.js.map} +1 -1
  317. package/dist/{trace-BpXByD7W.js → trace-CfppUzD9.js} +2 -2
  318. package/dist/{trace-BpXByD7W.js.map → trace-CfppUzD9.js.map} +1 -1
  319. package/dist/{traits-CCD8XsmI.js → traits-Bj1PM5F7.js} +2 -2
  320. package/dist/{traits-CCD8XsmI.js.map → traits-Bj1PM5F7.js.map} +1 -1
  321. package/dist/{transcript-BXWZiMuC.js → transcript-CW02A4s9.js} +3 -3
  322. package/dist/{transcript-BXWZiMuC.js.map → transcript-CW02A4s9.js.map} +1 -1
  323. package/dist/types-CbcnJxCy.js.map +1 -1
  324. package/dist/{types-BDo8ttQo.d.ts → types-D4WEnzhY.d.ts} +51 -16
  325. package/dist/{ui-DUiVPbQ2.js → ui-DfvPNmPP.js} +7 -7
  326. package/dist/{ui-DUiVPbQ2.js.map → ui-DfvPNmPP.js.map} +1 -1
  327. package/dist/{vertex-BEWxHoxH.js → vertex-BLxYasfw.js} +2 -2
  328. package/dist/{vertex-BEWxHoxH.js.map → vertex-BLxYasfw.js.map} +1 -1
  329. package/dist/vertex-D4H9bKHD.d.ts +2 -0
  330. package/dist/vertex-DZDUpp0W.js +1 -0
  331. package/dist/view/index.d.ts +2 -3
  332. package/dist/view/index.js +10 -10
  333. package/dist/{views-CiZGh3ws.js → views-ChoSQxfF.js} +6 -6
  334. package/dist/{views-CiZGh3ws.js.map → views-ChoSQxfF.js.map} +1 -1
  335. package/dist/views-DU0PM0UW.js +2 -0
  336. package/dist/{vm-container-BVn7pXfD.js → vm-container-DOtIi_rd.js} +9 -8
  337. package/dist/vm-container-DOtIi_rd.js.map +1 -0
  338. package/dist/{vm-images-CNk-Zl2a.js → vm-images-CHutQVml.js} +13 -13
  339. package/dist/{vm-images-CNk-Zl2a.js.map → vm-images-CHutQVml.js.map} +1 -1
  340. package/dist/{worker-entry-DmXQ2Znu.js → worker-entry-CKBfEt0h.js} +7 -7
  341. package/dist/{worker-entry-DmXQ2Znu.js.map → worker-entry-CKBfEt0h.js.map} +1 -1
  342. package/dist/workspace-BKcNJAPb.js +1 -0
  343. package/dist/{workspace-wwvwEHzP.js → workspace-Cip2dVwU.js} +9 -8
  344. package/dist/workspace-Cip2dVwU.js.map +1 -0
  345. package/package.json +9 -9
  346. package/skills/reeval/SKILL.md +2 -2
  347. package/skills/setup/SKILL.md +1 -1
  348. package/dist/agents-BztvTkfM.js.map +0 -1
  349. package/dist/app-files-6NHzghym.js +0 -10
  350. package/dist/app-files-6NHzghym.js.map +0 -1
  351. package/dist/attach-BH2HdwH_.js.map +0 -1
  352. package/dist/boat-DKRH0Gv7.js +0 -1
  353. package/dist/boat-DKjqo_ie.js.map +0 -1
  354. package/dist/bundle-DU2aQVeq.js.map +0 -1
  355. package/dist/capture-BzjNv0qP.js +0 -1
  356. package/dist/cases-FvhbM8M5.js +0 -1
  357. package/dist/cli-DMHOwdVr.js.map +0 -1
  358. package/dist/cli-spec-D0wuUaj9.js.map +0 -1
  359. package/dist/command-CXxckfsq.js.map +0 -1
  360. package/dist/config-myJT1Qjc.js.map +0 -1
  361. package/dist/daytona-Dfhwtr9P.js.map +0 -1
  362. package/dist/daytona-image-CnG6G00x.js.map +0 -1
  363. package/dist/daytona-image-yJK3c4EV.js +0 -1
  364. package/dist/db-Bbg1n_2M.js +0 -2
  365. package/dist/evaluate-4kBVtwZZ.js.map +0 -1
  366. package/dist/files-BFnkOAhn.js +0 -1
  367. package/dist/files-BgQxoDlN.js +0 -1
  368. package/dist/files-CDfG8swM.js.map +0 -1
  369. package/dist/files-CSe4VaMj.js +0 -1
  370. package/dist/files-CX_mmvCc.js +0 -775
  371. package/dist/files-CX_mmvCc.js.map +0 -1
  372. package/dist/files-D6M7J3iX.js +0 -1
  373. package/dist/harness-install-BfMBYDfP.js.map +0 -1
  374. package/dist/hosted-5Zz2peTR.js.map +0 -1
  375. package/dist/hosted-Co-waHe0.js.map +0 -1
  376. package/dist/hosted-run-202QicZ-.js +0 -1
  377. package/dist/hosted-run-BfAPIMyT.js +0 -230
  378. package/dist/hosted-run-BfAPIMyT.js.map +0 -1
  379. package/dist/init-BiL6B3S4.js +0 -1
  380. package/dist/inputs-load-M-BGe7gd.js +0 -1
  381. package/dist/judge-DwzqucLS.js.map +0 -1
  382. package/dist/kinds-DEKXOWVJ.js.map +0 -1
  383. package/dist/list-MK4L8tfW.js.map +0 -1
  384. package/dist/live-gZtkBwuo.js +0 -1
  385. package/dist/model-C6aoJLg_.js +0 -1
  386. package/dist/options-I9I3FwMl.js +0 -1
  387. package/dist/preflight-fyV5nnea.js +0 -1
  388. package/dist/prices-C0gKS_8G.js +0 -1
  389. package/dist/query-C9OKU1Vz.js +0 -1
  390. package/dist/record-D1_D1KFY.js.map +0 -1
  391. package/dist/redact-t-L3VGy8.js.map +0 -1
  392. package/dist/resolve-BdpO8BN1.js +0 -1
  393. package/dist/resolve-Bfo8sjd-.js.map +0 -1
  394. package/dist/resolve-D2RqmybX.js.map +0 -1
  395. package/dist/server-Buav2-CG.js +0 -1
  396. package/dist/shared-CHvO7eLi.d.ts +0 -1
  397. package/dist/source-dvxkqYvk.js +0 -1
  398. package/dist/src-C5rrQlt8.js.map +0 -1
  399. package/dist/ssh-pool-BorCizYw.js +0 -1
  400. package/dist/ssh-pool-Dvfx5GuV.js.map +0 -1
  401. package/dist/start-COB07NpH.js.map +0 -1
  402. package/dist/state-C5oBvmoZ.js +0 -1
  403. package/dist/suite-BwJGOhCZ.js +0 -2
  404. package/dist/tart-DMppfbEm.js.map +0 -1
  405. package/dist/tart-bake-Cva_qdir.js.map +0 -1
  406. package/dist/tart-cli-LzDud2Z6.js.map +0 -1
  407. package/dist/tart-hosts-CTRY5kQ2.js.map +0 -1
  408. package/dist/vertex-C7PI-WPc.d.ts +0 -3
  409. package/dist/vertex-DXfcXYKn.js +0 -1
  410. package/dist/views-B0qZR5Ef.js +0 -2
  411. package/dist/vm-container-BVn7pXfD.js.map +0 -1
  412. package/dist/workspace-CRgFdmgW.js +0 -1
  413. package/dist/workspace-wwvwEHzP.js.map +0 -1
@@ -0,0 +1,1477 @@
1
+ import { a as fromCwd, l as relativeFile, u as sha256 } from "./ids-DqEvrBFZ.js";
2
+ import { t as RUN_ID } from "./paths-Dwmi7L4X.js";
3
+ import { o as PACKAGE_VERSION, t as BUILD_ID } from "./root-Cm93-6ix.js";
4
+ import { f as readableRecord, o as readableArchiveManifest, p as readableRemarks, t as NewerSchemaError } from "./record-2liAelrB.js";
5
+ import { n as debugArchiveFile, r as debugRoot } from "./files-B0DbptiO.js";
6
+ import { i as TRACE_FILE, r as REQUESTS_FILE, t as DEBUG_LOG } from "./debug-CIXzB4wK.js";
7
+ import { r as runHeader, t as REMARKS_FILE } from "./remarks-D5qOZzcX.js";
8
+ import { r as repoTop, t as git } from "./git-DatgUcnf.js";
9
+ import { d as maskedMatch, o as findSecrets, s as findSecretsInJson } from "./redact-DMueYS-v.js";
10
+ import { t as patchPath } from "./patch-C7yBztZj.js";
11
+ import { n as renderSummary } from "./summary-DeeQJAR5.js";
12
+ import { z } from "zod";
13
+ import { createHash, randomBytes } from "node:crypto";
14
+ import { createReadStream, existsSync } from "node:fs";
15
+ import { hostname } from "node:os";
16
+ import { basename, dirname, isAbsolute, join } from "node:path";
17
+ import { link, mkdir, open, readFile, readdir, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
18
+ import { crc32, deflateRawSync, inflateRawSync } from "node:zlib";
19
+ import { isDeepStrictEqual } from "node:util";
20
+ // src/archive/zip.ts
21
+ /** A zip that can't be written as asked, or can't be read. */
22
+ var ZipError = class extends Error {
23
+ name = "ZipError";
24
+ };
25
+ const LOCAL = 67324752;
26
+ const CENTRAL = 33639248;
27
+ const END = 101010256;
28
+ const END64 = 101075792;
29
+ const LOCATOR64 = 117853008;
30
+ const ZIP64_EXTRA = 1;
31
+ const U16 = 65535;
32
+ const U32 = 4294967295;
33
+ /** General-purpose flag bit 11: the name is UTF-8. */
34
+ const UTF8 = 2048;
35
+ const ENCRYPTED = 1;
36
+ const LOCAL_SIZE = 30;
37
+ const CENTRAL_SIZE = 46;
38
+ const END_SIZE = 22;
39
+ const END64_SIZE = 56;
40
+ const LOCATOR64_SIZE = 20;
41
+ /** A regular file, rw-r--r--, in the high half of the external attributes (Unix). */
42
+ const FILE_ATTRIBUTES = 33188 << 16 >>> 0;
43
+ const MADE_BY_UNIX = 768;
44
+ const METHOD_CODE = {
45
+ store: 0,
46
+ deflate: 8
47
+ };
48
+ /** `a/./b` as `a/b`; null for a path that's absolute, empty, a folder or climbs out with `..`. */
49
+ function safeZipPath(path) {
50
+ if (path.startsWith("/") || /^[A-Za-z]:/.test(path) || path.includes("\\")) return null;
51
+ if (path.endsWith("/") || path.includes("\0")) return null;
52
+ const parts = path.split("/").filter((p) => p !== "" && p !== ".");
53
+ if (!parts.length || parts.includes("..")) return null;
54
+ return parts.join("/");
55
+ }
56
+ /** CRC-32 of any length: zlib's `crc32` takes a 32-bit length, so more goes in pieces. */
57
+ function crc32Of(data, piece = 2 ** 30) {
58
+ let crc = 0;
59
+ for (let at = 0; at < data.length; at += piece) crc = crc32(data.subarray(at, at + piece), crc);
60
+ return crc;
61
+ }
62
+ /** MS-DOS date and time fields, as zip keeps them: two-second steps, 1980 to 2107, read as UTC. */
63
+ function dosTime(at) {
64
+ const ms = Math.min(Math.max(at.getTime(), Date.UTC(1980, 0, 1)), Date.UTC(2107, 11, 31, 23, 59, 58));
65
+ const d = new Date(ms);
66
+ return {
67
+ time: d.getUTCHours() << 11 | d.getUTCMinutes() << 5 | d.getUTCSeconds() >> 1,
68
+ date: d.getUTCFullYear() - 1980 << 9 | d.getUTCMonth() + 1 << 5 | d.getUTCDate()
69
+ };
70
+ }
71
+ /** Writes a zip, one entry at a time, to `sink`; `finish()` writes the central directory. */
72
+ var ZipWriter = class {
73
+ #sink;
74
+ #time;
75
+ #always;
76
+ #entries = [];
77
+ #paths = /* @__PURE__ */ new Set();
78
+ #offset = 0;
79
+ #finished = false;
80
+ constructor(sink, options) {
81
+ this.#sink = sink;
82
+ this.#time = dosTime(options.mtime);
83
+ this.#always = options.zip64 === "always";
84
+ }
85
+ async #write(bytes) {
86
+ await this.#sink(bytes);
87
+ this.#offset += bytes.length;
88
+ }
89
+ /**
90
+ * Adds a file. `deflate` (the default) stores it instead when deflating doesn't make it
91
+ * smaller, as for data that's compressed already; the entry's method says which it got.
92
+ */
93
+ async add(path, data, method = "deflate") {
94
+ if (this.#finished) throw new ZipError(`can't add ${path}: the zip is finished`);
95
+ if (safeZipPath(path) !== path) throw new ZipError(`${path} isn't a relative path in the zip`);
96
+ if (this.#paths.has(path)) throw new ZipError(`${path} is in the zip already`);
97
+ const name = Buffer.from(path, "utf8");
98
+ if (name.length > U16) throw new ZipError(`${path.slice(0, 40)}… is too long for a zip path`);
99
+ this.#paths.add(path);
100
+ let body = data;
101
+ let used = "store";
102
+ if (method === "deflate") {
103
+ const deflated = deflateRawSync(data, { level: 6 });
104
+ if (deflated.length < data.length) {
105
+ body = deflated;
106
+ used = "deflate";
107
+ }
108
+ }
109
+ const entry = {
110
+ name,
111
+ method: used,
112
+ crc: crc32Of(data),
113
+ compressedSize: body.length,
114
+ size: data.length,
115
+ offset: this.#offset
116
+ };
117
+ const zip64 = this.#always || entry.size >= U32 || entry.compressedSize >= U32;
118
+ const extra = zip64 ? zip64Extra([entry.size, entry.compressedSize]) : Buffer.alloc(0);
119
+ const header = Buffer.alloc(LOCAL_SIZE);
120
+ header.writeUInt32LE(LOCAL, 0);
121
+ header.writeUInt16LE(versionNeeded(used, zip64), 4);
122
+ header.writeUInt16LE(UTF8, 6);
123
+ header.writeUInt16LE(METHOD_CODE[used], 8);
124
+ header.writeUInt16LE(this.#time.time, 10);
125
+ header.writeUInt16LE(this.#time.date, 12);
126
+ header.writeUInt32LE(entry.crc, 14);
127
+ header.writeUInt32LE(zip64 ? U32 : entry.compressedSize, 18);
128
+ header.writeUInt32LE(zip64 ? U32 : entry.size, 22);
129
+ header.writeUInt16LE(name.length, 26);
130
+ header.writeUInt16LE(extra.length, 28);
131
+ await this.#write(Buffer.concat([
132
+ header,
133
+ name,
134
+ extra
135
+ ]));
136
+ await this.#write(body);
137
+ this.#entries.push(entry);
138
+ return used;
139
+ }
140
+ /** Writes the central directory and the end records; returns the zip's size in bytes. */
141
+ async finish() {
142
+ if (this.#finished) throw new ZipError("the zip is finished already");
143
+ this.#finished = true;
144
+ const start = this.#offset;
145
+ for (const e of this.#entries) {
146
+ const big = {
147
+ size: this.#always || e.size >= U32,
148
+ compressedSize: this.#always || e.compressedSize >= U32,
149
+ offset: this.#always || e.offset >= U32
150
+ };
151
+ const extra = zip64Extra([
152
+ ...big.size ? [e.size] : [],
153
+ ...big.compressedSize ? [e.compressedSize] : [],
154
+ ...big.offset ? [e.offset] : []
155
+ ]);
156
+ const zip64 = big.size || big.compressedSize || big.offset;
157
+ const header = Buffer.alloc(CENTRAL_SIZE);
158
+ header.writeUInt32LE(CENTRAL, 0);
159
+ header.writeUInt16LE(MADE_BY_UNIX | versionNeeded(e.method, zip64), 4);
160
+ header.writeUInt16LE(versionNeeded(e.method, zip64), 6);
161
+ header.writeUInt16LE(UTF8, 8);
162
+ header.writeUInt16LE(METHOD_CODE[e.method], 10);
163
+ header.writeUInt16LE(this.#time.time, 12);
164
+ header.writeUInt16LE(this.#time.date, 14);
165
+ header.writeUInt32LE(e.crc, 16);
166
+ header.writeUInt32LE(big.compressedSize ? U32 : e.compressedSize, 20);
167
+ header.writeUInt32LE(big.size ? U32 : e.size, 24);
168
+ header.writeUInt16LE(e.name.length, 28);
169
+ header.writeUInt16LE(zip64 ? extra.length : 0, 30);
170
+ header.writeUInt32LE(FILE_ATTRIBUTES, 38);
171
+ header.writeUInt32LE(big.offset ? U32 : e.offset, 42);
172
+ await this.#write(Buffer.concat([
173
+ header,
174
+ e.name,
175
+ zip64 ? extra : Buffer.alloc(0)
176
+ ]));
177
+ }
178
+ const size = this.#offset - start;
179
+ const count = this.#entries.length;
180
+ const zip64 = this.#always || count >= U16 || size >= U32 || start >= U32;
181
+ if (zip64) {
182
+ const end64 = Buffer.alloc(END64_SIZE);
183
+ end64.writeUInt32LE(END64, 0);
184
+ end64.writeBigUInt64LE(BigInt(44), 4);
185
+ end64.writeUInt16LE(813, 12);
186
+ end64.writeUInt16LE(45, 14);
187
+ end64.writeBigUInt64LE(BigInt(count), 24);
188
+ end64.writeBigUInt64LE(BigInt(count), 32);
189
+ end64.writeBigUInt64LE(BigInt(size), 40);
190
+ end64.writeBigUInt64LE(BigInt(start), 48);
191
+ const locator = Buffer.alloc(LOCATOR64_SIZE);
192
+ locator.writeUInt32LE(LOCATOR64, 0);
193
+ locator.writeBigUInt64LE(BigInt(this.#offset), 8);
194
+ locator.writeUInt32LE(1, 16);
195
+ await this.#write(Buffer.concat([end64, locator]));
196
+ }
197
+ const end = Buffer.alloc(END_SIZE);
198
+ end.writeUInt32LE(END, 0);
199
+ end.writeUInt16LE(zip64 ? U16 : count, 8);
200
+ end.writeUInt16LE(zip64 ? U16 : count, 10);
201
+ end.writeUInt32LE(zip64 ? U32 : size, 12);
202
+ end.writeUInt32LE(zip64 ? U32 : start, 16);
203
+ await this.#write(end);
204
+ return this.#offset;
205
+ }
206
+ };
207
+ const versionNeeded = (method, zip64) => zip64 ? 45 : method === "deflate" ? 20 : 10;
208
+ function zip64Extra(values) {
209
+ const extra = Buffer.alloc(4 + values.length * 8);
210
+ extra.writeUInt16LE(ZIP64_EXTRA, 0);
211
+ extra.writeUInt16LE(values.length * 8, 2);
212
+ for (const [i, v] of values.entries()) extra.writeBigUInt64LE(BigInt(v), 4 + i * 8);
213
+ return extra;
214
+ }
215
+ /** A zip file, read in ranges; `close()` closes it. */
216
+ async function fileSource(path) {
217
+ const handle = await open(path, "r");
218
+ try {
219
+ const { size } = await handle.stat();
220
+ return {
221
+ size,
222
+ async read(offset, length) {
223
+ const out = Buffer.alloc(length);
224
+ let at = 0;
225
+ while (at < length) {
226
+ const { bytesRead } = await handle.read(out, at, length - at, offset + at);
227
+ if (bytesRead === 0) break;
228
+ at += bytesRead;
229
+ }
230
+ return out.subarray(0, at);
231
+ },
232
+ close: () => handle.close()
233
+ };
234
+ } catch (error) {
235
+ await handle.close();
236
+ throw error;
237
+ }
238
+ }
239
+ const u64 = (b, at, what) => {
240
+ const n = b.readBigUInt64LE(at);
241
+ if (n > BigInt(Number.MAX_SAFE_INTEGER)) throw new ZipError(`${what} is too large to read`);
242
+ return Number(n);
243
+ };
244
+ async function readExactly(source, offset, length, what) {
245
+ if (offset < 0 || offset + length > source.size) throw new ZipError(`${what} lies outside the zip (${source.size} bytes)`);
246
+ const read = await source.read(offset, length);
247
+ const bytes = Buffer.from(read.buffer, read.byteOffset, read.byteLength);
248
+ if (bytes.length !== length) throw new ZipError(`${what} was cut short`);
249
+ return bytes;
250
+ }
251
+ /** The end-of-central-directory record: the last one whose comment runs to the end. */
252
+ async function findEnd(source) {
253
+ const tailLength = Math.min(source.size, 65557);
254
+ const tail = await readExactly(source, source.size - tailLength, tailLength, "the end record");
255
+ for (let at = tail.length - END_SIZE; at >= 0; at--) {
256
+ if (tail.readUInt32LE(at) !== END) continue;
257
+ if (at + END_SIZE + tail.readUInt16LE(at + 20) !== tail.length) continue;
258
+ return {
259
+ record: tail.subarray(at, at + END_SIZE),
260
+ offset: source.size - tailLength + at
261
+ };
262
+ }
263
+ throw new ZipError("no end-of-central-directory record: not a zip, or cut short");
264
+ }
265
+ /** Reads a zip's central directory from `source`. */
266
+ async function readZip(source) {
267
+ const end = await findEnd(source);
268
+ let count = end.record.readUInt16LE(10);
269
+ let directorySize = end.record.readUInt32LE(12);
270
+ let directoryStart = end.record.readUInt32LE(16);
271
+ const locatorAt = end.offset - LOCATOR64_SIZE;
272
+ if (locatorAt >= 0) {
273
+ const locator = await readExactly(source, locatorAt, LOCATOR64_SIZE, "the zip64 locator");
274
+ if (locator.readUInt32LE(0) === LOCATOR64) {
275
+ const end64 = await readExactly(source, u64(locator, 8, "the zip64 end record offset"), END64_SIZE, "the zip64 end record");
276
+ if (end64.readUInt32LE(0) !== END64) throw new ZipError("the zip64 end record is missing");
277
+ count = u64(end64, 32, "the entry count");
278
+ directorySize = u64(end64, 40, "the central directory size");
279
+ directoryStart = u64(end64, 48, "the central directory offset");
280
+ }
281
+ }
282
+ const directory = await readExactly(source, directoryStart, directorySize, "the central directory");
283
+ const entries = [];
284
+ const byPath = /* @__PURE__ */ new Map();
285
+ const locals = /* @__PURE__ */ new Map();
286
+ let at = 0;
287
+ for (let i = 0; i < count; i++) {
288
+ if (at + CENTRAL_SIZE > directory.length || directory.readUInt32LE(at) !== CENTRAL) throw new ZipError(`central directory entry ${i + 1} of ${count} is missing`);
289
+ const flags = directory.readUInt16LE(at + 8);
290
+ const code = directory.readUInt16LE(at + 10);
291
+ const nameLength = directory.readUInt16LE(at + 28);
292
+ const extraLength = directory.readUInt16LE(at + 30);
293
+ const commentLength = directory.readUInt16LE(at + 32);
294
+ const next = at + CENTRAL_SIZE + nameLength + extraLength + commentLength;
295
+ if (next > directory.length) throw new ZipError(`central directory entry ${i + 1} is cut short`);
296
+ const nameBytes = directory.subarray(at + CENTRAL_SIZE, at + CENTRAL_SIZE + nameLength);
297
+ const raw = nameBytes.toString("utf8");
298
+ const extra = directory.subarray(at + CENTRAL_SIZE + nameLength, at + CENTRAL_SIZE + nameLength + extraLength);
299
+ let size = directory.readUInt32LE(at + 24);
300
+ let compressedSize = directory.readUInt32LE(at + 20);
301
+ let offset = directory.readUInt32LE(at + 42);
302
+ const crc = directory.readUInt32LE(at + 16);
303
+ at = next;
304
+ if (raw.endsWith("/")) continue;
305
+ const path = safeZipPath(raw);
306
+ if (path !== raw) throw new ZipError(`${JSON.stringify(raw)} isn't a relative path in the zip`);
307
+ if (flags & ENCRYPTED) throw new ZipError(`${path} is encrypted`);
308
+ const method = code === 0 ? "store" : code === 8 ? "deflate" : null;
309
+ if (!method) throw new ZipError(`${path} uses compression method ${code}, not store or deflate`);
310
+ if (size === U32 || compressedSize === U32 || offset === U32) {
311
+ const values = zip64Values(extra, path);
312
+ const take = () => {
313
+ const v = values.shift();
314
+ if (v === void 0) throw new ZipError(`${path}'s zip64 sizes are missing`);
315
+ return v;
316
+ };
317
+ if (size === U32) size = take();
318
+ if (compressedSize === U32) compressedSize = take();
319
+ if (offset === U32) offset = take();
320
+ }
321
+ if (byPath.has(path)) throw new ZipError(`${path} is in the zip twice`);
322
+ const entry = {
323
+ path,
324
+ method,
325
+ crc32: crc,
326
+ compressedSize,
327
+ size,
328
+ offset
329
+ };
330
+ entries.push(entry);
331
+ byPath.set(path, entry);
332
+ locals.set(entry, {
333
+ name: Buffer.from(nameBytes),
334
+ code
335
+ });
336
+ }
337
+ const bounds = /* @__PURE__ */ new Map();
338
+ const byOffset = [...entries].sort((a, b) => a.offset - b.offset);
339
+ for (const [i, e] of byOffset.entries()) {
340
+ const limit = byOffset[i + 1]?.offset ?? directoryStart;
341
+ if (e.offset + LOCAL_SIZE + (locals.get(e)?.name.length ?? 0) + e.compressedSize > limit) throw new ZipError(`${e.path} overlaps the next entry or the central directory`);
342
+ bounds.set(e, limit);
343
+ }
344
+ return {
345
+ entries,
346
+ get: (path) => byPath.get(path),
347
+ read: async (entry) => {
348
+ const limit = bounds.get(entry);
349
+ const local = locals.get(entry);
350
+ if (limit === void 0 || !local) throw new ZipError(`${entry.path} isn't this zip's entry`);
351
+ return readEntry(source, entry, local, limit);
352
+ }
353
+ };
354
+ }
355
+ function zip64Values(extra, path) {
356
+ for (let at = 0; at + 4 <= extra.length;) {
357
+ const id = extra.readUInt16LE(at);
358
+ const length = extra.readUInt16LE(at + 2);
359
+ if (at + 4 + length > extra.length) throw new ZipError(`${path}'s extra field is cut short`);
360
+ if (id === ZIP64_EXTRA) {
361
+ const values = [];
362
+ for (let i = 0; i + 8 <= length; i += 8) values.push(u64(extra, at + 4 + i, `${path}'s zip64 size`));
363
+ return values;
364
+ }
365
+ at += 4 + length;
366
+ }
367
+ throw new ZipError(`${path} has no zip64 extra field`);
368
+ }
369
+ async function readEntry(source, entry, central, limit) {
370
+ const header = await readExactly(source, entry.offset, LOCAL_SIZE, `${entry.path}'s header`);
371
+ if (header.readUInt32LE(0) !== LOCAL) throw new ZipError(`${entry.path}'s local header is missing`);
372
+ const nameLength = header.readUInt16LE(26);
373
+ if (!(await readExactly(source, entry.offset + LOCAL_SIZE, nameLength, entry.path)).equals(central.name) || header.readUInt16LE(8) !== central.code || header.readUInt16LE(6) & ENCRYPTED) throw new ZipError(`${entry.path}'s local header doesn't match its central directory entry`);
374
+ const dataAt = entry.offset + LOCAL_SIZE + nameLength + header.readUInt16LE(28);
375
+ if (dataAt + entry.compressedSize > limit) throw new ZipError(`${entry.path} overlaps the next entry or the central directory`);
376
+ if (entry.method === "store" && entry.compressedSize !== entry.size) throw new ZipError(`${entry.path} is stored as ${entry.compressedSize} bytes, not the ${entry.size} its entry says`);
377
+ const body = await readExactly(source, dataAt, entry.compressedSize, entry.path);
378
+ let data;
379
+ if (entry.method === "store") data = body;
380
+ else try {
381
+ data = inflateRawSync(body, { maxOutputLength: Math.max(entry.size, 1) });
382
+ } catch (error) {
383
+ throw new ZipError(`${entry.path} doesn't inflate: ${error.message}`);
384
+ }
385
+ if (data.length !== entry.size) throw new ZipError(`${entry.path} is ${data.length} bytes, not the ${entry.size} its entry says`);
386
+ if (crc32Of(data) !== entry.crc32) throw new ZipError(`${entry.path} doesn't match its CRC-32`);
387
+ return data;
388
+ }
389
+ // src/archive/index.ts
390
+ /** The manifest's path in the archive. */
391
+ const MANIFEST_FILE = "reeval-archive.json";
392
+ /** The largest manifest `openArchive` reads, far past a run of a hundred thousand files. */
393
+ const MAX_MANIFEST_BYTES = 64 * 2 ** 20;
394
+ /** Formats that are compressed already, which an archive stores rather than deflates. */
395
+ const COMPRESSED = /\.(?:png|jpe?g|gif|webp|avif|zip|gz|tgz|zst|br|xz|bz2|mp4|webm|woff2?)$/i;
396
+ /** An archive that can't be written as asked, or doesn't read as one. */
397
+ var ArchiveError = class extends Error {
398
+ name = "ArchiveError";
399
+ };
400
+ /** `20260924T152700Z` of a run id, as a date. */
401
+ function runStart(runId) {
402
+ const m = /^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z_/.exec(runId);
403
+ if (!m || !RUN_ID.test(runId)) throw new ArchiveError(`${runId} isn't a run id`);
404
+ const [, y, mo, d, h, mi, s] = m.map(Number);
405
+ return new Date(Date.UTC(y, mo - 1, d, h, mi, s));
406
+ }
407
+ const recordPath = (runId) => `${runId}.json`;
408
+ /** Whether `path` belongs in an archive of `contents`: the record, or a file under the run. */
409
+ const inLayout = (contents, runId, path) => path.startsWith(`${runId}/`) || contents === "run" && path === recordPath(runId);
410
+ async function writeAll(handle, bytes) {
411
+ for (let at = 0; at < bytes.length;) {
412
+ const { bytesWritten } = await handle.write(bytes, at, bytes.length - at);
413
+ at += bytesWritten;
414
+ }
415
+ }
416
+ /**
417
+ * Writes `file`, an archive of `options.files`, through a temporary file renamed into place, so
418
+ * the archive is either all there or not there. Returns its manifest.
419
+ */
420
+ async function writeArchive(file, options) {
421
+ const { contents, runId } = options;
422
+ const mtime = runStart(runId);
423
+ if (contents === "debug" && !options.debugLevel) throw new ArchiveError(`a debug archive of ${runId} needs its debug level`);
424
+ if (contents === "run" && options.debugLevel) throw new ArchiveError(`a run archive of ${runId} has no debug level`);
425
+ const inputs = [...options.files].sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
426
+ for (const [i, input] of inputs.entries()) {
427
+ if (safeZipPath(input.path) !== input.path) throw new ArchiveError(`${input.path} isn't a relative path in the archive`);
428
+ if (!inLayout(contents, runId, input.path)) throw new ArchiveError(`${input.path} doesn't belong in a ${contents} archive of ${runId}: ${contents === "run" ? `only ${recordPath(runId)} and` : "only"} files under ${runId}/ do`);
429
+ if (inputs[i - 1]?.path === input.path) throw new ArchiveError(`${input.path} is given twice`);
430
+ }
431
+ if (contents === "run" && inputs[0]?.path !== recordPath(runId)) throw new ArchiveError(`a run archive of ${runId} needs its record, ${recordPath(runId)}`);
432
+ const tmp = join(dirname(file), `.tmp-${randomBytes(6).toString("hex")}-${basename(file)}`);
433
+ const handle = await open(tmp, "wx");
434
+ let landed = false;
435
+ try {
436
+ const zip = new ZipWriter((bytes) => writeAll(handle, bytes), {
437
+ mtime,
438
+ zip64: options.zip64 ?? "auto"
439
+ });
440
+ const files = [];
441
+ for (const input of inputs) {
442
+ const data = typeof input.data === "function" ? await input.data() : input.data;
443
+ files.push({
444
+ path: input.path,
445
+ sha256: sha256(data),
446
+ bytes: data.length
447
+ });
448
+ await zip.add(input.path, data, COMPRESSED.test(input.path) ? "store" : "deflate");
449
+ }
450
+ const manifest = {
451
+ kind: "reeval-archive",
452
+ schemaVersion: 1,
453
+ contents,
454
+ runId,
455
+ revision: options.revision ?? 1,
456
+ reeval: PACKAGE_VERSION,
457
+ createdAt: options.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
458
+ ...options.debugLevel ? { debugLevel: options.debugLevel } : {},
459
+ files
460
+ };
461
+ await zip.add(MANIFEST_FILE, Buffer.from(`${JSON.stringify(manifest, null, 2)}\n`));
462
+ await zip.finish();
463
+ await handle.sync();
464
+ await handle.close();
465
+ await rename(tmp, file);
466
+ landed = true;
467
+ await syncDir(dirname(file));
468
+ return manifest;
469
+ } finally {
470
+ if (!landed) {
471
+ await handle.close().catch(() => {});
472
+ await rm(tmp, { force: true });
473
+ }
474
+ }
475
+ }
476
+ /** The rename's directory entry, flushed where the platform lets a directory be opened. */
477
+ async function syncDir(dir) {
478
+ const handle = await open(dir, "r").catch(() => null);
479
+ await handle?.sync().catch(() => {}).finally(() => handle.close().catch(() => {}));
480
+ }
481
+ /**
482
+ * What `openArchive` relies on. A field or a `debugLevel` a newer reeval added passes, as other
483
+ * readers ignore what they don't know; `contents` it doesn't know isn't an archive it can read.
484
+ */
485
+ const manifestSchema = z.looseObject({
486
+ kind: z.literal("reeval-archive"),
487
+ schemaVersion: z.literal(1),
488
+ contents: z.enum(["run", "debug"]),
489
+ runId: z.string().regex(RUN_ID, "must be a run id"),
490
+ revision: z.number().int().min(1),
491
+ reeval: z.string(),
492
+ createdAt: z.string(),
493
+ debugLevel: z.string().optional(),
494
+ files: z.array(z.object({
495
+ path: z.string(),
496
+ sha256: z.string().regex(/^[0-9a-f]{64}$/, "must be a sha256 in hex"),
497
+ bytes: z.number().int().min(0)
498
+ }))
499
+ });
500
+ /**
501
+ * Opens an archive: a file, or any `ZipSource`. Refuses one whose manifest is missing or doesn't
502
+ * fit, or whose entries aren't the manifest's files; a manifest from a newer reeval throws a
503
+ * `NewerSchemaError`.
504
+ */
505
+ async function openArchive(from, what) {
506
+ const name = what ?? (typeof from === "string" ? from : "The archive");
507
+ const file = typeof from === "string" ? await fileSource(from) : null;
508
+ const source = file ?? from;
509
+ try {
510
+ const zip = await readZip(source).catch((error) => {
511
+ throw error instanceof ZipError ? new ArchiveError(`${name} isn't a readable zip: ${error.message}`) : error;
512
+ });
513
+ const manifest = await readManifest(zip, name);
514
+ return {
515
+ manifest,
516
+ ...reader(zip, manifest, name),
517
+ close: async () => file?.close()
518
+ };
519
+ } catch (error) {
520
+ await file?.close();
521
+ throw error;
522
+ }
523
+ }
524
+ async function readManifest(zip, name) {
525
+ const entry = zip.get(MANIFEST_FILE);
526
+ if (!entry) throw new ArchiveError(`${name} has no ${MANIFEST_FILE}, so it isn't a reeval archive`);
527
+ if (Math.max(entry.size, entry.compressedSize) > MAX_MANIFEST_BYTES) {
528
+ const bytes = Math.max(entry.size, entry.compressedSize);
529
+ throw new ArchiveError(`${name}'s ${MANIFEST_FILE} is ${bytes} bytes, too large to read`);
530
+ }
531
+ let value;
532
+ try {
533
+ value = JSON.parse((await zip.read(entry)).toString("utf8"));
534
+ } catch (error) {
535
+ throw new ArchiveError(`${name}'s ${MANIFEST_FILE} doesn't read: ${error.message}`);
536
+ }
537
+ if (value?.kind !== "reeval-archive") throw new ArchiveError(`${name}'s ${MANIFEST_FILE} isn't a reeval archive manifest`);
538
+ const parsed = manifestSchema.safeParse(readableArchiveManifest(value, name));
539
+ if (!parsed.success) {
540
+ const issue = parsed.error.issues[0];
541
+ throw new ArchiveError(`${name}'s ${MANIFEST_FILE} doesn't fit: ${issue?.path.join(".") || "(root)"} ${issue?.message}`);
542
+ }
543
+ const manifest = parsed.data;
544
+ const { contents, runId } = manifest;
545
+ const listed = /* @__PURE__ */ new Set();
546
+ for (const f of manifest.files) {
547
+ if (f.path === "reeval-archive.json" || !inLayout(contents, runId, f.path)) throw new ArchiveError(`${name} lists ${f.path}, which doesn't belong in a ${contents} archive`);
548
+ if (listed.has(f.path)) throw new ArchiveError(`${name} lists ${f.path} twice`);
549
+ listed.add(f.path);
550
+ const entry = zip.get(f.path);
551
+ if (!entry) throw new ArchiveError(`${name} lists ${f.path}, which isn't in the zip`);
552
+ if (entry.size !== f.bytes) throw new ArchiveError(`${name}'s ${f.path} is ${entry.size} bytes in the zip, not the ${f.bytes} its manifest says`);
553
+ }
554
+ const extra = zip.entries.find((e) => e.path !== "reeval-archive.json" && !listed.has(e.path));
555
+ if (extra) throw new ArchiveError(`${name} holds ${extra.path}, which its manifest doesn't list`);
556
+ if (contents === "run" && !listed.has(recordPath(runId))) throw new ArchiveError(`${name} has no record, ${recordPath(runId)}`);
557
+ return manifest;
558
+ }
559
+ function reader(zip, manifest, name) {
560
+ const files = new Map(manifest.files.map((f) => [f.path, f]));
561
+ const read = async (path) => {
562
+ const f = files.get(path);
563
+ const entry = zip.get(path);
564
+ if (!f || !entry) throw new ArchiveError(`${name} has no ${path}`);
565
+ let data;
566
+ try {
567
+ data = await zip.read(entry);
568
+ } catch (error) {
569
+ if (error instanceof ZipError) throw new ArchiveError(`${name}: ${error.message}`);
570
+ throw error;
571
+ }
572
+ if (sha256(data) !== f.sha256) throw new ArchiveError(`${name}'s ${path} doesn't match the hash in its manifest`);
573
+ return data;
574
+ };
575
+ return {
576
+ has: (path) => files.has(path),
577
+ read,
578
+ verify: async () => {
579
+ for (const f of manifest.files) await read(f.path);
580
+ }
581
+ };
582
+ }
583
+ // src/history/ignore.ts
584
+ /**
585
+ * Un-ignores recorded artifacts. A parent `*.log` would otherwise drop `setup.log` and
586
+ * `checks/<n>.log` when someone `git add`s the history folder. Ignores the `.tmp-*` files a
587
+ * write keeps there while it runs, such as a claim a crashed write left.
588
+ */
589
+ const HISTORY_GITIGNORE = `# Un-ignore recorded files. A parent *.log drops setup.log and checks/*.log.
590
+ !*.json
591
+ !*.zip
592
+ !*.jsonl
593
+ !*.md
594
+ !*.patch
595
+ !*.log
596
+ # A write in progress, or one cut short: never part of history.
597
+ .tmp-*
598
+ `;
599
+ /**
600
+ * Marks recorded runs generated, so GitHub collapses them in a pull request's diff, and their
601
+ * archives binary, so git never diffs or merges one as text. Matches run ids (`RUN_ID`) only:
602
+ * `history.dir` may be a folder that holds other files too.
603
+ */
604
+ const HISTORY_GITATTRIBUTES = `# Recorded runs: GitHub collapses them in a pull request's diff.
605
+ /[0-9]*T[0-9]*Z_*.json linguist-generated=true
606
+ /[0-9]*T[0-9]*Z_*/** linguist-generated=true
607
+ /[0-9]*T[0-9]*Z_*.zip binary linguist-generated=true
608
+ `;
609
+ const historyGitignorePath = (historyDir) => join(historyDir, ".gitignore");
610
+ const historyGitattributesPath = (historyDir) => join(historyDir, ".gitattributes");
611
+ async function ensureFile(historyDir, path, content) {
612
+ try {
613
+ await readFile(path);
614
+ } catch (error) {
615
+ if (error.code !== "ENOENT") throw error;
616
+ await mkdir(historyDir, { recursive: true });
617
+ await writeFile(path, content);
618
+ }
619
+ return path;
620
+ }
621
+ /**
622
+ * Writes `content` to `path`, or adds the rules of `content` an existing file lacks, keeping
623
+ * what's there: the whole block when it has none of them.
624
+ */
625
+ async function ensureRules(historyDir, path, content) {
626
+ let existing;
627
+ try {
628
+ existing = await readFile(path, "utf8");
629
+ } catch (error) {
630
+ if (error.code !== "ENOENT") throw error;
631
+ return ensureFile(historyDir, path, content);
632
+ }
633
+ const lines = new Set(existing.split(/\r?\n/).map((l) => l.trim()));
634
+ const rules = content.split("\n").filter((l) => l && !l.startsWith("#"));
635
+ const missing = rules.filter((r) => !lines.has(r));
636
+ if (missing.length === 0) return path;
637
+ const eol = existing.includes("\r\n") ? "\r\n" : "\n";
638
+ const gap = existing === "" || existing.endsWith("\n") ? "" : eol;
639
+ const added = missing.length === rules.length ? content : `${missing.join("\n")}\n`;
640
+ await writeFile(path, `${existing}${gap}${added.replaceAll("\n", eol)}`);
641
+ return path;
642
+ }
643
+ /**
644
+ * Writes the history-folder `.gitignore` when it's missing. An existing one is the user's: a
645
+ * later `!` rule would undo their own ignores, so it only gains `!*.zip` when runs are archived.
646
+ */
647
+ async function ensureHistoryGitignore(historyDir, archive) {
648
+ const path = historyGitignorePath(historyDir);
649
+ if (!existsSync(path)) return ensureFile(historyDir, path, HISTORY_GITIGNORE);
650
+ return archive ? ensureRules(historyDir, path, "!*.zip\n") : path;
651
+ }
652
+ /** Writes the history-folder `.gitattributes`, or adds the rules of `HISTORY_GITATTRIBUTES` it lacks. */
653
+ const ensureHistoryGitattributes = (historyDir) => ensureRules(historyDir, historyGitattributesPath(historyDir), HISTORY_GITATTRIBUTES);
654
+ /** `git check-ignore -v` one line: `<source>:<line>:<pattern><TAB><pathname>`. */
655
+ function parseCheckIgnore(line) {
656
+ const tab = line.indexOf(" ");
657
+ if (tab < 0) return null;
658
+ const meta = line.slice(0, tab);
659
+ const pathname = line.slice(tab + 1);
660
+ const match = meta.match(/^(.*):(\d+):(.*)$/);
661
+ if (!match) return null;
662
+ const [, source, lineNo, rule] = match;
663
+ if (!source || !rule) return null;
664
+ if (rule.startsWith("!")) return null;
665
+ return {
666
+ path: pathname,
667
+ rule,
668
+ source: `${source}:${lineNo}`
669
+ };
670
+ }
671
+ /**
672
+ * Files among `files` that git would ignore (so `git add` of the history folder would drop them).
673
+ * Empty when this isn't a git repo or git can't tell.
674
+ */
675
+ async function ignoredRecordedFiles(root, files) {
676
+ if (files.length === 0) return [];
677
+ const top = await repoTop(root);
678
+ if (!top) return [];
679
+ const r = await git(top, [
680
+ "check-ignore",
681
+ "-v",
682
+ "--no-index",
683
+ "--stdin"
684
+ ], { input: `${files.map((f) => relativeFile(top, f)).join("\n")}\n` });
685
+ if (r.code !== 0) return [];
686
+ return r.stdout.toString("utf8").split("\n").filter(Boolean).flatMap((line) => {
687
+ const parsed = parseCheckIgnore(line);
688
+ if (!parsed) return [];
689
+ const abs = isAbsolute(parsed.path) ? parsed.path : join(top, parsed.path);
690
+ return [{
691
+ ...parsed,
692
+ path: fromCwd(abs)
693
+ }];
694
+ });
695
+ }
696
+ // src/history/secret-scan.ts
697
+ /** Findings shown per file; the rest are counted. */
698
+ const SHOWN = 5;
699
+ const HUNK = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
700
+ /** Where line `lineIndex` of a `git diff` falls: the file it changes, and its line in the new version. */
701
+ function inPatch(lines, lineIndex) {
702
+ let file = null;
703
+ let next = null;
704
+ for (let i = 0; i <= lineIndex; i++) {
705
+ const text = lines[i];
706
+ if (text.startsWith("diff --git ")) {
707
+ let end = i + 1;
708
+ while (end < lines.length && !/^(@@|diff --git )/.test(lines[end])) end++;
709
+ file = patchPath(lines.slice(i, end).join("\n"));
710
+ next = null;
711
+ continue;
712
+ }
713
+ const hunk = HUNK.exec(text);
714
+ if (hunk) {
715
+ next = Number(hunk[1]);
716
+ continue;
717
+ }
718
+ if (next === null) continue;
719
+ if (i === lineIndex) return {
720
+ file,
721
+ line: text.startsWith("-") ? null : next
722
+ };
723
+ if (!text.startsWith("-") && !text.startsWith("\\")) next++;
724
+ }
725
+ return {
726
+ file,
727
+ line: null
728
+ };
729
+ }
730
+ const JSON_FILE = /\.(?:json|jsonl|ndjson)$/;
731
+ /**
732
+ * Every secret-looking stretch of `text`, placed: by file and line inside a patch, else by line.
733
+ * In a JSON file, only what redaction masks: its strings.
734
+ */
735
+ function scanText(path, text) {
736
+ const matches = JSON_FILE.test(path) ? findSecretsInJson(text) : findSecrets(text);
737
+ if (matches.length === 0) return [];
738
+ const lines = text.split("\n");
739
+ const starts = [];
740
+ let at = 0;
741
+ for (const line of lines) {
742
+ starts.push(at);
743
+ at += line.length + 1;
744
+ }
745
+ const lineOf = (offset) => {
746
+ let lo = 0;
747
+ let hi = starts.length - 1;
748
+ while (lo < hi) {
749
+ const mid = lo + hi + 1 >> 1;
750
+ if (starts[mid] <= offset) lo = mid;
751
+ else hi = mid - 1;
752
+ }
753
+ return lo;
754
+ };
755
+ const patch = path.endsWith(".patch");
756
+ return matches.map((m) => {
757
+ const index = lineOf(m.start);
758
+ return {
759
+ ...patch ? inPatch(lines, index) : {
760
+ file: null,
761
+ line: index + 1
762
+ },
763
+ what: maskedMatch(text, m),
764
+ rule: m.rule
765
+ };
766
+ });
767
+ }
768
+ const place = (f) => [f.file, f.line === null ? null : `line ${f.line}`].filter(Boolean).join(" ");
769
+ /** `<label> line <n>: <what>`, or `<label>: <file> line <n>: <what>` in a patch, a few per file. */
770
+ function findingLines(label, findings) {
771
+ const out = findings.slice(0, SHOWN).map((f) => {
772
+ const where = place(f);
773
+ if (!where) return `${label}: ${f.what}`;
774
+ return `${label}${f.file ? ": " : " "}${where}: ${f.what}`;
775
+ });
776
+ if (findings.length > SHOWN) out.push(`${label}: and ${findings.length - SHOWN} more`);
777
+ return out;
778
+ }
779
+ /** The findings as a recordable note: where, and which rule, never any part of the value. */
780
+ function findingSummary(findings) {
781
+ const shown = findings.slice(0, 3).map((f) => {
782
+ const where = place(f);
783
+ return `${where ? `${where}: ` : ""}${f.rule}`;
784
+ });
785
+ const more = findings.length > 3 ? `, and ${findings.length - 3} more` : "";
786
+ return `${shown.join("; ")}${more}`;
787
+ }
788
+ // src/history/files.ts
789
+ var HistoryError = class extends Error {
790
+ name = "HistoryError";
791
+ };
792
+ /** A record from a newer reeval: skipped with a warning to upgrade, never "restore or delete it". */
793
+ var NewerRecordError = class extends HistoryError {
794
+ reason;
795
+ constructor(error) {
796
+ super(error.message);
797
+ this.reason = error.reason;
798
+ }
799
+ };
800
+ /** Where `reeval run` writes runs before they're recorded. Gitignored. */
801
+ const scratchDir = (root) => join(root, ".reeval", "runs");
802
+ const cacheFile = (root) => join(root, ".reeval", "history-cache.json");
803
+ const TEXT_FILE = /\.(json|jsonl|md|patch|log|txt)$/;
804
+ const isMissing = (error) => error.code === "ENOENT";
805
+ /**
806
+ * A file another process is writing, renaming or removing right now: Windows refuses to open or
807
+ * replace one that's open elsewhere (EPERM, EBUSY). It reads fine on a later try.
808
+ */
809
+ const inFlux = (error) => [
810
+ "ENOENT",
811
+ "EPERM",
812
+ "EBUSY"
813
+ ].includes(error.code ?? "");
814
+ const tmpName = () => `${process.pid}-${randomBytes(6).toString("hex")}`;
815
+ const encodeRecord = (record) => Buffer.from(`${JSON.stringify(record, null, 2)}\n`);
816
+ function parseRecord(bytes, where) {
817
+ const value = JSON.parse(Buffer.from(bytes).toString("utf8"));
818
+ if (value?.kind !== "reeval-run") throw new HistoryError(`${where} is not a reeval run record`);
819
+ try {
820
+ return readableRecord(value, where);
821
+ } catch (error) {
822
+ if (error instanceof NewerSchemaError) throw new NewerRecordError(error);
823
+ throw error;
824
+ }
825
+ }
826
+ async function readRecord(path) {
827
+ return parseRecord(await readFile(path), path);
828
+ }
829
+ const warnedUnreadable = /* @__PURE__ */ new Set();
830
+ /**
831
+ * Says once per process that a run-named file isn't a readable record, so a run lost to a bad
832
+ * merge or a cut-short copy doesn't silently drop out of history, compare's base and queries.
833
+ */
834
+ function warnUnreadable(path, error) {
835
+ if (warnedUnreadable.has(path)) return;
836
+ warnedUnreadable.add(path);
837
+ if (error instanceof NewerRecordError) {
838
+ process.stderr.write(`warning: skipped ${fromCwd(path)}: ${error.reason}\n`);
839
+ return;
840
+ }
841
+ const why = error instanceof Error ? error.message : String(error);
842
+ process.stderr.write(`warning: skipped ${fromCwd(path)}: not a readable reeval run record (${why}). Restore it from git, or delete it.\n`);
843
+ }
844
+ /** A run's record file in a history or scratch folder. */
845
+ const recordFile = (dir, runId) => join(dir, `${runId}.json`);
846
+ /** A run's artifact directory in a history or scratch folder. */
847
+ const runDir = (dir, runId) => join(dir, runId);
848
+ /** The top-level `.json` names in `dir` (records land last and whole), sorted; null if it's missing. */
849
+ async function recordNames(dir) {
850
+ try {
851
+ return (await readdir(dir)).filter((n) => n.endsWith(".json") && !n.startsWith(".")).sort();
852
+ } catch (error) {
853
+ if (isMissing(error)) return null;
854
+ throw error;
855
+ }
856
+ }
857
+ /**
858
+ * The newest `limit` records across `dirs`, by file name (= start time), oldest first. Files that
859
+ * aren't readable records are skipped: these feed estimates, not results.
860
+ */
861
+ async function recentRecords(dirs, limit) {
862
+ const paths = [];
863
+ for (const dir of dirs) {
864
+ const names = await recordNames(dir).catch(() => null) ?? [];
865
+ paths.push(...names.map((n) => join(dir, n)));
866
+ }
867
+ const recent = paths.sort((a, b) => (a.split("/").at(-1) ?? "").localeCompare(b.split("/").at(-1) ?? "")).slice(-limit);
868
+ const records = [];
869
+ for (const path of recent) try {
870
+ records.push(await readRecord(path));
871
+ } catch {}
872
+ return records;
873
+ }
874
+ const BUILD = BUILD_ID;
875
+ async function readCache(root) {
876
+ try {
877
+ const parsed = JSON.parse(await readFile(cacheFile(root), "utf8"));
878
+ if (parsed.build === BUILD && parsed.files) return parsed;
879
+ } catch {}
880
+ return {
881
+ build: BUILD,
882
+ files: {}
883
+ };
884
+ }
885
+ /**
886
+ * Every run in `dir`, sorted by file name (= start time). Derived from the folder listing on
887
+ * every read; parsed records are cached in `.reeval/` by size and mtime, and never committed.
888
+ */
889
+ async function listRuns(root, dir, recorded) {
890
+ const names = (await recordNames(dir) ?? []).filter((n) => RUN_ID.test(n.slice(0, -5)));
891
+ if (names.length === 0) return [];
892
+ const cache = await readCache(root);
893
+ let changed = false;
894
+ const entries = [];
895
+ for (const name of names) {
896
+ const path = join(dir, name);
897
+ const key = relativeFile(root, path);
898
+ try {
899
+ const info = await stat(path);
900
+ const hit = cache.files[key];
901
+ if (hit && hit.size === info.size && hit.mtimeMs === info.mtimeMs) {
902
+ entries.push(hit.entry);
903
+ continue;
904
+ }
905
+ const entry = runHeader(await readRecord(path), recorded);
906
+ cache.files[key] = {
907
+ size: info.size,
908
+ mtimeMs: info.mtimeMs,
909
+ entry
910
+ };
911
+ entries.push(entry);
912
+ changed = true;
913
+ } catch (error) {
914
+ if (inFlux(error)) continue;
915
+ if (!(error instanceof HistoryError) && !(error instanceof SyntaxError)) throw error;
916
+ warnUnreadable(path, error);
917
+ }
918
+ }
919
+ if (changed) await writeCache(root, cache);
920
+ return entries;
921
+ }
922
+ /**
923
+ * Best-effort: another reader (a studio serving parallel requests, a second `reeval`) may be
924
+ * replacing the same file, which Windows refuses. The cache is only a speed-up.
925
+ */
926
+ async function writeCache(root, cache) {
927
+ const tmp = `${cacheFile(root)}.${tmpName()}`;
928
+ try {
929
+ await mkdir(dirname(cacheFile(root)), { recursive: true });
930
+ await writeFile(tmp, JSON.stringify(cache));
931
+ await rename(tmp, cacheFile(root));
932
+ } catch {
933
+ await rm(tmp, { force: true }).catch(() => {});
934
+ }
935
+ }
936
+ /**
937
+ * `<dir>/.tmp-<runId>.claim`: whoever creates it owns `<dir>/<runId>/` and `<dir>/<runId>.json`
938
+ * until it's removed. It holds `<pid>\n<host>\n<token>\n`, linked into place whole.
939
+ */
940
+ const claimFile = (dir, runId) => join(dir, `.tmp-${runId}.claim`);
941
+ const busy = (runId, file) => new HistoryError(`${runId} is being recorded by another process right now. Try again once it finishes; if no reeval is running, delete ${fromCwd(file)}.`);
942
+ /** A claim whose process is gone on this host. Another host's can't be probed, so it holds. */
943
+ function claimGone(held) {
944
+ const [pidLine, host] = held.split("\n");
945
+ const pid = Number(pidLine);
946
+ if (!Number.isInteger(pid) || pid <= 0 || !host) return true;
947
+ if (host !== hostname()) return false;
948
+ try {
949
+ process.kill(pid, 0);
950
+ return false;
951
+ } catch (error) {
952
+ return error.code === "ESRCH";
953
+ }
954
+ }
955
+ /**
956
+ * Removes the stale claim `held`, and only it. Breakers of one claim take
957
+ * `<claim>.<hash of held>.break` first, so only one at a time may unlink it; while `held` is in
958
+ * place nobody else can remove or replace it, so reading it then unlinking it is safe.
959
+ */
960
+ async function breakClaim(file, held, runId) {
961
+ const lock = `${file}.${sha256(held).slice(0, 12)}.break`;
962
+ try {
963
+ await writeFile(lock, "", { flag: "wx" });
964
+ } catch (error) {
965
+ if (error.code === "EEXIST" || inFlux(error)) throw busy(runId, file);
966
+ throw error;
967
+ }
968
+ try {
969
+ let now;
970
+ try {
971
+ now = await readFile(file, "utf8");
972
+ } catch (error) {
973
+ if (isMissing(error)) return;
974
+ if (inFlux(error)) throw busy(runId, file);
975
+ throw error;
976
+ }
977
+ if (now === held) await unlink(file);
978
+ } finally {
979
+ await unlink(lock).catch(() => {});
980
+ }
981
+ }
982
+ /** Takes `runId`'s claim in `dir`, breaking one a dead process left; returns its release. */
983
+ async function claimRun(dir, runId) {
984
+ const file = claimFile(dir, runId);
985
+ const body = `${process.pid}\n${hostname()}\n${randomBytes(6).toString("hex")}\n`;
986
+ const tmp = `${file}.${tmpName()}`;
987
+ await writeFile(tmp, body);
988
+ try {
989
+ for (let tries = 0; tries < 3; tries++) {
990
+ try {
991
+ await link(tmp, file);
992
+ return async () => {
993
+ if (await readFile(file, "utf8").catch(() => null) === body) await unlink(file).catch(() => {});
994
+ };
995
+ } catch (error) {
996
+ if (![
997
+ "EEXIST",
998
+ "EPERM",
999
+ "EBUSY"
1000
+ ].includes(error.code ?? "")) throw error;
1001
+ }
1002
+ let held;
1003
+ try {
1004
+ held = await readFile(file, "utf8");
1005
+ } catch (error) {
1006
+ if (isMissing(error)) continue;
1007
+ if (inFlux(error)) throw busy(runId, file);
1008
+ throw error;
1009
+ }
1010
+ if (!claimGone(held)) throw busy(runId, file);
1011
+ await breakClaim(file, held, runId);
1012
+ }
1013
+ throw busy(runId, file);
1014
+ } finally {
1015
+ await unlink(tmp).catch(() => {});
1016
+ }
1017
+ }
1018
+ /**
1019
+ * A record its continuation replaces: the run stopped before it finished, or `next` ran one of
1020
+ * its infra errors again and keeps that error in the attempt's `retries`.
1021
+ */
1022
+ const replaceable = (bytes, where, next) => {
1023
+ try {
1024
+ const was = parseRecord(bytes, where);
1025
+ if (was.status === "interrupted" || was.status === "budget") return true;
1026
+ const now = parseRecord(next, where);
1027
+ const retried = new Map(now.evals.flatMap((e) => e.attempts).map((a) => [a.key, a.retries ?? []]));
1028
+ return was.evals.flatMap((e) => e.attempts).some((a) => a.outcome === "infra_error" && retried.get(a.key)?.some((r) => r.at === a.startedAt && r.error.message === a.error?.message));
1029
+ } catch {
1030
+ return false;
1031
+ }
1032
+ };
1033
+ const readIfThere = (path) => readFile(path).catch((error) => {
1034
+ if (isMissing(error)) return null;
1035
+ throw error;
1036
+ });
1037
+ /**
1038
+ * Claims the run, then writes `<dir>/<runId>/` (artifacts, and the snapshots `moves` brings in
1039
+ * by renaming), then `<dir>/<runId>.json` (the record). The record lands last and create-only, so a reader never sees a half-written run, and
1040
+ * a run is never rewritten, except an interrupted or budget-stopped one by its resumed run, and a
1041
+ * finished one by its `--retry-errors`.
1042
+ */
1043
+ async function writeRun(dir, record, artifacts, moves = /* @__PURE__ */ new Map()) {
1044
+ const recordPath = recordFile(dir, record.runId);
1045
+ const artifactDir = artifacts.size > 0 ? runDir(dir, record.runId) : null;
1046
+ const bytes = encodeRecord(record);
1047
+ if ((await readIfThere(recordPath))?.equals(bytes)) return {
1048
+ recordPath,
1049
+ artifactDir,
1050
+ created: false
1051
+ };
1052
+ await mkdir(dir, { recursive: true });
1053
+ const release = await claimRun(dir, record.runId);
1054
+ try {
1055
+ return await writeClaimed(dir, record.runId, bytes, artifacts, moves);
1056
+ } finally {
1057
+ await release();
1058
+ }
1059
+ }
1060
+ /** What most likely makes a run's new record differ from the recorded one, for the refusal. */
1061
+ function likelyChange(existing, bytes, runId) {
1062
+ const parse = (b) => {
1063
+ try {
1064
+ return JSON.parse(b.toString());
1065
+ } catch {
1066
+ return null;
1067
+ }
1068
+ };
1069
+ const [was, now] = [parse(existing), parse(bytes)];
1070
+ if (was && now && !isDeepStrictEqual(was.debug, now.debug)) {
1071
+ const { debug: _was, ...before } = was;
1072
+ const { debug: _now, ...after } = now;
1073
+ if (isDeepStrictEqual(before, after)) return `its debug data differs: .reeval/debug/${runId} was pruned or changed since it was recorded, or history.debug is another level`;
1074
+ }
1075
+ return "another --artifacts level?";
1076
+ }
1077
+ async function writeClaimed(dir, runId, bytes, artifacts, moves) {
1078
+ const recordPath = recordFile(dir, runId);
1079
+ const artifactDir = artifacts.size > 0 ? runDir(dir, runId) : null;
1080
+ const existing = await readIfThere(recordPath);
1081
+ if (existing?.equals(bytes)) return {
1082
+ recordPath,
1083
+ artifactDir,
1084
+ created: false
1085
+ };
1086
+ if (existing && !replaceable(existing, recordPath, bytes)) throw new HistoryError(`${runId} is already recorded with different content (${likelyChange(existing, bytes, runId)}). Recorded runs are never rewritten.`);
1087
+ const staging = artifactDir ? join(dir, `.tmp-${tmpName()}`) : null;
1088
+ try {
1089
+ if (staging) {
1090
+ for (const [path, content] of artifacts) {
1091
+ const file = join(staging, ...path.split("/"));
1092
+ await mkdir(dirname(file), { recursive: true });
1093
+ await writeFile(file, content);
1094
+ }
1095
+ for (const [path, source] of moves) {
1096
+ const target = join(staging, ...path.split("/"));
1097
+ await mkdir(dirname(target), { recursive: true });
1098
+ await rename(source, target);
1099
+ }
1100
+ }
1101
+ if (existing) {
1102
+ const old = join(dir, `.tmp-${tmpName()}`);
1103
+ const tmp = join(dir, `.tmp-${tmpName()}.json`);
1104
+ await writeFile(tmp, bytes);
1105
+ let moved = false;
1106
+ try {
1107
+ await rename(runDir(dir, runId), old).then(() => {
1108
+ moved = true;
1109
+ }, (error) => {
1110
+ if (error.code !== "ENOENT") throw error;
1111
+ });
1112
+ if (staging && artifactDir) await rename(staging, artifactDir);
1113
+ await rename(tmp, recordPath);
1114
+ } catch (error) {
1115
+ if (moved) {
1116
+ await rm(runDir(dir, runId), {
1117
+ recursive: true,
1118
+ force: true
1119
+ });
1120
+ await rename(old, runDir(dir, runId));
1121
+ }
1122
+ throw error;
1123
+ } finally {
1124
+ await rm(tmp, { force: true });
1125
+ }
1126
+ await rm(old, {
1127
+ recursive: true,
1128
+ force: true
1129
+ });
1130
+ return {
1131
+ recordPath,
1132
+ artifactDir,
1133
+ created: true
1134
+ };
1135
+ }
1136
+ await rm(runDir(dir, runId), {
1137
+ recursive: true,
1138
+ force: true
1139
+ });
1140
+ if (staging && artifactDir) await rename(staging, artifactDir);
1141
+ } finally {
1142
+ if (staging) await rm(staging, {
1143
+ recursive: true,
1144
+ force: true
1145
+ });
1146
+ }
1147
+ const tmp = join(dir, `.tmp-${tmpName()}.json`);
1148
+ await writeFile(tmp, bytes);
1149
+ try {
1150
+ await link(tmp, recordPath);
1151
+ } catch (error) {
1152
+ if (error.code === "EEXIST") throw new HistoryError(`${recordPath} was written by another process meanwhile`);
1153
+ throw error;
1154
+ } finally {
1155
+ await unlink(tmp).catch(() => {});
1156
+ }
1157
+ return {
1158
+ recordPath,
1159
+ artifactDir,
1160
+ created: true
1161
+ };
1162
+ }
1163
+ const failed = (x) => x.outcome === "fail" || x.outcome === "infra_error";
1164
+ const keeps = (x, level) => level === "all" || level === "failures" && failed(x);
1165
+ /** Each capture's PNG, then the page facts beside it. */
1166
+ const withPages = (refs) => refs.flatMap((r) => r.capture?.page ? [r, r.capture.page] : [r]);
1167
+ const attemptRefs = (a) => [
1168
+ ...Object.values(a.files).flatMap((v) => Array.isArray(v) ? withPages(v) : v ? [v] : []),
1169
+ ...a.checks.flatMap((c) => c.log ? [c.log] : []),
1170
+ ...(a.answers ?? []).flatMap((q) => q.input ? [q.input] : [])
1171
+ ];
1172
+ /** `<dir>/<runId>.zip`: a recorded run, its record and every file recorded with it, as one zip. */
1173
+ const archiveFile = (dir, runId) => join(dir, `${runId}.zip`);
1174
+ /** The whole of the run's `.reeval/debug/<runId>/` as its zip; none when it has no debug data. */
1175
+ async function archiveDebug(root, runId) {
1176
+ const dir = join(debugRoot(root), runId);
1177
+ if ((await pathsUnder(dir)).length === 0) return void 0;
1178
+ const release = await claimRun(debugRoot(root), runId);
1179
+ try {
1180
+ const files = [];
1181
+ for (const path of await pathsUnder(dir)) {
1182
+ const file = join(dir, ...path.split("/"));
1183
+ files.push({
1184
+ path: `${runId}/${path}`,
1185
+ sha256: await sha256File(file),
1186
+ data: () => readFile(file)
1187
+ });
1188
+ }
1189
+ if (files.length === 0) return void 0;
1190
+ return await freshArchive(debugArchiveFile(root, runId), {
1191
+ contents: "debug",
1192
+ runId,
1193
+ debugLevel: "all",
1194
+ files
1195
+ });
1196
+ } finally {
1197
+ await release();
1198
+ }
1199
+ }
1200
+ /** Every file under `dir`, by posix path, sorted. */
1201
+ async function pathsUnder(dir, at = "") {
1202
+ const entries = await readdir(join(dir, at), { withFileTypes: true }).catch(() => []);
1203
+ const out = [];
1204
+ for (const entry of entries) {
1205
+ const path = at ? `${at}/${entry.name}` : entry.name;
1206
+ if (entry.isDirectory()) out.push(...await pathsUnder(dir, path));
1207
+ else if (entry.isFile()) out.push(path);
1208
+ }
1209
+ return out.sort();
1210
+ }
1211
+ async function sha256File(file) {
1212
+ const hash = createHash("sha256");
1213
+ for await (const chunk of createReadStream(file)) hash.update(chunk);
1214
+ return hash.digest("hex");
1215
+ }
1216
+ /** What a run's archive holds of `<runId>/`: everything but what's added after recording. */
1217
+ const archived = (path) => !path.startsWith("analysis/");
1218
+ /**
1219
+ * Writes an archive of `files`, unless the one at `path` already lists exactly them. A missing
1220
+ * zip, or one that isn't a readable archive, is written at revision 1; one that lists other
1221
+ * files is written again a revision on. One a newer reeval wrote is left as it is.
1222
+ */
1223
+ async function freshArchive(path, options) {
1224
+ const wanted = new Map(options.files.map((f) => [f.path, "sha256" in f ? f.sha256 : sha256(f.data)]));
1225
+ let was = null;
1226
+ try {
1227
+ const archive = await openArchive(path);
1228
+ was = archive.manifest;
1229
+ await archive.close();
1230
+ } catch (error) {
1231
+ if (error instanceof NewerSchemaError) return {
1232
+ path,
1233
+ written: false
1234
+ };
1235
+ if (!isMissing(error) && !(error instanceof ArchiveError)) throw error;
1236
+ }
1237
+ const same = was?.files.length === wanted.size && was.files.every((f) => wanted.get(f.path) === f.sha256);
1238
+ if (was && same) return {
1239
+ path,
1240
+ written: false
1241
+ };
1242
+ await writeArchive(path, {
1243
+ ...options,
1244
+ revision: was ? was.revision + 1 : 1
1245
+ });
1246
+ return {
1247
+ path,
1248
+ written: true
1249
+ };
1250
+ }
1251
+ /**
1252
+ * The run's archive beside its record: under the run's claim, of the record and files as they
1253
+ * are in the folder, so it never holds what this reeval would write but didn't. Nothing when the
1254
+ * record there isn't `record` any more: another recording replaced it meanwhile and archives its
1255
+ * own.
1256
+ */
1257
+ async function archiveRun(dir, runId, record) {
1258
+ const release = await claimRun(dir, runId);
1259
+ try {
1260
+ const landed = await readIfThere(recordFile(dir, runId));
1261
+ if (!landed?.equals(record)) return void 0;
1262
+ const files = (await filesUnder(runDir(dir, runId))).filter(([path]) => archived(path));
1263
+ return await freshArchive(archiveFile(dir, runId), {
1264
+ contents: "run",
1265
+ runId,
1266
+ files: [{
1267
+ path: `${runId}.json`,
1268
+ data: landed
1269
+ }, ...files.map(([file, data]) => ({
1270
+ path: `${runId}/${file}`,
1271
+ data
1272
+ }))]
1273
+ });
1274
+ } finally {
1275
+ await release();
1276
+ }
1277
+ }
1278
+ /** Every file under `dir`, by posix path, with its bytes. */
1279
+ async function filesUnder(dir, at = "") {
1280
+ const entries = await readdir(join(dir, at), { withFileTypes: true }).catch(() => []);
1281
+ const out = [];
1282
+ for (const entry of entries) {
1283
+ const path = at ? `${at}/${entry.name}` : entry.name;
1284
+ if (entry.isDirectory()) out.push(...await filesUnder(dir, path));
1285
+ else if (entry.isFile()) out.push([path, await readFile(join(dir, path))]);
1286
+ }
1287
+ return out;
1288
+ }
1289
+ const DEBUG_FILES = {
1290
+ requests: [REQUESTS_FILE],
1291
+ all: [
1292
+ REQUESTS_FILE,
1293
+ DEBUG_LOG,
1294
+ TRACE_FILE
1295
+ ]
1296
+ };
1297
+ /**
1298
+ * The run's debug data `level` names, from `.reeval/debug/<run>`, written to `staging` for the
1299
+ * upload; a file the secret scan finds something in is left out and named in `dropped`.
1300
+ */
1301
+ async function stageDebug(root, runId, options) {
1302
+ const wanted = DEBUG_FILES[options.level];
1303
+ const debug = {
1304
+ level: options.level,
1305
+ files: []
1306
+ };
1307
+ const dropped = [];
1308
+ await rm(options.staging, {
1309
+ recursive: true,
1310
+ force: true
1311
+ });
1312
+ for (const [path, bytes] of await filesUnder(join(debugRoot(root), runId))) {
1313
+ if (!wanted.includes(path.slice(path.lastIndexOf("/") + 1))) continue;
1314
+ const findings = scanText(path, Buffer.from(bytes).toString());
1315
+ if (findings.length > 0) {
1316
+ dropped.push({
1317
+ path,
1318
+ note: `${SECRET_NOTE} (${findingSummary(findings)})`
1319
+ });
1320
+ continue;
1321
+ }
1322
+ const file = join(options.staging, ...path.split("/"));
1323
+ await mkdir(dirname(file), { recursive: true });
1324
+ await writeFile(file, bytes);
1325
+ debug.files.push({
1326
+ path,
1327
+ sha256: sha256(bytes),
1328
+ bytes: bytes.length
1329
+ });
1330
+ }
1331
+ if (dropped.length) debug.dropped = dropped;
1332
+ return debug.files.length || dropped.length ? debug : void 0;
1333
+ }
1334
+ /** Why a patch that looked like it held a secret isn't in the record. Starts with `SECRET_NOTE`. */
1335
+ const SECRET_NOTE = "not kept: it looked like it held a secret";
1336
+ /** Promotes a scratch run into the committed history folder. reeval never commits it. */
1337
+ async function recordRun(options) {
1338
+ const { runId, artifacts: level } = options;
1339
+ const source = scratchDir(options.root);
1340
+ let scratch;
1341
+ try {
1342
+ scratch = await readRecord(join(source, `${runId}.json`));
1343
+ } catch (error) {
1344
+ if (isMissing(error)) throw new HistoryError(`No run ${runId} in .reeval/runs`);
1345
+ throw error;
1346
+ }
1347
+ if (scratch.status !== "complete" && !options.allowIncomplete) throw new HistoryError(`Run ${runId} was ${scratch.status}; pass --allow-incomplete to record it`);
1348
+ const record = structuredClone(scratch);
1349
+ record.artifacts = level;
1350
+ const files = /* @__PURE__ */ new Map();
1351
+ const keep = async (ref) => {
1352
+ const bytes = await readFile(join(source, runId, ...ref.path.split("/")));
1353
+ if (sha256(bytes) !== ref.sha256) throw new HistoryError(`${runId}/${ref.path} changed since the run wrote it`);
1354
+ files.set(ref.path, bytes);
1355
+ return bytes;
1356
+ };
1357
+ for (const e of record.evals) {
1358
+ const shown = /* @__PURE__ */ new Set();
1359
+ for (const q of e.answers ?? []) {
1360
+ if (!q.input) continue;
1361
+ if (level === "none" || !keeps(e, level)) {
1362
+ delete q.input;
1363
+ continue;
1364
+ }
1365
+ const input = JSON.parse(Buffer.from(await keep(q.input)).toString());
1366
+ for (const s of input.calls.flatMap((c) => c.screenshots ?? [])) if ("path" in s && s.path) shown.add(s.path);
1367
+ }
1368
+ const whole = failed(e) && !e.attempts.some(failed);
1369
+ for (const a of e.attempts) {
1370
+ const cellFailed = e.attempts.some((b) => b.cell === a.cell && failed(b));
1371
+ const cell = e.cells.find((c) => c.key === a.cell);
1372
+ const all = whole || cell !== void 0 && failed(cell) && !cellFailed;
1373
+ if (level !== "none" && (all || keeps(a, level))) {
1374
+ for (const ref of attemptRefs(a)) await keep(ref);
1375
+ continue;
1376
+ }
1377
+ const caseFailed = e.attempts.some((b) => b.cell === a.cell && b.case === a.case && failed(b));
1378
+ const diff = level !== "none" && caseFailed ? a.files.diff : void 0;
1379
+ const screenshots = (a.files.artifacts ?? []).filter((r) => shown.has(r.path));
1380
+ a.files = {
1381
+ ...diff ? { diff } : {},
1382
+ ...screenshots.length ? { artifacts: screenshots } : {}
1383
+ };
1384
+ for (const ref of [...diff ? [diff] : [], ...withPages(screenshots)]) await keep(ref);
1385
+ for (const c of a.checks) delete c.log;
1386
+ for (const q of a.answers ?? []) delete q.input;
1387
+ }
1388
+ }
1389
+ const patch = record.git?.worktreePatch;
1390
+ let droppedPatch = [];
1391
+ if (patch && record.git && level !== "none") {
1392
+ const bytes = await readFile(join(source, runId, patch.path));
1393
+ if (sha256(bytes) !== patch.sha256) throw new HistoryError(`${runId}/${patch.path} changed since the run wrote it`);
1394
+ const findings = options.skipSecretScan ? [] : scanText(patch.path, bytes.toString());
1395
+ if (findings.length > 0) {
1396
+ droppedPatch = findingLines(patch.path, findings);
1397
+ record.git.worktreePatch = null;
1398
+ record.git.worktreePatchNote = `${SECRET_NOTE} (${findingSummary(findings)})`;
1399
+ } else files.set(patch.path, bytes);
1400
+ } else if (patch && record.git) {
1401
+ record.git.worktreePatch = null;
1402
+ record.git.worktreePatchNote = "not kept: recorded with artifacts 'none'";
1403
+ }
1404
+ const remarkBytes = await readFile(join(source, runId, REMARKS_FILE)).catch(() => null);
1405
+ let remarks = null;
1406
+ if (remarkBytes) try {
1407
+ remarks = readableRemarks(JSON.parse(remarkBytes.toString()), REMARKS_FILE);
1408
+ files.set(REMARKS_FILE, remarkBytes);
1409
+ } catch {}
1410
+ if (level !== "none") files.set("summary.md", Buffer.from(renderSummary(record, { remarks })));
1411
+ const debug = options.debug && await stageDebug(options.root, runId, options.debug);
1412
+ if (debug) record.debug = debug;
1413
+ if (!options.skipSecretScan) {
1414
+ const found = [[`${runId}.json`, scanText(`${runId}.json`, encodeRecord(record).toString())], ...[...files].filter(([path]) => TEXT_FILE.test(path)).map(([path, bytes]) => [`${runId}/${path}`, scanText(path, Buffer.from(bytes).toString())])].filter(([, findings]) => findings.length > 0);
1415
+ if (found.length > 0) {
1416
+ const lines = found.flatMap(([path, findings]) => findingLines(path, findings));
1417
+ throw new HistoryError(`Refusing to record ${runId}: ${found.length} file(s) look like they contain a secret:\n${lines.map((l) => ` ${l}`).join("\n")}\nCheck them, then pass --skip-secret-scan if these are false positives.`);
1418
+ }
1419
+ }
1420
+ const committed = options.committed ?? true;
1421
+ if (committed) {
1422
+ await ensureHistoryGitignore(options.historyDir, options.archive ?? false);
1423
+ await ensureHistoryGitattributes(options.historyDir);
1424
+ }
1425
+ const written = await writeRun(options.historyDir, record, files);
1426
+ const zip = options.archive && await archiveRun(options.historyDir, runId, encodeRecord(record)).catch((error) => {
1427
+ const why = error instanceof Error ? error.message : String(error);
1428
+ throw new HistoryError(`Recorded ${runId}, but couldn't archive it: ${why}`, { cause: error });
1429
+ });
1430
+ const debugArchive = options.debugArchive && await archiveDebug(options.root, runId).catch((error) => {
1431
+ const why = error instanceof Error ? error.message : String(error);
1432
+ throw new HistoryError(`Recorded ${runId}, but couldn't archive its debug data: ${why}`, { cause: error });
1433
+ });
1434
+ const archive = {
1435
+ ...zip ? { archive: zip } : {},
1436
+ ...debugArchive ? { debugArchive } : {}
1437
+ };
1438
+ const bytes = [...files.values()].reduce((n, b) => n + b.length, encodeRecord(record).length);
1439
+ if (!committed) return {
1440
+ ...written,
1441
+ files: files.size,
1442
+ bytes,
1443
+ droppedPatch,
1444
+ ignored: [],
1445
+ ...debug ? { debug } : {},
1446
+ ...archive
1447
+ };
1448
+ const folderFiles = [historyGitignorePath(options.historyDir), historyGitattributesPath(options.historyDir)];
1449
+ if (!written.created) {
1450
+ const ignored = await ignoredRecordedFiles(options.root, folderFiles);
1451
+ return {
1452
+ ...written,
1453
+ files: files.size,
1454
+ bytes,
1455
+ droppedPatch,
1456
+ ignored,
1457
+ ...archive
1458
+ };
1459
+ }
1460
+ const writtenPaths = [
1461
+ written.recordPath,
1462
+ ...folderFiles,
1463
+ ...[...files.keys()].map((path) => join(written.artifactDir ?? options.historyDir, ...path.split("/")))
1464
+ ];
1465
+ const ignored = await ignoredRecordedFiles(options.root, writtenPaths);
1466
+ return {
1467
+ ...written,
1468
+ files: files.size,
1469
+ bytes,
1470
+ droppedPatch,
1471
+ ignored,
1472
+ ...archive
1473
+ };
1474
+ }
1475
+ export { ensureHistoryGitignore as S, warnUnreadable as _, encodeRecord as a, scanText as b, parseRecord as c, recordFile as d, recordNames as f, scratchDir as g, runDir as h, archiveFile as i, readRecord as l, replaceable as m, NewerRecordError as n, filesUnder as o, recordRun as p, SECRET_NOTE as r, listRuns as s, HistoryError as t, recentRecords as u, writeRun as v, ensureHistoryGitattributes as x, findingLines as y };
1476
+
1477
+ //# sourceMappingURL=files-BesexM88.js.map