reeval 0.17.2 → 0.19.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 (403) hide show
  1. package/README.md +5 -3
  2. package/THIRD_PARTY_NOTICES.md +5 -5
  3. package/dist/{adapter-DyvDj4ZN.js → adapter-C8xPuXYq.js} +5 -4
  4. package/dist/adapter-C8xPuXYq.js.map +1 -0
  5. package/dist/{agent-v036GEgG.js → agent-CBoLndM7.js} +30 -10
  6. package/dist/{agent-v036GEgG.js.map → agent-CBoLndM7.js.map} +1 -1
  7. package/dist/agents-C6zhkxp3.js +1151 -0
  8. package/dist/agents-C6zhkxp3.js.map +1 -0
  9. package/dist/{analysis-adKPz-UJ.js → analysis-BnG_1x_O.js} +4 -4
  10. package/dist/{analysis-adKPz-UJ.js.map → analysis-BnG_1x_O.js.map} +1 -1
  11. package/dist/{app-files-hpRT5lj_.js → app-files-DT5mJyV4.js} +4 -4
  12. package/dist/app-files-DT5mJyV4.js.map +1 -0
  13. package/dist/assemble-UPCRrtOz.js +1 -0
  14. package/dist/{assemble-Dlh6Xv3U.js → assemble-t6h018An.js} +194 -307
  15. package/dist/assemble-t6h018An.js.map +1 -0
  16. package/dist/{attempt-CtKGvaQR.js → attempt-CAdlwlNu.js} +3 -3
  17. package/dist/{attempt-CtKGvaQR.js.map → attempt-CAdlwlNu.js.map} +1 -1
  18. package/dist/{attempt-host-DErH-DYV.js → attempt-host-CIm1-11m.js} +18 -10
  19. package/dist/{attempt-host-DErH-DYV.js.map → attempt-host-CIm1-11m.js.map} +1 -1
  20. package/dist/boat-BjLqFJIZ.js +108 -0
  21. package/dist/boat-BjLqFJIZ.js.map +1 -0
  22. package/dist/boat-CJCtzfB1.js +322 -0
  23. package/dist/boat-CJCtzfB1.js.map +1 -0
  24. package/dist/bridge/index.mjs +300 -78
  25. package/dist/capture-DoxFUN3J.js +1 -0
  26. package/dist/{capture-Bdcx9Gap.js → capture-iBzFiC0j.js} +406 -625
  27. package/dist/capture-iBzFiC0j.js.map +1 -0
  28. package/dist/cases-Dy0mifal.js +1 -0
  29. package/dist/cases-z9E6DCd5.js +639 -0
  30. package/dist/cases-z9E6DCd5.js.map +1 -0
  31. package/dist/{cli-CGd51thd.js → cli-20Fpvs5H.js} +929 -576
  32. package/dist/cli-20Fpvs5H.js.map +1 -0
  33. package/dist/{cli-spec-ChkleEVm.js → cli-spec-Dsr79Qy1.js} +46 -18
  34. package/dist/cli-spec-Dsr79Qy1.js.map +1 -0
  35. package/dist/cli.js +2 -2
  36. package/dist/{client-CF-DOjOU.js → client-KM4C5r5_.js} +111 -14
  37. package/dist/client-KM4C5r5_.js.map +1 -0
  38. package/dist/{command-CsfcwMyc.js → command-B5OyHpOu.js} +24 -81
  39. package/dist/command-B5OyHpOu.js.map +1 -0
  40. package/dist/{command-CtTdCF3B.js → command-BLNVDiIg.js} +10 -10
  41. package/dist/{command-CtTdCF3B.js.map → command-BLNVDiIg.js.map} +1 -1
  42. package/dist/{command-CyIb9BSC.js → command-CRh-cb6Z.js} +120 -55
  43. package/dist/command-CRh-cb6Z.js.map +1 -0
  44. package/dist/{command-TLmY-rYp.js → command-aUJvENwy.js} +18 -18
  45. package/dist/command-aUJvENwy.js.map +1 -0
  46. package/dist/{commands-C54S45d7.js → commands-CWy-WndG.js} +239 -92
  47. package/dist/commands-CWy-WndG.js.map +1 -0
  48. package/dist/{commands-jO9Jj35r.js → commands-CfdBX-mc.js} +1 -1
  49. package/dist/{config-ImY6AlRE.js → config-B9mB1kF5.js} +924 -1729
  50. package/dist/config-B9mB1kF5.js.map +1 -0
  51. package/dist/{context-BajfiH0S.js → context-Bkv3ndjq.js} +3 -2
  52. package/dist/context-Bkv3ndjq.js.map +1 -0
  53. package/dist/{cost-e4IppZpJ.js → cost-BdRgySQl.js} +4 -4
  54. package/dist/{cost-e4IppZpJ.js.map → cost-BdRgySQl.js.map} +1 -1
  55. package/dist/cost-Cr26Alhq.js +1 -0
  56. package/dist/{cursor-catalog-Bw6-pJjR.js → cursor-catalog-BSn9xjmo.js} +3 -3
  57. package/dist/{cursor-catalog-Bw6-pJjR.js.map → cursor-catalog-BSn9xjmo.js.map} +1 -1
  58. package/dist/db-P2fXw4nx.js +2 -0
  59. package/dist/{db-sHGpaLo9.js → db-zgC1tvKB.js} +178 -74
  60. package/dist/db-zgC1tvKB.js.map +1 -0
  61. package/dist/debug-CF4p4Lp_.js +1 -0
  62. package/dist/{debug-B5jDImcW.js → debug-CIXzB4wK.js} +2 -2
  63. package/dist/{debug-B5jDImcW.js.map → debug-CIXzB4wK.js.map} +1 -1
  64. package/dist/{default-effort-fpdbYVKm.js → default-effort-BAy8ixd1.js} +1 -1
  65. package/dist/{default-effort-BZRa-SQP.js → default-effort-DGhQmu95.js} +8 -5
  66. package/dist/default-effort-DGhQmu95.js.map +1 -0
  67. package/dist/{dist-ByYk_wAs.js → dist-CAFD1yfv.js} +28 -6
  68. package/dist/dist-CAFD1yfv.js.map +1 -0
  69. package/dist/{docker-CWuSRj7a.js → docker-Cqw-CyWz.js} +4 -4
  70. package/dist/{docker-CWuSRj7a.js.map → docker-Cqw-CyWz.js.map} +1 -1
  71. package/dist/{docker--2ytOHcu.js → docker-DAMnm3L9.js} +103 -73
  72. package/dist/docker-DAMnm3L9.js.map +1 -0
  73. package/dist/{docker-CIzHzwlC.js → docker-Dr4XeDc8.js} +1 -1
  74. package/dist/{doctor-eE65YpEv.js → doctor-B2PohneB.js} +86 -29
  75. package/dist/doctor-B2PohneB.js.map +1 -0
  76. package/dist/{env-T86lAqUD.js → env-8x1O8I1M.js} +2 -2
  77. package/dist/{env-T86lAqUD.js.map → env-8x1O8I1M.js.map} +1 -1
  78. package/dist/{environment-Cy3FVLR5.js → environment-DB8o3hGi.js} +80 -40
  79. package/dist/environment-DB8o3hGi.js.map +1 -0
  80. package/dist/{errors-BQV__TzH.js → errors-BZgLSZtV.js} +2 -2
  81. package/dist/{errors-BQV__TzH.js.map → errors-BZgLSZtV.js.map} +1 -1
  82. package/dist/{eval-source-BTsTRiBW.js → eval-source-D3sbAzt-.js} +23 -15
  83. package/dist/eval-source-D3sbAzt-.js.map +1 -0
  84. package/dist/evaluate-COdzf7Hl.d.ts +92 -0
  85. package/dist/{evaluate-CFFdyYZX.js → evaluate-CwKeN_fo.js} +472 -159
  86. package/dist/evaluate-CwKeN_fo.js.map +1 -0
  87. package/dist/files-B4KQUiM7.js +1 -0
  88. package/dist/files-BEwfjD8J.js +64 -0
  89. package/dist/files-BEwfjD8J.js.map +1 -0
  90. package/dist/{files-CQU08uh4.js → files-BRzV7aPh.js} +5 -5
  91. package/dist/{files-CQU08uh4.js.map → files-BRzV7aPh.js.map} +1 -1
  92. package/dist/{files-CIX-pLl4.js → files-BiFU16BW.js} +6 -6
  93. package/dist/{files-CIX-pLl4.js.map → files-BiFU16BW.js.map} +1 -1
  94. package/dist/files-C1Rk9FYA.js +1 -0
  95. package/dist/files-C3mCC8Mn.js +1 -0
  96. package/dist/{files-tnMgu7-X.js → files-Cl7BQ5gE.js} +55 -14
  97. package/dist/{files-tnMgu7-X.js.map → files-Cl7BQ5gE.js.map} +1 -1
  98. package/dist/{files-BGlHnC46.js → files-DgXyaAg6.js} +2 -2
  99. package/dist/{files-BGlHnC46.js.map → files-DgXyaAg6.js.map} +1 -1
  100. package/dist/{files-p-uTdOjA.js → files-DlQshsks.js} +3 -2
  101. package/dist/files-DlQshsks.js.map +1 -0
  102. package/dist/files-DnlA1A7N.js +1 -0
  103. package/dist/gate-CgYdaprG.js +49 -0
  104. package/dist/gate-CgYdaprG.js.map +1 -0
  105. package/dist/gateway.d.ts +1 -1
  106. package/dist/{git-BWVkG4Yl.js → git-fDiJ8UIV.js} +3 -3
  107. package/dist/{git-BWVkG4Yl.js.map → git-fDiJ8UIV.js.map} +1 -1
  108. package/dist/harness-C2berMiM.js +105 -0
  109. package/dist/harness-C2berMiM.js.map +1 -0
  110. package/dist/{harness-Ch2P81sx.js → harness-DXv2gnaT.js} +68 -111
  111. package/dist/harness-DXv2gnaT.js.map +1 -0
  112. package/dist/harness.d.ts +1 -1
  113. package/dist/harness.js +1 -1
  114. package/dist/{ids-DuK6xl4w.js → ids-C_advdJA.js} +3 -8
  115. package/dist/ids-C_advdJA.js.map +1 -0
  116. package/dist/{images-BVZHDf_z.js → images-BNgcR77K.js} +98 -10
  117. package/dist/images-BNgcR77K.js.map +1 -0
  118. package/dist/index.d.ts +23 -3
  119. package/dist/index.js +5 -5
  120. package/dist/init-4RPeD-K-.js +1 -0
  121. package/dist/{init-BWnMbUnc.js → init-DbuZVRrW.js} +8 -7
  122. package/dist/init-DbuZVRrW.js.map +1 -0
  123. package/dist/ink-list-BpfidQ1h.js +274 -0
  124. package/dist/ink-list-BpfidQ1h.js.map +1 -0
  125. package/dist/{invocations-BGRs1r_C.js → invocations-CxGNOlh0.js} +4 -4
  126. package/dist/{invocations-BGRs1r_C.js.map → invocations-CxGNOlh0.js.map} +1 -1
  127. package/dist/judge-COMXT1Hx.js +230 -0
  128. package/dist/judge-COMXT1Hx.js.map +1 -0
  129. package/dist/judge.d.ts +1 -1
  130. package/dist/judge.js +1 -1
  131. package/dist/judgments-CzgpsTqv.js +246 -0
  132. package/dist/judgments-CzgpsTqv.js.map +1 -0
  133. package/dist/kinds-C1oY3qyC.js +697 -0
  134. package/dist/kinds-C1oY3qyC.js.map +1 -0
  135. package/dist/{summary-zP3cCXDN.js → layout-Cm85tQYk.js} +77 -154
  136. package/dist/layout-Cm85tQYk.js.map +1 -0
  137. package/dist/list-DuThsE28.js +1348 -0
  138. package/dist/list-DuThsE28.js.map +1 -0
  139. package/dist/live-CJCK11nh.js +1 -0
  140. package/dist/{live-d_5a5iUv.js → live-CgYbO4Te.js} +24 -4
  141. package/dist/live-CgYbO4Te.js.map +1 -0
  142. package/dist/{live-ColieOai.js → live-CnGrRM6j.js} +8 -8
  143. package/dist/{live-ColieOai.js.map → live-CnGrRM6j.js.map} +1 -1
  144. package/dist/{matchers-B4ZtlJyP.js → matchers-CXLn-1jm.js} +4 -3
  145. package/dist/{matchers-B4ZtlJyP.js.map → matchers-CXLn-1jm.js.map} +1 -1
  146. package/dist/{model-DOXnWH65.js → model-047Dcd-a.js} +1 -1
  147. package/dist/model-Cv4GuTsZ.js +1 -0
  148. package/dist/{model-CFSjV-HJ.js → model-CwwkrCb7.js} +5 -5
  149. package/dist/{model-CFSjV-HJ.js.map → model-CwwkrCb7.js.map} +1 -1
  150. package/dist/{model-DBpdRXtO.js → model-DJjLw-0r.js} +43 -19
  151. package/dist/{model-DBpdRXtO.js.map → model-DJjLw-0r.js.map} +1 -1
  152. package/dist/{model-DOiCiMCD.js → model-V3mMXp6x.js} +213 -559
  153. package/dist/model-V3mMXp6x.js.map +1 -0
  154. package/dist/{node-CwP1G178.js → node-D7pAU--0.js} +34 -25
  155. package/dist/node-D7pAU--0.js.map +1 -0
  156. package/dist/{opencode-providers-yNKyXD49.js → opencode-providers-BGiXt8_B.js} +107 -49
  157. package/dist/opencode-providers-BGiXt8_B.js.map +1 -0
  158. package/dist/{openrouter-models-C8nzPKG2.js → openrouter-models-Cw1z8-sq.js} +2 -2
  159. package/dist/{openrouter-models-C8nzPKG2.js.map → openrouter-models-Cw1z8-sq.js.map} +1 -1
  160. package/dist/options-CHubslQf.js +1 -0
  161. package/dist/{gate-BoDKeuJu.js → pairs-BGb134Vu.js} +3 -49
  162. package/dist/pairs-BGb134Vu.js.map +1 -0
  163. package/dist/{patch-DvLr8wCZ.js → patch-DH4e_Gkd.js} +3 -3
  164. package/dist/{patch-DvLr8wCZ.js.map → patch-DH4e_Gkd.js.map} +1 -1
  165. package/dist/plain-BYUf_fUV.js +267 -0
  166. package/dist/plain-BYUf_fUV.js.map +1 -0
  167. package/dist/{plan-CIfOFhth.js → plan-Cgq9NCEX.js} +117 -45
  168. package/dist/plan-Cgq9NCEX.js.map +1 -0
  169. package/dist/{plugins-BEs2Am3L.js → plugins-BkmPxDiY.js} +11 -268
  170. package/dist/plugins-BkmPxDiY.js.map +1 -0
  171. package/dist/preflight-4gWSy0Pe.js +1 -0
  172. package/dist/{preflight-50Qw5e5K.js → preflight-BElE_q0u.js} +16 -9
  173. package/dist/preflight-BElE_q0u.js.map +1 -0
  174. package/dist/preflight-CtlloeOQ.js +68 -0
  175. package/dist/preflight-CtlloeOQ.js.map +1 -0
  176. package/dist/{preflight-BAIRsTpl.js → preflight-R-InZCQb.js} +1 -1
  177. package/dist/{prepare-8XhzhLHX.js → prepare-C7f5mPl5.js} +9 -9
  178. package/dist/{prepare-8XhzhLHX.js.map → prepare-C7f5mPl5.js.map} +1 -1
  179. package/dist/{prepare-8nvfDFQx.js → prepare-CzkAdbXm.js} +2 -2
  180. package/dist/{prices-C4BRuSe8.js → prices-5m3SzMZ3.js} +3 -3
  181. package/dist/{prices-C4BRuSe8.js.map → prices-5m3SzMZ3.js.map} +1 -1
  182. package/dist/{provenance-Cc8fFE7Z.js → provenance-zsc4--dP.js} +6 -5
  183. package/dist/provenance-zsc4--dP.js.map +1 -0
  184. package/dist/provider-BnUoz4KB.js +1 -0
  185. package/dist/{provider-DZd8t_XW.js → provider-BxzZq3Th.js} +2 -2
  186. package/dist/{provider-DZd8t_XW.js.map → provider-BxzZq3Th.js.map} +1 -1
  187. package/dist/{providers-DZSTlC9R.js → providers-B8xYMeah.js} +152 -9
  188. package/dist/providers-B8xYMeah.js.map +1 -0
  189. package/dist/providers-CVu8e0xS.js +1 -0
  190. package/dist/{query-DXpxaaTH.js → query-Bb3SYICk.js} +3 -3
  191. package/dist/{query-DXpxaaTH.js.map → query-Bb3SYICk.js.map} +1 -1
  192. package/dist/query-DIfkUcPh.js +1 -0
  193. package/dist/{questions-C_Y-oXW6.js → questions-CWlR9ffu.js} +41 -11
  194. package/dist/questions-CWlR9ffu.js.map +1 -0
  195. package/dist/{record-DhzwkSXc.js → record-6IUzwP9K.js} +5 -3
  196. package/dist/record-6IUzwP9K.js.map +1 -0
  197. package/dist/{redact-BEEGc37e.js → redact-BhjtnjrU.js} +11 -7
  198. package/dist/redact-BhjtnjrU.js.map +1 -0
  199. package/dist/remarks-CAvTSq16.js +1 -0
  200. package/dist/{remarks-0EXMh6AD.js → remarks-D9Lcd1fF.js} +3 -2
  201. package/dist/remarks-D9Lcd1fF.js.map +1 -0
  202. package/dist/remarks-DPCONFxZ.js +138 -0
  203. package/dist/remarks-DPCONFxZ.js.map +1 -0
  204. package/dist/{remarks-E4rpi8Ym.js → remarks-vtkPmQb9.js} +327 -41
  205. package/dist/remarks-vtkPmQb9.js.map +1 -0
  206. package/dist/{remote-DZ00A8V_.js → remote-BgYWqogI.js} +6 -6
  207. package/dist/{remote-DZ00A8V_.js.map → remote-BgYWqogI.js.map} +1 -1
  208. package/dist/{resolve-B_JlQ0La.js → resolve-Do0ZaYH6.js} +11 -10
  209. package/dist/resolve-Do0ZaYH6.js.map +1 -0
  210. package/dist/resolve-amw_2Odz.js +1 -0
  211. package/dist/{results-BMJHaQbi.js → results-JyuM64gy.js} +7 -7
  212. package/dist/{results-BMJHaQbi.js.map → results-JyuM64gy.js.map} +1 -1
  213. package/dist/resume-AW5oXzUc.js +691 -0
  214. package/dist/resume-AW5oXzUc.js.map +1 -0
  215. package/dist/retry-ChzISxmy.js +105 -0
  216. package/dist/retry-ChzISxmy.js.map +1 -0
  217. package/dist/{runtime-CSZ1hjlN.js → runtime-BpW1f1Mx.js} +26 -7
  218. package/dist/runtime-BpW1f1Mx.js.map +1 -0
  219. package/dist/sandbox/boat.d.ts +26 -0
  220. package/dist/sandbox/boat.js +37 -0
  221. package/dist/sandbox/boat.js.map +1 -0
  222. package/dist/{sandbox-B5W8lLL1.js → sandbox-kSgr7vo5.js} +31 -3
  223. package/dist/sandbox-kSgr7vo5.js.map +1 -0
  224. package/dist/sandbox.d.ts +20 -2
  225. package/dist/sandbox.js +1 -1
  226. package/dist/server-2_gUnVvf.js +1 -0
  227. package/dist/{server-BfN6q2lH.js → server-Cn8VqO9S.js} +10 -10
  228. package/dist/{server-BfN6q2lH.js.map → server-Cn8VqO9S.js.map} +1 -1
  229. package/dist/{shared-ogqPJ0uo.js → shared-Cfi45Bvy.js} +9 -2
  230. package/dist/shared-Cfi45Bvy.js.map +1 -0
  231. package/dist/slug-IHh3f770.js +136 -0
  232. package/dist/slug-IHh3f770.js.map +1 -0
  233. package/dist/source-CY3etKzw.js +1 -0
  234. package/dist/{source-BD6Bg0Tr.js → source-CYOhR98B.js} +2 -2
  235. package/dist/{source-BD6Bg0Tr.js.map → source-CYOhR98B.js.map} +1 -1
  236. package/dist/src-6Zzyg4Qd.js +2 -0
  237. package/dist/{src-BC2WXULN.js → src-BDhcPtnI.js} +2 -2
  238. package/dist/{src-B-L8O1Ld.js → src-BNQznj4z.js} +2 -2
  239. package/dist/{src-B-L8O1Ld.js.map → src-BNQznj4z.js.map} +1 -1
  240. package/dist/src-BRMsk9nh.js +2 -0
  241. package/dist/{src-Dp-fWOfG.js → src-CV_7DkPa.js} +47 -45
  242. package/dist/{src-Dp-fWOfG.js.map → src-CV_7DkPa.js.map} +1 -1
  243. package/dist/{src-KlDOGD0B.js → src-Cb2MWozp.js} +3 -1
  244. package/dist/{src-KlDOGD0B.js.map → src-Cb2MWozp.js.map} +1 -1
  245. package/dist/{src-Cpy9MNS3.js → src-Ck2r_EMT.js} +617 -74
  246. package/dist/src-Ck2r_EMT.js.map +1 -0
  247. package/dist/{src-HTG2SoNz.js → src-DAzaCTcN.js} +2 -2
  248. package/dist/{src-HTG2SoNz.js.map → src-DAzaCTcN.js.map} +1 -1
  249. package/dist/src-DB7N8TYJ.js +2 -0
  250. package/dist/src-DPDaAYwh.js +2 -0
  251. package/dist/{src-Cx0HJIJ-.js → src-Dbk19BiP.js} +2 -2
  252. package/dist/src-DtodMT59.js +1 -0
  253. package/dist/{src-uluei5nU.js → src-DvGns8cz.js} +2 -2
  254. package/dist/{src-uluei5nU.js.map → src-DvGns8cz.js.map} +1 -1
  255. package/dist/{src-B_igzM1O.js → src-Dw79VLa3.js} +3 -1
  256. package/dist/{src-B_igzM1O.js.map → src-Dw79VLa3.js.map} +1 -1
  257. package/dist/{src-D5t4OiRt.js → src-KxS91P7L.js} +3 -1
  258. package/dist/{src-D5t4OiRt.js.map → src-KxS91P7L.js.map} +1 -1
  259. package/dist/src-T-OeuJLr.js +2 -0
  260. package/dist/{src-BvM0jWuZ.js → src-YvblOrBU.js} +2 -2
  261. package/dist/{src-BvM0jWuZ.js.map → src-YvblOrBU.js.map} +1 -1
  262. package/dist/src-zntEDlnx.js +3 -0
  263. package/dist/{state-CdSjXIfE.js → state-BOLt8pJg.js} +17 -17
  264. package/dist/{state-CdSjXIfE.js.map → state-BOLt8pJg.js.map} +1 -1
  265. package/dist/state-kimtIhBP.js +1 -0
  266. package/dist/{stats-D-Gqwqt0.js → stats-C18W4xPX.js} +63 -8
  267. package/dist/stats-C18W4xPX.js.map +1 -0
  268. package/dist/suite-CKBa6MKt.js +2 -0
  269. package/dist/suite-COglUhPd.js +1272 -0
  270. package/dist/suite-COglUhPd.js.map +1 -0
  271. package/dist/summary-DU5zaibx.js +148 -0
  272. package/dist/summary-DU5zaibx.js.map +1 -0
  273. package/dist/tart-BTVXp8rz.js +373 -0
  274. package/dist/tart-BTVXp8rz.js.map +1 -0
  275. package/dist/tart-cli-BIC9HqPg.js +37 -0
  276. package/dist/tart-cli-BIC9HqPg.js.map +1 -0
  277. package/dist/tart-cli-BMrkmBjI.js +1 -0
  278. package/dist/tart-images-DZ_Mbh-g.js +233 -0
  279. package/dist/tart-images-DZ_Mbh-g.js.map +1 -0
  280. package/dist/tart-ref-7Qv3cm3B.js +1 -0
  281. package/dist/tart-ref-DYZijjrU.js +55 -0
  282. package/dist/tart-ref-DYZijjrU.js.map +1 -0
  283. package/dist/testing.d.ts +47 -37
  284. package/dist/testing.js +4 -4
  285. package/dist/{text-D--Q5KsA.js → text-B8-W3Cvn.js} +2 -4
  286. package/dist/{text-D--Q5KsA.js.map → text-B8-W3Cvn.js.map} +1 -1
  287. package/dist/trace-Dx2NBE1O.js +311 -0
  288. package/dist/trace-Dx2NBE1O.js.map +1 -0
  289. package/dist/traits-DKnYkqeK.js +66 -0
  290. package/dist/traits-DKnYkqeK.js.map +1 -0
  291. package/dist/{transcript-C_IpYMRk.js → transcript-CCf07UmU.js} +3 -3
  292. package/dist/{transcript-C_IpYMRk.js.map → transcript-CCf07UmU.js.map} +1 -1
  293. package/dist/{types-C4OkYhZg.js → types-C2mLpph3.js} +3 -2
  294. package/dist/types-C2mLpph3.js.map +1 -0
  295. package/dist/{types-BHR1lGPh.d.ts → types-DBwFsGem.d.ts} +420 -136
  296. package/dist/{judge-ByEUlzOM.js → vercel-CGlSBv63.js} +3 -229
  297. package/dist/vercel-CGlSBv63.js.map +1 -0
  298. package/dist/{vertex-6uSpZ5L8.js → vertex-Eb2wqahk.js} +5 -2
  299. package/dist/vertex-Eb2wqahk.js.map +1 -0
  300. package/dist/vertex-O88TCwgY.js +1 -0
  301. package/dist/view/index.d.ts +238 -90
  302. package/dist/view/index.js +11 -9
  303. package/dist/{views-CKoN5NAx.js → views-DAIiLiV3.js} +8 -7
  304. package/dist/views-DAIiLiV3.js.map +1 -0
  305. package/dist/views-DtRhj2Tn.js +2 -0
  306. package/dist/{worker-entry-D5dB8cgT.js → worker-entry-BIROTPX1.js} +11 -8
  307. package/dist/{worker-entry-D5dB8cgT.js.map → worker-entry-BIROTPX1.js.map} +1 -1
  308. package/dist/workspace-CcQRT31C.js +1 -0
  309. package/dist/{workspace-Cho30qlM.js → workspace-uuE51x35.js} +7 -7
  310. package/dist/{workspace-Cho30qlM.js.map → workspace-uuE51x35.js.map} +1 -1
  311. package/package.json +26 -11
  312. package/skills/eval-rubric/SKILL.md +31 -4
  313. package/dist/adapter-DyvDj4ZN.js.map +0 -1
  314. package/dist/app-files-hpRT5lj_.js.map +0 -1
  315. package/dist/assemble-DTXwCL3m.js +0 -1
  316. package/dist/assemble-Dlh6Xv3U.js.map +0 -1
  317. package/dist/capture-BT2fAmpZ.js +0 -1
  318. package/dist/capture-Bdcx9Gap.js.map +0 -1
  319. package/dist/cli-CGd51thd.js.map +0 -1
  320. package/dist/cli-spec-ChkleEVm.js.map +0 -1
  321. package/dist/client-CF-DOjOU.js.map +0 -1
  322. package/dist/command-CsfcwMyc.js.map +0 -1
  323. package/dist/command-CyIb9BSC.js.map +0 -1
  324. package/dist/command-TLmY-rYp.js.map +0 -1
  325. package/dist/commands-C54S45d7.js.map +0 -1
  326. package/dist/config-ImY6AlRE.js.map +0 -1
  327. package/dist/context-BajfiH0S.js.map +0 -1
  328. package/dist/contrasts-DtSX8E_V.js +0 -101
  329. package/dist/contrasts-DtSX8E_V.js.map +0 -1
  330. package/dist/cost-CMzY9VXv.js +0 -1
  331. package/dist/db-ZIk6S2CD.js +0 -2
  332. package/dist/db-sHGpaLo9.js.map +0 -1
  333. package/dist/debug-BnXV7JbX.js +0 -1
  334. package/dist/default-effort-BZRa-SQP.js.map +0 -1
  335. package/dist/dist-ByYk_wAs.js.map +0 -1
  336. package/dist/docker--2ytOHcu.js.map +0 -1
  337. package/dist/doctor-eE65YpEv.js.map +0 -1
  338. package/dist/environment-Cy3FVLR5.js.map +0 -1
  339. package/dist/eval-source-BTsTRiBW.js.map +0 -1
  340. package/dist/evaluate-CFFdyYZX.js.map +0 -1
  341. package/dist/evaluate-DnGOaGQc.d.ts +0 -43
  342. package/dist/files-B3d-8Fe0.js +0 -1
  343. package/dist/files-COW5JBJM.js +0 -1
  344. package/dist/files-Do4Rp3yZ.js +0 -1
  345. package/dist/files-p-uTdOjA.js.map +0 -1
  346. package/dist/gate-BoDKeuJu.js.map +0 -1
  347. package/dist/harness-Ch2P81sx.js.map +0 -1
  348. package/dist/ids-DuK6xl4w.js.map +0 -1
  349. package/dist/images-BVZHDf_z.js.map +0 -1
  350. package/dist/init-BWnMbUnc.js.map +0 -1
  351. package/dist/init-s1jN-PCI.js +0 -1
  352. package/dist/judge-ByEUlzOM.js.map +0 -1
  353. package/dist/live-DmJix4c8.js +0 -1
  354. package/dist/live-d_5a5iUv.js.map +0 -1
  355. package/dist/model-8uZBYqV5.js +0 -1
  356. package/dist/model-DOiCiMCD.js.map +0 -1
  357. package/dist/node-CwP1G178.js.map +0 -1
  358. package/dist/opencode-providers-yNKyXD49.js.map +0 -1
  359. package/dist/plan-CIfOFhth.js.map +0 -1
  360. package/dist/plugins-BEs2Am3L.js.map +0 -1
  361. package/dist/preflight-50Qw5e5K.js.map +0 -1
  362. package/dist/provenance-Cc8fFE7Z.js.map +0 -1
  363. package/dist/provider-DCdTHQpk.js +0 -1
  364. package/dist/providers-CP_bBtYm.js +0 -1
  365. package/dist/providers-DZSTlC9R.js.map +0 -1
  366. package/dist/query-kFPuqBv1.js +0 -1
  367. package/dist/questions-C_Y-oXW6.js.map +0 -1
  368. package/dist/record-DhzwkSXc.js.map +0 -1
  369. package/dist/redact-BEEGc37e.js.map +0 -1
  370. package/dist/remarks-0EXMh6AD.js.map +0 -1
  371. package/dist/remarks-BL18Id09.js +0 -1
  372. package/dist/remarks-DeZZT8PK.js +0 -116
  373. package/dist/remarks-DeZZT8PK.js.map +0 -1
  374. package/dist/remarks-E4rpi8Ym.js.map +0 -1
  375. package/dist/resolve-BJSay360.js +0 -1
  376. package/dist/resolve-B_JlQ0La.js.map +0 -1
  377. package/dist/resume-CexsWuGK.js +0 -434
  378. package/dist/resume-CexsWuGK.js.map +0 -1
  379. package/dist/runtime-CSZ1hjlN.js.map +0 -1
  380. package/dist/sandbox-B5W8lLL1.js.map +0 -1
  381. package/dist/server-SBzrf35T.js +0 -1
  382. package/dist/shared-ogqPJ0uo.js.map +0 -1
  383. package/dist/source-Dn1uqPon.js +0 -1
  384. package/dist/src-BKDZO3ra.js +0 -2
  385. package/dist/src-BxrHipV0.js +0 -3
  386. package/dist/src-C9elednc.js +0 -2
  387. package/dist/src-CM7xdJFA.js +0 -2
  388. package/dist/src-CWEGknZo.js +0 -2
  389. package/dist/src-Cpy9MNS3.js.map +0 -1
  390. package/dist/src-DVaAKCsH.js +0 -1
  391. package/dist/src-DurP--_D.js +0 -2
  392. package/dist/state-Cicc9Oa5.js +0 -1
  393. package/dist/stats-D-Gqwqt0.js.map +0 -1
  394. package/dist/suite-BYJ2Q0S-.js +0 -2
  395. package/dist/suite-BtHPBFYL.js +0 -544
  396. package/dist/suite-BtHPBFYL.js.map +0 -1
  397. package/dist/summary-zP3cCXDN.js.map +0 -1
  398. package/dist/types-C4OkYhZg.js.map +0 -1
  399. package/dist/vertex-6uSpZ5L8.js.map +0 -1
  400. package/dist/vertex-BaAz44YN.js +0 -1
  401. package/dist/views-CKoN5NAx.js.map +0 -1
  402. package/dist/views-CmyX255j.js +0 -2
  403. package/dist/workspace-Dw9DEZox.js +0 -1
@@ -1,26 +1,26 @@
1
- import { n as isOneOf } from "./object-CeQ8dgUC.js";
2
1
  import { n as UsageError } from "./errors-ttMTnIYX.js";
3
- import { c as jsonValueSchema, h as parseDuration, i as durationSchema, m as TIMER_LIMIT, n as dataProblem, p as MAX_TIMER_MS } from "./shared-ogqPJ0uo.js";
4
- import { x as gatewayNameSchema } from "./harness-Ch2P81sx.js";
5
- import { l as sha256 } from "./ids-DuK6xl4w.js";
6
- import { Ht as turnsSchema, It as fakeJudgeDataSchema, Nt as captureWindowSchema, Rt as judgeFields, Vt as sharedInputFields, b as resolveModelGateway, ct as awaitListening, lt as parseProbe, ut as probeScript, v as gatewayScope, zt as judgeModelNameSchema } from "./config-ImY6AlRE.js";
7
- import { y as vertexSettingsIn } from "./vertex-6uSpZ5L8.js";
8
- import { d as redactJson, m as redactSecrets } from "./redact-BEEGc37e.js";
9
- import { a as plural, i as formatDuration, n as clip } from "./text-D--Q5KsA.js";
10
- import { s as cacheDir } from "./root-Co0jhOT5.js";
11
- import { mt as shellQuote } from "./src-Cpy9MNS3.js";
12
- import { t as InfraError } from "./types-C4OkYhZg.js";
13
- import { r as getRunContext, s as SUBJECT } from "./runtime-CSZ1hjlN.js";
14
- import { i as debugTrace, r as debugLog } from "./attempt-CtKGvaQR.js";
15
- import { r as openRouterFallbacks } from "./openrouter-models-C8nzPKG2.js";
16
- import { i as hostModel } from "./model-DBpdRXtO.js";
2
+ import { g as parseDuration } from "./shared-Cfi45Bvy.js";
3
+ import { n as isOneOf } from "./object-CeQ8dgUC.js";
4
+ import { a as plural, i as formatDuration, n as clip } from "./text-B8-W3Cvn.js";
17
5
  import { t as addUsage } from "./usage-DJiDnh2D.js";
18
- import { t as untraced } from "./docker-CWuSRj7a.js";
6
+ import { _ as probeScript, g as parseProbe, h as hostListening, m as awaitListening, n as capabilitiesOf, v as servePort } from "./kinds-C1oY3qyC.js";
7
+ import { c as sha256 } from "./ids-C_advdJA.js";
8
+ import { At as execOptionsProblem, Dt as CAPTURE_NAME, Ot as CAPTURE_NAME_RULE, b as resolveModelGateway, v as gatewayScope } from "./config-B9mB1kF5.js";
9
+ import { y as vertexSettingsIn } from "./vertex-Eb2wqahk.js";
10
+ import { f as redactJson, h as redactSecrets } from "./redact-BhjtnjrU.js";
11
+ import { s as cacheDir } from "./root-Co0jhOT5.js";
12
+ import { yt as shellQuote } from "./src-Ck2r_EMT.js";
13
+ import { t as InfraError } from "./types-C2mLpph3.js";
14
+ import { r as getRunContext, s as SUBJECT } from "./runtime-BpW1f1Mx.js";
15
+ import { i as debugTrace, r as debugLog } from "./attempt-CAdlwlNu.js";
16
+ import { r as openRouterFallbacks } from "./openrouter-models-Cw1z8-sq.js";
17
+ import { i as hostModel } from "./model-DJjLw-0r.js";
18
+ import { t as untraced } from "./docker-Cqw-CyWz.js";
19
19
  import { n as pageLines } from "./capture-DMBZE9cs.js";
20
+ import { z } from "zod";
20
21
  import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
21
22
  import { homedir, tmpdir } from "node:os";
22
23
  import { join, posix } from "node:path";
23
- import { z } from "zod";
24
24
  import net, { createServer } from "node:net";
25
25
  import { createHash, randomUUID } from "node:crypto";
26
26
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
@@ -29,521 +29,6 @@ import http from "node:http";
29
29
  import { crc32, deflateSync, inflateRawSync, inflateSync } from "node:zlib";
30
30
  import { mkdir, writeFile } from "node:fs/promises";
31
31
  import { generateText, stepCountIs, tool } from "ai";
32
- // src/contract/attempt.ts
33
- const nullableNumber = z.number().nullable();
34
- const tokenUsageSchema = z.strictObject({
35
- input: z.number(),
36
- output: z.number(),
37
- cacheRead: z.number(),
38
- cacheWrite: z.number(),
39
- reasoning: nullableNumber
40
- });
41
- const fileChangeSchema = z.strictObject({
42
- path: z.string(),
43
- status: z.enum([
44
- "added",
45
- "modified",
46
- "deleted"
47
- ])
48
- });
49
- const diffSchema = z.strictObject({
50
- patch: z.string(),
51
- files: z.array(fileChangeSchema)
52
- });
53
- const turnStatusSchema = z.enum([
54
- "completed",
55
- "aborted",
56
- "error"
57
- ]);
58
- const webEventTypeSchema = z.enum(["web-search", "web-fetch"]);
59
- const at = {
60
- ts: z.string(),
61
- atMs: z.number()
62
- };
63
- const transcriptEventSchema = z.discriminatedUnion("type", [
64
- z.strictObject({
65
- ...at,
66
- type: z.enum(["text", "reasoning"]),
67
- text: z.string(),
68
- durationMs: nullableNumber
69
- }),
70
- z.strictObject({
71
- ...at,
72
- type: z.literal("file-edit"),
73
- toolCallId: z.string(),
74
- path: z.string(),
75
- kind: z.enum([
76
- "create",
77
- "modify",
78
- "write",
79
- "delete"
80
- ]),
81
- added: nullableNumber,
82
- removed: nullableNumber,
83
- durationMs: nullableNumber,
84
- stalled: z.boolean().optional(),
85
- subagent: z.string().optional()
86
- }),
87
- z.strictObject({
88
- ...at,
89
- type: z.literal("web-search"),
90
- toolCallId: z.string(),
91
- query: z.string(),
92
- references: nullableNumber,
93
- ok: z.boolean().nullable().optional(),
94
- durationMs: nullableNumber,
95
- stalled: z.boolean().optional(),
96
- subagent: z.string().optional()
97
- }),
98
- z.strictObject({
99
- ...at,
100
- type: z.literal("web-fetch"),
101
- toolCallId: z.string(),
102
- url: z.string(),
103
- ok: z.boolean().nullable(),
104
- durationMs: nullableNumber,
105
- stalled: z.boolean().optional(),
106
- subagent: z.string().optional()
107
- }),
108
- z.strictObject({
109
- ...at,
110
- type: z.literal("tool"),
111
- toolCallId: z.string(),
112
- tool: z.string(),
113
- input: z.unknown(),
114
- output: z.unknown(),
115
- ok: z.boolean().nullable(),
116
- durationMs: nullableNumber,
117
- stalled: z.boolean().optional(),
118
- subagent: z.string().optional()
119
- }),
120
- z.strictObject({
121
- ...at,
122
- type: z.literal("error"),
123
- message: z.string()
124
- }),
125
- z.strictObject({
126
- ...at,
127
- type: z.literal("retry"),
128
- message: z.string()
129
- })
130
- ]);
131
- const turnDataSchema = z.strictObject({
132
- prompt: z.string(),
133
- text: z.string(),
134
- status: turnStatusSchema,
135
- startedAt: z.string(),
136
- durationMs: z.number(),
137
- transcript: z.array(transcriptEventSchema),
138
- usage: tokenUsageSchema.nullable(),
139
- model: z.string().nullable(),
140
- unreported: z.array(webEventTypeSchema),
141
- diff: diffSchema
142
- });
143
- const execResultSchema = z.strictObject({
144
- exitCode: z.number().int(),
145
- stdout: z.string(),
146
- stderr: z.string()
147
- });
148
- const execRetrySchema = z.strictObject({
149
- retries: z.number().int("must be a whole number, from 0").min(0, "must be a whole number, from 0").optional(),
150
- interval: z.number().min(0, "must be 0 or more milliseconds").max(MAX_TIMER_MS, `must be ${TIMER_LIMIT}`).optional()
151
- });
152
- /** A background command has no exit for `retries` to wait on. */
153
- const noBackgroundRetry = (options, ctx) => {
154
- if (!options.background) return;
155
- for (const key of ["retries", "interval"]) {
156
- if (options[key] === void 0) continue;
157
- ctx.addIssue({
158
- code: "custom",
159
- path: [key],
160
- message: "can't be used with background: true, whose exit reeval doesn't wait for: drop one of them"
161
- });
162
- }
163
- };
164
- const execOptionsSchema = z.strictObject({
165
- background: z.boolean().optional(),
166
- ...execRetrySchema.shape
167
- }).superRefine(noBackgroundRetry);
168
- /** What's wrong with `c.exec()`'s options, or undefined. */
169
- const execOptionsProblem = (value) => dataProblem(execOptionsSchema, value, "c.exec()", () => Object.keys(execOptionsSchema.shape));
170
- const assertionRecordSchema = z.strictObject({
171
- label: z.string(),
172
- labelled: z.boolean(),
173
- matcher: z.string(),
174
- status: z.enum([
175
- "pass",
176
- "fail",
177
- "error"
178
- ]),
179
- soft: z.boolean(),
180
- at: z.string().optional(),
181
- message: z.string().optional(),
182
- durationMs: z.number().optional()
183
- });
184
- const turnIndex = z.number().int("must be a turn index, from 0").min(0, "must be a turn index, from 0").describe("The turn's index, from 0.");
185
- const captureConsoleMessageSchema = z.strictObject({
186
- level: z.enum([
187
- "error",
188
- "warning",
189
- "info",
190
- "log",
191
- "debug"
192
- ]),
193
- text: z.string(),
194
- source: z.string(),
195
- url: z.string().optional()
196
- });
197
- const captureFailedRequestSchema = z.strictObject({
198
- method: z.string(),
199
- url: z.string(),
200
- status: z.number().optional(),
201
- error: z.string().optional()
202
- });
203
- const capturePageFields = {
204
- status: z.number().optional(),
205
- finalUrl: z.string(),
206
- console: z.array(captureConsoleMessageSchema),
207
- errors: z.array(z.string()),
208
- failedRequests: z.array(captureFailedRequestSchema),
209
- dropped: z.number().optional()
210
- };
211
- z.strictObject(capturePageFields);
212
- const captureSchema = z.strictObject({
213
- name: z.string(),
214
- port: z.number(),
215
- path: z.string(),
216
- viewport: z.union([captureWindowSchema, z.literal("full-page")]),
217
- file: z.strictObject({
218
- path: z.string(),
219
- sha256: z.string(),
220
- bytes: z.number()
221
- }),
222
- ...capturePageFields
223
- });
224
- const judgeArtifactRefSchema = z.strictObject({
225
- name: z.string(),
226
- path: z.string(),
227
- sha256: z.string(),
228
- bytes: z.number(),
229
- mediaType: z.literal("image/png")
230
- });
231
- const verdictFields = {
232
- threshold: z.number(),
233
- question: z.string(),
234
- model: z.string(),
235
- gateway: gatewayNameSchema.optional(),
236
- artifacts: z.array(judgeArtifactRefSchema).optional()
237
- };
238
- const verdictSchema = z.strictObject({
239
- verdict: z.enum(["pass", "fail"]),
240
- score: z.number(),
241
- ...verdictFields,
242
- resolvedModel: z.string().optional(),
243
- upstream: z.string().optional(),
244
- costUsd: z.number().optional()
245
- });
246
- const judgeFailureSchema = z.strictObject({
247
- verdict: z.literal("error"),
248
- score: z.null(),
249
- ...verdictFields,
250
- error: z.string()
251
- });
252
- /** A pattern, for the matchers that take a string or a `RegExp`. */
253
- const patternSchema = z.strictObject({
254
- regexp: z.string().describe("The pattern's source, as `RegExp.prototype.source` gives it."),
255
- flags: z.string().regex(/^[dgimsuvy]*$/, "must use only the flags d, g, i, m, s, u, v and y").optional().describe("Its flags, e.g. `i`.")
256
- }).describe("A regular expression, where a matcher takes a string or a `RegExp`.");
257
- /** A pattern in the runner's own language, which reeval never compiles. */
258
- function hasAnsweredPattern(value) {
259
- if (Array.isArray(value)) return value.some(hasAnsweredPattern);
260
- if (typeof value !== "object" || value === null) return false;
261
- return "matchedBy" in value || Object.values(value).some(hasAnsweredPattern);
262
- }
263
- const answeredPatternSchema = z.strictObject({
264
- matchedBy: z.string().regex(/\S/).describe("The pattern as the runner's language writes it, e.g. `re.compile('npm t')`."),
265
- answers: z.record(z.string(), z.boolean()).describe("Whether it matches each string the runner has been asked about.")
266
- }).describe("A pattern the runner matches in its own language. reeval runs the matcher with it, and when the matcher tests a string not in `answers` replies with those strings (`untested`) instead of a record; the runner matches them and makes the call again with them in `answers`.");
267
- const isPatternLike = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && "regexp" in value;
268
- const matcherArgSchema = z.union([
269
- patternSchema,
270
- answeredPatternSchema,
271
- jsonValueSchema
272
- ]).superRefine((value, ctx) => {
273
- if (!isPatternLike(value)) return;
274
- for (const issue of patternSchema.safeParse(value).error?.issues ?? []) ctx.addIssue(issue);
275
- }).describe("One argument to a matcher: a JSON value, a regular expression as `{ regexp, flags? }`, or a pattern in the runner's own language as `{ matchedBy, answers }`.");
276
- const matcherSubjectSchema = z.union([
277
- z.strictObject({ turn: turnIndex }),
278
- z.strictObject({ attempt: z.literal(true).describe("The attempt itself, `c`.") }),
279
- z.strictObject({ value: jsonValueSchema.describe("A value the eval passes as it is.") }),
280
- z.strictObject({
281
- exec: z.string().regex(/\S/).describe("A command reeval runs, for its `ExecResult`; again on each try when polled."),
282
- result: execResultSchema.optional().describe("The command's `ExecResult` when the runner already ran it: reeval checks that instead of running it again, and the check is still named by the command.")
283
- }),
284
- z.strictObject({ readFile: z.string().regex(/\S/).describe("A file reeval reads, for its contents (null when there's none).") })
285
- ]).describe("What `expect` was given: a turn `c.send` returned, the attempt (for its files and latest turn), a value, such as an `ExecResult`, or a command or file reeval reads for it.");
286
- const nonEmpty = z.string().regex(/\S/, "must not be empty");
287
- const CAPTURE_NAME = new RegExp(`^[a-z0-9][a-z0-9_-]{0,99}$`);
288
- const CAPTURE_NAME_RULE = `must be 1 to 100 of a-z, 0-9, _ and -, starting with a letter or digit`;
289
- const portSchema = z.number().int().min(1, "a port from 1 to 65535").max(65535, "a port from 1 to 65535");
290
- const millisSchema = z.number().positive("more than zero milliseconds").max(MAX_TIMER_MS, TIMER_LIMIT);
291
- const captureWaitSchema = z.enum(["load", "idle"]);
292
- const waitSchema = z.union([captureWaitSchema, z.strictObject({ ms: millisSchema })]);
293
- const captureInstructionSchema = z.union([nonEmpty, z.strictObject({ wait: waitSchema })]);
294
- const captureCallDataSchema = z.strictObject({
295
- name: z.string().regex(CAPTURE_NAME, CAPTURE_NAME_RULE).optional(),
296
- path: z.string().optional(),
297
- viewport: z.union([captureWindowSchema, z.literal("full-page")]).optional(),
298
- timeout: durationSchema.optional(),
299
- wait: waitSchema.optional(),
300
- instructions: z.array(captureInstructionSchema).optional().describe("Journey: goal strings and `{ wait }` beats, run by the vision model."),
301
- model: z.string().optional()
302
- }).describe("`c.capture()`'s camera and path as data. Default `path` is `/`; default `name` is derived from the path. A test's `fakeInstructions` journey is TypeScript-only.");
303
- const handleId = nonEmpty.describe("A background process, as an exec or serve reply named it.");
304
- const judgeOnSchema = z.union([z.strictObject({ turn: turnIndex }), z.strictObject({ value: jsonValueSchema.describe("Graded as the output.") })]);
305
- const judgeCallDataSchema = z.strictObject({
306
- model: z.union([judgeModelNameSchema, fakeJudgeDataSchema]).optional().describe("`'provider/model'`, or a fake judge with a numeric score."),
307
- ...judgeFields,
308
- ...sharedInputFields,
309
- contents: z.array(nonEmpty).optional(),
310
- turns: turnsSchema.optional(),
311
- on: judgeOnSchema.optional().describe("The turn `task`, `output`, `transcript` and `diff` read instead of the latest: an earlier turn, or a value graded as the output."),
312
- artifacts: z.union([z.literal(true), z.array(z.union([nonEmpty, captureSchema]))]).optional().describe("Captures this call sends the judge as image file parts: a capture `c.capture` returned, or its name, or `true` for every capture so far. The provider that cannot take files fails the call.")
313
- }).describe("`c.judge()`'s options as data: the judge options, with the model by name or a fake judge's numeric score, the inputs it shows the judge (at least one turned on) and `on`.");
314
- const callSiteSchema = z.strictObject({
315
- file: nonEmpty.describe("The eval file: absolute, or relative to the project root."),
316
- line: z.number().int().min(1).describe("From 1.")
317
- }).describe("Where the eval made the call, which the record names beside the check's outcome.");
318
- const attemptCallSchema = z.discriminatedUnion("op", [
319
- z.strictObject({
320
- op: z.literal("send"),
321
- prompt: z.string().describe("The turn's prompt.")
322
- }).describe("`c.send(prompt)`: the next turn of the agent session. Replies with a turn."),
323
- z.strictObject({
324
- op: z.literal("exec"),
325
- command: nonEmpty.describe("A shell command, run in the workspace."),
326
- background: z.boolean().optional().describe("Leave it running and reply with its handle, not its output."),
327
- ...execRetrySchema.shape
328
- }).superRefine(noBackgroundRetry).describe("`c.exec(command, { background?, retries?, interval? })`: a command in the sandbox. Replies with its exit code and output (the last try, with `retries`), or with a handle when it runs in the background."),
329
- z.strictObject({
330
- op: z.literal("serve"),
331
- command: nonEmpty.describe("A shell command; `PORT` is set to the port."),
332
- port: portSchema.optional().describe("The container port. Omit it and reeval allocates one.")
333
- }).describe("`c.serve(command, port?)`: a background process, once it listens, and its port."),
334
- z.strictObject({
335
- op: z.literal("kill"),
336
- handle: handleId
337
- }).describe("`handle.kill()`: stops a background process. Killing one that's gone is fine."),
338
- z.strictObject({
339
- op: z.literal("capture"),
340
- target: z.union([z.strictObject({ port: portSchema }), z.strictObject({ handle: handleId })]).describe("A container port, or a serve handle by its id."),
341
- options: captureCallDataSchema.optional()
342
- }).describe("`c.capture(target, options)`: screenshots a path on a tunneled sandbox port and writes `artifacts/<name>.png`. Replies with the capture."),
343
- z.strictObject({
344
- op: z.literal("readFile"),
345
- path: nonEmpty.describe("Workspace-relative, or `~/` for the home directory.")
346
- }).describe("`c.readFile(path)`. Replies with its contents, or null when there is no such file."),
347
- z.strictObject({
348
- op: z.literal("writeFile"),
349
- path: nonEmpty.describe("Workspace-relative, or `~/` for the home directory."),
350
- contents: z.string().describe("The file's contents, in `encoding`."),
351
- encoding: z.enum(["utf8", "base64"]).optional().describe("How `contents` is encoded; base64 carries bytes. Default `utf8`.")
352
- }).describe("`c.writeFile(path, contents)`, creating its directories."),
353
- z.strictObject({
354
- op: z.literal("expect"),
355
- subject: matcherSubjectSchema,
356
- matcher: z.string().regex(/^[a-z][A-Za-z]*$/, "must be a matcher name such as toHaveFile, without \"not.\" (set not: true instead)").describe("The matcher's name, e.g. `toHaveFile` or `toBe`, without `not.`."),
357
- args: z.array(matcherArgSchema).describe("The matcher's arguments."),
358
- not: z.boolean().describe("Called as `expect(…).not`."),
359
- soft: z.boolean().describe("Called as `expect`: a failure fails the attempt at its end and the body carries on. False for `expect.require`, whose failure the runner raises, ending the body."),
360
- label: z.string().optional().describe("`expect`'s second argument."),
361
- at: callSiteSchema.optional(),
362
- poll: z.strictObject({
363
- interval: millisSchema.optional().describe("Milliseconds between tries. Default 50."),
364
- timeout: millisSchema.optional().describe("Milliseconds before it fails with the last error. Default 1000.")
365
- }).optional().describe("`expect.poll`: reeval re-reads the subject and retries the matcher until it passes, recording only the final outcome. The subject must be one reeval can re-read: the attempt, a command or a file.")
366
- }).superRefine((call, ctx) => {
367
- if (call.poll && "value" in call.subject) ctx.addIssue({
368
- code: "custom",
369
- path: ["subject"],
370
- message: "can't be polled: reeval can't re-read a value. Poll the attempt, an exec or a readFile"
371
- });
372
- if (call.poll && "exec" in call.subject && call.subject.result) ctx.addIssue({
373
- code: "custom",
374
- path: ["subject", "result"],
375
- message: "can't be polled: drop result so reeval runs the command on each try"
376
- });
377
- if (call.poll && call.args.some(hasAnsweredPattern)) ctx.addIssue({
378
- code: "custom",
379
- path: ["args"],
380
- message: "can't be polled with a { matchedBy } pattern, whose answers can't follow the subject from try to try: poll with a string, or check once"
381
- });
382
- }).describe("A matcher call: `expect(subject, label).not?.matcher(...args)`. Replies with its record."),
383
- z.strictObject({
384
- op: z.literal("record"),
385
- matcher: z.string().regex(/^[a-z][A-Za-z]*$/, "must be a name such as assert").describe("What made the check in the eval's language, e.g. `assert`."),
386
- subject: z.string().optional().describe("What it checked, as the eval wrote it (`result.ok`): names the check when it has no label."),
387
- label: z.string().optional().describe("The check's own name, the same whether it passes or fails."),
388
- status: z.enum(["pass", "fail"]),
389
- message: z.string().optional().describe("Why it failed."),
390
- soft: z.boolean().optional().describe("The body carried on after a failure, as after an `expect`. Default false: the check raised, as Python's `assert` does."),
391
- at: callSiteSchema.optional()
392
- }).describe("A check the eval's own language made, such as Python's `assert`: recorded as a matcher call is, so it's named, counted and compared the same. Replies with its record."),
393
- z.strictObject({
394
- op: z.literal("judge"),
395
- question: nonEmpty.describe("A yes/no question about the inputs `options` turns on."),
396
- options: judgeCallDataSchema
397
- }).describe("`c.judge(question, options)`. Replies with its verdict, or a judge failure when the provider failed.")
398
- ]).describe("One call an eval's body makes on its attempt. The sandbox and the agent session start on the first call that needs them; there's no call to start them.");
399
- const attemptErrorSchema = z.looseObject({
400
- name: z.string().describe("The error's class, e.g. `UsageError` or `AssertionError`."),
401
- message: z.string()
402
- }).describe("Why a call failed, in reeval's words.");
403
- const id = nonEmpty.describe("Pairs a reply with its request.");
404
- const attemptRequestSchema = z.strictObject({
405
- id,
406
- call: attemptCallSchema
407
- }).describe("A call, numbered so its reply can find it.");
408
- z.union([
409
- z.discriminatedUnion("op", [
410
- z.strictObject({
411
- id,
412
- ok: z.literal(true),
413
- op: z.literal("send"),
414
- turn: turnDataSchema
415
- }),
416
- z.strictObject({
417
- id,
418
- ok: z.literal(true),
419
- op: z.literal("exec"),
420
- result: z.union([execResultSchema, z.strictObject({ handle: handleId }).describe("A background process, still running.")])
421
- }),
422
- z.strictObject({
423
- id,
424
- ok: z.literal(true),
425
- op: z.literal("serve"),
426
- handle: handleId,
427
- port: z.number().describe("The container port it listens on.")
428
- }),
429
- z.strictObject({
430
- id,
431
- ok: z.literal(true),
432
- op: z.literal("kill")
433
- }),
434
- z.strictObject({
435
- id,
436
- ok: z.literal(true),
437
- op: z.literal("capture"),
438
- capture: captureSchema
439
- }),
440
- z.strictObject({
441
- id,
442
- ok: z.literal(true),
443
- op: z.literal("readFile"),
444
- contents: z.string().nullable().describe("Null when there is no such file.")
445
- }),
446
- z.strictObject({
447
- id,
448
- ok: z.literal(true),
449
- op: z.literal("writeFile")
450
- }),
451
- z.strictObject({
452
- id,
453
- ok: z.literal(true),
454
- op: z.literal("expect"),
455
- assertion: assertionRecordSchema
456
- }),
457
- z.strictObject({
458
- id,
459
- ok: z.literal(true),
460
- op: z.literal("record"),
461
- assertion: assertionRecordSchema
462
- }),
463
- z.strictObject({
464
- id,
465
- ok: z.literal(true),
466
- op: z.literal("judge"),
467
- verdict: z.union([verdictSchema, judgeFailureSchema])
468
- })
469
- ]),
470
- z.strictObject({
471
- id,
472
- ok: z.literal(true),
473
- op: z.literal("expect"),
474
- untested: z.record(z.string(), z.array(z.string())).describe("The strings the matcher tested that a `{ matchedBy, answers }` argument has no answer for, by its `matchedBy`. Nothing was recorded: answer them and make the call again.")
475
- }),
476
- z.strictObject({
477
- id,
478
- ok: z.literal(false),
479
- op: z.enum([
480
- "send",
481
- "exec",
482
- "readFile",
483
- "writeFile",
484
- "expect",
485
- "record",
486
- "judge",
487
- "serve",
488
- "kill",
489
- "capture"
490
- ]),
491
- error: attemptErrorSchema
492
- })
493
- ]).describe("reeval's reply to a call: its result, or the error it threw. A failed matcher is a result (its record says `fail`), not an error, unless the matcher couldn't run.");
494
- const cellRoleSchema = z.enum(["control", "variant"]);
495
- const cellSchema = z.strictObject({
496
- key: z.string(),
497
- harness: z.string(),
498
- environment: z.string(),
499
- sandbox: z.string(),
500
- role: cellRoleSchema,
501
- variant: z.string().optional()
502
- });
503
- z.strictObject({
504
- type: z.literal("start"),
505
- attempt: z.strictObject({
506
- id: nonEmpty,
507
- cell: cellSchema,
508
- n: z.number().int().min(1, "a run number, from 1").describe("The run number, from 1.")
509
- }).describe("`c.attempt`: which cell of the matrix this attempt is, and its run number."),
510
- file: nonEmpty.describe("The eval file, relative to the project."),
511
- body: nonEmpty.describe("The eval's `body`, as its declaration named it.")
512
- }).describe("reeval to the runner: run this eval's body for this attempt. Nothing has started yet: the sandbox and the agent session start on the body's first call that needs them, so its own code runs first. The runner sends its calls, then `done`.");
513
- z.strictObject({
514
- type: z.literal("abort"),
515
- reason: z.enum(["timeout", "canceled"]).describe("`timeout`: the eval's `timeout` ran out. `canceled`: the run was stopped."),
516
- message: z.string().describe("reeval's sentence, e.g. `Eval timed out after 600s`.")
517
- }).describe("reeval to the runner: the attempt was aborted, as `c.signal` aborts. Calls in flight reply with errors; the runner should stop the body and send `done`.");
518
- z.strictObject({
519
- type: z.literal("done"),
520
- error: attemptErrorSchema.optional().describe("What the body threw, if it threw. A failed `expect.require` is one.")
521
- }).describe("The runner to reeval: the eval's body has finished. The attempt's checks and record follow.");
522
- const CALL_KEYS = Object.fromEntries(attemptCallSchema.options.map((o) => [o.shape.op.value, Object.keys(o.shape)]));
523
- const OTHER_KEYS = [
524
- "id",
525
- "call",
526
- "turn",
527
- "attempt",
528
- "value",
529
- "regexp",
530
- "flags",
531
- "matchedBy",
532
- "answers",
533
- ...Object.keys(judgeCallDataSchema.shape),
534
- ...Object.keys(captureSchema.shape),
535
- ...Object.keys(captureCallDataSchema.shape),
536
- "port",
537
- "handle",
538
- "exec",
539
- "result",
540
- "readFile",
541
- "interval",
542
- "timeout",
543
- "ms"
544
- ];
545
- /** What's wrong with an attempt request a runner sent, by the field's path, or undefined. */
546
- const attemptRequestProblem = (value) => dataProblem(attemptRequestSchema, value, "The attempt request", (object) => typeof object.op === "string" ? CALL_KEYS[object.op] ?? [] : OTHER_KEYS);
547
32
  // src/capture/fake-instructions.ts
548
33
  const FAKE_INSTRUCTIONS = Symbol.for("reeval.capture.fakeInstructions");
549
34
  function isWaitStep(step) {
@@ -788,10 +273,13 @@ async function waitForPage(cdp, wait, timeoutMs, nav) {
788
273
  await page.ready(nav, timeoutMs);
789
274
  }
790
275
  const clamp = (n, lo, hi) => Math.min(hi, Math.max(lo, n));
791
- /** Map a full-page click onto the live window, scrolling with the wheel if needed. */
276
+ /**
277
+ * Map a full-page point onto the live window, scrolled to `scrollY`. A point already in the window
278
+ * is left where it is; any other is scrolled to the window's middle with the wheel.
279
+ */
792
280
  function mapPagePoint(x, y, window, page, scrollY) {
793
- const maxY = Math.max(0, (page?.height ?? window.height) - window.height);
794
- const target = y >= window.height || y < 0 ? clamp(y - window.height / 2, 0, maxY) : scrollY;
281
+ const maxY = Math.max(0, (page?.height ?? window.height) - window.height, scrollY);
282
+ const target = y >= scrollY && y < scrollY + window.height ? scrollY : clamp(y - window.height / 2, 0, maxY);
795
283
  const nextY = clamp(target, 0, maxY);
796
284
  return {
797
285
  x: clamp(x, 0, window.width - 1),
@@ -862,7 +350,7 @@ async function pressKey(cdp, event) {
862
350
  ...up
863
351
  });
864
352
  }
865
- async function dispatchInput(cdp, action, window, page, scrollY = 0) {
353
+ async function dispatchInput(cdp, action, window, page, scrollY = 0, keyed = false) {
866
354
  if (action.type === "done") return scrollY;
867
355
  if (action.type === "type") {
868
356
  if (action.replace) {
@@ -875,7 +363,13 @@ async function dispatchInput(cdp, action, window, page, scrollY = 0) {
875
363
  });
876
364
  if (!action.text) await pressKey(cdp, KEYS.Backspace);
877
365
  }
878
- if (action.text) await cdp.send("Input.insertText", { text: action.text });
366
+ if (action.text && keyed) for (const text of action.text) await pressKey(cdp, {
367
+ key: text,
368
+ code: "",
369
+ windowsVirtualKeyCode: 0,
370
+ text
371
+ });
372
+ else if (action.text) await cdp.send("Input.insertText", { text: action.text });
879
373
  return scrollY;
880
374
  }
881
375
  if (action.type === "key") {
@@ -887,12 +381,13 @@ async function dispatchInput(cdp, action, window, page, scrollY = 0) {
887
381
  if (action.type === "scroll") {
888
382
  await cdp.send("Input.dispatchMouseEvent", {
889
383
  type: "mouseWheel",
890
- x: action.x,
891
- y: action.y,
384
+ x: clamp(action.x, 0, window.width - 1),
385
+ y: clamp(action.y - scrollY, 0, window.height - 1),
892
386
  deltaX: 0,
893
387
  deltaY: action.dy
894
388
  });
895
- return scrollY + action.dy;
389
+ const maxY = Math.max(0, (page?.height ?? window.height) - window.height);
390
+ return clamp(scrollY + action.dy, 0, Math.max(maxY, scrollY));
896
391
  }
897
392
  const mapped = mapPagePoint(action.type === "drag" ? action.x : action.x, action.type === "drag" ? action.y : action.y, window, page, scrollY);
898
393
  if (mapped.dy !== 0) await cdp.send("Input.dispatchMouseEvent", {
@@ -1028,10 +523,12 @@ function requestId(msg) {
1028
523
  */
1029
524
  function trackNetwork(cdp, quietMs = 500) {
1030
525
  const inFlight = /* @__PURE__ */ new Map();
526
+ let started = 0;
1031
527
  let changed;
1032
528
  cdp.on("Network.requestWillBeSent", (msg) => {
1033
529
  const id = requestId(msg);
1034
530
  if (id === void 0) return;
531
+ started++;
1035
532
  inFlight.set(id, Date.now());
1036
533
  changed?.();
1037
534
  });
@@ -1043,6 +540,8 @@ function trackNetwork(cdp, quietMs = 500) {
1043
540
  cdp.on("Network.loadingFinished", end);
1044
541
  cdp.on("Network.loadingFailed", end);
1045
542
  return {
543
+ started: () => started,
544
+ pending: () => inFlight.size > 0,
1046
545
  /** A request started in the last `FRESH_REQUEST_MS` is still in flight; a long poll is not fresh. */
1047
546
  fresh() {
1048
547
  const since = Date.now() - FRESH_REQUEST_MS;
@@ -1273,7 +772,7 @@ function waitForPortFile(file, timeoutMs, signal) {
1273
772
  });
1274
773
  }
1275
774
  function pickPageDebuggerUrl(targets) {
1276
- return targets.find((t) => t.webSocketDebuggerUrl && t.type !== "browser")?.webSocketDebuggerUrl;
775
+ return targets.find((t) => t.webSocketDebuggerUrl && t.type === "page")?.webSocketDebuggerUrl;
1277
776
  }
1278
777
  async function pageDebuggerUrl(port, timeoutMs) {
1279
778
  const deadline = Date.now() + timeoutMs;
@@ -1363,6 +862,70 @@ async function disposeChrome(child, userData) {
1363
862
  } catch {}
1364
863
  removeChromeProfile(userData);
1365
864
  }
865
+ /** Clipped text the page controls, in the words the model reads. */
866
+ const TARGET_CAP = 40;
867
+ const targetAt = (x, y) => `(() => {
868
+ const clip = (s) => String(s ?? '').replace(/\\s+/g, ' ').trim().slice(0, ${TARGET_CAP})
869
+ let e = document.elementFromPoint(${x}, ${y})
870
+ while (e && e.shadowRoot && e.shadowRoot.elementFromPoint) {
871
+ const inner = e.shadowRoot.elementFromPoint(${x}, ${y})
872
+ if (!inner || inner === e) break
873
+ e = inner
874
+ }
875
+ if (!e || e === document.documentElement || e === document.body) return 'the page background'
876
+ const control = e.closest('a,button,input,select,textarea,label,summary,[role],[onclick],[tabindex]') || e
877
+ const tag = control.tagName.toLowerCase()
878
+ const type = tag === 'input' ? '[' + (control.type || 'text') + ']' : ''
879
+ const name = clip(control.getAttribute('aria-label') || control.getAttribute('title') || (control.labels && control.labels[0] && control.labels[0].innerText) || control.getAttribute('placeholder') || (tag === 'input' || tag === 'select' || tag === 'textarea' ? '' : control.innerText) || control.getAttribute('alt'))
880
+ return tag + type + (name ? ' ' + JSON.stringify(name) : '')
881
+ })()`;
882
+ const SEGMENTED_FOCUS = `(() => {
883
+ let a = document.activeElement
884
+ for (;;) {
885
+ if (a && a.shadowRoot && a.shadowRoot.activeElement) { a = a.shadowRoot.activeElement; continue }
886
+ let inner = null
887
+ try { inner = a && a.contentDocument ? a.contentDocument.activeElement : null } catch {}
888
+ if (inner && inner !== a.contentDocument.body) { a = inner; continue }
889
+ break
890
+ }
891
+ return !!a && a.tagName === 'INPUT' && ['date', 'time', 'datetime-local', 'month', 'week'].includes(a.type)
892
+ })()`;
893
+ /** The window's scroll offset and the page's size, from CDP: no script runs in the page. */
894
+ async function readLayout(cdp) {
895
+ const metrics = await cdp.send("Page.getLayoutMetrics").catch(() => void 0);
896
+ const scrollY = metrics?.cssVisualViewport?.pageY;
897
+ const { width, height } = metrics?.cssContentSize ?? {};
898
+ if (typeof scrollY !== "number" || typeof width !== "number" || typeof height !== "number") return;
899
+ return {
900
+ scrollY: Math.round(scrollY),
901
+ width: Math.ceil(width),
902
+ height: Math.ceil(height)
903
+ };
904
+ }
905
+ /** How long a wheel's scroll may stand still before it counts as stopped short. */
906
+ const SCROLL_STILL_MS = 200;
907
+ const SCROLL_CAP_MS = 1500;
908
+ /**
909
+ * The window's offset once a wheel sent from `from` toward `want` has scrolled: the compositor
910
+ * scrolls after `Input.dispatchMouseEvent` returns. A page that stops short (its end, a locked
911
+ * body) stands still, and its offset then is the answer.
912
+ */
913
+ async function scrolledTo(cdp, from, want) {
914
+ const start = Date.now();
915
+ let last = from;
916
+ let still = start;
917
+ for (;;) {
918
+ const y = (await readLayout(cdp))?.scrollY;
919
+ if (y === void 0) return want;
920
+ if (y === want) return y;
921
+ const now = Date.now();
922
+ if (y !== last) {
923
+ last = y;
924
+ still = now;
925
+ } else if (now - still >= SCROLL_STILL_MS || now - start >= SCROLL_CAP_MS) return y;
926
+ await new Promise((resolve) => setTimeout(resolve, 16));
927
+ }
928
+ }
1366
929
  /**
1367
930
  * Chrome's flags for `proxy`: every request goes to it, loopback ones included, which Chrome
1368
931
  * otherwise never proxies.
@@ -1445,11 +1008,12 @@ async function withChrome(bin, window, timeoutMs, options, fn, signal) {
1445
1008
  if (wait === "idle" && !nav) return network.quiet(waitMs);
1446
1009
  return waitForPage(cdp, wait, waitMs, nav);
1447
1010
  },
1448
- async screenshot(fullPage) {
1011
+ async screenshot(fullPage, clip) {
1449
1012
  for (let tries = 1;; tries++) try {
1450
1013
  const shot = await cdp.send("Page.captureScreenshot", {
1451
1014
  format: "png",
1452
- captureBeyondViewport: fullPage
1015
+ captureBeyondViewport: fullPage,
1016
+ ...clip ? { clip } : {}
1453
1017
  });
1454
1018
  if (!shot.data) throw new Error("Page.captureScreenshot returned no data");
1455
1019
  return Buffer.from(shot.data, "base64");
@@ -1458,12 +1022,56 @@ async function withChrome(bin, window, timeoutMs, options, fn, signal) {
1458
1022
  await new Promise((resolve) => setTimeout(resolve, SCREENSHOT_RETRY_MS));
1459
1023
  }
1460
1024
  },
1025
+ async reveal(action, page) {
1026
+ if (action.type !== "click" && action.type !== "hover" && action.type !== "drag") return false;
1027
+ const from = (await readLayout(cdp))?.scrollY ?? scrollY;
1028
+ const at = mapPagePoint(action.x, action.y, window, page, from);
1029
+ if (at.dy === 0) return false;
1030
+ await cdp.send("Input.dispatchMouseEvent", {
1031
+ type: "mouseWheel",
1032
+ x: window.width / 2,
1033
+ y: window.height / 2,
1034
+ deltaX: 0,
1035
+ deltaY: at.dy
1036
+ });
1037
+ scrollY = await scrolledTo(cdp, from, at.scrollY);
1038
+ return scrollY !== from;
1039
+ },
1461
1040
  async dispatch(action, page) {
1462
- scrollY = await dispatchInput(cdp, action, window, page, scrollY);
1041
+ const from = (await readLayout(cdp))?.scrollY ?? scrollY;
1042
+ if (action.type !== "click" && action.type !== "hover" && action.type !== "drag") {
1043
+ const keyed = action.type === "type" && await cdp.send("Runtime.evaluate", {
1044
+ expression: SEGMENTED_FOCUS,
1045
+ returnByValue: true
1046
+ }).then((r) => r.result?.value === true).catch(() => false);
1047
+ scrollY = await dispatchInput(cdp, action, window, page, from, keyed);
1048
+ return { scrolled: false };
1049
+ }
1050
+ const at = mapPagePoint(action.x, action.y, window, page, from);
1051
+ if (at.dy !== 0) await cdp.send("Input.dispatchMouseEvent", {
1052
+ type: "mouseWheel",
1053
+ x: window.width / 2,
1054
+ y: window.height / 2,
1055
+ deltaX: 0,
1056
+ deltaY: at.dy
1057
+ });
1058
+ const after = at.dy !== 0 ? await scrolledTo(cdp, from, at.scrollY) : from;
1059
+ const point = mapPagePoint(action.x, action.y, window, page, after);
1060
+ const target = (await cdp.send("Runtime.evaluate", {
1061
+ expression: targetAt(Math.round(point.x), Math.round(point.y)),
1062
+ returnByValue: true
1063
+ }).catch(() => void 0))?.result?.value;
1064
+ scrollY = await dispatchInput(cdp, action, window, page, after);
1065
+ return {
1066
+ ...typeof target === "string" ? { target } : {},
1067
+ scrolled: after !== from
1068
+ };
1463
1069
  },
1464
- busy() {
1465
- return loading.size > 0 || network.fresh();
1070
+ layout: () => readLayout(cdp),
1071
+ busy(any) {
1072
+ return loading.size > 0 || (any ? network.pending() : network.fresh());
1466
1073
  },
1074
+ requests: () => network.started(),
1467
1075
  dialogs() {
1468
1076
  return opened.splice(0);
1469
1077
  },
@@ -2015,7 +1623,13 @@ const PROBE = `(() => {
2015
1623
  const hash = (s) => { let h = 2166136261; for (let i = 0; i < s.length; i++) { h ^= s.charCodeAt(i); h = Math.imul(h, 16777619) } return (h >>> 0).toString(36) }
2016
1624
  const clip = (s) => String(s ?? '').replace(/\\s+/g, ' ').trim().slice(0, ${TEXT_CAP})
2017
1625
  let a = document.activeElement
2018
- while (a && a.shadowRoot && a.shadowRoot.activeElement) a = a.shadowRoot.activeElement
1626
+ for (;;) {
1627
+ if (a && a.shadowRoot && a.shadowRoot.activeElement) { a = a.shadowRoot.activeElement; continue }
1628
+ let inner = null
1629
+ try { inner = a && a.contentDocument ? a.contentDocument.activeElement : null } catch {}
1630
+ if (inner && inner !== a.contentDocument.body) { a = inner; continue }
1631
+ break
1632
+ }
2019
1633
  if (a === document.body || a === document.documentElement) a = null
2020
1634
  const tag = a ? a.tagName.toLowerCase() : ''
2021
1635
  const type = a && tag === 'input' ? (a.type || 'text') : ''
@@ -2029,7 +1643,9 @@ const PROBE = `(() => {
2029
1643
  : a.isContentEditable ? clip(a.innerText)
2030
1644
  : null
2031
1645
  const buttons = ['button', 'submit', 'reset', 'image', 'file', 'range', 'color', 'hidden']
2032
- const editable = !!a && ((tag === 'input' && !toggles && !buttons.includes(type)) || tag === 'textarea' || a.isContentEditable)
1646
+ // Focus inside a cross-origin frame or a closed shadow root shows only its host, which can't tell.
1647
+ const sealed = !!a && (tag === 'iframe' || tag === 'frame' || (!!a.attachShadow && !a.shadowRoot && tag.includes('-')))
1648
+ const editable = sealed ? null : !!a && ((tag === 'input' && !toggles && !buttons.includes(type)) || tag === 'textarea' || a.isContentEditable)
2033
1649
  const controls = Array.from(document.querySelectorAll('input,select,textarea'))
2034
1650
  .map((e) => (e.type === 'checkbox' || e.type === 'radio' ? (e.checked ? '1' : '0') : e.value))
2035
1651
  return {
@@ -2088,20 +1704,27 @@ function describeChange(after, fields, origin) {
2088
1704
  /**
2089
1705
  * Waits for the page to stop changing after a move: two reads `SETTLE_POLL_MS` apart that agree,
2090
1706
  * with no navigation or fresh request in flight. At `SETTLE_CAP_MS` it gives up and adds the
2091
- * fields still changing to `volatile`, so a clock or an animation doesn't hold up every move.
1707
+ * fields that changed `VOLATILE_CHANGES` times or more to `volatile`, so a clock or an animation
1708
+ * doesn't hold up every move. A field that changed once (content that loaded just as the cap came,
1709
+ * behind requests that kept the page busy) is not volatile. With `anyRequest`, a request of any
1710
+ * age holds it too, as a first look waits for data a page fetches after `load`.
2092
1711
  */
2093
- async function settledState(session, volatile, left) {
1712
+ async function settledState(session, volatile, left, anyRequest = false) {
2094
1713
  const start = Date.now();
2095
1714
  const sleep = () => new Promise((resolve) => setTimeout(resolve, Math.max(0, Math.min(100, left()))));
1715
+ const changes = /* @__PURE__ */ new Map();
2096
1716
  let prev = await probePage(session);
2097
1717
  for (;;) {
2098
1718
  if (left() <= 0) return prev;
2099
1719
  await sleep();
2100
1720
  const next = await probePage(session);
2101
1721
  const moving = differing(prev, next, volatile);
2102
- if (!moving.length && !session.busy()) return next;
1722
+ for (const field of moving) changes.set(field, (changes.get(field) ?? 0) + 1);
1723
+ if (!moving.length && !session.busy(anyRequest)) return next;
2103
1724
  if (Date.now() - start >= 3e3 || left() <= 0) {
2104
- for (const field of moving) if (field !== "url" && field !== "focus") volatile.add(field);
1725
+ const marked = [...changes].filter(([field, n]) => n >= 2 && field !== "url" && field !== "focus").map(([field]) => field);
1726
+ for (const field of marked) volatile.add(field);
1727
+ if (marked.length) debugLog("check", `capture page keeps changing on its own: ${marked.join(", ")}`);
2105
1728
  return next;
2106
1729
  }
2107
1730
  prev = next;
@@ -2110,12 +1733,12 @@ async function settledState(session, volatile, left) {
2110
1733
  /** How long a settled page is watched for a change still to come after a move that ends its instruction. */
2111
1734
  const LATE_CHANGE_MS = 1e3;
2112
1735
  /**
2113
- * The page once a change that starts within `LATE_CHANGE_MS` of `settled` has settled too, or
1736
+ * The page once a change that starts within `windowMs` of `settled` has settled too, or
2114
1737
  * `settled`: an auth callback's redirect or a save's message often comes a beat after the
2115
1738
  * request that made it, and the next instruction's first look must not be the page before it.
2116
1739
  */
2117
- async function lateSettledState(session, settled, volatile, left) {
2118
- const until = Date.now() + Math.min(LATE_CHANGE_MS, left());
1740
+ async function lateSettledState(session, settled, volatile, left, windowMs = LATE_CHANGE_MS) {
1741
+ const until = Date.now() + Math.min(windowMs, left());
2119
1742
  while (Date.now() < until) {
2120
1743
  await new Promise((resolve) => setTimeout(resolve, Math.min(100, left())));
2121
1744
  if (differing(settled, await probePage(session), volatile).length || session.busy()) return settledState(session, volatile, left);
@@ -2173,9 +1796,12 @@ function onClock(session, clock) {
2173
1796
  },
2174
1797
  navigate: (url) => race(clock, () => session.navigate(url)),
2175
1798
  wait: (wait, ms, nav) => race(clock, () => session.wait(wait, ms, nav).catch(own)),
2176
- screenshot: (fullPage) => race(clock, () => session.screenshot(fullPage)),
1799
+ screenshot: (fullPage, clip) => race(clock, () => session.screenshot(fullPage, clip)),
1800
+ reveal: (action, page) => race(clock, () => session.reveal(action, page)),
2177
1801
  dispatch: (action, page) => race(clock, () => session.dispatch(action, page)),
2178
- busy: () => session.busy(),
1802
+ layout: () => race(clock, () => session.layout()),
1803
+ busy: (any) => session.busy(any),
1804
+ requests: () => session.requests(),
2179
1805
  dialogs: () => session.dialogs(),
2180
1806
  page: (origin) => session.page(origin)
2181
1807
  };
@@ -2273,29 +1899,107 @@ function moveFromTool(name, input) {
2273
1899
  */
2274
1900
  const normalizesPoints = (model) => model.slice(model.lastIndexOf("/") + 1).toLowerCase().startsWith("gemini-");
2275
1901
  const NORMALIZED = 1e3;
2276
- /** Scales an action's 0–1000 points to CSS pixels on a `page`-sized screenshot. */
2277
- function scalePoints(action, page) {
2278
- const x = (n) => Math.round(n * page.width / NORMALIZED);
2279
- const y = (n) => Math.round(n * page.height / NORMALIZED);
1902
+ /**
1903
+ * The most pixels and the longest edge of the screenshot a model sees. Anthropic's API scales a
1904
+ * larger image down and its models then answer in the smaller image's pixels, so reeval scales it
1905
+ * itself and maps the points back.
1906
+ */
1907
+ const SHOT_PIXELS = 115e4;
1908
+ const SHOT_EDGE = 1568;
1909
+ /** The scale that keeps a `width`×`height` image within `SHOT_PIXELS` and `SHOT_EDGE`. */
1910
+ function shotScale(width, height) {
1911
+ const fit = Math.min(1, Math.sqrt(SHOT_PIXELS / (width * height)), SHOT_EDGE / Math.max(width, height));
1912
+ return Math.floor(fit * 1e3) / 1e3;
1913
+ }
1914
+ /** What a model is shown of `layout`: the whole page, unless it is over `TALL_PAGE` windows tall. */
1915
+ function shotRegion(layout, window) {
1916
+ const height = Math.max(layout.height, window.height);
1917
+ if (height <= 2 * window.height) return {
1918
+ y: 0,
1919
+ width: window.width,
1920
+ height,
1921
+ partial: false
1922
+ };
1923
+ return {
1924
+ y: Math.min(Math.max(0, layout.scrollY), height - window.height),
1925
+ width: window.width,
1926
+ height: window.height,
1927
+ partial: true
1928
+ };
1929
+ }
1930
+ async function modelShot(session) {
1931
+ const layout = await session.layout();
1932
+ if (!layout) {
1933
+ const png = await session.screenshot(true);
1934
+ const size = pngSize(png);
1935
+ return {
1936
+ png,
1937
+ image: size,
1938
+ region: {
1939
+ y: 0,
1940
+ ...size
1941
+ },
1942
+ page: size,
1943
+ partial: false
1944
+ };
1945
+ }
1946
+ const { partial, ...region } = shotRegion(layout, session.window);
1947
+ const scale = shotScale(region.width, region.height);
1948
+ const png = await session.screenshot(!partial, {
1949
+ x: 0,
1950
+ ...region,
1951
+ scale
1952
+ });
1953
+ const page = {
1954
+ width: Math.max(layout.width, session.window.width),
1955
+ height: Math.max(layout.height, session.window.height)
1956
+ };
1957
+ return {
1958
+ png,
1959
+ image: pngSize(png),
1960
+ region,
1961
+ page,
1962
+ partial
1963
+ };
1964
+ }
1965
+ /**
1966
+ * An action's points, from the model's screenshot to page CSS pixels: 0–1000 across the image
1967
+ * for a model that normalizes, the image's pixels for any other. A point off the image is refused.
1968
+ */
1969
+ function toPagePoints(action, shot, normalized) {
1970
+ const { image, region } = shot;
1971
+ const span = normalized ? {
1972
+ width: NORMALIZED,
1973
+ height: NORMALIZED
1974
+ } : image;
1975
+ const off = (px, py) => px < 0 || py < 0 || px > span.width || py > span.height;
1976
+ const x = (n) => Math.round(n * region.width / span.width);
1977
+ const y = (n) => Math.round(region.y + n * region.height / span.height);
1978
+ const refuse = (px, py) => ({ refused: `(${px}, ${py}) is outside the screenshot, which is ${normalized ? `0-${NORMALIZED} on both axes` : `${image.width}×${image.height}`}` });
2280
1979
  switch (action.type) {
2281
1980
  case "click":
2282
1981
  case "hover":
2283
- case "scroll": return {
2284
- ...action,
2285
- x: x(action.x),
2286
- y: y(action.y)
2287
- };
2288
- case "drag": return {
2289
- ...action,
2290
- x: x(action.x),
2291
- y: y(action.y),
2292
- toX: x(action.toX),
2293
- toY: y(action.toY)
2294
- };
1982
+ case "scroll":
1983
+ if (off(action.x, action.y)) return refuse(action.x, action.y);
1984
+ return {
1985
+ ...action,
1986
+ x: x(action.x),
1987
+ y: y(action.y)
1988
+ };
1989
+ case "drag":
1990
+ if (off(action.x, action.y)) return refuse(action.x, action.y);
1991
+ if (off(action.toX, action.toY)) return refuse(action.toX, action.toY);
1992
+ return {
1993
+ ...action,
1994
+ x: x(action.x),
1995
+ y: y(action.y),
1996
+ toX: x(action.toX),
1997
+ toY: y(action.toY)
1998
+ };
2295
1999
  default: return action;
2296
2000
  }
2297
2001
  }
2298
- const systemPrompt = (normalized) => `You drive a web page from screenshots. Call one tool. ${normalized ? `Coordinates are normalized to 0-${NORMALIZED} on the full-page image: x and toX across its width, y and toY down its height. A scroll's dy is in CSS pixels.` : "Coordinates are CSS pixels on the full-page image."} Each turn you get the goal, what has focus, your earlier moves with what each did, and a fresh screenshot. Click a field before typing into it, and do not repeat a move that already worked. A dropdown (select) never opens in the screenshot: click it once, press ArrowDown or ArrowUp until it shows the option you want, then press Enter to choose it. On a click or key press after which nothing of the goal is left, such as the click that submits a form you have filled in, set completesGoal to true: reeval makes it and goes on to the next goal without asking you again. Call done when the goal is met. Do not mention CDP.`;
2002
+ const systemPrompt = (normalized) => `You drive a web page from screenshots. Call one tool. ${normalized ? `Coordinates are normalized to 0-${NORMALIZED} on the screenshot: x and toX across its width, y and toY down its height.` : "Coordinates are pixels on the screenshot, whose size each turn gives."} A scroll's dy is in page pixels, positive to scroll down. Each turn you get the goal, what has focus, your earlier moves with what each did, and a fresh screenshot. Click a field before typing into it, and do not repeat a move that already worked. A dropdown (select) never opens in the screenshot: click it once, press ArrowDown or ArrowUp until it shows the option you want, then press Enter to choose it. On a click or key press after which nothing of the goal is left, such as the click that submits a form you have filled in, set completesGoal to true: reeval makes it and goes on to the next goal without asking you again. A goal with more than one step (sign in and allow access, fill in and confirm) is complete only on its last step's move, not on a submit that leads to the next step. Call done when the goal is met. Do not mention CDP.`;
2299
2003
  const completesGoal = z.boolean().optional().describe("True only on the last move the goal needs: nothing of the goal is left after it.");
2300
2004
  const useTools = {
2301
2005
  click: tool({
@@ -2321,7 +2025,7 @@ const useTools = {
2321
2025
  })
2322
2026
  }),
2323
2027
  scroll: tool({
2324
- description: "Wheel-scroll a constrained scroller at (x, y).",
2028
+ description: "Wheel-scroll by dy page pixels with the pointer at (x, y): the page, or the scrolling box under the point.",
2325
2029
  inputSchema: z.object({
2326
2030
  x: z.number(),
2327
2031
  y: z.number(),
@@ -2416,7 +2120,8 @@ function moveKey({ final: _, ...action }) {
2416
2120
  /** Sets what `move` did, from its page before and `after`. */
2417
2121
  function settleMove(move, after, origin, volatile) {
2418
2122
  move.after = after;
2419
- const fields = move.before ? differing(move.before, after, volatile) : [];
2123
+ const ignored = move.scrolled ? /* @__PURE__ */ new Set([...volatile, "view"]) : volatile;
2124
+ const fields = move.before ? differing(move.before, after, ignored) : [];
2420
2125
  const notes = move.before ? describeChange(after, fields, origin) : [];
2421
2126
  for (const dialog of move.dialogs) notes.push(`the page opened ${dialog}, which reeval accepted`);
2422
2127
  move.changed = fields.length > 0 || move.dialogs.length > 0;
@@ -2433,6 +2138,23 @@ function stuckMoves(moves) {
2433
2138
  }
2434
2139
  return n;
2435
2140
  }
2141
+ /**
2142
+ * A focused date or time input, as the probe names it. Only these get the no-separators hint,
2143
+ * which other fields would take as theirs too, dropping the spaces and slashes a card needs.
2144
+ */
2145
+ const SEGMENTED = /^input\[(date|time|datetime-local|month|week)\]/;
2146
+ /**
2147
+ * How to type into a focused date or time input. Chrome's year segment takes up to six digits and
2148
+ * a month input's month segment waits for more, so a part followed by another needs ArrowRight.
2149
+ */
2150
+ function segmentedHint(focus) {
2151
+ const kind = SEGMENTED.exec(focus)?.[1];
2152
+ if (!kind) return void 0;
2153
+ const first = "Click its left edge, its first part, before typing.";
2154
+ if (kind === "datetime-local") return `A date and time field takes the date's digits with no separators, then ArrowRight, then the time's: type 11142026, press ArrowRight, type 0730PM. ${first}`;
2155
+ if (kind === "month") return `A month field takes the month's number, then ArrowRight, then the year: type 11, press ArrowRight, type 2026. ${first}`;
2156
+ return `A date or time field takes its digits in the order it shows them, with no separators: 11142026 for mm/dd/yyyy, 0730PM for --:-- --, 462026 for Week --, ----. ${first}`;
2157
+ }
2436
2158
  /** What the model reads about the page now: where it is and what has focus. */
2437
2159
  function stateLines(now, origin, volatile) {
2438
2160
  const lines = [];
@@ -2442,14 +2164,24 @@ function stateLines(now, origin, volatile) {
2442
2164
  else if (now.focus) {
2443
2165
  lines.push(`Focused: ${now.focus}${now.value ? `, holding ${JSON.stringify(now.value)}` : ""}.`);
2444
2166
  if (now.focus.startsWith("select")) lines.push("A dropdown never opens in the screenshot: press ArrowDown or ArrowUp to the option, then Enter; it holds the new option only after Enter.");
2167
+ const hint = segmentedHint(now.focus);
2168
+ if (hint) lines.push(hint);
2445
2169
  }
2446
2170
  if (volatile.has("text") || volatile.has("nodes") || volatile.has("view")) lines.push("Parts of the page keep changing on their own, so the effects below leave them out.");
2447
2171
  return lines;
2448
2172
  }
2449
2173
  /** The goal, where the journey is, the page now, and the moves so far with what each did. */
2450
- function goalPrompt(step, earlier, now, moves, origin, volatile = /* @__PURE__ */ new Set()) {
2174
+ function goalPrompt(step, earlier, now, moves, origin, volatile = /* @__PURE__ */ new Set(), view = {}) {
2451
2175
  const lines = [`Goal: ${step.goal}`];
2452
- if (step.total > 1) lines.push(`This is instruction ${step.index} of ${step.total}.${earlier.length ? ` Already done: ${earlier.map((g) => JSON.stringify(g)).join(", ")}.` : ""}`);
2176
+ const quoted = (goals) => goals.map((g) => JSON.stringify(g)).join(", ");
2177
+ if (step.total > 1) {
2178
+ const done = earlier.length ? ` Already done: ${quoted(earlier)}.` : "";
2179
+ const later = view.later?.length ? ` Still to come, not part of this goal: ${quoted(view.later)}.` : "";
2180
+ lines.push(`This is instruction ${step.index} of ${step.total}.${done}${later}`);
2181
+ }
2182
+ const { shot } = view;
2183
+ if (shot && !view.normalized) lines.push(`The screenshot is ${shot.image.width}×${shot.image.height} pixels.`);
2184
+ if (shot?.partial) lines.push(`The page is ${shot.page.height} px tall, more than the screenshot shows: it shows the window, scrolled ${shot.region.y} px down. Scroll to see the rest.`);
2453
2185
  lines.push(...stateLines(now, origin, volatile));
2454
2186
  if (!moves.length) {
2455
2187
  lines.push("You have made no moves for this goal yet.");
@@ -2458,22 +2190,24 @@ function goalPrompt(step, earlier, now, moves, origin, volatile = /* @__PURE__ *
2458
2190
  lines.push("Your moves for this goal so far, oldest first. The screenshot shows the page now.");
2459
2191
  moves.forEach((m, i) => {
2460
2192
  const effect = m.refused ? `not made: ${m.refused}` : m.effect ?? "";
2461
- lines.push(`${i + 1}. ${m.said}${effect ? ` → ${effect}` : ""}`);
2193
+ lines.push(`${i + 1}. ${m.said}${m.target ? ` on ${m.target}` : ""}${effect ? ` → ${effect}` : ""}`);
2462
2194
  });
2195
+ if (moves.at(-1)?.unproven) lines.push(`Move ${moves.length} was marked completesGoal, but it sent no request and opened no page or dialog, so the goal goes on. If the goal is met, call done; if that move only opened a step on the way, such as a confirmation, finish it.`);
2463
2196
  if (stuckMoves(moves) >= 2) lines.push("Your last moves repeated the same action and nothing changed. Do not repeat it: if the goal is met, call done; otherwise try a different action.");
2464
2197
  const from = pathOf(moves.find((m) => m.before)?.before?.url, origin);
2465
2198
  const at = pathOf(now.url, origin);
2466
2199
  if (from && at && from !== at) lines.push(`Your moves took the page from ${from} to ${at}. If they did what the goal asks, call done: a goal's "once", "if" or "when" says where it starts, so do not undo them to get back there.`);
2467
2200
  return lines.join("\n");
2468
2201
  }
2469
- async function runModelGoal(session, { step, earlier, origin, modelName, clock, volatile, pristine, loadModel }) {
2202
+ async function runModelGoal(session, { step, earlier, origin, modelName, clock, volatile, pristine, later, loadModel }) {
2470
2203
  const { goal } = step;
2471
2204
  const model = await loadModel(modelName);
2472
2205
  const normalized = normalizesPoints(modelName);
2473
2206
  const made = [];
2474
2207
  let dispatched = 0;
2475
2208
  let usage = null;
2476
- let now = await probePage(session);
2209
+ let now = pristine ? await settledState(session, volatile, clock.remaining, true) : await probePage(session);
2210
+ const quiet = pristine && !session.busy(true) ? session.requests() : void 0;
2477
2211
  let stale = 0;
2478
2212
  const trail = {
2479
2213
  origin,
@@ -2490,18 +2224,19 @@ async function runModelGoal(session, { step, earlier, origin, modelName, clock,
2490
2224
  check(clock);
2491
2225
  const last = made.at(-1);
2492
2226
  if (last?.after) {
2493
- const late = await probePage(session);
2227
+ let late = await probePage(session);
2228
+ if (differing(last.after, late, volatile).length || session.busy()) late = await settledState(session, volatile, clock.remaining);
2494
2229
  last.dialogs.push(...session.dialogs());
2495
2230
  if (differing(last.after, late, volatile).length || last.dialogs.length) settleMove(last, late, origin, volatile);
2496
2231
  now = late;
2497
2232
  }
2498
- if (stuckMoves(made) >= 5) throw new Error(`c.capture() instruction ${step.index} of ${step.total} ${JSON.stringify(goal)} repeated ${last?.said} 5 times and nothing changed`);
2499
- const ephemeral = await session.screenshot(true);
2500
- const page = pngSize(ephemeral);
2233
+ if (stuckMoves(made) >= 5) throw new Error(`c.capture() instruction ${step.index} of ${step.total} ${JSON.stringify(goal)} repeated ${last?.said}${last?.target ? ` on ${last.target}` : ""} 5 times and nothing changed`);
2234
+ const shot = await modelShot(session);
2235
+ const { png: ephemeral, ...seen } = shot;
2501
2236
  debugTrace("check", "capture-shot", {
2502
2237
  goal,
2503
2238
  bytes: ephemeral.length,
2504
- page,
2239
+ ...seen,
2505
2240
  url: now.url
2506
2241
  }, false);
2507
2242
  const signal = AbortSignal.timeout(check(clock));
@@ -2514,7 +2249,11 @@ async function runModelGoal(session, { step, earlier, origin, modelName, clock,
2514
2249
  role: "user",
2515
2250
  content: [{
2516
2251
  type: "text",
2517
- text: goalPrompt(step, earlier, now, made, origin, volatile)
2252
+ text: goalPrompt(step, earlier, now, made, origin, volatile, {
2253
+ shot: seen,
2254
+ normalized,
2255
+ later
2256
+ })
2518
2257
  }, {
2519
2258
  type: "file",
2520
2259
  mediaType: "image/png",
@@ -2536,10 +2275,12 @@ async function runModelGoal(session, { step, earlier, origin, modelName, clock,
2536
2275
  const said = `${call.toolName} ${JSON.stringify(input)}`;
2537
2276
  const fresh = await probePage(session);
2538
2277
  const opened = session.dialogs();
2539
- const moved = differing(now, fresh, volatile);
2540
- if (!last && pristine) {
2278
+ let moved = differing(now, fresh, volatile);
2279
+ if (!last && quiet !== void 0 && !opened.length && session.requests() === quiet) {
2541
2280
  for (const f of moved) if (f !== "url" && f !== "focus") volatile.add(f);
2542
- } else if ((moved.length || opened.length) && stale < STALE_ASKS) {
2281
+ moved = differing(now, fresh, volatile);
2282
+ }
2283
+ if ((moved.length || opened.length) && stale < STALE_ASKS) {
2543
2284
  stale++;
2544
2285
  if (last && !last.refused) {
2545
2286
  last.dialogs.push(...opened);
@@ -2550,9 +2291,10 @@ async function runModelGoal(session, { step, earlier, origin, modelName, clock,
2550
2291
  continue;
2551
2292
  }
2552
2293
  stale = 0;
2553
- let asks = actionFromTool(call.toolName, input);
2294
+ const tool = actionFromTool(call.toolName, input);
2295
+ let asks = "refused" in tool ? tool : toPagePoints(tool, shot, normalized);
2554
2296
  if (!("refused" in asks) && asks.type === "type" && now.editable === false) asks = { refused: "nothing that takes text is focused; click a field first" };
2555
- const logged = !("refused" in asks) && asks.type === "type" && now.focus?.includes("[password]") ? `type ${JSON.stringify({
2297
+ const logged = !("refused" in asks) && asks.type === "type" && (now.focus?.includes("[password]") || now.editable === null) ? `type ${JSON.stringify({
2556
2298
  ...input,
2557
2299
  text: "•".repeat(String(input.text ?? "").length)
2558
2300
  })}` : said;
@@ -2567,13 +2309,13 @@ async function runModelGoal(session, { step, earlier, origin, modelName, clock,
2567
2309
  });
2568
2310
  continue;
2569
2311
  }
2570
- const chosen = normalized ? scalePoints(asks, page) : asks;
2312
+ const page = shot.page;
2571
2313
  debugLog("check", `capture use ${logged} on ${JSON.stringify(goal)} · ${latency}`);
2572
2314
  debugTrace("check", "capture-use", {
2573
2315
  goal,
2574
- action: chosen,
2316
+ action: asks,
2575
2317
  page
2576
- }, `capture use ${chosen.type}`);
2318
+ }, `capture use ${asks.type}`);
2577
2319
  if (asks.type === "done") return {
2578
2320
  moves: dispatched,
2579
2321
  usage,
@@ -2586,18 +2328,30 @@ async function runModelGoal(session, { step, earlier, origin, modelName, clock,
2586
2328
  dialogs: []
2587
2329
  };
2588
2330
  made.push(move);
2589
- await session.dispatch(chosen, page);
2331
+ let sent = session.requests();
2332
+ if (await session.reveal(asks, page)) {
2333
+ move.before = await settledState(session, volatile, clock.remaining);
2334
+ sent = session.requests();
2335
+ }
2336
+ const landed = await session.dispatch(asks, page);
2337
+ if (landed?.target) move.target = landed.target;
2338
+ if (landed?.scrolled) move.scrolled = true;
2590
2339
  dispatched++;
2591
2340
  now = await settledState(session, volatile, clock.remaining);
2341
+ if (asks.type === "type" || asks.type === "hover") now = await lateSettledState(session, now, volatile, clock.remaining, 700);
2592
2342
  move.dialogs.push(...session.dialogs());
2593
2343
  settleMove(move, now, origin, volatile);
2594
2344
  if (asks.final && move.changed) {
2595
- await lateSettledState(session, now, volatile, clock.remaining);
2596
- return {
2597
- moves: dispatched,
2598
- usage,
2599
- ended: "final"
2600
- };
2345
+ const left = now.url !== move.before?.url;
2346
+ if (session.requests() > sent || left || move.dialogs.length) {
2347
+ await lateSettledState(session, now, volatile, clock.remaining);
2348
+ return {
2349
+ moves: dispatched,
2350
+ usage,
2351
+ ended: "final"
2352
+ };
2353
+ }
2354
+ move.unproven = true;
2601
2355
  }
2602
2356
  }
2603
2357
  clock.step = {
@@ -2680,6 +2434,7 @@ async function runJourney(raw, url, options) {
2680
2434
  clock,
2681
2435
  volatile,
2682
2436
  pristine: moves === 0,
2437
+ later: goals.slice(stringIndex + 1),
2683
2438
  loadModel: options.loadModel
2684
2439
  });
2685
2440
  usage = addUsage(usage, goal.usage);
@@ -2751,30 +2506,54 @@ async function acceptIntoSnapshot(sandbox, path, signal) {
2751
2506
  const r = await sandbox.execOwn(`${snapshotEnv(sandbox)} && export GIT_LITERAL_PATHSPECS=1 && ${GIT} add -f -- ${quoted} && ${next} ${GIT} read-tree HEAD && ${next} ${GIT} add -f -- ${quoted} && tree=$(${next} ${GIT} write-tree) && rm -f "$GIT_DIR/next-index" && ${RESET_HEAD}`, { signal });
2752
2507
  if (r.exitCode !== 0) throw new InfraError(`Failed to keep ${path} out of the diff: ${r.stderr.trim()}`);
2753
2508
  }
2754
- async function diffSinceSnapshot(sandbox, signal) {
2755
- const env = `${snapshotEnv(sandbox)} && ${GIT} add -A && `;
2756
- const patch = await sandbox.execOwn(`${env}${GIT} diff --cached --binary HEAD`, { signal });
2757
- const names = await sandbox.execOwn(`${env}${GIT} diff --cached --name-status --no-renames -z HEAD`, { signal });
2758
- if (patch.exitCode !== 0 || names.exitCode !== 0) throw new InfraError(`Failed to diff the workspace: ${patch.stderr || names.stderr}`);
2509
+ async function rawChanges(sandbox, signal) {
2510
+ const r = await sandbox.execOwn(`${snapshotEnv(sandbox)} && ${GIT} add -A && ${GIT} diff --cached --raw --no-renames --no-abbrev -z HEAD`, { signal });
2511
+ if (r.exitCode !== 0) throw new InfraError(`Failed to diff the workspace: ${r.stderr}`);
2759
2512
  const status = {
2760
2513
  A: "added",
2761
2514
  M: "modified",
2762
2515
  D: "deleted"
2763
2516
  };
2764
- const fields = names.stdout.split("\0");
2765
- const files = [];
2517
+ const fields = r.stdout.split("\0");
2518
+ const changes = [];
2766
2519
  for (let i = 0; i + 1 < fields.length; i += 2) {
2767
- const code = fields[i];
2768
- files.push({
2520
+ const [, mode = "", , id = "", code = ""] = fields[i].split(" ");
2521
+ changes.push({
2769
2522
  path: fields[i + 1],
2770
- status: status[code[0]] ?? "modified"
2523
+ status: status[code[0]] ?? "modified",
2524
+ blob: `${mode} ${id}`
2771
2525
  });
2772
2526
  }
2527
+ return changes;
2528
+ }
2529
+ const blobsOf = (changes) => new Map(changes.map((c) => [c.path, c.blob]));
2530
+ async function diffSinceSnapshot(sandbox, signal) {
2531
+ const patch = await sandbox.execOwn(`${snapshotEnv(sandbox)} && ${GIT} add -A && ${GIT} diff --cached --binary HEAD`, { signal });
2532
+ if (patch.exitCode !== 0) throw new InfraError(`Failed to diff the workspace: ${patch.stderr}`);
2533
+ const changes = await rawChanges(sandbox, signal);
2534
+ const files = changes.map(({ path, status }) => ({
2535
+ path,
2536
+ status
2537
+ }));
2773
2538
  return {
2774
- patch: patch.stdout,
2775
- files
2539
+ diff: {
2540
+ patch: patch.stdout,
2541
+ files
2542
+ },
2543
+ blobs: blobsOf(changes)
2776
2544
  };
2777
2545
  }
2546
+ /** The workspace's `Blobs` now, to tell later which files a turn changed. */
2547
+ async function workspaceBlobs(sandbox, signal) {
2548
+ return blobsOf(await rawChanges(sandbox, signal));
2549
+ }
2550
+ /**
2551
+ * Paths whose content or mode differs between two `Blobs`: a file changed, created or deleted
2552
+ * between them.
2553
+ */
2554
+ function changedBetween(before, after) {
2555
+ return [.../* @__PURE__ */ new Set([...after.keys(), ...before.keys()])].filter((p) => before.get(p) !== after.get(p));
2556
+ }
2778
2557
  /** Every file in the workspace as git sees it (its `.gitignore` applies), sorted. */
2779
2558
  async function workspaceFiles(sandbox, signal) {
2780
2559
  const r = await sandbox.execOwn(`${snapshotEnv(sandbox)} && ${GIT} add -A && ${GIT} ls-files -z`, { signal });
@@ -2851,7 +2630,7 @@ function createChecks(a) {
2851
2630
  function exec(command, options) {
2852
2631
  const problem = options === void 0 ? void 0 : execOptionsProblem(options);
2853
2632
  if (problem) return Promise.reject(new UsageError(problem));
2854
- if (options?.background) return import("./capture-BT2fAmpZ.js").then(({ startBackground }) => startBackground(a, command, "c.exec({ background: true })"));
2633
+ if (options?.background) return import("./capture-DoxFUN3J.js").then(({ startBackground }) => startBackground(a, command, "c.exec({ background: true })"));
2855
2634
  const run = execForeground(command, options?.retries ?? 0, options?.interval ?? 1e3);
2856
2635
  return Object.defineProperty(run, SUBJECT, { value: command });
2857
2636
  }
@@ -2928,21 +2707,21 @@ async function startBackground(a, command, who, extraEnv = {}) {
2928
2707
  }
2929
2708
  async function launch(a, command, who, extraEnv) {
2930
2709
  const box = await sandboxFor(a, who);
2931
- const docker = a.spec.sandbox.kind === "docker";
2710
+ const { processTable } = capabilitiesOf(a.spec.sandbox);
2932
2711
  const tag = randomUUID();
2933
2712
  const log = `${BG_LOG}-${tag.slice(0, 8)}.log`;
2934
- const wrapped = `${docker ? "bash" : "sh"} -c ${shellQuote(command)} >${log} 2>&1 & echo $$ $!`;
2713
+ const wrapped = `${processTable ? "bash" : "sh"} -c ${shellQuote(command)} >${log} 2>&1 & echo $$ $!`;
2935
2714
  const r = await asCheck(a, () => box.exec(wrapped, {
2936
2715
  signal: a.signal,
2937
2716
  env: {
2938
2717
  ...a.env?.checkVars ?? {},
2939
2718
  ...extraEnv,
2940
- ...docker ? { [BG_TAG]: tag } : {}
2719
+ ...processTable ? { [BG_TAG]: tag } : {}
2941
2720
  }
2942
2721
  }));
2943
2722
  const [group = "", pid = ""] = r.stdout.trim().split(/\s+/).slice(-2);
2944
2723
  if (!/^\d+$/.test(pid) || !/^\d+$/.test(group)) throw new Error(`c.exec({ background: true }) did not start (no pid):\n${(r.stderr || r.stdout).trim()}`);
2945
- const tree = docker ? `for e in /proc/[0-9]*/environ; do grep -qsxzF ${shellQuote(`${BG_TAG}=${tag}`)} "$e" && kill -9 "$(basename "$(dirname "$e")")" 2>/dev/null; done` : process.platform === "win32" ? msysTreeKill(pid, group) : `kill -9 -${group} 2>/dev/null`;
2724
+ const tree = processTable ? `for e in /proc/[0-9]*/environ; do grep -qsxzF ${shellQuote(`${BG_TAG}=${tag}`)} "$e" && kill -9 "$(basename "$(dirname "$e")")" 2>/dev/null; done` : process.platform === "win32" ? msysTreeKill(pid, group) : `kill -9 -${group} 2>/dev/null; tree() { kill -STOP "$1" 2>/dev/null; for c in $(pgrep -P "$1" 2>/dev/null); do tree "$c"; done; kill -9 "$1" 2>/dev/null; }; tree ${pid}`;
2946
2725
  let killed = false;
2947
2726
  const handle = { async kill() {
2948
2727
  if (killed) return;
@@ -2961,12 +2740,14 @@ async function launch(a, command, who, extraEnv) {
2961
2740
  * the one port that wasn't listening before it started, which it records.
2962
2741
  */
2963
2742
  async function serveCommand(a, command, port) {
2964
- const want = port ?? await allocatePort();
2965
2743
  const box = await sandboxFor(a, "c.serve()");
2966
- const tables = a.spec.sandbox.kind !== "fake";
2967
- const look = (pid) => untraced(() => box.exec(probeScript(pid, tables), { signal: a.signal })).then((r) => parseProbe(r.stdout));
2744
+ const source = capabilitiesOf(a.spec.sandbox).listeners;
2745
+ const onHost = source === "host";
2746
+ const look = (pid) => untraced(() => box.exec(probeScript(pid, source), { signal: a.signal })).then((r) => parseProbe(r.stdout));
2968
2747
  const first = await look();
2969
2748
  const before = new Set(first.proc ? first.listeners.map((l) => l.port) : []);
2749
+ const taken = async (p) => first.proc ? before.has(p) : onHost && await hostListening(p) !== void 0;
2750
+ const want = await servePort(command, port, allocatePort, taken);
2970
2751
  const { handle, pid, log } = await launch(a, command, "c.serve()", { PORT: String(want) });
2971
2752
  const found = await awaitListening(command, {
2972
2753
  want,
@@ -2975,7 +2756,7 @@ async function serveCommand(a, command, port) {
2975
2756
  signal: a.signal,
2976
2757
  probe: () => look(pid),
2977
2758
  output: async () => (await box.exec(`tail -c 65536 ${log} 2>/dev/null`)).stdout,
2978
- ...tables ? { hostListening: async () => "" } : {}
2759
+ ...onHost ? {} : { hostListening: async () => "" }
2979
2760
  }).catch(async (error) => {
2980
2761
  await handle.kill();
2981
2762
  throw error;
@@ -3209,6 +2990,6 @@ async function writeCaptureSidecars(stagingDir, recordFile, blobs, pages) {
3209
2990
  for (const [name, png] of blobs) await writeFile(join(dir, `${name}.png`), png);
3210
2991
  for (const [name, json] of pages) await writeFile(join(dir, `${name}.capture.json`), json);
3211
2992
  }
3212
- export { writeCaptureSidecars as a, sandboxFor as c, workspaceFiles as d, fakeInstructions as f, startBackground as i, diffSinceSnapshot as l, msysTreeKill as n, asCheck as o, attemptRequestProblem as p, serveCommand as r, createChecks as s, capturePage as t, snapshot as u };
2993
+ export { writeCaptureSidecars as a, sandboxFor as c, snapshot as d, workspaceBlobs as f, startBackground as i, changedBetween as l, fakeInstructions as m, msysTreeKill as n, asCheck as o, workspaceFiles as p, serveCommand as r, createChecks as s, capturePage as t, diffSinceSnapshot as u };
3213
2994
 
3214
- //# sourceMappingURL=capture-Bdcx9Gap.js.map
2995
+ //# sourceMappingURL=capture-iBzFiC0j.js.map